Wednesday, 14 August 2013

PHP match_preg_all error

PHP match_preg_all error

I'm currently working on a hit counter that counts whenever a new visitor
visits the page, So for each new visitor i create a new .txt file.
The file is stored as "hits/".$_SERVER['REMOTE_ADDR'].".txt".
Here's my code:
<?php
$visits = 0;
$hits = 0;
$fileResource = @fopen("hits/".$remote_addr.".txt","w+");
fwrite($fileResource,
"IP Adress:".$remote_addr."
Timestamp:".time().""
);
$fileResource = @fopen("hits/".$remote_addr.".txt","r");
$fileContent = @fread($fileResource,100000);
preg_match_all("/(.*):(.*)\n/i",$fileContent,$fileMatches);
foreach(glob("hits/*.txt") as $hit){
$hits++;
}
?>
So what i am trying to do is:
Grab the contents from the file (Done)
Format it so it can be displayed in an Admin Panel by getting what's
between ":" and \n (Need help)
Display it on the Admin Panel

No comments:

Post a Comment