Commit b448372f authored by thejoelinux's avatar thejoelinux

Merge branch '80-adaptation-php-7' into 'master'

correction session + 2 controllers

Closes #80

See merge request !8
parents 86dd29db 7368ef80
<?php
// This class store/retrieve the sessions in/from the database.
// This class store/retrieve the sessions in/from the database.
// You will need this if you have more than one webserver
// to enable the persistence of sessions accross different front servers.
class session_saas {
class session_saas implements SessionHandlerInterface {
private $life_time = 0;
private $debug = false;
......@@ -12,14 +12,7 @@ class session_saas {
if($this->debug) {
trigger_error('session_saas::__construct called', E_USER_NOTICE);
}
session_set_save_handler(
array(&$this, 'open'),
array(&$this, 'close'),
array(&$this, 'read'),
array(&$this, 'write'),
array(&$this, 'destroy'),
array(&$this, 'gc')
);
session_set_save_handler($this);
// session_name("whatever");
$this->life_time = ini_get('session.gc_maxlifetime');
// -- Define a lifetime on session cookie
......@@ -39,7 +32,7 @@ class session_saas {
return true;
}
public function open() {
public function open($save_path, $session_name) {
if($this->debug) {
trigger_error('session_saas::open called', E_USER_NOTICE);
}
......@@ -91,9 +84,9 @@ class session_saas {
'content' => $postdata
)
);
$context = stream_context_create($opts);
if(file_get_contents($GLOBALS["saas_sessions_url"], false, $context)) {
if(!file_get_contents($GLOBALS["saas_sessions_url"], false, $context)) {
return false;
}
return true;
......@@ -117,7 +110,7 @@ class session_saas {
'content' => $postdata
)
);
$context = stream_context_create($opts);
if(!file_get_contents($GLOBALS["saas_sessions_url"], false, $context)) {
return false;
......
......@@ -58,7 +58,7 @@ class GamesController extends AppController {
return "games/edit";
}
function _edit() {
function _edit($success = 'edit') {
$game = Game::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
if($this->format == "json") {
echo json_encode($game);
......@@ -72,13 +72,13 @@ class GamesController extends AppController {
try {
Game::fetch_all($games);
echo json_encode($games);
exit(); // no further rendering needed
exit(); // no further rendering needed
} catch(data_exception $e) {
return "data_exception";
}
}
function _delete() {
try {
$game = Game::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
......@@ -148,10 +148,10 @@ class GamesController extends AppController {
$game->create_reservation();
$this->set_message("La réservation a été faite");
} else {
$this->set_message("Impossible de réserver : pas d'adresse email pour cet utilisateur", "danger");
$this->set_message("Impossible de réserver : pas d'adresse email pour cet utilisateur", "danger");
}
} else {
$this->set_message("Impossible de réserver : pas d'inscription valide pour cet utilisateur", "danger");
$this->set_message("Impossible de réserver : pas d'inscription valide pour cet utilisateur", "danger");
}
$this->set("game", $game);
return "games/edit";
......@@ -174,10 +174,10 @@ class GamesController extends AppController {
return "games/not_found";
} catch (data_exception $e) {
return "data_exception";
}
}
}
function _list() {
function _list($method = 'fetch_all') {
if($this->format == "json") {
parent::_list();
}
......
......@@ -37,7 +37,7 @@ class MembersController extends AppController {
// TODO : posted datas should be validated
// who is responsible for that ? i think
// this is the model
// TODO once a member is created : an online access
// could be granted when there is a valid subs.
......@@ -58,19 +58,19 @@ class MembersController extends AppController {
header("Pragma: no-cache");
header("Expires: 0");
while(list($key, $val) = each($members)) {
echo
echo
'"'.$val->subscription_end_date.'";"'.$val->subscription_status.'";"'.
$val->firstname.'";"'.$val->lastname.'";"'.
$val->address.'";"'.$val->po_town.'";"'.$val->email.'"';
echo "\n";
}
exit(); // no further rendering needed
exit(); // no further rendering needed
} catch(data_exception $e) {
return "data_exception";
}
}
function _edit() {
function _edit($success = 'edit') {
try {
$member = Member::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
if($member->id != 0) {
......@@ -119,7 +119,7 @@ class MembersController extends AppController {
try {
Member::fetch_all($members);
echo json_encode($members);
exit(); // no further rendering needed
exit(); // no further rendering needed
} catch(data_exception $e) {
return "data_exception";
}
......@@ -286,7 +286,7 @@ class MembersController extends AppController {
}
}
function _list() {
function _list($method = 'fetch_all') {
if($this->format == "json") {
parent::_list();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment