Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. Yeah it should do as $_SERVER['DOCUMENT_ROOT'] is set with the servers document root.
  2. Change: [code]$log[] .= 'Line ' . ($i+1) . ':    ' . rtrim($ip[$i]);[/code] to [code]$log[] .= str_replace($ipaddy . ': ', '', rtrim($ip[$i]));[/code]
  3. Must of missed that, does the code now work when use file('phpsimplechoose_log.php'); instead of file('iplog.php');
  4. This is where $_SERVER['DOCUMENT_ROOT'] comes in, if you dont want to type out $_SERVER['DOCUMENT_ROOT'] all the time then you can do this: $dr = $_SERVER['DOCUMENT_ROOT']; then use $dr to referent the document root. like so: include $dr . '/inc/file.php';
  5. No, you dont. Yeah you can just use phpsimplechoose_log.php instead of iplog.php I thought you wanted the person to login first in order to view the ip logs. That why I suggested you use a seperate file for the iplogs.
  6. Okay, you'll want to put: [code]192.168.1.1: Sat July 22, 2006 12:55 : Choice 1.  dfghf  Choice 2.  ghdfgh  We say... ghdfgh <br /> 192.168.1.1: Sat July 22, 2006 13:39 : Choice 1.  gsdfg  Choice 2.  sdfgdfg  We say... gsdfg <br /> 80.144.16.124: Sat July 22, 2006 13:56 : Choice 1.  me  Choice 2.  him  Choice 3.  she  Choice 4.  it  Choice 5.  who  We say... it <br /> 80.144.16.124: Sat July 22, 2006 13:57 : Choice 1.  good  Choice 2.  bad  Choice 3.  evil  Choice 4.  ugly  Choice 5.  world  We say... bad <br />[/code] within iplog.php In order for the code to work.
  7. I dont think so. I havn't seen this done. Just use relative paths.
  8. Whats in iplog? As this is the file being used to get the log for the ip address ($ipaddy). Does the code work when $ipaddy is $ipaddy = '192.168.1.1'; Whats in phpsimplechoose_log.php?
  9. escape the quotes (\") or do this: [code] while($code = mysql_fetch_object($q)) {     echo '<input style="border:none;" type="radio" name="loc" onClick="go(\'index.php?page=delete_news\');">' . $code->title . "<br />\n";[/code]
  10. Argh! Hand on. I think I know why. Looking at the log you have from your first post, you have spaces at the beginning of each line within your iplog.php file. The regular expression is failing becuase of this. Okay try this code: [code]<?php // open the ip log file: $ip = file('iplog.php') or die("Unable to open iplog.php"); #echo '<pre>' . print_r($ip, true) . '</pre>'; // intiate our log var, will be used later $log = ''; // our IP addy to search for $ipaddy = $_SERVER['REMOTE_ADDR']; // now loop through our ips, and display log for any matches: for($i = 0; $i < count($ip); $i++) {     #if(preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:+/", $ip[$i], $log))     // find our matches     if(preg_match("/^{$ipaddy}:+/", trim($ip[$i])))     {         // add each match to the log array         $log[] .= 'Line ' . ($i+1) . ':&nbsp; &nbsp; ' . rtrim($ip[$i]);     } } // matches where found! Check that $log is an array if(is_array($log)) {     // count how many matches there are     $matches = count($log);     // display how many matches there were     echo "<h1>{$matches} matchs found for IP {$ipaddy}</h1>\n";     // display the log     echo implode("<br />\n", $log); } else {   // no matches where found!   echo "<h1>No matches found for IP {$ipaddy}</h1>"; } ?>[/code] You should now get some results, <i>touch wood</i>!
  11. Okay, so its getting the contents of the file. But its failing somewhere. Change your code to this: [code]// open the ip log file: $ip = file('iplog.php') or die("Unable to open iplog.php"); // intiate our log var, will be used later $log = ''; // our IP addy to search for $ipaddy = $_SERVER['REMOTE_ADDR']; // now loop through our ips, and display log for any matches: for($i = 0; $i < count($ip); $i++) {     if(preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:+/", $ip[$i], $log))     {         echo '<pre>' . print_r($log, true) . '</pre>';     } }[/code] Do you get anything? You should get an array of ipaddress found within iplog.php
  12. Could you post your phpinfo? By running [code]<?php phpinfo(); ?>[/code] So I can see what you current setup is. As currently I dont know why its not working. Also add this: [code]echo '<pre>' . print_r($ip, true) . '</pre>';[/code] After: [code]$ip = file('iplog.php');[/code] Do you get anythink?
  13. Just out of curiousity, change this: [code]$file = 'iplog.php'; /*$iplog = fopen($file, 'r'); // get contents of file: $ips = fread($iplog, filesize($file)); // close file: fclose($iplog); // now get each line from the log file: $ip = explode("\n", $ips);[/code] To this: [code]$ip = file('iplog.php');[/code] Also do you have safe_mode on?
  14. What version of PHP are you using? As I am using PHP5, but I dont think I am using PHP5 specific functions. I am on Windows too.
  15. You dont need the actual main servers config files, but you can a files called .htaccess files, which most hosts allow you to use anyway.
  16. Whats in post.php?
  17. [quote]Is it possible to use [code]$_SERVER['REMOTE_ADDR'][/code] for the IP to look for?[/quote] Yes, Change $ipaddy = "207.144.154.140"; to $ipaddy = $_SERVER['REMOTE_ADDR']; Also if you want to display line numbers, change this: [code]$log[] .= $ip[$i];[/code] to this: [code]$log[] .= 'Line ' . ($i+1) . ':&nbsp; &nbsp; ' . $ip[$i];[/code] [quote]EDIT: With and without the header I am getting: No matches found for IP 192.168.1.1[/quote] In that case do you have the correct permissions to iplog.php or whatever file you are using to log the ip addresses, also is iplog.php in the same directory as this script is being run in?
  18. I would store your IP addresses in a seperate log file, called iplog.php, The use this code to show the log for a particular IP Address: [code]<?php // DO NOT DELETE THIS include 'phpsimplechoose_config.php'; // Below is where the verification takes place. Try to play around with it. if (!isset($_SERVER['PHP_AUTH_USER'])) {     header('WWW-Authenticate: Basic realm="Please enter User/Password"');     header('HTTP/1.0 401 Unauthorized');     die; } else {     if (($_SERVER['PHP_AUTH_USER'] !== $phpsc_username) || ($_SERVER['PHP_AUTH_PW'] !== $phpsc_password))     {         header('WWW-Authenticate: Basic realm="Incorrect! Please try again."');         header('HTTP/1.0 401 Unauthorized');         die;     } } // open the ip log file: $file = 'iplog.php'; $iplog = fopen($file, 'r'); // get contents of file: $ips = fread($iplog, filesize($file)); // close file: fclose($iplog); // now get each line from the log file: $ip = explode("\n", $ips); // intiate our log var, will be used later $log = ''; // our IP addy to search for $ipaddy = "207.144.154.140"; // now loop through our ips, and display log for any matches: for($i = 0; $i < count($ip); $i++) {     #if(preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:+/", $ip[$i], $log))     // find our matches     if(preg_match("/^{$ipaddy}:+/", $ip[$i]))     {         // add each match to the log array         $log[] .= $ip[$i];     } } // matches where found! Check that $log is an array if(is_array($log)) {     // count how many matches there are     $matches = count($log);     // display how many matches there were     echo "<h1>{$matches} matchs found for IP {$ipaddy}</h1>\n";     // display the log     echo implode("<br />\n", $log); } else {   // no matches where found!   echo "<h1>No matches found for IP {$ipaddy}</h1>"; } ?>[/code] Change this line: [code]$ipaddy = "207.144.154.140";[/code] To the ip address you want to search for, or you can implement a form instead. NOTE: This code is untested with the header authentication, however it works fine without it.
  19. change: <input type="button" to <input type="radio" Also this a HTML issue so I am moving this.
  20. Change: [code]preg_match($GetTheRegularExpressionString, $GetTheStringToValidateString) == true[/code] To just: [code]$GetTheRegularExpressionString == $GetTheStringToValidateString[/code] Also you cannot use header when you output something to the browser, here: [code]print "dat=opps"; // connot oputput this, before you use header! $URL="RegularExpressionsHTMLVersion.aspx"; header ("Location: $URL");[/code]
  21. Look into mod_rewrite should be able to help here.
  22. Could explain a bit more please.
  23. Try, $meny = implode('-', $_POST['meny']); then use $meny within your query: ysql_query("INSERT INTO adminmeny (user, datum, meny) values ('" .$_POST['user']. "', '$datum', '" .$meny. "' )") or exit(mysql_error());
  24. What extension are you trying to enable? Also make sure the path to your extensions directory is an absolute path to your extensions, for example: [code]extension_dir = "C:\php\ext"[/code] Also make sure you have uncommented the extension you wish to enable too within the php.ini, for example for the gd library, find the following within the php.ini: [code];extension=php_gd2.dll[/code] Now remove the semi-colon from the stat of the line. Save your php.ini, restart your webserver for the changes to take affect.
  25. The clue is here: Table 'chinese.sponsors' doesn't exist That is saying the table sponsors doesnt exists within the chinese database. Check that your have spelt your table correctly and that your are using the correct database.
×
×
  • 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.