Location: PHPKode > scripts > Tera WURFL > tera-wurfl/admin/tera_wurfl_updatedb.php
<?php
$source = (isset($_GET['source']))? $_GET['source']: "local";
$type = (isset($_GET['type']))? $_GET['type']: "main";
require_once('../tera_wurfl_config.php');
require_once(WURFL_PARSER_FILE);

$dbcon = mysql_connect(DB_HOST,DB_USER,DB_PASS) or die("Could not connect to MySQL Server (".DB_HOST."): ".mysql_error());
mysql_select_db(DB_SCHEMA,$dbcon) or die("Connected to MySQL Server but could not select database (".DB_SCHEMA."): ".mysql_error($dbcon));

$start = utime();
$results = load_wurfl($type,$source);
$end = utime();
echo "<strong>Database Update</strong><hr />";
echo "Total Update Time: ".($end-$start)."<br />";
echo "Total Devices in WURFL: ".$results['total']."<br />";
echo "Total Devices inserted in DB: ".$results['inserted']."<br />";
echo "Total Queries: ".$results['queries']."<br />";
echo "Largest Query: ".(ceil($results['maxquerysize']/1024))."KB<br />";
echo "Total Errors: ".count($results['errors'])."<br /><br />";
if(count($results['errors']) == 0){
	if(WURFL_PATCH_ENABLE === true){
		echo "<strong>Applying Patch</strong><hr />";
		$start = utime();
		$results = apply_patch();
		$end = utime();
		echo "Total Update Time: ".($end-$start)."<br />";
		echo "Total Devices in Patch File: ".$results['total']."<br />";
		echo "New Devices Added: ".$results['new']."<br />";
		echo "Merged Devices: ".$results['merged']."<br />";
		echo "Total Queries: ".$results['queries']."<br />";
		echo "Total Errors: ".count($results['errors'])."<br /><br />";
	}else{
		echo "<strong>Patch Disabled in Configuration</strong><br />";
	}
	echo "<br /><br />Update Complete!<br />";
}else{
	echo "Did not attept to apply the patch since there were errors while updating.";
}
echo "<a href=\"index.php\">Return to administration tool.</a>";

function utime($time = false){
	if(!time)$time = time();
	list($usec, $sec) = explode(" ", microtime());
	$out = ((float)$usec + (float)$sec);
	return($out); 
}
function javascriptRedir($page, $seconds, $custommsg=false){
	global $redirectDelay;
	if(isset($redirectDelay))$seconds += $redirectDelay;
	$file = '';
	$line = '';
	$sent = headers_sent($file,$line);
	if($seconds == 0 && !$sent){
		//headers have not been sent and instant redir was requested - do it!
		session_write_close();
		header("Location: $page");
//		die("header");
		exit;
	}
	$time = $seconds * 1000;
//	die("JavaScript, ($sent)output started on line $line in $file");
	if($custommsg){
		echo $msg;
	}else{
		echo "<br><br>You will be redirected to <a href='$page'>$page</a> in $seconds seconds...";
	}
	echo '<script language="javascript">'."\n".'setTimeout('."'".'window.location.href = "'.$page.'"'."'".', '.$time.');'.'</script>';
	echo '<noscript><meta http-equiv="refresh" content="'.$time.';url='.$page.'" /></noscript>';
	exit;
}
?>
Return current item: Tera WURFL