<?php
-/**
-* Global Search Engine for Moodle
-*
-* @package search
-* @category core
-* @subpackage search_engine
-* @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
-* @date 2008/03/31
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-*
-* Asynchronous adder for new indexable contents
-*
-* Major chages in this review is passing the xxxx_db_names return to
-* multiple arity to handle multiple document types modules
-*/
-
-/**
-* includes and requires
-*/
-require_once('../config.php');
-require_once("$CFG->dirroot/search/lib.php");
+ /**
+ * Global Search Engine for Moodle
+ *
+ * @package search
+ * @category core
+ * @subpackage search_engine
+ * @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+ * @date 2008/03/31
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ *
+ * Asynchronous adder for new indexable contents
+ *
+ * Major chages in this review is passing the xxxx_db_names return to
+ * multiple arity to handle multiple document types modules
+ */
+
+ /**
+ * includes and requires
+ */
+ require_once('../config.php');
+ require_once("$CFG->dirroot/search/lib.php");
+ require_once("$CFG->dirroot/search/indexlib.php");
+
+/// makes inclusions of the Zend Engine more reliable
+ $separator = (array_key_exists('WINDIR', $_SERVER)) ? ';' : ':' ;
+ ini_set('include_path', $CFG->dirroot.'\search'.$separator.ini_get('include_path'));
/// checks global search activation
error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
}
- require_once("$CFG->dirroot/search/indexlib.php");
+/// check for php5 (lib.php)
+
+ if (!search_check_php5()) {
+ $phpversion = phpversion();
+ mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")");
+ exit(0);
+ }
- $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+ try {
+ $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+ } catch(LuceneException $e) {
+ mtrace("Could not construct a valid index. Maybe the first indexation was never made, or files might be corrupted. Run complete indexation again.");
+ return;
+ }
$dbcontrol = new IndexDBControl();
$addition_count = 0;
$startindextime = time();
mtrace('Index size before: '.$CFG->search_index_size."\n");
/// get all modules
-
if ($mods = get_records_select('modules')) {
/// append virtual modules onto array
mtrace("Added $addition_count documents.");
mtrace('Index size after: '.$index->count());
-?>
+?>
\ No newline at end of file
<?php
-/**
-* Global Search Engine for Moodle
-*
-* @package search
-* @category core
-* @subpackage search_engine
-* @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
-* @date 2008/03/31
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-*
-* Asynchronous index cleaner
-*
-* Major chages in this review is passing the xxxx_db_names return to
-* multiple arity to handle multiple document types modules
-*/
-
-/**
-* includes and requires
-*/
-require_once('../config.php');
-require_once("$CFG->dirroot/search/lib.php");
-
-
- require_login();
+ /**
+ * Global Search Engine for Moodle
+ *
+ * @package search
+ * @category core
+ * @subpackage search_engine
+ * @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+ * @date 2008/03/31
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ *
+ * Asynchronous index cleaner
+ *
+ * Major chages in this review is passing the xxxx_db_names return to
+ * multiple arity to handle multiple document types modules
+ */
+
+ /**
+ * includes and requires
+ */
+ require_once('../config.php');
+ require_once("$CFG->dirroot/search/lib.php");
+ require_once("$CFG->dirroot/search/indexlib.php");
+/// makes inclusions of the Zend Engine more reliable
+ $separator = (array_key_exists('WINDIR', $_SERVER)) ? ';' : ':' ;
+ ini_set('include_path', $CFG->dirroot.'\search'.$separator.ini_get('include_path'));require_login();
+
+/// checks global search activation
if (empty($CFG->enableglobalsearch)) {
error(get_string('globalsearchdisabled', 'search'));
}
error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
} //if
- require_once("$CFG->dirroot/search/indexlib.php");
+/// check for php5 (lib.php)
+ if (!search_check_php5()) {
+ $phpversion = phpversion();
+ mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")");
+ exit(0);
+ }
- $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+ try {
+ $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+ } catch(LuceneException $e) {
+ mtrace("Could not construct a valid index. Maybe the first indexation was never made, or files might be corrupted. Run complete indexation again.");
+ return;
+ }
$dbcontrol = new IndexDBControl();
$deletion_count = 0;
$startcleantime = time();
mtrace('Starting clean-up of removed records...');
mtrace('Index size before: '.$CFG->search_index_size."\n");
+/// check all modules
if ($mods = get_records_select('modules')) {
$mods = array_merge($mods, search_get_additional_modules());
<?php
-/**
-* Global Search Engine for Moodle
-*
-* @package search
-* @category core
-* @subpackage search_engine
-* @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
-* @date 2008/03/31
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-*
-* Index asynchronous updator
-*
-* Major chages in this review is passing the xxxx_db_names return to
-* multiple arity to handle multiple document types modules
-*/
+ /**
+ * Global Search Engine for Moodle
+ *
+ * @package search
+ * @category core
+ * @subpackage search_engine
+ * @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+ * @date 2008/03/31
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ *
+ * Index asynchronous updator
+ *
+ * Major chages in this review is passing the xxxx_db_names return to
+ * multiple arity to handle multiple document types modules
+ */
+
+ /**
+ * includes and requires
+ */
+ require_once('../config.php');
+ require_once("$CFG->dirroot/search/lib.php");
+ require_once("$CFG->dirroot/search/indexlib.php");
-/**
-* includes and requires
-*/
-require_once('../config.php');
-require_once("$CFG->dirroot/search/lib.php");
+/// makes inclusions of the Zend Engine more reliable
+ $separator = (array_key_exists('WINDIR', $_SERVER)) ? ';' : ':' ;
+ ini_set('include_path', $CFG->dirroot.'\search'.$separator.ini_get('include_path'));require_login();
/// checks global search activation
error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
}
- require_once("$CFG->dirroot/search/indexlib.php");
-
- $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+/// check for php5 (lib.php)
+ if (!search_check_php5()) {
+ $phpversion = phpversion();
+ mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")");
+ exit(0);
+ }
+
+ try {
+ $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+ } catch(LuceneException $e) {
+ mtrace("Could not construct a valid index. Maybe the first indexation was never made, or files might be corrupted. Run complete indexation again.");
+ return;
+ }
$dbcontrol = new IndexDBControl();
$update_count = 0;
$indexdate = $CFG->search_indexer_update_date;
mtrace(" Add: $add->title (database id = $add->dbid, moodle instance id = $add->docid)");
$index->addDocument($add);
}
- } else {
+ }
+ else{
mtrace("No types to update.\n");
}
mtrace("Finished $mod->name.\n");