Elite Skills
Monday, June 12, 2006
  PHP Blogging Tricks
PHP Blogging Tricks
Auto Ping Me!

Use the fopen function along with a pingomatic or pingoat URL.

$handle = fopen("http://www.thepingotmaticurl.csdf?sfasdf", "r");

Just add it to the end of your code after the part the RSS is built automatically.
Auto Link

Say you have other blog categories and sites you want to automatically link for certain keywords. Just use an ereg expression.

$url=ereg_replace('bored',
'bored',$url);

No BOT Spam Comments

Most people don't need one of those fancy scripts that generates random images with crazy backgrounds. Just ask your users a simple question. Spell 1? ____ If someone happens to make a bot that accomodates to your blog, which is horridly unlikely, unless you have some smart enemies, just chance the question.

Adding this is really easy, and comes in two parts. Add this to your comment form.

Spell one:


Now just add this to your action="whatever.php" code from the same form.

if (!($strtoupper($_POST['human'])=="ONE"))
{ exit; }

This simply sets their post to uppercase so it doesn't matter what case they write it in, and checks if it is the string "ONE". If they get the answer wrong, it exits the script.
Ignore really short comments

Who cares about comments that say "great" with no detail? I rather have comments that contribute something to the blog. To ignore short comments:

if (strlen($comment)<30){ exit; }

Not that you should change $comment to whatever your variable the program uses to hold the comment.
Too long comments

You can limit posts length in the php.ini and you can just add this code.

if (strlen($comment)>2000){ exit; }

Blocking Links

if (ereg("HTTP://",strtoupper($comment))){
echo "No links please...";
exit;
}

You can also use this code and change http:// to something like ASDF or IDIOT to block out jibberish and curse words.
NoFollow

In your linking script, or if you link them directly withhtml, instead of a href= write a rel="nofollow" so that search engines don't follow the links in your blog and crawl more of your site. This is kind of controvercial, because it makes the browser not count them for pagerank, but it's best done with external comments by users.
 
Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home
Roleplay My Site Ear Trainer Anime

Name:
Location: North Richland Hills, Texas, United States
Archives
July 2004 / February 2006 / March 2006 / June 2006 / July 2006 / August 2007 / October 2007 / June 2008 / August 2008 / April 2010 /


Powered by Blogger

Subscribe to
Comments [Atom]