PHP - Identifying Web Crawlers / Spiders By Ip Address
hey guys, in the attached image, i'm logged into another forum I'm part of and I'm looking at the page called "who's online". I have a php traffic report page that, when accessed, echoes out database data that has been stored by way of another php script that captures geoLocation data (ip address of ISP, referrer page, date/time of visit) using PHP global variables. my question is - how does this forum script know the identity of the google spiders? in my traffic report, i am only capturing the ip address of the ISP as the identifying information. from what I understand, it's not possible to capture the actual location of the visitor, only the ISP's location. if I look up the ip address on an ip lookup website, i can see that it is a google spider, but can this be done through PHP scripting? Edited November 16, 2019 by ajetrumpet Similar TutorialsHy! Any help on this topic would be much appreciated. Here is the deal. I need to redirect some countries to another URL. But I need to allow a free access for search engine's bots even if they come from those countries. Here is what I did until now: Used MaxMind PHP API and databases to establish redirect. And then tried to modify the code to redirect ONLY if user is from blocked country AND IS NOT allowed crawler... suprise suprise, it's not working as I imagined:)! Here is the code so far: #!/usr/bin/php -q <?php // This code demonstrates how to lookup the country by IP Address include("geoip.inc"); // Uncomment if querying against GeoIP/Lite City. // include("geoipcity.inc"); $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); $my_countries = array('de', 'se', 'no', 'ee', 'it', 'lv', 'cz', 'dk', 'sk', 'at', 'ch', 'lu', 'nl', 'es', 'hu', 'sg', 'gr', 'ua', 'fi', 'ru', 'cn', 'hk', 'my', 'id', 'us', 'ar', 'mx', 'ec', 'cr', 'py', 'br'); $allowed_spiders = array('Googlebot', 'Yammybot', 'Openbot', 'Yahoo', 'MSNbot', 'Ask Jeeves', 'Teoma', 'Architext spider', 'FAST-WebCrawler', 'Slurp', 'Yahoo Slurp', 'ia_archiver', 'Scooter', 'crawler@fast', 'Crawler', 'InfoSeek sidewinder', 'Lycos_Spider_(T-Rex)'); $agent_name = $_SERVER['HTTP_USER_AGENT']; if (in_array(strtolower($country), $my_countries)) { foreach($allowed_spiders as $s){ if(!strpos($s,$agent_name)){ header('Location: www.REDIRECT URL.com'); } } exit; } ?> How I imagined this code should work is: First check from where is user coming. Then compare GeoIP shortcode for country to shortcodes for banned countries. AND then if traffic is indeed from banned country also check if user agent name has anything in it from an array of allowed spider names (Googlebot can be Googlebot, or Googlebot/2.1 for an example). And if it's not allowed spider then redirect user to another address. I tried many variations of this but nothing seems to work. Each time that I tried to fetch page as a googlebot in webmaster, I got 302 redirection. Any help or guidance here MUCH appreciated. Thank you PHP JEDI in advance !! I have a form with PHP validation and also a mysqli query checking for duplicates in the database for mailing address and email address in mysql.
It works fine but the customers are adding spaces in the mailing address for example 111 mailing address A V E, 1 1 1 ma iling address A V E etc. and my sql query doesn't see that as an address that's a duplicate.
Their alslo adding email address like my@emailaddress.com and m.y@emailaddress.com, m.y.2@emailaddress.com etc to bypass that comparision also.
Is there anyway to stop this from happening?
Can you help me with where im going wrong here in this code this with a search function i am see the out put with pagination view however $id is not getting captured as the link id any help would be appreciated <form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table id="tic"> <tr> <td>Ticket No | Emp ID:</td><td><input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>"></td> <td><input type="submit" name="submit" value="Search"></td> </tr> </table> </form> <? if($_GET["txtKeyword"] != "") { $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); $objDB = mysql_select_db("ticket"); $result = "SELECT * FROM data WHERE (employee LIKE '%".$_GET["txtKeyword"]."%')"; $objQuery = mysql_query($result) or die ("Error Query [".$result."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 5; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $result .=" order by stamp LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($result); ?> <table id="ticket" <tr> <th> <div align="center">Ticket No</div></th> <th> <div align="center">Date</div></th> <th> <div align="center">Issue Type</div></th> <th> <div align="center">Status</div></th> <th> <div align="center">view</div></th> </tr> <? while($row = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><?=$row["id"];?></div></td> <td><div align="center"><?=$row["stamp"];?></div></td> <td><div align="center"><?=$row["issue"];?></div></td> <td><div align="center"><?=$row["status"];?></div></td> <td><div align="center"><a href="edit.php?id='$row['id']'">Update</a></div></td> </tr> <? } ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'>Back</a> "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]'>Next</a> "; } mysql_close($objConnect); } ?> Hi everyone, I have this script that identify's the current page in the navigation Code: [Select] <?php $currentPage = basename($_SERVER['SCRIPT_NAME']); ?> <ul id="nav"><!-- Open Nav --> <li><a href="index2.php" <?php if ($currentPage == 'index2.php') {echo 'class="selected"';} ?>>Home</a></li> <li><a href="salon-information.php" <?php if ($currentPage == 'salon-information.php') {echo 'class="selected"';} ?>>Salon Information</a></li> <li><a href="about-us.php" <?php if ($currentPage == 'about-us.php') {echo 'class="selected"';} ?>>About us</a></li> <li><a href="hair-care-advice.php" <?php if ($currentPage == 'hair-care-advice.php') {echo 'class="selected"';} ?>>Hair Care Advice</a></li> </ul><!-- Close Nav --> My problem is that hair-care-advice.php has a number of sub pages. How do I get it so the selected class remains selected for all the sub pages as well as the main page. Any help would be greatly appreciated Thank you Barry In my .htaccess, I have the following to enter a domain name then a store number such as www.domain.com/c111
The page storeNumber.php displays perfectly call the correct variables through the _GET.
The help I got and has been set up works for an Alpha and thre rest numbers.
What would be rewriterule be to use any random string of Alpha Numberic characters? Such as C123, 12CF, cf15, C2f5...
RewriteOptions inherit RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z0-9-]+)$ /storeNumber.php?storeNumberID=$1 [NC,L]Thanks for any help in advance, Mike Hello, Please let me know what is the wrong with the following lines of code. I am trying to find the MAC Address of the user who is logging. When I am running the code in localhost it is working. But the same code is not working when I upload it in the server. <?php function getMac(){ exec("ipconfig /all", $output); foreach($output as $line){ if (preg_match("/(.*)Physical Address(.*)/", $line)){ $mac = $line; $mac = str_replace("Physical Address. . . . . . . . . :","",$mac); } } return $mac; } $mac = getMac(); $mac = trim($mac); echo $mac; ?> Please help. Thanks a lot in advance. Regards & Thanks. Okay, so I know how to get an IP address using $_SERVER['REMOTE_ADDR'], however, I need to get an IP a little different. How would I get the IP of the visitor on a remote site loading MY site using file_get_contents()? It just returns that remote websites server IP... :/ Thanks! I have problem with # char in address and jquery, or any address with #. When i put this code in my php: <a href="#" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin"></span>Open Dialog</a> .. my link on that button is still same like link that i am on it, it do not add "#" in address, but if i, instead of href="#", put href="#some_text", that link shows nice, link.php#some_text, but without text in # it doesn't work :S Why is that happening, and how can i fix that? Hey guys, is there any way to get the IP address of people accessing my website using PHP? I'm trying to get a statistics area to work for my website. If there isn't a way using PHP, what would be an application which can get the IP address? Thanks a lot, Noid Just want to ask..if i use $_SERVER['REMOTE_ADDR'] to get user IP address, will it also come up with result when they use blackberry or mobile phone?? thanks I know how to get an ip adress from a domain by using gethostbyname(), but I wanted to know if it was possible to get the domain name from the ip address. As in a website address (example.com) has a ip address of xxx.xx.xxx.xxx What I am trying to do is to get the 'example.com' domain name from the ip address. Is this at all possible, if so, how can it be done? Thanks in advance for any that helps out. Hello i just spent my hour finding way to get XML attribute using PHP via URL i wanted to know is it possible or not like http://myurl.com/index.php?$xml=link1 link1 in my XML is some text can we get attribute like this via using URL on address bar Code: [Select] <?xml version="1.0" encoding="ISO-8859-1"?> <note> <link1>www.2advanced.com</link1> <link2>www.hotmail.com</link2> <link3>www.gmail.com</link3> <link4>www.twitter.com</link4> </note> Hi, I have a second website under the same domain www.lucyeleanorbrown.com/weddings.html which I wanted to change to www.weddings.lucyeleanorbrown.com, I have been looking around for PHP for this but am unsure of what to search for, could anyone give me a suggestion? Thank you Alright, the register/login system is fully working with sql injection, BUUUT now I want to store their IP Address. WHOLE new function that I've never dealt with before. So I need some help. Am I doing something wrong? I have the IPadd in the database as INT(10) and then I went down to another drop down list and hit unsigned. I feel like I'm doing something wrong with the field in the database.. { $_SERVER['REMOTE_ADDR'] = $IPadd; $sql = "INSERT INTO Member (username,createDate,password,firstName,email,IPadd) VALUES ('$username',NOW(),md5('$password'),'$firstName','$email',inet_aton('$IPadd'))"; mysqli_query($cxn,$sql); $_SESSION['auth']="yes"; $_SESSION['username'] = $username; header("Location: testing.php"); } Hi! What should the code be if I get an IP address to a postback url and I want to find that member in my database who has that IP-address? The postback comes like this http://yoursite.com/postback.php?ip=xxx Please help I have about 7 fields in one of my tables. Some of the fields are null or blank since they arent required (like address2) Is their a better way of formatting an address rather than doing something like: <?php while ($row = mysql_fetch_array($query)) { if ($row['address2'] != "") { echo $row['address2'] . "<br/"; } if ($row['otherField'] != "") { echo $row['otherField'] . "<br/"; } if ($row['anotherField'] != "") { echo $row['anotherField'] . "<br/"; } } ?> I have more fields than just address2, I just don't want a bunch of if statements I see all over the web that I should tie a session cookie to an ip to help stop some XSS session stealing, but I can't find HOW to do this anywhere. Can someone post some example code? Thanks! I would get the ip address of the user that is on the site. I used $ip = $_SERVER['REMOTE_ADDR']; and it doesn't show my actual ip. Is it because im using an apache server on my computer. I'm trying to get the screen to print out the users IP address so I've used the following code. echo($_SERVER['REMOTE_ADDR']); However this only prints out "::1". Does anyone know why it's printing this and not a proper IP Address? Thanks Is there anything to worry if I see no SSL warning in my browser's address bar when I am in the logging credentials form?
|