MDL-10234
[moodle-linuxchix.git] / search / indexersplash.php
blob913e2ae669b3321f710f182628bd4c15e785b288
1 <?php
2 /* This file serves as a splash-screen (entry page) to the indexer script -
3 * it is in place to prevent accidental reindexing which can lead to a loss
4 * of time, amongst other things.
5 * */
7 require_once('../config.php');
8 require_once("$CFG->dirroot/search/lib.php");
10 require_login();
12 if (empty($CFG->enableglobalsearch)) {
13 error('Global searching is not enabled.');
16 if (!isadmin()) {
17 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
18 } //if
20 //check for php5 (lib.php)
21 if (!search_check_php5()) {
22 $phpversion = phpversion();
23 mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version $phpversion)");
24 exit(0);
25 } //if
27 require_once("$CFG->dirroot/search/indexlib.php");
28 $indexinfo = new IndexInfo();
30 if ($indexinfo->valid()) {
31 mtrace("<pre>The data directory ($indexinfo->path) contains $indexinfo->filecount files, and\n"
32 ."there are ".$indexinfo->dbcount." records in the <em>search_documents</em> table.\n"
33 ."\n"
34 ."This indicates that you have already succesfully indexed this site. Follow the link\n"
35 ."if you are sure that you want to continue indexing - this will replace any existing\n"
36 ."index data (no Moodle data is affected).\n"
37 ."\n"
38 ."You are encouraged to use the 'Test indexing' script before continuing onto\n"
39 ."indexing - this will check if the modules are set up correctly. Please correct\n"
40 ."any errors before proceeding.\n"
41 ."\n"
42 ."<a href='tests/index.php'>Test indexing</a> or "
43 ."<a href='indexer.php?areyousure=yes'>Continue indexing</a> or <a href='index.php'>Back to query page</a>."
44 ."</pre>");
45 } else {
46 header('Location: indexer.php?areyousure=yes');
47 } //else