| What is Simple Word Frequency? | | | | The php code. |
| The following script can help you count the number of | | | | <?php |
| time a word or phrase has occured inside a text | | | | /* |
| document at a certain time. | | | | | Simple word frequency |
| In this example the script will be used to track the | | | |                       © |
| number of downloads of a filename. it is necessary to | | | | 2010Â | |
| have ".log" file in order to get the number of hits that a | | | | | This script may be used and hosted free of charge |
| filename receives. The download log used here is | | | | by anyone           | |
| DOWNLOAD.LOG and the filename we want to track | | | | | for personal purpose as long as this copyright notice |
| is FILENAME.PHP | | | | remains              | |
| What is a ".log" file? | | | | | |
| A log file used to store data from activities done on a | | | | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â | |
| server. A server log is a log file (or several files) | | | | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
| automatically created and maintained by a server of | | | | Â Â Â | |
| activity performed by it. The ".log" file we use for this | | | | */ |
| example should contain time and date and | | | | $download = "download.log"; |
| FILENAME.PHP so that whenever a user downloads | | | | $fh = fopen($download, 'r'); |
| the file the DOWNLOAD.LOG will automatically store | | | | $content = fread($fh, filesize($download));fclose($fh); |
| this data. The ip adress of the user can be stored to | | | | $filename = "filename.php"; |
| but it is not advised due to security reasons. However | | | | $str = str_replace("$filename", "", "$content", |
| in case you do want to use this feature don' t worry | | | | $count);echo "$filename has been downloaded $count |
| about other people browsing the log file because it can | | | | times."; |
| only be accesed by the site administrator. | | | | ? |