/**
  * Override the default Symphony constructor to initialise the Log, Config
  * and Database objects for installation/update. This allows us to use the
  * normal accessors.
  */
 protected function __construct()
 {
     if (get_magic_quotes_gpc()) {
         General::cleanArray($_SERVER);
         General::cleanArray($_COOKIE);
         General::cleanArray($_GET);
         General::cleanArray($_POST);
     }
     // Include the default Config for installation.
     include INSTALL . '/includes/config_default.php';
     $this->initialiseConfiguration($settings);
     // Initialize date/time
     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__ . self::Configuration()->get('datetime_separator', 'region') . __SYM_TIME_FORMAT__);
     DateTimeObj::setSettings(self::Configuration()->get('region'));
     // Initialize language
     $this->initialiseLang();
     // Initialize logs
     $this->initialiseLog(INSTALL_LOGS . '/install');
     // Initialize database
     $this->initialiseDatabase();
     // Initialize error handlers
     GenericExceptionHandler::initialise(Symphony::Log());
     GenericErrorHandler::initialise(Symphony::Log());
 }
 public function initialiseCookie()
 {
     $cookie_path = @parse_url(URL, PHP_URL_PATH);
     $cookie_path = '/' . trim($cookie_path, '/');
     define_safe('__SYM_COOKIE_PATH__', $cookie_path);
     define_safe('__SYM_COOKIE_PREFIX_', self::$Configuration->get('cookie_prefix', 'symphony'));
     $this->Cookie = new Cookie(__SYM_COOKIE_PREFIX_, TWO_WEEKS, __SYM_COOKIE_PATH__);
 }
 public function modifyTextarea($context)
 {
     if ($context['field']->get('formatter') != 'tinymce') {
         return;
     }
     if (!defined('__TINYMCE_SCRIPTS_IN_HEAD__') || !__TINYMCE_SCRIPTS_IN_HEAD__) {
         define_safe('__TINYMCE_SCRIPTS_IN_HEAD__', true);
         Administration::instance()->Page->addScriptToHead(URL . '/extensions/richtext_tinymce/lib/tiny_mce.js', 200);
         Administration::instance()->Page->addScriptToHead(URL . '/extensions/richtext_tinymce/assets/applyMCE.js', 210);
     }
     $context['textarea']->setAttribute('id', trim($context['textarea']->getAttribute('id') . ' ' . $context['field']->get('element_name')));
 }
 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;
     $this->Configuration = new Configuration(true);
     $this->Configuration->setArray($settings);
     $cookie_path = parse_url(URL, PHP_URL_PATH);
     $cookie_path = '/' . trim($cookie_path, '/');
     define_safe('__SYM_COOKIE_PATH__', $cookie_path);
     define_safe('__SYM_COOKIE_PREFIX_', $this->Configuration->get('cookie_prefix', 'symphony'));
     define_safe('__LANG__', $this->Configuration->get('lang', 'symphony') ? $this->Configuration->get('lang', 'symphony') : 'en');
     define_safe('__SYM_DATE_FORMAT__', $this->Configuration->get('date_format', 'region'));
     define_safe('__SYM_TIME_FORMAT__', $this->Configuration->get('time_format', 'region'));
     define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . ' ' . __SYM_TIME_FORMAT__);
     $this->initialiseLog();
     error_reporting(E_ALL);
     set_error_handler(array(&$this, '__errorHandler'));
     $this->Cookie =& new Cookie(__SYM_COOKIE_PREFIX_, TWO_WEEKS, __SYM_COOKIE_PATH__);
     try {
         Lang::init(LANG . '/lang.%s.php', __LANG__);
     } catch (Exception $e) {
         trigger_error($e->getMessage(), E_USER_ERROR);
     }
     if (!$this->initialiseDatabase()) {
         $error = $this->Database->getLastError();
         $this->customError(E_USER_ERROR, 'Symphony Database Error', $error['num'] . ': ' . $error['msg'], true, true, 'database-error', array('error' => $error, 'message' => __('There was a problem whilst attempting to establish a database connection. Please check all connection information is correct. The following error was returned.')));
     }
     if (!$this->initialiseExtensionManager()) {
         trigger_error('Error creating Symphony extension manager.', E_USER_ERROR);
     }
     DateTimeObj::setDefaultTimezone($this->Configuration->get('timezone', 'region'));
 }
    }
}
/**
 * Status when an extension is installed and enabled
 * @var integer
 */
define_safe('EXTENSION_ENABLED', 10);
/**
 * Status when an extension is disabled
 * @var integer
 */
define_safe('EXTENSION_DISABLED', 11);
/**
 * Status when an extension is in the file system, but has not been installed.
 * @var integer
 */
define_safe('EXTENSION_NOT_INSTALLED', 12);
/**
 * Status when an extension version in the file system is different to
 * the version stored in the database for the extension
 * @var integer
 */
define_safe('EXTENSION_REQUIRES_UPDATE', 13);
/**
 * Status when the extension is not compatible with the current version of
 * Symphony
 * @since Symphony 2.3
 * @var integer
 */
define_safe('EXTENSION_NOT_COMPATIBLE', 14);
/**
 * Returns the User Agent string of the browser that is viewing the current page
 * @var string
 */
define_safe('HTTP_USER_AGENT', getenv('HTTP_USER_AGENT'));
/**
 * If HTTPS is on, `__SECURE__` will be set to true, otherwise false. Use union of
 * the `HTTPS` environmental variable and the X-Forwarded-Proto header to allow
 * downstream proxies to inform the webserver of secured downstream connections
 * @var string|boolean
 */
define_safe('__SECURE__', HTTPS == 'on' || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https');
/**
 * The base URL of this Symphony install, minus the symphony path.
 * @var string
 */
define_safe('URL', 'http' . (defined('__SECURE__') && __SECURE__ ? 's' : '') . '://' . DOMAIN);
/**
 * Returns the URL + /symphony. This should be used whenever the a developer
 * wants to link to the Symphony root
 * @since Symphony 2.2
 * @var string
 */
define_safe('SYMPHONY_URL', URL . '/symphony');
/**
 * Returns the folder name for Symphony as an application
 * @since Symphony 2.3.2
 * @var string
 */
define_safe('APPLICATION_URL', URL . '/symphony');
    Symphony::initialiseExtensionManager();
    // Handle custom admin paths, #702
    $adminPath = Symphony::Configuration()->get('admin-path', 'symphony');
    $adminPath = is_null($adminPath) ? 'symphony' : $adminPath;
    if (isset($_GET['symphony-page']) && strpos($_GET['symphony-page'], $adminPath, 0) === 0) {
        $_GET['symphony-page'] = preg_replace('%^' . preg_quote($adminPath) . '\\/%', '', $_GET['symphony-page'], 1);
        if ($_GET['symphony-page'] == '') {
            unset($_GET['symphony-page']);
        }
        $_GET['mode'] = $_REQUEST['mode'] = 'administration';
    }
    /**
     * Returns the URL + /symphony. This should be used whenever the a developer
     * wants to link to the Symphony root
     * @since Symphony 2.2
     * @var string
     */
    define_safe('SYMPHONY_URL', URL . '/' . $adminPath);
    /**
     * Overload the default Symphony launcher logic.
     * @delegate ModifySymphonyLauncher
     * @since Symphony 2.5.0
     * @param string $context
     * '/all/'
     */
    Symphony::ExtensionManager()->notifyMembers('ModifySymphonyLauncher', '/all/');
    // Use default launcher:
    if (defined('SYMPHONY_LAUNCHER') === false) {
        define('SYMPHONY_LAUNCHER', 'symphony_launcher');
    }
}
     * @param integer $page_id
     *  The ID of the page.
     */
    public static function detach($type, $r_handle, $page_id)
    {
        $col = self::getColumnFromType($type);
        $pages = PageManager::fetch(false, array($col), array(sprintf('`id` = %d', $page_id)));
        if (is_array($pages) && count($pages) == 1) {
            $result = $pages[0][$col];
            $values = explode(',', $result);
            $idx = array_search($r_handle, $values, false);
            if ($idx !== false) {
                array_splice($values, $idx, 1);
                $result = implode(',', $values);
                return PageManager::edit($page_id, array($col => MySQL::cleanValue($result)));
            }
        }
        return false;
    }
}
/**
 * The integer value for event-type resources.
 * @var integer
 */
define_safe('RESOURCE_TYPE_EVENT', 20);
/**
 * The integer value for datasource-type resources.
 * @var integer
 */
define_safe('RESOURCE_TYPE_DS', 21);
require_once DOCROOT . '/vendor/autoload.php';
require_once 'class.image.php';
require_once CONFIG;
Symphony::initialiseConfiguration($settings);
// Setup the environment
if (method_exists('DateTimeObj', 'setSettings')) {
    DateTimeObj::setSettings($settings['region']);
} else {
    DateTimeObj::setDefaultTimezone($settings['region']['timezone']);
}
define_safe('MODE_NONE', 0);
define_safe('MODE_RESIZE', 1);
define_safe('MODE_RESIZE_CROP', 2);
define_safe('MODE_CROP', 3);
define_safe('MODE_FIT', 4);
define_safe('CACHING', $settings['image']['cache'] == 1 ? true : false);
set_error_handler('__errorHandler');
function processParams($string, &$image_settings)
{
    $param = (object) array('mode' => 0, 'width' => 0, 'height' => 0, 'position' => 0, 'background' => 0, 'file' => 0, 'external' => false);
    // Check for matching recipes
    if (file_exists(WORKSPACE . '/jit-image-manipulation/recipes.php')) {
        include WORKSPACE . '/jit-image-manipulation/recipes.php';
    }
    // check to see if $recipes is even available before even checking if it is an array
    if (!empty($recipes) && is_array($recipes)) {
        foreach ($recipes as $recipe) {
            // Is the mode regex? If so, bail early and let not JIT process it.
            if ($recipe['mode'] === 'regex' && preg_match($recipe['url-parameter'], $string)) {
                // change URL to a "normal" JIT URL
                $string = preg_replace($recipe['url-parameter'], $recipe['jit-parameter'], $string);
 function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         $entryManager = new EntryManager($this->_Parent);
         if (!($ret = $entryManager->fetch($entry_id))) {
             $this->_Parent->customError(E_USER_ERROR, __('Unknown Entry'), __('The entry you are looking for could not be found.'), false, true);
         }
         $entry = $ret[0];
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $error)) {
             $this->pageAlert($error['message'], Alert::ERROR);
         } else {
             ###
             # Delegate: EntryPreEdit
             # Description: Just prior to editing of an Entry.
             $this->_Parent->ExtensionManager->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             if (!$entry->commit()) {
                 define_safe('__SYM_DB_INSERT_FAILED__', true);
                 $this->pageAlert(NULL, Alert::ERROR);
             } else {
                 ###
                 # Delegate: EntryPostEdit
                 # Description: Editing an entry. Entry object is provided.
                 $this->_Parent->ExtensionManager->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 $prepopulate_field_id = $prepopulate_value = NULL;
                 if (isset($_POST['prepopulate'])) {
                     $prepopulate_field_id = array_shift(array_keys($_POST['prepopulate']));
                     $prepopulate_value = stripslashes(rawurldecode(array_shift($_POST['prepopulate'])));
                 }
                 //redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/edit/' . $entry_id . '/saved/');
                 redirect(sprintf('%s/symphony/publish/%s/edit/%d/saved%s/', URL, $this->_context['section_handle'], $entry->get('id'), !is_null($prepopulate_field_id) ? ":{$prepopulate_field_id}:{$prepopulate_value}" : NULL));
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         ###
         # Delegate: Delete
         # Description: Prior to deleting an entry. Entry ID is provided, as an array to remain compatible with other Delete delegate call
         Administration::instance()->ExtensionManager->notifyMembers('Delete', '/publish/', array('entry_id' => $entry_id));
         $entryManager = new EntryManager($this->_Parent);
         $entryManager->delete($entry_id);
         redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/');
     }
 }
 function __actionDo()
 {
     if (!isset($_POST['fields']['source']) or $_POST['fields']['source'] <= 0) {
         $this->_errors[] = 'You didn\'t choose a source, perhaps you don\'t have any sections with an upload field in them?';
         $this->_valid = false;
         return;
     }
     if (!isset($_POST['fields']['sourcedir']) or !preg_match('/^\\/workspace\\/uploads\\/mui/i', $_POST['fields']['sourcedir'])) {
         $this->_errors[] = 'Fail!';
         $this->_valid = false;
         return;
     }
     $this->_section_id = $_POST['fields']['source'];
     // section id
     $entryManager = new EntryManager($this->_Parent);
     $sectionManager = new SectionManager($this->_Parent);
     $section = $sectionManager->fetch($this->_section_id);
     // get all the fields for the types we support, and get ready to put the filename in them
     foreach ($this->_driver->getTypes() as $type) {
         $f = $section->fetchFields($type);
         if (count($f) > 0) {
             foreach ($f as $field) {
                 $field_names[] = $field;
             }
         }
         //array($field->get('element_name'), $field->get('destination'));
     }
     $files = General::listStructure(DOCROOT . $_POST['fields']['sourcedir']);
     if (count($files['filelist']) == 0) {
         $this->_errors[] = "There are no files in this directory: {$_POST['fields']['sourcedir']}.";
         $this->_valid = false;
         return;
     }
     // a list of all the entries so we can rollback
     $entries = array();
     foreach ($files['filelist'] as $k => $f) {
         $continue = false;
         $this->_files[] = $f;
         $entry =& $entryManager->create();
         $entry->set('section_id', $this->_section_id);
         $entry->set('author_id', $this->_Parent->Author->get('id'));
         $entry->set('creation_date', DateTimeObj::get('Y-m-d H:i:s'));
         $entry->set('creation_date_gmt', DateTimeObj::getGMT('Y-m-d H:i:s'));
         $chkfields = $fields = $_POST['fields'][$this->_section_id];
         // loop over all the supported fields
         foreach ($field_names as $field) {
             $dest = $field->get('destination');
             $name = $field->get('element_name');
             $tmp_name = DOCROOT . $_POST['fields']['sourcedir'] . '/' . $f;
             $new_name = DOCROOT . $dest . '/' . $f;
             /* if you don't want to rollback implement this */
             // if($field->get('validator') != NULL){
             //     $rule = $field->get('validator');
             //
             // 		// skip this file since it doesn't validate
             //     if(!General::validateString($tmp_name, $rule)) {
             // 			;
             // 			// $continue = true;
             // 		}
             // }
             $type = trim(shell_exec('file -b --mime ' . escapeshellarg($tmp_name)));
             $size = filesize($tmp_name);
             // setup fields to check the post
             $chkfields[$name][name] = $f;
             $chkfields[$name][type] = $type;
             $chkfields[$name][tmp_name] = $tmp_name;
             $chkfields[$name][error] = 0;
             $chkfields[$name][size] = $size;
             // an array to copy the files after
             $copy[] = array($tmp_name, $new_name);
             // setup upload fields as they should be as if they were processed
             $fields[$name][file] = preg_replace("/^\\/workspace/", '', $dest) . '/' . $f;
             $fields[$name][size] = $size;
             $fields[$name][mimetype] = $type;
             $fields[$name][meta] = serialize($this->getMetaInfo(DOCROOT . $fields[$name][file], $type));
         }
         // skip the file if it doesn't validate
         // if ($continue == true) continue;
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($chkfields, $this->_errors)) {
             $this->_ignored_files[] = $f;
             break;
         }
         // now we can copy the files to their new location since everything's validated
         foreach ($copy as $c) {
             if (@copy($c[0], $c[1])) {
                 @chmod($c[1], intval(0755, 8));
             } else {
                 $this->_errors[] = "Couldn't copy the files to the {$dest} directory. ";
                 return;
             }
         }
         // setup the data, process it
         if (__ENTRY_OK__ != $this->setDataFromPost($entry, $fields, $this->_errors, false, false, $entries)) {
             $this->_ignored_files[] = $f;
             break;
         }
         // commit the entry if we made it
         if (!$entry->commit()) {
             define_safe('__SYM_DB_INSERT_FAILED__', true);
         } else {
             $this->_valid = true;
         }
     }
     // rollback, delete all entries by id
     if ($this->_valid == false && count($entries) > 0) {
         $entryManager->delete($entries);
         return;
     }
     // if we made it here, and they want us to delete the files, it shall beDOCROOT . $_POST['fields']['sourcedir']
     if (isset($_POST['fields']['remove']) && $_POST['fields']['remove'] == 'on' && $this->_valid == true) {
         foreach ($files['filelist'] as $k => $f) {
             unlink(DOCROOT . $_POST['fields']['sourcedir'] . '/' . $f);
         }
         // already sanitized the sourcedir so no one can accidentally delete stuff
         // 	from anywhere but the uploads directory, make sure not to delete mui dir
         if ($_POST['fields']['sourcedir'] != '/workspace' . $this->_driver->getMUI()) {
             rmdir(DOCROOT . $_POST['fields']['sourcedir']);
         }
     }
     $this->_entries_count = count($files['filelist']) - count($this->_ignored_files);
 }
 public function initialiseCookie()
 {
     try {
         $cookie_path = parse_url(URL, PHP_URL_PATH);
         $cookie_path = '/' . trim($cookie_path, '/');
     } catch (Exception $e) {
         $cookie_path = '/';
     }
     define_safe('__SYM_COOKIE_PATH__', $cookie_path);
     define_safe('__SYM_COOKIE_PREFIX__', self::Configuration()->core()->symphony->{'cookie-prefix'});
     $this->Cookie = new Cookie(__SYM_COOKIE_PREFIX__, TWO_WEEKS, __SYM_COOKIE_PATH__);
 }
Exemple #13
0
 * @var string
 */
define_safe('HTTP_HOST', getenv('HTTP_HOST'));
/**
 * Returns the IP address of the machine that is viewing the current page.
 * @var string
 */
define_safe('REMOTE_ADDR', getenv('REMOTE_ADDR'));
/**
 * Returns the User Agent string of the browser that is viewing the current page
 * @var string
 */
define_safe('HTTP_USER_AGENT', getenv('HTTP_USER_AGENT'));
/**
 * If HTTPS is on, `__SECURE__` will be set to true, otherwise false
 * @var string|boolean
 */
define_safe('__SECURE__', HTTPS == 'on');
/**
 * The base URL of this Symphony install, minus the symphony path.
 * @var string
 */
define_safe('URL', 'http' . (defined('__SECURE__') && __SECURE__ ? 's' : '') . '://' . DOMAIN);
/**
 * Returns the URL + /symphony. This should be used whenever the a developer
 * wants to link to the Symphony root
 * @var string
 * @since Symphony 2.2
 */
define_safe('SYMPHONY_URL', URL . '/symphony');
 function __actionEdit()
 {
     if (empty($_POST['fields']['title'])) {
         $this->_errors = 'title';
         $this->pageAlert(__('%1$s', array(__('Title must not be empty'))), Alert::ERROR);
         return;
     }
     if (!$this->_driver->updateCat($_POST['fields'])) {
         define_safe('__SYM_DB_INSERT_FAILED__', true);
         $this->pageAlert(NULL, AdministrationPage::PAGE_ALERT_ERROR);
     } else {
         redirect(BASE_URL . '/edit/' . $this->_id . '/saved/');
     }
 }
Exemple #15
0
define_safe('SYMPHONY', DOCROOT . '/symphony');
define_safe('EXTENSIONS', DOCROOT . '/extensions');
define_safe('WORKSPACE', DOCROOT . '/workspace');
define_safe('LIBRARY', SYMPHONY . '/lib');
define_safe('ASSETS', SYMPHONY . '/assets');
define_safe('UTILITIES', WORKSPACE . '/utilities');
define_safe('DATASOURCES', WORKSPACE . '/data-sources');
define_safe('EVENTS', WORKSPACE . '/events');
define_safe('TEXTFORMATTERS', WORKSPACE . '/text-formatters');
define_safe('PAGES', WORKSPACE . '/pages');
define_safe('CACHE', MANIFEST . '/cache');
define_safe('TMP', MANIFEST . '/tmp');
define_safe('LOGS', MANIFEST . '/logs');
define_safe('CONFIG', MANIFEST . '/config.php');
define_safe('TOOLKIT', LIBRARY . '/toolkit');
define_safe('LANG', LIBRARY . '/lang');
define_safe('CORE', LIBRARY . '/core');
define_safe('BOOT', LIBRARY . '/boot');
define_safe('CONTENT', SYMPHONY . '/content');
define_safe('TEMPLATE', SYMPHONY . '/template');
define_safe('STARTTIME', precision_timer());
define_safe('TWO_WEEKS', 60 * 60 * 24 * 14);
define_safe('CACHE_LIFETIME', TWO_WEEKS);
define_safe('HTTPS', getenv('HTTPS'));
define_safe('HTTP_HOST', getenv('HTTP_HOST'));
define_safe('REMOTE_ADDR', getenv('REMOTE_ADDR'));
define_safe('HTTP_USER_AGENT', getenv('HTTP_USER_AGENT'));
define_safe('__SECURE__', HTTPS == 'on');
define_safe('URL', 'http' . (defined('__SECURE__') && __SECURE__ ? 's' : '') . '://' . DOMAIN);
define_safe('ACTIVITY_LOG', LOGS . '/main');
 function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         $entryManager = new EntryManager($this->_Parent);
         if (!($ret = $entryManager->fetch($entry_id))) {
             $this->_Parent->customError(E_USER_ERROR, __('Unknown Entry'), __('The entry you are looking for could not be found.'), false, true);
         }
         $entry = $ret[0];
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($entry->get('section_id'));
         $fields = $_POST['fields'];
         ## Combine FILES and POST arrays, indexed by their custom field handles
         if (isset($_FILES['fields'])) {
             $filedata = General::processFilePostData($_FILES['fields']);
             foreach ($filedata as $handle => $data) {
                 if (!isset($fields[$handle])) {
                     $fields[$handle] = $data;
                 } elseif (isset($data['error']) && $data['error'] == 4) {
                     $fields['handle'] = NULL;
                 } else {
                     foreach ($data as $ii => $d) {
                         if (isset($d['error']) && $d['error'] == 4) {
                             $fields[$handle][$ii] = NULL;
                         } elseif (is_array($d) && !empty($d)) {
                             foreach ($d as $key => $val) {
                                 $fields[$handle][$ii][$key] = $val;
                             }
                         }
                     }
                 }
             }
         }
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $error)) {
             $this->pageAlert($error['message'], Alert::ERROR);
         } else {
             ###
             # Delegate: EntryPreEdit
             # Description: Just prior to editing of an Entry.
             $this->_Parent->ExtensionManager->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             if (!$entry->commit()) {
                 define_safe('__SYM_DB_INSERT_FAILED__', true);
                 $this->pageAlert(NULL, Alert::ERROR);
             } else {
                 ###
                 # Delegate: EntryPostEdit
                 # Description: Editing an entry. Entry object is provided.
                 $this->_Parent->ExtensionManager->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/edit/' . $entry_id . '/saved/');
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         ## TODO: Fix Me
         ###
         # Delegate: Delete
         # Description: Prior to deleting an entry. Entry ID is provided.
         ##$ExtensionManager->notifyMembers('Delete', getCurrentPage(), array('entry_id' => $entry_id));
         $entryManager = new EntryManager($this->_Parent);
         $entryManager->delete($entry_id);
         redirect(URL . '/symphony/publish/' . $this->_context['section_handle'] . '/');
     }
 }
Exemple #17
0
        if (!is_array($associated_sections) || empty($associated_sections)) {
            return null;
        }
        $counts = array();
        foreach ($associated_sections as $as) {
            $field = FieldManager::fetch($as['child_section_field_id']);
            $parent_section_field_id = $as['parent_section_field_id'];
            $search_value = null;
            if (!is_null($parent_section_field_id)) {
                $search_value = $field->fetchAssociatedEntrySearchValue($this->getData($as['parent_section_field_id']), $as['parent_section_field_id'], $this->get('id'));
            } else {
                $search_value = $this->get('id');
            }
            $counts[$as['child_section_id']] = $field->fetchAssociatedEntryCount($search_value);
        }
        return $counts;
    }
}
/**
 * The constant for when an Entry is ok, that is, no errors have
 * been raised by any of it's Fields.
 * @var integer
 */
define_safe('__ENTRY_OK__', 0);
/**
 * The constant for an Entry if there is an error is raised by any of
 * it's Fields.
 * @var integer
 */
define_safe('__ENTRY_FIELD_ERROR__', 100);
Exemple #18
0
 function __actionNew()
 {
     if (empty($_POST['fields']['title'])) {
         $this->_errors = 'title';
         $this->pageAlert(__('Title is a required field'), Alert::ERROR);
         return;
     }
     if ($this->_driver->newCat($_POST['fields'])) {
         redirect(BASE_URL . '/tree/view/' . $_POST['fields']['parent'] . '/created/');
     } else {
         define_safe('__SYM_DB_INSERT_FAILED__', true);
         $this->pageAlert(NULL, AdministrationPage::PAGE_ALERT_ERROR);
     }
 }
 public function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         $entryManager = new EntryManager($this->_Parent);
         if (!($ret = $entryManager->fetch($entry_id))) {
             Administration::instance()->customError(__('Unknown Entry'), __('The entry you are looking for could not be found.'));
         }
         $entry = $ret[0];
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $error)) {
             $this->pageAlert($error['message'], Alert::ERROR);
         } else {
             /**
              * Just prior to editing of an Entry.
              *
              * @delegate EntryPreEdit
              * @param string $context
              * '/publish/edit/'
              * @param Section $section
              * @param Entry $entry
              * @param array $fields
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
             if (!$entry->commit()) {
                 define_safe('__SYM_DB_INSERT_FAILED__', true);
                 $this->pageAlert(NULL, Alert::ERROR);
             } else {
                 /**
                  * Just after the editing of an Entry
                  *
                  * @delegate EntryPostEdit
                  * @param string $context
                  * '/publish/edit/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                 $prepopulate_field_id = $prepopulate_value = NULL;
                 if (isset($_POST['prepopulate'])) {
                     $prepopulate_field_id = array_shift(array_keys($_POST['prepopulate']));
                     $prepopulate_value = stripslashes(rawurldecode(array_shift($_POST['prepopulate'])));
                 }
                 redirect(sprintf('%s/publish/%s/edit/%d/saved%s/', SYMPHONY_URL, $this->_context['section_handle'], $entry->get('id'), !is_null($prepopulate_field_id) ? ":{$prepopulate_field_id}:{$prepopulate_value}" : NULL));
             }
         }
     } elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
         /**
          * Prior to deletion of entries. Array of Entry ID's is provided.
          * The array can be manipulated
          *
          * @delegate Delete
          * @param string $context
          * '/publish/'
          * @param array $checked
          *  An array of Entry ID's passed by reference
          */
         Symphony::ExtensionManager()->notifyMembers('Delete', '/publish/', array('entry_id' => $entry_id));
         $entryManager = new EntryManager($this->_Parent);
         $entryManager->delete($entry_id);
         redirect(SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/');
     }
 }
<?php

require_once TOOLKIT . '/class.administrationpage.php';
define_safe('BASE_URL', URL . '/symphony/extension/configuration/settings');
class contentExtensionConfigurationSettings extends AdministrationPage
{
    private $_driver;
    private $_page;
    private $_flag;
    function __construct()
    {
        parent::__construct();
        $this->_driver = Symphony::ExtensionManager()->create('configuration');
    }
    function view()
    {
        $this->__switchboard();
    }
    function action()
    {
        $this->__switchboard('action');
        if (array_key_exists('save', $_POST['action'])) {
            $this->save();
        }
        if (array_key_exists('edit', $_POST['action'])) {
            $this->edit();
        }
    }
    function __switchboard($type = 'view')
    {
        $this->_page = $this->_context['0'];
$newsletter_id = $_SERVER['argv'][1];
$process_auth = $_SERVER['argv'][2];
$_SERVER['HTTP_HOST'] = $_SERVER['argv'][3];
// Generic Symphony includes & defines
define('DOCROOT', realpath(rtrim(dirname(__FILE__) . '/../../../', '\\/')));
define('DOMAIN', rtrim(rtrim($_SERVER['HTTP_HOST'], '\\/') . dirname($_SERVER['PHP_SELF']), '.\\/'));
define('HTTP_HOST', $_SERVER['HTTP_HOST']);
require_once DOCROOT . '/symphony/lib/boot/bundle.php';
//Inside bundle.php, the error_reporting is set again, but we don't want to be stopped by any other than fatal errors.
error_reporting(0);
require_once DOCROOT . '/symphony/lib/core/class.symphony.php';
require_once DOCROOT . '/symphony/lib/core/class.administration.php';
GenericErrorHandler::$enabled = false;
// ENM Specific includes & defines
define_safe('ENM_DIR', DOCROOT . '/extensions/email_newsletter_manager');
define_safe('ETM_DIR', DOCROOT . '/extensions/email_template_manager');
require_once ENM_DIR . '/lib/class.sendermanager.php';
require_once ENM_DIR . '/lib/class.recipientgroupmanager.php';
require_once ENM_DIR . '/lib/class.emailnewslettermanager.php';
require_once ENM_DIR . '/lib/class.emailbackgroundprocess.php';
// Needed to __construct() the Symphony class.
// This in turn is needed to get the Symphony::Database() functions working.
$thing = Administration::instance();
try {
    $newsletter = EmailNewsletterManager::create($newsletter_id);
    if (is_a($newsletter, 'EmailNewsletter')) {
        $newsletter->setPId(getmypid());
        $sending_settings = $newsletter->getSender()->about();
        if ($newsletter->sendBatch($process_auth) != 'completed') {
            time_sleep_until($start_time + $sending_settings['throttle-time']);
            EmailBackgroundProcess::spawnProcess($newsletter_id, $process_auth);
    public static function findParameterInEnv($needle, $env)
    {
        if (isset($env['env']['url'][$needle])) {
            return $env['env']['url'][$needle];
        }
        if (isset($env['env']['pool'][$needle])) {
            return $env['env']['pool'][$needle];
        }
        if (isset($env['param'][$needle])) {
            return $env['param'][$needle];
        }
        return null;
    }
}
/**
 * A constant that represents if this filter is an AND filter in which
 * an Entry must match all these filters
 * @var integer
 */
define_safe('DS_FILTER_AND', 1);
/**
 * A constant that represents if this filter is an OR filter in which an
 * entry can match any or all of these filters
 * @var integer
 */
define_safe('DS_FILTER_OR', 2);
require_once TOOLKIT . '/data-sources/class.datasource.author.php';
require_once TOOLKIT . '/data-sources/class.datasource.section.php';
require_once TOOLKIT . '/data-sources/class.datasource.static.php';
require_once TOOLKIT . '/data-sources/class.datasource.dynamic_xml.php';
require_once TOOLKIT . '/data-sources/class.datasource.navigation.php';
 public function __actionEdit()
 {
     $entry_id = intval($this->_context['entry_id']);
     if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
         if (!($ret = EntryManager::fetch($entry_id))) {
             Administration::instance()->customError(__('Unknown Entry'), __('The entry you are looking for could not be found.'));
         }
         $entry = $ret[0];
         $section = SectionManager::fetch($entry->get('section_id'));
         $post = General::getPostData();
         $fields = $post['fields'];
         // Initial checks to see if the Entry is ok
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $this->_errors)) {
             $this->pageAlert(__('Some errors were encountered while attempting to save.'), Alert::ERROR);
         } else {
             if (__ENTRY_OK__ != $entry->setDataFromPost($fields, $errors)) {
                 foreach ($errors as $field_id => $message) {
                     $this->pageAlert($message, Alert::ERROR);
                 }
             } else {
                 /**
                  * Just prior to editing of an Entry.
                  *
                  * @delegate EntryPreEdit
                  * @param string $context
                  * '/publish/edit/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPreEdit', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
                 // Check to see if the dancing was premature
                 if (!$entry->commit()) {
                     define_safe('__SYM_DB_INSERT_FAILED__', true);
                     $this->pageAlert(NULL, Alert::ERROR);
                 } else {
                     /**
                      * Just after the editing of an Entry
                      *
                      * @delegate EntryPostEdit
                      * @param string $context
                      * '/publish/edit/'
                      * @param Section $section
                      * @param Entry $entry
                      * @param array $fields
                      */
                     Symphony::ExtensionManager()->notifyMembers('EntryPostEdit', '/publish/edit/', array('section' => $section, 'entry' => $entry, 'fields' => $fields));
                     $prepopulate_querystring = '';
                     if (isset($_POST['prepopulate'])) {
                         foreach ($_POST['prepopulate'] as $field_id => $value) {
                             $prepopulate_querystring .= sprintf("prepopulate[%s]=%s&", $field_id, $value);
                         }
                         $prepopulate_querystring = trim($prepopulate_querystring, '&');
                     }
                     redirect(sprintf('%s/publish/%s/edit/%d/saved/%s', SYMPHONY_URL, $this->_context['section_handle'], $entry->get('id'), !empty($prepopulate_querystring) ? "?" . $prepopulate_querystring : NULL));
                 }
             }
         }
     } else {
         if (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
             /**
              * Prior to deletion of entries. An array of Entry ID's is provided which
              * can be manipulated. This delegate was renamed from `Delete` to `EntryPreDelete`
              * in Symphony 2.3.
              *
              * @delegate EntryPreDelete
              * @param string $context
              * '/publish/'
              * @param array $entry_id
              *	An array of Entry ID's passed by reference
              */
             $checked = array($entry_id);
             Symphony::ExtensionManager()->notifyMembers('EntryPreDelete', '/publish/', array('entry_id' => &$checked));
             EntryManager::delete($checked);
             /**
              * After the deletion of entries, this delegate provides an array of Entry ID's
              * that were deleted.
              *
              * @since Symphony 2.3
              * @delegate EntryPostDelete
              * @param string $context
              * '/publish/'
              * @param array $entry_id
              *  An array of Entry ID's that were deleted.
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPostDelete', '/publish/', array('entry_id' => $checked));
             redirect(SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/');
         }
     }
 }
<?php

include_once TOOLKIT . '/class.manager.php';
include_once TOOLKIT . '/class.extension.php';
define_safe('EXTENSION_ENABLED', 10);
define_safe('EXTENSION_DISABLED', 11);
define_safe('EXTENSION_NOT_INSTALLED', 12);
define_safe('EXTENSION_REQUIRES_UPDATE', 13);
class ExtensionManager extends Manager
{
    function __getClassName($name)
    {
        return 'extension_' . $name;
    }
    function __getClassPath($name)
    {
        return EXTENSIONS . strtolower("/{$name}");
    }
    function __getDriverPath($name)
    {
        return $this->__getClassPath($name) . '/extension.driver.php';
    }
    function getClassPath($name)
    {
        return EXTENSIONS . strtolower("/{$name}");
    }
    function sortByStatus($s1, $s2)
    {
        if ($s1['status'] == EXTENSION_ENABLED) {
            $status_s1 = 2;
        } elseif (in_array($s1['status'], array(EXTENSION_DISABLED, EXTENSION_NOT_INSTALLED, EXTENSION_REQUIRES_UPDATE))) {
Exemple #25
0
<?php

if (!defined('__IN_SYMPHONY__')) {
    die('<h2>Symphony Error</h2><p>You cannot directly access this file</p>');
}
define_safe(IMAGE_UPLOAD_NAME, 'Image Upload');
define_safe(IMAGE_UPLOAD_GROUP, 'image_upload');
class extension_image_upload extends Extension
{
    /*------------------------------------------------------------------------------------------------*/
    /*  Installation  */
    /*------------------------------------------------------------------------------------------------*/
    public function install()
    {
        return Symphony::Database()->query("CREATE TABLE `tbl_fields_image_upload` (\n\t\t\t\t `id` int(11) unsigned NOT NULL auto_increment,\n\t\t\t\t `field_id` int(11) unsigned NOT NULL,\n\t\t\t\t `destination` varchar(255) NOT NULL,\n\t\t\t\t `validator` varchar(50),\n\t\t\t\t `unique`  varchar(50),\n\t\t\t\t `min_width` int(11) unsigned,\n\t\t\t\t `min_height` int(11) unsigned,\n\t\t\t\t `max_width` int(11) unsigned,\n\t\t\t\t `max_height` int(11) unsigned,\n\t\t\t\t `resize` enum('yes','no') NOT NULL DEFAULT 'yes',\n\t\t\t\t  PRIMARY KEY (`id`),\n\t\t\t\t  KEY `field_id` (`field_id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
    }
    public function update($previousVersion = false)
    {
        // everything is OK by default
        $ret = true;
        // Before 1.1
        if ($ret && version_compare($previousVersion, '1.1', '<')) {
            $query = "ALTER TABLE `tbl_fields_image_upload`\n\t\t\t\t\tADD `max_width` int(11) unsigned,\n\t\t\t\t\tADD `max_height` int(11) unsigned,\n\t\t\t\t\tDEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
            try {
                Symphony::Database()->query($query);
            } catch (Exception $e) {
            }
        }
        // Before 1.3
        if ($ret && version_compare($previousVersion, '1.3', '<')) {
            $query = "ALTER TABLE `tbl_fields_image_upload`\n\t\t\t\t\t\t\tADD COLUMN `resize` enum('yes','no') NOT NULL DEFAULT 'yes'";
        $param->external = (bool) $matches[0][4];
        $param->file = $matches[0][5];
    } elseif (preg_match_all('/^1\\/([0-9]+)\\/([0-9]+)\\/(?:(0|1)\\/)?(.+)$/i', $string, $matches, PREG_SET_ORDER)) {
        $param->mode = 1;
        $param->width = $matches[0][1];
        $param->height = $matches[0][2];
        $param->external = (bool) $matches[0][3];
        $param->file = $matches[0][4];
    } elseif (preg_match_all('/^(?:(0|1)\\/)?(.+)$/i', $string, $matches, PREG_SET_ORDER)) {
        $param->external = (bool) $matches[0][1];
        $param->file = $matches[0][2];
    }
    return $param;
}
$param = processParams($_GET['param']);
define_safe('CACHING', $param->external == false && $settings['image']['cache'] == 1 ? true : false);
function __errorHandler($errno = NULL, $errstr, $errfile = NULL, $errline = NULL, $errcontext = NULL)
{
    global $param;
    if (error_reporting() != 0 && in_array($errno, array(E_WARNING, E_USER_WARNING, E_ERROR, E_USER_ERROR))) {
        $Log = new Log(ACTIVITY_LOG);
        $Log->pushToLog("{$errno} - " . strip_tags(is_object($errstr) ? $errstr->generate() : $errstr) . ($errfile ? " in file {$errfile}" : '') . ($errline ? " on line {$errline}" : ''), $errno == E_WARNING || $errno == E_USER_WARNING ? Log::WARNING : Log::ERROR, true);
        /*
        		stdClass Object
        		(
        		    [mode] => 1
        		    [width] => 100
        		    [height] => 210
        		    [position] => 0
        		    [background] => 0
        		    [file] => dimages/ribbon.gif
     * Given a string, this will clean it for use as a filename. Preserves multi-byte characters.
     *
     * @param string $string
     *	String to be cleaned up
     * @param string $delim
     *	Replacement for invalid characters
     * @param boolean $apply_transliteration
     *	If true, umlauts and special characters will be substituted
     * @return string
     *	Returns created filename
     */
    public static function createFilename($string, $delim = '-', $apply_transliteration = true)
    {
        // Use the transliteration table if provided
        if ($apply_transliteration == true) {
            $string = _t($string);
        }
        return General::createFilename($string, $delim);
    }
}
/**
 * Status when a language is installed and enabled
 * @var integer
 */
define_safe('LANGUAGE_ENABLED', 10);
/**
 * Status when a language is disabled
 * @var integer
 */
define_safe('LANGUAGE_DISABLED', 11);
Exemple #28
0
 function __actionEdit()
 {
     if (@array_key_exists('update', $_POST['action'])) {
         if (empty($_POST['fields']['title'])) {
             $this->_errors = 'title';
             $this->pageAlert(__('Title is a required field'), Alert::ERROR);
             return;
         }
         if ($this->_driver->edit($_POST)) {
             redirect(BASE_URL . '/list/edit/' . $this->_id . '/edited/');
         } else {
             define_safe('__SYM_DB_INSERT_FAILED__', true);
             $this->pageAlert('Error', Alert::ERROR);
         }
     }
     if (@array_key_exists("delete", $_POST['action'])) {
         if ($this->_driver->delete($_POST)) {
             redirect(BASE_URL . '/list/view/' . $_POST['fields']['parent'] . '/deleted/');
         } else {
             define_safe('__SYM_DB_INSERT_FAILED__', true);
             $this->pageAlert('Error', Alert::ERROR);
         }
     }
 }
 public function cbInitialiseCookie()
 {
     require_once 'lib/class.cookie.php';
     try {
         $cookie_path = parse_url(URL, PHP_URL_PATH);
         $cookie_path = '/' . trim($cookie_path, '/');
     } catch (Exception $e) {
         $cookie_path = '/';
     }
     define_safe('UAC_COOKIE_PATH', $cookie_path);
     define_safe('UAC_COOKIE_PREFIX', Symphony::Configuration()->uac()->{'cookie-prefix'});
     self::$Cookie = new Cookie(UAC_COOKIE_PREFIX, TWO_WEEKS, UAC_COOKIE_PATH, NULL, 'tbl_uac_sessions');
 }
Exemple #30
0
<?php

define_safe('PROFILE_RUNNING_TOTAL', 0);
define_safe('PROFILE_LAP', 1);
class Profiler
{
    var $_starttime;
    var $_records;
    var $_seed;
    function Profiler()
    {
        $this->_records = array();
        $this->_starttime = precision_timer();
        $this->_seed = NULL;
    }
    function retrieveLast()
    {
        return end($this->_records);
    }
    function retrieveTotalRunningTime()
    {
        $last = $this->retrieveLast();
        return $last[1];
    }
    function sample($msg, $type = PROFILE_RUNNING_TOTAL, $group = 'General')
    {
        $start = NULL;
        if ($type == PROFILE_RUNNING_TOTAL) {
            $this->_records[] = array($msg, precision_timer('stop', $this->_starttime), precision_timer(), $group);
        } else {
            if ($this->_seed) {