Posts Tagged ‘PHP Script’

Google Not Indexing SMF (Simple Machines Forum) Topic Pages

Thursday, February 28th, 2008

I’ve got the latest version of SMF (Simple Machines Forum) running on my AffiliStore website and have been using this for over a year now. I’ve had a strange problem in that Google seems to refuse to index the topic (post) pages. If you do a site: search on the AffiliStore forum you will find that it has indexed and cached all the member profile pages and a few other irrelevant bits of junk but no topic pages.

I decided to do a search on Google to see if anyone else has had the same problems and sure enough it seems that this is common amongst SMF users. Now the surprising thing is that when you go to the SMF main website and do a site: search on their community forum, Google seems to be listing their entire topic pages fine, so they seem to be blind to the problem even though people have posted about it in their forum.

Now I’ve looked into it quite a bit, checked the script to see if Googlebot is being blocked somewhere, removed a noindex meta tag which probably wasn’t doing too much harm as it only showed on certain pages you wouldn’t want indexed, tried the rewrite URLs option for a couple of months which again didn’t index topic pages and the rewrote URLs were very poor (along the lines of /forum/index.php/topic,72.0.html – that is just garbage) but the only conclusion I can come up with so far is that unless my server is somehow blocking SMF topic pages then Google doesn’t like the topic page URL format (/forum/index.php?topic=363.0 – is the . before the 0 causing a problem, surely not?).

So now I am trying a couple of other options, because I do love SMF compared to other forums as it is really user friendly and has loads of options. Firstly, I have now added the latest topic posts on the main pages of the AffiliStore website which should guarantee these pages being indexed as they have been brought to within one link of the top level of the website. I have also added a sitemap mod which creates regular forum sitemap and a sitemap.xml which I have uploaded to Google’s Webmaster Tools.

The next step is to just sit it out and wait to see if the above actions finally get the SMF topic pages indexed in Google. I’m not going to give up on SMF as v2 is just round the corner and I’m sure it will be even better than the current version, but it is frustrating as I do have a couple of thousand topic posts that should be bringing in lots of visitors for various longtail search terms.

Simple PHP Download Counter Script

Tuesday, February 26th, 2008

Here is a simple way to create a download counter script using PHP. It simply counts each click on the download link and stores the result in a writable text file.

First upload the file you wish users to download to your server. Then create a text file and name it “counter.txt“. Open the text file and add a 0, save and upload to your server and set the text file permissions to 777.

Now create a PHP file named “countdownloads.php” and add the following code:

<?php
$myFile = "counter.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);

$theData = $theData + 1;

$myFile = "counter.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $theData);
fclose($fh);

header("Location: download.zip");
?>

Now add the following code to your HTML page that will display the link to your download:

<p><a href="countdownloads.php">Download File</a><br />
<?php
$myFile = "counter.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
echo $theData;
fclose($fh);
?> Downloads<br />
since Feb 2008</p>

Upload these files to the same directory on your server and that should do the trick. I’m using this script on AffiliStore to count the downloads of the software.

Close
E-mail It