General updates, see README.txt.

This commit is contained in:
mchampan 2006-07-25 17:23:10 +00:00
parent d9e1bf2478
commit b585dc5fcb
12 changed files with 149 additions and 279 deletions

View file

@ -1,39 +1,18 @@
<?php
/* Prints some basic statistics about the current index.
* Allows the administrator to create an index if none exists.
*
* Does some diagnostics if you are logged in as an administrator.
* */
require_once('../config.php');
require_once("$CFG->dirroot/search/lib.php");
//check for php5, but don't die yet
if ($check = search_check_php5()) {
//filesystem stats
$index_path = "$CFG->dataroot/search";
$index_size = display_size(get_directory_size($index_path));
$index_dir = get_directory_list($index_path, '', false, false);
$index_filecount = count($index_dir);
if ($check = search_check_php5()) {
require_once("$CFG->dirroot/search/indexlib.php");
//indexed documents stats (via db)
$db_exists = false;
$admin_tables = $db->MetaTables();
if (in_array($CFG->prefix.'search_documents', $admin_tables)) {
$db_exists = true;
$types = search_get_document_types();
sort($types);
//total documents
$type_counts['Total'] = count_records('search_documents');
foreach($types as $type) {
$c = count_records('search_documents', 'doctype', $type);
$type_counts[$type] = (int)$c;
} //foreach
} else {
$type_counts['Total'] = 0;
} //else
} //if
$indexinfo = new IndexInfo();
} //if
if (!$site = get_site()) {
redirect("index.php");
@ -66,12 +45,35 @@
$admin_table->cellspacing = 0;
$admin_table->width = '500';
$admin_table->data[] = array('<strong>Data directory</strong>', '<em><strong>'.$index_path.'</strong></em>');
$admin_table->data[] = array('Files in index directory', $index_filecount);
$admin_table->data[] = array('Total size', $index_size);
$admin_table->data[] = array('<strong>Data directory</strong>', '<em><strong>'.$indexinfo->path.'</strong></em>');
$admin_table->data[] = array('Files in index directory', $indexinfo->filecount);
$admin_table->data[] = array('Total size', $indexinfo->size);
if ($index_filecount == 0 or !$db_exists) {
$admin_table->data[] = array('Click to create index', "<a href='indexersplash.php'>Indexer</a>");
if ($indexinfo->time > 0) {
$admin_table->data[] = array('Created on', date('r', $indexinfo->time));
} else {
$admin_table->data[] = array('Created on', '-');
} //else
if (!$indexinfo->valid($errors)) {
$admin_table->data[] = array('<strong>Errors</strong>', '&nbsp;');
foreach ($errors as $key=>$value) {
$admin_table->data[] = array($key.' ... ', $value);
} //foreach
$admin_table->data[] = array('<strong>Solutions</strong>', '&nbsp;');
if (isset($errors['dir'])) {
$admin_table->data[] = array('Check dir', 'Ensure the data directory exists and is writable.');
} //if
if (isset($errors['db'])) {
$admin_table->data[] = array('Check DB', 'Check your database for any problems.');
} //if
$admin_table->data[] = array('Run indexer test', '<a href=\'tests/index.php\'>tests/index.php</a>');
$admin_table->data[] = array('Run indexer', '<a href=\'indexersplash.php\'>indexersplash.php</a>');
} //if
} //if
@ -83,9 +85,18 @@
$table->cellspacing = 0;
$table->width = '500';
$table->data[] = array('<strong>Database</strong>', '<em><strong>search_documents<strong></em>');
foreach($type_counts as $key => $value) {
$table->data[] = array($key, $value);
$table->data[] = array('<strong>Database</strong>', '<em><strong>search_documents<strong></em>');
//add an extra field if we're admin
if (isadmin()) {
//don't want to confuse users if the two totals don't match (hint: they should)
$table->data[] = array('Documents in index', $indexinfo->indexcount);
} //if
$table->data[] = array('Documents in database', $indexinfo->dbcount);
foreach($indexinfo->types as $key => $value) {
$table->data[] = array("'$key' documents", $value);
} //foreach
if (isadmin()) {