function se_on_save_page($strSourceText, &$oPage) { seChangeLocale(); //the lib to include $oCurrentFile = new PFile(__FILE__); require_once $oCurrentFile->getParentPath() . SLASH . 'include' . SLASH . 'lib.searchengine.php'; if (!se_get_config('ACTIVATE', $bActivate)) { return $strSourceText; } if (!$bActivate) { return $strSourceText; } $returnval = true; if (!connectBdd()) { return false; } if (exist_page_search($oPage->getUrl())) { $type = 'update'; } else { $type = 'insert'; } switch ($type) { case 'insert': $returnval = insert_info_search($oPage, $strSourceText); break; case 'update': $returnval = update_info_search($oPage, $strSourceText); break; } closeBdd(); return $returnval ? $strSourceText : false; }
function query_search_engine($keyword) { if (!se_get_config('tablename', $strTable)) { return false; } if (!($cnx = connectBdd())) { return false; } $tabKeyword = split(' ', $keyword); $strK = ''; foreach ($tabKeyword as $k) { $strK .= $k . '.*'; } $strPublishedCondition = ''; if (!isConnected()) { $strPublishedCondition = ' AND published=1 '; } $sql = " SELECT *, MATCH(nom, url, texte) AGAINST('{$strK}') AS score \n\tFROM {$strTable} WHERE MATCH(nom, url, texte) AGAINST('{$keyword}') {$strPublishedCondition}\n\tORDER BY score DESC "; if (!($rest = mysql_query($sql, $cnx))) { return closeBdd(mysql_error($cnx)); } $result_search_engine = array(); while ($row = mysql_fetch_array($rest)) { $result_search_engine[] = $row; } closeBdd(); return $result_search_engine; }