Backlinks

See this nice summary page on referrer linking. I’m very tempted to try to write my own home-cooked one in PHP – you know, like, badly coded, slow, and works only on my server. Might be fun to do though.

[Update 9.7]: a certain number of hours of coding later, here is my php and mysql backlinks script source code. Enjoy!

Similar Posts:

This entry was posted in Social Media and the Web and tagged Code and Markup, Geek / Technical, Weblogs. Bookmark the permalink.

16 Responses to Backlinks

  1. Stephanie says:

    The backlinks script is written! Much faster than I expected. Just stuck with some cosmetic issues. Expect a new page in the coding section soon!

  2. y a qq chose qui ne marche pas :-(

    je vais voir le truc des espions et nettoyage ordi.

    merci.

    tu connais http://www.cexx.org/adware.htm et http://www.privacy.net/analyze/ worth a look.

  3. Stephanie says:

    If you want to give me a hand, I’m stuck with this part: read the first x lines of a remote page and output the text in between the tags into a variable.

  4. Stephanie says:

    Next step: collect google search terms. That will be fun!

  5. Jane Doe says:

    Reading a web page with php is easy ! $page=readfile(“http://www.disenchanted.com/dis/technology/xanadu.html”); will get you the source of the page.

    (another solution is to use system(“wget…”), which is a safer solution since wget will handle retry and timeout for ya)

    To parse $page, use regexp or a xml parser, to extract what you want (title, maybe the <link rel=”index” to catch the permalink and the <link rel=”alternate” type=”application/rss+xml” to catch the RSS feed are obvious candidate)

    Regexp are usually a better solution since HTML is not often valid xml

    You can also try to use preg_split to find the text before and after the link that caused the backlink activation.

    The concept of x lines is not obvious with html source… you can try to catch the content of the first <p> </p> or the first sentence (a sentence ends with !?. and a space)

    To remove all markup, use preg_replace see http://www.php.net/manual/en/function.preg-replace.php for the code

    Another source of help might be Biz, from Niutopia, since he has some perl code to do the same thing (grabbing title and some text about it) http://joueb.com/niutopia/news/155.shtml

  6. Stephanie says:

    not sure if this is the best, but it’s working! (not sure either how the php code will come out with this comments script):

    $referrer_page = implode(”,file(“http://www.disenchanted.com/dis/technology/xanadu.html”)); preg_match(‘!]>(.)!’, $referrer_page, $array_of_matches); $referrer_title=$array_of_matches[1];

    Actually, readfile spits the whole thing out on the page without waiting for me to tell it to do so.

  7. Morgazilla says:

    Bonjour dans les etoiles, il a l’air bien ce script, mais ne veut pas de moi :) , on dirait que c’est le titre qui ne passe pas, peut etre a cause de l’apostrophe ? “…J’ai arrete” @ un autre jour

  8. Stephanie says:

    Les referrers s’affichent seulement après au moins deux visites de deux ip différentes. Le tien s’affiche maintenant. Je vais mettre manuellement le nom dans la base, c’est vrai qu’il y a eu un blème! (apostrophe ou serveur bizarre, je sais pas…)

  9. Stephanie says:

    The backlinks script is written! Much faster than I expected. Just stuck
    with some cosmetic issues. Expect a new page in the coding section soon!

  10. y a qq chose qui ne marche pas :-(

    je vais voir le truc des espions et nettoyage ordi.

    merci.

    tu connais http://www.cexx.org/adware.htm et
    http://www.privacy.net/analyze/
    worth a look.

  11. Stephanie says:

    If you want to give me a hand, I'm stuck with this part: read the first x
    lines of a remote page and output the text in between the tags into a
    variable.

  12. Stephanie says:

    Next step: collect google search terms. That will be fun!

  13. Jane Doe says:

    Reading a web page with php is easy !
    $page=readfile(“http://www.disenchanted.com/dis/technology/xanadu.html”);
    will get you the source of the page.

    (another solution is to use system(“wget…”), which is a safer solution
    since wget will handle retry and timeout for ya)

    To parse $page,
    use regexp or a xml parser,
    to extract what you want (title,
    maybe the <link rel=”index” to catch the permalink
    and the <link rel=”alternate” type=”application/rss+xml” to catch the
    RSS feed are obvious candidate)

    Regexp are usually a better solution since HTML is not often valid xml

    You can also try to use preg_split to find the text before and after the
    link that caused the backlink activation.

    The concept of x lines is not obvious with html source…
    you can try to catch the content of the first


    or the first sentence (a sentence ends with !?. and a space)

    To remove all markup, use preg_replace
    see http://www.php.net/manual/en/function.preg-repl… for the code

    Another source of help might be Biz, from Niutopia, since he has some perl
    code to do the same thing (grabbing title and some text about it)
    http://joueb.com/niutopia/news/155.shtml

  14. Stephanie says:

    not sure if this is the best, but it's working! (not sure either how the
    php code will come out with this comments script):

    $referrer_page =
    implode('',file(“http://www.disenchanted.com/dis/technology/xanadu.html”));
    preg_match('!]>(.)!', $referrer_page, $array_of_matches);
    $referrer_title=$array_of_matches[1];

    Actually, readfile spits the whole thing out on the page without waiting
    for me to tell it to do so.

  15. Morgazilla says:

    Bonjour dans les etoiles, il a l'air bien ce script, mais ne veut pas de
    moi :) , on dirait que c'est le titre qui ne passe pas, peut etre a cause
    de l'apostrophe ? “…J'ai arrete”
    @ un autre jour

  16. Stephanie says:

    Les referrers s'affichent seulement après au moins deux visites de deux ip
    différentes. Le tien s'affiche maintenant. Je vais mettre manuellement le
    nom dans la base, c'est vrai qu'il y a eu un blème! (apostrophe ou serveur
    bizarre, je sais pas…)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>