if ($arr = $res->fetch_array(MYSQLI_ASSOC)) { if ($arr["user_id"] == $user_id) { strip_all($arr); $response["data"] = $arr["data"]; $response["result"] = "ok"; } } else { $response["result"] = "error"; } break; case "get_game_savings": $user_id = get_check_user_id(); $res = $db->query("select t2.id, t1.id as saving_id, t1.name, t1.score, t1.data \n\t\t\tfrom scores t1\n\t\t\tinner join games t2\n\t\t\t\ton t1.game_id = t2.id and t1.loose = 0\n\t\t\tinner join users t3\n\t\t\t\ton t2.user_id = t3.id and t3.id = {$user_id}\n\t\t\torder by t1.id desc"); $response["data"] = array(); while ($arr = $res->fetch_array(MYSQLI_ASSOC)) { strip_all($arr); $response["data"][] = $arr; } $response["result"] = "ok"; break; /* deprecated case "get_games_list": $user_id = get_check_user_id(); $res = $db->query( "select t1.id from games t1 inner join scores t2 on t1.id = t2.game_id and t2.loose = 0 where t1.user_id = $user_id group by t1.id having count(t2.id) > 0"
include_once "src/Router.php"; $router = new Router(); //URL rewriting $task = explode('/', $_SERVER["REQUEST_URI"]); //get the right route from the first parameter $route = $router->getRoute($task[1]); //get correct MVC bloc $model = new $route->model(); $controller = new $route->controller($model); $view = new $route->view($model); require_once "src/util/regex.php"; //var_dump($task); if (count($task) > 2) { $options = array_slice($task, 2); foreach ($options as $value) { if (empty($value) === false) { $controller->addOption(strip_all("/[^\\w]/", $value)); } } } //let the controller update the model and the view display the model according to itself //interruption by exception, for instance, inscription -> user already exists try { $controller->update(); $view->display(); } catch (exception $e) { echo $e->getMessage(); } //close db connexion $connexion->close(); $connexion = null;
function secure_strip($field) { return strip_all('[\\s\'"]', $field); }