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 static function driver() { if (class_exists('Administration')) { return Administration::instance()->Configuration; } return Frontend::instance()->Configuration; }
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 function Context() { if (class_exists('Frontend')) { return (object) Frontend::instance(); } return (object) Administration::instance(); }
public static function Database() { if (class_exists('Frontend')) { return Frontend::instance()->Database; } return Administration::instance()->Database; }
private static function __dbConnectionResource() { if (class_exists('Frontend')) { return Frontend::instance()->Database->getConnectionResource(); } return Administration::instance()->Database->getConnectionResource(); }
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(); }
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($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 getSectionId() { $sectionManager = new SectionManager(Frontend::instance()); $section_id = $sectionManager->fetchIDFromHandle(General::sanitize($_REQUEST['MUUsource'])); if (!($section = $sectionManager->fetch($section_id))) { return NULL; } else { return $section_id; } }
function __construct($args) { require_once 'lib/class.cachelite.php'; require_once CORE . '/class.frontend.php'; $this->_Parent =& $args['parent']; $this->_frontend = Frontend::instance(); $this->_lifetime = $this->_get_lifetime(); $this->_cacheLite = new Cache_Lite(array('cacheDir' => CACHE . '/', 'lifeTime' => $this->_lifetime)); $this->_url = $_SERVER['REQUEST_URI']; }
public function __construct() { if (class_exists('Frontend')) { self::$_context = Frontend::instance(); } else { self::$_context = Administration::instance(); } self::$_entryManager = new EntryManager(self::$_context); self::$_sectionManager = self::$_entryManager->sectionManager; self::$_fieldManager = self::$_entryManager->fieldManager; }
/** * Construct a new instance of an Entry. * * @param mixed $parent * The class that created this Entry object, usually the EntryManager, * passed by reference. */ public function __construct(&$parent) { $this->_Parent =& $parent; if (class_exists('Administration')) { $this->_engine = Administration::instance(); } elseif (class_exists('Frontend')) { $this->_engine = Frontend::instance(); } else { throw new Exception(__('No suitable engine object found')); } }
/** * Set up static members */ private function assert() { $mode = isset($_GET['mode']) && strtolower($_GET['mode']) == 'administration' ? 'administration' : 'frontend'; self::$_context = $mode == 'administration' ? Administration::instance() : Frontend::instance(); if (self::$_entry_manager == NULL) { self::$_entry_manager = new EntryManager(self::$_context); } if (self::$_entry_xml_datasource == NULL) { self::$_entry_xml_datasource = new EntryXMLDataSource(self::$_context, NULL, FALSE); } }
public function grab(&$param_pool) { $result = new XMLElement($this->dsParamROOTELEMENT); $driver = Frontend::instance()->ExtensionManager->create('iplocation_lookup'); $location = extension_IPLocation_Lookup::lookup(); if (is_null($location)) { $result->appendChild(new XMLElement('error', 'unknown location')); } else { $result->setValue($location); } return $result; }
public function __pageParamsResolve($ctx) { // context array contains: &$params $Frontend = Frontend::instance(); if (!isset($Frontend->__improvedpageresolve)) { return; } if (!empty($Frontend->__improvedpageresolve['params'])) { $ctx['params'] = array_merge($ctx['params'], $Frontend->__improvedpageresolve['params']); } unset($Frontend->__improvedpageresolve); }
public function grab(&$param_pool) { $result = new XMLElement($this->dsParamROOTELEMENT); $driver = Frontend::instance()->ExtensionManager->create('netspeed_service'); $speed = extension_netspeed_service::lookup(); if (is_null($speed)) { $result->appendChild(new XMLElement('error', 'Unknown')); } else { $result = $speed; } return $result; }
protected function __trigger() { $Members = Frontend::instance()->ExtensionManager->create('members'); $Members->initialiseCookie(); if ($Members->isLoggedIn() !== true || $_POST['id'] != (int) $Members->Member->get('id')) { // Oi! you can't be here redirect(URL . '/forbidden/'); exit; } include TOOLKIT . '/events/event.section.php'; return $result; }
public static function render($e) { $page_id = Symphony::Database()->fetchVar('page_id', 0, "SELECT `page_id` FROM `tbl_pages_types` WHERE `type` = '404' LIMIT 1"); if (is_null($page_id)) { parent::render(new SymphonyErrorPage(__('The page you requested does not exist.'), __('Page Not Found'), 'error', array('header' => 'HTTP/1.0 404 Not Found'))); } else { $url = '/' . Frontend::instance()->resolvePagePath($page_id) . '/'; $output = Frontend::instance()->display($url); header(sprintf('Content-Length: %d', strlen($output))); echo $output; exit; } }
function __construct(&$parent) { if (class_exists('Frontend')) { $symphony = Frontend::instance(); } else { $symphony = Administration::instance(); } if (!self::$ready) { self::$db = Symphony::Database(); self::$em = new EntryManager($symphony); self::$sm = new SectionManager($symphony); } }
function __construct(&$parent) { parent::__construct($parent); $this->_name = 'Member: Username & Password'; $this->_required = true; $this->set('required', 'yes'); if (!self::$_driver instanceof Extension) { if (class_exists('Frontend')) { self::$_driver = Frontend::instance()->ExtensionManager->create('members'); } else { self::$_driver = Administration::instance()->ExtensionManager->create('members'); } } }
function __construct(&$parent) { parent::__construct($parent); $this->_name = 'Member: Role'; // Set default $this->set('show_column', 'no'); if (!$this->_driver instanceof Extension) { if (class_exists('Frontend')) { $this->_driver = Frontend::instance()->ExtensionManager->create('members'); } else { $this->_driver = Administration::instance()->ExtensionManager->create('members'); } } }
function __construct(&$parent) { $this->_Parent =& $parent; $this->_fields = array(); $this->_data = array(); if (class_exists('Administration')) { $this->_engine = Administration::instance(); } elseif (class_exists('Frontend')) { $this->_engine = Frontend::instance(); } else { trigger_error(__('No suitable engine object found'), E_USER_ERROR); } $this->creationDate = DateTimeObj::getGMT('c'); }
public function __construct() { $this->id = $this->type = $this->subject = $this->body = NULL; $this->__roles = array(); if (!self::$_Parent instanceof Symphony) { if (class_exists('Frontend')) { self::$_Parent = Frontend::instance(); } else { self::$_Parent = Administration::instance(); } } if (!self::$_Members instanceof Extension) { self::$_Members = self::$_Parent->ExtensionManager->create('members'); } }
public function build() { $this->_view = strlen(trim($_GET['profile'])) == 0 ? 'general' : $_GET['profile']; $this->_xsl = @file_get_contents($this->_pagedata['filelocation']); // Build statistics: $this->_profiler = Frontend::instance()->Profiler; $this->_dbstats = Symphony::Database()->getStatistics(); $this->_records = array('general' => $this->_profiler->retrieveGroup('General'), 'data-sources' => $this->_profiler->retrieveGroup('Datasource'), 'events' => $this->_profiler->retrieveGroup('Event'), 'slow-queries' => array()); if (is_array($this->_dbstats['slow-queries']) && !empty($this->_dbstats['slow-queries'])) { foreach ($this->_dbstats['slow-queries'] as $q) { $this->_records['slow-queries'][] = array($q['time'], $q['query'], null, null, false); } } return parent::build(); }
public function __construct(&$parent) { parent::__construct($parent); if (class_exists('Administration')) { $this->Symphony = Administration::instance(); } else { $this->Symphony = Frontend::instance(); } $this->Driver = $this->Symphony->ExtensionManager->create('uploadfield'); $this->_name = 'Upload'; $this->_required = true; $this->_mimes = array('image' => array('image/bmp', 'image/gif', 'image/jpg', 'image/jpeg', 'image/png'), 'video' => array('video/quicktime'), 'text' => array('text/plain', 'text/html')); $this->set('show_column', 'yes'); $this->set('required', 'yes'); }
protected function __trigger() { // Cookies only show up on page refresh. // This flag helps in making sure the correct XML is being set $loggedin = false; if (isset($_REQUEST['action']['login'])) { $username = $_REQUEST['username']; $password = $_REQUEST['password']; $loggedin = Frontend::instance()->login($username, $password); } else { $loggedin = Frontend::instance()->isLoggedIn(); } if ($loggedin) { $result = new XMLElement('login-info'); $result->setAttribute('logged-in', 'true'); $author = null; if (is_callable(array('Symphony', 'Author'))) { $author = Symphony::Author(); } else { $author = Frontend::instance()->Author; } $result->setAttributeArray(array('id' => $author->get('id'), 'user-type' => $author->get('user_type'), 'primary-account' => $author->get('primary'))); $fields = array('name' => new XMLElement('name', $author->getFullName()), 'username' => new XMLElement('username', $author->get('username')), 'email' => new XMLElement('email', $author->get('email'))); if ($author->isTokenActive()) { $fields['author-token'] = new XMLElement('author-token', $author->createAuthToken()); } // Section if ($section = Symphony::Database()->fetchRow(0, "SELECT `id`, `handle`, `name` FROM `tbl_sections` WHERE `id` = '" . $author->get('default_area') . "' LIMIT 1")) { $default_area = new XMLElement('default-area', $section['name']); $default_area->setAttributeArray(array('id' => $section['id'], 'handle' => $section['handle'], 'type' => 'section')); $fields['default-area'] = $default_area; } else { $default_area = new XMLElement('default-area', $author->get('default_area')); $default_area->setAttribute('type', 'page'); $fields['default-area'] = $default_area; } foreach ($fields as $f) { $result->appendChild($f); } } else { $result = new XMLElement('user'); $result->setAttribute('logged-in', 'false'); } // param output Frontend::Page()->_param['login'] = $loggedin ? 'yes' : 'no'; Frontend::Page()->_param['login-filter'] = $loggedin ? 'yes,no' : 'yes'; return $result; }
/** * Initialize Subsection Manager as unrequired field */ function __construct(&$parent) { parent::__construct($parent); $this->_name = __('Subsection Manager'); $this->_required = false; if (class_exists('Frontend')) { $symphony = Frontend::instance(); } else { $symphony = Administration::instance(); } if (!self::$ready) { self::$db = Symphony::Database(); self::$em = new EntryManager($symphony); self::$fm = new FieldManager($symphony); self::$sm = new SectionManager($symphony); } }
function __construct(&$parent) { $this->_Parent =& $parent; $this->_fields = array(); $this->_data = array(); ## Since we are not sure where the Admin object is, inspect ## all the parent objects $this->catalogueParentObjects(); if (class_exists('Administration')) { $this->_engine = Administration::instance(); } elseif (class_exists('Frontend')) { $this->_engine = Frontend::instance(); } else { trigger_error(__('No suitable engine object found'), E_USER_ERROR); } $this->creationDate = DateTimeObj::getGMT('c'); }
function __construct(&$parent) { $this->_Parent = $parent; $this->_fields = array(); $this->_required = false; $this->_showcolumn = true; $this->_handle = strtolower(get_class($this)) == 'field' ? 'field' : strtolower(substr(get_class($this), 5)); if (class_exists('Administration')) { $this->_engine = Administration::instance(); } elseif (class_exists('Frontend')) { $this->_engine = Frontend::instance(); } else { trigger_error(__('No suitable engine object found'), E_USER_ERROR); } $this->creationDate = DateTimeObj::getGMT('c'); $this->Database = Symphony::Database(); }