public function index() { $user = UserService::getCurrentUser(); if (isset($user)) { echo 'Welcome, ' . $user->getNickname(); if (UserService::isCurrentUserAdmin()) { $data = array('title' => 'Admin Section', 'hello' => 'Hello admin...', 'content' => 'You are accessing the backend now'); $this->render("admin.html", $data); } else { header('Location: ' . UserService::createLoginURL($_SERVER['REQUEST_URI'])); } } }
<?php require_once 'vendor/autoload.php'; require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php'; use google\appengine\api\users\User; use google\appengine\api\users\UserService; session_start(); define('BASE_URL', 'http://localhost:8080'); define('USER', ''); define('PASS', ''); define('HOST', ''); define('DB', ''); //Csv Fileupload gsbucket options $options = ['gs_bucket_name' => 'shaffer-skiper.appspot.com']; $user = UserService::getCurrentUser(); $loginUrl = UserService::createLoginURL($_SERVER['REQUEST_URI']); $logoutUrl = UserService::createLogoutUrl('/');
<?php use google\appengine\api\users\User; use google\appengine\api\users\UserService; # Looks for current Google account session $user = UserService::getCurrentUser(); $username = ""; if ($user) { $username = '******' . htmlspecialchars($user->getNickname()); } else { header('Location: ' . UserService::createLoginURL($_SERVER['REQUEST_URI'])); } // display main welcome page echo '<!DOCTYPE html>'; echo '<html lang=en>'; echo '<meta charset=utf-8>'; echo "<head><title>RealCode - Coding Collaboration | Isreal Consulting (Proprietary)</title>"; echo "<!--[if lt IE 9]>\n<script src='http://html5shiv.googlecode.com/svn/trunk/html5.js'>\n</script>\n<![endif]-->"; echo "<link rel='stylesheet' type='text/css' href='stylesheet-main.css'>"; echo '</head>'; echo '<body>'; echo '<header>'; echo ' <h1>RealCode - Coding Collaboration | Isreal Consulting (Proprietary)</h1> </header>'; echo "<nav>\n<ul>\n <li><a href='main.php'>Home</a></li>\n <li><a href='#'>Login</a></li>\n <li><a href='README.md'>Readme</a></li>\n</ul>\n</nav>"; echo '<section>'; echo "<h1>NOTICE</h1>\n\n<article>\n<h2>Private & Proprietary Sytem</h2>\n<p>This system is private and owned by Isreal Consulting. Unauthorized access is prohibited. Violators will be prosecuted.</p>\n</article>"; echo "Welcome, " . $username; echo "<article>\n<h2>For Support</h2>\n<p>Visit the Isreal Consulting Support site:<br />\n<a href='http://cs.isrealconsulting.com'>support.isrealconsulting.com</a></p>"; echo '</article>'; echo '</section>';
public function redirect_to_login() { header('Location: ' . UserService::createLoginURL($_SERVER['REQUEST_URI'])); exit; }
$user = UserService::getCurrentUser(); if ($user) { ?> <span class="username"><?php echo $user->getNickname(); ?> </span> <a href="<?php echo UserService::createLogoutURL('', "google.com"); ?> ">log out</a> <?php } else { ?> <a href="<?php echo UserService::createLoginURL(''); ?> ">log in</a> <?php } ?> | <a href="reset.do">Reset Session</a> | Shift-Enter for newline | Ctrl-Up/Down for history | <a href="http://code.google.com/appengine/"> <img id="logo" src="/static/appengine_button_noborder.gif" width="120px" height="30px" /></a> </p> <script type="text/javascript"> document.getElementById('statement').focus(); </script>
public function testCreateLoginOtherApplicationError() { $req = new \google\appengine\CreateLoginURLRequest(); $req->setDestinationUrl('http://abc'); $exception = new \google\appengine\runtime\ApplicationError(123, 'yyy'); $this->setExpectedException('\\google\\appengine\\runtime\\ApplicationError', 'yyy'); $this->apiProxyMock->expectCall('user', 'CreateLoginURL', $req, $exception); UserService::createLoginURL('http://abc'); }
if ($conn->query("CREATE DATABASE IF NOT EXISTS {$db}") === FALSE) { die("Could not create database: {$conn->error} [{$conn->errno}]"); } if ($conn->select_db($db) === FALSE) { die("Could not select database: {$conn->error} [{$conn->errno}]"); } if ($conn->query($greeting_schema) === FALSE) { die("Could not create tables: {$conn->error} [{$conn->errno}]"); } $user = UserService::getCurrentUser(); if ($user) { $url = UserService::createLogoutURL('', "google.com"); $url_linktext = "Logout"; $author = $user->getNickname(); } else { $url = UserService::createLoginURL(''); $url_linktext = "Login"; $author = ""; } if (isset($_POST['content'])) { $stmt = $conn->prepare("INSERT INTO greeting (author, content) VALUES (?, ?)"); if ($stmt->bind_param('ss', $author, $_POST['content']) === FALSE) { die("Could not bind prepared statement"); } if ($stmt->execute() === FALSE) { die("Could not execute prepared statement"); } $stmt->close(); header("Location: /"); exit; }