<?php require_once __DIR__ . "/config.php"; /** * Add the Login Page in /admin/login route */ \Lobby\Router::route("/admin/login", function () { if (\Fr\LS::userExists("admin") === false) { \Fr\LS::register("admin", "admin", array("name" => "Admin", "created" => date("Y-m-d H:i:s"))); } include __DIR__ . "/page/login.php"; }); /** * Add the Change Password Page in /admin/ChangePassword route */ \Lobby\Router::route("/admin/ChangePassword", function () { include __DIR__ . "/page/change_password.php"; }); if (\Fr\LS::$loggedIn) { /** * Logged In */ \Lobby::hook("init", function () { /** * Add Change Password Item in Top Panel -> Admin before Log Out item * This is done by first removing the Log Out item, adding the Change * Password item and then adding back the Log Out item */ \Lobby\Panel::$top_items['left']['lobbyAdmin']['subItems']['ChangePassword'] = array("text" => "Change Password", "href" => "/admin/ChangePassword"); \Lobby\Panel::$top_items['left']['lobbyAdmin']['subItems']['LogOut'] = array("text" => "Log Out", "href" => "/admin/login?logout"); });
$client->client_id = 'fbAppID'; $client->client_secret = 'fbAppSecret'; $client->scope = 'user_about_me,email,user_birthday,user_location,publish_actions'; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://graph.facebook.com/me', 'GET', array(), array('FailOnAccessError' => true), $user); if ($success) { $location = $_SESSION['continue']; $email = $user->email; $name = $user->name; $gender = $user->gender; if (\Fr\LS::userExists($email)) { /** * Since user exists, we log him/her in */ \Fr\LS::login($email, ""); $who = $_SESSION['logSyscuruser']; $sql = $OP->dbh->prepare("UPDATE `oauth_session` SET `user` = ? WHERE `server` = ? AND `access_token` = ?"); $sql->execute(array($who, "Facebook", $client->access_token)); $OP->redirect($location); } else { /** * Make it DD/MM/YYYY format */ $birthday = date('d/m/Y', strtotime($user->birthday)); $image = get_headers("https://graph.facebook.com/me/picture?width=200&height=200&access_token=" . $client->access_token, 1); /* Facebook Redirects the above URL to the image URL, We get that new URL ! PHP is Magic */
/** * Add routes */ public function routes() { /** * Add the Login Page in /admin/login route */ \Lobby\Router::route("/admin/login", function () { if (LS::userExists("admin") === false) { LS::register("admin", "admin", array("name" => "Admin", "created" => date("Y-m-d H:i:s"))); } include __DIR__ . "/page/login.php"; }); }