You are here: function problems « PHP Programming Language « IT news, forums, messages
function problems

Posted by azriley on 02/15/06 21:07

could use some help with a function to clean up keywords in a url. I'm
expecting $keywords to equal 'coretta scott king' - the plus signs are
stripped out for search engine referrals. What am I doing wrong?


<?php

$referer = 'http://www.google.com/search?hl=en&q=coretta+scott+king';

function parse_keywords($referer){
// Google, AllTheWeb, MSN, Freeserve, Altavista
if ((eregi("www.google",$referer)) or
(eregi("www.alltheweb",$referer)) or (eregi("search.msn",$referer)) or
(eregi("ifind.freeserve",$referer)) or
(eregi("altavista.com",$referer))) {
preg_match("'q=(.*?)(&| )'si", " $url ", $keywords);
}
// HotBot, Lycos, Netscape, AOL
if ((eregi("www.hotbot",$referer)) or (eregi("search.lycos",$referer))
or (eregi("search.netscape",$referer)) or
(eregi("aolsearch.aol",$referer))) {
preg_match("'query=(.*?)(&| )'si", " $url ", $keywords);
}
// Yahoo
if ((eregi("yahoo.com",$referer)) or (eregi("search.yahoo",$referer)))
{
preg_match("'p=(.*?)(&| )'si", " $url ", $keywords);
}
// Looksmart
if (eregi("looksmart.com",$referer)) {
preg_match("'key=(.*?)(&| )'si", " $url ", $keywords);
}
// DMOZ
if (eregi("search.dmoz",$referer)) {
preg_match("'search=(.*?)(&| )'si", " $url ", $keywords);
}
// Ask
if (eregi("ask.co",$referer)) {
preg_match("'ask=(.*?)(&| )'si", " $url ", $keywords);
}

if (($keywords[1]!="") and ($keywords[1]!=" ")) {
$keywords=str_replace("+"," ",$keywords[1]);
}
return $keywords;
}
$keywords = parse_keywords($referer);
echo $keywords;


?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация