Tips & tricks & hacks: phpWebStats Thursday, 21 November 2024 @ 05:10:58 Am

My changes to Holger & Reimar's stock phpWebStat, to tweak it to suit my needs

(these are just notes to myself)

Although the below changes/hacks work for me, I make no guarantees as to your results... any disasters that occur are not my fault. Use at your own risk... do a backup before making changes to your own files.

 Hack #   Purpose (more-or-less in alphabetical order)   Affected file   Change   Contributor 

 

1

Colour

To select the Colour that phpWebStat will be displayed in:

Default colour-scheme (for all my websites except TNG)
Mousegray colour-scheme (TNG websites, to match my TNG template)

 

n/a
 In phpWebStat 
 General Settings
 Display tab
  • Colorscheme:  Standard (for all my websites except TNG)
• Colorscheme: Mousegray (for all my TNG websites, to match my TNG template)
n/a

 

2

Delimiters

To change the delimiters, from a dot to a comma:

• Example: from 123.456 (as used in Europe, etc.)
to 123,456 (as used in North America, etc.)
func/func_display.php
 • The line numbers below are correct as of phpWebStat v20.01, but might change in future releases.

1.)    Look for all lines with number_format   (Line  72:
(Line  73:
(Line  74:
(Line  75:
(Line  76:
(Line  77:
(Line  78:
(Line  79:

(Line  84:

(Line 303:

(Line 364:


(Line 365:
<td class="module-overview-hits">'.number_format ( ($module1+$stat_add_visitors) , 0 , "," , "." ).'</td>
<td class="module-overview-hits">'.number_format ( $module2 , 0 , "," , "." ).'</td>
<td class="module-overview-hits">'.number_format ( $module3 , 0 , "," , "." ).'</td>
<td class="module-overview-hits">'.number_format ( $module4 , 0 , "," , "." ).'</td>
<td class="module-overview-hits">'.number_format ( $module5 , 0 , "," , "." ).'</td>
<td class="module-overview-hits">'.number_format ( $module6 , 0 , "," , "." ).'</td>
<td class="module-overview-hits">'.number_format ( $module7 , 0 , "," , "." ).'</td>
<td class="module-overview-hits">'.number_format ( $module8 , 0 , "," , "." ).'</td>

<div style="width:35%; float:right; text-align:right">'.number_format ( $module9 , 0 , "," , "." ).'</div>

echo '<td class="module-hits">'.number_format ( $value , 0 , "," , "." ).'</td>';

<div style="width:30%; float:left; text-align:left">('.number_format ( array_sum ( $module_data ) , 0 , "," , "." ).
'/'.number_format ( $value_max , 0 , "," , "." ).')</div>

<div style="width:20%; float:right; text-align:right">('.number_format ( $count , 0 , "," , "." ).
'/'.number_format ( $count_all , 0 , "," , "." ).')</div>



 
 Remove all the white characters above, 
 so all that is left is: 
  (Line  72:
(Line  73:
(Line  74:
(Line  75:
(Line  76:
(Line  77:
(Line  78:
(Line  79:

(Line  84:

(Line 303:

(Line 364:


(Line 365:
<td class="module-overview-hits">'.number_format ( ($module1+$stat_add_visitors) ).'</td>
<td class="module-overview-hits">'.number_format ( $module2 ).'</td>
<td class="module-overview-hits">'.number_format ( $module3 ).'</td>
<td class="module-overview-hits">'.number_format ( $module4 ).'</td>
<td class="module-overview-hits">'.number_format ( $module5 ).'</td>
<td class="module-overview-hits">'.number_format ( $module6 ).'</td>
<td class="module-overview-hits">'.number_format ( $module7 ).'</td>
<td class="module-overview-hits">'.number_format ( $module8 ).'</td>

<div style="width:35%; float:right; text-align:right">'.number_format ( $module9 ).'</div>

echo '<td class="module-hits">'.number_format ( $value ).'</td>';

<div style="width:30%; float:left; text-align:left">('.number_format ( array_sum ( $module_data ) ).
'/'.number_format ( $value_max ).')</div>

<div style="width:20%; float:right; text-align:right">('.number_format ( $count ).
'/'.number_format ( $count_all ).')</div>

 • Lines 364 and 365 in the 2 sections above are shown here as being wrapped (to conserve space), but in the file they are actually all on 1 single line.
Reimar

(Forums)
counter.php

 • The line numbers below are correct as of phpWebStat v20.01, but might change in future releases.

2.)    Look for all lines with number_format   (Line 134:


(Line 135:


(Line 136:


(Line 137:


(Line 138:


(Line 139:


(Line 140:


(Line 141:


(Line 409:
if ( $counter_display_show_visitors_online == 1 ) { echo '<div class="row"><div class="data">'.$text1.'</div>
   <div class="hits">'.number_format ( $module1 , 0 , "," , "." ).'</div></div>'."\n"; }

if ( $counter_display_show_today == 1 ) { echo '<div class="row"><div class="data">'.$text2.'</div>
   <div class="hits">'.number_format ( $module2 , 0 , "," , "." ).'</div></div>'."\n"; }

if ( $counter_display_show_yesterday == 1 ) { echo '<div class="row"><div class="data">'.$text3.'</div>
   <div class="hits">'.number_format ( $module3 , 0 , "," , "." ).'</div></div>'."\n"; }

if ( $counter_display_show_this_month == 1 ) { echo '<div class="row"><div class="data">'.$text4.'</div>
   <div class="hits">'.number_format ( $module4 , 0 , "," , "." ).'</div></div>'."\n"; }

if ( $counter_display_show_last_month == 1 ) { echo '<div class="row"><div class="data">'.$text5.'</div>
   <div class="hits">'.number_format ( $module5 , 0 , "," , "." ).'</div></div>'."\n"; }

if ( $counter_display_show_max == 1 ) { echo '<div class="row"><div class="data">'.$text6.'</div>
   <div class="hits">'.number_format ( $module6 , 0 , "," , "." ).'</div></div>'."\n"; }

if ( $counter_display_show_average == 1 ) { echo '<div class="row"><div class="data">'.$text7.'</div>
   <div class="hits">'.number_format ( $module7 , 0 , "," , "." ).'</div></div>'."\n"; }

if ( $counter_display_show_total == 1 ) { echo '<div class="row"><div class="data">'.$text8.'</div>
   <div class="hits">'.number_format ( ($module8+$counter_add_visitors) , 0 , "," , "." ).'</div></div>'."\n"; }

{ $pageimpression = number_format ( file_row_size_big ( $logfile ) , 0 , "," , "." ); }



 
 Remove all the white characters above, 
 so all that is left is: 
  (Line 134:


(Line 135:


(Line 136:


(Line 137:


(Line 138:


(Line 139:


(Line 140:


(Line 141:


(Line 409:
if ( $counter_display_show_visitors_online == 1 ) { echo '<div class="row"><div class="data">'.$text1.'</div>
   <div class="hits">'.number_format ( $module1 ).'</div></div>'."\n"; }

if ( $counter_display_show_today == 1 ) { echo '<div class="row"><div class="data">'.$text2.'</div>
   <div class="hits">'.number_format ( $module2 ).'</div></div>'."\n"; }

if ( $counter_display_show_yesterday == 1 ) { echo '<div class="row"><div class="data">'.$text3.'</div>
   <div class="hits">'.number_format ( $module3 ).'</div></div>'."\n"; }

if ( $counter_display_show_this_month == 1 ) { echo '<div class="row"><div class="data">'.$text4.'</div>
   <div class="hits">'.number_format ( $module4 ).'</div></div>'."\n"; }

if ( $counter_display_show_last_month == 1 ) { echo '<div class="row"><div class="data">'.$text5.'</div>
   <div class="hits">'.number_format ( $module5 ).'</div></div>'."\n"; }

if ( $counter_display_show_max == 1 ) { echo '<div class="row"><div class="data">'.$text6.'</div>
   <div class="hits">'.number_format ( $module6 ).'</div></div>'."\n"; }

if ( $counter_display_show_average == 1 ) { echo '<div class="row"><div class="data">'.$text7.'</div>
   <div class="hits">'.number_format ( $module7 ).'</div></div>'."\n"; }

if ( $counter_display_show_total == 1 ) { echo '<div class="row"><div class="data">'.$text8.'</div>
   <div class="hits">'.number_format ( ($module8+$counter_add_visitors) ).'</div></div>'."\n"; }

{ $pageimpression = number_format ( file_row_size_big ( $logfile ) ); }




 • All the above lines (134-141) are shown here as being wrapped (to conserve space), but in the file they are actually all on 1 single line.
Figured it out
by myself

 

3

Domain Name

To add the Domain Name on the left, above the section listings:

• Sample in top-left area on: External hosts (on A2 Hosting)
Internal hosts (on Abyss Web Server)

 

index.php
1.)    In phpWebStat 
 General Settings
  For "The stat tracks for whom?", enter in exactly how you want the domain name to look (i.e. with upper-cases, if you wish)

2.)    Find this section:    echo '<div id="sidenav-navlink">
  <ul>
    <li class="active"><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab1\'); change(this); return false;">'.$lang_tab[1].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab2\'); change(this); return false;">'.$lang_tab[2].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab3\'); change(this); return false;">'.$lang_tab[3].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab4\'); change(this); return false;">'.$lang_tab[4].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab5\'); change(this); return false;">'.$lang_tab[5].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab6\'); change(this); return false;">'.$lang_tab[6].'</a></li>
  </ul>
</div>';
//--------------------------------
 
 Add the line in red:    echo '<div id="sidenav-navlink">
  <font style="color:red;" size="4"><b>'.$stat_name.'</b></font>
  <ul>
    <li class="active"><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab1\'); change(this); return false;">'.$lang_tab[1].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab2\'); change(this); return false;">'.$lang_tab[2].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab3\'); change(this); return false;">'.$lang_tab[3].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab4\'); change(this); return false;">'.$lang_tab[4].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab5\'); change(this); return false;">'.$lang_tab[5].'</a></li>
    <li><a href="javascript:return false" onclick="hideTAB(); showTAB(\'tab6\'); change(this); return false;">'.$lang_tab[6].'</a></li>
  </ul>
</div>';
//--------------------------------
Figured it out
by myself

 

4

Footer

To add my own Footer:

• Sample in footers on: External hosts (on A2 Hosting)
Internal hosts (on Abyss Web Server)

 

index.php
 Find this section:    echo '
</div> <!-- END main-wrapper or archive-main-wrapper -->
</div> <!-- END main-->'."\n";
//------------------------------------------------------------------------------
 
 Add the lines in red:        if
        ($_SERVER['REMOTE_ADDR'] == "192.168.2.1") {
            include "D:\Web\_common\_globals\jmm_global_footer.php";
            include "D:\Web\_common\_globals\jmm_global_banner_hosting.php";
    } elseif
        ($_SERVER['REMOTE_ADDR'] != "192.168.2.1") {
            include "/home/panauro1/public_html/common/_globals/jmm_global_footer.php" ;
            include "/home/panauro1/public_html/common/_globals/jmm_global_banner_hosting.php" ;
    }

echo '
</div> <!-- END main-wrapper or archive-main-wrapper -->
</div> <!-- END main-->'."\n";
//------------------------------------------------------------------------------

 • The if/elseif code above allows this phpWebStat index.php file to be dropped into either my internal Abyss Web Server or external A2 Hosting, and work regardless of where it is located.
 • If you have only single website that phpWebStat is running on, you can replace the above code in red directly with your own footer code.
Figured it out
by myself

 

5

Padding

At the bottom of all modules, phpWebStat shows counts, example:

(3,617/8,131)


For readability, to insert these 2 spaces, use Step 1 hack:

( 3,617/8,131 )
( 3,617/8,131 )


For readability, to insert these 4 spaces, use Step 2 hack:

( 3,617 / 8,131 )
( 3,617 / 8,131 )
Sample
func/func_display.php
 • The line numbers below are correct as of phpWebStat v20.01, but might change in future releases.

1.)    Find these (' and ') symbols:    (Line 364:


(Line 365:
<div style="width:30%; float:left; text-align:left">
   ('.number_format ( array_sum ( $module_data ) ).'/'.number_format ( $value_max ).')</div>

<div style="width:20%; float:right; text-align:right">
   ('.number_format ( $count ).'/'.number_format ( $count_all ).')</div>



 Place a space between the ( ' and ' ) symbols:    (Line 364:


(Line 365:
<div style="width:30%; float:left; text-align:left">
   ( '.number_format ( array_sum ( $module_data ) ).'/'.number_format ( $value_max ).' )</div>

<div style="width:20%; float:right; text-align:right">
   ( '.number_format ( $count ).'/'.number_format ( $count_all ).' )</div>

2.)    Notice these (' and / and ') symbols:    (Line 364:


(Line 365:
<div style="width:30%; float:left; text-align:left">
   ('.number_format ( array_sum ( $module_data ) ).'/'.number_format ( $value_max ).')</div>

<div style="width:20%; float:right; text-align:right">
   ('.number_format ( $count ).'/'.number_format ( $count_all ).')</div>



 Add spaces as shown here ( ' and here  /  and here ' )   (Line 364:


(Line 365:
<div style="width:30%; float:left; text-align:left">
   ( '.number_format ( array_sum ( $module_data ) ).' / '.number_format ( $value_max ). ' )</div>

<div style="width:20%; float:right; text-align:right">
   ( '.number_format ( $count ).' / '.number_format ( $count_all ).' )</div>

 • Lines 364 and 365 in the 2 sections above are shown here as being wrapped (to conserve space), but in the file they are actually all on 1 single line.
Figured it out
by myself

 

6

Tracking (phpWebStat)

To track viewing of phpWebStat itself:

 

index.php
 Find this section at the end of the file:    //------------------------------------------------------------------------------

include ( "func/html_footer.php" ); // include html footer

//------------------------------------------------------------------------------
// kill all vars
unset ( $visitor               );
unset ( $visitor_hour          );
unset ( $visitor_day           );
unset ( $visitor_weekday       );
unset ( $visitor_month         );
unset ( $visitor_year          );
unset ( $browser               );
unset ( $operating_system      );
unset ( $resolution            );
unset ( $color_depth           );
unset ( $site_name             );
unset ( $referer               );
unset ( $country               );
unset ( $country_full          );
unset ( $searchengines_archive );
unset ( $searchwords_archive   );
unset ( $entrysite             );
//------------------------------------------------------------------------------
?>
 
 Add the line in red:    //------------------------------------------------------------------------------

include ( 'stat/config/tracking_code.php' );   // JMM: tracking of phpWebStat itself
include ( "func/html_footer.php" );            // include html footer

//------------------------------------------------------------------------------
// kill all vars
unset ( $visitor               );
unset ( $visitor_hour          );
unset ( $visitor_day           );
unset ( $visitor_weekday       );
unset ( $visitor_month         );
unset ( $visitor_year          );
unset ( $browser               );
unset ( $operating_system      );
unset ( $resolution            );
unset ( $color_depth           );
unset ( $site_name             );
unset ( $referer               );
unset ( $country               );
unset ( $country_full          );
unset ( $searchengines_archive );
unset ( $searchwords_archive   );
unset ( $entrysite             );
//------------------------------------------------------------------------------
?>
Reimar

(Forums)

HTML Entities Encoder/Decoder website used to encode & decode the above HTML-code to text

This page was last modified (timestamped): Monday, 10th June 2024 @ 22:54 EDT (America/Toronto) / UTC -04:00
Tuesday, 11th June 2024 @ 02:54 GMT (UTC)
AAB8370AB7F612D133528B31215DEDD9DE568543
1,423 unique visits

NitroWings.me © Copyright 2019-2024 by John Mark Motyer, CD [8.3.12]