From 46a304a302b6f4f3c6273768674f7a9dceea1842 Mon Sep 17 00:00:00 2001
From: Steve Sutton Your request could not be completed at this time, please try again later! Searcing
+
Website: ".$this->website."
Authentication: ".$this->auth);
+
+ }
+
+ /**
+ * Perform a search on the Web site
+ *
+ * @param string $query The user's search string
+ * @param string $operator Operator for the query terms (AND, OR)
+ * Default = 'OR'
+ * @param integer $start Starting result number
+ * Default = 0 (first page)
+ * @param integer $rows Number of rows per result page
+ * Default = 10
+ *
+ * @return string JSON of results or false if a failure
+ *
+ * @access public
+ */
+ public function search($query, $operator = 'OR', $start = 0, $rows = 10)
+ {
+
+ // Clear all the results data
+ $this->clearResults();
+
+ // Filter and validate supplied parameters
+ if (
+ (filter_var($query, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)) == false ||
+ (in_array($operator, array('OR', 'AND'))) == false
+ ) {
+ $this->errorMessage = 'search() - $query or $operator did not validate.';
+ $this->debug();
+ return false;
+ }
+
+ // strip any characters that cause a problem. Add more characters to array if needed.
+ $remove = array("'");
+ $query = htmlspecialchars_decode($query, ENT_QUOTES);
+ $query = str_replace("'", "", $query);
+
+ $start = ($start - 0);
+ $rows = ($rows - 0);
+
+
+ // Check if we have a valid query
+ if (trim($query) == '') {
+ $this->errorMessage = 'search() - No query supplied';
+ $this->debug();
+ return false;
+ }
+
+ // Create request URL
+ switch ($this->type) {
+ case 'field':
+ $url = OpenSearchServer.'/services/rest/index/'.$this->index.'/search/field/?'.$this->auth;
+ break;
+ case 'pattern':
+ $url = OpenSearchServer.'/services/rest/index/'.$this->index.'/search/pattern/?'.$this->auth;
+ break;
+ }
+ $this->debug('Request URL: '.$url);
+
+ // Update query and operator in request
+ $this->request['query'] = $query;
+ $this->request['start'] = $start;
+ $this->request['rows'] = $rows;
+ $this->request['operator'] = $operator;
+
+ // If host filter has not been turned off, set filter to only search the specified Website in the index
+ if ($this->filter) {
+
+ // Determine if there's a specific filter type and value - Default to host:
+ $query = 'host:"'.$this->website.'"';
+ if ($this->filterType) {
+ if ($this->filterValue) {
+ $query = $this->filterType.':"'.$this->filterValue.'"';
+ } else {
+ $query = $this->filterType.':"'.$this->website.'"';
+ }
+ }
+
+ // Set filter
+ $this->request['filters'] = array(
+ array(
+ "type" => "QueryFilter",
+ "negative" => false,
+ "query" => $query
+ )
+ );
+
+ } else {
+ unset($this->request['filters']);
+ }
+
+ // Set curl options
+ curl_setopt_array($this->curl, array(
+ CURLOPT_URL => $url,
+ CURLOPT_POST => true,
+ CURLOPT_POSTFIELDS => json_encode($this->request),
+ CURLOPT_HTTPHEADER => array("Content-type: application/json; charset=utf-8"),
+ CURLOPT_VERBOSE => 1,
+ CURLOPT_HEADER => 1
+ ));
+
+ $this->debug('Post fields: '.print_r($this->request,1)."
");
+
+ // Do curl call and get result;
+ try {
+ $res = curl_exec($this->curl);
+ } catch (Exception $e) {
+
+ // Problem doing curl call - return failure information
+ $this->error = $e;
+ $this->errorMessage = 'search() - '.curl_error($this->curl);
+ $this->debug($e);
+
+ // Log the error in the server error log
+ error_log('GLMSearch: search() - '.curl_error($this->curl));
+
+ return false;
+ }
+
+ // Parse out results elements
+ $this->httpStatus = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
+ $header_size = curl_getinfo($this->curl, CURLINFO_HEADER_SIZE);
+ $this->httpHeader = substr($res, 0, $header_size);
+ $this->rawResults = substr($res, $header_size);
+
+ // Curl result debug
+ $this->debug(
+ "crawlURL() - Curl response\n"
+ .'HTTP Status: '.$this->httpStatus."\n"
+ ."HTTP Header\n".$this->httpHeader."\n\n"
+ );
+
+ // Check HTTP status code
+ if ($this->httpStatus != 200) {
+ $this->errorMessage = 'search() - Received bad status code: '.$this->httpStatus."
RawResults: ".print_r($res,1)."
";
+ $this->debug();
+ return false;
+ }
+
+ // Debug information
+ $this->errorMessage = 'search() - Completed successfully.';
+ $this->debug($this->rawResults);
+
+ return $this->rawResults;
+ }
+
+ /**
+ * Convert raw search results JSON to a associative array
+ *
+ * @return array Array of results or false if a failure
+ *
+ * @access public
+ */
+ public function results2array()
+ {
+
+ // Check if we don't have any search results
+ if ($this->rawResults == false) {
+ $this->errorMessage = 'results2array() - No search results to convert.';
+ $this->debug();
+ return false;
+ }
+
+ // Response should be a json - convert to associative array
+ $this->resultArray = json_decode($this->rawResults, true);
+ if ($this->resultArray == null) {
+ // Problem decoding json - return failure information
+ $this->errorMessage = 'results2array() - '.$this->jsonErrorMsg();
+ $this->debug();
+ return false;
+ }
+
+ // Check if result "successful" flag isn't true
+ if (!$this->resultArray['successful']) {
+ $this->errorMessage = 'resuts2array() - Search result marked as not successful.';
+ $this->debug();
+ return false;
+ }
+
+ $this->errorMessage = 'results2array() - Completed successfully.';
+ $this->debug($this->resultArray);
+
+ return $this->resultArray;
+
+ }
+
+ /**
+ * Compress search results as associative array into
+ * more succinct result array for use with output template.
+ *
+ * @param $res Uncompressed search results array
+ *
+ * @return array Array of results or false if a failure
+ *
+ * @access public
+ */
+ public function compressResults()
+ {
+
+ // Check if we don't have valid input
+ if (!is_array($this->resultArray) || !$this->resultArray['successful']) {
+ $this->errorMessage = 'compressResults() - Successful search results not supplied.';
+ $this->debug();
+ return false;
+ }
+
+ // Calculate certain paging values
+ $rowsPerPage = $this->resultArray['rows'];
+ $thisPageStartIndex = $this->resultArray['start']; // Based on first result being 0
+ $thisPageStart = $thisPageStartIndex + 1; // Displayed first result number
+ $numbResults = $this->resultArray['numFound'];
+ $numbResultsOnPage = count($this->resultArray['documents']);
+ $lastResultOnPage = $thisPageStart + $numbResultsOnPage - 1;
+ $previousPageStartIndex = $thisPageStartIndex - $rowsPerPage;
+ if ($previousPageStartIndex < 0) {
+ $previousPageStartIndex = false;
+ }
+ $nextPageStartIndex = $thisPageStartIndex + $rowsPerPage;
+ if ($nextPageStartIndex > ($numbResults - 1)) {
+ $nextPageStartIndex = false;
+ }
+
+ // Build basic search results array
+ $this->result = array(
+ 'resultsPerPage' => $this->resultArray['rows'],
+ 'operator' => $this->request['operator'],
+ 'totalResults' => $numbResults,
+ 'firstResultOnPage' => $thisPageStart,
+ 'resultsOnPage' => $numbResultsOnPage,
+ 'lastResultOnPage' => $lastResultOnPage,
+ 'previousPageStartIndex' => $previousPageStartIndex,
+ 'nextPageStartIndex' => $nextPageStartIndex,
+ 'documents' => array()
+ );
+
+ // Add in results for each document
+ foreach ($this->resultArray['documents'] as $d) {
+
+ // Base document information
+ $doc = array(
+ 'score' => $d['score'],
+ 'collapseCount' => $d['collapseCount']
+ );
+
+ // Document fields (simple text fields)
+ foreach ($d['fields'] as $df) {
+ $doc[$df['fieldName']] = array(
+ 'type' => 'field',
+ 'name' => $df['fieldName'],
+ 'value' => (isset($df['values'][0]) ? $df['values'][0] : '')
+ );
+
+ }
+
+ // Document snippets (possible multiple snippets per each)
+ foreach ($d['snippets'] as $ds) {
+ $doc[$ds['fieldName']] = array(
+ 'type' => 'snippets',
+ 'name' => $ds['fieldName'],
+ 'snippets' => array()
+ );
+
+ // Process possible multiple snippet values
+ if (is_array($ds['values']) && count($ds['values']) > 0) {
+ foreach ($ds['values'] as $sv) {
+ $doc[$ds['fieldName']]['snippets'][] = $sv;
+ }
+ }
+
+ }
+
+ // Need to add processing of "functions" also here
+
+ // Look for null or blank title
+ if (empty($doc['title']['value']) && !empty($doc['url']['value'])) {
+ $doc['title']['value'] = $doc['url']['value'];
+ }
+
+ // Clean up lastModifiedDate if included
+ if (isset($doc['lastModifiedDate']) && isset($doc['lastModifiedDate']['value'])) {
+ $d = $doc['lastModifiedDate']['value'];
+ $doc['lastModifiedDate']['textValue'] = '';
+ if (trim($d) != '') {
+ $doc['lastModifiedDate']['textValue'] = substr($d, 0, 4).'-'.substr($d,4,2).'-'.substr($d,6,2);
+ }
+ }
+
+ // Add this document to result documents array
+ $this->result['documents'][] = $doc;
+
+ }
+
+ $this->errorMessage = 'compressResults() - Completed successfully.';
+ $this->debug($this->result);
+
+ return $this->result;
+ }
+
+ /**
+ * Render result using Smarty template
+ *
+ * NOTE: This does not use an OpenSearchServer Template.
+ * We can consider adding that functionality later.
+ *
+ * @param string $template Template to use for producing results (def
+ * @param string $base Base path to template
+ *
+ * @return void
+ * @access public
+ */
+ public function render($templateName = GLMSearch_TEMPLATE, $templateBasePath = GLMSearch_TEMPLATE_PATH)
+ {
+
+ $smarty = new Smarty();
+
+ // Setup required Smarty paths - Assumes that BASE_PATH for site is properly defined
+ $smarty->setTemplateDir($templateBasePath);
+ $smarty->setCompileDir(BASE_PATH.'/smarty/templates_c');
+ $smarty->setCacheDir(BASE_PATH.'/smarty/cache');
+
+ // If we have a result, add it to Smarty
+ $haveResult = false;
+ if ($this->result != false) {
+
+ $haveResult = true;
+
+ // Convert compressed result array to an object for Smarty
+ $result = json_decode(json_encode($this->result));
+ $smarty->assign('result', $result);
+
+ }
+
+ // Tell template whether we have a result
+ $smarty->assign('haveResult', $haveResult);
+
+ // Script URI
+ $smarty->assign('thisScript', BASE_URL);
+
+ // Some other parameters
+ $smarty->assign('matchAll', ($this->request['operator'] == 'AND' ? 'on' : ''));
+ // Note: use {$query|escape:'url'} in Smarty to use this parameter in a URL
+ $smarty->assign('query', $this->request['query']);
+
+ // Display Smarty Console if requested
+ if ($this->smartyConsole) {
+ Smarty_Internal_Debug::display_debug($smarty);
+ }
+
+ // Generate the page
+ $page = $smarty->fetch($templateName);
+
+ $this->errorMessage = 'render() - Completed successfully.';
+ $this->debug($smarty->tpl_vars);
+
+ return $page;
+ }
+
+ /**
+ * Do entire search and display process
+ *
+ * Uses the following POST/GET parameters
+ * query User's search string
+ * matchAll Optional checkbox to specify use of "AND" operator
+ *
+ * @param string $template Template to use for producing results (override default)
+ * @param string $base Base path to template (override default)
+ *
+ * @return void
+ * @access public
+ */
+ public function doSearch($templateName = GLMSearch_TEMPLATE, $templateBasePath = GLMSearch_TEMPLATE_PATH, $request = false)
+ {
+
+ $this->errorMessage = 'doSearch() called.';
+ $this->debug("Template name: ".$templateName."
Template base path: ".$templateBasePath."
Request: ".print_r($request,1));
+
+ // Check if receiving an array of parameters rather than REQUEST parameters
+ if (is_array($request) && count($request) > 0) {
+
+ // Look for query string
+ $query = '';
+ if (isset($request['query'])) {
+ $query = trim($request['query']);
+ }
+
+ // Look for matchAll (operator) flag
+ $operator = '';
+ if (isset($request['matchAll'])) {
+ $operator = $request['matchAll'];
+ }
+
+ // Look for start row
+ $start = 0;
+ if (isset($request['start'])) {
+ $start = ($request['start']-0);
+ }
+
+ // Look for rows - Default is maximium allowable for sitemaps
+ $rows = 50000;
+ if (isset($request['rows'])) {
+ $rows = ($request['rows']-0);
+ }
+
+ } else {
+
+ // get query string - try POST, but if that fails try GET
+ $query = filter_input(INPUT_POST, 'query', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
+ if ($query == null) {
+ $query = filter_input(INPUT_GET, 'query', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
+ }
+ $operator = ($_REQUEST['matchAll'] != '' ? 'AND' : 'OR');
+ $start = ($_REQUEST['start'] - 0);
+ $rows = ($_REQUEST['rows'] - 0);
+
+ }
+
+ // Try to do the query and process the results
+ if (
+ trim($query) != '' &&
+ $this->search($query, $operator, $start, $rows) &&
+ $this->results2array() &&
+ $this->compressResults()
+ ) { }
+
+ $page = $this->render($templateName, $templateBasePath);
+
+ return $page;
+ }
+
+ /**
+ * Create an XML Sitemap from search results
+ *
+ * @param string $template Template to use for producing results (override default)
+ * @param array $request Array of request parameters
+ * 'query' Required - Search String
+ * 'matchAll' Optional - Match all words option ('AND', 'OR')
+ * 'start' Optional - Start index
+ * 'rows' Optional - Results per page
+ *
+ * @return void
+ * @access public
+ */
+ public function xmlSitemap($templateName = 'Sitemap_XML_0.9.html')
+ {
+
+ // Search for * (matches everything)
+ $request = array(
+ 'query' => 'a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9',
+ 'matchAll' => 'OR',
+ 'start' => 0,
+ 'rows' => 50000
+ );
+ $page = $this->doSearch($templateName, GLMSearch_TEMPLATE_PATH, $request);
+ $this->debug($page);
+ return $page;
+ }
+
+ /**
+ * Tell OpenSearchServer to crawl a particular URL pattern
+ *
+ * @param integer $pattern URL Pattern
+ *
+ * @return array Object Results from Search Engine or false if failure.
+ *
+ * @access public
+ */
+ public function crawlURL($pattern)
+ {
+
+ // Clear all the results data
+ $this->clearResults();
+
+ // Filter and validate supplied parameters
+ if (($pattern = filter_var($pattern, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)) == false) {
+ $this->errorMessage = 'crawlURL() - $pattern did not validate';
+ $this->debug();
+ return false;
+ }
+
+ // Create request URL
+ $param = 'url='.$pattern;
+ $url = OpenSearchServer.'/services/rest/index/'.$this->index.'/crawler/web/crawl?'.$this->auth.'&'.$param;
+
+ // Set curl options
+ curl_setopt_array($this->curl, array(
+ CURLOPT_URL => $url,
+ CURLOPT_POST => false,
+ CURLOPT_VERBOSE => 1,
+ CURLOPT_HEADER => 1
+ ));
+
+ // Do curl call and get result;
+ try {
+ $res = curl_exec($this->curl);
+ } catch (Exception $e) {
+ // Problem doing curl call - return failure information
+ $this->error = $e;
+ $this->errorMessage = 'crawlURL() - '.curl_error($this->curl);
+ $this->debug($e);
+ return false;
+ }
+
+ // Parse out results elements
+ $this->httpStatus = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
+ $header_size = curl_getinfo($this->curl, CURLINFO_HEADER_SIZE);
+ $this->httpHeader = substr($res, 0, $header_size);
+ $this->rawResults = substr($res, $header_size);
+
+ // Curl result debug
+ $this->debug(
+ "crawlURL() - Curl response\n"
+ .'HTTP Status: '.$this->httpStatus."\n"
+ ."HTTP Header\n".$this->httpHeader."\n\n"
+ );
+
+ // Check HTTP status code
+ if ($this->httpStatus != 200) {
+ $this->errorMessage = 'crawlURL() - Received bad status code: '.$this->httpStatus;
+ $this->debug($this->rawResults);
+ return false;
+ }
+
+ // Debug information
+ $this->errorMessage = 'crawlURL() - Completed successfully.';
+ $this->debug($this->rawResults);
+
+ return json_decode($this->rawResults);
+ }
+
+ /**
+ * Get text message for last JSON error
+ *
+ * @return void
+ * @access private
+ */
+ private function jsonErrorMsg()
+ {
+
+ // Get running version of PHP
+ if (defined('PHP_VERSION_ID')) {
+ $php = PHP_VERSION_ID;
+ } else {
+ $version = explode('.', PHP_VERSION);
+ $php = ($version[0] * 10000 + $version[1] * 100 + $version[2]);
+ }
+
+ // If PHP version 5.5 or later
+ if ($php >= 50500) {
+
+ // Just ask for the last json error message
+ $msg = json_last_error_msg();
+
+ } else {
+
+ // Running ealier PHP so set message based on last json error type
+ switch (json_last_error()) {
+
+ case JSON_ERROR_NONE:
+ $msg = 'No errors';
+ break;
+
+ case JSON_ERROR_DEPTH:
+ $msg = 'Maximum stack depth exceeded';
+ break;
+
+ case JSON_ERROR_STATE_MISMATCH:
+ $msg = 'Underflow or the modes mismatch';
+ break;
+
+ case JSON_ERROR_CTRL_CHAR:
+ $msg = 'Unexpected control character found';
+ break;
+
+ case JSON_ERROR_SYNTAX:
+ $msg = 'Syntax error, malformed JSON';
+ break;
+
+ case JSON_ERROR_UTF8:
+ $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
+ break;
+
+ default:
+ $msg = 'Unknown error';
+ break;
+ }
+ }
+
+ return $msg;
+
+ }
+
+ /**
+ * Clear all request and results data - used before a new curl call
+ *
+ * @return void
+ * @access private
+ */
+ private function clearResults()
+ {
+
+ /*
+ * Reset request to default
+ * (Note: Need to add more explanation for this data.)
+ */
+ $this->request = array(
+ 'query' => false, // Query String
+ 'start' => 0, // Result number for start of page
+ 'rows' => 10, // Number of rows to display per page
+ 'lang' => 'ENGLISH', // Language (in all caps)
+ 'operator' => 'AND', // Either AND or OR - And matches pages containing all words
+ 'collapsing' => array(
+ 'max' => 2,
+ 'mode' => 'OFF',
+ 'type' => 'OPTIMIZED'
+ ),
+ 'geo' => null,
+ 'filters' => null,
+ 'sorts' => null,
+ 'returnedFields' => array(
+ 'url',
+ 'title',
+ 'lastModifiedDate'
+ ),
+ 'snippets' => array(
+ array(
+ 'field' => 'content',
+ 'tag' => 'b',
+ 'separator' => '...',
+ 'maxSize' => 300,
+ 'maxNumber' => 1,
+ 'fragmenter' => 'SENTENCE'
+ )
+ ),
+ 'facets' => null,
+ 'joins' => null,
+ 'enableLog' => null,
+ 'customLogs' => null,
+ 'searchFields' => array(
+ array(
+ 'field' => 'title',
+ 'boost'=> 10
+ ),
+ array(
+ 'field' => 'content',
+ 'boost'=> 1
+ ),
+ array(
+ 'field' => 'titleExact',
+ 'boost'=> 10
+ ),
+ array(
+ 'field' => 'contentExact',
+ 'boost'=> 1
+ )
+ )
+ );
+ // Clear results
+ $this->httpStatus = false;
+ $this->httpHeader = false;
+ $this->rawResults = false;
+ $this->resultArray = false;
+ $this->result = false;
+ $this->errorMessage = false;
+ $this->error = false;
+
+ }
+
+ /**
+ * Display debug information if debug is on
+ *
+ * @return void
+ * @access private
+ */
+ public function debug($d = false)
+ {
+ if ($this->debug) {
+ echo $this->errorMessage."
";
+
+ if ($d != false) {
+ echo "".print_r($d,1)."
";
+ }
+ }
+ }
+
+}
+
+?>
diff --git a/recrawl.php b/recrawl.php
new file mode 100644
index 0000000..14024be
--- /dev/null
+++ b/recrawl.php
@@ -0,0 +1,77 @@
+
+
+
+
+ Index or re-index a specific Web page for site search engine.
+
+
+define('BASE_PATH', '/var/www/server/CommonApps/GLMSearch/V1.1/');
+
+switch ($_ENV['GLM_HOST_ID']) {
+ case 'PRODUCTION' :
+ case 'DEVELOPMENT' :
+ case 'STEVE' :
+ define('BASE_URL', 'http://stats.gaslightmedia.com/GLMSearch/V1.1/recrawl.php');
+ break;
+ case 'CHUCK' :
+ define('BASE_URL', 'http://192.168.44.7/CommonApps/GLMSearch/V1.1/recrawl.php');
+ break;
+ default :
+ die('
Index: $index
Site: $site
Pattern: $pattern
Login: $login
Key: $key
Debug: ".($debug ? 'Yes' : 'No')."
+
';
+
+ if ($res != false && $res->successful && preg_match('/Fetched - Parsed - Indexed/',$res->info)) {
+ echo 'Index of page: '.$pattern.' ';
+ } else {
+ echo 'Response: '.$res->info.'
+ Error information: '.print_r($res,1).'
+ ';
+ }
+
+ echo "
+ Please check the address you\'re supplying above. If you believe the address is a valid
+ Web page and you continue to have problems, please contact Gaslight Media for support
+ and provide the information supplied above.
+
Re-Crawling using a URL pattern
Site: $site
URL Pattern: $pattern
".print_r($res,1).""; +} else { + echo "Craw was not successful.
".print_r($res,1).""; +} + +?> diff --git a/test/remoteTest.php b/test/remoteTest.php new file mode 100644 index 0000000..5b1a704 --- /dev/null +++ b/test/remoteTest.php @@ -0,0 +1,4 @@ + +include '../docs/remoteSearch.inc'; +echo $glmsResults; +?> \ No newline at end of file diff --git a/test/test.php b/test/test.php new file mode 100644 index 0000000..c31c870 --- /dev/null +++ b/test/test.php @@ -0,0 +1,126 @@ + +/** + * Test GLMSearch Class + */ + +/* + * *** BE SURE TO SETUP THESE PARAMETERS BEFORE RUNNING TEST *** + * + * These defined parameters are usually provided by the site. + * + * Note that BASE_PATH would normally be the for the site. This + * is used to find the Smarty compile directory for the site, + * which should be created automatically. + */ +define('BASE_PATH', '/var/www/server/CommonApps/GLMSearch/V1.1/'); +define('BASE_URL', 'http://192.168.44.7/CommonApps/GLMSearch/V1.1/test/test.php'); + +/* + * These are required parameters to use the search server. + * + * $site The "index" as created by "Create a new indes" + * in the OpenSearchServer administrative interface. + * $login Login for access to the API as created under "Privileges" + * in the OpenSearchServer administrative interface. + * Use 'WebsiteServices' for all sites. (Sites are + * separated by "index".) + * $key API Key created along with login. The key below + * is for use with all sites. + * + * These parameters should normally be specified in the + * config/application.ini file as follows. + * + * glmsearch.site = "demo.gaslightmedia.com" + * glmsearch.login = "WebsiteServices" + * glmsearch.key = "3cd270eda427d55874aafa45919f7026" + * + */ +$index = 'Index_1'; +$site = 'www.wmta.org'; +$login = 'WebsiteServices'; +$key = '829800701e8440b67a78e3afbefa1049'; + + +$debug = true; // Tell the glmSearch class whether you want debug output. +$filter = true; // Tell the glmSearch class whether to use $site as a host filter. + +/* + * Load and instantiate search class + * + * The file included is normally '/var/www/server/CommonApps/GLMSearch/V1.1/glmSearch.inc'. + * + * $debug is optional. + */ +require('../glmSearch.inc'); +$glmSearch = new glmSearch($site, $login, $key, $debug, $index, $filter); + +/* + * This will turn on the Smarty console for GLMSearch. + * The Smarty console will show in a separate window and + * should contain all parameters available to the template. + */ +// $glmSearch->smartyConsole = true; + +/* + * Here's the easy way using the default template. + */ +$searchPage = $glmSearch->doSearch(); + +// Display the produced page +echo $searchPage; + +exit; + + + +/* The hard way to do all this. + * The easy way is to use the doSearch() method shown above. + +// Check if we have a query string +if (trim($_REQUEST['query']) != '') { + + // Check for match all terms + $operator = 'OR'; + if ($_REQUEST['matchAll'] != '') { + $operator = 'AND'; + } + + //echo "Performing search...
".$r.""; + + //echo "Converting raw results to array...
".print_r($r,1).""; + + //echo "Compressing results into better organized array...
".print_r($r,1).""; + +} // if have a query + +//echo "Rendering results with Smarty...