/** * POST /uom * */ public function s003() { $error; try { $req = App::request(); if ($req->isPost()) { $post = $req->post(); $attributes = array("uom_nama" => $post["uom_nama"], "aktif" => isset($post["aktif"]) ? 1 : 0); $table = UOM::table(); if (is_null($post["gen_id"]) || $post["gen_id"] == "") { $table->insert($attributes); } else { $where = "uom_nama = '" . $post["gen_id"] . "'"; $table->update($attributes, $where); } } } catch (Exception $e) { $error = $e->getMessage(); ZiUtil::unique_error($error); App::flash('error', $post["uom_nama"] . ' ' . ZiUtil::unique_error($error)); App::redirect('unitOM.a001'); } App::flash('info', 'Data Tersimpan : ' . $post["uom_nama"]); App::redirect('unitOM.index'); }
/** * 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; }
/** * Hook for after parsing route * * @return void */ public function onAfterRoute() { // First, check for presence of subject dn, which is the minimum required field if (!isset($_SERVER['SSL_CLIENT_S_DN']) || !$_SERVER['SSL_CLIENT_S_DN']) { \App::redirect($this->params->get('failure_location', '/invalidcert.php')); return; } if (\User::isGuest()) { // If so, redirect to login Request::setVar('option', 'com_users'); Request::setVar('task', 'user.login'); Request::setVar('authenticator', 'certificate'); Request::setVar('return', base64_encode(\Request::current())); return; } // Check if user is registered and if current session is linked to cert identity $hzad = \Hubzero\Auth\Domain::getInstance('authentication', 'certificate', $_SERVER['SSL_CLIENT_I_DN_CN']); if ($link = \Hubzero\Auth\Link::getInstance($hzad->id, $_SERVER['SSL_CLIENT_S_DN_CN'])) { if ($link->user_id == \User::get('id')) { // All clear...return nothing return; } } // Otherwise, we have a cert-based user that doesn't match the current user Request::setVar('option', 'com_users'); Request::setVar('task', 'user.logout'); $this->event->stop(); }
/** * 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); }
/** * 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; }
/** * 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); }
public function getUserMessageListAction() { $objRecipient = User::fetchById($this->getParam('user_id')); if (!is_object($objRecipient)) { App::redirect('/index/404'); } $this->view->objRecipient = $objRecipient; $this->view->objUser = App_Auth::getInstance()->getUser(); }
public static function validate_login() { session_regenerate_id(); if (empty($_SESSION['HTTP_USER_AGENT'])) { App::redirect('security'); } if (isset($_SESSION) and $_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'])) { App::redirect('security/logout'); } }
public function delete() { $module = $this->registry->core->getParam(); $updateXmlFile = ROOTPATH . 'sql' . DS . $module . DS . 'mysql_update' . DS . 'update.xml'; if (is_file($updateXmlFile)) { $this->gekoLab->uninstall($updateXmlFile); } $this->gekoLab->deletePackageHistory($module); App::redirect(__ADMINPANE__ . '/gekolab'); }
/** * Method to handle an error condition. * * @param Exception &$error The Exception object to be handled. * @return void */ public static function handleError(&$error) { $renderer = new \Hubzero\Error\Renderer\Page(App::get('document'), App::get('template')->template, App::get('config')->get('debug')); // Make sure the error is a 404 and we are not in the administrator. if (!App::isAdmin() and $error->getCode() == 404) { // Render the error page. $renderer->render($error); } // Get the full current URI. $uri = JURI::getInstance(); $current = $uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment')); // Attempt to ignore idiots. if (strpos($current, 'mosConfig_') !== false || strpos($current, '=http://') !== false) { // Render the error page. $renderer->render($error); } // See if the current url exists in the database as a redirect. $db = App::get('db'); $db->setQuery('SELECT ' . $db->quoteName('new_url') . ', ' . $db->quoteName('published') . ' FROM ' . $db->quoteName('#__redirect_links') . ' WHERE ' . $db->quoteName('old_url') . ' = ' . $db->quote($current), 0, 1); $link = $db->loadObject(); // If no published redirect was found try with the server-relative URL if (!$link or $link->published != 1) { $currRel = $uri->toString(array('path', 'query', 'fragment')); $db->setQuery('SELECT ' . $db->quoteName('new_url') . ', ' . $db->quoteName('published') . ' FROM ' . $db->quoteName('#__redirect_links') . ' WHERE ' . $db->quoteName('old_url') . ' = ' . $db->quote($currRel), 0, 1); $link = $db->loadObject(); } // If a redirect exists and is published, permanently redirect. if ($link and $link->published == 1) { App::redirect($link->new_url, null, null, true, false); } else { $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; $db->setQuery('SELECT id FROM ' . $db->quoteName('#__redirect_links') . ' WHERE old_url= ' . $db->quote($current)); $res = $db->loadResult(); if (!$res) { // If not, add the new url to the database. $query = $db->getQuery(true); $query->insert($db->quoteName('#__redirect_links'), false); $columns = array($db->quoteName('old_url'), $db->quoteName('new_url'), $db->quoteName('referer'), $db->quoteName('comment'), $db->quoteName('hits'), $db->quoteName('published'), $db->quoteName('created_date')); $query->columns($columns); $query->values($db->Quote($current) . ', ' . $db->Quote('') . ' ,' . $db->Quote($referer) . ', ' . $db->Quote('') . ',1,0, ' . $db->Quote(Date::toSql())); $db->setQuery($query); $db->query(); } else { // Existing error url, increase hit counter $query = $db->getQuery(true); $query->update($db->quoteName('#__redirect_links')); $query->set($db->quoteName('hits') . ' = ' . $db->quoteName('hits') . ' + 1'); $query->where('id = ' . (int) $res); $db->setQuery((string) $query); $db->query(); } // Render the error page. $renderer->render($error); } }
public function __construct($message, $code = 0, $messageToLogFile = NULL) { parent::__construct($message, $code, $messageToLogFile); if (__ENABLE_DEBUG__ == 0) { App::redirect('admin/mainside'); } $this->errorDesignPath = 'error/index/index.tpl'; echo "<pre>"; echo $this->errorText; die; }
public function logout() { if ($this->registry->router->getAdministrativeMode() == 1) { App::getModel('Frontend/login/login')->destroyAdminAutologinKey(); Session::flush(); App::redirect('login'); } else { Session::flush(); App::redirect(''); } }
public function __construct($message, $code = 0, $messageToLogFile = NULL) { parent::__construct($message, $code, $messageToLogFile); if (__ENABLE_DEBUG__ == 0) { App::redirect('admin/mainside'); } $this->errorDesignPath = 'error/index/index.tpl'; App::getModel('template')->assign('SHOP_NAME', App::getRegistry()->session->getActiveShopName()); App::getModel('template')->assign('error', preg_replace('/(\\n|\\r)+/', '\\n', nl2br(addslashes($this->errorText)))); App::getModel('template')->display($this->errorDesignPath); die; }
/** * Construct a new App_test object * * @param String $uri an optional relative URI (e.g. "/folder/file") */ public function __construct($uri = NULL) { $this->is_testing = TRUE; parent::__construct($uri); if (Config::get('TESTING_ENABLED') !== TRUE) { parent::redirect('', array('exit' => TRUE)); } $this->reset_folder(); $this->test_run = NULL; // Translations need validating Translate::validate(); }
/** * Handle an error * * @param object $error * @return void */ public static function handleError(&$error) { // Make sure the error is a 403 and we are in the frontend. if ($error->getCode() == 403 and App::isSite()) { // Redirect to the home page App::redirect('index.php', Lang::txt('PLG_SYSTEM_LOGOUT_REDIRECT'), null, true, false); } else { // Render the error page. $renderer = new \Hubzero\Error\Renderer\Page(App::get('document'), App::get('template')->template, App::get('config')->get('debug')); $renderer->render($error); } }
/** * Method to display the view * * @param string the template file to include */ public function display($tpl = null) { // Get the user and then check the database to see if the session and database are out of sync $real = User::getInstance(User::get('id')); if ($real->get('approved')) { // Update the session and redirect $session = App::get('session'); $sessionUser = $session->get('user'); $sessionUser->set('approved', $real->get('approved')); $session->set('user', $sessionUser); // Redirect App::redirect(Request::current(true)); } parent::display($tpl); }
public function edit() { $rawUnitmeasureData = $this->model->getUnitMeasureView($this->id); $populateData = array('required_data' => array('language_data' => $rawUnitmeasureData['language'])); $this->formModel->setPopulateData($populateData); $form = $this->formModel->initForm(); if ($form->Validate(\FormEngine\FE::SubmittedData())) { try { $this->model->editUnitMeasure($form->getSubmitValues(\FormEngine\Elements\Form::FORMAT_FLAT), $this->id); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/unitmeasure'); } $this->renderLayout(array('form' => $form->Render())); }
public function edit() { $rawNewsData = $this->model->getNewsView((int) $this->registry->core->getParam()); $populateData = array('required_data' => array('publish' => $rawNewsData['publish'], 'featured' => $rawNewsData['featured'], 'language_data' => $rawNewsData['language']), 'meta_data' => array('language_data' => $rawNewsData['language']), 'additional_data' => array('startdate' => $rawNewsData['startdate'], 'enddate' => $rawNewsData['enddate']), 'photos_pane' => array('photo' => $rawNewsData['photo'], 'mainphotoid' => $rawNewsData['mainphotoid']), 'view_data' => array('view' => $rawNewsData['view'])); $this->formModel->setPopulateData($populateData); $form = $this->formModel->initForm(); if ($form->Validate(\FormEngine\FE::SubmittedData())) { try { $this->model->editNews($form->getSubmitValues(\FormEngine\Elements\Form::FORMAT_FLAT), $this->registry->core->getParam()); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/news'); } $this->registry->xajaxInterface->registerFunction(array('doAJAXCreateSeo', App::getModel('seo'), 'doAJAXCreateSeo')); $this->renderLayout(array('form' => $form->Render())); }
/** * Reports an item as abusive * * @return void */ public function displayTask() { // Login required if (User::isGuest()) { $return = base64_encode(Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false, true), 'server')); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . $return, false)); return; } // Incoming $this->view->refid = Request::getInt('id', 0); $this->view->parentid = Request::getInt('parent', 0); $this->view->cat = Request::getVar('category', ''); // Check for a reference ID if (!$this->view->refid) { throw new Exception(Lang::txt('COM_SUPPORT_ERROR_REFERENCE_ID_NOT_FOUND'), 404); } // Check for a category if (!$this->view->cat) { throw new Exception(Lang::txt('COM_SUPPORT_ERROR_CATEGORY_NOT_FOUND'), 404); } // Get the search result totals $results = Event::trigger('support.getReportedItem', array($this->view->refid, $this->view->cat, $this->view->parentid)); // Check the results returned for a reported item $this->view->report = null; if ($results) { foreach ($results as $result) { if ($result) { $this->view->report = $result[0]; } } } // Ensure we found a reported item if (!$this->view->report) { $this->setError(Lang::txt('COM_SUPPORT_ERROR_REPORTED_ITEM_NOT_FOUND')); } // Set the page title $this->_buildTitle(); $this->view->title = $this->_title; // Set the pathway $this->_buildPathway(); // Output HTML foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->setLayout('display')->display(); }
/** * Renders the auth factor challenge * * @return string **/ public function onRenderChallenge() { // There's not really anything to render for this one, you either have // a cert or your don't. If the user does, we'll just redirect. Otherwise, // perhaps another plugin will give them another option. if ($this->isAuthenticated()) { // Update session and reload the current page App::get('session')->set('authfactors.status', true); App::redirect(Request::current()); } else { // Update session and reload the current page App::get('session')->set('authfactors.status', false); // Register an error with the cookie handler so that it outlives session termination with(new Handler(new Cookie(1)))->error(Lang::txt('COM_LOGIN_FACTORS_FAILED')); App::redirect(Request::current()); } }
/** * POST /warehouse * */ public function s003() { $req = App::request(); if ($req->isPost()) { $post = $req->post(); $attributes = array("warehouse_nama" => $post["warehouse_nama"], "keterangan" => $post["keterangan"], "company" => "RSMM"); $table = Warehouse::table(); if (is_null($post["gen_id"]) || $post["gen_id"] == "") { $attributes["id"] = ZiUtil::GetNowID(); $table->insert($attributes); } else { $where = "id = '" . $post["gen_id"] . "'"; $table->update($attributes, $where); } } App::redirect('warehouse.index'); }
/** * Method to carry template setting in user session if * using the mobile template. * * @return void */ public function onAfterDispatch() { $session = App::get('session'); $tmpl = Request::getVar('tmpl', ''); if ($tmpl == 'mobile') { $session->set('mobile', true); } else { if ($session->get('mobile')) { Request::setVar('tmpl', 'mobile'); } } // Are we requesting to view full site again? if ($tmpl == 'fullsite') { $session->set('mobile', false); Request::setVar('tmpl', ''); App::redirect($_SERVER['SCRIPT_URI'] . '?' . str_replace('tmpl=fullsite', '', $_SERVER['QUERY_STRING'])); } }
public function edit() { $ViewData = $this->model->getView((int) $this->id); if (empty($ViewData)) { App::redirect(__ADMINPANE__ . '/view'); } $populateData = array('required_data' => array('name' => $ViewData['name'], 'namespace' => $ViewData['namespace'], 'store' => $ViewData['store'], 'defaultvatid' => $ViewData['defaultvatid'], 'showtax' => $ViewData['showtax'], 'offline' => $ViewData['offline'], 'offlinetext' => $ViewData['offlinetext'], 'pageschemeid' => $ViewData['pageschemeid'], 'currencyid' => $ViewData['currencyid'], 'contactid' => $ViewData['contactid']), 'meta_data' => array('language_data' => $ViewData['language']), 'url_pane' => array('url' => $ViewData['url']), 'category_pane' => array('category' => $ViewData['category']), 'paymentmethod_pane' => array('paymentmethod' => $ViewData['paymentmethods']), 'dispatchmethod_pane' => array('dispatchmethod' => $ViewData['dispatchmethods']), 'assigntogroup_data' => array('taxes' => $ViewData['taxes'], 'periodid' => $ViewData['periodid'], 'table' => App::getModel('clientgroup')->getAssignToGroupPerView((int) $this->id)), 'registration_data' => array('forcelogin' => $ViewData['forcelogin'], 'confirmregistration' => $ViewData['confirmregistration'], 'enableregistration' => $ViewData['enableregistration']), 'cart_data' => array('cartredirect' => $ViewData['cartredirect'], 'minimumordervalue' => $ViewData['minimumordervalue']), 'logo' => array('photo' => $ViewData['photo'], 'favicon' => $ViewData['favicon'], 'watermark' => $ViewData['watermark']), 'invoice_data' => array('invoicenumerationkind' => $ViewData['invoicenumerationkind'], 'invoicedefaultpaymentdue' => $ViewData['invoicedefaultpaymentdue']), 'mailer_data' => array('mailer' => $ViewData['mailer']['mailer'], 'fromname' => $ViewData['mailer']['fromname'], 'fromemail' => $ViewData['mailer']['fromemail'], 'server' => $ViewData['mailer']['server'], 'port' => $ViewData['mailer']['port'], 'smtpsecure' => $ViewData['mailer']['smtpsecure'], 'smtpauth' => $ViewData['mailer']['smtpauth'], 'smtpusername' => $ViewData['mailer']['smtpusername'], 'smtppassword' => $ViewData['mailer']['smtppassword'], 'terms' => array('file' => $ViewData['terms']))); $this->formModel->setPopulateData($populateData); $form = $this->formModel->initForm(); if ($form->Validate(\FormEngine\FE::SubmittedData())) { try { $this->model->editView($form->getSubmitValues(\FormEngine\Elements\Form::FORMAT_FLAT), $this->id); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/view'); } $this->renderLayout(array('form' => $form->Render())); }
/** * Удаление категории */ public function delete() { if (!Request::ajax()) { App::redirect('/'); } if (!User::isAdmin()) { App::abort(403); } $errors = ''; $id = Request::input('id'); if ($category = Category::find_by_id($id)) { $category->token = Request::input('token', true); if ($category->is_valid() && $category->delete()) { exit(json_encode(['status' => 'ok'])); } else { $errors = $category->getErrorsText(); } } exit(json_encode(['status' => 'error', 'errors' => $errors])); }
/** * Method to handle an error condition. * * @param Exception &$error The Exception object to be handled. * @return void */ public static function handleError(&$error) { include_once PATH_CORE . DS . 'components' . DS . 'com_redirect' . DS . 'models' . DS . 'link.php'; $renderer = new \Hubzero\Error\Renderer\Page(App::get('document'), App::get('template')->template, App::get('config')->get('debug')); // Make sure the error is a 404 and we are not in the administrator. if (!App::isAdmin() and $error->getCode() == 404) { // Render the error page. $renderer->render($error); } // Get the full current URI. $uri = \Hubzero\Utility\Uri::getInstance(); $current = $uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment')); // Attempt to ignore idiots. if (strpos($current, 'mosConfig_') !== false || strpos($current, '=http://') !== false) { // Render the error page. $renderer->render($error); } // See if the current url exists in the database as a redirect. $link = \Components\Redirect\Models\Link::all()->whereEquals('old_url', $current)->row(); // If no published redirect was found try with the server-relative URL if (!$link->id || $link->published != 1) { $currRel = $uri->toString(array('path', 'query', 'fragment')); $link = \Components\Redirect\Models\Link::all()->whereEquals('old_url', $currRel)->row(); } // If a redirect exists and is published, permanently redirect. if ($link->id && $link->published == 1) { App::redirect($link->new_url, null, null, true, false); } else { $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; $row = \Components\Redirect\Models\Link::all()->whereEquals('old_url', $current)->row(); if (!$row->get('id')) { $row->set(['old_url' => $current, 'new_url' => '', 'referer' => $referer, 'comment' => '', 'hits' => 1, 'published' => 0, 'created_date' => Date::toSql()]); } else { $row->set('hits', intval($row->get('hits')) + 1); } $row->save(); // Render the error page. $renderer->render($error); } }
/** * Generate macro output * * @return string */ public function render() { // Check if we can render if (!parent::canRender()) { return \Lang::txt('[This macro is designed for Groups only]'); } // Get the arguments $args = $this->getArgs(); // No arguments passed? Can't do anything. if (empty($args)) { return; } // Clean up the args $args = array_map('trim', $args); @(list($url, $delay) = $args); $delay = intval($delay); // No delay time? Redirect now. if (!$delay) { return \App::redirect($url); } // Delayed redirect return '<script type="text/javascript">setTimeout(function () { window.location.href = "' . str_replace(array("'", '"'), array('%27', '%22'), $url) . '"; }, ' . $delay * 1000 . ');</script> <p class="warning">' . \Lang::txt('This page will redirect in %s seconds', $delay) . '</p>'; }
<?php /* * mobiCMS Content Management System (http://mobicms.net) * * For copyright and license information, please see the LICENSE.md * Installing the system or redistributions of files must retain the above copyright notice. * * @link http://mobicms.net mobiCMS Project * @copyright Copyright (C) mobiCMS Community * @license LICENSE.md (see attached file) */ defined('MOBICMS') or die('Error: restricted access'); use Config\System as Config; $uri = App::request()->getUri(); $form = new Mobicms\Form\Form(['action' => $uri]); $form->title(_dg('Clear Cache'))->html('<span class="description">' . _dg('The Cache clearing is required after installing a new language or upgrade existing ones.') . '</span>')->element('submit', 'update', ['value' => _dg('Clear Cache'), 'class' => 'btn btn-primary btn-xs'])->title(_dg('Default Language'))->element('radio', 'lng', ['checked' => Config::$lng, 'description' => _dg('If the choice is prohibited, the language will be forced to set for all visitors. If the choice is allowed, it will be applied only in the case, if requested by the client language is not in the system.'), 'items' => App::lng()->getLocalesList()])->element('checkbox', 'lngSwitch', ['checked' => Config::$lngSwitch, 'label_inline' => _dg('Allow to choose'), 'description' => _dg('Allow visitors specify the desired language from the list of available in the system. Including activated auto select languages by signatures of the browser.')])->divider()->element('submit', 'submit', ['value' => _g('Save'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _g('Back') . '</a>'); if ($form->process() === true) { if (isset($form->input['update'])) { // Обновляем кэш App::lng()->clearCache(); App::redirect($uri . '?cache'); } else { // Записываем настройки App::session()->remove('lng'); (new Mobicms\Config\WriteHandler())->write('System', $form->output); App::redirect($uri . '?saved'); } } App::view()->form = $form->display(); App::view()->setTemplate('edit_form.php');
/** * Delete a review * * @return void */ public function deletereview() { $database = App::get('db'); $publication =& $this->publication; // Incoming $reviewid = Request::getInt('comment', 0); // Do we have a review ID? if (!$reviewid) { $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_NO_ID')); return; } // Do we have a publication ID? if (!$publication->exists()) { $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_NO_RESOURCE_ID')); return; } $review = new \Components\Publications\Tables\Review($database); $review->load($reviewid); // Permissions check if ($review->created_by != User::get('id')) { return; } $review->state = 2; $review->store(); // Delete the review's comments $comments1 = \Hubzero\Item\Comment::all()->whereEquals('parent', $reviewid)->whereEquals('item_id', $publication->get('id'))->whereEquals('item_type', 'pubreview')->ordered()->rows(); foreach ($comments1 as $comment1) { $comment1->set('state', $comment1::STATE_DELETED); $comment1->save(); } // Recalculate the average rating for the parent publication $publication->table()->calculateRating(); $publication->table()->updateRating(); App::redirect(Route::url($publication->link('reviews')), Lang::txt('PLG_PUBLICATIONS_REVIEWS_REVIEW_DELETED')); return; }
/** * Edit project * * @return void */ public function editTask() { // Check that project exists if (!$this->model->exists() || $this->model->isDeleted()) { throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_CANNOT_LOAD'), 404); return; } // Check if project is in setup if ($this->model->inSetup()) { App::redirect(Route::url($this->model->link('setup'))); return; } // Only managers can edit project if (!$this->model->access('manager')) { throw new Exception(Lang::txt('ALERTNOTAUTH'), 403); return; } // Which section are we editing? $sections = array('info', 'team', 'settings'); if ($this->config->get('edit_settings', 0) == 0) { array_pop($sections); } $this->section = in_array($this->section, $sections) ? $this->section : 'info'; // Set the pathway $this->_buildPathway(); // Set the page title $this->_buildTitle(); $this->view->setLayout('edit'); if ($this->section == 'team') { $this->view->content = $this->_loadTeamEditor(); } // Output HTML $this->view->model = $this->model; $this->view->uid = User::get('id'); $this->view->section = $this->section; $this->view->sections = $sections; $this->view->title = $this->title; $this->view->option = $this->_option; $this->view->config = $this->config; $this->view->task = $this->_task; $this->view->publishing = $this->_publishing; $this->view->active = 'edit'; // Get messages and errors $error = $this->getError() ? $this->getError() : $this->_getNotifications('error'); if ($error) { $this->view->setError($error); } $this->view->msg = $this->_getNotifications('success'); $this->view->display(); }
/** * Show a form for submitting suggestions * * @return void */ public function suggestionsTask() { App::redirect(Route::url('index.php?option=com_wishlist')); }