public function logout() { $db = DB::getInstance(); $user = User::getInstance(); $db->delete('pl_api_session', 'where id=?', array($user->userid)); Forum::kickUser(); }
public function rentVideo() { $video_id = (int) $_REQUEST['video_id']; $price = $_REQUEST['price']; $user = User::getInstance(Stb::getInstance()->id); $response = array(); try { $package = $user->getPackageByVideoId($video_id); if (empty($package)) { throw new Exception(_('Server error')); } if ($price === '0') { $oss_result = true; } else { $oss_result = $user->subscribeToPackage($package['id']); } $response['result'] = $oss_result; $response['rent_duration'] = $package['rent_duration']; $response['package_id'] = $package['id']; $rent_session_id = $user->rentVideo($video_id, $price); $response['rent_info'] = Mysql::getInstance()->from('video_rent')->where(array('id' => $rent_session_id))->get()->first(); $response['rent_info']['expires_in'] = User::humanDateDiff($response['rent_info']['rent_end_date'], $response['rent_info']['rent_date']); } catch (OssDeny $e) { $response['message'] = $e->getMessage(); Stb::logOssError($e); } catch (OssException $e) { $response['message'] = _('This operation is temporarily unavailable.'); Stb::logOssError($e); } catch (Exception $e) { $response['message'] = $e->getMessage(); Stb::logOssError($e); } return $response; }
public function handleRequest() { $result = null; $response = new RESTApiResponse(); try { $request = new RESTApiRequest(); $request->init(); $response->setRequest($request); try { $access = OAuth\AuthAccessHandler::getAccessSchema($request); $access->checkRequest(); } catch (OAuth\AuthUnauthorized $access_exception) { throw new RESTUnauthorized($access_exception->getMessage()); } catch (OAuth\AuthBadRequest $access_exception) { throw new RESTBadRequest($access_exception->getMessage()); } catch (OAuth\AuthForbidden $access_exception) { throw new RESTForbidden($access_exception->getMessage()); } $session = $access->getSession(); \User::getInstance($session['uid']); $target_resolver = new RESTApiTargetResolver(); $target = $target_resolver->getTarget($request); $result = $target->execute($request); } catch (\Exception $e) { $response->setError($e); } $response->setBody($result); $response->send(); }
public function __construct() { $this->session = Session::getInstance(); $this->su = ScreenUtils::getInstance(); $this->user = User::getInstance(); $this->user->auth('*****@*****.**', 'tenant'); }
/** * Check user permissions and authentication */ public function checkAuth() { $user = User::getInstance(); $uid = false; if ($user->isAuthorized()) { $uid = $user->id; } if (!$uid) { if (Request::isAjax()) { Response::jsonError($this->_lang->MSG_AUTHORIZE); } else { $this->loginAction(); } } /* * Check CSRF token */ if ($this->_configFrontend->get('use_csrf_token') && Request::hasPost()) { $csrf = new Security_Csrf(); $csrf->setOptions(array('lifetime' => $this->_configFrontend->get('use_csrf_token_lifetime'), 'cleanupLimit' => $this->_configFrontend->get('use_csrf_token_garbage_limit'))); if (!$csrf->checkHeader() && !$csrf->checkPost()) { $this->_errorResponse($this->_lang->MSG_NEED_CSRF_TOKEN); } } $this->_user = $user; }
public function startUserSession($row) { $login_key = $_SESSION['login_key']; # Unset all session variable $_SESSION = array(); # Destroy session session_destroy(); # New session name session_name(SESS_NAME); # New session id session_id($login_key); # Start Session session_start(); $ts = new Date(); # Initialize session $_SESSION['start_ts'] = $ts->getTs(); $_SESSION['start_ts_str'] = $ts->getDate(); $_SESSION['auth_state'] = 'user'; $_SESSION['user_id'] = $row['id']; $_SESSION['login_key'] = $login_key; # Destroy old User object $this->user->__destruct(); # Initialize new User object $this->user = User::getInstance($_SESSION['user_id']); }
/** * Create new version * @property Db_Object $object * @return boolean */ public function newVersion(Db_Object $object) { $object->commitChanges(); $newVersion = $this->getLastVersion($object->getName(), $object->getId()) + 1; $newData = $object->getData(); if ($object->getConfig()->hasEncrypted()) { $ivField = $object->getConfig()->getIvField(); $ivKey = $object->get($ivField); if (empty($ivKey)) { $ivKey = Utils_String::createEncryptIv(); $newData[$ivField] = $ivKey; } $newData = $this->getStore()->encryptData($object, $newData); } $newData['id'] = $object->getId(); try { $vObject = new Db_Object('vc'); $vObject->set('date', date('Y-m-d')); $vObject->set('data', base64_encode(serialize($newData))); $vObject->set('user_id', User::getInstance()->id); $vObject->set('version', $newVersion); $vObject->set('record_id', $object->getId()); $vObject->set('object_name', $object->getName()); $vObject->set('date', date('Y-m-d H:i:s')); if ($vObject->save()) { return $newVersion; } return false; } catch (Exception $e) { $this->logError('Cannot create new version for ' . $object->getName() . '::' . $object->getId() . ' ' . $e->getMessage()); return false; } }
/** * enqueueDB * * @param string $type * @param int $id * @static * @access public * @return void */ public static function enqueueDB($type = '', $ids = array(), $action = 'index') { if ($type != '' && !empty($ids)) { $db = App::get('db'); $userID = User::getInstance()->get('uidNumber'); $timestamp = Date::of()->toSql(); if ($db->tableExists('#__search_queue') && count($ids) > 0) { $sql = "INSERT INTO #__search_queue (type, type_id, status, action, created_by, created) VALUES "; foreach ($ids as $key => $id) { if (!is_array($id)) { $sql .= "('" . $type . "'," . $id . ", 0, '" . $action . "', " . $userID . ", '{$timestamp}}'),"; } } $sql = rtrim($sql, ','); $sql .= ';'; try { $db->setQuery($sql); $db->query(); return true; } catch (\Exception $e) { //@FIXME: properly handle this error ddie($e->getMessage()); } } else { throw new \Hubzero\Exception\Exception('Queue table does not exist.'); } } }
function display($tpl = null) { $app = JFactory::getApplication(); $state = $this->get('State'); $items = $this->get('Items'); $pagination = $this->get('Pagination'); // Get the page/component configuration $params =& $state->params; foreach ($items as $item) { $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; } $form = new stdClass(); // Month Field $months = array('' => Lang::txt('COM_CONTENT_MONTH'), '01' => Lang::txt('JANUARY_SHORT'), '02' => Lang::txt('FEBRUARY_SHORT'), '03' => Lang::txt('MARCH_SHORT'), '04' => Lang::txt('APRIL_SHORT'), '05' => Lang::txt('MAY_SHORT'), '06' => Lang::txt('JUNE_SHORT'), '07' => Lang::txt('JULY_SHORT'), '08' => Lang::txt('AUGUST_SHORT'), '09' => Lang::txt('SEPTEMBER_SHORT'), '10' => Lang::txt('OCTOBER_SHORT'), '11' => Lang::txt('NOVEMBER_SHORT'), '12' => Lang::txt('DECEMBER_SHORT')); $form->monthField = Html::select('genericlist', $months, 'month', array('list.attr' => 'size="1" class="inputbox"', 'list.select' => $state->get('filter.month'), 'option.key' => null)); // Year Field $years = array(); $years[] = Html::select('option', null, Lang::txt('JYEAR')); for ($i = 2000; $i <= 2020; $i++) { $years[] = Html::select('option', $i, $i); } $form->yearField = Html::select('genericlist', $years, 'year', array('list.attr' => 'size="1" class="inputbox"', 'list.select' => $state->get('filter.year'))); $form->limitField = $pagination->getLimitBox(); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->filter = $state->get('list.filter'); $this->assignRef('form', $form); $this->assignRef('items', $items); $this->assignRef('params', $params); $this->assignRef('user', User::getInstance()); $this->assignRef('pagination', $pagination); $this->_prepareDocument(); parent::display($tpl); }
public function logout() { $u = User::getInstance(); $wrapper = Wrapper::getInstance(); $this->set('data', $wrapper->user($u)); $this->ApiSession->logout(); }
public function __construct() { $this->session = Session::getInstance(); $this->user = User::getInstance(); $this->user->auth('*****@*****.**', 'tenant'); $this->vu = VoteUtils::getInstance(); }
public function beforeFilter() { parent::beforeFilter(); App::import("vendor", array("model/board", "inc/pagination")); if (!isset($this->params['name'])) { $this->error(ECode::$BOARD_NONE); } try { $boardName = $this->params['name']; if (preg_match("/^\\d+\$/", $boardName)) { throw new BoardNullException(); } $this->_board = Board::getInstance($boardName); if ($this->_board->isDir()) { throw new BoardNullException(); } } catch (BoardNullException $e) { $this->error(ECode::$BOARD_UNKNOW); } if (isset($this->params['url']['mode'])) { $mode = (int) trim($this->params['url']['mode']); $this->_board->setMode($mode); } if (!$this->_board->hasReadPerm(User::getInstance())) { $this->error(ECode::$BOARD_NOPERM); } $this->_board->setOnBoard(); }
public function __construct() { $this->session = Session::getInstance(); $this->user = User::getInstance(); $this->webDBUtils = WebDBUtils::getInstance(); $this->log = Log::getInstance(); }
public function get(RESTApiRequest $request, $id) { $info = new \AccountInfo(); $user_info = $info->getMainInfo(); $user_info['id'] = \User::getInstance()->getId(); return $this->filterDocument($user_info); }
function display($tpl = null) { $user = User::getRoot(); // If this is an auth_link account update, carry on, otherwise raise an error if (!is_object($user) || !array_key_exists('auth_link_id', $user) || !is_numeric($user->get('username')) || !$user->get('username') < 0) { App::abort('405', 'Method not allowed'); return; } // Get and add the js and extra css to the page \Hubzero\Document\Assets::addComponentStylesheet('com_users', 'link.css'); \Hubzero\Document\Assets::addComponentStylesheet('com_users', 'providers.css'); \Hubzero\Document\Assets::addComponentScript('com_users', 'link'); // Import a few things jimport('joomla.user.helper'); // Look up a few things $hzal = \Hubzero\Auth\Link::find_by_id($user->get("auth_link_id")); $hzad = \Hubzero\Auth\Domain::find_by_id($hzal->auth_domain_id); $plugins = Plugin::byType('authentication'); // Get the display name for the current plugin being used Plugin::import('authentication', $hzad->authenticator); $plugin = Plugin::byType('authentication', $hzad->authenticator); $pparams = new \Hubzero\Config\Registry($plugin->params); $refl = new ReflectionClass("plgAuthentication{$plugin->name}"); $display_name = $pparams->get('display_name', $refl->hasMethod('onGetLinkDescription') ? $refl->getMethod('onGetLinkDescription')->invoke(NULL) : ucfirst($plugin->name)); // Look for conflicts - first check in the hub accounts $profile_conflicts = \Hubzero\User\Profile\Helper::find_by_email($hzal->email); // Now check the auth_link table $link_conflicts = \Hubzero\Auth\Link::find_by_email($hzal->email, array($hzad->id)); $conflict = array(); if ($profile_conflicts) { foreach ($profile_conflicts as $p) { $user_id = JUserHelper::getUserId($p); $juser = User::getInstance($user_id); $auth_link = \Hubzero\Auth\Link::find_by_user_id($juser->id); $dname = is_object($auth_link) && $auth_link->auth_domain_name ? $auth_link->auth_domain_name : 'hubzero'; $conflict[] = array("auth_domain_name" => $dname, "name" => $juser->name, "email" => $juser->email); } } if ($link_conflicts) { foreach ($link_conflicts as $l) { $juser = User::getInstance($l['user_id']); $conflict[] = array("auth_domain_name" => $l['auth_domain_name'], "name" => $juser->name, "email" => $l['email']); } } // Make sure we don't somehow have any duplicate conflicts $conflict = array_map("unserialize", array_unique(array_map("serialize", $conflict))); // @TODO: Could also check for high probability of name matches??? // Get the site name $sitename = Config::get('sitename'); // Assign variables to the view $this->assign('hzal', $hzal); $this->assign('hzad', $hzad); $this->assign('plugins', $plugins); $this->assign('display_name', $display_name); $this->assign('conflict', $conflict); $this->assign('sitename', $sitename); $this->assignref('juser', $user); parent::display($tpl); }
/** * stats_admin_filter_menu * * adds the stats menu item * * @param array $menu_items * @param string $url * @return array */ function stats_admin_filter_menu($menu_items, $url) { $User = User::getInstance(); if ($User->hasPerm('st')) { $menu_items['stats_plugin'] = array('name' => 'Stats', 'url' => $url); } return $menu_items; }
public function perform(IHttpContext $context, $params = null) { $request = $context->getRequest(); if (($username = $request->get('post', 'login')) && ($password = $request->get('post', 'password'))) { $user = User::getInstance(); return $user->authenticate($username, $password); } }
public function __construct() { $this->session = Session::getInstance(); $this->webDBUtils = WebDBUtils::getInstance(); $this->roleUtils = RoleUtils::getInstance(); $this->user = User::getInstance(); $this->pwUtils = PWUtils::getInstance(); }
public function __construct() { $this->session = Session::getInstance(); $this->user = User::getInstance(); $this->user->auth('*****@*****.**', 'tenant'); $this->playlistUtils = PlaylistUtils::getInstance(); $this->webDBUtils = WebDBUtils::getInstance(); }
public function listRecCommentsByRadioAndTypeId() { $user = User::getInstance(); $tid = KommentariUtils::TYPE_REC; $rid = $user->getRadioId(); $res = $this->webDBUtils->getCommentsByRadioAndTypeId($rid, $tid); return $res; }
public function Send($users, $data = false, $templatetype = false, $subject = false, $message = false) { $nt = NotifyTemplate::getInstance(); //$ntdata = $nt->FetchData($templateid); $us = UserSettings::getInstance(); $setting = Settings::getInstance(); $nm = NotificationModule::getInstance(); $user = User::getInstance(); $lang = Lang::getInstance(); for ($i = 0; $i < count($users); $i++) { $usersettings = $us->Get($users[$i]['id']); if (@$usersettings[$templatetype] != "0") { if (is_numeric($usersettings['language'])) { $langdata = $lang->FetchData($usersettings['language']); $langcode = $langdata['code']; } else { $langcode = $setting->Get('system.lang.default'); } if (strlen($langcode) != 2) { throw new Exception("Lang code not found or in wrong format"); } if (is_array($data) && $templatetype != '' && $templatetype != false) { if (!is_numeric($templateid = $nt->GetID($templatetype, 'type', "`langcode` = '" . $langcode . "'")) && !is_numeric($templateid = $nt->GetID($templatetype, 'type', "`langcode` = 'en'"))) { throw new Exception("Notify Template not found with type " . $templatetype . " and language " . $langcode); } $ntdata = $nt->FetchData($templateid); if (!is_array($ntdata)) { continue; } $message = $this->prepare_template($ntdata['text'], $data); } elseif (is_string($subject) && is_string($message)) { $ntdata['subject'] = $subject; } else { throw new Exception("Wrong parameters specified"); } if (is_numeric($usersettings['notifymodule']) && is_string($usersettings['notifyaddress'])) { $moduleid = $usersettings['notifymodule']; $address = $usersettings['notifyaddress']; } else { $userdata = $user->FetchData($users[$i]['id']); $moduleid = $setting->Get('system.notifymodule.default'); $address = $userdata['email']; } if (strlen($address) < 2 || !is_numeric($moduleid)) { continue; } if ($nm->Send($moduleid, $address, $ntdata['subject'], $message)) { $status = 'Done'; } else { $status = 'Fail'; } $this->Create(array('userid' => $users[$i]['id'], 'moduleid' => $moduleid, 'subject' => $ntdata['subject'], 'text' => $message, 'address' => $address, 'status' => $status)); } else { return true; } } return true; }
public function wGetTime() { $u = User::getInstance(); $file = $u->getHome('favboard'); if (!file_exists($file)) { return time(); } return filemtime($file); }
public function __construct() { require_once 'src/Loader.php'; $this->_loader = new Loader(); $this->_request = new Request(); $this->config = (require_once self::WEBROOT . "/config/config.php"); $this->_renderer = new Renderer($this->_request); $this->_user = User::getInstance(); }
/** * Инициализировать файлохранилище * @return Filestorage_Abstract */ public function getStorage() { $configMain = Registry::get('main', 'config'); $storageConfig = Config::factory(Config::File_Array, $configMain->get('configs') . '/filestorage.php'); $storageConfig->set('user_id', User::getInstance()->id); $fileStorage = Filestorage::factory($storageConfig->get('adapter'), $storageConfig); $fileStorage->setLog($this->getLogsAdapter()); return $fileStorage; }
public function index() { $this->css[] = "xwidget.css"; $this->notice = array(array("url" => Configure::read("site.notice.url"), "text" => Configure::read("site.notice.text"))); App::import('Sanitize'); App::import('vendor', 'model/widget'); $u = User::getInstance(); $ret = $w = array(); $ret = Widget::wGet($u); if (empty($ret)) { $this->set("widget", array()); return; } $persistent = Configure::read("widget.persistent"); if ($persistent) { $time = (array) nforum_cache_read("widget_time"); $update = false; } $w = array_fill(1, $u->getCustom("userdefine1", 31) == 1 ? 3 : 2, array()); foreach ($ret as $v) { $w[$v['col']][$v['row']] = $v; if ($persistent) { try { $ww = Widget::getInstance($v['name']); if (!$ww->wHasPerm(User::getInstance())) { $ww = new EWidget('你无权访问此应用'); $html = Widget::html($ww->wGetList()); } else { if (strpos($v['name'], "favor-") === 0) { $html = Widget::html($ww->wGetList()); } else { if (!isset($time[$v['name']]) || $time[$v['name']] < $ww->wGetTime() || false === ($html = nforum_cache_read("widget_" . $v['name']))) { $time[$v['name']] = $ww->wGetTime(); $html = Widget::html($ww->wGetList()); nforum_cache_write("widget_" . $v['name'], $html); $update = true; } } } } catch (WidgetNullException $e) { $ww = new EWidget(); //if persistent,it will not check wiget time and will not update widget_time. $html = Widget::html($ww->wGetList()); } $w[$v['col']][$v['row']]['content'] = $html; } } if ($persistent && $update) { nforum_cache_write("widget_time", $time); } foreach ($w as &$v) { ksort($v); } $this->set("widget", $w); $this->jsr[] = 'SYS.widget.persistent=' . ($persistent ? 'true' : 'false'); $this->jsr[] = "xWidget.init(SESSION.get('is_login'), SESSION.get('id'))"; }
public function delete(RESTApiRequest $request, $video_id) { if (empty($this->params['users.id'])) { throw new RESTBadRequest("User required"); } $user_id = $this->params['users.id']; $user = \User::getInstance($user_id); return $user->setEndedVideo($video_id); }
/** * Main handler. Does all the checks * * @param void * @return void */ public function audit() { /* If no user, some checks may be skipped... */ // Get user $jUser = User::getInstance(); // User specific checks if (!$jUser->get('guest')) { if ($sId = $this->getSku()) { // Check if the current user reached the max count of downloads for this SKU $sku = Sku::getInstance($sId); $skuDownloadLimit = $sku->getMeta('downloadLimit'); if ($skuDownloadLimit > 0) { // Get SKU download count $skuDownloadCount = CartDownload::countUserSkuDownloads($this->sId, $this->uId); // Check if the limit is reached if ($skuDownloadCount >= $skuDownloadLimit) { $this->setResponseStatus('error'); $this->setResponseNotice('You have reached the maximum number of allowed downloads for this product.'); $this->setResponseError(': you have reached the maximum number of allowed downloads for this product.'); } } return $this->getResponse(); } } // Check SKU-related stuff if this is a SKU if ($sId = $this->getSku()) { // Check if SKU is reached the download max count $sku = Sku::getInstance($sId); $skuDownloadLimit = $sku->getMeta('globalDownloadLimit'); if ($skuDownloadLimit > 0) { // Get SKU download count $skuDownloadCount = CartDownload::countSkuDownloads($this->sId); // Check if the limit is reached if ($skuDownloadCount >= $skuDownloadLimit) { $this->setResponseStatus('error'); $this->setResponseNotice('This product has reached the maximum number of allowed downloads and cannot be downloaded.'); $this->setResponseError(': this product has reached the maximum number of allowed downloads and cannot be downloaded.'); } } return $this->getResponse(); } // Get product download limit $productDownloadLimit = Product::getMetaValue($this->pId, 'globalDownloadLimit'); // Get product downloads count if ($productDownloadLimit > 0) { $productDownloadCount = CartDownload::countProductDownloads($this->pId); // Check if the limit is reached if ($productDownloadCount >= $productDownloadLimit) { $this->setResponseStatus('error'); $this->setResponseNotice('This product has reached the maximum number of allowed downloads and cannot be downloaded.'); $this->setResponseError(': this product has reached the maximum number of allowed downloads and cannot be downloaded.'); } } return $this->getResponse(); }
public function __construct() { parent::__construct(); if (key_exists('logout', $_REQUEST)) { User::getInstance('office')->logout(); M_Office_Util::refresh(); } if (!User::getInstance('office')->isLoggedIn()) { $this->loginForm(User::getInstance('office')->containers['office']['table']); } }
public function ajax_list() { $f = new Friend(User::getInstance()); $friends = $f->getRecord(1, $f->getTotalNum()); $ret = array(); foreach ($friends as $v) { $ret[] = $v->userid; } $this->set('no_html_data', $ret); $this->set('no_ajax_info', true); }
public function __construct() { $this->media_ext_str = join('|', $this->media_ext_arr); if (defined('STORAGE_NAME')) { $this->storage_name = STORAGE_NAME; } else { $this->storage_name = $_SERVER['SERVER_NAME'] ? $_SERVER['SERVER_NAME'] : $_SERVER['SERVER_ADDR']; } $this->user = User::getInstance(); $this->user->setStorageName($this->storage_name); }