Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Thanked 0 Times in 0 Posts

    search script help

    I recently found this search engine script while searching the net
    recently and desperately need help with it. The script displays search
    hippo results via xml feed and the sponsored results on the right hand
    side are from revenue pilot. The script works except there is a bug.
    The first query works fine (it displays 10 results per page) however
    when you click "next" to go to the next page it will display 15 and
    next page it will display 20 then 25 and so on. The other problem is
    that the table size of the search hippo results on the odd occasion
    will get bigger and will throw the revenue pilot results on the right
    hand side out of view. I imagine that someone with knowledge of these
    things would be able to rectify it quite easily, however this is a bit
    above my head. If somebody could help me with this it will be very
    much appreciated.

    Here is the search results file (search.php)


    // (C) 2003 C P Ridings
    // Create a search engine the easy way using searchhippo and

    // Change the layout by editing the index.html page and the template

    // This is a revenuepilot affiliate id for the paying side ads.
    // If you want to use your own id here you MUST get it from
    http://www.revenuepilot.com/iebar/ ONLY


    // Class to hold the SearchHippo results
    class ****em {
    var $shTitle;
    var $shDescription;
    var $shURL;
    var $shDispURL;

    // Class to hold the RevenuePilot Ads
    class rpAds {
    var $rpTitle;
    var $rpLink;
    var $rpDomain;
    var $rpDescription;

    $sTitle = "";
    $sLink = "";
    $sDescription = "";
    $arItems = array();
    $itemCount = 0;
    $adsItems = array();
    $adscount = 0;

    function startElement($parser, $name, $attrs) {
    global $curTag, $prevurl, $nexturl;
    $curTag .= "^$name";
    if ($name == "RESULTS") {
    // Get the results count and previous and next urls

    function endElement($parser, $name) {
    global $curTag;
    $caret_pos = strrpos($curTag,'^');
    $curTag = substr($curTag,0,$caret_pos);

    function characterData($parser, $data) {
    global $curTag;

    // now get the items
    global $arItems, $itemCount;
    if ($curTag == $itemTitleKey) {
    // make new xItem
    $arItems[$itemCount] = new ****em();
    // set new item object's properties
    $arItems[$itemCount]->shTitle = $data;
    elseif ($curTag == $itemLinkKey) {
    $arItems[$itemCount]->shURL = $data;
    elseif ($curTag == $itemDescKey) {
    $arItems[$itemCount]->shDescription = $data;
    elseif ($curTag == $itemDispKey) {
    $arItems[$itemCount]->shDispURL = $data;

    function rpstartElement($parser, $name, $attrs) {
    global $curTag, $adsItems, $adscount;
    $curTag .= "^$name";
    if ($name == "LISTING") {
    $adsItems[$adscount] = new rpAds();
    $adsItems[$adscount]->rpTitle = trim($attrs["TITLE"]);
    $adsItems[$adscount]->rpLink = trim($attrs["LINK"]);
    $adsItems[$adscount]->rpDomain = trim($attrs["DOMAIN"]);
    $adsItems[$adscount]->rpDescription = trim($attrs["DESCRIPTION"]);

    function rpendElement($parser, $name) {
    global $curTag;
    $caret_pos = strrpos($curTag,'^');
    $curTag = substr($curTag,0,$caret_pos);

    function rpcharacterData($parser, $data) {

    if ($HTTP_GET_VARS) {
    } else {

    if ($HTTP_GET_VARS) {
    } else {

    if ($HTTP_GET_VARS) {
    } else {

    if ($q == "") {
    echo "This is the front page which hasn't been done yet!";
    } else {
    // Get the SearchHippo XML document
    $docurl = "http://www.searchhippo.com/qxml.php?q=" .
    urlencode($q) . "&c=" . $c . "&i=" . $ir;
    $handle = fopen ($docurl, "r");
    $data = "";
    while (!feof($handle)) {
    $data .= fread($handle, 4096);
    // Fire up the XML parser
    $xml_parser = xml_parser_create();
    xml_set_element_handler($xml_parser, "startElement",
    xml_set_character_data_handler($xml_parser, "characterData");
    xml_parse($xml_parser, $data);
    for ($il = 0; $il < $itemCount; $il++) {
    $results.= "<font face=\"Verdana\" size=\"2\">";
    $results.= "<a href=\"" . $arItems[$il]->shURL .
    $results.= $arItems[$il]->shTitle;
    $results.= "</a><br>\n";
    $results.= $arItems[$il]->shDescription . "<br>";
    $results.= "</font><font face=\"Verdana\" size=\"1\" color=
    $results.= $arItems[$il]->shDispURL . "</
    fclose ($handle);
    // Get RevenuePilot Links
    $docurl = "http://search.revenuepilot.com/servlet/search?
    mode=xml&id=" . $revid . "&filter=off&perpage=4&ip=" . $theirip .
    "&skip=0&keyword=" . urlencode($q);
    $handle = fopen ($docurl, "r");
    $data = "";
    while (!feof($handle)) {
    $data .= fread($handle, 4096);
    $rpxml_parser = xml_parser_create();
    xml_set_element_handler($rpxml_parser, "rpstartElement",
    xml_set_character_data_handler($rpxml_parser, "rpcharacterData");
    xml_parse($rpxml_parser, $data);
    $ads = "";
    for ($il = 0; $il < $adscount; $il++) {
    $ads.= "<table border=\"0\" bordercolor=\"#FFFFFF\"
    cellpadding=\"5\" width=\"170\" bgcolor=\"#FFFFFF\"><tr><a href=\"" .
    $adsItems[$il]->rpLink . "\"><td valign=\"top\" onClick=
    \"self.location='" . $adsItems[$il]->rpLink . "'\" style=
    \"cursor:hand; cursorointer\">";
    $ads.= "<font face=\"Verdana\" size=\"2\">";
    $ads.= "<a href=\"" . $adsItems[$il]->rpLink . "\">";
    $ads.= $adsItems[$il]->rpTitle;
    $ads.= "</a><br>\n";
    $ads.= $adsItems[$il]->rpDescription . "<br>";
    $ads.= "</font><font face=\"Verdana\" size=\"2\" color=
    \"#7ec47b\">" . $adsItems[$il]->rpDomain . "\n";
    $ads.= "</td></a></tr></table><br>";
    fclose ($handle);
    $handle = fopen ("./results.tpl", "r");
    $data = fread ($handle, 1000000);
    $data = str_replace("[ADS]", $ads, $data);
    $data = str_replace("[RESULTS]", $results, $data);
    $data = str_replace("[QUERY]", $q, $data);
    $prevl = "";
    $nextl = "";
    if ($prevurl != "") {
    $prevl = "<a href=\"?q=" . urlencode($q) . "&c=" . $rc . "&i=" .
    $rir . "\"><font face=\"Verdana\" size=\"2\">Previous</font></a>";
    if ($nexturl != "") {
    $nextl = "<a href=\"?q=" . urlencode($q) . "&c=" . $rc . "&i=" .
    $rir . "\"><font face=\"Verdana\" size=\"2\">Next</font></a>";
    $data = str_replace("[NEXT]", $nextl, $data);
    $data = str_replace("[PREV]", $prevl, $data);
    echo $data;


    HERE IS THE TEMPLATE FILE (results.tpl)

    <title>[QUERY] :: Results</title>


    <p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


    <center><font face="Verdana" size="20" color="#0066cc">Easy Search</
    <center><form action="search.php" method="get"><input type="text"
    name="q" value="[QUERY]">&nbsp;<input type="hidden" name="c"
    value="0"><input type="hidden" name="i" value="0"><input type="submit"
    <center><a href="http://www.searchguild.com/"><font face="Verdana"
    size="2">Brought to you by SearchGuild.com</font></a></center>
    <table width="100%" bgcolor="#0062c4">

    <td><font face="Verdana" size="2" color="#eeeeee">Searched For:
    <table width="100%">
    <td valign="top">[RESULTS]</td>
    <td width="170" valign="top">[ADS]</td>
    <table width="100%" bgcolor="#0062c4">

    <td><font face="Verdana" color="#eeeeee" size="1">&copy;2003 <a
    by SearchHippo</font></td>

    please email me on webster.81@gmail.com thanks

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Thanked 30 Times in 28 Posts
    You might want to read some of the sticky's on top of the forum before you post if you expect an answer. Just as a tip, being that this is a forum and not tech support, I seriously doubt that anyone will email you. We're here to learn just as you are. So we'll want to share our answers on how to solve problems
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


    Posting Permissions

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