Hi I was move to another directory the acp from my invision forum and i want when a user goes to: http://www.myforum/admincp/ Code (markup): To get the ip from the user plus time in a file and display a message like i have your ip bla bla ..... Thanks
I don't really get what do you want. Can you please explain more detail? You want to redirect all users who accessed your ACP except yourself?
No I need when a user goes to: http://www.myforum/admincp/ Code (markup): that does not exist at all to put a file there and gets the ip from the user that was trying to open that directory so i will know who is trying to find my acp.
Simplified: $ip = getenv("REMOTE_ADDR"); $logfile = "ip_log.txt"; $file = fopen($logfile, 'w') or die("Failed to open logfile"); fwrite($file, $ip . '\n'); fclose($file); PHP: IPs will be separated by a new line.
Does that log also the time that the user try to find my acp? And also how can i display a message to him e.x: I have your ip bla bla Thanks
$ip = getenv("REMOTE_ADDR"); $logfile = "ip_log.txt"; $file = fopen($logfile, 'w') or die("Failed to open logfile"); fwrite($file, $ip . '|' . date('r') . '\n'); fclose($file); print "I have your ip bla bla"; PHP: Log format: IP-address|time-logged IP-address|time-logged IP-address|time-logged ... Code (markup):
Thank you Is this code secure? For r.f.i or any other security exploits? Ok i add the code to a file named admincp.php in a folder /admincp/ and i add also a file named: ip_log.txt But when i try to go to the www.myserver.com/admincp/ Code (markup): i get this: Forbidden You don't have permission to access /admincp/ on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Why it doesn't run the php file?
Yes you are write but now i can see this: $ip = getenv("REMOTE_ADDR"); $logfile = "ip_log.txt"; $file = fopen($logfile, 'w') or die("Failed to open logfile"); fwrite($file, $ip . '|' . date('r') . '\n'); fclose($file); print "I have your ip bla bla"; And i don't get any log in the txt file admincp directory : attributes 755 index.php file : attributes 644 ip_log.txt file : attributes 777 ?
you forgot php tag <?php $ip = getenv("REMOTE_ADDR"); $logfile = "ip_log.txt"; $file = fopen($logfile, 'w') or die("Failed to open logfile"); fwrite($file, $ip . '|' . date('r') . '\n'); fclose($file); print "I have your ip bla bla"; ?> PHP:
Thanks working great now 1)At the end of log i get this: -0600\n What is this? 2)Is this php file (code) secure for rfi ,lfi,exploits? 3)Also i just notice that logs the first user and then when someone else goes there it replace the first line It doesn't go to the next line like this: IP-address|time-logged IP-address|time-logged IP-address|time-logged ... Only one line and then replace this line with the info from the next user. Thanks for your help
<?php $ip = getenv("REMOTE_ADDR"); $logfile = "ip_log.txt"; $prev_content = @file_get_contents($logfile); $file = fopen($logfile, 'w') or die("Failed to open logfile"); fwrite($file, $prev_content . $ip . '|' . date('r') . ' '); fclose($file); print "I have your ip bla bla"; ?> PHP:
Should be secure because it does not take any _get variable or what. $ip = getenv("REMOTE_ADDR"); $logfile = "ip_log.txt"; $prev_content = @file_get_contents($logfile); $file = fopen($logfile, 'w') or die("Failed to open logfile"); fwrite($file, $prev_content . $ip . " | " . date('r') . "\r\n"); fclose($file); print "I have your ip bla bla"; PHP: -0600 ? That is your server's time & timezone. -0600 should be GMT-6.
you should change your 404 error page to this if you want to log everything. Then also add in the page they were trying to get.