/** * Constructor */ public function __construct($install) { parent::__construct($install); if (F::has('pageinfos')) { F::view()->assign(array('pageinfos' => Files::getPageInfos(F::get('pageinfos')['cat'], F::get('pageinfos')['page']))); } }
/** * Save properties of the user profile * @return [JSON] Success or error message */ public static function saveProfile() { if (!Flight::has('currentUser')) { Flight::json(['Error' => 'No Access']); } $currentUser = Flight::get('currentUser'); if (isset(Flight::request()->query->bio)) { $currentUser->bio = Flight::request()->data->bio; } else { if (isset(Flight::request()->query->password)) { if (!isset(Flight::request()->data->passwordold) || !isset(Flight::request()->data->passwordnew1) || !isset(Flight::request()->data->passwordnew2)) { Flight::json(['success' => false, 'exception' => 'Empty fields']); } if ($currentUser->password === hash("sha256", Flight::request()->data->passwordold)) { if (Flight::request()->data->passwordnew1 == Flight::request()->data->passwordnew2) { $currentUser->password = hash("sha256", Flight::request()->data->passwordnew1); } else { Flight::json(['success' => false, 'exception' => 'New passwords are not the same']); } } else { Flight::json(['success' => false, 'exception' => 'Old password is not correct ']); } } } $result = $currentUser->update(); if ($result != false) { $_SESSION['user'] = Flight::users()->getUserWithId(Flight::get('currentUser')->id); Flight::json(['success' => true]); } else { Flight::json(['sucess' => false, 'exception' => 'An error']); } }
public function get($key) { if ($val = parent::get($key)) { return $val; } return Flight::has($key) ? Flight::get($key) : null; }
/** * 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(); }
function getLang() { if (!isset($_COOKIE["extractLang"])) { setLang('it'); } if (Flight::has('lang')) { return Flight::get('lang'); } return $_COOKIE["extractLang"]; }
/** * 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 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]); }
/** * 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'); } }
<?php if (Flight::has('data_partenaires')) { $data = Flight::get('data_partenaires'); $c = 1; foreach ($data as $p) { if ($c % 2 == 0) { echo "<div class='content-section-a'>"; $class1 = "col-lg-5 col-sm-6"; $class2 = "col-lg-5 col-lg-offset-2 col-sm-6"; } else { echo "<div class='content-section-b'>"; $class1 = "col-lg-5 col-lg-offset-1 col-sm-push-6 col-sm-6"; $class2 = "col-lg-5 col-sm-pull-6 col-sm-6"; } echo "\n <div class='container'>\n <div class='row'>\n <div class='{$class1}'>\n <hr class='section-heading-spacer'>\n <div class='clearfix'></div>\n <h2 class='section-heading'> {$p['0']} </h2>\n {$p['3']}\n </div>\n <div class='{$class2}'>\n <a href='{$p['2']}'> <img class='img-responsive' src='{$p['1']}' alt=''> </a>\n </div>\n </div>\n\n </div>\n <!-- /.container -->\n\n </div>\n <!-- /.content-section-a -->"; $c = $c + 1; } // foreach } // if
/** * Call GUI Builder */ $gui = new Core_GUI($module); /** * Javascript Generator */ $js = new Core_GUI_JS($module); /** * Build Page Header */ $gui->getHeader(); /** * Get Resource ID */ if (Flight::has('RESOURCE_ID')) { $resId = Flight::get('RESOURCE_ID'); Flight::clear('RESOURCE_ID'); } else { // Bad Request Flight::redirect('/400'); } // =========================================================================================================== /** * Fetch Resource Model */ $dbh = Core_DBH::getDBH(); // Get Database Handle $sth = $dbh->prepare("\n\tSELECT\n\t\tbox.box_id,\n\t\tos.operating_system,\n\t\tbox.name,\n\t\tbox.notes,\n\t\tbox.steam_lib_path\n\tFROM " . DB_PREFIX . "box AS box\n\tJOIN " . DB_PREFIX . "os AS os\n\t\tON box.os_id = os.os_id\n\tWHERE\n\t\tbox.box_id = :resId\n\t;"); $sth->bindParam(':resId', $resId); $sth->execute();
$csshtml = ''; if (Flight::has('csslib')) { foreach (Flight::get('csslib') as $value) { if (!strpos($value, '?')) { $csshtml .= "<link href=\"" . $value . "?v=" . Flight::get('VERSION') . "\" rel=\"stylesheet\" >\n"; } else { $csshtml .= "<link href=\"" . $value . "&v=" . Flight::get('VERSION') . "\" rel=\"stylesheet\" >\n"; } } } return $csshtml; }); // 打印js Flight::map('printjs', function () { $jshtml = ''; if (Flight::has('jslib')) { foreach (Flight::get('jslib') as $value) { if (!strpos($value, '?')) { $jshtml .= "<script type='text/javascript' src=\"" . $value . "?v=" . Flight::get('VERSION') . "\"></script>\n"; } else { $jshtml .= "<script type='text/javascript' src=\"" . $value . "&v=" . Flight::get('VERSION') . "\"></script>\n"; } } } return $jshtml; }); Flight::map('defaultassets', function ($tag = 1) { if ($tag == 1) { // css $html = '<link rel="stylesheet" href="/public/css/bootstrap.min.css" type="text/css" /> <link rel="stylesheet" href="/public/css/font-awesome.min.css" type="text/css" />
<?php echo Flight::get('region'); ?> , <?php echo Flight::get('countryName'); ?> - Telephone Area Code: <?php echo Flight::get('areaCode'); ?> <a class="right" target="_blank" href="http://geoplugin.com/">geoplugin.com</a> </div> </div> <?php if ($js && Flight::has('google_analytics_site_id')) { ?> <script> (function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]= function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date; e=o.createElement(i);r=o.getElementsByTagName(i)[0]; e.src='//www.google-analytics.com/analytics.js'; r.parentNode.insertBefore(e,r)}(window,document,'script','ga')); ga('create','<?php echo Flight::get('google_analytics_site_id'); ?> ');ga('send','pageview'); </script> <?php }
<?php if ($geoinfo && $js) { switch ($maptype) { case 'here': $mapurl = "https://www.here.com/?map=" . Flight::get('latitude') . "," . Flight::get('longitude') . ",12,satellite"; break; case 'google': if (Flight::has('google_embed_key')) { $mapurl = "https://www.google.com/maps/embed/v1/view?key=" . Flight::get('google_embed_key') . "¢er=" . Flight::get('latitude') . "," . Flight::get('longitude') . "&zoom=12&maptype=satellite"; } else { $mapurl = "http://wikimapia.org/#lang=en&lat=" . Flight::get('latitude') . "&lon=" . Flight::get('longitude') . "&z=12&m=b"; } break; case 'wikimapia': $mapurl = "http://wikimapia.org/#lang=en&lat=" . Flight::get('latitude') . "&lon=" . Flight::get('longitude') . "&z=12&m=b"; break; default: $mapurl = "https://www.google.com/maps/embed/v1/view?key=" . Flight::get('google_embed_key') . "¢er=" . Flight::get('latitude') . "," . Flight::get('longitude') . "&zoom=12&maptype=satellite"; } ?> <div id="mappane"> <iframe id="map" src="<?php echo $mapurl; ?> " frameborder="0"></iframe> </div> <?php } elseif ($geoinfo) { ?>
<!doctype html> <html> <head> <meta charset="utf-8"> <title> <?php echo Flight::has('title') ? Flight::get('title') : 'Example'; ?> </title> </head> <body>
echo $user->bio; ?> </p> <?php if (Flight::has('currentUser') && Flight::get("currentUser")->id == $user->id) { ?> <textarea id="bio-edit" style="display:none"></textarea> <button id="updateBio" type="button" class="btn btn-success">Update</button> <button id="saveBio" type="button" class="btn btn-success" style="display:none">Save</button> <button id="cancelBio" type="button" class="btn btn-danger" style="display:none">Cancel</button> <?php } ?> </div> <?php if (Flight::has('currentUser') && Flight::get("currentUser")->id == $user->id) { ?> <div class="tab-pane fade in" id="tab3"> <div id="passwordalert" style="display:none" class="alert alert-danger" role="alert"></div> <h3>Change Password:</h3> <div class="input-group"> <span class="input-group-addon" id="label-oldpassword">Old Password</span> <input type="password" class="form-control" id="passwordold" placeholder="Old Password" aria-describedby="label-oldpassword"> </div> <br> <div class="input-group"> <span class="input-group-addon" id="label-new1password">New Password</span> <input type="password" class="form-control" id="passwordnew1" placeholder="New Password" aria-describedby="label-new1password"> </div> <br> <div class="input-group">
<?php require 'vender/session/class.session.php'; require 'vender/flight/Flight.php'; require 'vender/medoo/medoo.min.php'; // 定义默认配置变量 $conf = (include 'conf/conf.php'); foreach ($conf as $key => $value) { if (!Flight::has($key)) { Flight::set(strtoupper($key), $value); } } // 修改默认配置 // 覆盖base url 请求 Flight::set('flight.base_url ', Flight::get('SITE_URL')); // 允许 Flight 处理所有内部错误。 (默认: true) Flight::set('flight.handle_errors ', true); // 将错误日志记录到 web server 的错误日志文件。 (默认: false) Flight::set('flight.log_errors', true); // 包含视图模板文件的目录 (默认: ./views) Flight::set('flight.views.path', './view'); // 添加半自动类路径 Flight::path(dirname(__FILE__) . '/controller'); // 定义路径 define('ROOT_PATH', dirname(__FILE__)); define('VIEW_PATH', dirname(__FILE__) . '/view'); define('CORE_PATH', dirname(__FILE__) . '/core'); define('VENDER_PATH', dirname(__FILE__) . '/vender'); define('LOG_PATH', dirname(__FILE__) . '/log'); define('CONF_PATH', dirname(__FILE__) . '/conf'); define('FILE_PATH', dirname(__FILE__) . '/files');
<?php if (Flight::has('data_sponsors')) { $data = Flight::get('data_sponsors'); $c = 1; foreach ($data as $p) { if ($c % 2 == 0) { echo "<div class='content-section-a'>"; $class1 = "col-lg-5 col-sm-6"; $class2 = "col-lg-5 col-lg-offset-2 col-sm-6"; } else { echo "<div class='content-section-b'>"; $class1 = "col-lg-5 col-lg-offset-1 col-sm-push-6 col-sm-6"; $class2 = "col-lg-5 col-sm-pull-6 col-sm-6"; } echo "\n <div class='container'>\n <div class='row'>\n <div class='{$class1}'>\n <hr class='section-heading-spacer'>\n <div class='clearfix'></div>\n <h2 class='section-heading'> {$p['0']} </h2>\n {$p['3']}\n </div>\n <div class='{$class2}'>\n <a href='{$p['2']}'> <img class='img-responsive' src='{$p['1']}' alt=''> </a>\n </div>\n </div>\n\n </div>\n <!-- /.container -->\n\n </div>\n <!-- /.content-section-a -->"; $c = $c + 1; } // foreach } // if
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="<?php Flight::link('/'); ?> ">Blog</a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <?php if (Flight::has('currentUser')) { ?> <ul class="nav navbar-nav"> <li><a href="<?php Flight::link('/create'); ?> ">New Post</a></li> <li><a href="<?php Flight::link('/profile'); ?> ">Profile</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <p class="navbar-text">Signed in as <?php echo Flight::get('currentUser')->fullName(); ?>
<?php /** * User: LukaszPapierz * Date: 2015-09-13 * */ if (Flight::has('error_reporting')) { error_reporting(Flight::get('error_reporting')); }
<?php if (Flight::has('data_programme')) { $data = Flight::get('data_programme'); $c = 1; foreach ($data as $p) { if ($c % 2 == 0) { echo "<div class='content-section-a'>"; $class1 = "col-lg-5 col-sm-6"; $class2 = "col-lg-5 col-lg-offset-2 col-sm-6"; } else { echo "<div class='content-section-b'>"; $class1 = "col-lg-5 col-lg-offset-1 col-sm-push-6 col-sm-6"; $class2 = "col-lg-5 col-sm-pull-6 col-sm-6"; } echo "\n <div class='container'>\n <div class='row'>\n <div class='{$class1}'>\n <hr class='section-heading-spacer'>\n <div class='clearfix'></div>\n <h2 class='section-heading'> {$p['0']} </h2>\n {$p['3']}\n </div>\n <div class='{$class2}'>\n <a href='{$p['2']}'> <img class='img-responsive' src='{$p['1']}' alt=''> </a>\n </div>\n </div>\n\n </div>\n <!-- /.container -->\n\n </div>\n <!-- /.content-section-a -->"; $c = $c + 1; } // foreach } // if