Location: PHPKode > projects > Serveur Multicartes IPX800 > multicardipx800/jsonp.php
<?php
header('Content-Type: text; charset: UTF-8');
header("Cache-Control: no-cache");
require('LoadConfig.php');
session_name((string)$GLOBALS["config"]->general->namesession);
session_start();

include('LoginVerif.php');

require_once("./fctphp/function.php");
if ( acces_mysql() )
{
	require_once("./connect_mysql.php");

	require_once("class/".$_REQUEST["class"].".php");

	$current = new $_REQUEST["class"]($_REQUEST["numero"]);

	// Valeur initiale
	$close = "";
	if ( isset($current->carteid) )
		$close .= "carte_id = ".$current->carteid." and ";
	$close .= "numero = ";
	if ( isset($current->no) )
		$close .= $current->no;
	else
		$close .= $current->numero;

	$select = "SELECT time, `etat` FROM `".$_REQUEST["class"]."` where ".$close;
	$select .= " order by `time` asc";
	$select .= " LIMIT 1000";

	$values = array();
	
	$result = mysql_query($select) or die ('Erreur : '.mysql_error() );
	while($row = mysql_fetch_assoc($result))
	{
		If ( $_REQUEST["class"] == "btn" )
		{
			if ( $row["etat"] == "u" )
				$row["etat"] = 1;
			else
				$row["etat"] = 0;
		}
		array_push($values, "[".$row["time"]."000,".$row["etat"]."]");
	}	
	
	echo $_REQUEST["callback"]."(\n[\n";
	echo join(",\n", $values);
	echo "\n]\n);";
	flush();
}
else
{
	echo "Acces aux graphiques impossible. Bibliotheques non installees.";
}
?>
Return current item: Serveur Multicartes IPX800