public static function selectByUser($id) { $connection = Flight::dbMain(); try { $sql = "SELECT * FROM user_online WHERE user_id = :user_id;"; $query = $connection->prepare($sql); $query->bindParam(':user_id', $id, PDO::PARAM_INT); $query->execute(); if ($query->rowCount() < 1) { Flight::notFound("user_id not found"); } $row = $query->fetch(PDO::FETCH_ASSOC); $userOnline = new UserOnline(); $userOnline->Id = (int) $row['id']; $userOnline->User = User::select($row['user_id']); $userOnline->Dt = $row['online_dt']; return $result; } catch (PDOException $pdoException) { throw $pdoException; } catch (Exception $exception) { throw $exception; } finally { $connection = null; } }
/** * Secure require_once alias for the routing component of the system */ function bgp_safe_require($path) { if (file_exists($path)) { // Protect class files and xml files from being called directly if (strpos($path, '.class') === FALSE && strpos($path, '.xml') === FALSE && strpos($path, '.ini') === FALSE) { require_once $path; return 0; } } Flight::notFound(); }
$playlists = getPlaylists(); Flight::render('playlists', array('playlists' => $playlists), 'body_content'); Flight::render('layout', array('Titre' => 'Playlists')); }); Flight::route('GET /playlist/create', function ($id) { Flight::render('createPlaylist'); }); // Lecture APP Flight::route('GET /playlist/@id', function ($id) { $playlist = json_decode(getPlayList($id)); $tracks = getProposedTracks($id); //------ $include_in_header = '<script type="text/javascript" src="http://cdn-files.deezer.com/js/min/dz.js"></script>'; $footer_content = '<script type="text/javascript" src="' . _URL_APP_THEME_ . 'js/WebPlayerController.js"></script>'; if (isset($album->error)) { Flight::notFound(); } //------ Flight::render('playlist', array('playlist' => $playlist, 'tracks' => $tracks), 'body_content'); Flight::render('layout', array('Titre' => $playlist[0]->titre, 'include_in_header' => $include_in_header, 'footer_content' => $footer_content)); }); /** **** ****** ****** ****** routing proposedTracks ****** ****** **** **/ Flight::route('GET /proposedtrack/create', function () {
$id = Flight::get('hash')->decode($hash); if (!$id) { Flight::json(['status' => 0, 'msg' => '短址无法解析']); } else { $store = Flight::get('db')->select('urls', ['url'], ['id' => $id]); if (!$store) { Flight::json(['status' => 0, 'msg' => '地址不存在']); } else { Flight::json(['status' => 1, 'url' => $store[0]['url']]); } } } } }); Flight::route('/@hash', function ($hash) { $id = Flight::get('hash')->decode($hash); if (!$id) { Flight::notFound('短址无法解析'); } else { $store = Flight::get('db')->select('urls', ['url'], ['id' => $id]); if (!$store) { Flight::notFound('地址不存在'); } else { Flight::get('db')->update('urls', ['count[+]' => 1], ['id' => $id]); Flight::redirect($store[0]['url'], 302); } } }); Flight::map('notFound', function ($message) { Flight::response()->status(404)->header('content-type', 'text/html; charset=utf-8')->write('<h1>404 页面未找到</h1>' . "<h3>{$message}</h3>" . '<p><a href="' . Flight::get('flight.base_url') . '">回到首页</a></p>' . str_repeat(' ', 512))->send(); });
public function notFound() { return Flight::notFound(); }
$mainData['bbox'] = json_encode([[min($arrBbox[1], $arrBbox[3]), min($arrBbox[0], $arrBbox[2])], [max($arrBbox[1], $arrBbox[3]), max($arrBbox[0], $arrBbox[2])]]); $proName = $mainData['prov_name']; $regName = $mainData['reg_name']; $munName = $mainData['name']; $query = "SELECT stat.* FROM it_comuni com JOIN it_stats stat ON com.osm_id = stat.osm_id WHERE com.cod_istat=" . $db->quote($mainData['cod_istat']) . " AND data > (CURRENT_DATE - 30) ORDER BY data ASC"; $res = $db->query($query); $stats = $res->fetchAll(); Flight::render('extract.php', array('baseUrl' => Flight::request()->base, 'pTitle' => $municipality . ', ' . $province . ', ' . $region, 'region' => $regName, 'region_safe' => $region, 'province' => $proName, 'province_safe' => $province, 'municipality' => $munName, 'municipality_safe' => $municipality, 'mainData' => $mainData, 'stats' => $stats)); }); Flight::route('/@region/@province/@municipality/stats', function ($region, $province, $municipality) { checkLang(); $db = Flight::db(); $query = "SELECT com.osm_id,com.cod_istat,com.name, com.safe_name, pro.name AS prov_name, reg.name AS reg_name FROM it_regioni reg JOIN it_province pro ON reg.cod_istat = pro.cod_istat_reg JOIN it_comuni com ON pro.cod_istat=com.cod_istat_pro WHERE com.safe_name=" . $db->quote($municipality) . " AND pro.safe_name=" . $db->quote($province); $res = $db->query($query); $mainData = $res->fetchAll(); if (count($mainData) == 0) { return Flight::notFound(); } $mainData = $mainData[0]; $proName = $mainData['prov_name']; $regName = $mainData['reg_name']; $munName = $mainData['name']; $query = "SELECT stat.* FROM it_comuni com JOIN it_stats stat ON com.osm_id = stat.osm_id WHERE com.cod_istat=" . $db->quote($mainData['cod_istat']) . " ORDER BY data ASC"; $res = $db->query($query); $stats = $res->fetchAll(); Flight::render('extractStats.php', array('baseUrl' => Flight::request()->base, 'pTitle' => $municipality . ', ' . $province . ', ' . $region, 'region' => $regName, 'region_safe' => $region, 'province' => $proName, 'province_safe' => $province, 'municipality' => $munName, 'municipality_safe' => $municipality, 'mainData' => $mainData, 'stats' => $stats)); }); Flight::map('notFound', function () { echo "404"; }); Flight::start();