0) die("This version of the Zoom search script requires PHP 4.2.0 or higher.
You are currently using: PHP " . phpversion() . "
"); if ((version_compare(PHP_VERSION, '5.3.5') > 0 && version_compare(PHP_VERSION, '5.3.5') < 0) || (version_compare(PHP_VERSION, '5.2.17') < 0)) { // Protection from floating point bug in PHP engine if (strpos(str_replace('.', '', serialize($_REQUEST)), '22250738585072011') !== false) { header('Status: 422 Unprocessable Entity'); die(); } } $SETTINGSFILE = dirname(__FILE__)."/settings.php"; $WORDMAPFILE = dirname(__FILE__)."/zoom_wordmap.zdat"; $DICTIONARYFILE = dirname(__FILE__)."/zoom_dictionary.zdat"; $PAGEDATAFILE = dirname(__FILE__)."/zoom_pagedata.zdat"; $SPELLINGFILE = dirname(__FILE__)."/zoom_spelling.zdat"; $PAGETEXTFILE = dirname(__FILE__)."/zoom_pagetext.zdat"; $PAGEINFOFILE = dirname(__FILE__)."/zoom_pageinfo.zdat"; $RECOMMENDEDFILE = dirname(__FILE__)."/zoom_recommended.zdat"; // Check for dependent files if (!file_exists($SETTINGSFILE) || !file_exists($WORDMAPFILE) || !file_exists($DICTIONARYFILE)) { print("Zoom files missing error: Zoom is missing one or more of the required index data files.
Please make sure the generated index files are uploaded to the same path as this search script.
"); return; } require($SETTINGSFILE); if ($Spelling == 1 && !file_exists($SPELLINGFILE)) print("Zoom files missing error: Zoom is missing the 'zoom_spelling.zdat' file required for the Spelling Suggestion feature which has been enabled.
"); // ---------------------------------------------------------------------------- // Settings // ---------------------------------------------------------------------------- // The options available in the dropdown menu for number of results // per page $PerPageOptions = array(10, 20, 50, 100); /* // For foreign language support, setlocale may be required on the server for // wildcards and highlighting to work. Uncomment the following lines and specify // the appropriate locale information //if (setlocale(LC_ALL, "ru_RU.cp1251") == false) // for russian // print("Failed to change locale setting or locale setting invalid"); */ // Index format information $PAGEDATA_URL = 0; $PAGEDATA_TITLE = 1; $PAGEDATA_DESC = 2; $PAGEDATA_IMG = 3; $MaxPageDataLineLen = 5178; $METAFIELD_TYPE = 0; $METAFIELD_NAME = 1; $METAFIELD_SHOW = 2; $METAFIELD_FORM = 3; $METAFIELD_METHOD = 4; $METAFIELD_DROPDOWN = 5; $METAFIELD_TYPE_NUMERIC = 0; $METAFIELD_TYPE_TEXT = 1; $METAFIELD_TYPE_DROPDOWN = 2; $METAFIELD_TYPE_MULTI = 3; $METAFIELD_TYPE_MONEY = 4; $METAFIELD_METHOD_EXACT = 0; $METAFIELD_METHOD_LESSTHAN = 1; $METAFIELD_METHOD_LESSTHANORE = 2; $METAFIELD_METHOD_GREATERTHAN = 3; $METAFIELD_METHOD_GREATERTHANORE = 4; $METAFIELD_METHOD_SUBSTRING = 5; $METAFIELD_NOVALUE_MARKER = 4294967295; // ---------------------------------------------------------------------------- // Parameter initialisation // ---------------------------------------------------------------------------- // Send HTTP header to define meta charset if (isset($Charset) && $NoCharset == 0) header("Content-Type: text/html; charset=" . $Charset); // For versions of PHP before 4.1.0 // we will emulate the superglobals by creating references // NOTE: references created are NOT superglobals if (!isset($_SERVER) && isset($HTTP_SERVER_VARS)) $_SERVER = &$HTTP_SERVER_VARS; if (!isset($_GET) && isset($HTTP_GET_VARS)) $_GET = &$HTTP_GET_VARS; if (!isset($_POST) && isset($HTTP_POST_VARS)) $_POST = &$HTTP_POST_VARS; // fix get/post variables if magic quotes are enabled if (get_magic_quotes_gpc() == 1) { if (isset($_GET)) while (list($key, $value) = each($_GET)) { if (!is_array($value)) $_GET["$key"] = stripslashes($value); } if (isset($_POST)) while (list($key, $value) = each($_POST)) $_POST["$key"] = stripslashes($value); } // check magic_quotes for runtime stuff (reading from files, etc) if (get_magic_quotes_runtime() == 1) set_magic_quotes_runtime(0); // we use the method=GET and 'query' parameter now (for sub-result pages etc) $IsZoomQuery = 0; if (isset($_GET['zoom_query'])) { $query = $_GET['zoom_query']; $IsZoomQuery = 1; } else $query = ""; // number of results per page, defaults to 10 if not specified if (isset($_GET['zoom_per_page'])) { $per_page = intval($_GET['zoom_per_page']); if ($per_page < 1) $per_page = 1; } else $per_page = 10; // current result page number, defaults to the first page if not specified $NewSearch = 0; if (isset($_GET['zoom_page'])) { $page = intval($_GET['zoom_page']); if ($page < 1) $page = 1; } else { $page = 1; $NewSearch = 1; } // AND operator. // 1 if we are searching for ALL terms // 0 if we are searching for ANY terms (default) if (isset($_GET['zoom_and'])) $and = intval($_GET['zoom_and']); elseif (isset($DefaultToAnd) && $DefaultToAnd == 1) $and = 1; else $and = 0; // for category support if ($UseCats == 1) { if (isset($_GET['zoom_cat'])) { if (is_array($_GET['zoom_cat'])) $cat = $_GET['zoom_cat']; else $cat = array($_GET['zoom_cat']); $cat = array_filter($cat, "is_numeric"); } else $cat = array(-1); // default to search all categories $num_zoom_cats = count($cat); if ($num_zoom_cats == 0) $cat = array(-1); // default to search all categories } // for sorting options // zero is default (relevance) // 1 is sort by date (if Date/Time is available) if (isset($_GET['zoom_sort'])) $sort = intval($_GET['zoom_sort']); else $sort = 0; $LinkBackJoinChar = "?"; if (isset($LinkBackURL) == false || strlen($LinkBackURL) < 1) $SelfURL = htmlspecialchars($_SERVER['PHP_SELF']); else { $SelfURL = $LinkBackURL; } if (strchr($SelfURL, '?')) $LinkBackJoinChar = "&"; // init. link target string $zoom_target = ""; if ($UseLinkTarget == 1 && isset($LinkTarget)) $zoom_target = " target=\"" . $LinkTarget . "\" "; $UseMBFunctions = 0; if ($UseUTF8 == 1) { if (function_exists('mb_strtolower')) $UseMBFunctions = 1; } if ($UseStemming == 1) { $porterStemmer = new PorterStemmer(); } // ---------------------------------------------------------------------------- // Template buffers // ---------------------------------------------------------------------------- // defines for output elements $OUTPUT_FORM_START = 0; $OUTPUT_FORM_END = 1; $OUTPUT_FORM_SEARCHBOX = 2; $OUTPUT_FORM_SEARCHBUTTON = 3; $OUTPUT_FORM_RESULTSPERPAGE = 4; $OUTPUT_FORM_MATCH = 5; $OUTPUT_FORM_CATEGORIES = 6; $OUTPUT_FORM_CUSTOMMETA = 7; $OUTPUT_HEADING = 8; $OUTPUT_SUMMARY = 9; $OUTPUT_SUGGESTION = 10; $OUTPUT_PAGESCOUNT = 11; $OUTPUT_SORTING = 12; $OUTPUT_SEARCHTIME = 13; $OUTPUT_RECOMMENDED = 14; $OUTPUT_PAGENUMBERS = 15; $OUTPUT_CATSUMMARY = 16; $OUTPUT_TAG_COUNT = 17; $OutputBuffers = array_fill(0, $OUTPUT_TAG_COUNT, ""); $OutputResultsBuffer = ""; $TemplateShowTags = array( "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" ); $TemplateDefaultTag = ""; $TemplateDefaultTagLen = strlen($TemplateDefaultTag); $TemplateSearchFormTag = ""; $TemplateSearchFormTagLen = strlen($TemplateSearchFormTag); $TemplateResultsTag = ""; $TemplateResultsTagLen = strlen($TemplateResultsTag); $TemplateQueryTag = ""; $TemplateQueryTagLen = strlen($TemplateQueryTag); $OutputBuffers[$OUTPUT_FORM_START] = "
"; $OutputBuffers[$OUTPUT_FORM_END] = "
"; // Indexes for dict structure $DICT_WORD = 0; $DICT_PTR = 1; $DICT_VARCOUNT = 2; $DICT_VARIANTS = 3; // ---------------------------------------------------------------------------- // Functions // ---------------------------------------------------------------------------- function ShowDefaultForm() { global $OutputBuffers; global $OUTPUT_FORM_SEARCHBOX, $OUTPUT_FORM_SEARCHBUTTON, $OUTPUT_FORM_RESULTSPERPAGE; global $OUTPUT_FORM_MATCH, $OUTPUT_FORM_CATEGORIES, $OUTPUT_FORM_CUSTOMMETA; global $OUTPUT_FORM_START, $OUTPUT_FORM_END; print($OutputBuffers[$OUTPUT_FORM_START]); print($OutputBuffers[$OUTPUT_FORM_SEARCHBOX]); print($OutputBuffers[$OUTPUT_FORM_SEARCHBUTTON]); print($OutputBuffers[$OUTPUT_FORM_RESULTSPERPAGE]); print($OutputBuffers[$OUTPUT_FORM_MATCH]); print($OutputBuffers[$OUTPUT_FORM_CATEGORIES]); print($OutputBuffers[$OUTPUT_FORM_CUSTOMMETA]); print($OutputBuffers[$OUTPUT_FORM_END]); } function ShowDefaultSearchPage() { global $OutputResultsBuffer; global $OutputBuffers; global $OUTPUT_HEADING, $OUTPUT_SUMMARY, $OUTPUT_SUGGESTION, $OUTPUT_PAGESCOUNT; global $OUTPUT_RECOMMENDED, $OUTPUT_SORTING, $OUTPUT_PAGENUMBERS, $OUTPUT_SEARCHTIME; global $OUTPUT_CATSUMMARY; ShowDefaultForm(); // now show the default results layout print($OutputBuffers[$OUTPUT_HEADING]); print($OutputBuffers[$OUTPUT_SUMMARY]); print($OutputBuffers[$OUTPUT_CATSUMMARY]); print($OutputBuffers[$OUTPUT_SUGGESTION]); print($OutputBuffers[$OUTPUT_PAGESCOUNT]); print($OutputBuffers[$OUTPUT_RECOMMENDED]); print($OutputBuffers[$OUTPUT_SORTING]); print($OutputResultsBuffer); print($OutputBuffers[$OUTPUT_PAGENUMBERS]); print($OutputBuffers[$OUTPUT_SEARCHTIME]); } function ShowTemplate() { global $ZoomInfo; global $OutputBuffers; global $TemplateShowTags; global $OUTPUT_TAG_COUNT; global $TemplateSearchFormTag, $TemplateSearchFormTagLen; global $TemplateDefaultTag, $TemplateDefaultTagLen; global $TemplateResultsTag, $TemplateResultsTagLen; global $OutputResultsBuffer; global $TemplateQueryTag, $TemplateQueryTagLen, $queryForHTML; // DO NOT MODIFY THE TEMPLATE FILENAME BELOW: $TemplateFilename = "search_template.html"; // Note that there is no practical need to change the TemplateFilename. This file // is not visible to the end user. The search link on your website should point to // "search.php", and not the template file. // // Note also that you cannot change the filename to a PHP or ASP file. // The template file will only be treated as a static HTML page and changing the // extension will not alter this behaviour. Please see this FAQ support page // for a solution: http://www.wrensoft.com/zoom/support/faq_ssi.html //Open and print start of result page template $TemplateFilename = dirname(__FILE__) . "/" . $TemplateFilename; $template = file ($TemplateFilename); $numtlines = count($template); //Number of lines in the template $template_line = 0; $templatePtr = $template[$template_line]; while ($template_line < $numtlines && $templatePtr != "") { $tagPos = strpos($templatePtr, "\n"; // Replace the key text with the following if ($FormFormat > 0) { // Insert the form $OutputBuffers[$OUTPUT_FORM_SEARCHBOX] = $STR_FORM_SEARCHFOR . " \n"; $OutputBuffers[$OUTPUT_FORM_SEARCHBUTTON] = "\n"; if ($FormFormat == 2) { $OutputBuffers[$OUTPUT_FORM_RESULTSPERPAGE] = "" . $STR_FORM_RESULTS_PER_PAGE . "\n"; $OutputBuffers[$OUTPUT_FORM_RESULTSPERPAGE] .= "

\n"; if ($UseCats) { $OutputBuffers[$OUTPUT_FORM_CATEGORIES] = "\n"; $OutputBuffers[$OUTPUT_FORM_CATEGORIES] .= $STR_FORM_CATEGORY . " "; if ($SearchMultiCats) { $OutputBuffers[$OUTPUT_FORM_CATEGORIES] .= "