Location: PHPKode > projects > Wexplorer > weXplorer/SQLiteLogger.php
<?php

/*
 * Created on 8 nov. 2005
 *
 */
require_once ('config.inc.php');
global $db;
if (!file_exists(LOGFILE)) {
	if ($db = sqlite_open(LOGFILE, 0666, $sqliteerror)) {
		sqlite_query($db, '
		CREATE TABLE log (
				path varchar(150),
				name varchar(50),
				ext varchar(20),
				user varchar(20),
				ip varchar(20),
				date datetime
		)
		');
		sqlite_query($db, "INSERT INTO log VALUES ('dum/dim.dam','dim.dam','dam','dummy','127.0.0.1',datetime('now'));");
		sqlite_query($db, "CREATE INDEX log_path ON log ( path );");
		sqlite_query($db, "CREATE INDEX log_name ON log ( name );");
		sqlite_query($db, "CREATE INDEX log_ext  ON log ( ext  );");
		sqlite_query($db, "CREATE INDEX log_user ON log ( user );");
		sqlite_query($db, "CREATE INDEX log_ip   ON log ( ip   );");
		 
		$result = sqlite_query($db, 'select * from log');
	} else {
		die($sqliteerror);
	}
} else {
	$db = sqlite_open(LOGFILE, 0666, $sqliteerror);
	if(!$db||$db=="")
		die($sqliteerror);
}

function _log($date, $user, $path,$remoteIP) {
	global $db;
	$pathinfo = pathinfo($path);
	$name = $pathinfo['basename'];
	$ext = $pathinfo['extension'];
	sqlite_exec($db, "INSERT INTO log (path,name,ext,user,ip,date) VALUES ('$path','$name','$ext','$user','$remoteIP','$date')");
}

?>
Return current item: Wexplorer