/** * The main handler for the specfied handle. * * @param string $handle The instance handle. * * @return Handler */ public function handle($handle) { // Sanitize the handle name. $this->handle = $this->utility->sanitize_handle($handle); // Register this handle with the frontend class. $this->frontend->register_handle($this->handle); // Register the Ajax handler in the WordPress hook system. add_action('wp_ajax_' . $this->handle, array($this, 'ajax_handler')); add_action('wp_ajax_nopriv_' . $this->handle, array($this, 'ajax_handler')); return $this; }
function checkLoginFromAdmin($userid_from_zend) { $front = Frontend::getInstance(); if (isset($userid_from_zend) && $userid_from_zend != "" && $userid_from_zend != -2) { //echo "0*".$userid_from_zend."*"; $user_id = (int) $userid_from_zend; if ($user_id == 0) { die("Admin session expired"); } if ($front->isUserLoggedIn() && isset($_SESSION["userid"]) && $_SESSION["userid"] != 0 && $_SESSION["userid"] == $user_id) { // already logged nothing to do } else { if ($front->isUserLoggedIn() && isset($_SESSION["userid"]) && $_SESSION["userid"] != 0 && $_SESSION["userid"] != $user_id) { die("You are logged in Love application with another userid in this session. Please, logout from Love application!" . $_SESSION["userid"] . "**" . $user_id); } else { $sql = "SELECT " . USERS . ".*, " . COMPANY . ".name as company_name " . "FROM " . USERS . ", " . COMPANY . " " . "WHERE " . USERS . ".id = " . mysql_real_escape_string($user_id) . " AND " . USERS . ".company_id = " . COMPANY . ".id"; $row = doQuery($sql); $username = $row->username; $nickname = $row->nickname; // $admin = $row->admin; $_SESSION["userid"] = $user_id; $_SESSION["username"] = $username; $_SESSION["nickname"] = $nickname; // $_SESSION["admin"] = $admin; $_SESSION['running'] = "true"; if (!$front->isUserLoggedIn()) { $front = new Frontend(); if (!$front->isUserLoggedIn()) { clearSession(); die("You are still not logged! Click on another tab, and come back back here it could work"); } } if (!isAdmin($user_id)) { clearSession(); die("You should have admin right to get access to this page." . $admin . "**" . USERS); } } } } if (!$front->isUserLoggedIn()) { clearSession(); $front->getUser()->askUserToAuthenticate(); } if (!isAdmin($_SESSION["userid"])) { clearSession(); die("You should have admin right to get access to this page."); } }
private static function __dbConnectionResource() { if (class_exists('Frontend')) { return Frontend::instance()->Database->getConnectionResource(); } return Administration::instance()->Database->getConnectionResource(); }
public function __construct() { parent::__construct(); $this->load->helper('tools'); $this->load->library('user_agent'); $this->load->model('comments_model'); }
/** * setting * * @param VirtualConnectionInterface $conn database connection * @param bool $revision 리비전 처리 * @return \Illuminate\View\View */ public function setting(VirtualConnectionInterface $conn, $revision = false) { /** @var \Xpressengine\DynamicField\DynamicFieldHandler $dynamicField */ $dynamicField = app('xe.dynamicField'); $parent = $dynamicField->getConfigHandler()->parent($this->group); $configs = []; if ($parent !== null) { /** * @var ConfigEntity $config */ foreach (Cfg::children($parent) as $config) { if ($config->get('use') === true) { $configs[$config->get('id')] = $config; } } } /** * @var \Xpressengine\DynamicField\RegisterHandler $registerHandler */ $dynamicFieldHandler = app('xe.dynamicField'); $registerHandler = $dynamicFieldHandler->getRegisterHandler(); $types = $registerHandler->getTypes($dynamicFieldHandler); $fieldTypes = []; foreach ($types as $types) { $fieldTypes[] = $types; } \Frontend::rule('dynamicFieldSection', $this->getRules()); return View::make('dynamicField.setting', ['databaseName' => $conn->getName(), 'group' => $this->group, 'configs' => $configs, 'fieldTypes' => $fieldTypes, 'revision' => $revision]); }
public static function instance() { if (!self::$_instance instanceof Frontend) { self::$_instance = new self(); } return self::$_instance; }
public function __construct($strTemplate = '', $active = null) { parent::__construct(); $this->loadLanguageFile('imagemapster'); $this->strTemplate = $strTemplate; $this->active = $active; }
public function getLoveHistory($page, $justUser = false) { $front = Frontend::getInstance(); $page--; $l = $this->getLimit() * $page; $where = ''; $sql = "SELECT count(*) " . "FROM " . LOVE_LOVE; $res = mysql_query($sql); $row = mysql_fetch_row($res); $loves = $row[0]; $sql = "SELECT count(*) " . "FROM " . LOVE_LOVE . " " . "WHERE " . LOVE_LOVE . ".receiver = '" . $front->getUser()->getUsername() . "' " . "OR " . LOVE_LOVE . ".giver = '" . $front->getUser()->getUsername() . "' " . ($sql .= $justUser ? '' : "OR " . LOVE_LOVE . ".company_id = '" . $front->getUser()->getCompany_id() . "' "); $sql .= $where . " " . "ORDER BY id DESC"; $res = mysql_query($sql); $row = mysql_fetch_row($res); $count = $row[0]; $cPages = ceil($count / $this->getLimit()); $sql = "SELECT id,giver,receiver,why,private,TIMESTAMPDIFF(SECOND,at,NOW()) as delta " . "FROM " . LOVE_LOVE . " " . "WHERE " . LOVE_LOVE . ".receiver = '" . $front->getUser()->getUsername() . "' " . "OR " . LOVE_LOVE . ".giver = '" . $front->getUser()->getUsername() . "' "; $sql .= $justUser ? '' : "OR " . LOVE_LOVE . ".company_id = '" . $front->getUser()->getCompany_id() . "' "; $sql .= $where . " " . "ORDER BY id DESC " . "LIMIT " . $l . "," . $this->getLimit(); $res = mysql_query($sql); // Construct json for history $this->pages = array(array($page, $cPages, number_format($loves))); for ($i = 1; $row = mysql_fetch_assoc($res); $i++) { $givernickname = getNickName($row['giver']); $givernickname = !empty($givernickname) ? $givernickname : $row['giver']; $receivernickname = getNickName($row['receiver']); $receivernickname = !empty($receivernickname) ? $receivernickname : $row['receiver']; $why = $row['why']; if ($row['private']) { $why .= " (love sent quietly)"; } $history[] = array("id" => $row['id'], "giver" => $row['giver'], "giverNickname" => $givernickname, "receiver" => $row['receiver'], "receiverNickname" => $receivernickname, "why" => $why, "delta" => Utils::relativeTime($row['delta'])); } return $history; }
public static function Database() { if (class_exists('Frontend')) { return Frontend::instance()->Database; } return Administration::instance()->Database; }
public static function start($lifetime = 0, $path = '/', $domain = NULL) { if (!self::$_initialized) { ## Crude method of determining if we're in the admin or frontend if (class_exists('Frontend')) { self::$_db =& Frontend::instance()->Database; } elseif (class_exists('Administration')) { self::$_db =& Administration::instance()->Database; } else { return false; } if (!is_object(self::$_db) || !self::$_db->isConnected()) { return false; } self::$_cache = new Cacheable(self::$_db); $installed = self::$_cache->check('_session_config'); if (!$installed) { if (!self::createTable()) { return false; } self::$_cache->write('_session_config', true); } ini_set('session.save_handler', 'user'); session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc')); session_set_cookie_params($lifetime, $path, $domain ? $domain : self::getDomain(), false, false); self::$_initialized = true; if (session_id() == '') { session_start(); } } return session_id(); }
public static function driver() { if (class_exists('Administration')) { return Administration::instance()->Configuration; } return Frontend::instance()->Configuration; }
/** * makeView * * @param $target * @param $instanceId * @param $mode * * @return \Illuminate\Contracts\View\View */ protected function makeView($target, $instanceId, $mode) { /** @var SkinHandler $skinHandler */ $skinHandler = app('xe.skin'); $skinInstanceId = $skinHandler->mergeKey($target, $instanceId); $selectedSkin = $skinHandler->getAssigned([$target, $instanceId], $mode); if ($selectedSkin !== null) { $settingView = $selectedSkin->getSettingView(); } else { $settingView = null; } // get skin list $skinList = $skinHandler->getList($target); $skins = function ($skinList, $selectedSkin) { (yield ['text' => '선택하세요', 'selected' => false]); foreach ($skinList as $id => $skin) { $support = []; $support[] = $skin->supportDesktop() ? '데스크탑' : ''; $support[] = $skin->supportMobile() ? '모바일' : ''; $support = '[' . implode('|', $support) . ']'; (yield ['value' => $id, 'text' => $skin->getTitle() . $support, 'selected' => $selectedSkin === null ? false : $id === $selectedSkin->getId()]); } }; $skins = $skins($skinList, $selectedSkin); \Frontend::js('assets/skin/section.js')->load(); $url = route('settings.skin.section.setting'); \Frontend::html('skin.loadSkinSetting')->content("<script>\n XE.\$(function(\$){\n \$('.__xe_skinSetting').xeSkinSetting({\n 'loadUrl': '{$url}',\n 'saveUrl': '{$url}'\n });\n });\n </script>")->load(); return View::make('skin.setting', compact('skinInstanceId', 'settingView', 'skins', 'mode', 'selectedSkin')); }
/** * Generate array representation for download * * @param bool $blnOrderPaid * * @return array */ public function getForTemplate($blnOrderPaid = false) { global $objPage; $objDownload = $this->getRelated('download_id'); if (null === $objDownload) { return array(); } $arrDownloads = array(); $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); foreach ($objDownload->getFiles() as $objFileModel) { $objFile = new \File($objFileModel->path, true); if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) { continue; } // Send file to the browser if ($blnOrderPaid && $this->canDownload() && \Input::get('download') == $objDownload->id && \Input::get('file') == $objFileModel->path) { $this->download($objFileModel->path); } $arrMeta = \Frontend::getMetaData($objFileModel->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename))); } $strHref = ''; if (TL_MODE == 'FE') { $strHref = \Haste\Util\Url::addQueryString('download=' . $objDownload->id . '&file=' . $objFileModel->path); } // Add the image $arrDownloads[] = array('id' => $this->id, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname, 'remaining' => $objDownload->downloads_allowed > 0 ? sprintf($GLOBALS['TL_LANG']['MSC']['downloadsRemaining'], intval($this->downloads_remaining)) : '', 'downloadable' => $blnOrderPaid && $this->canDownload()); } return $arrDownloads; }
public function Context() { if (class_exists('Frontend')) { return (object) Frontend::instance(); } return (object) Administration::instance(); }
public static function lookup($ip) { $ch = curl_init(); // Notice: the request back to the Symphony services API includes your domain name // and the version of Symphony that you're using $version = Frontend::instance()->Configuration->get('version', 'symphony'); $domain = $_SERVER[SERVER_NAME]; curl_setopt($ch, CURLOPT_URL, "http://symphony-cms.net/_netspeed/1.0/?symphony=" . $version . "&domain=" . $domain . "&ip=" . $ip); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $speedinfo = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); if ($speedinfo === false || $info['http_code'] != 200) { return; } else { $speedinfo = explode(',', $speedinfo); } $result = new XMLElement("netspeed"); $included = array('id', 'connection', 'error'); $i = 0; foreach ($included as $netspeed) { $result->appendChild(new XMLElement($netspeed, $speedinfo[$i])); $i++; } return $result; }
public function frontendPreRenderHeaders($context) { $page = Frontend::Page(); foreach (self::$headers as $name => $value) { $page->addHeaderToPage($name, $value); } }
public function __construct($submitted) { parent::__construct(); $this->submitted = $submitted; $this->loadLanguageFile('tl_subscribe_plus'); $this->loadDataContainer('tl_subscribe_plus'); }
/** * Initialize the object (do not remove) */ public function __construct() { parent::__construct(); // See #4099 define('BE_USER_LOGGED_IN', false); define('FE_USER_LOGGED_IN', false); }
/** * Construct the object * @param string * @param array */ public function __construct($strName, $arrFiles) { parent::__construct(); $this->import('Isotope'); $this->name = $strName; $this->files = $arrFiles; }
function renderer($mode = 'frontend') { if (!in_array($mode, array('frontend', 'administration'))) { throw new Exception('Invalid Symphony Renderer mode specified. Must be either "frontend" or "administration".'); } require_once CORE . "/class.{$mode}.php"; return $mode == 'administration' ? Administration::instance() : Frontend::instance(); }
/** * initialize controller */ public function __construct() { $this->import('BackendUser', 'User'); parent::__construct(); $this->loadLanguageFile('default'); $this->loadLanguageFile('modules'); $this->setStaticUrls(); }
/** * Register hooks and load options. * * @since 1.0.0 */ public static function setup() { // Setup the registry Registry::load(); // Register the hooks of the subsystems Frontend::register_hooks(); Backend::register_hooks(); }
public function __construct() { // Set the item from the auto_item parameter if (!isset($_GET['store']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) { \Input::setGet('store', \Input::get('auto_item')); } parent::__construct(); }
/** * Initialize the object * @param integer */ public function __construct($intPoll) { parent::__construct(); $objPoll = \Database::getInstance()->prepare($this->getPollQuery('tl_poll'))->limit(1)->execute($intPoll); if ($objPoll->numRows) { $this->objPoll = $objPoll; } }
function renderer_json($mode) { if (strtolower($mode) == 'administration') { throw new Lib\Exceptions\InvalidModeException('JSON Renderer launcher is only available on the frontend'); } $renderer = Frontend::instance(); // Check if we should enable exception debug information $exceptionDebugEnabled = Symphony::isLoggedIn(); // Use the JSON exception and error handlers instead of the Symphony one. Lib\ExceptionHandler::initialise($exceptionDebugEnabled); Lib\ErrorHandler::initialise($exceptionDebugEnabled); // #1808 if (isset($_SERVER['HTTP_MOD_REWRITE'])) { throw new Exception("mod_rewrite is required, however is not enabled."); } $output = $renderer->display(getCurrentPage()); cleanup_session_cookies(); if (in_array('JSON', Frontend::Page()->pageData()['type'])) { // Load the output into a SimpleXML Container and convert to JSON try { $xml = new SimpleXMLElement($output, LIBXML_NOCDATA); // Convert the XML to a plain array. This step is necessary as we cannot // use JSON_PRETTY_PRINT directly on a SimpleXMLElement object $outputArray = json_decode(json_encode($xml), true); // Get the transforer object ready. Other extensions will // add their transormations to this. $transformer = new Lib\Transformer(); /** * Allow other extensions to add their own transformers */ Symphony::ExtensionManager()->notifyMembers('APIFrameworkJSONRendererAppendTransformations', '/frontend/', ['transformer' => &$transformer]); // Apply transformations $outputArray = $transformer->run($outputArray); // Now put the array through a json_encode $output = json_encode($outputArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); } catch (\Exception $e) { // This happened because the input was not valid XML. This could // occur for a few reasons, but there are two scenarios // we are interested in. // 1) This is a devkit page (profile, debug etc). We want the data // to be passed through and displayed rather than converted into // JSON. There is no easy way in Symphony to tell if a devkit has // control over the page, so instead lets inspect the output for // any signs a devkit is rendering the page. // 2) It is actually bad XML. In that case we need to let the error // bubble through. // Currently the easiest method is to check for the devkit.min.css // in the output. This may fail in the furture if this file is // renamed or moved. if (!preg_match("@\\/symphony\\/assets\\/css\\/devkit.min.css@", $output)) { throw $e; } } } echo $output; return $renderer; }
public function __construct() { global $objPage; $this->isActive = true; #$this->isActive = $this->getLoginStatus('BE_USER_AUTH'); $this->strIgnoreClasses = str_ireplace(array(',', '-'), array('|', '\\-'), $GLOBALS['TL_CONFIG']['frontendEditorIgnoreClasses']); $this->arrIgnoreContent = explode(',', $GLOBALS['TL_CONFIG']['frontendEditorIgnoreContent'] . ',autoLayoutStart,autoLayoutSeparator,autoLayoutStop'); parent::__construct(); }
public function __construct() { parent::__construct(); define('BE_USER_LOGGED_IN', $this->getLoginStatus('BE_USER_AUTH')); define('FE_USER_LOGGED_IN', $this->getLoginStatus('FE_USER_AUTH')); \Controller::setStaticUrls('TL_FILES_URL', $GLOBALS['TL_CONFIG']['staticFiles']); \Controller::setStaticUrls('TL_SCRIPT_URL', $GLOBALS['TL_CONFIG']['staticSystem']); \Controller::setStaticUrls('TL_PLUGINS_URL', $GLOBALS['TL_CONFIG']['staticPlugins']); }
public function display($page) { self::$_page = new FrontendPage($this); #### # Delegate: FrontendInitialised $this->ExtensionManager->notifyMembers('FrontendInitialised', '/frontend/'); $output = self::$_page->generate($page); return $output; }
public function __construct($message) { parent::__construct($message); $this->error = NULL; $bFoundFile = false; if (XSLProc::getErrors() instanceof MessageStack) { foreach (XSLProc::getErrors() as $e) { if ($e->type == XSLProc::ERROR_XML) { $this->error = $errors[0]; $this->file = XSLProc::lastXML(); $this->line = $this->error->line; $bFoundFile = true; break; } elseif (strlen(trim($e->file)) == 0) { continue; } $this->error = $errors[0]; $this->file = $this->error->file; $this->line = $this->error->line; $bFoundFile = true; break; } if (is_null($this->error)) { foreach (XSLProc::getErrors() as $e) { if (preg_match_all('/(\\/?[^\\/\\s]+\\/.+.xsl) line (\\d+)/i', $e->message, $matches, PREG_SET_ORDER)) { $this->file = $matches[0][1]; $this->line = $matches[0][2]; $bFoundFile = true; break; } elseif (preg_match_all('/([^:]+): (.+) line (\\d+)/i', $e->message, $matches, PREG_SET_ORDER)) { //throw new Exception("Fix XSLPROC Frontend doesn't have access to Page"); $this->line = $matches[0][3]; $this->file = VIEWS . '/' . Frontend::instance()->loadedView()->templatePathname(); $bFoundFile = true; } } } } /* // FIXME: This happens when there is an error in the page XSL. Since it is loaded in to a string then passed to the processor it does not return a file if(!$bFoundFile){ $page = Symphony::parent()->Page()->pageData(); $this->file = VIEWS . '/' . $page['filelocation']; $this->line = 0; // Need to look for a potential line number, since // it will not have been grabbed foreach($errors as $e){ if($e->line > 0){ $this->line = $e->line; break; } } } */ }
public function setContentDisposition(array $context = NULL) { $page_data = Frontend::Page()->pageData(); foreach ($page_data['type'] as $type) { if (substr($type, 0, 1) == ".") { $FileName = $page_data['handle']; Frontend::Page()->addHeaderToPage('Content-Disposition', 'attachment; filename=' . $FileName . $type); } } }