Displaying items by tag: code

Thursday, 08 April 2021 01:41

Hit Counter PHP Programming Example!

Add this code to the index.php file inside Joomla! templates directory or your /var/www/example.com/web directory.
Create an empty ../counter_01.txt file and chmod 777 ../counter_01.txt and chown www-data:www-data ../counter_01.txt

Save the ../counter_01.txt file outside the www/web accessible directory since of hacker attempts to write 0 or reset the counter.

<?php
$file="../counter_01.txt";
file_put_contents("../counter_01.txt", "\n", FILE_APPEND);
$linecount = 0;
$handle = fopen($file, "r");
while(!feof($handle)){
$line = fgets($handle);
$linecount++;
}
fclose($handle);
?>

This counter read line-height or newlines instead of a number, integer, or cipher.

Music to relax to https://www.youtube.com/watch?v=Ax-Q6sXqgdc&list=RDAx-Q6sXqgdc&start_radio=1

120 Words

Published in Programming