/** * 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); }
<?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; ?>
/** * 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; } }