/** * Generic function to access information of the User that is currently logged in. * * @param string $field The name of the key one wants to read * @param string $model Name of the associated $model to return information from (defaults to the User model itself) * @return mixed Either the value of $field on success or 'false' on failure * @access public */ static function get($field = null) { $user = Configure::read('User'); if (empty($user) && !defined('INTERNAL_CAKE_ERROR')) { User::sessionLogin() || User::cookieLogin() || User::guestLogin(); $user = Configure::read('User'); Assert::notEmpty($user); } if (empty($field) || is_null($user)) { return $user; } if (strpos($field, '.') === false) { if (in_array($field, array_keys($user))) { return $user[$field]; } $field = 'User.' . $field; } return Set::extract($user, $field); }
<?php @session_start(); require_once "../vars.php"; require_once "../includes/user.class.php"; if (!isset($_SESSION['loggeduser_id']) && isset($_COOKIE['guid'])) { $user = new User(); $res = $user->cookieLogin($_COOKIE['guid']); if (!$res) { setcookie("guid", "", time() - 60 * 60, "/"); } } if (!isset($_SESSION['loggeduser_id']) || !$_SESSION['loggeduser_id'] || !isset($_POST['watch_id']) || !isset($_POST['watch_type'])) { exit; } $user_id = (int) $_SESSION['loggeduser_id']; $target_id = (int) $_POST['watch_id']; $target_type = (int) $_POST['watch_type']; require_once "../includes/stream.class.php"; require_once "../includes/show.class.php"; require_once "../includes/movie.class.php"; $stream = new Stream(); if ($user_id && $target_id && $target_type) { $data = array(); $data['user_id'] = $user_id; $data['target_id'] = $target_id; $data['target_type'] = $target_type; $data['date_added'] = date("Y-m-d H:i:s"); $res = $stream->addWatch($data); if ($res) { $data = array();
/** * Function is called to set-up the current user before all other calls. * For an authentic user, settings and details are updated. * * @return bool */ public function authenticateUser() { if (isset($_SESSION["userData"]) && $_SESSION["userData"]->uid) { User::$current_user = $_SESSION["userData"]; //User::$current_user->refreshDetails(); //User::$current_user->refreshSettings(); } else { $_SESSION["userData"] = User::cookieLogin(); User::$current_user = $_SESSION["userData"]; //User::$current_user->getFriends(); } User::$current_user->initialize(); return true; }