Search Results

  • Print
  • Email
  • Decrease text size
  • Increase text size

'; echo 'No search results returned'; ?>

'; echo 'No search results returned'; die; } //is this a next query and if so which one if(empty($_GET['package'])) $package = 0; else $package = $_GET['package']; // trigger follow-up page coding for Did You Mean (DO NOT REMOVE) $next_package = 0; // if this is the follow-up page for Did You Mean if ($_GET['next_package'] == '1') { $action = "http://search.tamu.edu/search?" . $_GET['package'] . "&filter=0"; $query=$_GET['q']; $action = htmlspecialchars_decode($action); //flag indicates this is follow-up page for Did You Mean $next_package = 1; } else { $query=$_GET['q']; //$query='kurk'; /******************** MODIFY SPECIAL CHARACTERS IN QUERY ********************/ //replace space with + $find_this = ' '; $paste_this = "+"; $query = str_replace($find_this, $paste_this, $query); //htmlspecialchars_decode $query = urlencode($query); //$action="http://search.tamu.edu/search?q=".$query."&access=p&entqr=0&ud=1&sort=date%3AD%3AL%3Ad1&output=xml_no_dtd&oe=UTF-8&ie=UTF-8&client=ag_frontend&proxystylesheet=ag_frontend&site=ag_collection&filter=0"; $action="http://search.tamu.edu/search?site=ag_collection&sort=date%3AD%3AL%3Ad1&client=ag_frontend&entqr=0&G=Google+Search&access=p&ip=165.91.106.64&ie=UTF-8&q=".$query."&ie=UTF-8&ud=1&proxystylesheet=ag_frontend&output=xml_no_dtd&start=".$package; } /******************** CURL ********************/ $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)"; $ch = curl_init($action); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($ch, CURLOPT_HEADER ,1); // DO NOT RETURN HTTP HEADERS curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL AS STRING vs DISPLAY $Rec_Data = curl_exec($ch); //echo $Rec_Data; //die; /******************** CURL END ********************/ /******************** DIVIDE INTO MAIN BODY AND NEXT PAGE ********************/ //MAIN BODY $skip_next_page = '0'; // return with next page options if ((ereg('*.*
',$Rec_Data,$regs))) { $find_this = '
'; $paste_this = " "; $main_body = str_replace($find_this, $paste_this, $regs[0]); $main_body = htmlspecialchars_decode($main_body); //echo $main_body; //die; } elseif(ereg('*.*',$Rec_Data,$regs)) { $result = ereg('*.*',$Rec_Data,$regs); $main_body = $regs[0]; $complete_phrase = $main_body; $skip_next_page = '1'; } // Did You Mean elseif(ereg('

Did you mean: *.*



',$Rec_Data,$regs) && $next_package != 1) { //did you mean $result = ereg('


*.*',$Rec_Data,$regs); //remove hr tag $find_this = '
'; $paste_this = " "; $did_str = str_replace($find_this, $paste_this, $regs[0]); $find_this = ''; $did_str = str_replace($find_this, $paste_this, $did_str); $skip_next_page = '1'; //raw did you mean search string prior to url replacement //echo $did_str . '
'; //locate start and end of string search? $start_str = strpos($did_str, "search?"); $end_str = strpos($did_str, "\">", $start_str + 1); //isolate substring $next_str = substr($did_str, $start_str, ($end_str - $start_str)); $find_this = 'search?'; $paste_this = ''; $next_str = str_replace($find_this, $paste_this, $next_str); //echo $next_str . '
'; //serialize string $urlencoded_str = urlencode($next_str); //add redirect back to this page $next_str = "index.php?next_package=1&q=".$query."&package=" . $urlencoded_str; //replace existing substring with newly constructed string $did_str = substr_replace($did_str, $next_str, $start_str, ($end_str - $start_str)); //echo $did_str; //die; $complete_phrase = $did_str; } // regular return with no next page elseif ((ereg('*.*


',$Rec_Data,$regs))) { //simple return with no next page $find_this = '

'; $paste_this = "

"; $main_body = str_replace($find_this, $paste_this, $regs[0]); $find_this = '

'; $main_body = str_replace($find_this, $paste_this, $main_body); $main_body = str_replace('

','',$main_body); $main_body = htmlspecialchars_decode($main_body); $skip_next_page = '1'; $complete_phrase = $main_body; } /******************** IF NEXT PAGE ISOLATE AND CLEAN ********************/ //if (strpos($Rec_Data,'*.*

',$Rec_Data,$regs); $next_page = str_replace($find_this, $paste_this, $regs[0]); //determine number of next page calls prior to removing search //$loop_max = substr_count($next_page,'", $start_str + 1); //isolate substring $next_str = substr($next_page, $start_str, ($end_str - $start_str)); //serialize string $urlencoded_str = urlencode($next_str); //isolate next value associated with substring $start_str_prev = strpos($next_str, "start="); $next_rec = substr($next_str, $start_str_prev+6, strlen($next_str)); $next_str = "q=".$query."&package=".$next_rec; //replace existing substring with newly constructed string if ($loop_count != $package/10) $next_page = substr_replace($next_page, $next_str, $start_str, ($end_str - $start_str)); $loop_count++; } /* append revised next page code to end of no_next_page_phrase*/ $complete_phrase = $main_body . '
'. $next_page; $complete_phrase = str_replace('·', "", $complete_phrase); $complete_phrase = str_replace('©', "", $complete_phrase); $complete_phrase = str_replace('♦', " ", $complete_phrase); $complete_phrase = str_replace('“', """, $complete_phrase); $complete_phrase = str_replace('”', """, $complete_phrase); $complete_phrase = str_replace('•', "", $complete_phrase); $complete_phrase = str_replace('’', "'", $complete_phrase); $complete_phrase = str_replace('‘', "'", $complete_phrase); $complete_phrase = str_replace('–', "-", $complete_phrase); $complete_phrase = str_replace('Cached', "", $complete_phrase); $complete_phrase = str_replace('Text Version', "", $complete_phrase); $complete_phrase = htmlspecialchars_decode($complete_phrase); } $complete_phrase = str_replace('
'; echo $complete_phrase; curl_close ($ch); ?>