function generateData() { global $current_user; // мини блок с меню пользователя и его инфо // если страница user/id и это не наша страница - рисуем чужого пользователя $id = Request::get(0, false); if (!$id) { return false; } if ($id == $current_user->id) { return false; } else { $user = Users::getById($id); } /* @var $user User */ /* @var $current_user CurrentUser */ // выдаем данные по пользователю $this->data['profile']['id'] = $user->id; // можно добавить в друзья? if (in_array($user->id, $current_user->getFollowing())) { $this->data['profile']['following'] = 1; } else { $this->data['profile']['following'] = 0; } }
function generateData() { global $current_user; // мини блок с меню пользователя и его инфо // если страница user/id и это не наша страница - рисуем чужого пользователя if (Request::$pageName == 'user') { $id = Request::get(0, false); } else { $id = $current_user->id; } if ($id && $id == $current_user->id) { $user = $current_user; } else { if ($id) { $user = Users::getById($id); } } if (!$id) { return false; } /* @var $user User */ $this->data['profile']['id'] = $user->id; $this->data['profile']['nickname'] = $user->getProperty('nickname'); $this->data['profile']['rolename'] = $user->getRoleName(); $this->data['profile']['picture'] = $user->getProperty('picture') ? $user->id . '.jpg' : 'default.jpg'; }
function BasePage() { @session_start(); if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) { foreach ($_GET as $k => $v) { $_GET[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v); } foreach ($_POST as $k => $v) { $_POST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v); } foreach ($_REQUEST as $k => $v) { $_REQUEST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v); } foreach ($_COOKIE as $k => $v) { $_COOKIE[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v); } } // set site variable $s = new Sites(); $this->site = $s->get(); $this->smarty = new Smarty(); $this->smarty->template_dir = WWW_DIR . 'views/templates/' . $this->template_dir; $this->smarty->compile_dir = SMARTY_DIR . 'templates_c/'; $this->smarty->config_dir = SMARTY_DIR . 'configs/'; $this->smarty->cache_dir = SMARTY_DIR . 'cache/'; $this->smarty->error_reporting = E_ALL - E_NOTICE; $this->smarty->assign('site', $this->site); $this->smarty->assign('page', $this); if (isset($_SERVER["SERVER_NAME"])) { $this->serverurl = (isset($_SERVER["HTTPS"]) ? "https://" : "http://") . $_SERVER["SERVER_NAME"] . ($_SERVER["SERVER_PORT"] != "80" ? ":" . $_SERVER["SERVER_PORT"] : "") . WWW_TOP . '/'; $this->smarty->assign('serverroot', $this->serverurl); } $this->page = isset($_GET['page']) ? $_GET['page'] : 'content'; $users = new Users(); if ($users->isLoggedIn()) { $this->userdata = $users->getById($users->currentUserId()); $this->userdata["categoryexclusions"] = $users->getCategoryExclusion($users->currentUserId()); //update lastlogin every 15 mins if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) { $users->updateSiteAccessed($this->userdata['ID']); } $this->smarty->assign('userdata', $this->userdata); $this->smarty->assign('loggedin', "true"); $sab = new SABnzbd($this); if ($sab->integrated !== false && $sab->url != '' && $sab->apikey != '') { $this->smarty->assign('sabintegrated', $sab->integrated); $this->smarty->assign('sabapikeytype', $sab->apikeytype); } if ($this->userdata["role"] == Users::ROLE_ADMIN) { $this->smarty->assign('isadmin', "true"); } $this->floodCheck(true, $this->userdata["role"]); } else { $this->smarty->assign('isadmin', "false"); $this->smarty->assign('loggedin', "false"); $this->floodCheck(false, ""); } }
public function defaultAction() { $users = new Users(); $account = $users->getById(Auth::getUserId()); if ($account === false) { $this->doesNotExist(); return; } $this->view->assign('account', $account); }
public static function notifyNewInbox($user_ids, $id_sender) { global $current_user; $sender = Users::getById($id_sender); /* @var $sender User */ $subject = 'Новое письмо!'; if (isset($user_ids[$current_user->id])) { unset($user_ids[$current_user->id]); } /* @var $book Book */ $message = 'Новое личное сообщение от пользователя <a href="' . Config::need('www_path') . '/user/' . $sender->id . '">' . $sender->getNickName() . '</a>'; self::send($user_ids, $subject, $message, UserNotify::UN_NEW_MESSAGE, $only_email = true); }
function set() { global $current_user; $this->data['success'] = 1; if (!$current_user->authorized) { $this->error('Auth'); return; } /* @var $current_user User */ $id_user = false; if (isset($_POST['id_user'])) { if (!$current_user->can('ocr_edit')) { $this->error('You must be biber to do that'); return; } else { $id_user = (int) $_POST['id_user']; } } $_POST['status'] = isset($_POST['status']) ? $_POST['status'] : -1; $_POST['state'] = isset($_POST['state']) ? $_POST['state'] : -1; $id_user = $id_user ? $id_user : $current_user->id; $id_book = max(0, (int) $_POST['id_book']); if (!is_numeric($_POST['status'])) { foreach (Ocr::$statuses as $s) { if ($s['name'] == $_POST['status']) { $_POST['status'] = $s['id']; } } } if (!is_numeric($_POST['state'])) { foreach (Ocr::$states as $s) { if ($s['name'] == $_POST['state']) { $_POST['state'] = $s['id']; } } } $user = Users::getById($id_user); /*@var $user User*/ $user->load(); $status = max(-1, (int) $_POST['status']); $state = max(-1, (int) $_POST['state']); try { Ocr::setStatus($id_user, $id_book, $status, $state); } catch (Exception $e) { $this->error($e->getMessage()); } if ($state == Ocr::STATE_APPROVED) { $user->gainActionPoints('ocr_add', $id_book, BiberLog::TargetType_book); } }
public static function setStatus($id_user, $id_book, $status, $state) { global $current_user; $book = Books::getInstance()->getByIdLoaded($id_book); /* @var $book Book */ if ($book->getQuality() >= BOOK::BOOK_QUALITY_BEST) { throw new Exception('book quality is best, you cant fix states'); } if (!isset(self::$statuses[$status])) { throw new Exception('no status #' . $status); } if (!isset(self::$states[$state])) { throw new Exception('no status #' . $state); } $can_comment = false; if ($state > 0) { $query = 'SELECT `time` FROM `ocr` WHERE `id_book`=' . $id_book . ' AND `id_user`=' . $id_user . ' AND `status`=' . $status . ' AND `state`=' . $state; $last_time = Database::sql2single($query); if (time() - $last_time > 24 * 60 * 60) { $can_comment = true; } } if ($state == 0 && $status !== 0) { // delete $query = 'DELETE FROM `ocr` WHERE `id_book`=' . $id_book . ' AND `id_user`=' . $id_user . ' AND `status`=' . $status . ''; } else { // upsert $query = 'INSERT INTO `ocr` SET `id_book`=' . $id_book . ', `id_user`=' . $id_user . ', `status`=' . $status . ',`state`=' . $state . ',`time`=' . time() . ' ON DUPLICATE KEY UPDATE `time`=' . time() . ', `state`=' . $state; } if (!Database::query($query, false)) { throw new Exception('Duplicating #book ' . $id_book . ' #status' . $status . ' #state' . $state); } if ($state == 0) { $comment = 'User ' . $current_user->id . ' drop status ' . $status . ' state ' . $state . ' user_id ' . $id_user; } else { $comment = 'User ' . $current_user->id . ' set status ' . $status . ' state ' . $state . ' user_id ' . $id_user; } $comUser = Users::getById($id_user); /* @var $comUser User */ if ($can_comment && ($part = self::getMessagePart($status, $state))) { $comment = mb_strtolower($part, 'UTF-8') . ' книгу'; MongoDatabase::addSimpleComment(BiberLog::TargetType_book, $id_book, $id_user, $comment); } }
function generateProfile() { global $current_user; /* @var $current_user CurrentUser */ /* @var $user User */ $user = $current_user->id === $this->id ? $current_user : Users::getById($this->id); $this->data['profile'] = $user->getXMLInfo(); $this->data['profile']['role'] = $user->getRole(); $this->data['profile']['lang'] = $user->getLanguage(); $this->data['profile']['city_id'] = $user->getProperty('city_id'); $this->data['profile']['city'] = Database::sql2single('SELECT `name` FROM `lib_city` WHERE `id`=' . $user->getProperty('city_id')); $this->data['profile']['picture'] = $user->getProperty('picture') ? $user->id . '.jpg' : 'default.jpg'; $this->data['profile']['rolename'] = $user->getRoleName(); $this->data['profile']['bday'] = $user->getBday(date('d-m-Y'), 'd-m-Y'); $this->data['profile']['bdays'] = $user->getBday('неизвестно', 'd.m.Y'); // additional $this->data['profile']['link_fb'] = $user->getPropertySerialized('link_fb'); $this->data['profile']['link_vk'] = $user->getPropertySerialized('link_vk'); $this->data['profile']['link_tw'] = $user->getPropertySerialized('link_tw'); $this->data['profile']['link_lj'] = $user->getPropertySerialized('link_lj'); }
function removeFriend() { $id = max(0, (int) $_POST['id']); $current_user = new CurrentUser(); if ($current_user->authorized) { if ($current_user->id != $id) { $user_following = $current_user->getFollowing(); $friend = Users::getById($id); /* @var $friend User */ $friend_followers = $friend->getFollowers(); if (isset($user_following[$id])) { unset($user_following[$id]); } if (isset($friend_followers[$current_user->id])) { unset($friend_followers[$current_user->id]); } $current_user->setFollowing($user_following); $friend->setFollowers($friend_followers); $friend->save(); $current_user->save(); } } }
} function update($bind, $where = NULL) { return $this->_db->update($this->_table, $bind, $where); } function delete($where = NULL) { return $this->_db->delete($this->_table, $where); } function getTableName() { return $this->_table; } } class Users extends Table { // 针对于Users表的操作 function getById($id) { $sql = 'SELECT * FROM ' . $this->_table . ' WHERE id=' . $id; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); return $row; } } $bind = array('username' => 'Rose', 'password' => 'ben', 'age' => 29, 'sex' => 1); $db = new Mysql('localhost', 'root', 'root', 'test'); $users = new Users($db); //$users->insert ( $bind ); print_r($users->getById(152));
function getProfile($edit = false) { global $current_user; /* @var $current_user CurrentUser */ /* @var $user User */ $user = $current_user->id === $this->id ? $current_user : Users::getById($this->id); if ($edit && $user->id != $current_user->id) { $current_user->can_throw('users_edit', $user); } if ($edit) { foreach (Users::$rolenames as $id => $role) { $this->data['roles'][] = array('id' => $id, 'title' => $role); } } try { $user->load(); } catch (Exception $e) { throw new Exception('Пользователя не существует'); } if ($user->loaded) { } else { return; } $this->data['profile'] = $user->getXMLInfo(); $this->data['profile']['role'] = $user->getRole(); $this->data['profile']['lang'] = $user->getLanguage(); $this->data['profile']['city_id'] = $user->getProperty('city_id'); $this->data['profile']['picture'] = $user->getAvatar(); $this->data['profile']['rolename'] = $user->getRoleName(); $this->data['profile']['bday'] = $user->getBday(date('d-m-Y'), 'd-m-Y'); $this->data['profile']['path'] = $user->getUrl(); $this->data['profile']['path_edit'] = $user->getUrl() . '/edit'; $this->data['profile']['bdays'] = $user->getBday('неизвестно', 'd.m.Y'); // additional $this->data['profile']['link_fb'] = $user->getPropertySerialized('link_fb'); $this->data['profile']['link_vk'] = $user->getPropertySerialized('link_vk'); $this->data['profile']['link_tw'] = $user->getPropertySerialized('link_tw'); $this->data['profile']['link_lj'] = $user->getPropertySerialized('link_lj'); $this->data['profile']['quote'] = $user->getPropertySerialized('quote'); $this->data['profile']['about'] = $user->getPropertySerialized('about'); $this->data['profile']['change_nickname'] = $user->checkNickChanging(); // $this->data['profile']['path_message'] = Config::need('www_path').'/me/messages?to='.$user->id; $this->data['profile']['path_message'] = Config::need('www_path') . '/user/' . $user->getNickName() . '/contact'; $this->data['profile']['path_edit_notifications'] = Config::need('www_path') . '/user/me/edit_notifications'; $this->data['profile']['path_stat'] = Config::need('www_path') . '/admin/users/stat/' . $user->id; }
function getListData() { $user = Users::getById($this->data['user_id']); $out = array('id' => $this->id, 'title' => $this->getTitle(), 'anons' => $this->getAnons(), 'path' => $this->getUrl(), 'comment_count' => $this->getCommentCount(), 'image' => $this->getImage(), 'path' => Config::need('www_path') . '/blog/' . $user->data['nick'] . '/' . $this->id, 'path_edit' => Config::need('www_path') . '/blog/' . $user->data['nick'] . '/' . $this->id . '/edit'); return $out; }
function getProfile($edit = false) { global $current_user; /* @var $current_user CurrentUser */ /* @var $user User */ $user = $current_user->id === $this->id ? $current_user : Users::getById($this->id); if ($edit && $user->id != $current_user->id) { Error::CheckThrowAuth(User::ROLE_SITE_ADMIN); } if ($edit) { foreach (Users::$rolenames as $id => $role) { $this->data['roles'][] = array('id' => $id, 'title' => $role); } } $this->data['profile'] = $user->getXMLInfo(); $this->data['profile']['role'] = $user->getRole(); $this->data['profile']['nickname'] = $user->getNickName(); $this->data['profile']['lang'] = $user->getLanguage(); $this->data['profile']['city_id'] = $user->getProperty('city_id'); $this->data['profile']['city'] = Database::sql2single('SELECT `name` FROM `lib_city` WHERE `id`=' . (int) $user->getProperty('city_id')); $this->data['profile']['picture'] = $user->getAvatar(); $this->data['profile']['rolename'] = $user->getRoleName(); $this->data['profile']['bday'] = $user->getBday(date('d-m-Y'), 'd-m-Y'); $this->data['profile']['path'] = $user->getUrl(); $this->data['profile']['path_edit'] = $user->getUrl() . '/edit'; $this->data['profile']['bdays'] = $user->getBday('неизвестно', 'd.m.Y'); // additional $this->data['profile']['link_fb'] = $user->getPropertySerialized('link_fb'); $this->data['profile']['link_vk'] = $user->getPropertySerialized('link_vk'); $this->data['profile']['link_tw'] = $user->getPropertySerialized('link_tw'); $this->data['profile']['link_lj'] = $user->getPropertySerialized('link_lj'); $this->data['profile']['quote'] = $user->getPropertySerialized('quote'); $this->data['profile']['about'] = $user->getPropertySerialized('about'); // $this->data['profile']['path_message'] = Config::need('www_path').'/me/messages?to='.$user->id; $this->data['profile']['path_message'] = Config::need('www_path') . '/user/' . $user->getNickName() . '/contact'; }
function getProfile($edit = false) { global $current_user; /* @var $current_user CurrentUser */ /* @var $user User */ $user = $current_user->id === $this->id ? $current_user : Users::getById($this->id); if ($edit && $user->id != $current_user->id) { $current_user->can_throw('users_edit', $user); } foreach (Users::$rolenames as $id => $role) { $this->data['roles'][] = array('id' => $id, 'title' => $role); } try { $user->load(); } catch (Exception $e) { throw new Exception('Пользователя не существует'); } if ($user->loaded) { } else { return; } $this->data['user'] = $user->getListData(); /* Если 1. У юзера нет друзей / фоловеров 2. Не добавил ни одной книжки 3. Не добавил в любимые ни одного объекта */ $this->data['user']['role'] = $user->getRole(); $this->data['user']['id_city'] = $user->getProperty('id_city'); $this->data['user']['city'] = Database::sql2single('SELECT `name` FROM `lib_city` WHERE `id`=' . (int) $user->getProperty('id_city')); $this->data['user']['id_country'] = $user->getProperty('id_country'); $this->data['user']['country'] = Database::sql2single('SELECT `name` FROM `lib_country` WHERE `id`=' . (int) $user->getProperty('id_country')); $this->data['user']['id_region'] = $user->getProperty('id_region'); $this->data['user']['region'] = Database::sql2single('SELECT `name` FROM `lib_region` WHERE `id`=' . (int) $user->getProperty('id_region')); $this->data['user']['id_street'] = $user->getProperty('id_street'); $this->data['user']['street'] = Database::sql2single('SELECT `name` FROM `lib_street` WHERE `id`=' . (int) $user->getProperty('id_street')); $this->data['user']['picture'] = $user->getAvatar(); $this->data['user']['rolename'] = $user->getRoleName(); $bdayunix = max(0, strtotime($user->getBday())); if (!$edit) { $this->data['user']['bday'] = date('d M Y г.', $bdayunix); $en = array('/JAN/isU', '/FEB/isU', '/MAR/isU', '/APR/isU', '/MAY/isU', '/JUN/isU', '/JUL/isU', '/AUG/isU', '/SEP/isU', '/OCT/isU', '/NOV/isU', '/DEC/isU'); $ru = array('января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'); $this->data['user']['bday'] = preg_replace($en, $ru, $this->data['user']['bday']); } else { $this->data['user']['bday'] = date('Y-d-m', $bdayunix); } $this->data['user']['path'] = $user->getUrl(); $this->data['user']['path_edit'] = $user->getUrl() . '/edit'; // additional }
public function push($walls_disabled = array()) { global $current_user; if (!$this->canPushed) { return; } $eventId = false; // ревью обновляем if ($this->data['type'] == self::EVENT_BOOKS_REVIEW_ADD || $this->data['type'] == self::EVENT_BOOKS_RATE_ADD) { // ищем старую $eventId = MongoDatabase::findReviewEvent($current_user->id, $this->data['bid']); if ($eventId) { // есть старая? нужно удалить запись на стене со ссылкой на старую запись со всех стен MongoDatabase::deleteWallItemsByEventId($eventId); MongoDatabase::updateEvent($eventId, $this->data); } } // а если был такой эвент недавно, с тем же типом // то обновляем эфент, добавляя туда объекты if (in_array($this->data['type'], self::$eventsMultTypes)) { // находим эвент с таким типом $additionalCriteria = array(); if ($this->data['type'] == self::EVENT_BOOKS_ADD_SHELF) { $additionalCriteria['shelf_id'] = $this->data['shelf_id']; } list($eventId, $data) = MongoDatabase::findLastEventByType($this->data['user_id'], $this->data['type'], $additionalCriteria); if ($eventId) { // нашли эвент! $old_time = isset($data['time']) ? $data['time'] : time(); foreach ($this->data as $field => $value) { if (!isset($data[$field])) { $data[$field] = $value; } if (is_array($value)) { foreach ($value as $val) { if (is_array($data[$field])) { $data[$field][$val] = $val; } } } } $data['time'] = $old_time; MongoDatabase::deleteWallItemsByEventId($eventId); MongoDatabase::updateEvent($eventId, $data); } } $eventDbId = 0; if (!$eventId) { $eventId = MongoDatabase::addEvent($this->data); $query = 'INSERT INTO `events` SET `mongoid`=' . Database::escape($eventId); Database::query($query, false); $eventDbId = Database::lastInsertId(); if (!$eventDbId) { throw new Exception('cant push event id to database'); } } if ($eventId) { $user = Users::getById($this->data['user_id']); /* @var $user User */ $followerIds = $user->getFollowers(); $followerIds[$user->id] = $user->id; foreach ($walls_disabled as $id) { if (isset($followerIds[$id])) { unset($followerIds[$id]); } } MongoDatabase::pushEvents($this->data['user_id'], $followerIds, $eventId, $this->data['time']); } return $eventDbId; }
public function getUserName($id, $fallback) { $username = ''; if ($id !== null) { $users = new Users(); $user = $users->getById($id); if ($user !== false) { $username = $user['screenname']; } else { $username = $fallback; } } $username = trim($username); if ($username != '') { return $username; } else { return Translate::get('Unknown'); } }
public function getUser() { return Users::getById($this->getPlayedGame()->users_id); }
/** * sendRequest() * @return array */ protected function sendRequest($path, $params = array()) { $user = new Users(); $data = $user->getById($user->currentUserId()); $url = sprintf('%s/api', $data['nzbvortex_server_url']); $params = http_build_query($params); $ch = curl_init(sprintf("%s/%s?%s", $url, $path, $params)); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); #curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); #curl_setopt($ch, CURLOPT_PROXY, 'localhost:8888'); $response = curl_exec($ch); $response = json_decode($response, true); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); curl_close($ch); switch ($status) { case 0: throw new Exception(sprintf('Unable to connect. Is NZBVortex running? Is your API key correct? Is something blocking ports? (Err: %s)', $error)); break; case 200: return $response; break; case 403: throw new Exception('Unable to login. Is your API key correct?'); break; default: throw new Exception(sprintf("%s (%s): %s", $path, $status, $response['result'])); break; } }
/** * Set up session / smarty / user variables. */ public function __construct() { $this->https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false; session_set_cookie_params(0, '/', '', $this->https, true); @session_start(); if (NN_FLOOD_CHECK) { $this->floodCheck(); } if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) { $this->stripSlashes($_GET); $this->stripSlashes($_POST); $this->stripSlashes($_REQUEST); $this->stripSlashes($_COOKIE); } // Buffer settings/DB connection. $this->settings = new Settings(); $this->smarty = new Smarty(); $this->smarty->setTemplateDir(['user_frontend' => NN_WWW . 'templates/' . $this->settings->getSetting('style') . '/views/frontend', 'frontend' => NN_WWW . 'templates/default/views/frontend']); $this->smarty->setCompileDir(SMARTY_DIR . 'templates_c' . DIRECTORY_SEPARATOR); $this->smarty->setConfigDir(SMARTY_DIR . 'configs' . DIRECTORY_SEPARATOR); $this->smarty->setCacheDir(SMARTY_DIR . 'cache' . DIRECTORY_SEPARATOR); $this->smarty->error_reporting = NN_DEBUG ? E_ALL : E_ALL - E_NOTICE; $this->secure_connection = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443; if (isset($_SERVER['SERVER_NAME'])) { $this->serverurl = ($this->https === true ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443' ? ':' . $_SERVER['SERVER_PORT'] : '') . WWW_TOP . '/'; $this->smarty->assign('serverroot', $this->serverurl); } $this->page = isset($_GET['page']) ? $_GET['page'] : 'content'; $this->users = new Users(['Settings' => $this->settings]); if ($this->users->isLoggedIn()) { $this->userdata = $this->users->getById($this->users->currentUserId()); $this->userdata["categoryexclusions"] = $this->users->getCategoryExclusion($this->users->currentUserId()); // Change the theme to user's selected theme if they selected one, else use the admin one. if ($this->settings->getSetting('userselstyle') == 1) { if (isset($this->userdata['style']) && $this->userdata['style'] !== 'None') { $this->smarty->setTemplateDir(['user_frontend' => NN_WWW . 'templates/' . $this->userdata['style'] . '/views/frontend', 'frontend' => NN_WWW . 'templates/default/views/frontend']); } } //update lastlogin every 15 mins if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) { $this->users->updateSiteAccessed($this->userdata['id']); } $this->smarty->assign('userdata', $this->userdata); $this->smarty->assign('loggedin', "true"); if ($this->userdata['nzbvortex_api_key'] != '' && $this->userdata['nzbvortex_server_url'] != '') { $this->smarty->assign('weHasVortex', true); } else { $this->smarty->assign('weHasVortex', false); } $sab = new SABnzbd($this); $this->smarty->assign('sabintegrated', $sab->integratedBool); if ($sab->integratedBool !== false && $sab->url != '' && $sab->apikey != '') { $this->smarty->assign('sabapikeytype', $sab->apikeytype); } switch ((int) $this->userdata['role']) { case Users::ROLE_ADMIN: $this->smarty->assign('isadmin', 'true'); break; case Users::ROLE_MODERATOR: $this->smarty->assign('ismod', 'true'); } if ($this->userdata["hideads"] == "1") { $this->settings->setSetting(['adheader', '']); $this->settings->setSetting(['adbrowse', '']); $this->settings->setSetting(['addetail', '']); } $this->floodCheck($this->userdata["role"]); } else { $this->smarty->assign('isadmin', 'false'); $this->smarty->assign('ismod', 'false'); $this->smarty->assign('loggedin', 'false'); $this->floodCheck(); } $this->smarty->assign('site', $this->settings); $this->smarty->assign('page', $this); }
public function userName($id) { $usersModel = new Users(); $user = $usersModel->getById($id); return $user->name; }
function getShelves() { global $current_user; /* @var $current_user CurrentUser */ /* @var $user User */ $user = ($current_user->id === $this->id) ? $current_user : Users::getById($this->id); $bookShelf = $user->getBookShelf(); foreach ($bookShelf as $shelf => &$books) uasort($books, 'sort_by_add_time'); $bookIds = array(); foreach ($bookShelf as $shelf => $ids) { foreach ($ids as $bookId => $data) $bookIds[$bookId] = $bookId; } // все эти книжки нужно подгрузить Books::getByIdsLoaded($bookIds); Books::LoadBookPersons($bookIds); $shelfcounter = array(1 => 0, 2 => 0, 3 => 0); foreach ($bookShelf as $shelf => $ids) { foreach ($ids as $bookId => $data) { $book = Books::getById($bookId); if (isset($shelfcounter[$shelf])) $shelfcounter[$shelf]++; else $shelfcounter[$shelf] = 1; if ($shelfcounter[$shelf] > 10) continue; /* @var $book Book */ list($author_id, $author_name) = $book->getAuthor(); $this->data['shelves'][$shelf]['books'][$bookId] = array( 'id' => $book->id, 'title' => $book->getTitle(true), 'cover' => $book->getCover(), 'author' => $author_name, 'author_id' => $author_id, 'add_time' => $data['add_time'] ); } } foreach (Config::$shelves as $id => $title) { $this->data['shelves'][$id]['books']['count'] = (int) $shelfcounter[$id]; $this->data['shelves'][$id]['books']['title'] = $title; $this->data['shelves'][$id]['books']['link_title'] = 'Перейти на полку «' . $title . '»'; $this->data['shelves'][$id]['books']['link_url'] = 'user/' . $this->id . '/books/' . Config::$shelfNameById[$id]; } }
$data['table'] = $table; $message = ''; $data['message'] = ''; $_id = $prefix . 'uin'; $data['_id'] = $_id; $data['list'] = array(); $objUserModule = new userModule(); /** * $field_list :: This list is the list of all fields to be used for various puropse * */ $field_list = array('uin', 'username', 'password', 'email', 'status', 'us00uin'); $obj = new Users(); $data['field_list'] = $field_list; if (isset($_GET['_Id'])) { $id = $_GET['_Id']; $data['_data'] = $obj->getById($id); } else { $data['_data'] = $obj->get($prefix . 'us00uin < ' . $objUserModule->getCurrentRight(), $_id . ' desc'); //var_dump($data); $data['list_fields'] = array('UIN' => 'uin', 'User' => 'username'); $data['lists'] = $data['list_fields']; } //var_dump($data); $data['_extraModule'] = array(array('User Module', 'userModule'), array('ResetPassword', 'resetPass')); $_data = $obj->getById($id); $upload_dir = UPLOADS_DIR . 'Organization/'; $data['upload_dir'] = $upload_dir; $data['uploadUrl'] = '../uploads/Organization/'; /* * *************** END of these fields are required *********************************** */ /** * $fields_post :: This list is the list of all fields which are affected while inserting in database
function BasePage() { @session_start(); if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) { foreach ($_GET as $k => $v) { $_GET[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v); } foreach ($_POST as $k => $v) { $_POST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v); } foreach ($_REQUEST as $k => $v) { $_REQUEST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v); } foreach ($_COOKIE as $k => $v) { $_COOKIE[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v); } } // set site variable $s = new Sites(); $this->site = $s->get(); $this->smarty = new Smarty(); if ($this->site->style != "default") { $this->smarty->addTemplateDir(WWW_DIR . 'templates/' . $this->site->style . '/views/frontend', 'style_frontend'); } $this->smarty->addTemplateDir(WWW_DIR . 'templates/default/views/frontend', 'frontend'); $this->smarty->setCompileDir(SMARTY_DIR . 'templates_c' . DIRECTORY_SEPARATOR); $this->smarty->setConfigDir(SMARTY_DIR . 'configs' . DIRECTORY_SEPARATOR); $this->smarty->setCacheDir(SMARTY_DIR . 'cache' . DIRECTORY_SEPARATOR); $this->smarty->error_reporting = E_ALL - E_NOTICE; $this->secure_connection = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443; if (file_exists(WWW_DIR . 'templates/' . $this->site->style . '/theme.php')) { require_once WWW_DIR . 'templates/' . $this->site->style . '/theme.php'; } $this->smarty->assign('themevars', isset($themevars) ? $themevars : null); $servername = null; if (defined('EXTERNAL_PROXY_IP') && defined('EXTERNAL_HOST_NAME') && isset($_SERVER["REMOTE_ADDR"]) && $_SERVER["REMOTE_ADDR"] == EXTERNAL_PROXY_IP) { $servername = EXTERNAL_HOST_NAME; } elseif (isset($_SERVER["SERVER_NAME"])) { $servername = $_SERVER["SERVER_NAME"]; } if ($servername != "") { $this->serverurl = ($this->secure_connection ? "https://" : "http://") . $servername . ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443" ? ":" . $_SERVER["SERVER_PORT"] : "") . WWW_TOP . '/'; $this->smarty->assign('serverroot', $this->serverurl); } $this->page = isset($_GET['page']) ? $_GET['page'] : 'content'; $users = new Users(); if ($users->isLoggedIn()) { $this->userdata = $users->getById($users->currentUserId()); // // user can still be logged in but have been disabled by admin, so if they are, log them off // if ($this->userdata["role"] == Users::ROLE_DISABLED) { $users->logout(); $this->show403(); } $this->userdata["categoryexclusions"] = $users->getCategoryExclusion($users->currentUserId()); //update lastlogin every 15 mins if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) { $users->updateSiteAccessed($this->userdata['ID']); } $this->smarty->assign('userdata', $this->userdata); $this->smarty->assign('loggedin', "true"); if (!empty($this->userdata['nzbvortex_api_key']) && !empty($this->userdata['nzbvortex_server_url'])) { $this->smarty->assign('weHasVortex', true); } $sab = new SABnzbd($this); if ($sab->integrated !== false && $sab->url != '' && $sab->apikey != '') { $this->smarty->assign('sabintegrated', $sab->integrated); $this->smarty->assign('sabapikeytype', $sab->apikeytype); } $nzbget = new NZBGet($this); if ($nzbget->integrated !== false && $nzbget->url != '') { $this->smarty->assign('nzbgetintegrated', $nzbget->integrated); } if ($this->userdata["role"] == Users::ROLE_ADMIN) { $this->smarty->assign('isadmin', "true"); } if ($this->userdata["hideads"] == "1") { $this->site->adheader = ""; $this->site->adbrowse = ""; $this->site->addetail = ""; } $this->floodCheck($this->userdata["role"]); } else { $this->smarty->assign('isadmin', "false"); $this->smarty->assign('loggedin', "false"); $this->floodCheck(); } $this->smarty->assign('site', $this->site); $this->smarty->assign('page', $this); }