ajout $url bloque salle en paramètre

This commit is contained in:
jbousquie 2016-11-21 13:58:56 +01:00
parent bd8cc23c32
commit 98fdb510af

View File

@ -1,26 +1,38 @@
<?php <?php
require_once 'HTTP/Request2.php';
include_once('winlog_admin_conf.php');
Function bascule_salle($url) { Function bascule_salle($url) {
$salles_bloquees = array(); $salles_bloquees = array();
$r = new HttpRequest($url, HttpRequest::METH_GET); $r = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);
try { try {
$r->send(); $response = $r->send();
if ($r->getResponseCode() == 200) { if (200 == $response->getStatus()) {
$r->getResponseBody(); $body = $response->getBody();
$reponse = json_decode($r->getResponseBody()); $reponse = json_decode($body);
} }
} }
catch (HttpException $ex) { catch (HTTP_Request2_Exception $ex) {
echo $ex; echo $$ex->getMessage();
} }
return $r->getResponseCode(); return $reponse;
} }
$action = $_GET["a"]; $action = $_GET["a"];
$salle = $_GET["s"]; $salle = $_GET["s"];
$url = ""; $url = "";
if ($action === "b") { $url = "http://cache.iut-rodez.fr/salles/bloque_salle.php?s=$salle"; } $param = "?s=$salle";
if ($action === "d") { $url = "http://cache.iut-rodez.fr/salles/debloque_salle.php?s=$salle"; } if ($action === "b") {
$url = $url_bloque . $param;
}
if ($action === "d") {
$url = $url_debloque . $param;
}
if ($action != "" ) {
bascule_salle($url);
}
if ($action != "" ) { bascule_salle($url); }
$precedent = $_SERVER["HTTP_REFERER"]; $precedent = $_SERVER["HTTP_REFERER"];
header("Location: $precedent"); header("Location: $precedent");
?> ?>