Location: PHPKode > projects > ezStats for XBOX Live > ezStats2_xbl/admin/signatures.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/signatures.php';
	
	$secure = new Security();
	$settings = new Settings();
	$tpl = new Templates();
	$tpl->load_phrases("admin", true);
	date_default_timezone_set($settings->get("timezone"));
	
	// Standard-Variablen belegen
	$message = Array();
	$time = time();
	
	
	// Signaturen sind deaktiviert
	if ($settings->get("signatures") == "0") {
		if (isset ($_POST['request']) AND $_POST['request'] == "admin") {
			// Abruf aus dem Adminpanel heraus
			die (json_encode(array(
				"message" => $tpl->phrase('signatures_deactivated'),
				"time" => date("d.m.Y - H:i", $time)
			)));
		} 
		else {
			// Direkter Abruf
			eval ("\$html = \"".$tpl->template("update")."\";");
			$html = phpQuery::newDocumentHTML($html);
			
			pq('ul')->append('<li>'.$tpl->phrase('signatures_deactivated').'</li>');
			die ($html);
		}
	}
	
	
	// Spieler abrufen, die am längsten nicht mehr aktualisiert wurden
	$sql->query('
		SELECT id, name
		FROM '.$sql->prefix.'player
		WHERE id != 1
		ORDER BY date_sigupdate ASC
		LIMIT '.$settings->get("sig_updatecount").'
	');
	
	
	// Signaturen erstellen
	while ($player = $sql->fetchRow()) {
		$sig = new Signatures($player['id']);
		
		if ($sig->create_signature()) {
			$message[] = $player['name'].': '.$tpl->phrase("signatur_created");
		} else {
			$message[] = $player['name'].': '.$tpl->phrase("signatur_not_created");
		}
		
		// Datum der Aktualisierung in die Spielereigenschaften schreiben
		$sq1 = new MySQL();
		$sq1->query('UPDATE '.$sql->prefix.'player SET date_sigupdate = "'.$time.'" WHERE id = "'.$player['id'].'"');
		$sq1->disconnect();
	}
	
	
	// Datum der Aktualisierung in die Settings schreiben
	$sql->query('UPDATE '.$sql->prefix.'settings SET value="'.$time.'" WHERE name = "sig_lastupdate"');
	
	
	// 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("<br/>", $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 XBOX Live