Location: PHPKode > scripts > Guaranix Full Text > guaranix-full-text/phpIndexer.php
<?php

/***************************************************************************
 *   Copyright (C) 2006 by Cesar Rodas   *
 *   hide@address.com   *
 *                                                                         *
 *   Permission is hereby granted, free of charge, to any person obtaining *
 *   a copy of this software and associated documentation files (the       *
 *   "Software"), to deal in the Software without restriction, including   *
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 *   permit persons to whom the Software is furnished to do so, subject to *
 *   the following conditions:                                             *
 *                                                                         *
 *   The above copyright notice and this permission notice shall be        *
 *   included in all copies or substantial portions of the Software.       *
 *                                                                         *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 ***************************************************************************/


include "gnix.php";
set_time_limit(0);
error_reporting(E_ALL);




/*
$gnix = new Gnix(array("db" => "test.db"),SQLITE);
$gnix->install();
for($i=0; $i < 20; $i++) {
$texto['file'] = "cesar rodas es el mejor de todos";
$texto['body'] = strip_tags(file_get_contents( "index/Instalar.txt"));
$gnix->Index($texto);
}*/


$connstring = array("db" => "phpgnix", "host" => "localhost", "user" => "root", "pass" => "");
$gnix = new Gnix($connstring,MYSQL);
$gnix->install(); /* Install Just for the first time.. */


$t = microtime_float();
$folder = opendir("index"); /* This will index all what is in the folder INDEX(it must exist) */
while( $entry = readdir($folder))
{
	if ($entry == "." || $entry == "..")
		continue;
	print $entry."<br>";
	$texto['file'] = $entry;
	$texto['body'] = strip_tags(file_get_contents( "index/".$entry));
	$gnix->Index($texto);
	unset($texto);

}
$t = microtime_float()- $t;
print "Done in ".$t." seconds";

?> 
Return current item: Guaranix Full Text