hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Web Hosting : Web Hosting Tutorials : Viewing Webalizer through public_html (2 ways)
Reply

Web Hosting Tutorials Tutorials related to shared hosting.
Forum Jump

Viewing Webalizer through public_html (2 ways)

Reply Post New Thread In Web Hosting Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 02-10-2007, 09:44 PM
page-zone page-zone is offline
Web Host
 
Join Date: Jun 2002
Posts: 1,787

Viewing Webalizer through public_html (2 ways)


We get a lot of requests by end users for the ability to view cPanel's Webalizer stats without having to log into cPanel. Have always instructed people to create a symlink to the Webalizer folder using SSH, but not all users have ssh so we created this script which will do it for them using perl.

Putting it out here for anyone to use if they wish. Following is the code, provided as is with no support.

Code:
#!/usr/bin/perl

use CGI::Carp "fatalsToBrowser";
    my $Realize=0.1
;


$|=1;

use CGI qw(:all);

$JSCRIPT=<<EOF;

function verify(form)
{
	if (document.myform.user.value == "")   
	{	
	    alert ("Please, enter user name");
	    return false;
	}
	if (document.myform.directoryname.value == "")   
	{	
	    alert ("Please, enter directory name");
	    return false;
	}
	if (document.myform.domain.value == "")   
	{	
	    alert ("Please, enter domain name");
	    return false;
	}
   
}

function prev(form)
{  
    //location.href=document.myform.prev_path.value;
      history.go(-1);
      return true;
}

EOF
    ;




#====================================
$q=new CGI; 


$user=$q->param('user');
$directoryname=$q->param('directoryname');
$domain=$q->param('domain');

# if press 'More' button then go to Second step:
$more=$q->param('more');


$prev_path="http://your_path_for_back_from_this_form";



print $q->redirect($prev_path) if($q->param('back'));



$app_error=$q->param('app_error');

#
#Flags to determine to what page to go.
#
    if($app_error eq "YES")
    {
	$switch=1;
    }
    
    else
    {
	$switch=0;
    }




$JSbegin='';
#$JSbegin.=q{myform.user.value = '';}		if();
#$JSbegin.=q{myform.directoryname.value = '';}	if();
#$JSbegin.=q{myform.domain.value = '';}		if();
$JSbegin.=q{myform.directoryname.focus()};


print $q->header;
print $q->start_html(-title=>'PZ make webalizer publicly viewable - tool',-script=>$JSCRIPT, -onLoad=>$JSbegin);

print $q->h1({-align=>CENTER},'Make Webalizer Publicly Viewable - Tool');
print $q->hr({-width=>"50%", -align=>CENTER, -size=>4});

# if press 'More' then do action:
if($more and $user and $directoryname and $domain)
{
    do_action();


	if($app_error eq "NO"){

		print $q->table({-align=>LEFT,-width=>'100%'},
		Tr({-align=>LEFT, -valign=>BOTTOM},
	   	
		td($q->button(-name=>'back', -value=>' Back ',-onClick=>"return prev(this.form)")),

		td($q->font({-size=>3},"Done"),
		)

		));

	} else {

		print $q->table({-align=>LEFT,-width=>'100%'},
		Tr({-align=>LEFT, -valign=>BOTTOM},

		td($q->button(-name=>'back', -value=>' Back ',-onClick=>"return prev(this.form)"))
		


		));

	}
}
else
{

 print $q->start_form(-name=>myform,-action=>$action, -onSubmit=>"return verify(this.form)");

 print $q->dl($q->font({-size=>3},"Begin below")),

 $q->p,


 $q->dd($q->font({-size=>3},"FTP username for this domain :")),
 $q->dd($q->textfield (-size=>9, -maxlength=>9, -name=>'user', -value=>$user)),
 $q->p;  
  

 print $q->dd($q->font({-size=>3},"What do you want to call the directory? <br>e.g. wblzer will be then accessed at yourdomain.tld/wblzer:"));
 print $q->dd($q->textfield (-size=>30, -maxlength=>30, -name=>directoryname, -value=>$directoryname));

 print $q->dd($q->font({-size=>3},"This field for domain name (type with .tld):"));
 print $q->dd($q->textfield (-size=>30, -maxlength=>30, -name=>domain, -value=>$domain));



 print $q->hidden(-name=>prev_path, -value=>$prev_path);

 print $q->hidden(-name=>app_error,-value=>$app_error);



 print $q->p, 
 $q->p;

###
 print $q->table({-align=>LEFT,-width=>'100%'},
		Tr({-align=>LEFT, -valign=>BOTTOM},

		   	td($q->button(-name=>'back', -value=>' Back ',-onClick=>"return prev(this.form)")),

			td($q->submit(-name=>'more', -value=>' Start '))

		)
 );


 print $q->endform;

}
print $q->end_html;



#==================================
sub do_action
{ 
 local($r)=system("chmod 755 /home/$user/tmp");
 if (! $r) { 
      print "Successfull chmod 755 /home/$user/tmp<br>";
      local($r)=system("chmod 755 /home/$user/tmp/webalizer");
      if (! $r) { 
	      print "Successfull chmod 755 /home/$user/tmp/webalizer<br>";
	      local($r)=system("ln -s /home/$user/tmp/webalizer /home/$user/public_html/$directoryname");
	      if (! $r) { 
		      print "Successfull ln -s /home/$user/tmp/webalizer /home/$user/public_html/$directoryname<br>";
		      $app_error="NO"
	      } else {
		      print "Unsuccessfull ln -s /home/$user/tmp/webalizer /home/$user/public_html/$directoryname<br>";
		      $app_error="YES"
	      }

      } else {
	      print "Unsuccessfull chmod 755 /home/$user/tmp/webalizer is the directory there?<br>";
	      $app_error="YES"
      }	

 } else {
      print "Unsuccessfull chmod 755 /home/$user/tmp be sure to give me the correct ftp username for this domain!<br>";
      $app_error="YES"
 }


##========================================================##

}


############################################################
SSH method is:

Code:
chmod 755 /home/user/tmp
chmod 755 /home/user/tmp/webalizer
ln -s /home/user/tmp/webalizer /home/user/public_html/wblzer
Replace "user" with actual user

Reply With Quote


Sponsored Links
  #2  
Old 02-10-2007, 11:26 PM
bear bear is online now
Community Leader
 
Join Date: Oct 2002
Location: cognito
Posts: 17,307
An even simpler version is; in .htaccesss (does require login), add this:
Redirect /visitors https://ip.address.goes.here:2083/frontend/x2/stats/webalizer.html

Replace "visitors" with the word to redirect, IP with the right one and "x2" with whatever skin you're using.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Emerging Tech - HTML5 Blog 2013-05-14 14:46:22
AWS and GlowTouch Technologies Talk Public Cloud Opportunities in Upcoming Webinar Blog 2013-05-09 22:42:31
Learn to Grow Your Hosting Business with Public Cloud in GlowTouch Technologies, AWS Webinar Blog 2013-04-23 10:19:19
How Website Design Affects Conversion Rates Blog 2012-09-28 13:52:36
Asigra Partner Summit 2012: Making Money Off Public Cloud Features with Gary Hocking of NetApp Web Hosting News 2012-06-12 16:48:10


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?