Waxy backlinks from PHP

Among the updates in Waxy Backlinks v0.05 is the option to call it from PHP, as well as SSI. So now there’s no reason at all why you would want my quick and really dirty PHP script to show referrals.


Comment by Phil Ringnalda #
2002-07-08 22:50:47

Well, one reason maybe: mine doesn’t count refreshes.

Comment by Anonymous #
Comment by Phil Ringnalda #
2002-07-09 08:29:41

Er, yeah. Some days I can’t even link to myself. Fixed, thanks.

Comment by Waxy #
2002-07-15 00:41:31

Yours is likely much easier to implement in PHP weblogs. I’m going to recommend PHP users use your script instead.

Comment by almuhajabah #
2002-09-08 12:33:21

It would be great if there were some instructions about exactly what parts have to be changed to put in the proper paths and so on. The instructions about what code to put where in MT is very helpful, but more specifics on exactly what lines need to be changed would be much appreciated!

I’ve been looking for something like this and followed the link from Waxy’s site here since he recommended using your script (as mentioned above).

Thanks for another great trick for MT users!!

Comment by Donna #
2002-09-11 08:49:49

Phil, you absolutely rock! This installed beautifully with your directions, and Waxy is right – this is the tool of choice for PHP weblogs (like mine). Thank you!

Comment by Quadsk8 #
2002-09-12 06:38:15

Very kewl, thanks phil!
Got it working in a flash thanks to your clear explanation.

Comment by girlie #
2003-10-26 08:42:51

For the life of me, I can’t seem to get this to work. It gives no error messages but saves no referrals. I’m stumped. =(

Comment by Phil Ringnalda #
2003-10-26 09:06:35

Is it me, or Waxy, that you can’t get to work ;)

A quick glance at my code (which I haven’t looked at in months, at least, and wish I hadn’t now) shows that it is making a lot of assumptions about PHP on your server: it expects to be able to use fopen() on a URL, and expects to have stuff in the $_SERVER superglobal. Quickest way to check those is with phpinfo – create a PHP file that just does

echo phpinfo();

and look in the PHP Core section to be sure that allow_url_fopen says ”1”, and that the PHP Variables section includes a bunch of _SERVER variables (you could link to your file runs phpinfo(), so that _SERVER[’HTTP_REFERER’] would be set, to be sure, but if there are any _SERVER variables, I’d guess it would be when there was one).

Beyond that, well, I’m sure you did change $backlink_dir to a local path to a directory where PHP has permission to write, so that can’t be it. Hmmm. I’m actually using a slightly rewritten version, that uses MySQL (back when Dave Winer used to link to me, one link drove enough traffic fast enough that the filesystem-without-locking method blew up, but it’s also nicer for removing things that you don’t want to have around), worst comes to worst I could try to clean it up enough for you to try.

Comment by girlie #
2003-10-26 09:06:00

Um. Now I’m even more confused. It’s working now, although the referrer is the page itself. See here:


Anyway aside from that – now I’m unclear on why it shows just the URL instead of the site name and title like yours does here. Any suggestions?


Comment by Phil Ringnalda #
2003-10-26 09:17:54

Listing the page itself (and other pages on your site) – you just need to add yourself to the blacklist: $blacklist = array(’thegirliematters.com’, ’www.thegirliematters.com’);

Displaying a title rather than a prettified URL – let me think for a bit, about whether I’ve blown up the page with that lately: since you are grabbing the whole page, to look for a link to you, it shouldn’t be that tough to get the page title at the same time, but my regex skillz are pretty lame, so I’ve done things like get a referer from an RSS file, and then taken everything from the first <title> tag to the last </title> ( basically, a whole RSS file ;) ) as the page title a few times. Not sure if I want to unleash such a horror on the world.

Comment by girlie #
2003-10-26 09:36:27

Hmmm. So, you’re using something different here then? I just like how you’re showing some information about the site as the link text rather than the URL. =)

Comment by girlie #
2003-10-26 17:00:45

Hmmm. Should I see _SERVER[’HTTP_REFERER’] in the PHP Variables when I run phpinfo? Because I don’t – and now that I’ve blocked my own site from the referrals, there’s none at all – though I know from other referral scripts that they do exist!

I tried to go with the WaxyLinks version, but got an error about shell_exec being disabled due to security reasons. Oh joy. =P

Comment by Phil Ringnalda #
2003-10-26 17:09:22

You should only see it if you followed a link from another page to the page that’s running phpinfo() – otherwise, there isn’t a referrer, so it doesn’t show the variable.

Only seeing them from your own site makes it sound like your server isn’t letting fopen() check other sites for your URL. Um. Comment out the contents of function checkUrl($referrer), and put in just return true; and see if it works from other sites. If it does, then you won’t be able to check referrals to see if they actually link to you, which will leave you wide open to referral spam, which is a pain.

Trackback by PapaScott #
2002-07-09 02:17:53

PHP Backlink

Note to self: check back at philringnalda.com for 2 solutions for creating backlink lists.

Trackback by CraigSchamp.org #
2002-08-03 15:26:27

Links Everywhere

I’ve added a new feature courtesy of some code from Phil Ringnalda. The individual archive pages should show you a list of referring URLs to t…

2002-09-11 08:39:17

Widget-palooza continues.

I’ve installed Adam Kalsey’s Word count plugin for Movable Type, my first plugin. It’s counting the total words written over

2003-07-11 17:14:16

Sorry, Googlers.

The management is taking steps to fix it, but we’re not sure what they’ll be yet.

Name (required)
E-mail (required - never shown publicly)
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <del datetime="" cite=""> <dd> <dl> <dt> <em> <i> <ins datetime="" cite=""> <kbd> <li> <ol> <p> <pre> <q cite=""> <samp> <strong> <sub> <sup> <ul> in your comment.