function index() { global $argv, $title; printf($title); $doNZBs = false; if (count($argv) > 3) { $mode = strtolower($argv[2]); if ($mode == "full" || $mode == "delta") { $full = $mode == "full" ? true : false; $sphinx = new Sphinx(); if ($argv[3] == "all") { $indexes = $sphinx->getAllEnabledIndexes(); } else { $indexes = array_slice($argv, 3); } printf("Going to do %s index of %d %s\n\n", $mode, count($indexes), count($indexes) == 1 ? "index" : "indexes"); foreach ($indexes as $index) { if ($index == "nzbs") { $doNZBs = true; continue; } printf("Starting "); $sphinx->updateIndex($index, $full); printf("Update of '%s' complete\n\n", $index); } if ($doNZBs) { error_reporting(0); printf("Starting indexing index 'nzbs'...\n"); if ($mode == "full") { // re-index from the beginning printf("note: if you interrupt this, you can resume it later " . "by doing a 'delta' update of the 'nzbs' index\n"); $sphinx->indexNZBs(0); } else { // only do the delta $sphinx->indexNZBs(); } printf("Update of '%s' complete\n\n", 'nzbs'); } return true; } } }