'YahooDemo', 'type' => 'all', 'results' => 10, 'format' => 'html', 'language' => 'en', 'site' => $site ); $desc = "Options for Yahoo! Search plugin"; // autoload off since we only need options if searching $autoload = 'no'; add_option($ys_optionsName, $options, $desc, $autoload); return; } function ys_loadOptions() { global $ys_options, $ys_optionsName; $ys_options = get_option($ys_optionsName); if ( $ys_options === false) { ys_firstRun(); $ys_options = get_option($ys_optionsName); } return; } // hi-tech xml parsing function ys_getTag($xml, $tag) { $preg = "/<".$tag.">(.*?)<\/".$tag.">/si"; preg_match_all($preg, $xml, $matches); foreach ( $matches[1] as $value ) { $tags[] = $value; } return $tags; } // more hi-tech xml parsing function ys_getAttr($xml, $attr) { $preg = '/' . $attr . '\W*=\W*(\d+)/i'; preg_match($preg, $xml, $matches); $attrs = $matches[1]; return $attrs; } // format the yahoo query from what we know function ys_buildQuery() { global $ys_service, $ys_options; // only load when needed ys_loadOptions(); $q == False; if ( isset($_REQUEST['query']) ) { $q = $ys_service . '?query=' . rawurlencode($_REQUEST['query']); if ( ! empty($_REQUEST['start']) ) { $q .= "&start=" . $_REQUEST['start']; } foreach ($ys_options as $key => $value) { $q .= "&$key=$value"; } } return $q; } // handle paging function ys_nextPrev($total, $start, $last) { global $ys_options; $resultspp = $ys_options['results']; $encquery = rawurlencode($_REQUEST['query']); if($start > 1) { echo '« Previous Page'; } echo " — "; if( $last < $total ) { echo 'Next Page »'; } return; } // get it and print it function ys_showResults() { $query = ys_buildQuery(); $xml = file_get_contents($query); $arTitle = ys_getTag($xml, 'Title'); $arSummary = ys_getTag($xml, 'Summary'); $arUrl = ys_getTag($xml, 'Url'); $arClick = ys_getTag($xml, 'ClickUrl'); $arMod = ys_getTag($xml, 'ModificationDate'); $first = ys_getAttr($xml, 'firstResultPosition'); $returned = ys_getAttr($xml, 'totalResultsReturned'); $total = ys_getAttr($xml, 'totalResultsAvailable'); if ( $returned ) { $last = $first + $returned - 1; } else { $last = 0; } echo "

Found $total results, showing $first to $last

\n"; $dateFormat = get_settings('date_format'); $timeFormat = get_settings('time_format'); for ( $i = 0; $i < $returned; $i++) { $title = $arTitle[$i]; $summary = $arSummary[$i]; $url = $arUrl[$i]; $clickurl = $arClick[$i]; $lmod = $arMod[$i]; $lastmodified = date("$dateFormat \\a\\t $timeFormat", $lmod); echo <<

$title

$summary

Modified $lastmodified

RESULT; } ys_nextPrev($total, $first, $last); return; } function yahooSearchForm() { $query = ""; $showresults = 0; if ( isset($_REQUEST['query']) ) { $query = rawurldecode($_REQUEST['query']); $showresults = 1; } // The "Powered by..." text is required by the TOS, you did read the TOS // didn't you? Everyone's doing it; you should to. echo <<Powered by Yahoo! Search
SEARCH1; if ( $showresults ) { ys_showResults(); } return; } function ys_adminPanel() { if ( function_exists('add_options_page') ) { add_options_page('Yahoo! Search', 'Yahoo! Search', 9, basename(__FILE__), 'ys_optionsSubpanel'); } return; } // print the given array index as options for
A domain or hostname, not a URL nor a URI
You should not need to change this value. Application ID:
Request a Yahoo! appid (valid Yahoo! userid required)
Search Options
Results Per Page:
Search Type:
Format:
Language:
Language in which to display results. (complete list)
PANEL5; return; } add_action('admin_menu', 'ys_adminPanel'); ?>