File: reindex

package info (click to toggle)
bamboo 1.2-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 580 kB
  • ctags: 1,338
  • sloc: php: 4,061; makefile: 44; sh: 36
file content (55 lines) | stat: -rwxr-xr-x 1,417 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/php4 -q
<?php

/*************************************************************
 
This script will rebuild a site's index from scratch. This is
useful if the index becomes off because the files were edited
directly without going through the bamboo interface or because
a bamboo site is contained within another.

USAGE:
   reindex /var/www/mysite

*************************************************************/

$base = dirname(dirname(__FILE__));

require_once("$base/debug.php");
require_once("$base/Lang.php");
require_once("$base/Page.php");
require_once("$base/PageStore.php");
require_once("$base/Properties.php");
require_once("$base/Search.php");

ini_set('error_log', NULL);

$argv = &$GLOBALS['argv'];
$argc = &$GLOBALS['argc'];

if ($argc != 2)
	die("Usage: reindex [site dir]\n");

$src = $argv[1];
$_SERVER['DOCUMENT_ROOT']=$src;

if (!is_dir($src))
	die("site directory $src does not exist\n");

if (!is_file("$src/b.site")) 
	die("can't find b.site file in $src\n");
	
###############################################

$prop     = new Properties("$src/b.site");
$root 	  = $prop->getGlobal('siteroot');
$docroot  = $prop->getGlobal('sitedocroot');
$ps       = PageStoreFactory::create($prop->getGlobal('pagebackend'),$prop);
$page     = $ps->getPage('/');
$search   = new Search(IndexFactory::create($prop->getGlobal('indexbackend')));

$search->clear();
$search->indexTree($page);

return;
?>