2 /* Prints some basic statistics about the current index.
4 * Does some diagnostics if you are logged in as an administrator.
7 require_once('../config.php');
8 require_once("$CFG->dirroot/search/lib.php");
10 if ($CFG->forcelogin
) {
14 if (empty($CFG->enableglobalsearch
)) {
15 error('Global searching is not enabled.');
18 //check for php5, but don't die yet
19 if ($check = search_check_php5()) {
20 require_once("$CFG->dirroot/search/indexlib.php");
22 $indexinfo = new IndexInfo();
25 if (!$site = get_site()) {
26 redirect("index.php");
29 $strsearch = "Search"; //get_string();
30 $strquery = "Search statistics"; //get_string();
32 print_header("$site->shortname: $strsearch: $strquery", "$site->fullname",
33 "<a href=\"index.php\">$strsearch</a> -> $strquery");
35 //keep things pretty, even if php5 isn't available
37 print_heading(search_check_php5(true));
42 print_simple_box_start('center', '100%', '', 20);
43 print_heading($strquery);
45 print_simple_box_start('center', '', '', 20);
47 //this table is only for admins, shows index directory size and location
49 $admin_table->tablealign
= "center";
50 $admin_table->align
= array ("right", "left");
51 $admin_table->wrap
= array ("nowrap", "nowrap");
52 $admin_table->cellpadding
= 5;
53 $admin_table->cellspacing
= 0;
54 $admin_table->width
= '500';
56 $admin_table->data
[] = array('<strong>Data directory</strong>', '<em><strong>'.$indexinfo->path
.'</strong></em>');
57 $admin_table->data
[] = array('Files in index directory', $indexinfo->filecount
);
58 $admin_table->data
[] = array('Total size', $indexinfo->size
);
60 if ($indexinfo->time
> 0) {
61 $admin_table->data
[] = array('Created on', date('r', $indexinfo->time
));
63 $admin_table->data
[] = array('Created on', '-');
66 if (!$indexinfo->valid($errors)) {
67 $admin_table->data
[] = array('<strong>Errors</strong>', ' ');
69 foreach ($errors as $key=>$value) {
70 $admin_table->data
[] = array($key.' ... ', $value);
73 $admin_table->data
[] = array('<strong>Solutions</strong>', ' ');
75 if (isset($errors['dir'])) {
76 $admin_table->data
[] = array('Check dir', 'Ensure the data directory exists and is writable.');
79 if (isset($errors['db'])) {
80 $admin_table->data
[] = array('Check DB', 'Check your database for any problems.');
83 $admin_table->data
[] = array('Run indexer test', '<a href=\'tests/index.php\'>tests/index.php</a>');
84 $admin_table->data
[] = array('Run indexer', '<a href=\'indexersplash.php\'>indexersplash.php</a>');
88 //this is the standard summary table for normal users, shows document counts
89 $table->tablealign
= "center";
90 $table->align
= array ("right", "left");
91 $table->wrap
= array ("nowrap", "nowrap");
92 $table->cellpadding
= 5;
93 $table->cellspacing
= 0;
94 $table->width
= '500';
96 $table->data
[] = array('<strong>Database</strong>', '<em><strong>search_documents<strong></em>');
98 //add extra fields if we're admin
100 //don't want to confuse users if the two totals don't match (hint: they should)
101 $table->data
[] = array('Documents in index', $indexinfo->indexcount
);
103 //*cough* they should match if deletions were actually removed from the index,
104 //as it turns out, they're only marked as deleted and not returned in search results
105 $table->data
[] = array('Deletions in index', (int)$indexinfo->indexcount
- (int)$indexinfo->dbcount
);
108 $table->data
[] = array('Documents in database', $indexinfo->dbcount
);
110 foreach($indexinfo->types
as $key => $value) {
111 $table->data
[] = array("'$key' documents", $value);
115 print_table($admin_table);
121 print_simple_box_end();
122 print_simple_box_end();