public function post(\Request $request) { $factory = new Factory(); $view = new \View\JsonView(array('success' => true)); $response = new \Response($view); if (!$request->isVar('command')) { throw new \Exception('Bad command'); } switch ($request->getVar('command')) { case 'add': $factory->postNew(); break; case 'deactivate': $this->deactivate($factory, filter_input(INPUT_POST, 'lotId', FILTER_SANITIZE_NUMBER_INT)); break; case 'activate': $this->activate($factory, filter_input(INPUT_POST, 'lotId', FILTER_SANITIZE_NUMBER_INT)); break; case 'delete': Factory::delete(filter_input(INPUT_POST, 'lotId', FILTER_SANITIZE_NUMBER_INT)); break; default: throw new \Exception('Bad command:' . $request->getVar('command')); } return $response; }
public function post(\Request $request) { $factory = new Factory(); $view = new \View\JsonView(array('success' => true)); if (!$request->isVar('command')) { throw new \Exception('Bad command'); } switch ($request->getVar('command')) { case 'chooseWinners': $view = $this->chooseWinners(); break; case 'complete': $factory->completeGame(); break; case 'notify': $view = $view = new \View\JsonView(array('sent' => $factory->notify())); break; case 'completeLottery': $factory->completeLottery(); break; case 'pickup': $this->postPickUp(); break; default: throw new \Exception('Bad command:' . $request->getVar('command')); } $response = new \Response($view); return $response; }
public function post(\Request $request) { $factory = new Factory(); $view = new \View\JsonView(array('success' => true)); if (!$request->isVar('command')) { throw new \Exception('Bad command'); } switch ($request->getVar('command')) { case 'add': $factory->postNew(); break; case 'updateSignupStart': $view = new \View\JsonView($this->updateSignupStart()); break; case 'updateSignupEnd': $view = new \View\JsonView($this->updateSignupEnd()); break; case 'updatePickupDeadline': $view = new \View\JsonView($this->updatePickupDeadline()); break; case 'updateKickoff': $view = new \View\JsonView($this->updateKickoff()); break; case 'complete': $this->completeGame(); break; default: throw new \Exception('Bad command:' . $request->getVar('command')); } $response = new \Response($view); return $response; }
private function saveThumbnail(\Request $request) { $latitude = $request->getVar('latitude'); $longitude = $request->getVar('longitude'); Factory::createMapThumbnail($latitude, $longitude); $json['result'] = 'true'; $response = new \View\JsonView($json); return $response; }
public function post(\Request $request) { $factory = new Factory(); $view = new \View\JsonView(array('success' => true)); if (!$request->isVar('command')) { throw new \Exception('Bad command'); } switch ($request->getVar('command')) { case 'ban': $factory->ban($request->getVar('id'), $request->getVar('reason')); break; case 'unban': $factory->unban($request->getVar('id')); break; case 'ineligible': $factory->ineligible($request->getVar('id'), $request->getVar('reason')); break; case 'eligible': $factory->eligible($request->getVar('id')); break; case 'delete': $factory->delete($request->getVar('id')); break; case 'assign': if (!$this->assign()) { $view = new \View\JsonView(array('success' => false)); } break; default: throw new \Exception('Bad command:' . $request->getVar('command')); } $response = new \Response($view); return $response; }
public function post(\Request $request) { $social_links = \contact\Factory\ContactInfo\Social::pullSavedLinks(); $label = $request->getVar('label'); $url = $request->getVar('url'); if (empty($url)) { unset($social_links[$label]); } else { $social_links[$label] = $url; } \contact\Factory\ContactInfo\Social::saveLinks($social_links); echo 'post successful'; exit; }
/** * Return data on a resource view (this will be some form of HTML) * * @param object $resource Current resource * @param string $option Name of the component * @param array $areas Active area(s) * @param string $rtrn Data to be returned * @return array */ public function onResources($model, $option, $areas, $rtrn = 'all') { if (!$model->type->params->get('plg_share')) { return; } $arr = array('area' => $this->_name, 'html' => '', 'metadata' => ''); $resource = $model->resource; $sef = Route::url('index.php?option=com_resources&' . ($resource->alias ? 'alias=' . $resource->alias : 'id=' . $resource->id)); $url = Request::base() . ltrim($sef, '/'); // Incoming action $sharewith = Request::getVar('sharewith', ''); if ($sharewith) { // Log the activity if (!User::isGuest()) { Event::trigger('system.logActivity', ['activity' => ['action' => 'shared', 'scope' => 'resource', 'scope_id' => $resource->id, 'description' => Lang::txt('PLG_RESOURCES_SHARE_ENTRY_SHARED', '<a href="' . $sef . '">' . $resource->title . '</a>', $sharewith), 'details' => array('with' => $sharewith, 'title' => $resource->title, 'url' => $sef)], 'recipients' => [['resource', $resource->id], ['user', $resource->created_by], ['user', User::get('id')]]]); } // Email form if ($sharewith == 'email') { // Instantiate a view $view = $this->view('email', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors()); // Return the output $view->display(); exit; } return $this->share($sharewith, $url, $resource); } // Build the HTML meant for the "about" tab's metadata overview if ($rtrn == 'all' || $rtrn == 'metadata') { // Instantiate a view $view = $this->view('default', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors()); // Return the output $arr['metadata'] = $view->loadTemplate(); } return $arr; }
/** Class constructor @public **/ function __construct($page, $num_results, $total_items, $limit = 0, $baseURL = null, $automakeSEF = false, $detect_formatting = true) { // bind $this->_total = $total_items; $this->_num_results = $num_results; $this->_limit = $limit; $this->_limitstart = $this->_curpage > 1 ? $this->_curpage * $limit - $limit : 0; if ($this->_limit) { $this->_num_pages = $this->_total > $this->_limit ? ceil($this->_total / $this->_limit) : 0; } $this->_single_page = $this->_num_pages < 1; // check out-of-range page index $this->_curpage = $page > $this->_num_pages ? 1 : $page; // set base URL if don't exists $this->_baseURL = $baseURL; if (empty($baseURL)) { $config =& Factory::getConfig(); $uri = URL::getURI(); $this->_baseURL = $config->baseURL . $uri->_url; } // if true, URL::_ will be used $this->_automakeSEF = $automakeSEF; $this->_detect_formatting = $detect_formatting; // get component format if ($detect_formatting) { $component_format = Request::getVar('format'); if ($component_format) { $this->__component_format = 'format=' . Request::getVar('format'); } else { // turn it off if no special formatting found $this->_detect_formatting = false; } } }
public function actionDisplay() { $id = Request::getVar('id', null); $alias = Request::getVar('alias', null); $model = Video::getInstance(); if ($id == null or $id == "") { if ($alias != null and $alias != "") { $obj_item = $model->getItemByAlias($alias); } else { header("Location: /"); } } else { $obj_item = $model->getItem($id); } $items = $model->getItems($obj_item['catID'], true, 4); $items2 = $model->getItems($obj_item['catID'], false, 9); $obj_category = $model->getCategory($obj_item['catID']); $data['item'] = $obj_item; $data['items'] = $items; $data['items2'] = $items2; $data['category'] = $obj_category; $page_title = $obj_item['title']; $page_keyword = $obj_item['metakey'] != "" ? $obj_item['metakey'] : $page_title; $page_description = $obj_item['metadesc'] != "" ? $obj_item['metadesc'] : $page_title; setSysConfig("seopage.title", $page_title); setSysConfig("seopage.keyword", $page_keyword); setSysConfig("seopage.description", $page_description); Request::setVar('alias', $obj_category['alias']); $this->render('default', $data); }
function suggestions_getContent() { global $template; // open template $template->setFile('suggestions.tmpl'); $messageText = array(-3 => array('type' => 'error', 'message' => _('Fehler beim eintragen des Vorschlags.')), -2 => array('type' => 'error', 'message' => _('Es wurde kein Nachrichtentext angegeben.')), -1 => array('type' => 'error', 'message' => _('Du hast schon die Maximalzahl an möglichen Vorschlägen erreicht.')), 1 => array('type' => 'success', 'message' => _('Der Vorschlag wurde erfolgreich verschickt.'))); $suggestionsCount = suggestions_countSuggestion($_SESSION['player']->playerID); $action = Request::getVar('action', ''); switch ($action) { /**************************************************************************************************** * * Nachricht eintragen * ****************************************************************************************************/ case 'add': if ($suggestionsCount >= SUGGESTIONS_MAX) { $messageID = -1; break; } $message = Request::getVar('inputMessage', ''); if (empty($message)) { $messageID = -2; break; } $messageID = suggestions_addSuggestion($_SESSION['player']->playerID, $message); if ($messageID > 0) { $suggestionsCount++; } break; } $template->addVars(array('max_suggestions' => $suggestionsCount >= SUGGESTIONS_MAX ? true : false, 'status_msg' => isset($messageID) ? $messageText[$messageID] : '')); }
function controller_exec() { global $conf; if (!authorized()) { $err_str = 'Access restricted.'; if ($conf['modes']['db']['enabled']) { $group = $conf['access_limit_to_group']; Toolbar::title('Databases', 'databases'); Toolbar::preferences('com_databases', '200'); $err_str = "<p class=\"error\">Not authorized, access is limited to \"<em>{$group}</em>\"</p>. <h3>Use the Databases component parameters to change this</h3>"; } print $err_str; return; } // Get the task $task = Request::getVar('task', 'list'); $task_file = JPATH_COMPONENT . DS . 'tasks' . DS . $task . '.php'; if (require_once $task_file) { $task_func = 'dv_' . $task; if (function_exists($task_func)) { if (file_exists(JPATH_COMPONENT . DS . 'tasks' . DS . 'html' . DS . $task . '.js')) { $document = App::get('document'); $document->addScript(DB_PATH . DS . 'tasks' . DS . 'html' . DS . $task . '.js?v=2'); } $task_func(); } } }
/** * Hook for after routing application * * @return void */ public function onAfterRoute() { if (!App::isAdmin() && !App::isSite()) { return; } $client = 'Site'; if (App::isAdmin()) { $client = 'Admin'; return; } // Check if active for this client (Site|Admin) if (!$this->params->get('activate' . $client) || Request::getVar('format') == 'pdf') { return; } Html::behavior('framework'); if ($this->params->get('jqueryui')) { Html::behavior('framework', true); } if ($this->params->get('jqueryfb')) { Html::behavior('modal'); } if ($this->params->get('noconflict' . $client)) { Document::addScript(Request::root(true) . '/core/assets/js/jquery.noconflict.js'); } }
/** * Parse the URL parameters and map each parameter (in order) to the given array of names * * @param array varNames: Array of names to map the URL parameters to * @return object: Object with properties named after var names mapped to URL parameters */ protected function getParams($varNames) { $i = 0; // Strict processing doesn't allow extra or missing parameters in the URL $strictProcessing = false; $params = false; // check if there are more parameters than needed $extraParameter = Request::getVar('p' . count($varNames), ''); if ($strictProcessing && !empty($extraParameter)) { // too many parameters in the URL //throw new \Exception('Too many parameters'); App::abort(404, Lang::txt('Page Not Found')); } // Go through each var name and assign a sequential URL parameter's value to it foreach ($varNames as $varName) { $value = Request::getVar('p' . $i, ''); if (!empty($value)) { $params->{$varName} = $value; } else { if ($strictProcessing) { // missing parameter in the URL //throw new \Exception('Too few parameters'); App::abort(404, Lang::txt('Page Not Found')); } break; } $i++; } return $params; }
/** * Method to catch the onAfterRoute event. * * @return boolean */ public function onAfterRoute() { $task = Request::getVar('task', 'none'); if (User::isGuest() || !App::isSite() || $task == 'user.logout') { return false; } $menuId = $this->params->get('menuId', 0); if (!$menuId) { return false; } $menu = App::get('menu'); $activeMenu = $menu->getActive(); $defaultMenu = $menu->getDefault(); // If routing to the home page... if ($activeMenu == $defaultMenu) { // Reset the active menu item and // overwrite request vars $menu->setActive($menuId); $menu->setDefault($menuId, $defaultMenu->language); $item = $menu->getItem($menuId); $vars = $item->query; $vars['Itemid'] = $menuId; foreach ($vars as $key => $var) { Request::setVar($key, $var); } } return true; }
/** * Authorize * * @return void */ public function authorizeTask() { $oauth_token = \Request::getVar('oauth_token'); if (empty($oauth_token)) { throw new Exception('Forbidden', 403); } $db = \App::get('db'); $db->setQuery("SELECT * FROM `#__oauthp_tokens` WHERE token=" . $db->Quote($oauth_token) . " AND user_id=0 LIMIT 1;"); $result = $db->loadObject(); if ($result === false) { throw new Exception('Internal Server Error', 500); } if (empty($result)) { throw new Exception('Forbidden', 403); } if (Request::method() == 'GET') { $this->view->oauth_token = $oauth_token; $this->view->display(); return; } if (Request::method() == 'POST') { $token = Request::get('token', '' . 'post'); if ($token != sha1($this->verifier)) { throw new Exception('Forbidden', 403); } echo "posted"; return; } throw new Exception('Method Not Allowed', 405); }
/** * Method to set the home property for a list of items * * @since 1.6 */ function setDefault() { // Check for request forgeries Session::checkToken('request') or die(Lang::txt('JINVALID_TOKEN')); // Get items to publish from the request. $cid = Request::getVar('cid', array(), '', 'array'); $data = array('setDefault' => 1, 'unsetDefault' => 0); $task = $this->getTask(); $value = \Hubzero\Utility\Arr::getValue($data, $task, 0, 'int'); if (empty($cid)) { throw new Exception(Lang::txt($this->text_prefix . '_NO_ITEM_SELECTED'), 500); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers \Hubzero\Utility\Arr::toInteger($cid); // Publish the items. if (!$model->setHome($cid, $value)) { throw new Exception($model->getError(), 500); } else { if ($value == 1) { $ntext = 'COM_MENUS_ITEMS_SET_HOME'; } else { $ntext = 'COM_MENUS_ITEMS_UNSET_HOME'; } $this->setMessage(Lang::txts($ntext, count($cid))); } } $this->setRedirect(Route::url('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); }
/** * Initializes the github connection * * @param array $params Any connection params needed * @return object **/ public static function init($params = []) { // Get the params $pparams = Plugin::params('filesystem', 'github'); $app_key = isset($params['app_key']) ? $params['app_key'] : $pparams['app_key']; $app_secret = isset($params['app_secret']) ? $params['app_secret'] : $pparams['app_secret']; \Session::set('github.app_key', $app_key); \Session::set('github.app_secret', $app_secret); $repository = isset($params['repository']) ? $params['repository'] : $pparams['repository']; $credentials = []; if (isset($params['username']) && isset($params['password'])) { $credentials = [Settings::AUTHENTICATE_USING_PASSWORD, $params['username'], $params['password']]; } else { $accessToken = Session::get('github.token', false); if (!$accessToken) { $base = 'https://github.com/login/oauth/authorize'; $params = '?client_id=' . $app_key; $scope = '&scope=user,repo'; $return = Request::getVar('return') ? Request::getVar('return') : Request::current(true); $return = base64_encode($return); $state = '&state=' . $return; Session::set('github.state', $return); App::redirect($base . $params . $scope . $state); } $credentials = [Settings::AUTHENTICATE_USING_TOKEN, $accessToken]; } $settings = new Settings($params['repository'], $credentials); $api = new Api(new \Github\Client(), $settings); // Return the adapter return new GithubAdapter($api); }
/** * Return data on a course view (this will be some form of HTML) * * @param object $course Current course * @param object $offering Name of the component * @param boolean $describe Return plugin description only? * @return object */ public function onCourse($course, $offering, $describe = false) { if (!$offering->access('manage', 'section')) { return; } $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('description', Lang::txt('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'managers'))->set('display_menu_tab', true)->set('icon', 'f083'); if ($describe) { return $response; } $nonadmin = Request::getState('com_courses.offering' . $offering->get('id') . '.nonadmin', 0); if (!($active = Request::getVar('active')) && !$nonadmin) { Request::setVar('active', $active = $this->_name); } if ($response->get('name') == $active) { // Set the page title Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_COURSES_' . strtoupper($this->_name))); Pathway::append(Lang::txt('PLG_COURSES_' . strtoupper($this->_name)), $offering->link() . '&active=' . $this->_name); $view = with($this->view('default', 'overview'))->set('option', Request::getVar('option', 'com_courses'))->set('course', $course)->set('offering', $offering)->set('params', $this->params); foreach ($this->getErrors() as $error) { $view->setError($error); } $response->set('html', $view->loadTemplate()); } // Return the output return $response; }
function questionnaire_getQuestionnairePresents($caveID, &$ownCaves) { global $template; // open template $template->setFile('questionnairePresents.tmpl'); $template->setShowRresource(false); //messages $messageText = array(-5 => array('type' => 'error', 'message' => _('Ich bin mit dem Schnecken abzählen durcheinander gekommen, Häuptling! Versucht es noch einmal!')), -4 => array('type' => 'error', 'message' => _('Ihr habt nicht die passenden Schnecken, Häuptling!"')), -3 => array('type' => 'error', 'message' => _('Dieses Geschenk kann ich euch nicht anbieten, Häuptling!')), -2 => array('type' => 'error', 'message' => _('Datenbankfehler. Bitte versuche es später nochmals.')), -1 => array('type' => 'error', 'message' => _('Du hast keine Belognung ausgewählt.')), 1 => array('type' => 'success', 'message' => _('Eure Geschenke sind nun in eurer Höhle!')), 2 => array('type' => 'info', 'message' => _('Danke für die Schnecken!'))); $action = Request::getVar('action', ''); switch ($action) { /**************************************************************************************************** * * Gescenke abholen * ****************************************************************************************************/ case 'present': $presentID = Request::getVar('presentID', 0); $messageID = questionnaire_getPresent($caveID, $ownCaves, $presentID); break; } // geschenke auslesen $presents = questionnaire_getPresents(); // show my credits $credits = questionnaire_getCredits($_SESSION['player']->questionCredits); /**************************************************************************************************** * * Übergeben ans Template * ****************************************************************************************************/ $template->addVars(array('credits' => $credits, 'presents' => $presents, 'status_msg' => isset($messageID) ? $messageText[$messageID] : '')); }
/** * Calls an HTTP POST function to verify if the user's guess was correct * * @return True if the answer is correct, false otherwise * @since 2.5 */ public function onCheckAnswer($code) { // Initialise variables $privatekey = $this->params->get('private_key'); $remoteip = Request::getVar('REMOTE_ADDR', '', 'SERVER'); $challenge = Request::getString('recaptcha_challenge_field', ''); $response = Request::getString('recaptcha_response_field', ''); // Check for Private Key if (empty($privatekey)) { $this->_subject->setError(Lang::txt('PLG_RECAPTCHA_ERROR_NO_PRIVATE_KEY')); return false; } // Check for IP if (empty($remoteip)) { $this->_subject->setError(Lang::txt('PLG_RECAPTCHA_ERROR_NO_IP')); return false; } // Discard spam submissions if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { $this->_subject->setError(Lang::txt('PLG_RECAPTCHA_ERROR_EMPTY_SOLUTION')); return false; } $response = $this->_recaptcha_http_post(self::RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", array('privatekey' => $privatekey, 'remoteip' => $remoteip, 'challenge' => $challenge, 'response' => $response)); $answers = explode("\n", $response[1]); if (trim($answers[0]) == 'true') { return true; } else { //@todo use exceptions here $this->_subject->setError(Lang::txt('PLG_RECAPTCHA_ERROR_' . strtoupper(str_replace('-', '_', $answers[1])))); return false; } }
/** * View the order * * @return void */ public function viewTask() { // Incoming $id = Request::getVar('id', array(0)); // Get transaction info $tInfo = Cart::getTransactionInfo($id); $tItems = unserialize($tInfo->tiItems); foreach ($tItems as $item) { // Check if the product is still available $warehouse = new Warehouse(); $skuInfo = $warehouse->getSkuInfo($item['info']->sId); if (!$skuInfo) { // product no longer available $item['info']->available = false; } else { $item['info']->available = true; } } $tInfo->tiItems = $tItems; // Get user info $userId = Cart::getCartUser($tInfo->crtId); $user = Profile::getInstance($userId); //print_r($user); die; $this->view->user = $user; $this->view->tInfo = $tInfo; $this->view->tId = $id; $this->view->setLayout('view')->display(); }
/** * Constructor * * @return boolean */ public function onAfterRoute() { $task = Request::getVar('task', 'none'); if (User::isGuest() || !App::isSite() || $task == 'user.logout') { return false; } /*$ignoredURLs = (string) $this->params->get('ignore_urls', ''); if ($ignoredURLs) { $ignoredURLArray = explode("\r\n",$ignoredURLs); $fullURL = Request::current(); foreach ($ignoredURLArray as $str) { $pos = strpos($fullURL, $str); if ($pos !== false) { return false; } } } $ignoredOptions = (string) $this->params->get('ignore_options', ''); if ($ignoredOptions) { $option = Request::getCmd('option', ''); $ignoredOptionsArray = explode("\r\n", $ignoredOptions); foreach ($ignoredOptionsArray as $str) { if ($str == $option) { return false; } } }*/ $menuId = $this->params->get('menuId', 0); if (!$menuId) { return false; } $menu = App::get('menu'); $activeMenu = $menu->getActive(); $defaultMenu = $menu->getDefault(); if ($activeMenu == $defaultMenu) { $menu->setActive($menuId); $menu->setDefault($menuId, $defaultMenu->language); $item = $menu->getItem($menuId); $vars = $item->query; $vars['Itemid'] = $menuId; foreach ($vars as $key => $var) { Request::setVar($key, $var); } //Request::set($vars, 'method', true); //App::redirect(Route::url('index.php?Itemid=' . $menuId, false)); } return true; }
function storeItem() { global $mainframe, $user; if (!$user->isSuperAdmin()) { YiiMessage::raseNotice("Your account not have permission to modify module"); $this->redirect(Router::buildLink("cpanel")); } $cid = Request::getVar("id", 0); $obj_module = YiiModule::getInstance(); $obj_row = $obj_module->loadItem($cid); $obj_row->bind($_POST); $menu_selected = Request::getVar('selection-menu-select', 'selected'); $obj_row->params = json_encode($_POST['params']); $obj_row->menu = $menu_selected; $obj_row->store(); if ($menu_selected == 'all') { $query = "DELETE FROM " . TBL_MODULE_MENUITEM_REF . " WHERE moduleID = {$obj_row->id} "; Yii::app()->db->createCommand($query)->query(); $query = "INSERT INTO " . TBL_MODULE_MENUITEM_REF . " SET moduleID = {$obj_row->id}, menuID = 0 "; Yii::app()->db->createCommand($query)->query(); } else { if ($menu_selected == 'selected' and isset($_POST['selection-menu'])) { $menuids = $_POST['selection-menu']; foreach ($menuids as $menuid) { $query = "REPLACE INTO " . TBL_MODULE_MENUITEM_REF . " SET moduleID = {$obj_row->id}, menuID = {$menuid} "; Yii::app()->db->createCommand($query)->query(); } } else { $query = "DELETE FROM " . TBL_MODULE_MENUITEM_REF . " WHERE moduleID = {$obj_row->id} "; Yii::app()->db->createCommand($query)->query(); } } return $obj_row->id; }
/** creates the map-page with header and the specified map region */ function getCaveMapContent($caveID, $caves) { global $template; $caveData = $caves[$caveID]; $mapSize = getMapSize(); // Größe der Karte wird benötigt $message = ''; // template öffnen $template->setFile('map.tmpl'); $resolvedCoords = determineCoordsFromParameters($caveData, $mapSize); $template->addVars($resolvedCoords); // corrected x-y-coords of querried cave $xCoord = $resolvedCoords['xCoord']; $yCoord = $resolvedCoords['yCoord']; $minX = $mapSize['minX']; $minY = $mapSize['minY']; $maxX = $mapSize['maxX']; $maxY = $mapSize['maxY']; // get CaveBookmarks $cb_model = new CaveBookmarks_Model(); // get bookmarks $bookmarks = $cb_model->getCaveBookmarks(true); // set bookmarks if (sizeof($bookmarks)) { $template->addVars(array('caveBookmarks' => $bookmarks)); } if (Request::getVar('type', '') == 'minimap') { $mapData = calcCaveMiniMapRegionData(); } else { $mapData = calcCaveMapRegionData($caveID, $caves, $xCoord, $yCoord); } $template->addVars($mapData); }
/** * Initializes the dropbox connection * * @param array $params Any connection params needed * @return \League\Flysystem\Dropbox\DropboxAdapter **/ public static function init($params = []) { // Get the params $pparams = Plugin::params('filesystem', 'dropbox'); if (isset($params['app_token'])) { $accessToken = $params['app_token']; } else { $info = ['key' => isset($params['app_key']) ? $params['app_key'] : $pparams->get('app_key'), 'secret' => isset($params['app_secret']) ? $params['app_secret'] : $pparams->get('app_secret')]; \Session::set('dropbox.app_key', $info['key']); \Session::set('dropbox.app_secret', $info['secret']); \Session::set('dropbox.connection_to_set_up', Request::getVar('connection', 0)); $appInfo = \Dropbox\AppInfo::loadFromJson($info); $clientIdentifier = 'hubzero-cms/2.0'; $redirectUri = trim(Request::root(), '/') . '/developer/callback/dropboxAuthorize'; $csrfTokenStore = new \Dropbox\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token'); $oauth = new \Dropbox\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore); // Redirect to dropbox // We hide the return url in the state field...that's not exactly what // it was intended for, but it does the trick $return = Request::getVar('return') ? Request::getVar('return') : Request::current(true); $return = base64_encode($return); App::redirect($oauth->start($return)); } $app_secret = isset($params['app_secret']) ? $params['app_secret'] : $pparams->get('app_secret'); // Create the client $client = new \Dropbox\Client($accessToken, $app_secret); // Return the adapter return new \League\Flysystem\Dropbox\DropboxAdapter($client, isset($params['subdir']) ? $params['subdir'] : null); }
function rankingTribe_getContent() { global $template; // open template $template->setFile('rankingTribe.tmpl'); $template->setShowResource(false); $numRows = rankingTribe_getMaxRows(); $offset = 0; $row = array(); if ($numRows > 0) { $search = Request::getVar('search', ''); $page = Request::getVar('page', 0); if ($search !== '') { $offset = rankingTribe_checkOffsetBySearch($search, $numRows); if ($offset < 0) { $offset = 0; $template->addVar('status_msg', array('type' => 'error', 'message' => 'Der gesuchte Stamm wurde nicht gefunden')); } } else { $offset = rankingTribe_checkOffsetByPage($_SESSION['player']->tribeID, $page, $numRows); } $row = rankingTribe_getRowsByOffset($offset); } $template->addVars(array('page' => ceil($offset / RANKING_ROWS) + 1, 'max_pages' => ceil($numRows / RANKING_ROWS), 'rows_per_page' => RANKING_ROWS, 'row' => $row)); }
/** * Pub view for project files, notes etc. * * @return void */ public function displayTask() { require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'tables' . DS . 'publicstamp.php'; // Incoming $stamp = Request::getVar('s', ''); // Clean up stamp value (only numbers and letters) $regex = array('/[^a-zA-Z0-9]/'); $stamp = preg_replace($regex, '', $stamp); // Load item reference $objSt = new Tables\Stamp($this->database); if (!$stamp || !$objSt->loadItem($stamp)) { App::redirect(Route::url('index.php?option=' . $this->_option)); return; } // Can only serve files or notes at the moment if (!in_array($objSt->type, array('files', 'notes', 'publications'))) { App::redirect(Route::url('index.php?option=' . $this->_option)); return; } // Serve requested item $content = Event::trigger('projects.serve', array($objSt->type, $objSt->projectid, $objSt->reference)); // Output foreach ($content as $out) { if ($out) { return $out; } } // Redirect if nothing fetched App::redirect(Route::url('index.php?option=' . $this->_option)); return; }
function store() { global $mainframe, $db, $user; $post = $_POST; $arr_team_table = Request::getVar('arr_team_table', null); $arr_team_table = json_decode($arr_team_table, true); $model = Tournament::getInstance(); global $user; if (!$user->isSuperAdmin()) { YiiMessage::raseNotice("Your account not have permission to change Tournament"); $this->redirect(Router::buildLink("gamesport", array('view' => 'tournament'))); } $tourID = Request::getVar('tourID', 0); $db = Yii::app()->db; foreach ($arr_team_table as $table_num => $team_tables) { if (count($team_tables)) { $stt = 1; foreach ($team_tables as $teamID => $team) { if ($team == null) { continue; } if ($team['ordering'] == null or $team['ordering'] == 0) { $team['ordering'] = $stt; } $query = "UPDATE " . TBL_GS_TEAM_REGISTER_TOUR . " SET table_num = {$table_num}" . " ,ordering = " . $team['ordering'] . " ,mdate = now()" . " ,modified_by = {$user->id}" . " WHERE tourID = {$tourID} AND teamID = {$teamID}"; $command = $db->createCommand($query); $command->execute(); $stt++; } } } return true; }
/** * Gets the request filters and returns them * * @param string $namespace the application state variable namespace * @return array **/ public static function getFilters($namespace) { // Process query filters $q = User::getState("{$namespace}.query"); if ($incoming = Request::getVar('q', false)) { $q[] = $incoming; } // Set some defaults for the filters, if not set otherwise if (!is_array($q)) { $q[0]['column'] = $namespace == 'com_time.tasks' ? 'assignee_id' : 'user_id'; $q[0]['operator'] = 'e'; $q[0]['value'] = User::get('id'); } // Translate operators and augment query filters with human-friendly text $query = self::filtersMap($q); // Turn search into array of results, if not already $search = Request::getVar('search', User::getState("{$namespace}.search", '')); // If we have a search and it's not an array (i.e. it's coming in fresh with this request) if ($search && !is_array($search)) { // Explode multiple words into array $search = explode(" ", $search); // Only allow alphabetical characters for search $search = preg_replace("/[^a-zA-Z]/", "", $search); } // Set some values in the session User::setState("{$namespace}.search", $search); User::setState("{$namespace}.query", $query); return array('search' => $search, 'q' => $query); }
/** * Initializes the Google Drive connection * * @param array $params Any connection params needed * @return object **/ public static function init($params = []) { // Get the params $pparams = Plugin::params('filesystem', 'googledrive'); $app_id = isset($params['app_id']) && $params['app_id'] != '' ? $params['app_id'] : $pparams->get('app_id'); $app_secret = isset($params['app_secret']) && $params['app_secret'] != '' ? $params['app_secret'] : $pparams->get('app_secret'); $client = new \Google_Client(); $client->setClientId($app_id); $client->setClientSecret($app_secret); $client->addScope(Google_Service_Drive::DRIVE); $client->setAccessType('offline'); $client->setApprovalPrompt('force'); $client->setIncludeGrantedScopes(true); if (isset($params['app_token'])) { $accessToken = $params['app_token']; // json encode turned our array into an object, we need to undo that $accessToken = (array) $accessToken; } else { \Session::set('googledrive.app_id', $app_id); \Session::set('googledrive.app_secret', $app_secret); \Session::set('googledrive.connection_to_set_up', Request::getVar('connection', 0)); // Set upp a return and redirect to Google for auth $return = Request::getVar('return') ? Request::getVar('return') : Request::current(true); $return = base64_encode($return); $redirectUri = trim(Request::root(), '/') . '/developer/callback/googledriveAuthorize'; $client->setRedirectUri($redirectUri); Session::set('googledrive.state', $return); App::redirect($client->createAuthUrl()); } $client->setAccessToken($accessToken); $service = new \Google_Service_Drive($client); $adapter = new \Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter($service, 'root'); return $adapter; }