/** * Save chosen password */ public function save_pass() { $pass = F::request()->data->password; $pass2 = F::request()->data->password2; if ($pass === $pass2) { if (!empty($pass)) { if (Action::savePassword($pass)) { $_SESSION['flashbag'] = ' <div class="alert alert-success alert-dismissible"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> Your password has successfully been set. </div>'; $_SESSION['admin'] = 1; F::redirect('/settings'); exit; } else { $_SESSION['flashbag'] = '<div class="alert alert-danger">An error occured. Please verify that the app/ and src/ folder are writable.</div>'; } } else { $_SESSION['flashbag'] = '<div class="alert alert-warning">No password ? Are you serious ? Put at least some letters.</div>'; } } else { $_SESSION['flashbag'] = '<div class="alert alert-danger">You must enter the same password twice.</div>'; } $this->index(); }
/** * Checks whether or not user is logged in. Redirects to login page if not. */ private static function checkLogin() { // session stuff if (!isset($_SESSION['logged'])) { Flight::redirect('./login'); } }
public function init() { $data = $_REQUEST; if (isset($data[Profile::GET_CHANGE_PASSWORD_BUTTON])) { if (strlen($data[Profile::GET_CHANGE_PASSWORD]) > 0) { if (!User::passwordIsValid($data[Profile::GET_CHANGE_PASSWORD])) { Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=0'); } else { $user = Auth::getInstance()->getUser(); $user->password = User::getHashPassword(trim(strip_tags($data[Profile::GET_CHANGE_PASSWORD])), $user->login); $user->save(); Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=1'); return true; } } if (strlen($data[Profile::GET_CHANGE_PHONE]) > 0) { if (!User::validatePhone(trim($data[Profile::GET_CHANGE_PHONE]))) { Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=2'); } else { $user = Auth::getInstance()->getUser(); $user->number = trim($data[Profile::GET_CHANGE_PHONE]); $user->save(); Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=1'); return true; } } } }
public function deleteTeam($id) { Flight::auth()->check(20); $team = Flight::teams()->getTeamWithId($id); $team->delete(); Flight::redirect('/teams'); }
/** * Check if the user is authorized */ public function __construct($install, $login = false) { if (!isset($_SESSION['admin']) && !$install && !$login) { F::redirect('/login'); } parent::__construct($install); }
public function init() { $data = $_REQUEST; if (isset($data[Profile::GET_CHANGE_PASSWORD_BUTTON])) { $user = Auth::getInstance()->getUser(); if (strlen(trim($data[Profile::GET_CHANGE_MAIL])) > 0) { if ($user->email != trim($data[Profile::GET_CHANGE_MAIL])) { if (User::validEmail(trim(strip_tags($data[Profile::GET_CHANGE_MAIL])))) { $user->email = trim(strip_tags($data[Profile::GET_CHANGE_MAIL])); $user->password = User::getHashPassword($user->password, strtolower($user->email)); } else { Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=2'); } } } if (strlen(trim($data[Profile::GET_CHANGE_PASSWORD])) > 0) { if (!User::passwordIsValid($data[Profile::GET_CHANGE_PASSWORD])) { Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=0'); } else { $user->password = User::getHashPassword(trim(strip_tags($data[Profile::GET_CHANGE_PASSWORD])), strtolower($user->email)); } } $user->save(); Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=1'); return true; } }
public static function _manage_platoon($div, $plt) { $division = Division::findByName(strtolower($div)); $platoonId = Platoon::getIdFromNumber($plt, $division->id); if (!is_null($platoonId)) { $user = User::find(intval($_SESSION['userid'])); $member = Member::find(intval($_SESSION['memberid'])); if ($member->platoon_id == $platoonId || $user->role > 2 || User::isDev()) { $tools = Tool::find_all($user->role); $divisions = Division::find_all(); $platoon = Platoon::findById($platoonId); $unassignedMembers = Platoon::unassignedMembers($platoonId, true); $squads = Squad::findByPlatoonId($platoonId); $memberCount = count((array) Platoon::members($platoonId)); $js = 'manage'; Flight::render('manage/platoon', compact('division', 'platoon', 'squads', 'unassignedMembers', 'memberCount'), 'content'); Flight::render('layouts/application', compact('js', 'user', 'member', 'tools', 'divisions')); } else { // insufficient access Flight::redirect('404/', 404); } } else { // nonexistent platoon Flight::redirect('404/', 404); } }
public static function _doAddPartTimeMember() { $member = Member::find(intval($_SESSION['memberid'])); $member_params = array('member_id' => $_POST['member_id'], 'forum_name' => $_POST['name'], 'ingame_alias' => $_POST['ingame_alias'], 'game_id' => $member->game_id); PartTime::add($member_params); Flight::redirect('/manage/part-time'); }
public function deleteAbsence($id) { Flight::auth()->check(); $absence = Flight::absence()->getAbsenceWithId($id); $absence->delete(); Flight::redirect(Flight::request()->referrer); }
public function deletePlayer($id) { Flight::auth()->check(20); $player = Flight::players()->getPlayerWithId($id); $team_id = $player->team; $player->delete(); Flight::redirect('/team/' . $team_id); }
/** * Create a post */ public static function createPost() { if (!Flight::has('currentUser')) { Flight::redirect('/'); } $post = new post(['user' => Flight::get('currentUser')->id, 'title' => Flight::request()->data->title, 'content' => Flight::request()->data->content]); $post->store(); }
public function deleteEvent($id) { Flight::auth()->check(); $event = Flight::events()->getEventWithId($id); $team_id = $event->team; $event->delete(); Flight::redirect("/team/" . $team_id); }
/** * Logout logged user */ public function logout() { unset($_SESSION['db']); unset($_SESSION['logged']); unset($_SESSION); @session_destroy(); session_regenerate_id(); Flight::redirect('./login'); }
/** * check if the install process have been done */ private function checkInstall($install) { if (F::has('password')) { if (!$install && empty(F::get('password'))) { F::redirect('/install'); } elseif ($install && !empty(F::get('password'))) { F::redirect('/login'); } } }
public function sendMessage() { $data = $_REQUEST; if (isset($data[Help::GET_SEND])) { $message = wordwrap(trim(strip_tags($data[Help::GET_MESSAGE])), 70, "\r\n"); $theme = trim(strip_tags($data[Help::GET_THEME])); if ($this->send_mime_mail(Auth::getInstance()->getUser()->login, Auth::getInstance()->getUser()->login . '@no-reply', 'admin', "*****@*****.**", 'UTF-8', 'windows-1251', $theme, $message)) { Flight::redirect('/help?success=1'); } } }
/** * Logout process */ public function logout() { if (isset($_SESSION['admin'])) { $_SESSION['admin'] = null; $_SESSION['flashbag'] = ' <div class="alert alert-success alert-dismissible"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> You are no longer logged in. </div>'; } F::redirect('/'); }
public function init() { $data = $_REQUEST; if (isset($data[Controllerquest::BUTTON_DELETE])) { if (isset($data['idUser'])) { $user = Users::find_by_id($data['idUser']); $user->delete(); Flight::redirect('/users?success=1'); } } $this->_Users = Users::find('all'); }
public static function author($id = null) { if ($id == null) { if (Flight::has('currentUser')) { $user = Flight::get('currentUser'); } else { Flight::redirect("/"); } } else { $user = Flight::users()->getUserWithId($id); } Flight::util()->render('profile', ['user' => $user]); }
public function register() { Flight::auth()->check(20); $response = Flight::util()->validate("user", Flight::request()->data); if (is_array($response)) { Flight::util()->render('newUser', array('error' => $response, "teams" => Flight::teams()->getAllTeams())); return; } $data = Flight::request()->data; $user = new user($data); $user->teams = Flight::request()->data->teams; $user->store(); Flight::redirect("/createUser"); }
public static function _profile($id) { $user = User::find(intval($_SESSION['userid'])); $member = Member::find(intval($_SESSION['memberid'])); $tools = Tool::find_all($user->role); $divisions = Division::find_all(); // profile data $memberInfo = Member::findByMemberId(intval($id)); if (property_exists($memberInfo, 'id')) { $divisionInfo = Division::findById(intval($memberInfo->game_id)); $platoonInfo = Platoon::findById(intval($memberInfo->platoon_id)); $recruits = Member::findRecruits($memberInfo->member_id); $gamesPlayed = MemberGame::get($memberInfo->id); $aliases = MemberHandle::findByMemberId($memberInfo->id); // game data $bdate = date("Y-m-d", strtotime("tomorrow - 30 days")); $edate = date("Y-m-d", strtotime("tomorrow")); $totalGames = BfActivity::countPlayerGames($memberInfo->member_id, $bdate, $edate); $aodGames = BfActivity::countPlayerAODGames($memberInfo->member_id, $bdate, $edate); $games = BfActivity::find_allGames($memberInfo->member_id); $pctAod = $totalGames > 0 ? $aodGames * 100 / $totalGames : 0; switch ($divisionInfo->short_name) { case "bf": $activity = array('totalGames' => $totalGames, 'aodGames' => $aodGames, 'games' => $games, 'pctAod' => $pctAod); $activity_page = $divisionInfo->short_name; break; default: $activity = array(); $activity_page = 'default'; break; } if (property_exists($platoonInfo, 'id')) { $platoonInfo->link = "<li><a href='divisions/{$divisionInfo->short_name}/platoon/{$platoonInfo->number}'>{$platoonInfo->name}</a></li>"; $platoonInfo->item = "<li class='list-group-item text-right'><span class='pull-left'><strong>Platoon: </strong></span> <span class='text-muted'>{$platoonInfo->name}</span></li>"; } // if squad leader, show recruits if ($memberInfo->position_id == 5) { Flight::render('member/sl-personnel', array('member' => $memberInfo), 'sl_personnel'); } Flight::render('member/alerts', array('memberInfo' => $memberInfo), 'alerts'); Flight::render('member/recruits', array('recruits' => $recruits), 'recruits'); Flight::render('member/member_data', array('memberInfo' => $memberInfo, 'divisionInfo' => $divisionInfo, 'platoonInfo' => $platoonInfo, 'aliases' => $aliases), 'member_data'); Flight::render('member/activity/' . $activity_page, $activity, 'activity'); Flight::render('member/history', array(), 'history'); Flight::render('member/profile', array('user' => $user, 'member' => $member, 'memberInfo' => $memberInfo, 'divisionInfo' => $divisionInfo, 'platoonInfo' => $platoonInfo, 'gamesPlayed' => $gamesPlayed), 'content'); Flight::render('layouts/application', array('js' => 'member', 'user' => $user, 'member' => $member, 'tools' => $tools, 'divisions' => $divisions)); } else { Flight::redirect('/404', 404); } }
public function changeQuest($id) { $quest = Quest::find_by_id($id); if ($quest instanceof Quest) { $quest->name = trim(strip_tags($this->data['name_modal'])); $quest->name = trim(strip_tags($this->data['name_modal'])); $quest->sex = trim(strip_tags($this->data['quest1'])); $quest->fio = trim(strip_tags($this->data['quest2'])); $quest->ref = trim(strip_tags($this->data['quest4'])); $quest->rev = trim(strip_tags($this->data['quest5'])); $quest->mail = trim(strip_tags($this->data['quest6'])); $quest->tel = trim(strip_tags($this->data['quest7'])); $quest->save(); Flight::redirect('/quest?success=2'); } }
public function init() { $data = $_REQUEST; if (isset($data[Setting::GET_SYSTEM_STATUS_BUTTON])) { if (isset($data[Setting::GET_SYSTEM_STATUS])) { $status = new Status_System(); $status->is_active = 1; $status->save(); Flight::redirect('/admin/setting'); } else { $status = new Status_System(); $status->is_active = 0; $status->save(); Flight::redirect('/admin/setting'); } } }
public function init() { $data = $_REQUEST; // выход if (isset($data[Auth::GET_LOGOUT])) { $_COOKIE[Auth::COOKIE_INDETIFICATION] = ''; setcookie(Auth::COOKIE_INDETIFICATION, '', 0, '/'); Flight::redirect('/'); } // вход $this->initByRequest(); if (!$this->isAuth()) { $this->initByCookie(); if (!$this->isAuth()) { setcookie(Auth::COOKIE_INDETIFICATION, '', 0, '/'); } } }
public static function _retentionNumbers() { $user = User::find(intval($_SESSION['userid'])); if ($user->role >= 3 || User::isDev()) { $member = Member::find(intval($_SESSION['memberid'])); $tools = Tool::find_all($user->role); $divisions = Division::find_all(); $recruited = Report::recruitedLast30days($member->game_id); $removed = Report::removedLast30days($member->game_id); $monthlyBreakdown = Report::recruitingWeekly($member->game_id); $byTheMonth = Report::recruitingByTheMonth($member->game_id); $js = 'report'; Flight::render('reports/retention', compact('recruited', 'removed', 'js', 'monthlyBreakdown', 'byTheMonth'), 'content'); Flight::render('layouts/application', array('user' => $user, 'member' => $member, 'tools' => $tools, 'divisions' => $divisions)); } else { Flight::redirect('/404', 404); } }
/** * Reading / Editing page */ public function page($params) { $mode = $params[0]; $pageinfos = F::get('pageinfos'); if (empty($pageinfos['cat'])) { $pageTitle = F::get('config')['document']; $url_view = '{$root}'; $url_edit = '{$root}.edit'; $path = 'docs/.home'; } else { $pageTitle = Files::getPageTitle($pageinfos['cat'], $pageinfos['page']); $url_view = '{$root}' . $pageinfos['cat'] . '/' . $pageinfos['page']; $url_edit = '{$root}' . $pageinfos['cat'] . '/' . $pageinfos['page'] . '.edit'; $path = 'docs/' . $pageinfos['cat'] . '/' . $pageinfos['page']; } if (file_exists($path) && is_file($path) && is_readable($path)) { $pageContent = file_get_contents($path); # Edit mode if ($mode == 'edit' && F::has('admin')) { # Content submited if (F::request()->method == 'POST') { $pageContent = F::request()->data->pageContent; file_put_contents($path, $pageContent); $_SESSION['flashbag'] = ' <div class="alert alert-success alert-dismissible"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> The page has been saved </div>'; F::redirect('/' . $pageinfos['cat'] . '/' . $pageinfos['page']); } else { $pageContent = file_get_contents($path); F::render('Doc/page-edit.html', array('page_edit_url' => $url_edit, 'page_view_url' => $url_view, 'page_title' => $pageTitle, 'page_content' => $pageContent, 'edition_mode' => true)); } } else { F::render('Doc/page-view.html', array('page_edit_url' => $url_edit, 'page_title' => $pageTitle, 'page_content' => $pageContent, 'page_last_modif' => date('Y-m-d H:i:s', filemtime($path)))); } } else { F::render('Core/404.html'); } }
public static function _doLogin() { $user = trim(htmlspecialchars($_POST['user'])); $pass = $_POST['password']; if (!User::exists($user)) { $invalid_login = true; } else { $params = User::validatePassword($pass, $user); if (empty($params)) { $invalid_login = true; } else { // updateLoggedInTime($user); $_SESSION['loggedIn'] = true; $_SESSION['userid'] = $params['userid']; $_SESSION['memberid'] = $params['memberid']; } } if (isset($invalid_login)) { Flight::redirect('/invalid-login'); } else { Flight::redirect('/'); } }
$track = json_decode(getTrack($id)); if (!isset($track->error)) { Flight::render('editTRack', array('track' => $track), 'body_content'); Flight::render('layout', array('Titre' => 'Modifier le track ' . $track[0]->title)); } else { Flight::redirect($request->referrer); } }); Flight::route('GET|POST /album/@id/edit', function ($id) { $request = Flight::request(); if ($request->method == "GET") { $album = json_decode(getAlbum($id)); if (!isset($album->error)) { Flight::render('editAlbum', array('album' => $album), 'body_content'); Flight::render('layout', array('Titre' => 'Modifier un track à ' . $album[0]->title)); } else { Flight::redirect($request->referrer); } } else { if ($request->method == "POST") { $album = json_encode($_POST); $result = json_decode(editAlbum($album)); if (isset($result->ID)) { Flight::redirect($request->referrer); } else { Flight::redirect('http://localhost/php/App/playlists'); } } } }); Flight::start();
<?php require 'vendor/autoload.php'; //define('PREFIX', ''); //default define('PREFIX', '.aldgate'); //default Flight::route('/', function () { $en = Flight::request()->query['en']; if ($en == 1) { Flight::redirect('home'); } else { Flight::redirect('inicio'); } }); Flight::route('/inicio(/@active)', function ($active) { $active = isset($active) ? $active : 'home'; Flight::render('home' . PREFIX . '.es', array('active' => $active, 'lang' => 'es')); }); Flight::route('/home(/@active)', function ($active) { $active = isset($active) ? $active : 'home'; Flight::render('home' . PREFIX . '.en', array('active' => $active, 'lang' => 'en')); }); Flight::route('/aboutus', function () { Flight::render('aboutus' . PREFIX . '.en', array('active' => 'aboutus', 'lang' => 'en')); }); Flight::route('/sobrenosotros', function () { Flight::render('aboutus' . PREFIX . '.es', array('active' => 'aboutus', 'lang' => 'es')); }); Flight::route('/quienessomos', function () { Flight::render('aboutus' . PREFIX . '.es', array('active' => 'aboutus', 'lang' => 'es')); });
$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(); });
ini_set('session.cookie_secure', '1'); } // A special bit of configuration for our host: // An SSL proxy is provided at https://sslsites.de/your.domain/ // By default, a cookie is set for sslsites.de which means // other websites available over that proxy can read the cookies! ini_set('session.cookie_path', parse_url(MY_URL, PHP_URL_PATH)); // Sessions valid for one hour session_set_cookie_params(COOKIE_SESSION_DURATION); session_start(); require_once 'include/flight/flight/Flight.php'; require_once 'tokens.php'; init_token_db(); require_once 'handlers/fb_handlers.php'; Flight::route('/', 'handle_root'); Flight::route('/login', 'handle_login'); Flight::route('/fb_callback', 'handle_fb_callback'); Flight::route('/checkin', 'handle_checkin'); Flight::route('/access_code', 'handle_access_code'); Flight::route('/privacy', 'handle_privacy'); Flight::route('/rerequest_permission/', 'handle_rerequest_permission'); require_once 'handlers/gw_handlers.php'; Flight::route('/ping', 'handle_ping'); Flight::route('/auth', 'handle_auth'); // Once login is done, the gateway redirects // the user to MY_URL . 'portal' // We don't serve this here, so use external page Flight::route('/portal', function () { Flight::redirect(PORTAL_URL); }); Flight::start();