Jump to content

tvercoe

New Members
  • Posts

    9
  • Joined

  • Last visited

tvercoe's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. this is what i ended up using as dont know what code is to chmod so have to manually make file ip-address-mainsite.txt and its chmod is 0777 it works mint thank you heaps <!-- Below Code Logs ONLY User's IP Address & Time Stamp & Browser Info To logs/ip-address-mainsite.txt --> <?php $iplogfile = 'logs/ip-address-mainsite.txt'; $ipaddress = $_SERVER['REMOTE_ADDR']; //load the file $file = file_get_contents($iplogfile); //check to see if the ipaddress is already in the file if ( ! preg_match("/$ipaddress/", $file )) { //nope, log it! $webpage = $_SERVER['SCRIPT_NAME']; $timestamp = date('d/m/Y h:i:s'); $browser = $_SERVER['HTTP_USER_AGENT']; $fp = fopen($iplogfile, 'a+'); fwrite($fp, '['.$timestamp.']: '.$ipaddress.' '.$browser. "\r\n"); fclose($fp); } ?>
  2. here's what i got now seems to work when take out chmod <!DOCTYPE html> <html> <head> <meta name="author" content="evilbudz"> <html lang="en-NZ"> <meta charset="UTF-8"> <meta name="keywords" content="NZ Quakes,nz quakes,Earthquake,earthquake,Christchurch,christchurch,Shake,shake,Quakes,quakes"> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileImage" content="/ms-icon-144x144.png"> <meta name="theme-color" content="#ffffff"> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta name="NZ Quakes, nz quakes, Earthquake, earthquake, Christchurch, christchurch, Shake, shake" content="NZ Quakes - Earthquake Info For New Zealand"> <link rel="manifest" href="/manifest.json"> <link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"> <link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <!-- Below Code Logs ONLY User's IP Address & Time Stamp & Browser Info To logs/ip-address-mainsite.txt --> <?php $iplogfile = 'http://www.nzquakes.maori.nz/logs/ip-address-mainsite.txt'; $ipaddress = $_SERVER['REMOTE_ADDR']; //load the file $file = file_get_contents($iplogfile); //check to see if the ipaddress is already in the file if ( ! preg_match("/$ipaddress/", $file )) { //nope, log it! $webpage = $_SERVER['SCRIPT_NAME']; $timestamp = date('d/m/Y h:i:s'); $browser = $_SERVER['HTTP_USER_AGENT']; $fp = fopen($iplogfile, 'a+'); fwrite($fp, '['.$timestamp.']: '.$ipaddress.' '.$browser. "\r\n"); fclose($fp); } ?> <title>Welcome To - NZ Quakes</title> </head> </body> <frameset rows="17%,*,8%"> <frame src="nzquakes_frame_a.html" noresize="noresize"> <frame src="nzquakes_frame_b.html" noresize="noresize"> <frame src="nzquakes_frame_c.html" noresize="noresize"> </frameset> </html>
  3. chmod($iplogfile, 0777); seems to be the problem keeps saying error line 49 thats whats on line 49
  4. ok i chaged it to point to http://www.nzquakes.maori.nz/ip-address-mainsite.txt and same for other one now i just get these 2 messages, they are to do with the chmod as i can see both log files and directory are chmod 777 PHP Error Message Warning: chmod() [function.chmod]: No such file or directory in /home/a1582367/public_html/index.html on line 42 Free Web Hosting PHP Error Message Warning: chmod() [function.chmod]: No such file or directory in /home/a1582367/public_html/index.html on line 59 Free Web Hosting
  5. i know i have change order of code around maybe but the coding seems right-ish <!DOCTYPE html> <html> <head> <meta name="author" content="evilbudz"> <html lang="en-NZ"> <meta charset="UTF-8"> <meta name="keywords" content="NZ Quakes,nz quakes,Earthquake,earthquake,Christchurch,christchurch,Shake,shake,Quakes,quakes"> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileImage" content="/ms-icon-144x144.png"> <meta name="theme-color" content="#ffffff"> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta name="NZ Quakes, nz quakes, Earthquake, earthquake, Christchurch, christchurch, Shake, shake" content="NZ Quakes - Earthquake Info For New Zealand"> <link rel="manifest" href="/manifest.json"> <link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"> <link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <!-- Below Code Logs ONLY User's IP Address & Time Stamp & Browser Info To logs/ip-address-mainsite.txt --> <?php $iplogfile = 'logs/ip-address-mainsite.txt'; $ipaddress = $_SERVER['REMOTE_ADDR']; $webpage = $_SERVER['SCRIPT_NAME']; $timestamp = date('d/m/Y h:i:s'); $browser = $_SERVER['HTTP_USER_AGENT']; $fp = fopen($iplogfile, 'a+'); chmod($iplogfile, 0777); fwrite($fp, '['.$timestamp.']: '.$ipaddress.' '.$browser. "\r\n"); fclose($fp); $iplogfile = '../logs/ip-address-contactform.txt'; $ipaddress = $_SERVER['REMOTE_ADDR']; //load the file $file = file_get_contents($iplogfile); //check to see if the ipaddress is already in the file if ( ! preg_match("/$ipaddress/", $file )) { //nope, log it! $webpage = $_SERVER['SCRIPT_NAME']; $timestamp = date('d/m/Y h:i:s'); $browser = $_SERVER['HTTP_USER_AGENT']; $fp = fopen($iplogfile, 'a+'); chmod($iplogfile, 0777); fwrite($fp, '['.$timestamp.']: '.$ipaddress.' '.$browser. "\r\n"); fclose($fp); } ?> <title>Welcome To - NZ Quakes</title> </head> </body> <frameset rows="17%,*,8%"> <frame src="nzquakes_frame_a.html" noresize="noresize"> <frame src="nzquakes_frame_b.html" noresize="noresize"> <frame src="nzquakes_frame_c.html" noresize="noresize"> </frameset> </html>
  6. my log exist at www.nzquakes.maori.nz/logs/ip-address-mainsite.txt & www.nzquakes.maori.nz/logs/ip-address-contactform.txt they are there but no work is my code wronge? PHP Error Message Warning: file_get_contents(../logs/ip-address-contactform.txt) [function.file-get-contents]: failed to open stream: No such file or directory in /home/a1582367/public_html/index.html on line 52 Free Web Hosting PHP Error Message Warning: fopen(../logs/ip-address-contactform.txt) [function.fopen]: failed to open stream: No such file or directory in /home/a1582367/public_html/index.html on line 60 Free Web Hosting PHP Error Message Warning: chmod() [function.chmod]: No such file or directory in /home/a1582367/public_html/index.html on line 61 Free Web Hosting PHP Error Message Warning: fwrite(): supplied argument is not a valid stream resource in /home/a1582367/public_html/index.html on line 62 Free Web Hosting PHP Error Message Warning: fclose(): supplied argument is not a valid stream resource in /home/a1582367/public_html/index.html on line 63 Free Web Hosting
  7. because i get aalot of bots/spammer/hackers i want to be able to log their ip's (Done) now have to find sum code to look into logs and not log ip if its there (noob so done know much) i cant find code anywhere for this people tell me it easy but yet they cant supply code either can someone supply the code needs be every lil bit of cade as no point in just giving parts to noobs and would like the best way at the mo i can only log to files as dont know how create the database dont know what any of it means (noob)
  8. please can tel me the code to check against a log file for allready entered ip address below is the code i have to log the ip <?php $iplogfile = '../logs/ip-address-contactform.txt'; $ipaddress = $_SERVER['REMOTE_ADDR']; $webpage = $_SERVER['SCRIPT_NAME']; $timestamp = date('m/d/Y h:i:s'); $browser = $_SERVER['HTTP_USER_AGENT']; $fp = fopen($iplogfile, 'a+'); chmod($iplogfile, 0777); fwrite($fp, '['.$timestamp.']: '.$ipaddress.' '.$browser. "\r\n"); fclose($fp); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.