WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Logwriter
Categories : PHP, Log Files Update Picture
Ye Ding
Date : Apr 02nd 2003
Grade : 4 of 5 (graded 9 times)
Viewed : 4565
File : logwriteren.zip
Images : No Images for this code example.
Search : More code by Ye Ding
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php

/*
http://www.china-on-site.com/flexphpsite/
This little program can make an access log for certain pages, and the log file can be analyzed by
other log analyzing software. If you want to get the combined format log with referer and user
agent information, or you want to know the referer information of certain pages, but your hosting
provider doesn't offer access log downloading, or just provide the common format log, then you can
use this program.
*/

//settings

$logwriter_logformat = "combined"; // log format,combined or common
$logwriter_logdir = "C:/apache/htdocs/logwriter/"; // physical path where your log file located
$logwriter_logfilename = "access.log"; // your log file's filename
$logwriter_timezone = "+0800"; // your server's time zone. +0800 means GMT+8



function logwriter_writelog($logstring){

global $logwriter_logdir,$logwriter_logfilename;
$fullpathfilename = $logwriter_logdir.$logwriter_logfilename;

if (!is_file($fullpathfilename)) {
        print "Log file doesn't exist or file is corrupt.";
        return;
}

if (!is_writeable($fullpathfilename)) {
        print "Log file is not writable,please change its permission.";
        return;
}

if($fp = @fopen($fullpathfilename, "a")) {
         flock($fp, 2);
fputs($fp, $logstring);
fclose($fp);
}
}

function logwriter_handlevar($varname,$defaultvalue) {
$tempvar = getenv($varname);
if(!empty($tempvar)) {
return $tempvar;
} else {
return $defaultvalue;
}
}

if (!empty($REMOTE_HOST)) {
$logwriter_remote_vistor = $REMOTE_HOST;
}else{
$logwriter_remote_vistor = logwriter_handlevar("REMOTE_ADDR","-");
}

$logwriter_remote_ident = logwriter_handlevar("REMOTE_IDENT","-");
$logwriter_remote_user = logwriter_handlevar("REMOTE_USER","-");
$logwriter_date = date("d/M/Y:H:i:s");

$logwriter_server_port = logwriter_handlevar("SERVER_PORT","80");
if($logwriter_server_port!="80") {
$logwriter_server_port = ":".$logwriter_server_port;
}else{
$logwriter_server_port = "";
}

$logwriter_request_method = logwriter_handlevar("REQUEST_METHOD","GET");
$logwriter_request_uri = logwriter_handlevar("REQUEST_URI","");
$logwriter_server_protocol = logwriter_handlevar("SERVER_PROTOCOL","HTTP/1.1");

if ($logwriter_logformat=="common") {
$logwriter_logstring = "$logwriter_remote_vistor $logwriter_remote_ident $logwriter_remote_user
[$logwriter_date $logwriter_timezone] \"$logwriter_request_method $logwriter_request_uri
$logwriter_server_protocol\" 200 -\n";
}else{

$logwriter_http_referer = logwriter_handlevar("HTTP_REFERER","-");
$logwriter_http_user_agent = logwriter_handlevar("HTTP_USER_AGENT","");

$logwriter_logstring = "$logwriter_remote_vistor $logwriter_remote_ident $logwriter_remote_user
[$logwriter_date $logwriter_timezone] \"$logwriter_request_method $logwriter_request_uri
$logwriter_server_protocol\" 200 - \"$logwriter_http_referer\" \"$logwriter_http_user_agent\"\n";

}

logwriter_writelog($logwriter_logstring);

?>



PHP Based Apache + Mysql Error Log Parser
Categories : PHP, PHP Classes, Apache, MySQL, Log Files
An efficient iterative and buffered text file reader
Categories : PHP, Classes and Objects, Filesystem, PHP Classes, Log Files
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
logger class (PHP5 +)
Categories : PHP, PHP Classes, Log Files, XML
filesplit : Split big text files in multiple small ones
Categories : PHP, Log Files, Filesystem, PHP Classes
Scan Apache access log files and report possible worms attack
Categories : PHP, PHP Classes, Security, Apache, Log Files
Making a simple Hit-Log using PHP and MySql
Categories : PHP, Log Files, Beginner Guides, Databases, MySQL
Retrieve text from table and email to your e- address in pipe delimited format.
Categories : PHP, MySQL
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
A PHP function to encrypt and decrypt a number or string or a combination of the two.
Categories : PHP, Encryption, Security
Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Authorize.net AIM Interface Class v1.0.0
Categories : PHP, PHP Classes, Ecommerce, Payment Gateways
Cut your MySQL Connections to 1 line of code
Categories : PHP, Beginner Guides, Databases, MySQL
Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality.
Categories : PHP, GD image library, Graphics