/** * Inserts comment into database. * @param int $userId Id of user who is posting the comment. * @param string $comment Comment text. * @return string JSON encoded string that consist of 3 fields: * user,comment and postTime */ public function insertComment($userId, $comment) { $user = new ASUser($userId); $userInfo = $user->getInfo(); $datetime = date("Y-m-d H:i:s"); $this->db->insert("as_comments", array("posted_by" => $user->id(), "posted_by_name" => $userInfo['username'], "comment" => strip_tags($comment), "post_time" => $datetime)); $result = array("user" => $userInfo['username'], "comment" => stripslashes(strip_tags($comment)), "postTime" => $datetime); return json_encode($result); }
/** * Get page where user should be redirected, based on user's role. * If there is no specific page set for provided role, redirect to default page. * * @return string Page where user should be redirected. */ function get_redirect_page() { $login = new ASLogin(); if ($login->isLoggedIn()) { $user = new ASUser(ASSession::get("user_id")); $role = $user->getRole(); } else { $role = 'default'; } $redirect = unserialize(SUCCESS_LOGIN_REDIRECT); if (!isset($redirect['default'])) { $redirect['default'] = 'index.php'; } return isset($redirect[$role]) ? $redirect[$role] : $redirect['default']; }
<?php include "admin/ASEngine/AS.php"; if (!$login->isLoggedIn()) { redirect("login.php"); } $user = new ASUser(ASSession::get("user_id")); $userInfo = $user->getInfo(); require 'conf/data.php'; require 'includes/header.php'; require 'includes/nav.php'; require 'includes/modal.php'; ?> <div class="container"> <?php if (strlen($search) <= 1) { ?> <br><br><br> <h3>Search term "<?php echo $search; ?> " too short</h3><hr> <?php } else { ?> <h3>You searched for "<i><?php echo $search; ?>
function onlyAdmin() { $login = new ASLogin(); if (!$login->isLoggedIn()) { exit; } $loggedUser = new ASUser(ASSession::get("user_id")); if (!$loggedUser->isAdmin()) { exit; } }
<a href="/Fed/Production/index.php?id=<?php echo $previd; ?> ">Previous</a> </li> <li> <a href="/Fed/Production/index.php?id=<?php echo $nextid; ?> ">Next</a> </li> <?php $userId = ASSession::get('user_id'); $user = new ASUser($userId); ?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?php echo ASLang::get('welcome'); ?> , <?php echo e($userInfo['username']); ?> <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li> <a href="admin/profile.php">
?> <!--</th>--> <th><?php echo ASLang::get('confirmed'); ?> </th> <th><?php echo ASLang::get('action'); ?> </th> </thead> <?php foreach ($users as $user) { ?> <?php $tmpUser = new ASUser($user['user_id']); ?> <?php $userRole = $tmpUser->getRole(); ?> <tr class="user-row"> <td><?php echo htmlentities($user['username']); ?> </td> <td><?php echo htmlentities($user['email']); ?> </td> <td><?php echo $user['register_date'];
/** * Check if user has already logged in via specific provider and return user's data if he does. * @param $provider oAuth provider (facebook, twitter or gmail) * @param $id Identifier provided by provider * @return array|mixed User info if user has already logged in via specific provider, empty array otherwise. */ public function getBySocial($provider, $id) { $result = $this->db->select('SELECT * FROM `as_social_logins` WHERE `provider` = :p AND `provider_id` = :id ', array('p' => $provider, 'id' => $id)); if (count($result) > 0) { $res = $result[0]; $user = new ASUser($res['user_id']); return $user->getInfo(); } else { return $result; } }