Location: PHPKode > projects > WEB-PA > spider/include/funzioni.php
<?php

function getSpiderStatus() {
	return get_setting('status','UNKNOWN (status record is missing)');
}

function getSpiderCommand() {
	return get_setting('command');
}

function get_setting($key,$default = null) {
	global $paos_db;

	$sql = "SELECT * FROM utility WHERE akey='$key' LIMIT 0,30";
	$res = mysql_query($sql,$paos_db);
	$errno = mysql_errno();
	if($errno){
		echo "errore $errno query $sql";
	}

	if ($row =  mysql_fetch_assoc($res)) {
		return $row['value'];
	} else {
		return $default;
	}
}


// Scrive sul disco lo stato attuale
function status($now) {
	return write_setting('status',$now);
}

// Imposta un comando per successiva esecuzione
function command($what) {
	return write_setting('command',$what);
}

function write_setting($key,$value) {
	global $paos_db;

	$sql = "DELETE FROM utility WHERE akey='$key'";
	$res = mysql_query($sql,$paos_db);
	$errno = mysql_errno();
	if($errno){
		echo "errore $errno query $sql";
	}

	if ($value != '' && $value != null) {
		$sql = "INSERT INTO utility (akey,value) VALUES ('$key','$value')";
		$res = mysql_query($sql,$paos_db);
		$errno = mysql_errno();
		if($errno){
			echo "errore $errno query $sql";
		}
	}
}


?>
Return current item: WEB-PA