Page Counter / Post Counter: Daily Views

Finally, bloggers, today i'm going to give you Daily Page Views Counter Widget or Post Views Counter Widget which i suppose this to complete the previous widget that i already gave to you. If you haven't read the previous posts, i have given to you Unique And Total Page Views Counter Widget, Single Post Views Counter Widget, and Total Online And Online On Page Visitors Counter Widget. In addition, i have made a table form too, you can use it to join all the widgets into one place, so you'll have such a custom page counter widget, your own page counter widget. Take a look on the following article if you'd like, or if you just want to know how to host php script: Create Page Counter Widget or Add The Ready To Use Page Counter Widget To Your Website.

Of course, the form is designated only for those who're not realy familiar with coding, if you're coding expert you might want to create your own form, mine is sucks, and i know that.

How To Create Daily Page Views / Post Views Counter Widget

Like the previous widgets, definitely it is, the daily page views widget that i'm going to give here is made of php script, but the widget doesn't need database and table, however the widget requires you to upload a .txt file to your root for it to saving some temporary numbers, something like that.

Here is what you're gonna do:

1. Create a new text file (example.txt) and fill it with date of the last week (year/month/day), or just let it empty is fine.
2. Go to control panel > File manager > Upload the file to your root folder.

Do not upload the file to directory public_html, instead upload the file in the same place with, it's your root directory.

3. After you uploaded the file, on file manager, click or check the check box for the file then click chmood. Just check all "read" and the first "write", then the most important thing: Chmood the file to 777.
4. Finally, copypass the following script and make it .php file, then upload it to your public_html directory.

<?php
$save = "daily-counter.txt";
$open = fopen($save, "a+");
$file = filesize($save);
$today = date("d/m/y");
if ($file==0)
{
$counter = 1;
fwrite($open, $today."-".$counter);
}
else {
$read = fread($open, $file); $cdata = explode("-", $read); ftruncate($open, 0); if($today == $cdata[0])
{ $counter = $cdata[1]+1; fwrite($open, $today."-".$counter); }
else { $counter = 1; fwrite($open, $today."-".$counter); }
}
fclose($open);
echo "document.write($counter);";

?>

Here to copy


Note! change the line in red using the .txt file's name that you uploaded to your root.

Well done! Now you have one more page views counter on your blogger blog. For weekly and monthly page views, maybe you want to keep an eye on my blog. :)

0 comments:

Post a Comment