Posts Tagged ‘wordpress’

a self-made log statistics with wordpress

Tuesday, August 14th, 2012

It’s not the case of freeshell.de or nic-nac-project.de that kindly is hosting this blog, but in the world there are some low cost hosting profiles where You can’t access your weblog.
Several times the webserver logs nothing at all.
Since I think  it’s a nice thing to have my web access statistics, if Your wordpress blog is on such kind of webserver, I suggest to add some plugin to your wordpress installation, such as myStat.

Once I preferred to write my own the http access log, in order to process it with awstats.
To do this, I changed the footer.php of my wordpress theme adding theese lines after the </html> tag:

<?php wp_footer(); ?>
</body>
</html>
<?php
// kludge to write a sort of access log on a file….
$monthyear = date(“F-Y”);
$remoteip = getenv(‘REMOTE_ADDR’);
$mytimestamp = date(“d/M/Y:G:i:s T”);
$useragent= getenv(“HTTP_USER_AGENT”);
$requri= getenv(“REQUEST_URI”);
$reqmet= getenv(“REQUEST_METHOD”);
$referrer= getenv(“HTTP_REFERER”);
$docroot= getenv(“DOCUMENT_ROOT”);
$logdir= $docroot . “/bloglog”;
$fplog = fopen($logdir .”/accesslog-myblog-“.$monthyear.”.txt”, “a+”);
fprintf ($fplog, “%s – [%s] \”%s %s\” \”%s\” \”%s\” 200\n”,
$remoteip, $mytimestamp,
$reqmet, $requri,
$useragent, $referrer);
fclose ($fplog);
?>

Doing so, a web access to any page of my site will add a log line into the accesslog-myblog-August-2012.txt  file. This file is into a directory named bloglog at the root of the webpages.

Getting this file and putting it on a linux box with awstats installed, it’s easy to generate my web statistics.

 

First I have to create a /etc/awstats/awstats-myblogname.conf telling my LogFile path and my LogFormat

LogFormat = “%host – %time1 %methodurlnoprot %uaquot %refererquot %code”

Then I have to run

 /usr/share/awstats/tools/awstats_updateall.pl now         -configdir=”/etc/awstats”         -awstatsprog=”/usr/share/awstats/wwwroot/cgi-bin/awstats.pl”

in order to read my stats at http://my-awstats-server.local/awstats/awstats.pl?config=myblogname

turn off wordpress php error reporting

Tuesday, June 1st, 2010

If, due to your provider php configuration, Your wordpress pages are writing some error messages like

Deprecated: Assigning the return value of new by reference is deprecated in /home/j/jose/public_html/wp-settings.php on line 520
Deprecated: Assigning the return value of new by reference is deprecated in /home/j/jose/public_html/wp-settings.php on line 535
Deprecated: Assigning the return value of new by reference is deprecated in /home/j/jose/public_html/wp-settings.php on line 542
Deprecated: Assigning the return value of new by reference is deprecated in /home/j/jose/public_html/wp-settings.php on line 578
Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/j/jose/public_html/wp-settings.php on line 18

php warning message

In lost-in-code website You can find the solution: just add theese two lines

error_reporting(0);
@ini_set(‘display_errors’, 0);

at the bebinning og wp-config.php file.