public function action() { ##Do not proceed if the config file is read only if (!is_writable(CONFIG)) { redirect(URL . '/symphony/system/preferences/'); } ### # Delegate: CustomActions # Description: This is where Extensions can hook on to custom actions they may need to provide. $this->_Parent->ExtensionManager->notifyMembers('CustomActions', '/system/preferences/'); if (isset($_POST['action']['save'])) { $settings = $_POST['settings']; ### # Delegate: Save # Description: Saving of system preferences. $this->_Parent->ExtensionManager->notifyMembers('Save', '/system/preferences/', array('settings' => &$settings, 'errors' => &$this->_errors)); if (!is_array($this->_errors) || empty($this->_errors)) { foreach ($settings as $set => $values) { foreach ($values as $key => $val) { Symphony::Configuration()->set($key, $val, $set); } } $this->_Parent->saveConfig(); redirect(URL . '/symphony/system/preferences/success/'); } } }
/** * Given a CSV file, generate a resulting XML tree * * @param string $data * @return string */ public static function convertToXML($data) { $headers = array(); // Get CSV settings $settings = array('csv-delimiter' => ',', 'csv-enclosure' => '"', 'csv-escape' => '\\'); $settings = array_merge($settings, (array) Symphony::Configuration()->get('remote_datasource')); // DOMDocument $doc = new DOMDocument('1.0', 'utf-8'); $doc->formatOutput = true; $root = $doc->createElement('data'); $doc->appendChild($root); foreach (str_getcsv($data, PHP_EOL) as $i => $row) { if (empty($row)) { continue; } if ($i == 0) { foreach (str_getcsv($row, $settings['csv-delimiter'], $settings['csv-enclosure'], $settings['csv-escape']) as $i => $head) { if (class_exists('Lang')) { $head = Lang::createHandle($head); } $headers[] = $head; } } else { self::addRow($doc, $root, str_getcsv($row, $settings['csv-delimiter'], $settings['csv-enclosure'], $settings['csv-escape']), $headers); } } $output = $doc->saveXML($doc->documentElement); return trim($output); }
public static function upgrade() { // 2.2.2 Beta 1 if (version_compare(self::$existing_version, '2.2.2 Beta 1', '<=')) { Symphony::Configuration()->set('version', '2.2.2 Beta 1', 'symphony'); // Rename old variations of the query_caching configuration setting if (Symphony::Configuration()->get('disable_query_caching', 'database')) { $value = Symphony::Configuration()->get('disable_query_caching', 'database') == "no" ? "on" : "off"; Symphony::Configuration()->set('query_caching', $value, 'database'); Symphony::Configuration()->remove('disable_query_caching', 'database'); } // Add Session GC collection as a configuration parameter Symphony::Configuration()->set('session_gc_divisor', '10', 'symphony'); // Save the manifest changes Symphony::Configuration()->write(); } // 2.2.2 Beta 2 if (version_compare(self::$existing_version, '2.2.2 Beta 2', '<=')) { Symphony::Configuration()->set('version', '2.2.2 Beta 2', 'symphony'); try { // Change Textareas to be MEDIUMTEXT columns $textarea_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_textarea`"); foreach ($textarea_tables as $field) { Symphony::Database()->query(sprintf("ALTER TABLE `tbl_entries_data_%d` CHANGE `value` `value` MEDIUMTEXT, CHANGE `value_formatted` `value_formatted` MEDIUMTEXT", $field)); Symphony::Database()->query(sprintf('OPTIMIZE TABLE `tbl_entries_data_%d`', $field)); } } catch (Exception $ex) { } // Save the manifest changes Symphony::Configuration()->write(); } // Update the version information return parent::upgrade(); }
public static function lookup($ip) { $ch = curl_init(); // Notice: the request back to the service API includes your domain name // and the version of Symphony that you're using $version = Symphony::Configuration()->get('version', 'symphony'); $domain = $_SERVER[SERVER_NAME]; curl_setopt($ch, CURLOPT_URL, "http://api.josephdenne.com/_geoloc/array/?symphony=" . $version . "&domain=" . $domain . "&ip=" . $ip); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $geoinfo = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); if ($geoinfo === false || $info['http_code'] != 200) { return; } else { $geoinfo = explode(',', $geoinfo); } $result = new XMLElement("geolocation"); $included = array('id', 'lookups', 'country', 'region', 'city', 'lat', 'lon', 'error'); $i = 0; foreach ($included as $geoloc) { $result->appendChild(new XMLElement($geoloc, $geoinfo[$i])); $i++; } return $result; }
/** * Starts a Session object, only if one doesn't already exist. This function maps * the Session Handler functions to this classes methods by reading the default * information from the PHP ini file. * * @link http://php.net/manual/en/function.session-set-save-handler.php * @link http://php.net/manual/en/function.session-set-cookie-params.php * @param integer $lifetime * How long a Session is valid for, by default this is 0, which means it * never expires * @param string $path * The path the cookie is valid for on the domain * @param string $domain * The domain this cookie is valid for * @param boolean $httpOnly * Whether this cookie can be read by Javascript. By default the cookie * cannot be read by Javascript * @param boolean $secure * Whether this cookie should only be sent on secure servers. By default this is * false, which means the cookie can be sent over HTTP and HTTPS * @throws Exception * @return string|boolean * Returns the Session ID on success, or false on error. */ public static function start($lifetime = 0, $path = '/', $domain = null, $httpOnly = true, $secure = false) { if (!self::$_initialized) { if (!is_object(Symphony::Database()) || !Symphony::Database()->isConnected()) { return false; } if (session_id() == '') { ini_set('session.save_handler', 'user'); ini_set('session.gc_maxlifetime', $lifetime); ini_set('session.gc_probability', '1'); ini_set('session.gc_divisor', Symphony::Configuration()->get('session_gc_divisor', 'symphony')); } 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(), $secure, $httpOnly); session_cache_limiter(''); if (session_id() == '') { if (headers_sent()) { throw new Exception('Headers already sent. Cannot start session.'); } register_shutdown_function('session_write_close'); session_start(); } self::$_initialized = true; } return session_id(); }
public function frontendPrePageResolve($context) { if (!self::$resolved) { // get languages from configuration if (self::$languages = Symphony::Configuration()->get('languages', 'multilingual')) { self::$languages = explode(',', str_replace(' ', '', self::$languages)); // detect language from path if (preg_match('/^\\/([a-z]{2})\\//', $context['page'], $match)) { // set language from path self::$language = $match[1]; } else { // detect language from browser self::$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); } // check if language is supported if (!in_array(self::$language, self::$languages)) { // set to default otherwise self::$language = self::$languages[0]; } // redirect root page if (!$context['page']) { header('Location: ' . URL . '/' . self::$language . '/'); exit; } } self::$resolved = true; } }
protected function __parseLog($file) { $items = array(); $last = null; if (is_readable($file)) { header('content-type: text/plain'); if (preg_match('/.gz$/', $file)) { $handle = gzopen($file, "r"); $data = gzread($handle, Symphony::Configuration()->get('maxsize', 'log')); gzclose($handle); } else { $data = file_get_contents($file); } $lines = explode(PHP_EOL, $data); // Skip log info: while (count($lines)) { $line = trim(array_shift($lines)); if ($line == '--------------------------------------------') { break; } } // Create items: foreach ($lines as $line) { preg_match('/^(.*?) > (.*)/', trim($line), $matches); // New entry: if (count($matches) == 3) { $message = htmlentities($matches[2]); $items[] = (object) array('timestamp' => DateTimeObj::get(__SYM_DATETIME_FORMAT__, strtotime($matches[1])), 'message' => $message); } } // Reverse order: $items = array_reverse($items); } return $items; }
public static function save(Utility $utility) { $file = UTILITIES . "/{$utility->name}"; FileWriter::write($file, $utility->body, Symphony::Configuration()->core()->symphony->{'file-write-mode'}); //General::writeFile($file, $utility->body,Symphony::Configuration()->core()->symphony->{'file-write-mode'}); return file_exists($file); }
protected function __construct() { $this->Profiler = new Profiler(); if (get_magic_quotes_gpc()) { General::cleanArray($_SERVER); General::cleanArray($_COOKIE); General::cleanArray($_GET); General::cleanArray($_POST); } include CONFIG; self::$Configuration = new Configuration(true); self::$Configuration->setArray($settings); define_safe('__LANG__', self::$Configuration->get('lang', 'symphony') ? self::$Configuration->get('lang', 'symphony') : 'en'); define_safe('__SYM_DATE_FORMAT__', self::$Configuration->get('date_format', 'region')); define_safe('__SYM_TIME_FORMAT__', self::$Configuration->get('time_format', 'region')); define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . ' ' . __SYM_TIME_FORMAT__); $this->initialiseLog(); GenericExceptionHandler::initialise(); GenericErrorHandler::initialise($this->Log); $this->initialiseCookie(); try { Lang::init(LANG . '/lang.%s.php', __LANG__); } catch (Exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); } $this->initialiseDatabase(); if (!$this->initialiseExtensionManager()) { throw new SymphonyErrorPage('Error creating Symphony extension manager.'); } DateTimeObj::setDefaultTimezone(self::$Configuration->get('timezone', 'region')); }
/** * Save the preferences * * @param $context */ public function savePreferences($context) { if (isset($_POST['force_download']['trusted_locations'])) { Symphony::Configuration()->set('trusted_locations', serialize(explode("\n", str_replace("\r", '', $_POST['force_download']['trusted_locations']))), 'force_download'); Symphony::Configuration()->write(); } }
/** * Initialize contextual XML (formerly params) */ public function initializeContext() { $this->View->context->register(array('system' => array('site-name' => Symphony::Configuration()->core()->symphony->sitename, 'site-url' => URL, 'admin-url' => URL . '/symphony', 'symphony-version' => Symphony::Configuration()->core()->symphony->version), 'date' => array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => date_default_timezone_get()))); if ($this->User) { $this->View->context->register(array('session' => self::instance()->User->fields())); } }
static function upgrade() { if (version_compare(self::$existing_version, '2.3.3beta1', '<=')) { // Update DB for the new author role #1692 Symphony::Database()->query(sprintf("ALTER TABLE `tbl_authors` CHANGE `user_type` `user_type` enum('author', 'manager', 'developer') DEFAULT 'author'", $field)); // Remove directory from the upload fields, #1719 $upload_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_upload`"); if (is_array($upload_tables) && !empty($upload_tables)) { foreach ($upload_tables as $field) { Symphony::Database()->query(sprintf("UPDATE tbl_entries_data_%d SET file = substring_index(file, '/', -1)", $field)); } } } if (version_compare(self::$existing_version, '2.3.3beta2', '<=')) { // Update rows for associations if (!Symphony::Configuration()->get('association_maximum_rows', 'symphony')) { Symphony::Configuration()->set('association_maximum_rows', '5', 'symphony'); } } // Update the version information Symphony::Configuration()->set('version', self::getVersion(), 'symphony'); Symphony::Configuration()->set('useragent', 'Symphony/' . self::getVersion(), 'general'); if (Symphony::Configuration()->write() === false) { throw new Exception('Failed to write configuration file, please check the file permissions.'); } else { return true; } }
public function view() { $section_handle = (string) $this->context[0]; $page = isset($this->context[1]) ? (int) $this->context[1] : 1; if (empty($section_handle)) { die('Invalid section handle'); } $config = (object) Symphony::Configuration()->get('elasticsearch'); ElasticSearch::init(); $type = ElasticSearch::getTypeByHandle($section_handle); if ($page === 1) { // delete all documents in this index $query = new Elastica_Query(array('query' => array('match_all' => array()))); $type->type->deleteByQuery($query); } // get new entries $em = new EntryManager(Symphony::Engine()); $entries = $em->fetchByPage($page, $type->section->get('id'), (int) $config->{'reindex-batch-size'}, NULL, NULL, FALSE, FALSE, TRUE); foreach ($entries['records'] as $entry) { ElasticSearch::indexEntry($entry, $type->section); } $entries['total-entries'] = 0; // last page, count how many entries in the index if ($entries['remaining-pages'] == 0) { // wait a few seconds, allow HTTP requests to complete... sleep(5); $entries['total-entries'] = $type->type->count(); } header('Content-type: application/json'); echo json_encode(array('pagination' => array('total-pages' => (int) $entries['total-pages'], 'total-entries' => (int) $entries['total-entries'], 'remaining-pages' => (int) $entries['remaining-pages'], 'next-page' => $page + 1))); exit; }
protected function __construct() { $this->Profiler = new Profiler(); if (get_magic_quotes_gpc()) { General::cleanArray($_SERVER); General::cleanArray($_COOKIE); General::cleanArray($_GET); General::cleanArray($_POST); } include CONFIG; self::$Configuration = new Configuration(true); self::$Configuration->setArray($settings); DateTimeObj::setDefaultTimezone(self::$Configuration->get('timezone', 'region')); self::$_lang = self::$Configuration->get('lang', 'symphony') ? self::$Configuration->get('lang', 'symphony') : 'en'; // Legacy support for __LANG__ constant define_safe('__LANG__', self::lang()); define_safe('__SYM_DATE_FORMAT__', self::$Configuration->get('date_format', 'region')); define_safe('__SYM_TIME_FORMAT__', self::$Configuration->get('time_format', 'region')); define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . ' ' . __SYM_TIME_FORMAT__); $this->initialiseLog(); GenericExceptionHandler::initialise(); GenericErrorHandler::initialise(self::$Log); $this->initialiseCookie(); $this->initialiseDatabase(); if (!$this->initialiseExtensionManager()) { throw new SymphonyErrorPage('Error creating Symphony extension manager.'); } Lang::loadAll($this->ExtensionManager); }
public function view($call_parent = TRUE) { $this->addElementToHead(new XMLElement('script', "Symphony.Context.add('elasticsearch', " . json_encode(Symphony::Configuration()->get('elasticsearch')) . ")", array('type' => 'text/javascript')), 99); if ($call_parent) { parent::view(); } }
function build() { if (!$this->canAccessPage()) { $this->_Parent->customError(E_USER_ERROR, __('Access Denied'), __('You are not authorised to access this page.')); exit; } header('Content-Type: text/javascript'); $css = Symphony::Configuration()->get('styles', 'ckeditor'); $lines = explode("\n", $css); // h3.groen-blok { color: #363636; background: #a3cf5e; } // h3.zwart-blok { color: #fff; background: #363636; } $js = 'var ckeditor_styles = ['; $rules = array(); foreach ($lines as $line) { if (!empty($line)) { $a = explode('{', $line); $selector = trim($a[0]); $b = explode('.', $selector); $element = $b[0]; $className = $b[1]; // {name: 'Groen Blok', element: 'h3', attributes: {class: 'groen-blok'}} $c = explode('-', $className); $name = ''; foreach ($c as $d) { $name .= ucfirst($d) . ' '; } $rules[] = '{name: \'' . trim($name) . '\', element: \'' . $element . '\', attributes: {class: \'' . $className . '\'}}'; } } $js .= implode(',', $rules) . ']'; die($js); }
public function view() { // Ensure we have been set $_POST data from Members events if (!array_key_exists('members', $_POST)) { $this->setHttpStatus(self::HTTP_STATUS_BAD_REQUEST); return; } else { if (!is_writable(CONFIG)) { $this->setHttpStatus(self::HTTP_STATUS_ERROR); $this->_Result->appendChild(new XMLElement('message', __('The Symphony configuration file, <code>/manifest/config.php</code>, is not writable. You will not be able to save changes to preferences.'))); return; } } $settings = $_POST['members']; // Generate Recovery Code if (isset($settings['generate-recovery-code-template'])) { Symphony::Configuration()->set('generate-recovery-code-template', implode(',', array_filter($settings['generate-recovery-code-template'])), 'members'); } else { if ($settings['event'] == 'generate-recovery-code') { Symphony::Configuration()->remove('generate-recovery-code-template', 'members'); } } // Reset Password if (isset($settings['reset-password-template'])) { Symphony::Configuration()->set('reset-password-template', implode(',', array_filter($settings['reset-password-template'])), 'members'); } else { if ($settings['event'] == 'reset-password') { Symphony::Configuration()->remove('reset-password-template', 'members'); } } if ($settings['event'] == 'reset-password') { Symphony::Configuration()->set('reset-password-auto-login', $settings['auto-login'], 'members'); } // Regenerate Activation Code if (isset($settings['regenerate-activation-code-template'])) { Symphony::Configuration()->set('regenerate-activation-code-template', implode(',', array_filter($settings['regenerate-activation-code-template'])), 'members'); } else { if ($settings['event'] == 'regenerate-activation-code') { Symphony::Configuration()->remove('regenerate-activation-code-template', 'members'); } } // Activate Account if (isset($settings['activate-account-template'])) { Symphony::Configuration()->set('activate-account-template', implode(',', array_filter($settings['activate-account-template'])), 'members'); } else { if ($settings['event'] == 'activate-account') { Symphony::Configuration()->remove('activate-account-template', 'members'); } } if ($settings['event'] == 'activate-account') { Symphony::Configuration()->set('activate-account-auto-login', $settings['auto-login'], 'members'); } // Return successful if (Symphony::Configuration()->write()) { $this->setHttpStatus(self::HTTP_STATUS_OK); $this->_Result->appendChild(new XMLElement('message', __('Preferences saved.'))); $this->_Result->appendChild(new XMLElement('timestamp', '<![CDATA[' . Widget::Time(null, __SYM_TIME_FORMAT__)->generate() . ']]>')); } }
public function __construct() { // die('construct'); $this->clientId = Symphony::Configuration()->get('client-id', 'paypal'); $this->clientSecret = Symphony::Configuration()->get('client-secret', 'paypal'); $this->mode = Symphony::Configuration()->get('mode', 'paypal'); $this->apiContext = $this->generateApiContext($this->clientId, $this->clientSecret); }
public function send() { $this->validate(); $credentials = Symphony::Configuration()->get('postmarkapp'); $email = new Mail_Postmark($credentials['api_key'], $credentials['from_name'], $credentials['from_address']); $email->to($this->recipient)->replyTo($this->sender_email_address, $this->sender_name)->subject($this->subject)->messagePlain($this->message)->send(); return true; }
private function __construct() { $this->_language = General::sanitize($_REQUEST['language']); $this->_region = General::sanitize($_REQUEST['region']); $this->_language_code = $this->_region ? $this->_language . '-' . $this->_region : $this->_language; $supported_language_codes = explode(',', General::sanitize(Symphony::Configuration()->get('language_codes', 'language_redirect'))); $this->_supported_language_codes = $this->cleanLanguageCodes($supported_language_codes); }
protected function __trigger() { $clientId = Symphony::Configuration()->get('client_id', 'githuboauth'); $scope = Symphony::Configuration()->get('scope', 'githuboauth'); $redirectUrl = Symphony::Configuration()->get('auth_redirect', 'githuboauth'); header('Location: https://github.com/login/oauth/authorize?client_id=' . $clientId . '&redirect_uri=' . $redirectUrl . '&scope=' . $scope); exit; }
public function update($previousVersion) { if (version_compare($previousVersion, '0.7', '<')) { Symphony::Configuration()->remove('geocoding-field'); Administration::instance()->saveConfig(); } return true; }
public function update($previousVersion) { if (version_compare($previousVersion, '2.0', '<')) { Symphony::Configuration()->remove('canofspam'); Symphony::Configuration()->write(); Symphony::Database()->query("DROP TABLE `tbl_canofspam_tracking`"); } return true; }
function build() { if (!$this->canAccessPage()) { $this->_Parent->customError(E_USER_ERROR, __('Access Denied'), __('You are not authorised to access this page.')); exit; } header('Content-Type: text/css'); die(Symphony::Configuration()->get('styles', 'ckeditor')); }
protected function __construct() { parent::__construct(); $this->Profiler->sample('Engine Initialisation'); // Need this part for backwards compatiblity $this->Database = Symphony::Database(); $this->Configuration = Symphony::Configuration(); $this->_callback = NULL; }
/** * Returns the default gateway. * Will throw an exception if the gateway can not be found. * * @return string */ public static function getDefaultGateway() { $gateway = Symphony::Configuration()->get('default_gateway', 'Email'); if ($gateway) { return $gateway; } else { return self::$_default_gateway; } }
static function upgrade() { Symphony::Configuration()->set('version', '2.2.5', 'symphony'); if (Symphony::Configuration()->write() === false) { throw new Exception('Failed to write configuration file, please check the file permissions.'); } else { return true; } }
/** * The constructor for Frontend calls the parent Symphony constructor. * * @see core.Symphony#__construct() * @deprecated The constructor creates backwards compatible references * to `$this->Database`, `$this->ExtensionManager` and `$this->Configuration` * that act as alias for `Symphony::Database()`, `Symphony::ExtensionManager()` * and `Symphony::Configuration()`. These will be removed in the * next Symphony release */ protected function __construct() { parent::__construct(); $this->_env = array(); // Need this part for backwards compatiblity $this->Database = Symphony::Database(); $this->Configuration = Symphony::Configuration(); $this->ExtensionManager = Symphony::ExtensionManager(); }
/** * This function will upgrade Symphony from the `self::$existing_version` * to `getVersion()`. * * @return boolean */ public static function upgrade() { Symphony::Configuration()->set('version', static::getVersion(), 'symphony'); Symphony::Configuration()->set('useragent', 'Symphony/' . static::getVersion(), 'general'); if (Symphony::Configuration()->write() === false) { throw new Exception('Failed to write configuration file, please check the file permissions.'); } else { return true; } }
public function uninstall() { Symphony::Configuration()->remove('cdi'); Symphony::Configuration()->write(); CdiMaster::uninstall(); CdiSlave::uninstall(); CdiDBSync::uninstall(); CdiDumpDB::uninstall(); return true; }