how to put PHP and this code

Status
Not open for further replies.

Derek

Community Support Force
Community Support
Messages
12,882
Reaction score
186
Points
63
how do i put it in my stie???



<?
/* Craze's IP Logger */
/* By Seena Zandipour */
/* Put this script in your 404 Message so when people try to access your hidden files,
their IP will be logged in many ways!!! */

/* connect to database */
$conn = mysql_connect("localhost","username", "password") or die(mysql_error());
mysql_select_db(database1, $conn) or die(mysql_error());

/* get the users ip address */
$ip = $SERVER['REMOTE_ADDR'];
/* get today's date and time */
$date = date('m/d/Y - h:m A');

if($ip){

/* Send an email to the admin with users IP */
$mail = mail('admin@site.net', 'ip logged!', 'A user with the IP of $ip has tried to
view secret files. Please goto http://www.locateip.via.name/ to figure out where that
bastard lives, and hunt him down!');

/* Log the IP in a datbase */
$query = mysql_query("INSERT INTO ip_log (ip,date) VALUES ('$ip', '$date')") or
die(mysql_error());

/* Log the ip in a flatfile (txt document) */
$file = fopen("iplog.txt", "w");
$write = fwrite($file, "\n IP ADDRESS: $ip, DATE: $date");
fclose($file);

if($mail){
echo "Mail sent to admin!";
}
if($query){
echo "User IP Logged in database!";
}
if($write){
echo "User IP logged in text file!";
}

echo "Task Complete!";

}
?>





and PHP codes
 

Chris S

Retired
Messages
2,055
Reaction score
1
Points
38
doesn't go here.

but you would make a page called ip.php and past that code in there

then upload to server.

Then create a .htaccess file


Code:
ErrorDocument 400 /errors/iplogger.php
ErrorDocument 401 /errors/iplogger.php
ErrorDocument 403 /errors/iplogger.php
ErrorDocument 404 /errors/iplogger.php
ErrorDocument 500 /errors/iplogger.php

and if you want you can make it better like this

Code:
ErrorDocument 400 /errors/iplogger.php?error=400
ErrorDocument 401 /errors/iplogger.php?error=401
ErrorDocument 403 /errors/iplogger.php?error=403
ErrorDocument 404 /errors/iplogger.php?error=404
ErrorDocument 500 /errors/iplogger.php?error=500

then the php code would look like

Code:
<?
/* Craze's IP Logger */
/* By Seena Zandipour */
/* Put this script in your 404 Message so when people try to access your hidden files,
their IP will be logged in many ways!!! */

/* connect to database */
$conn = mysql_connect("localhost","username", "password") or die(mysql_error());
mysql_select_db(database1, $conn) or die(mysql_error());

/* get the users ip address */
$ip = $SERVER['REMOTE_ADDR'];
/* get today's date and time */
$date = date('m/d/Y - h:m A');

if($ip){

/* Send an email to the admin with users IP */
$mail = mail('admin@site.net', 'ip logged!', 'A user with the IP of $ip has tried to
view secret files. Please goto http://www.locateip.via.name/ to figure out where that
bastard lives, and hunt him down!');

/* Log the IP in a datbase */
$query = mysql_query("INSERT INTO ip_log (ip,date) VALUES ('$ip', '$date')") or
die(mysql_error());

/* Log the ip in a flatfile (txt document) */
$file = fopen("iplog.txt", "w");
$write = fwrite($file, "\n IP ADDRESS: $ip, DATE: $date");
fclose($file);

if($mail){
echo "Mail sent to admin!";
}
if($query){
echo "User IP Logged in database!";
}
if($write){
echo "User IP logged in text file!";
}

$error = $_GET['error'];

if ($error == '404'){
echo "Sorry, this page has been moved.";
}elseif ($error == '500'){
echo "Sorry, Internal Server Error";
}elseif ($error == '401'){
echo "Sorry, You frogot to authuncate your self.";
}elseif ($error == '403'){
echo "Sorry, You are not allowed to view this page. It is forbidden.";
}elseif ($error == '400'){
echo "Sorry, but you must of send a bad request to the server.";
}else{
echo "Sorry, I cannot find an error page related to the error you achieved.";
}


echo "Task Complete!";

}
?>
*Note* Code not tested
 
Last edited:
Status
Not open for further replies.
Top