public static function saveVersion($entry, $fields, $is_update)
 {
     // list existing versions of this entry
     $existing_versions = General::listStructure(MANIFEST . '/versions/' . $entry->get('id') . '/', '/.xml$/');
     // create folder
     if (!file_exists(MANIFEST . '/versions/' . $entry->get('id'))) {
         General::realiseDirectory(MANIFEST . '/versions/' . $entry->get('id'));
     }
     // max version number
     $new_version_number = count($existing_versions['filelist']);
     $new_version_number++;
     if ($is_update) {
         $new_version_number--;
     }
     if ($new_version_number == 0) {
         $new_version_number++;
     }
     unset($fields['entry-versions']);
     // run custom DS to get the built XML of this entry
     $ds = new EntryVersionsXMLDataSource(self::Context(), null, false);
     $ds->dsParamINCLUDEDELEMENTS = array_keys($fields);
     $ds->dsParamFILTERS['id'] = $entry->get('id');
     $ds->dsSource = (string) $entry->get('section_id');
     $param_pool = array();
     $entry_xml = $ds->grab($param_pool);
     // get text value of the entry
     $proc = new XsltProcess();
     $data = $proc->process($entry_xml->generate(), file_get_contents(EXTENSIONS . '/entry_versions/lib/entry-version.xsl'), array('version' => $new_version_number, 'created-by' => self::Context()->Author ? self::Context()->Author->getFullName() : '', 'created-date' => date('Y-m-d', time()), 'created-time' => date('H:i', time())));
     $write = General::writeFile(MANIFEST . '/versions/' . $entry->get('id') . '/' . $new_version_number . '.xml', $data);
     General::writeFile(MANIFEST . '/versions/' . $entry->get('id') . '/' . $new_version_number . '.dat', self::serializeEntry($entry));
     return $new_version_number;
 }
 public function update($previousVersion = false)
 {
     if (version_compare($previousVersion, '1.21', '<')) {
         // Simplify JIT htaccess rule [#75]
         try {
             $htaccess = file_get_contents(DOCROOT . '/.htaccess');
             $htaccess = str_replace('RewriteRule ^image\\/(.+\\.(jpg|gif|jpeg|png|bmp))$', 'RewriteRule ^image\\/(.+)$', $htaccess);
         } catch (Exception $ex) {
             if (!file_put_contents(DOCROOT . '/.htaccess', $htaccess)) {
                 Administration::instance()->Page->pageAlert(__('An error occurred while updating %s. %s', array(__('JIT Image Manipulation'), $ex->getMessage())), Alert::ERROR);
                 return false;
             }
         }
     }
     if (version_compare($previousVersion, '1.17', '<')) {
         // Add [B] flag to the .htaccess rule [#37]
         try {
             $htaccess = file_get_contents(DOCROOT . '/.htaccess');
             $htaccess = str_replace('extensions/jit_image_manipulation/lib/image.php?param={$token} [L,NC]', 'extensions/jit_image_manipulation/lib/image.php?param={$token} [B,L,NC]', $htaccess);
         } catch (Exception $ex) {
             if (!file_put_contents(DOCROOT . '/.htaccess', $htaccess)) {
                 Administration::instance()->Page->pageAlert(__('An error occurred while updating %s. %s', array(__('JIT Image Manipulation'), $ex->getMessage())), Alert::ERROR);
                 return false;
             }
         }
     }
     if (version_compare($previousVersion, '1.15', '<')) {
         // Move /manifest/jit-trusted-sites into /workspace/jit-image-manipulation
         if (General::realiseDirectory(WORKSPACE . '/jit-image-manipulation', Symphony::Configuration()->get('write_mode', 'directory')) && file_exists(MANIFEST . '/jit-trusted-sites')) {
             rename(MANIFEST . '/jit-trusted-sites', WORKSPACE . '/jit-image-manipulation/trusted-sites');
         }
     }
 }
Пример #3
0
 public function install()
 {
     Symphony::Configuration()->set('lang', 'en', 'redactor');
     Symphony::Configuration()->set('direction_ltr', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_toolbar', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_source', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_focus', 'no', 'redactor');
     Symphony::Configuration()->set('enable_shortcuts', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_autoresizing', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_cleanup', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_fixed', 'no', 'redactor');
     Symphony::Configuration()->set('enable_fixedbox', 'no', 'redactor');
     Symphony::Configuration()->set('enable_paragraphy', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_convertlinks', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_convertdivs', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_fileupload', 'no', 'redactor');
     Symphony::Configuration()->set('enable_imageupload', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_overlay', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_observeimages', 'yes', 'redactor');
     Symphony::Configuration()->set('enable_airmode', 'no', 'redactor');
     Symphony::Configuration()->set('enable_wym', 'no', 'redactor');
     Symphony::Configuration()->set('enable_mobile', 'yes', 'redactor');
     Symphony::Configuration()->set('buttons', implode($this->buttons, ','), 'redactor');
     Symphony::Configuration()->set('airbuttons', implode($this->airbuttons, ','), 'redactor');
     Symphony::Configuration()->set('allowedtags', implode($this->allowedtags, ','), 'redactor');
     Symphony::Configuration()->set('filepath', WORKSPACE . '/redactor/files', 'redactor');
     Symphony::Configuration()->set('imagepath', WORKSPACE . '/redactor/images', 'redactor');
     Symphony::Configuration()->write();
     return General::realiseDirectory(Symphony::Configuration()->get('filepath', 'redactor')) && General::realiseDirectory(Symphony::Configuration()->get('imagepath', 'redactor'));
 }
Пример #4
0
 public function install()
 {
     $result = true;
     if (!file_exists(TEXTFORMATTERS)) {
         $result = General::realiseDirectory(TEXTFORMATTERS, $this->_Parent->Configuration->get('write_mode', 'directory'));
     }
     return $result;
 }
 public function install()
 {
     $result = true;
     if (!file_exists(TEXTFORMATTERS)) {
         $result = General::realiseDirectory(TEXTFORMATTERS, Symphony::Configuration()->get('write_mode', 'directory'));
     }
     return $result;
 }
 public function install()
 {
     @General::realiseDirectory(WORKSPACE . '/sections');
     @General::realiseDirectory(WORKSPACE . '/pages');
     Symphony::Database()->query("ALTER TABLE `tbl_sections` ADD `guid` varchar(13) NOT NULL AFTER `navigation_group`");
     Symphony::Database()->query("ALTER TABLE `tbl_fields` ADD `guid` varchar(13) NOT NULL AFTER `show_column`");
     Symphony::Database()->query("ALTER TABLE `tbl_pages` ADD `guid` varchar(13) NOT NULL AFTER `sortorder`");
     return true;
 }
 public function update($previousVersion = false)
 {
     if (version_compare($previousVersion, '1.15', '<')) {
         // Move /manifest/jit-trusted-sites into /workspace/jit-image-manipulation
         if (General::realiseDirectory(WORKSPACE . '/jit-image-manipulation', Symphony::Configuration()->get('write_mode', 'directory')) && file_exists(MANIFEST . '/jit-trusted-sites')) {
             rename(MANIFEST . '/jit-trusted-sites', WORKSPACE . '/jit-image-manipulation/trusted-sites');
         }
     }
 }
Пример #8
0
 public function install()
 {
     if (file_exists(WORKSPACE . $this->upload)) {
         return true;
     }
     if (!General::realiseDirectory(WORKSPACE . $this->upload, intval('0755', 8))) {
         return false;
     }
     return true;
 }
Пример #9
0
 public function install()
 {
     // create tables
     Symphony::Database()->query("CREATE TABLE `tbl_elasticsearch_logs` (\n\t\t\t\t  `id` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t  `date` datetime NOT NULL,\n\t\t\t\t  `keywords` varchar(255) DEFAULT NULL,\n\t\t\t\t  `keywords_raw` varchar(255) DEFAULT NULL,\n\t\t\t\t  `sections` varchar(255) DEFAULT NULL,\n\t\t\t\t  `page` int(11) NOT NULL,\n\t\t\t\t  `results` int(11) DEFAULT NULL,\n\t\t\t\t  `session_id` varchar(255) DEFAULT NULL,\n\t\t\t\t  `user_agent` varchar(255) DEFAULT NULL,\n\t\t\t\t  `ip` varchar(255) DEFAULT NULL,\n\t\t\t\t  PRIMARY KEY (`id`),\n\t\t\t\t  UNIQUE KEY `id` (`id`),\n\t\t\t\t  KEY `keywords` (`keywords`),\n\t\t\t\t  KEY `date` (`date`),\n\t\t\t\t  KEY `session_id` (`session_id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
     // create config defaults
     Symphony::Configuration()->setArray(array('elasticsearch' => array('host' => '', 'index-name' => '', 'reindex-batch-size' => 20, 'reindex-batch-delay' => 0, 'per-page' => 20, 'sort' => '_score', 'direction' => 'desc', 'highlight-fragment-size' => 200, 'highlight-per-field' => 1, 'build-entry-xml' => 'no', 'default-sections' => '', 'default-language' => '', 'log-searches' => 'yes')));
     Administration::instance()->saveConfig();
     // create workspace structure
     $config = (object) Symphony::Configuration()->get('directory');
     General::realiseDirectory(WORKSPACE . '/elasticsearch', $config->{'write_mode'});
     General::writeFile(WORKSPACE . '/elasticsearch/.htaccess', file_get_contents(EXTENSIONS . '/elasticsearch/templates/.htaccess'), $config->{'write_mode'});
     General::writeFile(WORKSPACE . '/elasticsearch/index.json', file_get_contents(EXTENSIONS . '/elasticsearch/templates/index.json'), $config->{'write_mode'});
     General::realiseDirectory(WORKSPACE . '/elasticsearch/mappings', $config->{'write_mode'});
 }
 public function update($previousVersion = false)
 {
     require_once 'lib/class.htaccess.php';
     $htaccess = new HTAccess();
     if ($htaccess->exists() && !$htaccess->is_writable()) {
         throw new Exception(__('.htaccess exists but is not writable.'));
     }
     if (version_compare($previousVersion, '1.15', '<')) {
         // Move /manifest/jit-trusted-sites into /workspace/jit-image-manipulation
         if (General::realiseDirectory(WORKSPACE . '/jit-image-manipulation', Symphony::Configuration()->get('write_mode', 'directory')) && file_exists(MANIFEST . '/jit-trusted-sites')) {
             if (!@rename(MANIFEST . '/jit-trusted-sites', WORKSPACE . '/jit-image-manipulation/trusted-sites')) {
                 $message = __('An error occured while updating %s. Could not move the trusted file to %s', array(__('JIT Image Manipulation'), WORKSPACE . '/jit-image-manipulation/trusted-sites'));
                 throw new Exception($message);
             }
         }
     }
     if (version_compare($previousVersion, '1.17', '<')) {
         // Add [B] flag to the .htaccess rule [#37]
         try {
             if ($htaccess->exists()) {
                 $htaccess->addBFlagToRule();
             }
         } catch (Exception $ex) {
             $message = __('An error occured while updating %s. %s', array(__('JIT Image Manipulation'), $ex->getMessage()));
             throw new Exception($message);
         }
     }
     if (version_compare($previousVersion, '1.21', '<')) {
         try {
             // Simplify JIT htaccess rule [#75]
             if ($htaccess->exists()) {
                 $htaccess->simplifyJITAccessRule();
             }
         } catch (Exception $ex) {
             $message = __('An error occured while updating %s. %s', array(__('JIT Image Manipulation'), $ex->getMessage()));
             throw new Exception($message);
         }
     }
     if (version_compare($previousVersion, '2.0.0', '<')) {
         try {
             if ($htaccess->exists()) {
                 $htaccess->transformRuleToSymphonyLauncher();
             }
         } catch (Exception $ex) {
             $message = __('An error occured while updating %s. %s', array(__('JIT Image Manipulation'), $ex->getMessage()));
             throw new Exception($message);
         }
     }
 }
Пример #11
0
 public function install()
 {
     General::realiseDirectory(CACHE . '/sass_compiler/', Symphony::Configuration()->get('write_mode', 'directory'));
     $htaccess = @file_get_contents(DOCROOT . '/.htaccess');
     if ($htaccess === false) {
         return false;
     }
     ## Cannot use $1 in a preg_replace replacement string, so using a token instead
     $token = md5(time());
     $rule = "\n\t### SASS RULES\n\tRewriteRule ^sass\\/(.+\\.sass)\$ extensions/sass_compiler/lib/sass.php?mode=sass&param={$token} [L,NC]\n\tRewriteRule ^scss\\/(.+\\.scss)\$ extensions/sass_compiler/lib/sass.php?mode=scss&param={$token} [L,NC]\n\n";
     ## Remove existing rules
     $htaccess = self::__removeSassRules($htaccess);
     if (preg_match('/### SASS RULES/', $htaccess)) {
         $htaccess = preg_replace('/### SASS RULES/', $rule, $htaccess);
     } else {
         $htaccess = preg_replace('/RewriteRule .\\* - \\[S=14\\]\\s*/i', "RewriteRule .* - [S=14]\n{$rule}\t", $htaccess);
     }
     ## Replace the token with the real value
     $htaccess = str_replace($token, '$1', $htaccess);
     return @file_put_contents(DOCROOT . '/.htaccess', $htaccess);
 }
 /**
  * Serialises the data source object properties into a checksum hash to see
  * whether the data source is currently cached, and whether it has expired.
  * Returns boolean of whether the data source is stale or not.
  *
  * @param Datasource $datasource
  *  The current data source object
  * @param string $filename
  *  Cache filename, passed by reference
  * @param int $file_age
  *  Cache file age (in seconds), passed by reference
  */
 private function __buildCacheFilename($datasource, &$filename, &$file_age)
 {
     $filename = null;
     // Checks if cacheabledatasource directory exists. If not, try to restore.
     if (!file_exists(CACHE . '/cacheabledatasource')) {
         if (!General::realiseDirectory(CACHE . '/cacheabledatasource', Symphony::Configuration()->get('write_mode', 'directory'))) {
             throw new Exception(__('Cacheable Datasource: Cache directory could not be restored at %s.', array('<code>/manifest/cache/cacheabledatasource</code>')));
         }
     }
     // get resolved values of each public property of this DS
     // (sort, filters, included elements etc.)
     foreach (get_class_vars(get_class($datasource)) as $key => $value) {
         if (substr($key, 0, 2) == 'ds') {
             $value = $datasource->{$key};
             $filename .= $key . (is_array($value) ? http_build_query($value) : $value);
         }
     }
     $filename = sprintf("%s/cache/cacheabledatasource/%s_%s.xml", MANIFEST, preg_replace("/^datasource/", '', get_class($datasource)), md5($filename));
     if (!file_exists($filename)) {
         return false;
     }
     $file_age = (int) floor(time() - filemtime($filename));
     return $file_age < $datasource->dsParamCACHE;
 }
Пример #13
0
 private static function __install()
 {
     $fields = $_POST['fields'];
     $start = time();
     Symphony::Log()->writeToLog(PHP_EOL . '============================================', true);
     Symphony::Log()->writeToLog('INSTALLATION PROCESS STARTED (' . DateTimeObj::get('c') . ')', true);
     Symphony::Log()->writeToLog('============================================', true);
     // MySQL: Establishing connection
     Symphony::Log()->pushToLog('MYSQL: Establishing Connection', E_NOTICE, true, true);
     try {
         Symphony::Database()->connect($fields['database']['host'], $fields['database']['user'], $fields['database']['password'], $fields['database']['port'], $fields['database']['db']);
     } catch (DatabaseException $e) {
         self::__abort('There was a problem while trying to establish a connection to the MySQL server. Please check your settings.', $start);
     }
     // MySQL: Setting prefix & character encoding
     Symphony::Database()->setPrefix($fields['database']['tbl_prefix']);
     Symphony::Database()->setCharacterEncoding();
     Symphony::Database()->setCharacterSet();
     // MySQL: Importing schema
     Symphony::Log()->pushToLog('MYSQL: Importing Table Schema', E_NOTICE, true, true);
     try {
         Symphony::Database()->import(file_get_contents(INSTALL . '/includes/install.sql'), true);
     } catch (DatabaseException $e) {
         self::__abort('There was an error while trying to import data to the database. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getDatabaseErrorMessage(), $start);
     }
     // MySQL: Creating default author
     Symphony::Log()->pushToLog('MYSQL: Creating Default Author', E_NOTICE, true, true);
     try {
         Symphony::Database()->insert(array('id' => 1, 'username' => Symphony::Database()->cleanValue($fields['user']['username']), 'password' => Cryptography::hash(Symphony::Database()->cleanValue($fields['user']['password'])), 'first_name' => Symphony::Database()->cleanValue($fields['user']['firstname']), 'last_name' => Symphony::Database()->cleanValue($fields['user']['lastname']), 'email' => Symphony::Database()->cleanValue($fields['user']['email']), 'last_seen' => NULL, 'user_type' => 'developer', 'primary' => 'yes', 'default_area' => NULL, 'auth_token_active' => 'no'), 'tbl_authors');
     } catch (DatabaseException $e) {
         self::__abort('There was an error while trying create the default author. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getDatabaseErrorMessage(), $start);
     }
     // Configuration: Populating array
     $conf = Symphony::Configuration()->get();
     foreach ($conf as $group => $settings) {
         foreach ($settings as $key => $value) {
             if (isset($fields[$group]) && isset($fields[$group][$key])) {
                 $conf[$group][$key] = $fields[$group][$key];
             }
         }
     }
     // Create manifest folder structure
     Symphony::Log()->pushToLog('WRITING: Creating ‘manifest’ folder (/manifest)', E_NOTICE, true, true);
     if (!General::realiseDirectory(DOCROOT . '/manifest', $conf['directory']['write_mode'])) {
         self::__abort('Could not create ‘manifest’ directory. Check permission on the root folder.', $start);
     }
     Symphony::Log()->pushToLog('WRITING: Creating ‘logs’ folder (/manifest/logs)', E_NOTICE, true, true);
     if (!General::realiseDirectory(DOCROOT . '/manifest/logs', $conf['directory']['write_mode'])) {
         self::__abort('Could not create ‘logs’ directory. Check permission on /manifest.', $start);
     }
     Symphony::Log()->pushToLog('WRITING: Creating ‘cache’ folder (/manifest/cache)', E_NOTICE, true, true);
     if (!General::realiseDirectory(DOCROOT . '/manifest/cache', $conf['directory']['write_mode'])) {
         self::__abort('Could not create ‘cache’ directory. Check permission on /manifest.', $start);
     }
     Symphony::Log()->pushToLog('WRITING: Creating ‘tmp’ folder (/manifest/tmp)', E_NOTICE, true, true);
     if (!General::realiseDirectory(DOCROOT . '/manifest/tmp', $conf['directory']['write_mode'])) {
         self::__abort('Could not create ‘tmp’ directory. Check permission on /manifest.', $start);
     }
     // Writing configuration file
     Symphony::Log()->pushToLog('WRITING: Configuration File', E_NOTICE, true, true);
     Symphony::Configuration()->setArray($conf);
     if (!Symphony::Configuration()->write(CONFIG, $conf['file']['write_mode'])) {
         self::__abort('Could not create config file ‘' . CONFIG . '’. Check permission on /manifest.', $start);
     }
     // Writing htaccess file
     Symphony::Log()->pushToLog('CONFIGURING: Frontend', E_NOTICE, true, true);
     $rewrite_base = ltrim(preg_replace('/\\/install$/i', NULL, dirname($_SERVER['PHP_SELF'])), '/');
     $htaccess = str_replace('<!-- REWRITE_BASE -->', $rewrite_base, file_get_contents(INSTALL . '/includes/htaccess.txt'));
     if (!General::writeFile(DOCROOT . "/.htaccess", $htaccess, $conf['file']['write_mode'], 'a')) {
         self::__abort('Could not write ‘.htaccess’ file. Check permission on ' . DOCROOT, $start);
     }
     // Writing /workspace folder
     if (!is_dir(DOCROOT . '/workspace')) {
         // Create workspace folder structure
         Symphony::Log()->pushToLog('WRITING: Creating ‘workspace’ folder (/workspace)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace’ directory. Check permission on the root folder.', $start);
         }
         Symphony::Log()->pushToLog('WRITING: Creating ‘data-sources’ folder (/workspace/data-sources)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace/data-sources', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace/data-sources’ directory. Check permission on the root folder.', $start);
         }
         Symphony::Log()->pushToLog('WRITING: Creating ‘events’ folder (/workspace/events)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace/events', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace/events’ directory. Check permission on the root folder.', $start);
         }
         Symphony::Log()->pushToLog('WRITING: Creating ‘pages’ folder (/workspace/pages)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace/pages', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace/pages’ directory. Check permission on the root folder.', $start);
         }
         Symphony::Log()->pushToLog('WRITING: Creating ‘utilities’ folder (/workspace/utilities)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace/utilities', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace/utilities’ directory. Check permission on the root folder.', $start);
         }
     } else {
         Symphony::Log()->pushToLog('An existing ‘workspace’ directory was found at this location. Symphony will use this workspace.', E_NOTICE, true, true);
         // MySQL: Importing workspace data
         Symphony::Log()->pushToLog('MYSQL: Importing Workspace Data...', E_NOTICE, true, true);
         if (is_file(DOCROOT . '/workspace/install.sql')) {
             try {
                 Symphony::Database()->import(file_get_contents(DOCROOT . '/workspace/install.sql'), $fields['database']['use-server-encoding'] != 'yes' ? true : false, true);
             } catch (DatabaseException $e) {
                 self::__abort('There was an error while trying to import data to the database. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getDatabaseErrorMessage(), $start);
             }
         }
     }
     // Write extensions folder
     if (!is_dir(DOCROOT . '/extensions')) {
         // Create extensions folder
         Symphony::Log()->pushToLog('WRITING: Creating ‘extensions’ folder (/extensions)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/extensions', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘extension’ directory. Check permission on the root folder.', $start);
         }
     }
     // Install existing extensions
     Symphony::Log()->pushToLog('CONFIGURING: Installing existing extensions', E_NOTICE, true, true);
     $disabled_extensions = array();
     foreach (new DirectoryIterator(EXTENSIONS) as $e) {
         if ($e->isDot() || $e->isFile() || !is_file($e->getRealPath() . '/extension.driver.php')) {
             continue;
         }
         $handle = $e->getBasename();
         try {
             if (!ExtensionManager::enable($handle)) {
                 $disabled_extensions[] = $handle;
                 Symphony::Log()->pushToLog('Could not enable the extension ‘' . $handle . '’.', E_NOTICE, true, true);
             }
         } catch (Exception $ex) {
             $disabled_extensions[] = $handle;
             Symphony::Log()->pushToLog('Could not enable the extension ‘' . $handle . '’. ' . $ex->getMessage(), E_NOTICE, true, true);
         }
     }
     // Loading default language
     if (isset($_REQUEST['lang']) && $_REQUEST['lang'] != 'en') {
         Symphony::Log()->pushToLog('CONFIGURING: Default language', E_NOTICE, true, true);
         $language = Lang::Languages();
         $language = $language[$_REQUEST['lang']];
         // Is the language extension enabled?
         if (in_array('lang_' . $language['handle'], ExtensionManager::listInstalledHandles())) {
             Symphony::Configuration()->set('lang', $_REQUEST['lang'], 'symphony');
             if (!Symphony::Configuration()->write(CONFIG, $conf['file']['write_mode'])) {
                 Symphony::Log()->pushToLog('Could not write default language ‘' . $language['name'] . '’ to config file.', E_NOTICE, true, true);
             }
         } else {
             Symphony::Log()->pushToLog('Could not enable the desired language ‘' . $language['name'] . '’.', E_NOTICE, true, true);
         }
     }
     // Installation completed. Woo-hoo!
     Symphony::Log()->writeToLog('============================================', true);
     Symphony::Log()->writeToLog(sprintf('INSTALLATION COMPLETED: Execution Time - %d sec (%s)', max(1, time() - $start), date('d.m.y H:i:s')), true);
     Symphony::Log()->writeToLog('============================================' . PHP_EOL . PHP_EOL . PHP_EOL, true);
     return $disabled_extensions;
 }
Пример #14
0
 public function __viewIndex()
 {
     $this->setPageType('form');
     $this->Form->setAttribute('enctype', 'multipart/form-data');
     $this->setTitle('Symphony &ndash; Add Multiple Files From a Folder');
     $this->appendSubheading('Upload!');
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings');
     $fieldset->appendChild(new XMLElement('legend', 'Essentials'));
     $p = new XMLElement('p');
     $p->setAttribute('id', 'guideme');
     $p->setValue('Upload some files. They will be put under a directory named: <b>/workspace' . $this->_driver->getMUI() . '/' . date('Y-m-d') . '.</b>');
     $fileinput = new XMLElement('div');
     $fileinput->setAttribute('id', 'fileInput');
     $input = Widget::Input('fileInput', null, 'file');
     $input->setAttribute('style', 'display:none');
     $input->setAttribute('height', '30');
     $input->setAttribute('width', '110');
     $input->setAttribute('id', 'fileInput');
     $script = new XMLElement('script');
     $script->setAttribute("type", 'text/javascript');
     $folder_name = date("Y-m-d");
     $path = preg_replace('/^http\\:\\/\\/.*\\//i', '', URL);
     if (preg_match('/http\\:\\/\\//i', $path)) {
         $path = '';
     }
     if (!General::realiseDirectory(WORKSPACE . $this->_driver->getMUI() . '/' . $folder_name, intval('0755', 8))) {
     }
     // could already exist echo "failed!";
     // echo $path;
     // echo WORKSPACE.$this->upload.'/'.$folder_name;
     // echo $_SERVER['DOCUMENT_ROOT']."/".$path."/workspace".$this->_driver->getMUI()."/".$folder_name;
     // echo $folder_name;
     $js = "\n\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\$('#fileInput').fileUpload ({\n\t\t\t\t\t\t'uploader'  : '" . URL . "/extensions/massuploadutility/assets/uploader.swf',\n\t\t\t\t\t\t'script'    : '" . ($path != '' ? '/' . $path : '') . "/extensions/massuploadutility/assets/upload.php',\n\t\t\t\t\t\t'cancelImg' : '" . URL . "/extensions/massuploadutility/assets/cancel.png',\n\t\t\t\t\t\t'auto'      : true,\n\t\t\t\t\t  'displayData': 'speed',\n\t\t\t\t\t  'simUploadLimit': 2,\n\t\t\t\t\t\t'folder'    : '" . ($path != '' ? '/' . $path : '') . "/workspace" . $this->_driver->getMUI() . "/" . $folder_name . "',\n\t\t\t\t\t  'multi'\t\t\t: true,\n\t\t\t      'onAllComplete': function(event, queueID, fileObj, response, data) { \$('#guideme').html('Upload complete! <b>Add more or click the button that says Process Files!</b>'); \$('#uploadcomplete').show(); },\n\t\t\t\t\t\t'onError': function (a, b, c, d) {\n\t\t\t\t\t\t\tif (d.status == 404)\n\t\t\t\t\t\t\t\talert('Could not find upload script. Use a path relative to: '+'<?= getcwd() ?>');\n\t\t\t\t\t\t\telse if (d.type === \"HTTP\")\n\t\t\t\t\t\t\t\talert('error '+d.type+\": \"+d.status);\n\t\t\t\t\t\t\telse if (d.type ===\"File Size\")\n\t\t\t\t\t\t\t\talert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\talert('error '+d.type+\": \"+d.text);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\t";
     $script->setValue($js);
     $div = new XMLElement('div');
     $div->setAttribute('id', 'fileInputQueue');
     $div->setAttribute('class', 'fileUploadQueue');
     $queue = new XMLElement('a');
     $queue->setAttribute('href', "javascript:\$('#fileInput').fileUploadClearQueue();");
     $queue->setValue('Clear Queue');
     $fieldset->appendChild($p);
     $fieldset->appendChild($fileinput);
     $fieldset->appendChild($script);
     $fieldset->appendChild($div);
     $fieldset->appendChild($queue);
     /* now the section fields */
     $submit = Widget::Input('action[save]', 'Process files', 'button', array('accesskey' => 's'));
     $submit->setAttribute('onClick', "window.location='" . $this->_uri . "/do'");
     $actions = new XMLElement('div');
     $actions->setAttribute('class', 'actions');
     $div = new XMLElement('div');
     $div->setAttribute('class', 'uploadcomplete');
     $div->setAttribute('id', 'uploadcomplete');
     $div->setAttribute('style', 'display:none');
     $actions->appendChild($submit);
     $div->appendChild($actions);
     // <p><strong>Multiple File Upload</strong></p>
     // <input style="display: none;" id="fileInput2" name="fileInput2" height="30" type="file" width="110">
     // <embed src="/_scripts/uploader.swf?fileUploadID=fileInput2&amp;pagepath=/demo/&amp;script=/_scripts/upload.php&amp;folder=/_uploads&amp;btnWidth=110&amp;btnHeight=30&amp;wmode=opaque&amp;multi=true&amp;fileDataName=Filedata"
     //     quality="high" id="fileInput2Uploader" class="fileUploaderBtn" name="fileInput2Uploader" allowscriptaccess="sameDomain" wmode="opaque" type="application/x-shockwave-flash" height="30" width="110"
     //     />
     // <div id="fileInput2Queue" class="fileUploadQueue"></div>
     //   <br>
     //   <a href="javascript:$('#fileInput2').fileUploadStart();">Upload Files</a> | <a href="javascript:$('#fileInput2').fileUploadClearQueue();">Clear Queue</a>
     $this->Form->appendChild($fieldset);
     $this->Form->appendChild($div);
 }
Пример #15
0
if (!defined('BITTER_LANGUAGE_PATH')) {
    define('BITTER_LANGUAGE_PATH', EXTENSIONS . '/devkit_debug/lib/bitter/languages');
}
if (!defined('BITTER_FORMAT_PATH')) {
    define('BITTER_FORMAT_PATH', EXTENSIONS . '/devkit_debug/lib/bitter/formats');
}
if (!defined('BITTER_CACHE_PATH')) {
    define('BITTER_CACHE_PATH', EXTENSIONS . '/devkit_debug/lib/bitter/caches');
}
require_once LIB . '/class.cache.php';
require_once LIB . '/class.devkit.php';
require_once EXTENSIONS . '/devkit_debug/lib/bitter/bitter.php';
// Create cache folter:
if (!is_dir(BITTER_CACHE_PATH)) {
    General::realiseDirectory(BITTER_CACHE_PATH);
}
class DevKit_Debug extends DevKit
{
    protected $show;
    protected $view;
    protected $input;
    protected $output;
    protected $params;
    protected $template;
    protected $utilities;
    protected $state;
    protected $states;
    protected $url;
    public function __construct(View $view)
    {
Пример #16
0
 public function setXMLImporter(&$name, &$error, $new)
 {
     $template = file_get_contents(EXTENSIONS . '/xmlimporter/templates/xml-importer.php');
     $old = !empty($name) ? $this->getXMLImporter($name) : array();
     // Update author:
     if (!isset($new['about']['author'])) {
         $new['about']['author'] = array('name' => Symphony::Engine()->Author()->getFullName(), 'email' => Symphony::Engine()->Author()->get('email'));
     }
     // Update dates:
     $new['about']['created'] = DateTimeObj::getGMT('c', @strtotime($new['about']['created']));
     $new['about']['updated'] = DateTimeObj::getGMT('c');
     // New name:
     $name = str_replace('-', '', Lang::createHandle($new['about']['name']));
     // Create new file:
     if (strpos(@$new['about']['file'], dirname(__FILE__)) === 0) {
         $rootdir = dirname(__FILE__);
     } else {
         $rootdir = WORKSPACE;
     }
     $filemode = Symphony::Configuration()->get('write_mode', 'file');
     $filename = sprintf('%s/xml-importers/xml-importer.%s.php', $rootdir, $name);
     $dirmode = Symphony::Configuration()->get('write_mode', 'directory');
     $dirname = dirname($filename);
     // Make sure the directory exists:
     if (!is_dir($dirname)) {
         General::realiseDirectory($dirname, $dirmode);
     }
     // Make sure new file can be written:
     if (!is_writable($dirname) or file_exists($filename) and !is_writable($filename)) {
         $error = __('Cannot save formatter, path is not writable.');
         return false;
     }
     $filedata = sprintf($template, str_replace(' ', '', ucwords(str_replace('-', ' ', Lang::createHandle($new['about']['name'])))), var_export($new['about']['name'], true), var_export($new['about']['author']['name'], true), var_export($new['about']['author']['email'], true), var_export($new['about']['description'], true), var_export($new['about']['created'], true), var_export($new['about']['updated'], true), var_export($new['can-update'], true), var_export($new['fields'], true), var_export($new['included-elements'], true), var_export($new['namespaces'], true), var_export($new['source'], true), var_export($new['timeout'], true), var_export($new['section'], true), var_export($new['unique-field'], true));
     // Write file to disk:
     General::writeFile($filename, $filedata, $filemode);
     // Cleanup old file:
     if ($filename != @$old['about']['html-formatter-file'] and file_exists($filename) and @file_exists($old['about']['html-formatter-file'])) {
         General::deleteFile($old['about']['html-formatter-file']);
     }
     return true;
 }
 public function set($lang, $data, $name)
 {
     if (strlen($lang) < 1 || !is_array($data) || empty($name)) {
         return false;
     }
     $isSymphony = $name == 'symphony';
     $data['about']['extension'] = $name;
     $this->__updateAuthors($data['about']);
     if (!is_array($data['dictionary'])) {
         $data['dictionary'] = array();
     }
     if (!is_array($data['transliterations']) || $isSymphony && empty($data['transliterations'])) {
         $data['transliterations'] = $isSymphony ? TranslationManager::defaultTransliterations() : array();
     }
     $file = TranslationManager::filePath($lang, $name);
     if (!$isSymphony && !is_dir(dirname($file))) {
         if (!General::realiseDirectory(dirname($file), $this->_Parent->Configuration->get('write_mode', 'directory'))) {
             return false;
         }
     }
     return General::writeFile($file, TranslationManager::toPHP($data), $this->_Parent->Configuration->get('write_mode', 'file'));
 }
Пример #18
0
 /**
  * Overrides the `initialiseLog()` method and writes
  * logs to logs/updater
  */
 public function initialiseLog()
 {
     if (is_dir(INSTALL_LOGS) || General::realiseDirectory(INSTALL_LOGS, self::Configuration()->get('write_mode', 'directory'))) {
         parent::initialiseLog(INSTALL_LOGS . '/update');
     }
 }
    function install(&$Page, $fields)
    {
        global $warnings;
        $database_connection_error = false;
        try {
            $db = new MySQL();
            $db->connect($fields['database']['host'], $fields['database']['username'], $fields['database']['password'], $fields['database']['port']);
            $tables = $db->fetch(sprintf("SHOW TABLES FROM `%s` LIKE '%s'", mysql_escape_string($fields['database']['name']), mysql_escape_string($fields['database']['prefix']) . '%'));
        } catch (DatabaseException $e) {
            $database_connection_error = true;
        }
        ## Invalid path
        if (!@is_dir(rtrim($fields['docroot'], '/') . '/symphony')) {
            $Page->log->pushToLog("Configuration - Bad Document Root Specified: " . $fields['docroot'], E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-symphony-dir');
            }
        } elseif (is_dir(rtrim($fields['docroot'], '/') . '/workspace') && !is_writable(rtrim($fields['docroot'], '/') . '/workspace')) {
            $Page->log->pushToLog("Configuration - Workspace folder not writable: " . $fields['docroot'] . '/workspace', E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-workspace');
            }
        } elseif (!is_writable(rtrim($fields['docroot'], '/'))) {
            $Page->log->pushToLog("Configuration - Root folder not writable: " . $fields['docroot'], E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-root');
            }
        } elseif ($database_connection_error) {
            $Page->log->pushToLog("Configuration - Could not establish database connection", E_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (version_compare($db->fetchVar('version', 0, "SELECT VERSION() AS `version`;"), '5.0', '<')) {
            $version = $db->fetchVar('version', 0, "SELECT VERSION() AS `version`;");
            $Page->log->pushToLog('Configuration - MySQL Version is not correct. ' . $version . ' detected.', E_NOTICE, true);
            define("kDATABASE_VERSION_WARNING", true);
            $warnings['database-incorrect-version'] = __('Symphony requires <code>MySQL 5.0</code> or greater to work, however version <code>%s</code> was detected. This requirement must be met before installation can proceed.', array($version));
            if (!defined("ERROR")) {
                define("ERROR", 'database-incorrect-version');
            }
        } elseif (!$db->select($fields['database']['name'])) {
            $Page->log->pushToLog("Configuration - Database '" . $fields['database']['name'] . "' Not Found", E_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (is_array($tables) && !empty($tables)) {
            $Page->log->pushToLog("Configuration - Database table prefix clash with '" . $fields['database']['name'] . "'", E_NOTICE, true);
            define("kDATABASE_PREFIX_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'database-table-clash');
            }
        } elseif (trim($fields['user']['username']) == '') {
            $Page->log->pushToLog("Configuration - No username entered.", E_NOTICE, true);
            define("kUSER_USERNAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-username');
            }
        } elseif (trim($fields['user']['password']) == '') {
            $Page->log->pushToLog("Configuration - No password entered.", E_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-password');
            }
        } elseif ($fields['user']['password'] != $fields['user']['confirm-password']) {
            $Page->log->pushToLog("Configuration - Passwords did not match.", E_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-password-mismatch');
            }
        } elseif (trim($fields['user']['firstname']) == '' || trim($fields['user']['lastname']) == '') {
            $Page->log->pushToLog("Configuration - Did not enter First and Last names.", E_NOTICE, true);
            define("kUSER_NAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-name');
            }
        } elseif (!preg_match('/^\\w(?:\\.?[\\w%+-]+)*@\\w(?:[\\w-]*\\.)+?[a-z]{2,}$/i', $fields['user']['email'])) {
            $Page->log->pushToLog("Configuration - Invalid email address supplied.", E_NOTICE, true);
            define("kUSER_EMAIL_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-invalid-email');
            }
        } else {
            $config = $fields;
            $kDOCROOT = rtrim($config['docroot'], '/');
            $database = array_map("trim", $fields['database']);
            if (!isset($database['host']) || $database['host'] == "") {
                $database['host'] = "localhost";
            }
            if (!isset($database['port']) || $database['port'] == "") {
                $database['port'] = "3306";
            }
            if (!isset($database['prefix']) || $database['prefix'] == "") {
                $database['prefix'] = "sym_";
            }
            $install_log = $Page->log;
            $start = time();
            $install_log->writeToLog(CRLF . '============================================', true);
            $install_log->writeToLog('INSTALLATION PROCESS STARTED (' . DateTimeObj::get('c') . ')', true);
            $install_log->writeToLog('============================================', true);
            $install_log->pushToLog("MYSQL: Establishing Connection...", E_NOTICE, true, false);
            $db = new MySQL();
            if (!$db->connect($database['host'], $database['username'], $database['password'], $database['port'])) {
                define('_INSTALL_ERRORS_', "There was a problem while trying to establish a connection to the MySQL server. Please check your settings.");
                $install_log->pushToLog("Failed", E_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $install_log->pushToLog("MYSQL: Selecting Database '" . $database['name'] . "'...", E_NOTICE, true, false);
            if (!$db->select($database['name'])) {
                define('_INSTALL_ERRORS_', "Could not connect to specified database. Please check your settings.");
                $install_log->pushToLog("Failed", E_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $db->setPrefix($database['prefix']);
            $conf = getDynamicConfiguration();
            if ($conf['database']['runtime_character_set_alter'] == '1') {
                $db->setCharacterEncoding($conf['database']['character_encoding']);
                $db->setCharacterSet($conf['database']['character_set']);
            }
            $install_log->pushToLog("MYSQL: Importing Table Schema...", E_NOTICE, true, false);
            $error = NULL;
            if (!fireSql($db, getTableSchema(), $error, $config['database']['use-server-encoding'] != 'yes' ? true : false)) {
                define('_INSTALL_ERRORS_', "There was an error while trying to import data to the database. MySQL returned: {$error}");
                $install_log->pushToLog("Failed", E_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $author_sql = sprintf("INSERT INTO  `tbl_authors` (\n\t\t\t\t\t\t`id` ,\n\t\t\t\t\t\t`username` ,\n\t\t\t\t\t\t`password` ,\n\t\t\t\t\t\t`first_name` ,\n\t\t\t\t\t\t`last_name` ,\n\t\t\t\t\t\t`email` ,\n\t\t\t\t\t\t`last_seen` ,\n\t\t\t\t\t\t`user_type` ,\n\t\t\t\t\t\t`primary` ,\n\t\t\t\t\t\t`default_area` ,\n\t\t\t\t\t\t`auth_token_active`\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t%s('%s'),\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\tNULL ,\n\t\t\t\t\t\t'developer',\n\t\t\t\t\t\t'yes',\n\t\t\t\t\t\tNULL,\n\t\t\t\t\t\t'no'\n\t\t\t\t\t);", $db->cleanValue($config['user']['username']), 'SHA1', $db->cleanValue($config['user']['password']), $db->cleanValue($config['user']['firstname']), $db->cleanValue($config['user']['lastname']), $db->cleanValue($config['user']['email']));
            $install_log->pushToLog("MYSQL: Creating Default Author...", E_NOTICE, true, false);
            if (!$db->query($author_sql)) {
                $error = $db->getLastError();
                define('_INSTALL_ERRORS_', "There was an error while trying create the default author. MySQL returned: " . $error['num'] . ': ' . $error['msg']);
                $install_log->pushToLog("Failed", E_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $conf = array();
            if (@is_dir($fields['docroot'] . '/workspace')) {
                foreach (getDynamicConfiguration() as $group => $settings) {
                    if (!is_array($conf['settings'][$group])) {
                        $conf['settings'][$group] = array();
                    }
                    $conf['settings'][$group] = array_merge($conf['settings'][$group], $settings);
                }
            } else {
                $conf['settings']['admin']['max_upload_size'] = '5242880';
                $conf['settings']['symphony']['pagination_maximum_rows'] = '17';
                $conf['settings']['symphony']['allow_page_subscription'] = '1';
                $conf['settings']['symphony']['lang'] = Lang::get();
                $conf['settings']['symphony']['pages_table_nest_children'] = 'no';
                $conf['settings']['log']['archive'] = '1';
                $conf['settings']['log']['maxsize'] = '102400';
                $conf['settings']['image']['cache'] = '1';
                $conf['settings']['image']['quality'] = '90';
                $conf['settings']['database']['character_set'] = 'utf8';
                $conf['settings']['database']['character_encoding'] = 'utf8';
                $conf['settings']['database']['runtime_character_set_alter'] = '1';
                $conf['settings']['public']['display_event_xml_in_source'] = 'no';
            }
            $conf['settings']['symphony']['version'] = kVERSION;
            $conf['settings']['symphony']['cookie_prefix'] = 'sym-';
            $conf['settings']['general']['useragent'] = 'Symphony/' . kVERSION;
            $conf['settings']['general']['sitename'] = strlen(trim($config['general']['sitename'])) > 0 ? $config['general']['sitename'] : __('Website Name');
            $conf['settings']['file']['write_mode'] = $config['permission']['file'];
            $conf['settings']['directory']['write_mode'] = $config['permission']['directory'];
            $conf['settings']['database']['host'] = $database['host'];
            $conf['settings']['database']['port'] = $database['port'];
            $conf['settings']['database']['user'] = $database['username'];
            $conf['settings']['database']['password'] = $database['password'];
            $conf['settings']['database']['db'] = $database['name'];
            $conf['settings']['database']['tbl_prefix'] = $database['prefix'];
            $conf['settings']['region']['time_format'] = $config['region']['time_format'];
            $conf['settings']['region']['date_format'] = $config['region']['date_format'];
            $conf['settings']['region']['datetime_separator'] = ' ';
            $conf['settings']['region']['timezone'] = $config['region']['timezone'];
            ## Create Manifest Directory structure
            $install_log->pushToLog("WRITING: Creating 'manifest' folder (/manifest)", E_NOTICE, true, true);
            if (!General::realiseDirectory($kDOCROOT . '/manifest', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'manifest' directory. Check permission on the root folder.");
                $install_log->pushToLog("ERROR: Creation of 'manifest' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'logs' folder (/manifest/logs)", E_NOTICE, true, true);
            if (!General::realiseDirectory($kDOCROOT . '/manifest/logs', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'logs' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'logs' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'cache' folder (/manifest/cache)", E_NOTICE, true, true);
            if (!General::realiseDirectory($kDOCROOT . '/manifest/cache', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'cache' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'cache' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'tmp' folder (/manifest/tmp)", E_NOTICE, true, true);
            if (!General::realiseDirectory($kDOCROOT . '/manifest/tmp', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'tmp' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'tmp' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Configuration File", E_NOTICE, true, true);
            if (!writeConfig($kDOCROOT . '/manifest/', $conf, $conf['settings']['file']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not write config file. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Writing Configuration File Failed", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            $htaccess = '
### Symphony 2.2.x ###
Options +FollowSymlinks -Indexes

<IfModule mod_rewrite.c>

	RewriteEngine on
	RewriteBase /' . REWRITE_BASE . '

	### SECURITY - Protect crucial files
	RewriteRule ^manifest/(.*)$ - [F]
	RewriteRule ^workspace/utilities/(.*).xsl$ - [F]
	RewriteRule ^workspace/pages/(.*).xsl$ - [F]
	RewriteRule ^(.*).sql$ - [F]
	RewriteRule (^|/)\\. - [F]

	### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
	RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
	RewriteRule .* - [S=14]

	### IMAGE RULES
	RewriteRule ^image\\/(.+\\.(jpg|gif|jpeg|png|bmp))$ extensions/jit_image_manipulation/lib/image.php?param=$1 [L,NC]

	### CHECK FOR TRAILING SLASH - Will ignore files
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_URI} !/$
	RewriteCond %{REQUEST_URI} !(.*)/$
	RewriteRule ^(.*)$ $1/ [L,R=301]

	### URL Correction
	RewriteRule ^(symphony/)?index.php(/.*/?) $1$2 [NC]

	### ADMIN REWRITE
	RewriteRule ^symphony\\/?$ index.php?mode=administration&%{QUERY_STRING} [NC,L]

	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^symphony(\\/(.*\\/?))?$ index.php?symphony-page=$1&mode=administration&%{QUERY_STRING}	[NC,L]

	### FRONTEND REWRITE - Will ignore files and folders
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.*\\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}	[L]

</IfModule>
######
';
            $install_log->pushToLog("CONFIGURING: Frontend", E_NOTICE, true, true);
            if (!General::writeFile($kDOCROOT . "/.htaccess", $htaccess, $conf['settings']['file']['write_mode'], 'a')) {
                define('_INSTALL_ERRORS_', "Could not write .htaccess file. Check permission on " . $kDOCROOT);
                $install_log->pushToLog("ERROR: Writing .htaccess File Failed", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            if (@(!is_dir($fields['docroot'] . '/workspace'))) {
                ### Create the workspace folder structure
                $install_log->pushToLog("WRITING: Creating 'workspace' folder (/workspace)", E_NOTICE, true, true);
                if (!General::realiseDirectory($kDOCROOT . '/workspace', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'data-sources' folder (/workspace/data-sources)", E_NOTICE, true, true);
                if (!General::realiseDirectory($kDOCROOT . '/workspace/data-sources', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/data-sources' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/data-sources' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'events' folder (/workspace/events)", E_NOTICE, true, true);
                if (!General::realiseDirectory($kDOCROOT . '/workspace/events', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/events' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/events' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'pages' folder (/workspace/pages)", E_NOTICE, true, true);
                if (!General::realiseDirectory($kDOCROOT . '/workspace/pages', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/pages' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/pages' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'utilities' folder (/workspace/utilities)", E_NOTICE, true, true);
                if (!General::realiseDirectory($kDOCROOT . '/workspace/utilities', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/utilities' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/utilities' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            } else {
                $install_log->pushToLog("MYSQL: Importing Workspace Data...", E_NOTICE, true, false);
                $error = NULL;
                if (!fireSql($db, getWorkspaceData(), $error, $config['database']['use-server-encoding'] != 'yes' ? true : false)) {
                    define('_INSTALL_ERRORS_', "There was an error while trying to import data to the database. MySQL returned: {$error}");
                    $install_log->pushToLog("Failed", E_ERROR, true, true, true);
                    installResult($Page, $install_log, $start);
                } else {
                    $install_log->pushToLog("Done", E_NOTICE, true, true, true);
                }
            }
            if (@(!is_dir($fields['docroot'] . '/extensions'))) {
                $install_log->pushToLog("WRITING: Creating 'extensions' folder (/extensions)", E_NOTICE, true, true);
                if (!General::realiseDirectory($kDOCROOT . '/extensions', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'extensions' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'extensions' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            }
            $install_log->pushToLog("Installation Process Completed In " . max(1, time() - $start) . " sec", E_NOTICE, true);
            installResult($Page, $install_log, $start);
            // Redirect to backend
            redirect('http://' . rtrim(str_replace('http://', '', _INSTALL_DOMAIN_), '/') . '/symphony/');
        }
    }
Пример #20
0
<?php

if (!defined('BITTER_LANGUAGE_PATH')) {
    define('BITTER_LANGUAGE_PATH', EXTENSIONS . '/debugdevkit/lib/bitter/languages');
}
if (!defined('BITTER_FORMAT_PATH')) {
    define('BITTER_FORMAT_PATH', EXTENSIONS . '/debugdevkit/lib/bitter/formats');
}
if (!defined('BITTER_CACHE_PATH')) {
    define('BITTER_CACHE_PATH', CACHE);
}
require_once TOOLKIT . '/class.devkit.php';
require_once EXTENSIONS . '/debugdevkit/lib/bitter/bitter.php';
// Create cache folder:
if (!is_dir(BITTER_CACHE_PATH) && General::realiseDirectory(BITTER_CACHE_PATH) === false) {
    throw new Exception(__('Failed to create cache folder. Please check "%s" is writable.', array(EXTENSIONS . '/debugdevkit/lib/bitter')));
} elseif (!is_writable(BITTER_CACHE_PATH)) {
    throw new Exception(__('Cache folder is not writable. Please check permissions on "%s".', array(EXTENSIONS . '/debugdevkit/lib/bitter')));
}
class Content_DebugDevKit_Debug extends DevKit
{
    protected $_view = '';
    protected $_xsl = '';
    protected $_full_utility_list = '';
    public function __construct()
    {
        parent::__construct();
        $this->_title = __('Debug');
        $this->_query_string = parent::__buildQueryString(array('symphony-page', 'debug'));
        if (!empty($this->_query_string)) {
            $this->_query_string = '&amp;' . General::sanitize($this->_query_string);
Пример #21
0
 public function install()
 {
     return General::realiseDirectory(WORKSPACE . '/indecent/');
 }
Пример #22
0
 /**
  * Creates a new entry for each valid file in the `$target_section`
  */
 public function commitFiles()
 {
     $entryManager = new EntryManager(Administration::instance());
     $section = $this->target_section;
     // This is the default field instances that will populated with data.
     $entries = array();
     $fields = array('upload' => $this->target_field, 'name' => null, 'section' => null);
     foreach ($section->fetchFields() as $field) {
         if (General::validateString($field->get('type'), Extension_BulkImporter::$supported_fields['name']) && is_null($fields['name'])) {
             $fields['name'] = $field;
         }
         if (General::validateString($field->get('type'), Extension_BulkImporter::$supported_fields['section']) && is_null($fields['section'])) {
             $fields['section'] = $field;
         }
     }
     foreach ($this->files as $file) {
         $path = '/';
         if ($this->preserve_subdirectories) {
             $path = dirname(substr($file->location, strlen($this->extracted_directory)));
             if ($path != '/') {
                 $path .= '/';
             }
         } else {
             if ($this->archive_is_parent) {
                 $path = '/' . $this->extracted_archive . '/';
             }
         }
         $final_destination = preg_replace("/^\\/workspace/", '', $this->target_field->get('destination')) . $path . $file->rawname;
         if (!$file->isValid($this->target_field, $final_destination)) {
             continue;
         }
         $_post = array();
         $entry = $entryManager->create();
         $entry->set('section_id', $section->get('id'));
         $entry->set('author_id', Administration::instance()->Author->get('id'));
         // Set the Name
         if (!is_null($fields['name'])) {
             $_post[$fields['name']->get('element_name')] = $file->name;
         }
         // Set the Upload Field
         if (is_null($fields['upload'])) {
             throw new Exception(__('No valid upload field found in the <code>%s</code>', array($section->get('name'))));
         }
         $_post[$this->target_field->get('element_name')] = $final_destination;
         // Cache some info, before we move file
         // https://github.com/brendo/bulkimporter/pull/7#issuecomment-1105691
         $meta = array('size' => $file->size, 'mimetype' => $file->mimetype, 'meta' => serialize($this->target_field->getMetaInfo($file->location, $file->mimetype)));
         // Move the image from it's bulk-imported location
         $path = WORKSPACE . dirname($final_destination);
         if (!file_exists($path)) {
             General::realiseDirectory($path);
             chmod($path, intval(0755, 8));
         }
         if (rename($file->location, WORKSPACE . $final_destination)) {
             chmod(WORKSPACE . $final_destination, intval(0755, 8));
         }
         $errors = array();
         //	Check all the fields that they are correct
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($_post, $errors)) {
             if (!empty($errors)) {
                 $file->setErrors($errors);
             }
             continue;
         }
         if (__ENTRY_OK__ == $entry->setDataFromPost($_post, $errors, false, false)) {
             //	Because we can't upload the file using the inbuilt function
             //	we have to fake the expected output
             $upload = $entry->getData($this->target_field->get('id'));
             foreach ($meta as $key => $value) {
                 if (empty($upload[$key])) {
                     $upload[$key] = $value;
                 }
             }
             $entry->setData($this->target_field->get('id'), $upload);
             /**
              * Just prior to creation of an Entry
              *
              * @delegate EntryPreCreate
              * @param string $context
              * '/publish/new/'
              * @param Section $section
              * @param Entry $entry
              * @param array $fields
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPreCreate', '/publish/new/', array('section' => $section, 'entry' => &$entry, 'fields' => &$_post));
             if ($entry->commit()) {
                 $file->setUploaded();
                 $entries[$final_destination] = $entry->get('id');
                 /**
                  * Creation of an Entry. New Entry object is provided.
                  *
                  * @delegate EntryPostCreate
                  * @param string $context
                  * '/publish/new/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
                  */
                 Symphony::ExtensionManager()->notifyMembers('EntryPostCreate', '/publish/new/', array('section' => $section, 'entry' => $entry, 'fields' => $_post));
             }
         } else {
             $file->setErrors(__('Could not save entry in the <code>%s</code>', array($section->get('name'))));
         }
     }
     // Set the Section Association
     if (!empty($entries) && !is_null($this->linked_entry['linked-entry'])) {
         $entry = current($entryManager->fetch($this->linked_entry['linked-entry']));
         // Linked field, process the array of ID's to add
         $field = $entryManager->fieldManager->fetch($this->linked_entry['linked-field']);
         $result = $field->processRawFieldData($entries, $s, false, $entry->get('id'));
         // Get the current linked entries and merge with the new ones
         $existing_values = $entry->getData($this->linked_entry['linked-field']);
         if (is_array($existing_values['relation_id'])) {
             $result['relation_id'] = array_merge_recursive($result['relation_id'], $existing_values['relation_id']);
         }
         $entry->setData($this->linked_entry['linked-field'], $result);
         $entry->commit();
     }
     $this->entries = $entries;
 }
Пример #23
0
 /**
  * Creates the table needed for the settings of the field
  */
 public function install()
 {
     General::realiseDirectory(WORKSPACE . '/er-templates');
     return FieldEntry_relationship::createFieldTable();
 }
Пример #24
0
 public function setFormatter(&$name, &$error, $new)
 {
     $template = file_get_contents(EXTENSIONS . '/htmlformatter/templates/formatter.php');
     $old = !empty($name) ? $this->getFormatter($name) : array();
     // Update author:
     if (!isset($new['about']['author'])) {
         $new['about']['author'] = array('name' => $this->_Parent->Author->getFullName(), 'website' => URL, 'email' => $this->_Parent->Author->get('email'));
     }
     // Update dates:
     $new['about']['html-formatter-created'] = DateTimeObj::getGMT('c', @strtotime($new['about']['html-formatter-created']));
     $new['about']['html-formatter-updated'] = DateTimeObj::getGMT('c');
     // New name:
     $name = str_replace('-', '', Lang::createHandle($new['about']['name']));
     // Create new file:
     if (strpos(@$new['about']['html-formatter-file'], dirname(__FILE__)) === 0) {
         $rootdir = dirname(__FILE__);
     } else {
         $rootdir = WORKSPACE;
     }
     $filemode = $this->_Parent->Configuration->get('write_mode', 'file');
     $filename = sprintf('%s/text-formatters/formatter.%s.php', $rootdir, $name);
     $dirmode = $this->_Parent->Configuration->get('write_mode', 'directory');
     $dirname = dirname($filename);
     // Make sure the directory exists:
     if (!is_dir($dirname)) {
         General::realiseDirectory($dirname, $dirmode);
     }
     // Make sure new file can be written:
     if (!is_writable($dirname) or file_exists($filename) and !is_writable($filename)) {
         $error = __('Cannot save formatter, path is not writable.');
         return false;
     }
     $filedata = sprintf($template, str_replace(' ', '', ucwords(str_replace('-', ' ', Lang::createHandle($new['about']['name'])))), var_export($new['about']['name'], true), var_export($new['about']['author']['name'], true), var_export($new['about']['author']['website'], true), var_export($new['about']['author']['email'], true), var_export($new['about']['description'], true), var_export($new['about']['html-formatter-created'], true), var_export($new['about']['html-formatter-updated'], true), var_export($new['options']['pretty_acronyms'], true), var_export($new['options']['pretty_ampersands'], true), var_export($new['options']['pretty_dashes'], true), var_export($new['options']['pretty_ellipses'], true), var_export($new['options']['pretty_quotation_marks'], true), var_export($new['options']['pretty_sentence_spacing'], true), var_export($new['options']['pretty_symbols'], true), var_export($new['options']['prevent_widowed_words'], true), var_export($new['options']['editor_name'], true));
     // Write file to disk:
     General::writeFile($filename, $filedata, $filemode);
     // Cleanup old file:
     if ($filename != @$old['about']['html-formatter-file'] and file_exists($filename) and @file_exists($old['about']['html-formatter-file'])) {
         General::deleteFile($old['about']['html-formatter-file']);
     }
     return true;
 }
Пример #25
0
<?php

$root = Symphony::Configuration()->get('filepath', 'redactor');
General::realiseDirectory($root);
$tmpname = $_FILES['file']['name'];
$tmpfile = $_FILES['file']['tmp_name'];
$extension = substr($tmpname, strrpos($tmpname, '.'));
$filename = md5(date('YmdHis')) . $extension;
$file = $root . '/' . $filename;
copy($tmpfile, $file);
$array = array('filename' => $tmpname, 'filelink' => URL . '/symphony/extension/richtext_redactor/getfile/?name=' . $filename);
echo stripslashes(json_encode($array));
die;
Пример #26
0
 public function entrySaved($context)
 {
     require_once MANIFEST . '/jit-recipes.php';
     require_once MANIFEST . '/jit-precaching.php';
     require_once TOOLKIT . '/class.fieldmanager.php';
     $fm = new FieldManager(Symphony::Engine());
     $section = $context['section'];
     if (!$section) {
         require_once TOOLKIT . '/class.sectionmanager.php';
         $sm = new SectionManager(Symphony::Engine());
         $section = $sm->fetch($context['entry']->get('section_id'));
     }
     // iterate over each field in this entry
     foreach ($context['entry']->getData() as $field_id => $data) {
         // get the field meta data
         $field = $fm->fetch($field_id);
         // iterate over the field => recipe mapping
         foreach ($cached_recipes as $cached_recipe) {
             // check a mapping exists for this section/field combination
             if ($section->get('handle') != $cached_recipe['section']) {
                 continue;
             }
             if ($field->get('element_name') != $cached_recipe['field']) {
                 continue;
             }
             // iterate over the recipes mapped for this section/field combination
             foreach ($cached_recipe['recipes'] as $cached_recipe_name) {
                 // get the file name, includes path relative to workspace
                 $file = $data['file'];
                 if (!isset($file) || is_null($file)) {
                     continue;
                 }
                 // trim the filename from path
                 $uploaded_file_path = explode('/', $file);
                 array_pop($uploaded_file_path);
                 // image path relative to workspace
                 if (is_array($uploaded_file_path)) {
                     $uploaded_file_path = implode('/', $uploaded_file_path);
                 }
                 // iterate over all JIT recipes
                 foreach ($recipes as $recipe) {
                     // only process if the recipe has a URL Parameter (name)
                     if (is_null($recipe['url-parameter'])) {
                         continue;
                     }
                     // if not using wildcard, only process specified recipe names
                     if ($cached_recipe_name != '*' && $cached_recipe_name != $recipe['url-parameter']) {
                         continue;
                     }
                     // process the image using the usual JIT URL and get the result
                     $image_data = file_get_contents(URL . '/image/' . $recipe['url-parameter'] . $file);
                     // create a directory structure that matches the JIT URL structure
                     General::realiseDirectory(WORKSPACE . '/image-cache/' . $recipe['url-parameter'] . $uploaded_file_path);
                     // save the image to disk
                     file_put_contents(WORKSPACE . '/image-cache/' . $recipe['url-parameter'] . $file, $image_data);
                 }
             }
         }
     }
 }