Welcome to PCCS-Linux.COM Hello, and welcome to the PCCS-Linux Home Page.
Your last visit was !!!
Your Browser is running on Other
 
Logging Script


<?php

$ip = $REMOTE_ADDR;
function log_this($action,$logfile_name) {
global $db_user, $ip;

        if(file_exists("logs/$logfile_name")) {
         $logfile = f"logs/$logfile_name","a");
         fputs($logfile,$ip.",".date("dS of F Y h:i:s A")."," . $db_user
.",". $action ."\n");
         fclose($logfile);
        } else {   
        exec ("touch logs/$logfile_name");
         $logfile = f"logs/$logfile_name","a");
         fputs($logfile,$ip.",".date("dS of F Y h:i:s A")."," . $db_user
.",". $action ."\n");
         fclose($logfile);
     }         
   }


?>



Example usage:

[code snippet]

elseif($action == "flush_s")
{                       
$qry = "FLUSH STATUS";
log_this($qry,"dblog.txt");
show_results($qry);
echo "<META CONTENT=\"0; URL=./\" HTTP-EQUIV=\"REFRESH\">";
 }

Another Example

<?php

if($HTTP_SERVER_VARS["argc"] != 0) // If someone is trying to pass an
argument 
Header("Location: $PHP_SELF"); // Then reload the page argument-free

echo "ERROR: Can't find database.";

if(strstr($HTTP_USER_AGENT,'Win')) {
        $BROWSER_PLATFORM="Windows BOX";
} else if(strstr($HTTP_USER_AGENT,'Win')) {
        $BROWSER_PLATFORM="Windows BOX";
} else if(strstr($HTTP_USER_AGENT,'Mac')) {
        $BROWSER_PLATFORM="Mac";
} else if(strstr($HTTP_USER_AGENT,'Linux')) {
        $BROWSER_PLATFORM="Linux";
} else if(strstr($HTTP_USER_AGENT,'Unix')) {
        $BROWSER_PLATFORM="UNIX BOX";
} else {
        $BROWSER_PLATFORM="Other";
}


$infraction_subject = "INVALID DIR ACCESS Attempt ";
$infraction = "INVALID DIRECTORY ACCESS Attempted to the logs
directory!!!";
$send_email = 0; // 0  NO,  1  YES
$email_admin = "root@localhost";

if($send_email == "1") {

    $to = $email_admin;
    $from = "HACKER@". $REMOTE_ADDR;
    $subject = $infraction_subject . "From" .  $REMOTE_ADDR;
    $message = "\tSome one at" . $REMOTE_ADDR .  "Did:  " . $infraction .
"\n";
    $message .= " Using : " . $HTTP_USER_AGENT . " on : " .  date("dS of
F Y h:i:s A");

    mail("$to","$subject","$message","From:$from\nReply-To: $from");
}

$logfile = "log.txt";
$badiplogfile = "badiplog.txt";
// Log Infraction

if(file_exists($logfile)) {

  $myfile = f$logfile,"a");

fputs($myfile,$BROWSER_PLATFORM."|".$HTTP_USER_AGENT."|".$REMOTE_ADDR."|".date("dS
of F Y h:i:s A")."|"."$infraction"."\n");
  fclose($myfile);

} else {

  $myfile = f$logfile,"w");

fputs($myfile,$BROWSER_PLATFORM."|".$HTTP_USER_AGENT."|".$REMOTE_ADDR."|".date("dS
of F Y h:i:s A")."|"."$infraction"."\n");
  fclose($myfile);

}

// Log IP address date and time 

if(file_exists($badlogfile)) {

  $myfile = f$badiplogfile,"a");

fputs($myfile,$BROWSER_PLATFORM."|".$HTTP_USER_AGENT."|".$REMOTE_ADDR."|".date("dS
of F Y h:i:s A")."|"."Watch this:  IP ADDRESS"."\n");
  fclose($myfile);

} else {

  $myfile = f$badiplogfile,"w");

fputs($myfile,$BROWSER_PLATFORM."|".$HTTP_USER_AGENT."|".$REMOTE_ADDR."|".date("dS
of F Y h:i:s A")."|"."Watch this:  IP ADDRESS"."\n");
  fclose($myfile);

}



?>

>> Comments/FeedBack


Page hits 82 last request on :11:50



This web site is prepared and maintained by Chauncey Thorn.
The information contained in this site was valid at the time of posting.
Chauncey Thorn, assumes no liability for damages incurred directly or indirectly as a result of errors, omissions or discrepancies.

Remember most of the content here are my notes...

All logos and trademarks in this site are property of their respective owner. All the rest © by PCCS-Linux.COM

PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002