Backlinks [en]

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!

8 thoughts on “Backlinks [en]

  1. 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. 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

  3. Reading a web page with php is easy !
    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 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)

  4. 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 =
    preg_match(‘!]*>(.*)!’, $referrer_page, $array_of_matches);

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

  5. 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

  6. 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 *