You are here: Re: code checking « All PHP « IT news, forums, messages
Re: code checking

Posted by moosus on 11/09/06 23:48

Steve

Thanks for the reply.

I am not against doing it using a DB as I have access to one.

I am assuming that I would have to track users by using a session?

Really what I need to be able to do is track the number of visitors I have
to specific pages (ie venue.php?vid=10)

If you can give me any pointers I would appreciate it

Cheers
moosus

in article SLl4h.139$wl2.86@newsfe05.lga, Steve at no.one@example.com wrote
on 9/11/06 12:23 AM:

>
> "Moosus Gracius" <moosus [at] hotmail.com> wrote in message
> news:psc3l218v3du7brihid8bdchpo2n5qa4cv@4ax.com...
> | G'day all,
> |
> | I am only new to php and do most of my codeing with a book in one
> | hand.
> |
> | I have written a small script I wish to use as an include in the
> | footer of a site I am designing.
> |
> | Whilst the code is functioning at the moment I was hoping I could get
> | some input from you as to making it a little more "clean" for want of
> | a better word.
> |
> | Obviously there is some comments to pull. But I would like to hear if
> | there are ways I can make it neater / faster / smaller
> |
> | Cheers
> | moosus
> |
> |
> |
> |
> | ************************CODE***********************************
> | <?php
> | //Count & IP file name creation
> | if (isset($vid)){
> | $filecount =
> | $_SERVER['DOCUMENT_ROOT'].$vid."/counter/_count.txt";
> | $fileip = $_SERVER['DOCUMENT_ROOT'].$vid."/counter/_ip.txt";
> | } else {
> | $filecount =
> | $_SERVER['DOCUMENT_ROOT']."/counter".$_SERVER['PHP_SELF']."_count.txt";
> | $fileip =
> | $_SERVER['DOCUMENT_ROOT']."/counter".$_SERVER['PHP_SELF']."_ip.txt";
> | }
> | // Count file Check
> | if (file_exists($filecount) && file_exists($fileip)){
> | } else {
> | touch($filecount);
> | touch($fileip);
> | echo '<p>Touching Count & IP files</p>'; // Error Checking
> | }
> |
> | echo '<p>file count name = '.$filecount.'</p><p>file ip name =
> | '.$fileip.'</p>'; //Error checking
> |
> | // Tracking & recording
> | $fcount = fopen($filecount , "rw" ) or die();
> | $count = (int) fgets($fcount, 100);
> | echo '<p>count = '.$count.'</p>'; //Error checking
> | $fip = fopen( $fileip , "rw" ) or die();
> | $lastIp = fgets($fip, 50 );
> |
> | $count++;
> |
> | echo '<p>count = '.$count.'</p>'; //Error checking
> | fclose($fcount);
> | fclose($fip);
> |
> | $fcount = fopen($filecount , "w" ) or die();
> | $fip = fopen($fileip , "w" ) or die();
> | flock($fcount, LOCK_EX);
> | fwrite( $fcount, $count);
> | flock($fcount, LOCK_UN);
> | flock($fip, LOCK_EX);
> | fwrite( $fip, $HTTP_SERVER_VARS["REMOTE_ADDR"] );
> | flock($fip, LOCK_EX);
> |
> | fclose($fcount);
> | fclose($fip);
> |
> | echo $count ; //Output Number
> |
> | ?>
>
> man, that's got to be hell on your file system. have you thought of using a
> db? all of that code could be expressed in about 3 to 5 lines of code using
> a db. not only that, but you'd be able to easily report on activities by ip
> address in a more intuitive manner (where they went, when they went there,
> etc.).
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация