Unless you want to program a spider, similar to google's, that crawls the web and indexes pages that have a link to your site, the best you're going to be able to do is watch the referer header. The "referer" header is provided as a way to see what site referred the traffic. For example, if you click on a link in pageA.php that went to pageB.php, the referer header would contain the url of pageA.php as it loads pageB.php. For your use i'd just store the referer header in a database table along with its page (or some way to identify the page, like if an id is associated with it).
Now the only caveat is that the referer header can be faked, or not exist at all. This means it can be a potential attack vector if you use the referer header text without sanitation, and it cannot be relied upon for any user authorization system. However, since your use is fairly basic you should have no issue with the referer header, just be sure to sanitize and escape its contents before inserting it into your db table.
To grab the referer header use:
$_SERVER['HTTP_REFERER']
Now, this will only show you what URL's are linking to yours AND also provide traffic to your site. If you have inbound links that provide no traffic then no referer header will get recorded for them.
Last edited by Jarrod1937; 02-06-2011 at 06:51 PM.
Thanks for your reply. I knew about HTTP_REFERER, but I was just wondering if there was a more efficient way than collecting the links as they come in and then storing them all in a DB. No worries though, either way would work for my purposes.
Bookmarks