SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: help me-please

  1. #1
    SitePoint Member
    Join Date
    Oct 2004
    Location
    brunei
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help me-please

    Hi... I need some help fast... I'm developing an integrated search engine(something like dogpile) ..where it will generate the result from the multiple search engines to my web page......

    this is the index file:

    <?
    include ("template.inc");
    include ("ccfunc.php3");
    $cc_name="<i>CyberC<b>rawl</b></i>";
    $cc_pname="CyberCrawl";
    $i=1;

    $t = new Template("/home/sites/mysite/templates");

    if(!isSet($query)){

    $t->set_file("Main","main.html");
    $t->set_var("cc_name",$cc_name);
    $t->set_var("cc_pname",$cc_pname);
    $t->set_var("query",$query);
    $t->parse("MainOutput","Main");
    $t->p("MainOutput");



    }else{

    $t->set_file(array(
    "Results" => "result.html",
    "List" => "list.html"));

    query_lycos($query);
    $SearchEngine="Lycos";
    $header1="<center><p><table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\" bgcolor=\"#99ccff\">\n<tr>\n<td><font face=\"arial\" size=\"2\"><b>&nbsp;<i>$SearchEngine Results</i></b></font></td>\n</tr></table>\n</center>\n";
    reset($lycos_link);
    reset($lycos_desc);
    while (list($key, $desc) = each($lycos_desc)) {
    while (list($key, $link) = each($lycos_link)) {
    $t->set_var("link",$link);
    $t->set_var("desc",$desc);
    $t->parse("Details1","List",true);
    }
    }
    unset($lycos_link);
    unset($lycos_desc);
    unset($SearchEngine);
    $i++;



    query_google($query);
    $SearchEngine="Google";
    $header2="<center><p><table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\" bgcolor=\"#99ccff\">\n<tr>\n<td><font face=\"arial\" size=\"2\"><b>&nbsp;<i>$SearchEngine Results</i></b></font></td>\n</tr></table>\n</center>\n";
    reset($g_link);
    reset($g_desc);
    while (list($key, $desc) = each($g_desc)) {
    while (list($key, $link) = each($g_link)) {
    $t->set_var("link",$link);
    $t->set_var("desc",$desc);


    $t->parse("Details4","List",true);
    }
    }
    unset($g_link);
    unset($g_desc);
    unset($SearchEngine);
    $i++;

    $t->set_var("Header1",$header1);
    $t->set_var("Header2",$header2);
    $t->set_var("cc_name",$cc_name);
    $t->set_var("cc_pname",$cc_pname);
    $t->set_var("query",$query);
    $t->pparse("output","Results");

    }
    ?>




    this is the ccfunction file:

    <?

    function query_lycos($query){
    $query = ereg_replace(" ","+",$query);
    $submit_url = "http://www.de.lycos.de/cgi-bin/pursuit?matchmode=and&mtemp=main&etemp=error&query=".$query."&cat=de_spkr";

    $file = fopen($submit_url, "r");
    $rf = fread($file, 50000);

    $tmp1= "%begin%".ereg_replace("\n","",$rf);
    $tmp1= ereg_replace("\r","",$tmp1);
    $tmp1= ereg_replace("\t","",$tmp1);
    $tmp1=ereg_replace("</HTML>","%end%",$tmp1);
    $tmp1=ereg_replace("&nbsp;<img src=/graphics/dog/cool_dog_nonanim.gif height=21 width=20 border=0 align=absbottom vspace=2><font face=Verdana,Helvetica,Arial size=1 color=#cc0000>besonders empfehlenswert&nbsp;</font>","",$tmp1);
    $tmp1=eregi_replace("<LI><b>","%break%%linkstart%<b>",$tmp1);
    $tmp1=ereg_replace("</ol>(.*)%end%","",$tmp1);
    $tmp=explode("%break%", $tmp1);

    global $lycos_desc,$lycos_link;
    while(list($key,$val) = each($tmp))
    if($key){
    $val=eregi_replace("\n","",$val);
    $val=eregi_replace("</A></b><BR>","</A></b>%linkend% %descstart%",$val);
    $val=ereg_replace("<FONT SIZE=\"1\"><i>","%descend%",$val);
    $val=eregi_replace("<br>","",$val);
    $val=eregi_replace("<font size=\"2\">","",$val);
    $val=eregi_replace("</font>","",$val);
    $val=eregi_replace("<b>","",$val);
    $val=eregi_replace("</b>","",$val);

    $grab1 = eregi("%linkstart%(.*)%linkend%", $val, $link);
    $grab2 = eregi("%descstart%(.*)%descend%", $val, $desc);
    $link[1]=ereg_replace("\">","\" target=\"_parent\">",$link[1]);
    $lycos_link[]=$link[1];
    $lycos_desc[]=$desc[1];

    }

    fclose($file);
    }


    function query_google($query){
    $query = ereg_replace(" ","+",$query);
    $submit_url = "http://www.google.com/search?q=".$query."&meta=lr%3Dlang_de%26hl%3Dde";

    $file = fopen($submit_url, "r");
    $rf = fread($file, 50000);

    $tmp1= "%begin%".ereg_replace("\n","",$rf);
    $tmp1=ereg_replace("</body></html>","%end%",$tmp1);
    $tmp1=ereg_replace("%begin%(.*)Sekunden.</font></center><p>","%break%%linkstart%",$tmp1);
    $tmp1=ereg_replace("<p><A HREF","%break%%linkstart%<a href",$tmp1);
    $tmp1=ereg_replace("<p><center><div class=nav>(.*)%end%","",$tmp1);
    $tmp=explode("%break%", $tmp1);

    global $g_link,$g_desc;
    while(list($key,$val) = each($tmp))
    if($key){
    $val=ereg_replace("\n","",$val);
    $val=ereg_replace("</A><font size=-1><br>","</A>%linkend% %descstart%",$val);
    if(!eregi("<br><font size=-1 color=#8f8f8f>Kategorie:",$val)){
    $val=ereg_replace("<br><font color=green>","%descend%",$val);
    }
    $val=ereg_replace("<br><font size=-1 color=#8f8f8f>Kategorie:","%descend%",$val);
    $val=ereg_replace("<font size=-1 color=#8f8f8f>Beschreibung/font>","",$val);
    $grab1 = eregi("%linkstart%(.*)%linkend%", $val, $link);
    $grab2 = eregi("%descstart%(.*)%descend%", $val, $desc);
    $link[1]=ereg_replace("/>","/ target=\"_parent\">",$link[1]);
    $g_link[]=$link[1];
    $g_desc[]=$desc[1];
    }

    fclose($file);
    }

    ?>



    please help me in this code. I cant make this program run and at the same time I can't retrieve the result from the search engine
    everytime i run this program i will get this warning...

    Warning: reset(): Passed variable is not an array or object

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    instead
    PHP Code:
    reset($lycos_link);
    reset($lycos_desc); 
    try
    PHP Code:
    $lycos_link "";
    $lycos_desc ""
    this way u initied the variable with empty value


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •