Location: PHPKode > scripts > ezStats for PlayStation Network > ezStats2_psn/admin/update.php
<?php
	require '../tmp/sql.php';
	require '../classes/mysql.php';
	
	$sql = new MySQL(); if ($sql->debug) error_reporting (E_ALL|E_STRICT); else error_reporting (0);
	
	require '../plugins/phpQuery.php';
	require '../classes/settings.php';
	require '../classes/security.php';
	require '../classes/functions.php';
	require '../classes/template.php';
	require '../classes/player.php';
	require '../classes/stats.php';
	require '../classes/psn.php';
	
	$secure = new Security();
	$settings = new Settings();
	$player = new Player();
	$tpl = new Templates();
	$tpl->load_phrases("admin", true);
	date_default_timezone_set($settings->get("timezone"));
	
	
	// Standard-Variablen belegen
	$message = Array();
	$time = time();
	
	
	// Spieler abrufen
	$sql->query('
		SELECT id, name
		FROM '.$sql->prefix.'player
		WHERE id != 1
		ORDER BY last_update ASC
		LIMIT '.$settings->get('updatecount').'
	');
	
	
	// Spieler aktualisieren
	while ($row = $sql->fetchRow()) {
		$sq1 = new MySQL();
		$result = $player->update($row['id'], $row['name']);
		
		if ($result) {
			$message[] = $row['name'].' (OK)';
		} else {
			$message[] = $row['name'].' (NOK)';
		}
		$sq1->query('UPDATE `'.$sq1->prefix.'player` SET `last_update` = "'.$time.'" WHERE `id` = "'.$row['id'].'"');
	}
	
	
	// Datum der Aktualisierung in die Settings schreiben
	$sql->query('UPDATE '.$sql->prefix.'settings SET value="'.$time.'" WHERE name = "lastcheckall"');
	
	
	// Ergebnis ausgeben
	if (isset ($_POST['request']) AND $_POST['request'] == "admin") {
		// Abruf aus dem Adminpanel heraus
		die (json_encode(array(
			"message" => $tpl->phrase('update_message').implode(", ", $message),
			"time" => date("d.m.Y - H:i", $time)
		)));
	} 
	else {
		// Direkter Abruf
		eval ("\$html = \"".$tpl->template("update")."\";");
		$html = phpQuery::newDocumentHTML($html);
		
		foreach ($message as $string) pq('ul')->append('<li>'.$string.'</li>');
		echo $html;
	}
?>
Return current item: ezStats for PlayStation Network