1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Keyword Alert Script

Discussion in 'Black Hat SEO Tools' started by The Scarlet Pimp, May 2, 2009.

  1. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    787
    Likes Received:
    3,117
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    This is a very simple script that will send you an email every time somebody views the web page it's installed on. The email will show you the exact keywords and search engine the visitor used to find your web page. Plus it will also show you that visitor's IP number.

    This script can be helpful if you use Adwords since you'll know which words, phrases, and misspellings are being used. Or you can just add the words to your web page to (hopefully) increase your overall rank. :D

    You'll need to adjust this to show the correct time when the page was viewed. Replace 'xxx' with the time difference between where you are and where the
    Server is.

    For example, if you live in New York and you host with Lunar Pages you would
    replace 'xxx' with the numeral '3' because there's a three hour time difference between NY and California. But if you live in Cali. then you'd use the numeral '0' because you're in the same time zone.

    Add your email address and the time difference (if any) and place this at the
    bottom of the page. You should also add a filter to your email account so the
    messages get filed into their appropriate folders. Otherwise your main email account will get flooded with alert messages!

    An easy way to do this is to file the alerts according to message subject,
    which you can easily change to anything that you like. If you have any problems, post them here. But this is pretty straight forward so you should
    not have any problems.

    $recipient = "addy@domain.com"; Put your email here.

    $hourdiff = "XXX"; Enter time difference here.

    $subject = "Visitor Alert: Home Page"; Change this as you will.


    Code:
    <?
    $myserver = "http://".$HTTP_HOST.$_SERVER[REQUEST_URI];
    $ip = $_SERVER['REMOTE_ADDR'];
    $cname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $fullhost = gethostbyaddr($ip);
    $host = preg_replace("/^[^.]+./", "*.", $fullhost);
    $hourdiff = "XXX"; 
    $timeadjust = ($hourdiff * 60 * 60); 
    $melbdate = date("D, M. jS, Y [g:i A]",time() + $timeadjust); 
    $recipient = "addy@domain.com";
    $subject = "Visitor Alert: Home Page";
    $message = "--------------------------------<br>
    *** SENDER INFO ***
    <p>
    ISP Address:<br> 
    <a href='http://ws.arin.net/cgi-bin/whois.pl?queryinput=$_SERVER[REMOTE_ADDR]'>$_SERVER[REMOTE_ADDR]</a>
    <p>
    ISP Name:<br> 
    $cname
    <p>
    Browser Type:<br> 
    $_SERVER[HTTP_USER_AGENT]
    <p>
    Page Referer:<br> 
    <a href=$_SERVER[HTTP_REFERER]>$_SERVER[HTTP_REFERER]</a>
    <p>
    Page Viewed:<br>
    <a href=$myserver>$myserver</a>
    <p>
    Date and Time Sent:<br>
    $melbdate<br>
    --------------------------------";
    $message = stripslashes($message);
    $headers = "From: Alert <alert@NoReply.not>\r\n";
    $headers.= "MIME-Version: 1.0\r\n";
    $headers.= "Content-type: text/html; charset=ISO-8859-1\r\n";
    mail($recipient,$subject,$message,$headers);
    ?>
    
    
    
     
    • Thanks Thanks x 7
  2. jammy

    jammy Junior Member

    Joined:
    Dec 5, 2008
    Messages:
    127
    Likes Received:
    110
    awesome , might prove useful.

    thanks and reps to you bro.
     
  3. projext

    projext Regular Member

    Joined:
    Jan 23, 2009
    Messages:
    240
    Likes Received:
    53
    Occupation:
    Freelance SEO Consultant and average internet mark
    Location:
    Manchester, Uk
    This looks awesome.

    Do we just add it to the page html?
     
  4. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    787
    Likes Received:
    3,117
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    post it just before the closing </body> tag and it
    should work fine. it only works if the page extension
    is ".php"

    edit and paste that script onto a page named,
    'test.php' and then view the page. you'll get an
    email showing your info.
     
    Last edited: May 2, 2009
  5. kikou

    kikou Junior Member Premium Member

    Joined:
    Feb 23, 2008
    Messages:
    107
    Likes Received:
    66
    Thanks for the script, I will have to test it.:)

    K
     
  6. ThomasDark

    ThomasDark Junior Member

    Joined:
    Oct 2, 2009
    Messages:
    116
    Likes Received:
    34
    Occupation:
    SEO, Internet Marketer
    Location:
    U.K
    I just installed it on my site, works beautifully. I have one question though. If i visit www. mysite. com via google, I get an e-mail. and if I then go to www. mysite. com/ page1 I also get an e-mail, so if a visitor visits 10 pages on my site, I will get 10 e-mails.

    Is there any way I can limit it? maybe only get an e-mail if I get a visitor from a refering site, rather than from other pages on my site I currently have it installed in my header.php on my wordpress blog.
     
  7. jmm223

    jmm223 Registered Member

    Joined:
    Apr 10, 2007
    Messages:
    79
    Likes Received:
    25
    This is nice...but "why email"?
    Seems like a pain to get all this via tons of emails. I think the script could easily be altered to log the info to a text file on the server or into a db.

    Just my 2 cents.
     
    • Thanks Thanks x 1
  8. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    787
    Likes Received:
    3,117
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    hee! hee! i'd never put it on a blog, in fact you should remove it because it may overload your server and make you look like you're bulk mailing spam.

    hmmm... i dunno how to make it do as you ask, but that is a good question. :confused:
     
  9. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    787
    Likes Received:
    3,117
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    good point! i will work on that change... :cool:
     
  10. g111k

    g111k Regular Member

    Joined:
    Jul 23, 2009
    Messages:
    263
    Likes Received:
    193
    I think emails is still a very good feature... but instead of an email for every visitor maybe you could group it by let's say a timeframe of your choice? like get an email update with all of the visitors info every hour or every day

     
  11. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    787
    Likes Received:
    3,117
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    hmmm... that would require a table, and i know zip about those...
    :prof01:
     
  12. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    787
    Likes Received:
    3,117
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    here ya go! :D
    change the 'XXX' to a number that reflects the time diff. between where you are and where your server is!

    Code:
    <?php 
    $myserver = "http://".$HTTP_HOST.$_SERVER[REQUEST_URI];
    $ip = $_SERVER['REMOTE_ADDR'];
    $cname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $fullhost = gethostbyaddr($ip);
    $host = preg_replace("/^[^.]+./", "*.", $fullhost);
    $hourdiff = "XXX"; 
    $timeadjust = ($hourdiff * 60 * 60); 
    $melbdate = date("D. M. j, Y [g:i A]",time() + $timeadjust);
    $subject = "<font color=#990000><b>Visitor Alert: Index Page</b></font>\n";
    $message = "<br />--------------------------------<br />
    *** SENDER INFO ***
    <p>
    ISP Address:<br />
    <a href='http://ws.arin.net/cgi-bin/whois.pl?queryinput=$_SERVER[REMOTE_ADDR]'>$_SERVER[REMOTE_ADDR]</a>
    <p>
    ISP Name:<br />
    $cname
    <p>
    Browser Type:<br />
    $_SERVER[HTTP_USER_AGENT]
    <p>
    Page Referer:<br />
    <a href=$_SERVER[HTTP_REFERER]>$_SERVER[HTTP_REFERER]</a>
    <p>
    Page Viewed:<br />
    <a href=$myserver>$myserver</a>
    <p>
    Date and Time Sent:<br />
    $melbdate<br />
    --------------------------------
    <br /><br /><br />\n\n\n";
    $message = stripslashes($message);
    $myFile = "log.php";
    $fh = fopen($myFile, 'a') or die ('cannot open the log file, check permission');
    $stringData = "$subject$message";
    fwrite($fh, $stringData);
    fclose($fh);
    ?>
    
     
  13. Seariz

    Seariz Junior Member

    Joined:
    Aug 29, 2009
    Messages:
    169
    Likes Received:
    36
    Occupation:
    Retired
    Thanks for the script, looks nice, ill take a loot further into it later tonight.
     
  14. lkphil

    lkphil Newbie

    Joined:
    Jan 31, 2009
    Messages:
    4
    Likes Received:
    0
    time diff allow negative numbers?
     
  15. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    787
    Likes Received:
    3,117
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    you can try it, but i suppose the time isn't all that important...:)
     
  16. 1zooegypt

    1zooegypt Newbie

    Joined:
    Nov 17, 2010
    Messages:
    11
    Likes Received:
    0
    very good post