function _podcastUpdate() { global $objDatabase, $_ARRAYLANG, $objUpdate, $_CONFIG; //move podcast images directory $path = ASCMS_DOCUMENT_ROOT . '/images'; $oldImagesPath = '/content/podcast'; $newImagesPath = '/podcast'; if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '1.2.1')) { if (!file_exists($path . $newImagesPath) && file_exists($path . $oldImagesPath)) { \Cx\Lib\FileSystem\FileSystem::makeWritable($path . $oldImagesPath); if (!\Cx\Lib\FileSystem\FileSystem::copy_folder($path . $oldImagesPath, $path . $newImagesPath)) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_TO_MOVE_DIRECTORY'], $path . $oldImagesPath, $path . $newImagesPath)); return false; } } \Cx\Lib\FileSystem\FileSystem::makeWritable($path . $newImagesPath); \Cx\Lib\FileSystem\FileSystem::makeWritable($path . $newImagesPath . '/youtube_thumbnails'); //change thumbnail paths $query = "UPDATE `" . DBPREFIX . "module_podcast_medium` SET `thumbnail` = REPLACE(`thumbnail`, '/images/content/podcast/', '/images/podcast/')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } //set new default settings $query = "UPDATE `" . DBPREFIX . "module_podcast_settings` SET `setvalue` = '50' WHERE `setname` = 'thumb_max_size' AND `setvalue` = ''"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "UPDATE `" . DBPREFIX . "module_podcast_settings` SET `setvalue` = '85' WHERE `setname` = 'thumb_max_size_homecontent' AND `setvalue` = ''"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } // only update if installed version is at least a version 2.0.0 // older versions < 2.0 have a complete other structure of the content page and must therefore completely be reinstalled if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) { try { // migrate content page to version 3.0.1 $search = array('/(.*)/ms'); $callback = function ($matches) { $content = $matches[1]; if (empty($content)) { return $content; } // add missing placeholder {PODCAST_JAVASCRIPT} if (strpos($content, '{PODCAST_JAVASCRIPT}') === false) { $content .= "\n{PODCAST_JAVASCRIPT}"; } // add missing placeholder {PODCAST_PAGING} if (strpos($content, '{PODCAST_PAGING}') === false) { $content = preg_replace('/(\\s+)(<!--\\s+END\\s+podcast_media\\s+-->)/ms', '$1$2$1<div class="noMedium">$1 {PODCAST_PAGING}$1</div>', $content); } return $content; }; \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'podcast'), $search, $callback, array('content'), '3.0.1'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } return true; }
/** * Cloudrexx * * @link http://www.cloudrexx.com * @copyright Cloudrexx AG 2007-2015 * * According to our dual licensing model, this program can be used either * under the terms of the GNU Affero General Public License, version 3, * or under a proprietary license. * * The texts of the GNU Affero General Public License with an additional * permission and of our proprietary license can be found at and * in the LICENSE file you have received along with this program. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * "Cloudrexx" is a registered trademark of Cloudrexx AG. * The licensing of the program under the AGPLv3 does not imply a * trademark license. Therefore any rights, title and interest in * our trademarks remain entirely with us. */ function _marketUpdate() { global $objDatabase, $_ARRAYLANG; $query = "SELECT id FROM " . DBPREFIX . "module_market_settings WHERE name='codeMode'"; $objCheck = $objDatabase->SelectLimit($query, 1); if ($objCheck !== false) { if ($objCheck->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_market_settings` ( `id` , `name` , `value` , `description` , `type` )\n VALUES ( NULL , 'codeMode', '1', 'TXT_MARKET_SET_CODE_MODE', '2')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_market_mail'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_market_mail')); return false; } if (!isset($arrColumns['MAILTO'])) { $query = "ALTER TABLE `" . DBPREFIX . "module_market_mail` ADD `mailto` VARCHAR( 10 ) NOT NULL AFTER `content`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } /***************************************************************** * EXTENSION: New attributes 'color' and 'sort_id' for entries * * ADDED: Contrexx v2.1.0 * *****************************************************************/ $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_market'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_market')); return false; } if (!isset($arrColumns['SORT_ID'])) { $query = "ALTER TABLE `" . DBPREFIX . "module_market` ADD `sort_id` INT( 4 ) NOT NULL DEFAULT '0' AFTER `paypal`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (!isset($arrColumns['COLOR'])) { $query = "ALTER TABLE `" . DBPREFIX . "module_market` ADD `color` VARCHAR(50) NOT NULL DEFAULT '' AFTER `description`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } try { // delete obsolete table contrexx_module_market_access \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_market_access'); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_market_spez_fields', array('id' => array('type' => 'INT(5)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(100)'), 'value' => array('type' => 'VARCHAR(100)'), 'type' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '1'), 'lang_id' => array('type' => 'INT(2)', 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0'))); } catch (\Cx\Lib\UpdateException $e) { DBG::trace(); return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }
function _ecardUpdate() { global $objDatabase, $_ARRAYLANG, $_CORELANG; try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_ecard_ecards', array('code' => array('type' => 'VARCHAR(35)', 'notnull' => true, 'default' => '', 'primary' => true), 'date' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'TTL' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'salutation' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'senderName' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'senderEmail' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'recipientName' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'recipientEmail' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'message' => array('type' => 'TEXT', 'notnull' => true))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_ecard_settings', array('setting_name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'primary' => true), 'setting_value' => array('type' => 'TEXT', 'notnull' => true, 'default' => 0))); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } $ins_tpl = "\n INSERT INTO " . DBPREFIX . "module_ecard_settings (setting_name, setting_value)\n VALUES ('%s', '%s')\n ON DUPLICATE KEY UPDATE `setting_name` = `setting_name`\n "; $insert_values = array(array('maxCharacters', '100'), array('maxLines', '50'), array('motive_0', 'Bild_001.jpg'), array('motive_1', 'Bild_002.jpg'), array('motive_2', ''), array('motive_3', ''), array('motive_4', ''), array('motive_5', ''), array('motive_6', ''), array('motive_7', ''), array('motive_8', ''), array('maxHeight', '300'), array('validdays', '30'), array('maxWidth', '300'), array('maxHeightThumb', '80'), array('maxWidthThumb', '80'), array('subject', 'Sie haben eine E-Card erhalten!'), array('emailText', "[[ECARD_SENDER_NAME]] hat Ihnen eine E-Card geschickt.<br />\n Sie können diese während den nächsten [[ECARD_VALID_DAYS]] Tagen unter [[ECARD_URL]] abrufen.")); foreach ($insert_values as $setting) { $query = sprintf($ins_tpl, addslashes($setting[0]), addslashes($setting[1])); if (!$objDatabase->Execute($query)) { return _databaseError($query, $objDatabase->ErrorMsg()); } } /* * ********************************************** * BUGFIX: Set write access to the image dir * * ********************************************** */ $arrImagePaths = array(array(ASCMS_DOCUMENT_ROOT . '/images/modules/ecard', ASCMS_PATH_OFFSET . '/images/modules/ecard'), array(ASCMS_ECARD_OPTIMIZED_PATH, ASCMS_ECARD_OPTIMIZED_WEB_PATH), array(ASCMS_ECARD_SEND_ECARDS_PATH, ASCMS_ECARD_SEND_ECARDS_WEB_PATH), array(ASCMS_ECARD_THUMBNAIL_PATH, ASCMS_ECARD_THUMBNAIL_WEB_PATH)); foreach ($arrImagePaths as $arrImagePath) { if (\Cx\Lib\FileSystem\FileSystem::makeWritable($arrImagePath[0])) { if ($mediaDir = @opendir($arrImagePath[0])) { while ($file = readdir($mediaDir)) { if ($file != '.' && $file != '..') { if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($arrImagePath[0] . '/' . $file)) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], $arrImagePath[0] . '/' . $file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], $arrImagePath[0] . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], $arrImagePath[0] . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } return true; }
/** * Cloudrexx * * @link http://www.cloudrexx.com * @copyright Cloudrexx AG 2007-2015 * * According to our dual licensing model, this program can be used either * under the terms of the GNU Affero General Public License, version 3, * or under a proprietary license. * * The texts of the GNU Affero General Public License with an additional * permission and of our proprietary license can be found at and * in the LICENSE file you have received along with this program. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * "Cloudrexx" is a registered trademark of Cloudrexx AG. * The licensing of the program under the AGPLv3 does not imply a * trademark license. Therefore any rights, title and interest in * our trademarks remain entirely with us. */ function _feedUpdate() { global $objDatabase, $_ARRAYLANG; $query = "ALTER TABLE `" . DBPREFIX . "module_feed_newsml_documents` CHANGE `publicIdentifier` `publicIdentifier` VARCHAR( 255 ) NOT NULL DEFAULT ''"; if (!$objDatabase->Execute($query)) { return _databaseError($query, $objDatabase->ErrorMsg()); } $arrIndexes = $objDatabase->MetaIndexes(DBPREFIX . 'module_feed_newsml_documents'); if ($arrIndexes !== false) { if (!isset($arrIndexes['unique'])) { $query = "ALTER TABLE `" . DBPREFIX . "module_feed_newsml_documents` ADD UNIQUE `unique` (`publicIdentifier`)"; if (!$objDatabase->Execute($query)) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_feed_newsml_documents')); return false; } return true; }
function _memberdirUpdate() { global $objDatabase, $_ARRAYLANG, $_CORELANG; try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_directories', array('dirid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parentdir' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '1'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'description' => array('type' => 'TEXT'), 'displaymode' => array('type' => 'SET(\'0\',\'1\',\'2\')', 'notnull' => true, 'default' => '0'), 'sort' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '1'), 'pic1' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '0'), 'pic2' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')), array('memberdir_dir' => array('fields' => array('name', 'description'), 'type' => 'FULLTEXT'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_name', array('field' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'dirid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'active' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => ''), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_settings', array('setid' => array('type' => 'INT(4)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'setname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'setvalue' => array('type' => 'TEXT'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_values', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'dirid' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'pic1' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'pic2' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), '0' => array('type' => 'SMALLINT(5)', 'notnull' => true, 'unsigned' => true, 'default' => '0'), '1' => array('type' => 'TEXT'), '2' => array('type' => 'TEXT'), '3' => array('type' => 'TEXT'), '4' => array('type' => 'TEXT'), '5' => array('type' => 'TEXT'), '6' => array('type' => 'TEXT'), '7' => array('type' => 'TEXT'), '8' => array('type' => 'TEXT'), '9' => array('type' => 'TEXT'), '10' => array('type' => 'TEXT'), '11' => array('type' => 'TEXT'), '12' => array('type' => 'TEXT'), '13' => array('type' => 'TEXT'), '14' => array('type' => 'TEXT'), '15' => array('type' => 'TEXT'), '16' => array('type' => 'TEXT'), '17' => array('type' => 'TEXT'), '18' => array('type' => 'TEXT'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1'))); $arrSettings = array('default_listing' => array('1', '1'), 'max_height' => array('400', '1'), 'max_width' => array('500', '1')); foreach ($arrSettings as $key => $arrSetting) { if (!\Cx\Lib\UpdateUtil::sql("SELECT 1 FROM `" . DBPREFIX . "module_memberdir_settings` WHERE `setname` = '" . $key . "'")->RecordCount()) { \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "module_memberdir_settings`\n SET `setname` = '" . $key . "',\n `setvalue` = '" . $arrSetting[0] . "',\n `lang_id` = '" . $arrSetting[1] . "'\n "); } } } catch (\Cx\Lib\UpdateException $e) { // we COULD do something else here.. return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_MEDIA_PATH . '/memberdir')) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_MEDIA_PATH . '/memberdir/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } return true; }
function _egovUpdate() { global $objDatabase, $_ARRAYLANG; // Check required tables.. $arrTables = $objDatabase->MetaTables('TABLES'); if (!$arrTables) { setUpdateMsg($_ARRAYLANG['TXT_UNABLE_DETERMINE_DATABASE_STRUCTURE']); return false; } // Create new configuration table if missing if (!in_array(DBPREFIX . "module_egov_configuration", $arrTables)) { $query = "\n CREATE TABLE " . DBPREFIX . "module_egov_configuration (\n `name` varchar(255) NOT NULL default '',\n `value` text NOT NULL,\n UNIQUE KEY `name` (`name`)\n ) ENGINE=MyISAM;\n "; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // Copy original values $arrField = array('set_sender_name', 'set_sender_email', 'set_recipient_email', 'set_state_subject', 'set_state_email', 'set_calendar_color_1', 'set_calendar_color_2', 'set_calendar_color_3', 'set_calendar_legende_1', 'set_calendar_legende_2', 'set_calendar_legende_3', 'set_calendar_background', 'set_calendar_border', 'set_calendar_date_label', 'set_calendar_date_desc', 'set_orderentry_subject', 'set_orderentry_email', 'set_orderentry_name', 'set_orderentry_sender', 'set_orderentry_recipient', 'set_paypal_email', 'set_paypal_currency', 'set_paypal_ipn'); foreach ($arrField as $fieldname) { $query = "\n SELECT 1 FROM " . DBPREFIX . "module_egov_configuration\n WHERE name='{$fieldname}'\n "; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } if ($objResult->RecordCount() == 1) { // The value is already there continue; } // Copy the original value $query = "\n INSERT INTO " . DBPREFIX . "module_egov_configuration (name, value)\n SELECT '{$fieldname}', `{$fieldname}`\n FROM " . DBPREFIX . "module_egov_settings\n "; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // Add new settings for Yellowpay $arrField = array('yellowpay_accepted_payment_methods' => '', 'yellowpay_authorization' => 'immediate', 'yellowpay_uid' => 'demo', 'yellowpay_hashseed' => 'demo', 'yellowpay_shopid' => '', 'yellowpay_use_testserver' => '1'); foreach ($arrField as $fieldname => $defaultvalue) { $query = "\n SELECT 1 FROM " . DBPREFIX . "module_egov_configuration\n WHERE name='{$fieldname}'\n "; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } if ($objResult->RecordCount() == 1) { // The value is already there continue; } // Add the new setting with its default value $query = "\n INSERT INTO " . DBPREFIX . "module_egov_configuration (\n name, value\n ) VALUES (\n '{$fieldname}', '{$defaultvalue}'\n )\n "; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // products table if (!in_array(DBPREFIX . "module_egov_products", $arrTables)) { $query = "\n CREATE TABLE `" . DBPREFIX . "module_egov_products` (\n `product_id` int(11) NOT NULL auto_increment,\n `product_autostatus` tinyint(1) NOT NULL default '0',\n `product_name` varchar(255) NOT NULL default '',\n `product_desc` text NOT NULL,\n `product_price` decimal(11,2) NOT NULL default '0.00',\n `product_per_day` enum('yes','no') NOT NULL default 'no',\n `product_quantity` tinyint(2) NOT NULL default '0',\n `product_target_email` varchar(255) NOT NULL default '',\n `product_target_url` varchar(255) NOT NULL default '',\n `product_message` text NOT NULL,\n `product_status` tinyint(1) NOT NULL default '1',\n `product_electro` tinyint(1) NOT NULL default '0',\n `product_file` varchar(255) NOT NULL default '',\n `product_sender_name` varchar(255) NOT NULL default '',\n `product_sender_email` varchar(255) NOT NULL default '',\n `product_target_subject` varchar(255) NOT NULL,\n `product_target_body` text NOT NULL,\n `product_paypal` tinyint(1) NOT NULL default '0',\n `product_paypal_sandbox` varchar(255) NOT NULL default '',\n `product_paypal_currency` varchar(255) NOT NULL default '',\n `product_orderby` int(11) NOT NULL default '0',\n PRIMARY KEY (`product_id`)\n ) TYPE=MyISAM;\n "; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // Add Yellowpay field to Product table $arrProductColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_egov_products'); if ($arrProductColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_egov_products')); return false; } if (!isset($arrProductColumns['YELLOWPAY'])) { $query = "\n ALTER TABLE " . DBPREFIX . "module_egov_products\n ADD `yellowpay` TINYINT(1) unsigned NOT NULL default '0'\n "; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // Add quantity limit field to Product table if (!isset($arrProductColumns['PRODUCT_QUANTITY_LIMIT'])) { $query = "\n ALTER TABLE " . DBPREFIX . "module_egov_products\n ADD `product_quantity_limit` TINYINT(2) unsigned NOT NULL default '1'\n AFTER `product_quantity`;\n "; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // Add alternative payment method name field to Product table if (!isset($arrProductColumns['ALTERNATIVE_NAMES'])) { $query = "\n ALTER TABLE " . DBPREFIX . "module_egov_products\n ADD `alternative_names` TEXT NOT NULL;\n "; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } /******************************** * EXTENSION: Timezone * * ADDED: Contrexx v3.0.0 * ********************************/ try { \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_egov_orders` CHANGE `order_date` `order_date` TIMESTAMP NOT NULL DEFAULT "0000-00-00 00:00:00"'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }
public static function DefaultActionHandler($e) { if ($e instanceof Update_DatabaseException) { return _databaseError($e->sql, $e->getMessage()); } setUpdateMsg($e->getMessage()); return false; }
function _writeNewConfigurationFile() { global $_CORELANG, $_ARRAYLANG, $_DBCONFIG, $_PATHCONFIG, $_FTPCONFIG, $_CONFIGURATION, $_CONFIG; $ftpStatus = $_FTPCONFIG['is_activated'] ? 'true' : 'false'; $charset = 'UTF-8'; $dbCharset = 'utf8'; $_FTPCONFIG['port'] = intval($_FTPCONFIG['port']); $configurationTpl = <<<CONFIG_TPL <?php global \$_DBCONFIG, \$_PATHCONFIG, \$_FTPCONFIG, \$_CONFIG; /** * @exclude * * Cloudrexx CMS Web Installer * Please use the Cloudrexx CMS installer to configure this file * or edit this file and configure the parameters for your site and * database manually. */ /** * ------------------------------------------------------------------------- * Set installation status * ------------------------------------------------------------------------- */ define('CONTREXX_INSTALLED', true); /** * ------------------------------------------------------------------------- * Database configuration section * ------------------------------------------------------------------------- */ \$_DBCONFIG['host'] = '{$_DBCONFIG['host']}'; // This is normally set to localhost \$_DBCONFIG['database'] = '{$_DBCONFIG['database']}'; // Database name \$_DBCONFIG['tablePrefix'] = '{$_DBCONFIG['tablePrefix']}'; // Database table prefix \$_DBCONFIG['user'] = '******'user']}'; // Database username \$_DBCONFIG['password'] = '******'password']}'; // Database password \$_DBCONFIG['dbType'] = '{$_DBCONFIG['dbType']}'; // Database type (e.g. mysql,postgres ..) \$_DBCONFIG['charset'] = '{$dbCharset}'; // Charset (default, latin1, utf8, ..) \$_DBCONFIG['timezone'] = '{$_CONFIG['timezone']}'; // Controller's timezone for model \$_DBCONFIG['collation'] = '{$_DBCONFIG['collation']}'; /** * ------------------------------------------------------------------------- * Site path specific configuration * ------------------------------------------------------------------------- */ \$_PATHCONFIG['ascms_root'] = ''; \$_PATHCONFIG['ascms_root_offset'] = ''; // example: '/cms'; \$_PATHCONFIG['ascms_installation_root'] = \$_PATHCONFIG['ascms_root']; \$_PATHCONFIG['ascms_installation_offset'] = \$_PATHCONFIG['ascms_root_offset']; // example: '/cms'; /** * ------------------------------------------------------------------------- * Ftp specific configuration * ------------------------------------------------------------------------- */ \$_FTPCONFIG['is_activated'] = {$ftpStatus}; // Ftp support true or false \$_FTPCONFIG['host'] = '{$_FTPCONFIG['host']}';// This is normally set to localhost \$_FTPCONFIG['port'] = {$_FTPCONFIG['port']}; // Ftp remote port \$_FTPCONFIG['username'] = '******'username']}'; // Ftp login username \$_FTPCONFIG['password'] = '******'password']}'; // Ftp login password \$_FTPCONFIG['path'] = '{$_FTPCONFIG['path']}'; // Ftp path to cms (must not include ascms_root_offset) /** * ------------------------------------------------------------------------- * Base setup (altering might break the system!) * ------------------------------------------------------------------------- */ // Set character encoding \$_CONFIG['coreCharacterEncoding'] = 'UTF-8'; // example 'UTF-8' CONFIG_TPL; // write settings try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . '/config/configuration.php'); $objFile->makeWritable(); $objFile->write($configurationTpl); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_WRITE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/configuration.php')); setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_DOCUMENT_ROOT . '/config/configuration.php', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } return true; }
/** * Cloudrexx * * @link http://www.cloudrexx.com * @copyright Cloudrexx AG 2007-2015 * * According to our dual licensing model, this program can be used either * under the terms of the GNU Affero General Public License, version 3, * or under a proprietary license. * * The texts of the GNU Affero General Public License with an additional * permission and of our proprietary license can be found at and * in the LICENSE file you have received along with this program. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * "Cloudrexx" is a registered trademark of Cloudrexx AG. * The licensing of the program under the AGPLv3 does not imply a * trademark license. Therefore any rights, title and interest in * our trademarks remain entirely with us. */ function _accessUpdate() { global $objDatabase, $objUpdate, $_CONFIG, $_ARRAYLANG, $_CORELANG; $arrTables = $objDatabase->MetaTables('TABLES'); if (!$arrTables) { setUpdateMsg($_ARRAYLANG['TXT_UNABLE_DETERMINE_DATABASE_STRUCTURE']); return false; } /**************************** * * ADD NOTIFICATION E-MAILS * ***************************/ try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_mail', array('type' => array('type' => 'ENUM(\'reg_confirm\',\'reset_pw\',\'user_activated\',\'user_deactivated\',\'new_user\')', 'notnull' => true, 'default' => 'reg_confirm'), 'lang_id' => array('type' => 'TINYINT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'sender_mail' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'sender_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'subject' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'format' => array('type' => 'ENUM(\'text\',\'html\',\'multipart\')', 'notnull' => true, 'default' => 'text'), 'body_text' => array('type' => 'TEXT'), 'body_html' => array('type' => 'TEXT')), array('mail' => array('fields' => array('type', 'lang_id'), 'type' => 'UNIQUE')), 'InnoDB'); $result = \Cx\Lib\UpdateUtil::sql('SHOW KEYS FROM `' . DBPREFIX . 'access_group_dynamic_ids`'); if ($result->EOF) { \Cx\Lib\UpdateUtil::sql('ALTER IGNORE TABLE `' . DBPREFIX . 'access_group_dynamic_ids` ADD PRIMARY KEY ( `access_id` , `group_id` )'); } $result = \Cx\Lib\UpdateUtil::sql('SHOW KEYS FROM `' . DBPREFIX . 'access_group_static_ids`'); if ($result->EOF) { \Cx\Lib\UpdateUtil::sql('ALTER IGNORE TABLE `' . DBPREFIX . 'access_group_static_ids` ADD PRIMARY KEY ( `access_id` , `group_id` )'); } } catch (\Cx\Lib\UpdateException $e) { // we COULD do something else here.. return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } \DBG::msg('001'); $arrMails = array(array('type' => 'reg_confirm', 'subject' => 'Benutzerregistrierung bestätigen', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nVielen Dank für Ihre Anmeldung bei [[HOST]].\\r\\nBitte klicken Sie auf den folgenden Link, um Ihre E-Mail-Adresse zu bestätigen:\\r\\n[[ACTIVATION_LINK]]\\r\\n\\r\\nUm sich später einzuloggen, geben Sie bitte Ihren Benutzernamen \\"[[USERNAME]]\\" und das Passwort ein, das Sie bei der Registrierung festgelegt haben.\\r\\n\\r\\n\\r\\n--\\r\\nIhr [[SENDER]]'), array('type' => 'reset_pw', 'subject' => 'Kennwort zurücksetzen', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nUm ein neues Passwort zu wählen, müssen Sie auf die unten aufgeführte URL gehen und dort Ihr neues Passwort eingeben.\\r\\n\\r\\nWICHTIG: Die Gültigkeit der URL wird nach 60 Minuten verfallen, nachdem diese E-Mail abgeschickt wurde.\\r\\nFalls Sie mehr Zeit benötigen, geben Sie Ihre E-Mail Adresse einfach ein weiteres Mal ein.\\r\\n\\r\\nIhre URL:\\r\\n[[URL]]\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'), array('type' => 'user_activated', 'subject' => 'Ihr Benutzerkonto wurde aktiviert', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nIhr Benutzerkonto auf [[HOST]] wurde soeben aktiviert und kann von nun an verwendet werden.\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'), array('type' => 'user_deactivated', 'subject' => 'Ihr Benutzerkonto wurde deaktiviert', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nIhr Benutzerkonto auf [[HOST]] wurde soeben deaktiviert.\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'), array('type' => 'new_user', 'subject' => 'Ein neuer Benutzer hat sich registriert', 'body_text' => 'Der Benutzer [[USERNAME]] hat sich soeben registriert und muss nun frei geschaltet werden.\\r\\n\\r\\nÜber die folgende Adresse kann das Benutzerkonto von [[USERNAME]] verwaltet werden:\\r\\n[[LINK]]\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]')); foreach ($arrMails as $arrMail) { $query = "SELECT 1 FROM `" . DBPREFIX . "access_user_mail` WHERE `type` = '" . $arrMail['type'] . "'"; $objMail = $objDatabase->SelectLimit($query, 1); if ($objMail !== false) { if ($objMail->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "access_user_mail` (\n `type`,\n `lang_id`,\n `sender_mail`,\n `sender_name`,\n `subject`,\n `body_text`,\n `body_html`\n ) VALUES (\n '" . $arrMail['type'] . "',\n 0,\n '" . addslashes($_CONFIG['coreAdminEmail']) . "',\n '" . addslashes($_CONFIG['coreAdminName']) . "',\n '" . $arrMail['subject'] . "',\n '" . $arrMail['body_text'] . "',\n ''\n )"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } /**************** * * ADD SETTINGS * ***************/ try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_settings', array('key' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'value' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'key'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'value')), array('key' => array('fields' => array('key'), 'type' => 'UNIQUE')), 'InnoDB'); if (in_array(DBPREFIX . "communit_config", $arrTables)) { $objResult = \Cx\Lib\UpdateUtil::sql('SELECT `name`, `value`, `status` FROM `' . DBPREFIX . 'community_config`'); while (!$objResult->EOF) { $arrCommunityConfig[$objResult->fields['name']] = array('value' => $objResult->fields['value'], 'status' => $objResult->fields['status']); $objResult->MoveNext(); } } $arrSettings = array('user_activation' => array('value' => '', 'status' => isset($arrCommunityConfig['user_activation']['status']) ? $arrCommunityConfig['user_activation']['status'] : 0), 'user_activation_timeout' => array('value' => isset($arrCommunityConfig['user_activation_timeout']['value']) ? $arrCommunityConfig['user_activation_timeout']['value'] : 0, 'status' => isset($arrCommunityConfig['user_activation_timeout']['status']) ? $arrCommunityConfig['user_activation_timeout']['status'] : 0), 'assigne_to_groups' => array('value' => isset($arrCommunityConfig['community_groups']['value']) ? $arrCommunityConfig['community_groups']['value'] : '', 'status' => 1), 'max_profile_pic_width' => array('value' => '160', 'status' => 1), 'max_profile_pic_height' => array('value' => '160', 'status' => 1), 'profile_thumbnail_pic_width' => array('value' => '50', 'status' => 1), 'profile_thumbnail_pic_height' => array('value' => '50', 'status' => 1), 'max_profile_pic_size' => array('value' => '30000', 'status' => 1), 'max_pic_width' => array('value' => '600', 'status' => 1), 'max_pic_height' => array('value' => '600', 'status' => 1), 'max_thumbnail_pic_width' => array('value' => '130', 'status' => 1), 'max_thumbnail_pic_height' => array('value' => '130', 'status' => 1), 'max_pic_size' => array('value' => '200000', 'status' => 1), 'notification_address' => array('value' => addslashes($_CONFIG['coreAdminEmail']), 'status' => 1), 'user_config_email_access' => array('value' => '', 'status' => 1), 'user_config_profile_access' => array('value' => '', 'status' => 1), 'default_email_access' => array('value' => 'members_only', 'status' => 1), 'default_profile_access' => array('value' => 'members_only', 'status' => 1), 'user_delete_account' => array('value' => '', 'status' => 1), 'block_currently_online_users' => array('value' => '10', 'status' => 0), 'block_currently_online_users_pic' => array('value' => '', 'status' => 0), 'block_last_active_users' => array('value' => '10', 'status' => 0), 'block_last_active_users_pic' => array('value' => '', 'status' => 0), 'block_latest_reg_users' => array('value' => '10', 'status' => 0), 'block_latest_reg_users_pic' => array('value' => '', 'status' => 0), 'block_birthday_users' => array('value' => '10', 'status' => 0), 'block_birthday_users_pic' => array('value' => '', 'status' => 0), 'session_user_interval' => array('value' => '0', 'status' => 1), 'user_accept_tos_on_signup' => array('value' => '', 'status' => 0), 'user_captcha' => array('value' => '', 'status' => 0), 'profile_thumbnail_method' => array('value' => 'crop', 'status' => 1), 'profile_thumbnail_scale_color' => array('value' => '#FFFFFF', 'status' => 1)); foreach ($arrSettings as $key => $arrSetting) { if (!\Cx\Lib\UpdateUtil::sql("SELECT 1 FROM `" . DBPREFIX . "access_settings` WHERE `key` = '" . $key . "'")->RecordCount()) { \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings`\n SET `key` = '" . $key . "',\n `value` = '" . $arrSetting['value'] . "',\n `status` = '" . $arrSetting['status'] . "'\n "); } } // delete obsolete table community_config \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'community_config'); // delete obsolete table user_validity \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'user_validity'); } catch (\Cx\Lib\UpdateException $e) { // we COULD do something else here.. return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /******************** * * ADD USER PROFILE * *******************/ try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_profile', array('user_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'gender' => array('type' => 'ENUM(\'gender_undefined\',\'gender_female\',\'gender_male\')', 'notnull' => true, 'default' => 'gender_undefined', 'after' => 'user_id'), 'title' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'gender'), 'firstname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'title'), 'lastname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'firstname'), 'company' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'lastname'), 'address' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'company'), 'city' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'after' => 'address'), 'zip' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => '', 'after' => 'city'), 'country' => array('type' => 'SMALLINT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'zip'), 'phone_office' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'country'), 'phone_private' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'phone_office'), 'phone_mobile' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'phone_private'), 'phone_fax' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'phone_mobile'), 'birthday' => array('type' => 'VARCHAR(11)', 'notnull' => false, 'after' => 'phone_fax'), 'website' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'birthday'), 'profession' => array('type' => 'VARCHAR(150)', 'notnull' => true, 'default' => '', 'after' => 'website'), 'interests' => array('type' => 'text', 'after' => 'profession'), 'signature' => array('type' => 'text', 'after' => 'interests'), 'picture' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'signature')), array('profile' => array('fields' => array('firstname' => 100, 'lastname' => 100, 'company' => 50))), 'InnoDB'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /*************************** * * MIGRATE GROUP RELATIONS * **************************/ try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_rel_user_group', array('user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'user_id')), array(), 'InnoDB'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'access_users'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users')); return false; } if (in_array('groups', $arrColumns)) { $query = "SELECT `id`, `groups` FROM " . DBPREFIX . "access_users WHERE `groups` != ''"; $objUser = $objDatabase->Execute($query); if ($objUser) { while (!$objUser->EOF) { $arrGroups = explode(',', $objUser->fields['groups']); foreach ($arrGroups as $groupId) { $query = "SELECT 1 FROM " . DBPREFIX . "access_rel_user_group WHERE `user_id` = " . $objUser->fields['id'] . " AND `group_id` = " . intval($groupId); $objRel = $objDatabase->SelectLimit($query, 1); if ($objRel) { if ($objRel->RecordCount() == 0) { $query = "INSERT INTO " . DBPREFIX . "access_rel_user_group (`user_id`, `group_id`) VALUES (" . $objUser->fields['id'] . ", " . intval($groupId) . ")"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } $objUser->MoveNext(); } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "ALTER TABLE `" . DBPREFIX . "access_users` DROP `groups`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } \DBG::msg('002'); /********************* * * ADD USER VALIDITY * ********************/ try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_validity', array('validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true)), array(), 'InnoDB'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } $query = "SELECT 1 FROM `" . DBPREFIX . "access_user_validity`"; $objResult = $objDatabase->SelectLimit($query, 1); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `" . DBPREFIX . "access_user_validity` (`validity`) VALUES\n ('0'), ('1'), ('15'), ('31'), ('62'),\n ('92'), ('123'), ('184'), ('366'), ('731')\n "; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } /******************** * * MIGRATE PROFILES * *******************/ if (in_array('firstname', $arrColumns)) { $query = "SELECT `id`, `firstname`, `lastname`, `residence`, `profession`, `interests`, `webpage`, `company`, `zip`, `phone`, `mobile`, `street` FROM `" . DBPREFIX . "access_users`"; $objUser = $objDatabase->Execute($query); if ($objUser) { while (!$objUser->EOF) { $query = "SELECT 1 FROM `" . DBPREFIX . "access_user_profile` WHERE `user_id` = " . $objUser->fields['id']; $objProfile = $objDatabase->SelectLimit($query, 1); if ($objProfile) { if ($objProfile->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "access_user_profile` (\n `user_id`,\n `gender`,\n `firstname`,\n `lastname`,\n `company`,\n `address`,\n `city`,\n `zip`,\n `country`,\n `phone_office`,\n `phone_private`,\n `phone_mobile`,\n `phone_fax`,\n `website`,\n `profession`,\n `interests`,\n `picture`\n ) VALUES (\n " . $objUser->fields['id'] . ",\n 'gender_undefined',\n '" . addslashes($objUser->fields['firstname']) . "',\n '" . addslashes($objUser->fields['lastname']) . "',\n '" . addslashes($objUser->fields['company']) . "',\n '" . addslashes($objUser->fields['street']) . "',\n '" . addslashes($objUser->fields['residence']) . "',\n '" . addslashes($objUser->fields['zip']) . "',\n 0,\n '',\n '" . addslashes($objUser->fields['phone']) . "',\n '" . addslashes($objUser->fields['mobile']) . "',\n '',\n '" . addslashes($objUser->fields['webpage']) . "',\n '" . addslashes($objUser->fields['profession']) . "',\n '" . addslashes($objUser->fields['interests']) . "',\n ''\n )"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $objUser->MoveNext(); } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } $arrRemoveColumns = array('firstname', 'lastname', 'residence', 'profession', 'interests', 'webpage', 'company', 'zip', 'phone', 'mobile', 'street', 'levelid'); foreach ($arrRemoveColumns as $column) { if (in_array($column, $arrColumns)) { $query = "ALTER TABLE " . DBPREFIX . "access_users DROP `" . $column . "`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } $arrColumnDetails = $objDatabase->MetaColumns(DBPREFIX . 'access_users'); if ($arrColumnDetails === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users')); return false; } if (in_array('regdate', $arrColumns)) { if ($arrColumnDetails['REGDATE']->type == 'date') { if (!in_array('regdate_new', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `regdate_new` INT( 14 ) UNSIGNED NULL DEFAULT '0' AFTER `regdate`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } $query = "UPDATE `" . DBPREFIX . "access_users` SET `regdate_new` = UNIX_TIMESTAMP(`regdate`), `regdate` = '0000-00-00' WHERE `regdate` != '0000-00-00'"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "ALTER TABLE `" . DBPREFIX . "access_users` DROP `regdate`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'access_users'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users')); return false; } if (in_array('regdate_new', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` CHANGE `regdate_new` `regdate` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0'"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } $query = "ALTER TABLE `" . DBPREFIX . "access_users` CHANGE `is_admin` `is_admin` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } if (!in_array('email_access', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `email_access` ENUM( 'everyone', 'members_only', 'nobody' ) NOT NULL DEFAULT 'nobody' AFTER `email`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (!in_array('profile_access', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `profile_access` ENUM( 'everyone', 'members_only', 'nobody' ) NOT NULL DEFAULT 'members_only' AFTER `active`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (!in_array('frontend_lang_id', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` CHANGE `langId` `frontend_lang_id` INT( 2 ) UNSIGNED NOT NULL DEFAULT '0'"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (!in_array('backend_lang_id', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `backend_lang_id` INT( 2 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `frontend_lang_id`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } else { $query = "UPDATE `" . DBPREFIX . "access_users` SET `backend_lang_id` = `frontend_lang_id`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } if (!in_array('last_auth', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `last_auth` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `regdate`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (!in_array('last_activity', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `last_activity` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `last_auth`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (!in_array('expiration', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `expiration` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `regdate`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (!in_array('validity', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `validity` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `expiration`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } else { try { \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "access_users` SET `expiration` = `validity`*60*60*24+`regdate` WHERE `expiration` = 0 AND `validity` > 0"); } catch (\Cx\Lib\UpdateException $e) { // we COULD do something else here.. return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } \DBG::msg('003'); /*********************************** * * MIGRATE COMMUNITY CONTENT PAGES * **********************************/ // only execute this part for versions < 2.0.0 $pattern = array('/section=community&(amp;)?cmd=profile/', '/section=community&(amp;)?cmd=register/', '/section=community/'); $replacement = array('section=access&$1cmd=settings', 'section=access&$1cmd=signup', 'section=access'); try { \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array(), $pattern, $replacement, array('content', 'target'), '2.0.0'); \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'community'), array('/community/', '/profile/', '/register/'), array('access', 'settings', 'signup'), array('module', 'cmd'), '2.0.0'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /*********************************** * * CREATE PROFILE ATTRIBUTE TABLES * **********************************/ try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_attribute', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'id'), 'type' => array('type' => 'ENUM(\'text\',\'textarea\',\'mail\',\'uri\',\'date\',\'image\',\'checkbox\',\'menu\',\'menu_option\',\'group\',\'frame\',\'history\')', 'notnull' => true, 'default' => 'text', 'after' => 'parent_id'), 'mandatory' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'type'), 'sort_type' => array('type' => 'ENUM(\'asc\',\'desc\',\'custom\')', 'notnull' => true, 'default' => 'asc', 'after' => 'mandatory'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'sort_type'), 'access_special' => array('type' => 'ENUM(\'\',\'menu_select_higher\',\'menu_select_lower\')', 'notnull' => true, 'default' => '', 'after' => 'order_id'), 'access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'access_special')), array(), 'InnoDB'); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_attribute_name', array('attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'attribute_id'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'lang_id')), array(), 'InnoDB'); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_attribute_value', array('attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'attribute_id'), 'history_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'user_id'), 'value' => array('type' => 'text', 'after' => 'history_id')), array('value' => array('fields' => array('value'), 'type' => 'FULLTEXT'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_core_attribute', array('id' => array('type' => 'VARCHAR(25)', 'primary' => true), 'mandatory' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'sort_type' => array('type' => 'ENUM(\'asc\',\'desc\',\'custom\')', 'notnull' => true, 'default' => 'asc', 'after' => 'mandatory'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'sort_type'), 'access_special' => array('type' => 'ENUM(\'\',\'menu_select_higher\',\'menu_select_lower\')', 'notnull' => true, 'default' => '', 'after' => 'order_id'), 'access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'access_special')), array(), 'InnoDB'); /************************ * * ADD USER TITLE TABLE * ***********************/ \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_title', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'title')), array('title' => array('fields' => array('title'), 'type' => 'UNIQUE')), 'InnoDB'); $arrDefaultTitle = array('Sehr geehrte Frau', 'Sehr geehrter Herr', 'Dear Ms', 'Dear Mr', 'Madame', 'Monsieur'); foreach ($arrDefaultTitle as $title) { \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_user_title` SET `title` = '" . $title . "' ON DUPLICATE KEY UPDATE `id` = `id`"); } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /****************************** * * REMOVE OBSOLETE ACCESS IDS * *****************************/ $query = 'DELETE FROM `' . DBPREFIX . 'access_group_static_ids` WHERE `access_id` IN (28, 29, 30, 33, 34, 36)'; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } /******************* * * MIGRATE SESSION * ******************/ $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'sessions'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'sessions')); return false; } if (!in_array('user_id', $arrColumns)) { $query = "\n ALTER TABLE `" . DBPREFIX . "sessions`\n DROP `username`,\n ADD `user_id` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `status`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } /*************************************** * * ADD CHECKBOX PROFILE ATTRIBUTE TYPE * **************************************/ $query = "ALTER TABLE `" . DBPREFIX . "access_user_attribute` CHANGE `type` `type` enum('text','textarea','mail','uri','date','image','checkbox','menu','menu_option','group','frame','history') NOT NULL DEFAULT 'text'"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } // Currently, this is only here to create the u2u_active field.. but instead of adding // 10 lines for each new field in the future, why not just extend this block try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_users', array('id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'is_admin' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'id'), 'username' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'is_admin'), 'password' => array('type' => 'VARCHAR(32)', 'notnull' => false, 'after' => 'username'), 'regdate' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'password'), 'expiration' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'regdate'), 'validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'expiration'), 'last_auth' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'validity'), 'last_auth_status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '1', 'after' => 'last_auth'), 'last_activity' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'last_auth_status'), 'email' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'last_activity'), 'email_access' => array('type' => 'ENUM(\'everyone\',\'members_only\',\'nobody\')', 'notnull' => true, 'default' => 'nobody', 'after' => 'email'), 'frontend_lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'email_access'), 'backend_lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'frontend_lang_id'), 'active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'backend_lang_id'), 'primary_group' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'active'), 'profile_access' => array('type' => 'ENUM(\'everyone\',\'members_only\',\'nobody\')', 'notnull' => true, 'default' => 'members_only', 'after' => 'primary_group'), 'restore_key' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => '', 'after' => 'profile_access'), 'restore_key_time' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'restore_key'), 'u2u_active' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '1', 'after' => 'restore_key_time')), array('username' => array('fields' => array('username')))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_groups', array('group_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'group_name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'group_id'), 'group_description' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'group_name'), 'is_active' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '1', 'after' => 'group_description'), 'type' => array('type' => 'ENUM(\'frontend\',\'backend\')', 'notnull' => true, 'default' => 'frontend', 'after' => 'is_active'), 'homepage' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'type'))); } catch (\Cx\Lib\UpdateException $e) { // we COULD do something else here.. return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } \DBG::msg('004'); // only update if installed version is at least a version 2.0.0 // older versions < 2.0 have a complete other structure of the content page and must therefore completely be reinstalled if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) { try { // migrate content page to version 3.0.1 $search = array('/(.*)/ms'); $callback = function ($matches) { $content = $matches[1]; if (empty($content)) { return $content; } // add missing access_captcha template block if (!preg_match('/<!--\\s+BEGIN\\s+access_captcha\\s+-->.*<!--\\s+END\\s+access_captcha\\s+-->/ms', $content)) { $content = preg_replace('/(<\\/fieldset>|)(\\s*)(<p[^>]*>|)(\\{ACCESS_SIGNUP_BUTTON\\})(<\\/p>|)/ms', '$2<!-- BEGIN access_captcha -->$2$3<label>{TXT_ACCESS_CAPTCHA}</label>{ACCESS_CAPTCHA_CODE}$5$2<!-- END access_captcha -->$2$1$2$3$4$5', $content); } // add missing access_newsletter template block if (!preg_match('/<!--\\s+BEGIN\\s+access_newsletter\\s+-->.*<!--\\s+END\\s+access_newsletter\\s+-->/ms', $content)) { $content = preg_replace('/(\\s*)(<p[^>]*>|)(\\{ACCESS_SIGNUP_BUTTON\\})(<\\/p>|)/ms', '$1<!-- BEGIN access_newsletter -->$1<fieldset><legend>Newsletter abonnieren</legend>$1 <!-- BEGIN access_newsletter_list -->$1 <p>$1 <label for="access_user_newsletters-{ACCESS_NEWSLETTER_ID}"> {ACCESS_NEWSLETTER_NAME}</label>$1 <input type="checkbox" name="access_user_newsletters[]" id="access_user_newsletters-{ACCESS_NEWSLETTER_ID}" value="{ACCESS_NEWSLETTER_ID}"{ACCESS_NEWSLETTER_SELECTED} />$1 </p>$1 <!-- END access_newsletter_list -->$1</fieldset>$1<!-- END access_newsletter -->$1$2$3$4', $content); } return $content; }; \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'access', 'cmd' => 'signup'), $search, $callback, array('content'), '3.0.1'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } /*************************************** * * ADD NETWORK TABLE FOR SOCIAL LOGIN * **************************************/ if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) { try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_network', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'oauth_provider' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'oauth_id' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'oauth_provider'), 'user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'oauth_id')), array(), 'InnoDB'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /*************************************** * * ADD NEW VALUES FOR SOCIAL LOGIN * **************************************/ try { \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin', '', '0') ON DUPLICATE KEY UPDATE `key` = `key`"); \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_show_signup', '', 0) ON DUPLICATE KEY UPDATE `key` = `key`"); \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('use_usernames', '0', '1') ON DUPLICATE KEY UPDATE `key` = `key`"); \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_assign_to_groups', '3', '0') ON DUPLICATE KEY UPDATE `key` = `key`"); \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_active_automatically', '', '1') ON DUPLICATE KEY UPDATE `key` = `key`"); \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ('access', 'providers', 'sociallogin', 'text', '{\"facebook\":{\"active\":\"0\",\"settings\":[\"\",\"\"]},\"twitter\":{\"active\":\"0\",\"settings\":[\"\",\"\"]},\"google\":{\"active\":\"0\",\"settings\":[\"\",\"\",\"\"]}}', '', '0') ON DUPLICATE KEY UPDATE `section` = `section`"); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /** * Content page * access signup */ try { // migrate content page to version 3.0.1 $search = array('/(.*)/ms'); $callback = function ($matches) { $content = $matches[1]; if (empty($content)) { return $content; } // fix duplicated social networks blocks if (preg_match('/<!--\\s+BEGIN\\s+access_social_networks\\s+-->.*<!--\\s+BEGIN\\s+access_social_networks\\s+-->/ms', $content)) { $content = preg_replace('/<br\\s+\\/><br\\s+\\/><!--\\s+BEGIN\\s+access_social_networks\\s+-->.*?<!--\\s+END\\s+access_social_networks\\s+-->/ms', '', $content); } // add missing access_social_networks template block if (!preg_match('/<!--\\s+BEGIN\\s+access_social_networks\\s+-->.*<!--\\s+END\\s+access_social_networks\\s+-->/ms', $content)) { $content = preg_replace('/(<!--\\s+BEGIN\\s+access_signup_form\\s+-->.*?)(<div[^>]*>|)(.*?\\{ACCESS_SIGNUP_MESSAGE\\}.*?)(<\\/div>|)/ms', '$1<br /><br /><!-- BEGIN access_social_networks --><fieldset><legend>oder Login mit Social Media</legend><!-- BEGIN access_social_networks_facebook --> <a class="facebook loginbutton" href="{ACCESS_SOCIALLOGIN_FACEBOOK}">Facebook</a> <!-- END access_social_networks_facebook --> <!-- BEGIN access_social_networks_google --> <a class="google loginbutton" href="{ACCESS_SOCIALLOGIN_GOOGLE}">Google</a> <!-- END access_social_networks_google --> <!-- BEGIN access_social_networks_twitter --> <a class="twitter loginbutton" href="{ACCESS_SOCIALLOGIN_TWITTER}">Twitter</a> <!-- END access_social_networks_twitter --> </fieldset> <!-- END access_social_networks -->$2$3$4', $content); } return $content; }; \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'access', 'cmd' => 'signup'), $search, $callback, array('content'), '3.0.2'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } /*************************************** * * ADD SETTING FOR SOCIAL LOGIN * **************************************/ if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) { try { \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_activation_timeout', '10', '0') ON DUPLICATE KEY UPDATE `key` = `key`"); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } /*************************************** * * STRICT_TRANS_TABLES ISSUE FIX FOR PROFILE TABLE * **************************************/ if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) { try { \Cx\Lib\UpdateUtil::sql("ALTER TABLE `" . DBPREFIX . "access_user_profile` CHANGE `interests` `interests` TEXT NULL"); \Cx\Lib\UpdateUtil::sql("ALTER TABLE `" . DBPREFIX . "access_user_profile` CHANGE `signature` `signature` TEXT NULL"); // add access to filesharing for existing groups try { $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 7 GROUP BY group_id"); if ($result !== false) { while (!$result->EOF) { \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n VALUES (8, " . intval($result->fields['group_id']) . ")"); $result->MoveNext(); } } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } /************************************************ * BUGFIX: Set write access to the upload dir * ************************************************/ // This is obsolete due to the new \Cx\Lib\FileSystem /* require_once ASCMS_FRAMEWORK_PATH.'/File.class.php'; $objFile = new File(); if (is_writeable(ASCMS_ACCESS_PROFILE_IMG_PATH) || $objFile->setChmod(ASCMS_ACCESS_PROFILE_IMG_PATH, ASCMS_ACCESS_PROFILE_IMG_WEB_PATH, '')) { if ($mediaDir = @opendir(ASCMS_ACCESS_PROFILE_IMG_PATH)) { while($file = readdir($mediaDir)) { if ($file != '.' && $file != '..') { if (!is_writeable(ASCMS_ACCESS_PROFILE_IMG_PATH.'/'.$file) && !$objFile->setChmod(ASCMS_ACCESS_PROFILE_IMG_PATH.'/', ASCMS_ACCESS_PROFILE_IMG_WEB_PATH.'/', $file)) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_ACCESS_PROFILE_IMG_PATH.'/'.$file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PROFILE_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PROFILE_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } require_once ASCMS_FRAMEWORK_PATH.'/File.class.php'; $objFile = new File(); if (is_writeable(ASCMS_ACCESS_PHOTO_IMG_PATH) || $objFile->setChmod(ASCMS_ACCESS_PHOTO_IMG_PATH, ASCMS_ACCESS_PHOTO_IMG_WEB_PATH, '')) { if ($mediaDir = @opendir(ASCMS_ACCESS_PHOTO_IMG_PATH)) { while($file = readdir($mediaDir)) { if ($file != '.' && $file != '..') { if (!is_writeable(ASCMS_ACCESS_PHOTO_IMG_PATH.'/'.$file) && !$objFile->setChmod(ASCMS_ACCESS_PHOTO_IMG_PATH.'/', ASCMS_ACCESS_PHOTO_IMG_WEB_PATH.'/', $file)) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_ACCESS_PHOTO_IMG_PATH.'/'.$file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PHOTO_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PHOTO_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; }*/ return true; }
function _newsUpdate() { global $objDatabase, $_CONFIG, $objUpdate, $_ARRAYLANG; /************************************************ * EXTENSION: Placeholder NEWS_LINK replaced * * by NEWS_LINK_TITLE * * ADDED: Contrexx v2.1.0 * ************************************************/ if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.1.0')) { try { \Cx\Lib\UpdateUtil::migrateContentPage('news', null, '{NEWS_LINK}', '{NEWS_LINK_TITLE}', '2.1.0'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } /************************************************ * EXTENSION: Front- and backend permissions * * ADDED: Contrexx v2.1.0 * ************************************************/ $query = "SELECT 1 FROM `" . DBPREFIX . "module_news_settings` WHERE `name` = 'news_message_protection'"; $objResult = $objDatabase->SelectLimit($query, 1); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_news_settings` (`name`, `value`) VALUES ('news_message_protection', '1'),\n ('recent_news_message_limit', '5')\n "; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "SELECT 1 FROM `" . DBPREFIX . "module_news_settings` WHERE `name` = 'news_message_protection_restricted'"; $objResult = $objDatabase->SelectLimit($query, 1); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_news_settings` (`name`, `value`) VALUES ('news_message_protection_restricted', '1')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'module_news'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_news')); return false; } if (!in_array('frontend_access_id', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "module_news` ADD `frontend_access_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `validated`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (!in_array('backend_access_id', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "module_news` ADD `backend_access_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `frontend_access_id`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } /************************************************ * EXTENSION: Thunbmail Image * * ADDED: Contrexx v2.1.0 * ************************************************/ $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'module_news'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_news')); return false; } if (!in_array('teaser_image_thumbnail_path', $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "module_news` ADD `teaser_image_thumbnail_path` TEXT NOT NULL AFTER `teaser_image_path`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } try { // delete obsolete table contrexx_module_news_access \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_news_access'); # fix some ugly NOT NULL without defaults \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news', array('id' => array('type' => 'INT(6) UNSIGNED', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'date' => array('type' => 'INT(14)', 'notnull' => false, 'default_expr' => 'NULL'), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'text' => array('type' => 'MEDIUMTEXT', 'notnull' => true), 'redirect' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'source' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'url1' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'url2' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'catid' => array('type' => 'INT(2) UNSIGNED', 'notnull' => true, 'default' => 0), 'lang' => array('type' => 'INT(2) UNSIGNED', 'notnull' => true, 'default' => 0), 'userid' => array('type' => 'INT(6) UNSIGNED', 'notnull' => true, 'default' => 0), 'startdate' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'enddate' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'status' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => 1), 'validated' => array('type' => "ENUM('0','1')", 'notnull' => true, 'default' => 0), 'frontend_access_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'default' => 0), 'backend_access_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'default' => 0), 'teaser_only' => array('type' => "ENUM('0','1')", 'notnull' => true, 'default' => 0), 'teaser_frames' => array('type' => 'TEXT', 'notnull' => true), 'teaser_text' => array('type' => 'TEXT', 'notnull' => true), 'teaser_show_link' => array('type' => 'TINYINT(1) UNSIGNED', 'notnull' => true, 'default' => 1), 'teaser_image_path' => array('type' => 'TEXT', 'notnull' => true), 'teaser_image_thumbnail_path' => array('type' => 'TEXT', 'notnull' => true), 'changelog' => array('type' => 'INT(14)', 'notnull' => true, 'default' => 0)), array('newsindex' => array('type' => 'FULLTEXT', 'fields' => array('text', 'title', 'teaser_text')))); } catch (\Cx\Lib\UpdateException $e) { // we COULD do something else here.. DBG::trace(); return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } //encoding was a little messy in 2.1.4. convert titles and teasers to their raw representation if ($_CONFIG['coreCmsVersion'] == "2.1.4") { try { $res = \Cx\Lib\UpdateUtil::sql('SELECT `id`, `title`, `teaser_text` FROM `' . DBPREFIX . 'module_news` WHERE `changelog` > ' . mktime(0, 0, 0, 12, 15, 2010)); while ($res->MoveNext()) { $title = $res->fields['title']; $teaserText = $res->fields['teaser_text']; $id = $res->fields['id']; //title is html entity style $title = html_entity_decode($title, ENT_QUOTES, CONTREXX_CHARSET); //teaserText is html entity style, but no cloudrexx was specified on encoding $teaserText = html_entity_decode($teaserText); \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_news` SET `title`="' . addslashes($title) . '", `teaser_text`="' . addslashes($teaserText) . '" where `id`=' . $id); } $hfr = new HackyFeedRepublisher(); $hfr->runRepublishing(); } catch (\Cx\Lib\UpdateException $e) { DBG::trace(); return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } /**************************** * ADDED: Contrexx v3.0.0 * *****************************/ try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_locale', array('news_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'news_id'), 'is_active' => array('type' => 'INT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'lang_id'), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'is_active'), 'text' => array('type' => 'mediumtext', 'notnull' => true, 'after' => 'title'), 'teaser_text' => array('type' => 'text', 'notnull' => true, 'after' => 'text')), array('newsindex' => array('fields' => array('text', 'title', 'teaser_text'), 'type' => 'FULLTEXT'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories_locale', array('category_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'category_id'), 'name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'lang_id')), array('name' => array('fields' => array('name'), 'type' => 'FULLTEXT'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_types', array('typeid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_types_locale', array('lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'type_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'lang_id'), 'name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'type_id')), array('name' => array('fields' => array('name'), 'type' => 'FULLTEXT'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_settings_locale', array('name' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'primary' => true), 'lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'name'), 'value' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'lang_id')), array('name' => array('fields' => array('name'), 'type' => 'FULLTEXT'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_comments', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'text' => array('type' => 'mediumtext', 'notnull' => true, 'after' => 'title'), 'newsid' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'text'), 'date' => array('type' => 'INT(14)', 'notnull' => false, 'default' => NULL, 'after' => 'newsid'), 'poster_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'date'), 'userid' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'poster_name'), 'ip_address' => array('type' => 'VARCHAR(15)', 'notnull' => true, 'default' => '0.0.0.0', 'after' => 'userid'), 'is_active' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '1', 'after' => 'ip_address'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_stats_view', array('user_sid' => array('type' => 'CHAR(32)', 'notnull' => true), 'news_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'after' => 'user_sid'), 'time' => array('type' => 'timestamp', 'notnull' => true, 'default_expr' => 'CURRENT_TIMESTAMP', 'on_update' => 'CURRENT_TIMESTAMP', 'after' => 'news_id')), array('idx_user_sid' => array('fields' => array('user_sid')), 'idx_news_id' => array('fields' => array('news_id')))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news', array('id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'date' => array('type' => 'INT(14)', 'notnull' => false, 'default' => NULL, 'after' => 'id'), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'date'), 'text' => array('type' => 'mediumtext', 'notnull' => true, 'after' => 'title'), 'redirect' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'text'), 'source' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'redirect'), 'url1' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'source'), 'url2' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'url1'), 'catid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'url2'), 'lang' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'catid'), 'typeid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'lang'), 'publisher' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'typeid'), 'publisher_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'publisher'), 'author' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'publisher_id'), 'author_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'author'), 'userid' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'author_id'), 'startdate' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'userid'), 'enddate' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'startdate'), 'status' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '1', 'after' => 'enddate'), 'validated' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'status'), 'frontend_access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'validated'), 'backend_access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'frontend_access_id'), 'teaser_only' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'backend_access_id'), 'teaser_frames' => array('type' => 'text', 'notnull' => true, 'after' => 'teaser_only'), 'teaser_text' => array('type' => 'text', 'notnull' => true, 'after' => 'teaser_frames'), 'teaser_show_link' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'teaser_text'), 'teaser_image_path' => array('type' => 'text', 'notnull' => true, 'after' => 'teaser_show_link'), 'teaser_image_thumbnail_path' => array('type' => 'text', 'notnull' => true, 'after' => 'teaser_image_path'), 'changelog' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0', 'after' => 'teaser_image_thumbnail_path'), 'allow_comments' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'changelog')), array('newsindex' => array('fields' => array('text', 'title', 'teaser_text'), 'type' => 'FULLTEXT'))); $arrColumnsNews = $objDatabase->MetaColumnNames(DBPREFIX . 'module_news'); if ($arrColumnsNews === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_news')); return false; } if (isset($arrColumnsNews['TITLE']) && isset($arrColumnsNews['TEXT']) && isset($arrColumnsNews['TEASER_TEXT']) && isset($arrColumnsNews['LANG'])) { \Cx\Lib\UpdateUtil::sql(' INSERT INTO `' . DBPREFIX . 'module_news_locale` (`news_id`, `lang_id`, `title`, `text`, `teaser_text`) SELECT `id`, `lang`, `title`, `text`, `teaser_text` FROM `' . DBPREFIX . 'module_news` ON DUPLICATE KEY UPDATE `news_id` = `news_id` '); } if (isset($arrColumnsNews['TITLE'])) { \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news` DROP `title`'); } if (isset($arrColumnsNews['TEXT'])) { \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news` DROP `text`'); } if (isset($arrColumnsNews['TEASER_TEXT'])) { \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news` DROP `teaser_text`'); } if (isset($arrColumnsNews['LANG'])) { \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news` DROP `lang`'); } $arrColumnsNewsCategories = $objDatabase->MetaColumnNames(DBPREFIX . 'module_news_categories'); if ($arrColumnsNewsCategories === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_news_categories')); return false; } if (isset($arrColumnsNewsCategories['NAME'])) { \Cx\Lib\UpdateUtil::sql(' INSERT INTO ' . DBPREFIX . 'module_news_categories_locale (`category_id`, `lang_id`, `name`) SELECT c.catid, l.id, c.name FROM ' . DBPREFIX . 'module_news_categories AS c, ' . DBPREFIX . 'languages AS l ORDER BY c.catid, l.id ON DUPLICATE KEY UPDATE `category_id` = `category_id` '); \Cx\Lib\UpdateUtil::sql(' INSERT INTO ' . DBPREFIX . 'module_news_categories_locale (`category_id`, `lang_id`, `name`) SELECT c.catid, l.id, c.name FROM ' . DBPREFIX . 'module_news_categories AS c, ' . DBPREFIX . 'languages AS l ORDER BY c.catid, l.id ON DUPLICATE KEY UPDATE `category_id` = `category_id` '); \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news_categories` DROP `name`'); } if (isset($arrColumnsNewsCategories['LANG'])) { \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news_categories` DROP `lang`'); } \Cx\Lib\UpdateUtil::sql(' INSERT INTO `' . DBPREFIX . 'module_news_settings_locale` (`name`, `lang_id`, `value`) SELECT n.`name`, l.`id`, n.`value` FROM `' . DBPREFIX . 'module_news_settings` AS n, `' . DBPREFIX . 'languages` AS l WHERE n.`name` IN ("news_feed_description", "news_feed_title") ORDER BY n.`name`, l.`id` ON DUPLICATE KEY UPDATE `' . DBPREFIX . 'module_news_settings_locale`.`name` = `' . DBPREFIX . 'module_news_settings_locale`.`name` '); \Cx\Lib\UpdateUtil::sql('DELETE FROM `' . DBPREFIX . 'module_news_settings` WHERE `name` IN ("news_feed_title", "news_feed_description")'); \Cx\Lib\UpdateUtil::sql(' INSERT INTO `' . DBPREFIX . 'module_news_settings` (`name`, `value`) VALUES ("news_comments_activated", "0"), ("news_comments_anonymous", "0"), ("news_comments_autoactivate", "0"), ("news_comments_notification", "1"), ("news_comments_timeout", "30"), ("news_default_teasers", ""), ("news_use_types","0"), ("news_use_top","0"), ("news_top_days","10"), ("news_top_limit","10"), ("news_assigned_author_groups", "0"), ("news_assigned_publisher_groups", "0") ON DUPLICATE KEY UPDATE `name` = `name` '); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } try { \Cx\Lib\UpdateUtil::migrateContentPage('news', 'details', array('{NEWS_DATE}', '{NEWS_COMMENTS_DATE}'), array('{NEWS_LONG_DATE}', '{NEWS_COMMENTS_LONG_DATE}'), '3.0.1'); // this adds the block news_redirect $search = array('/.*\\{NEWS_TEXT\\}.*/ms'); $callback = function ($matches) { if (!preg_match('/<!--\\s+BEGIN\\s+news_redirect\\s+-->/ms', $matches[0])) { $newsContent = <<<NEWS <!-- BEGIN news_text -->{NEWS_TEXT}<!-- END news_text --> <!-- BEGIN news_redirect -->{TXT_NEWS_REDIRECT_INSTRUCTION} <a href="{NEWS_REDIRECT_URL}" target="_blank">{NEWS_REDIRECT_URL}</a><!-- END news_redirect --> NEWS; return str_replace('{NEWS_TEXT}', $newsContent, $matches[0]); } else { return $matches[0]; } }; \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'news', 'cmd' => 'details'), $search, $callback, array('content'), '3.0.1'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } try { // migrate content page to version 3.0.1 $search = array('/(.*)/ms'); $callback = function ($matches) { $content = $matches[1]; if (empty($content)) { return $content; } // migrate to ckeditor $content = str_replace('FCKeditorAPI.GetInstance(\'newsText\').SetData(\'\')', 'CKEDITOR.instances[\'newsText\'].setData()', $content); if (!preg_match('/<!--\\s+BEGIN\\s+news_submit_form_captcha\\s+-->.*<!--\\s+END\\s+news_submit_form_captcha\\s+-->/ms', $content)) { // check if captcha code is already present if (preg_match('/\\{IMAGE_URL\\}/ms', $content)) { // add missing template block news_submit_form_captcha $content = preg_replace('/(.*)(<p[^>]*>.*?<label[^>]*>.*?\\{IMAGE_URL\\}.*?<\\/p>)/ms', '$1<!-- BEGIN news_submit_form_captcha -->$2<!-- END news_submit_form_captcha -->', $content); } else { // add whole captcha code incl. template block $content = preg_replace('/(.*)(<tr[^>]*>.*?<td([^>]*)>.*?\\{NEWS_TEXT\\}.*?(\\s*)<\\/tr>)/ms', '$1$2$4<!-- BEGIN news_submit_form_captcha -->$4<tr>$4 <td$3>{NEWS_CAPTCHA_CODE}</td>$4</tr>$4<!-- END news_submit_form_captcha -->', $content); } } // add text variable $content = str_replace('Captcha', '{TXT_NEWS_CAPTCHA}', $content); // replace image with {NEWS_CAPTCHA_CODE} $content = preg_replace('/<img[^>]+\\{IMAGE_URL\\}[^>]+>(?:<br\\s*\\/?>)?/ms', '{NEWS_CAPTCHA_CODE}', $content); // remove {TXT_CAPTCHA} $content = str_replace('{TXT_CAPTCHA}', '', $content); // remove <input type="text" name="captcha" id="captcha" /> $content = preg_replace('/<input[^>]+name\\s*=\\s*[\'"]captcha[\'"][^>]*>/ms', '', $content); return $content; }; \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'news', 'cmd' => 'submit'), $search, $callback, array('content'), '3.0.1'); \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'news'), '/(\\{NEWS_COUNT_COMMENTS\\})/', '<!-- BEGIN news_comments_count -->$1<!-- END news_comments_count -->', array('content'), '3.0.3'); \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'news', 'cmd' => 'details'), '/(\\{NEWS_COUNT_COMMENTS\\})/', '<!-- BEGIN news_comments_count -->$1<!-- END news_comments_count -->', array('content'), '3.0.3'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /************************************************ * EXTENSION: Categories as NestedSet * * ADDED: Contrexx v3.1.0 * ************************************************/ if (!isset($_SESSION['contrexx_update']['news'])) { $_SESSION['contrexx_update']['news'] = array(); } if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0') && !isset($_SESSION['contrexx_update']['news']['nestedSet'])) { try { $nestedSetRootId = null; $count = null; $leftAndRight = 2; $sorting = 1; $level = 2; // add nested set columns \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories', array('catid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(11)', 'after' => 'catid'), 'left_id' => array('type' => 'INT(11)', 'after' => 'parent_id'), 'right_id' => array('type' => 'INT(11)', 'after' => 'left_id'), 'sorting' => array('type' => 'INT(11)', 'after' => 'right_id'), 'level' => array('type' => 'INT(11)', 'after' => 'sorting'))); // add nested set root node and select its id $objResultRoot = \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_news_categories` (`catid`, `parent_id`, `left_id`, `right_id`, `sorting`, `level`) VALUES (0, 0, 0, 0, 0, 0)'); if ($objResultRoot) { $nestedSetRootId = $objDatabase->Insert_ID(); } // count categories $objResultCount = \Cx\Lib\UpdateUtil::sql('SELECT count(`catid`) AS count FROM `' . DBPREFIX . 'module_news_categories`'); if ($objResultCount && !$objResultCount->EOF) { $count = $objResultCount->fields['count']; } // add nested set information to root node \Cx\Lib\UpdateUtil::sql(' UPDATE `' . DBPREFIX . 'module_news_categories` SET `parent_id` = ' . $nestedSetRootId . ', `left_id` = 1, `right_id` = ' . $count * 2 . ', `sorting` = 1, `level` = 1 WHERE `catid` = ' . $nestedSetRootId . ' '); // add nested set information to all categories $objResultCatSelect = \Cx\Lib\UpdateUtil::sql('SELECT `catid` FROM `' . DBPREFIX . 'module_news_categories` ORDER BY `catid` ASC'); if ($objResultCatSelect) { while (!$objResultCatSelect->EOF) { $catId = $objResultCatSelect->fields['catid']; if ($catId != $nestedSetRootId) { \Cx\Lib\UpdateUtil::sql(' UPDATE `' . DBPREFIX . 'module_news_categories` SET `parent_id` = ' . $nestedSetRootId . ', `left_id` = ' . $leftAndRight++ . ', `right_id` = ' . $leftAndRight++ . ', `sorting` = ' . $sorting++ . ', `level` = ' . $level . ' WHERE `catid` = ' . $catId . ' '); } $objResultCatSelect->MoveNext(); } } // add new tables \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories_locks', array('lockId' => array('type' => 'VARCHAR(32)'), 'lockTable' => array('type' => 'VARCHAR(32)', 'after' => 'lockId'), 'lockStamp' => array('type' => 'BIGINT(11)', 'notnull' => true, 'after' => 'lockTable'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories_catid', array('id' => array('type' => 'INT(11)', 'notnull' => true))); // insert id of last added category \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_news_categories_catid` (`id`) VALUES (' . $nestedSetRootId . ')'); $_SESSION['contrexx_update']['news']['nestedSet'] = true; } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } /************************************ * EXTENSION: Module page changes * * ADDED: Contrexx v3.1.0 * ************************************/ if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) { try { $result = \Cx\Lib\UpdateUtil::sql('SELECT `id` FROM `' . DBPREFIX . 'content_page` WHERE `module` = "news" AND `cmd` RLIKE "^[0-9]*$"'); if ($result && $result->RecordCount() > 0) { while (!$result->EOF) { \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('id' => $result->fields['id']), '/(.*)/ms', function ($matches) { $page = $matches[0]; if (!empty($page) && !preg_match('/<!--\\s+BEGIN\\s+news_status_message\\s+-->.*<!--\\s+END\\s+news_status_message\\s+-->/ms', $page) && !preg_match('/<!--\\s+BEGIN\\s+news_menu\\s+-->.*<!--\\s+END\\s+news_menu\\s+-->/ms', $page) && !preg_match('/<!--\\s+BEGIN\\s+news_list\\s+-->.*<!--\\s+END\\s+news_list\\s+-->/ms', $page)) { $page = preg_replace_callback('/<form[^>]*>[^<]*\\{NEWS_CAT_DROPDOWNMENU\\}[^>]*<\\/form>/ims', function ($matches) { $menu = $matches[0]; $menu = preg_replace_callback('/(action\\s*=\\s*([\'"])[^\\2]+section=news)\\2/i', function ($matches) { return $matches[1] . '&cmd=[[NEWS_CMD]]' . $matches[2]; }, $menu); return ' <!-- BEGIN news_status_message --> {TXT_NEWS_NO_NEWS_FOUND} <!-- END news_status_message --> <!-- BEGIN news_menu --> ' . $menu . ' <!-- END news_menu --> '; }, $page); $page = preg_replace_callback('/<ul[^>]*>[^<]*<!--\\s+BEGIN\\s+newsrow\\s+-->.*<!--\\s+END\\s+newsrow\\s+-->[^>]*<\\/ul>/ims', function ($matches) { return ' <!-- BEGIN news_list --> ' . $matches[0] . ' <!-- END news_list --> '; }, $page); if (!preg_match('/<!--\\s+BEGIN\\s+news_status_message\\s+-->.*<!--\\s+END\\s+news_status_message\\s+-->/ms', $page)) { $page = ' <!-- BEGIN news_status_message --> {TXT_NEWS_NO_NEWS_FOUND} <!-- END news_status_message --> ' . $page; } } return $page; }, array('content'), '3.1.0'); $result->MoveNext(); } } $result = \Cx\Lib\UpdateUtil::sql('SELECT `id` FROM `' . DBPREFIX . 'content_page` WHERE `module` = "news" AND `cmd` RLIKE "^details[0-9]*$"'); if ($result && $result->RecordCount() > 0) { while (!$result->EOF) { \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('id' => $result->fields['id']), '/(.*)/ms', function ($matches) { $page = $matches[0]; if (!empty($page) && !preg_match('/<!--\\s+BEGIN\\s+news_use_teaser_text\\s+-->.*<!--\\s+END\\s+news_use_teaser_text\\s+-->/ms', $page)) { $page = preg_replace('/\\{NEWS_TEASER_TEXT\\}/', '<!-- BEGIN news_use_teaser_text -->\\0<!-- END news_use_teaser_text -->', $page); } return $page; }, array('content'), '3.1.0'); $result->MoveNext(); } } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } /*********************************** * EXTENSION: new settings added * * ADDED: Contrexx v3.1.0 * ***********************************/ if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) { try { $result = \Cx\Lib\UpdateUtil::sql('SELECT `name` FROM `' . DBPREFIX . 'module_news_settings` WHERE `name` = "news_use_teaser_text"'); if ($result && $result->RecordCount() == 0) { \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_news_settings` (`name`, `value`) VALUES ("news_use_teaser_text", 1)'); } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } return true; }
function _convertThemes2UTF() { global $objDatabase, $_CORELANG, $_ARRAYLANG; // get installed themes $query = 'SELECT themesname, foldername FROM `' . DBPREFIX . 'skins`'; $objTheme = $objDatabase->Execute($query); $arrThemes = array(); if ($objTheme !== false) { while (!$objTheme->EOF) { $arrThemes[$objTheme->fields['themesname']] = $objTheme->fields['foldername']; $objTheme->MoveNext(); } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } if (count($arrThemes)) { foreach ($arrThemes as $path) { if (!isset($_SESSION['contrexx_update']['update']['utf_themes'][$path])) { $_SESSION['contrexx_update']['update']['utf_themes'][$path] = array(); } $dh = @opendir(ASCMS_THEMES_PATH . '/' . $path); if ($dh !== false) { while (($file = @readdir($dh)) !== false) { if (substr($file, -5) == '.html') { if (!in_array($file, $_SESSION['contrexx_update']['update']['utf_themes'][$path])) { $content = file_get_contents(ASCMS_THEMES_PATH . '/' . $path . '/' . $file); $fh = @fopen(ASCMS_THEMES_PATH . '/' . $path . '/' . $file, 'wb'); if ($fh !== false) { $status = true; if (@fwrite($fh, utf8_encode($content)) !== false) { $_SESSION['contrexx_update']['update']['utf_themes'][$path][] = $file; } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_CONVERT_FILE'], ASCMS_THEMES_PATH . '/' . $path . '/' . $file)); $status = false; } @fclose($fh); if (!$status) { return false; } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_WRITE_FILE'], ASCMS_THEMES_PATH . '/' . $path . '/' . $file)); setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_THEMES_PATH . '/' . $path . '/' . $file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } } } @closedir($dh); } } } return true; }
function _docsysUpdate() { global $objDatabase, $_ARRAYLANG; try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_docsys_entry_category', array('entry' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'category' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true))); if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_docsys', 'catid')) { $query = "SELECT `id`, `catid` FROM `" . DBPREFIX . "module_docsys`"; $objResult = $objDatabase->Execute($query); if ($objResult !== false) { while (!$objResult->EOF) { $query = "SELECT 1 FROM `" . DBPREFIX . "module_docsys_entry_category` WHERE `entry` = " . $objResult->fields['id'] . " AND `category` = " . $objResult->fields['catid']; $objCheck = $objDatabase->SelectLimit($query, 1); if ($objCheck !== false) { if ($objCheck->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_docsys_entry_category` (`entry`, `category`) VALUES ('" . $objResult->fields['id'] . "', '" . $objResult->fields['catid'] . "')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $objResult->MoveNext(); } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } // Fix some fuckup that UpdatUtil can't do.. make sure that "id" is unique before attempting // to make it a primary key $duplicateIDs_sql = "SELECT COUNT(*) as c, id FROM " . DBPREFIX . "module_docsys GROUP BY id HAVING c > 1"; $duplicateIDs = $objDatabase->Execute($duplicateIDs_sql); if ($duplicateIDs === false) { return _databaseError($duplicateIDs_sql, $objDatabase->ErrorMsg()); } $fix_queries = array(); while (!$duplicateIDs->EOF) { $id = $duplicateIDs->fields['id']; $entries_sql = "SELECT * FROM " . DBPREFIX . "module_docsys WHERE id = {$id}"; $entries = $objDatabase->Execute($entries_sql); if ($entries === false) { return _databaseError($entries_sql, $objDatabase->ErrorMsg()); } // NOW: put them all in an array, DELETE them and then re-INSERT them // without id. the auto_increment will take care of the rest. The first one we // re-insert can keep it's id. $entries_sql = "SELECT * FROM " . DBPREFIX . "module_docsys WHERE id = {$id}"; $entries = $objDatabase->Execute($entries_sql); if ($entries === false) { return _databaseError($entries_sql, $objDatabase->ErrorMsg()); } $is_first = true; $fix_queries[] = "DELETE FROM " . DBPREFIX . "module_docsys WHERE id = {$id}"; while (!$entries->EOF) { $pairs = array(); foreach ($entries->fields as $k => $v) { // only first may keep it's id if ($k == 'id' and !$is_first) { continue; } $pairs[] = "{$k} = '" . addslashes($v) . "'"; } $fix_queries[] = "INSERT INTO " . DBPREFIX . "module_docsys SET " . join(', ', $pairs); $is_first = false; $entries->MoveNext(); } $duplicateIDs->MoveNext(); } // Now run all of these queries. basically DELETE, INSERT,INSERT, DELETE,INSERT... foreach ($fix_queries as $insert_query) { if ($objDatabase->Execute($insert_query) === false) { return _databaseError($insert_query, $objDatabase->ErrorMsg()); } } // alter column startdate from date to int $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_docsys'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_docsys')); return false; } if (isset($arrColumns['STARTDATE'])) { if ($arrColumns['STARTDATE']->type == 'date') { if (!isset($arrColumns['STARTDATE_NEW'])) { $query = 'ALTER TABLE `' . DBPREFIX . 'module_docsys` ADD `startdate_new` INT(14) UNSIGNED NOT NULL DEFAULT \'0\' AFTER `startdate`'; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } $query = 'UPDATE `' . DBPREFIX . 'module_docsys` SET `startdate_new` = UNIX_TIMESTAMP(`startdate`) WHERE `startdate` != \'0000-00-00\''; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = 'ALTER TABLE `' . DBPREFIX . 'module_docsys` DROP `startdate`'; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_docsys'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_docsys')); return false; } if (!isset($arrColumns['STARTDATE'])) { $query = 'ALTER TABLE `' . DBPREFIX . 'module_docsys` CHANGE `startdate_new` `startdate` INT(14) UNSIGNED NOT NULL DEFAULT \'0\''; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // alter column enddate from date to int $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_docsys'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_docsys')); return false; } if (isset($arrColumns['ENDDATE'])) { if ($arrColumns['ENDDATE']->type == 'date') { if (!isset($arrColumns['ENDDATE_NEW'])) { $query = 'ALTER TABLE `' . DBPREFIX . 'module_docsys` ADD `enddate_new` INT(14) UNSIGNED NOT NULL DEFAULT \'0\' AFTER `enddate`'; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } $query = 'UPDATE `' . DBPREFIX . 'module_docsys` SET `enddate_new` = UNIX_TIMESTAMP(`enddate`) WHERE `enddate` != \'0000-00-00\''; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = 'ALTER TABLE `' . DBPREFIX . 'module_docsys` DROP `enddate`'; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_docsys'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_docsys')); return false; } if (!isset($arrColumns['ENDDATE'])) { $query = 'ALTER TABLE `' . DBPREFIX . 'module_docsys` CHANGE `enddate_new` `enddate` INT(14) UNSIGNED NOT NULL DEFAULT \'0\''; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_docsys', array('id' => array('type' => 'INT(6)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'date' => array('type' => 'INT(14)', 'notnull' => false), 'title' => array('type' => 'VARCHAR(250)'), 'author' => array('type' => 'VARCHAR(150)'), 'text' => array('type' => 'MEDIUMTEXT', 'notnull' => true), 'source' => array('type' => 'VARCHAR(250)'), 'url1' => array('type' => 'VARCHAR(250)'), 'url2' => array('type' => 'VARCHAR(250)'), 'lang' => array('type' => 'INT(2)', 'unsigned' => true, 'default' => '0'), 'userid' => array('type' => 'INT(6)', 'unsigned' => true, 'default' => '0'), 'startdate' => array('type' => 'INT(14)', 'unsigned' => true, 'default' => '0'), 'enddate' => array('type' => 'INT(14)', 'unsigned' => true, 'default' => '0'), 'status' => array('type' => 'TINYINT(4)', 'default' => '1'), 'changelog' => array('type' => 'INT(14)', 'default' => '0')), array('newsindex' => array('fields' => array('title', 'text'), 'type' => 'FULLTEXT'))); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }
/** * Cloudrexx * * @link http://www.cloudrexx.com * @copyright Cloudrexx AG 2007-2015 * * According to our dual licensing model, this program can be used either * under the terms of the GNU Affero General Public License, version 3, * or under a proprietary license. * * The texts of the GNU Affero General Public License with an additional * permission and of our proprietary license can be found at and * in the LICENSE file you have received along with this program. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * "Cloudrexx" is a registered trademark of Cloudrexx AG. * The licensing of the program under the AGPLv3 does not imply a * trademark license. Therefore any rights, title and interest in * our trademarks remain entirely with us. */ function _downloadsUpdate() { global $objDatabase, $_ARRAYLANG, $_CORELANG, $objUpdate, $_CONFIG; /************************************************ * EXTENSION: Initial creation of the * * database tables * * ADDED: Contrexx v2.1.0 * ************************************************/ $arrTables = $objDatabase->MetaTables('TABLES'); if (!sizeof($arrTables)) { setUpdateMsg($_ARRAYLANG['TXT_UNABLE_DETERMINE_DATABASE_STRUCTURE']); return false; } $tables = array(DBPREFIX . 'module_downloads_category' => "CREATE TABLE `" . DBPREFIX . "module_downloads_category` (\n `id` int(11) unsigned NOT NULL auto_increment,\n `parent_id` int(11) unsigned NOT NULL default '0',\n `is_active` tinyint(1) unsigned NOT NULL default '1',\n `visibility` tinyint(1) unsigned NOT NULL default '1',\n `owner_id` int(5) unsigned NOT NULL default '0',\n `order` int(3) unsigned NOT NULL default '0',\n `deletable_by_owner` tinyint(1) unsigned NOT NULL default '1',\n `modify_access_by_owner` tinyint(1) unsigned NOT NULL default '1',\n `read_access_id` int(11) unsigned NOT NULL default '0',\n `add_subcategories_access_id` int(11) unsigned NOT NULL default '0',\n `manage_subcategories_access_id` int(11) unsigned NOT NULL default '0',\n `add_files_access_id` int(11) unsigned NOT NULL default '0',\n `manage_files_access_id` int(11) unsigned NOT NULL default '0',\n `image` varchar(255) NOT NULL default '',\n PRIMARY KEY (`id`),\n KEY `is_active` (`is_active`),\n KEY `visibility` (`visibility`)\n ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_category_locale' => "CREATE TABLE `" . DBPREFIX . "module_downloads_category_locale` (\n `lang_id` int(11) unsigned NOT NULL default '0',\n `category_id` int(11) unsigned NOT NULL default '0',\n `name` varchar(255) NOT NULL default '',\n `description` text NOT NULL,\n PRIMARY KEY (`lang_id`,`category_id`),\n FULLTEXT KEY `name` (`name`),\n FULLTEXT KEY `description` (`description`)\n ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_download_locale' => "CREATE TABLE `" . DBPREFIX . "module_downloads_download_locale` (\n `lang_id` int(11) unsigned NOT NULL default '0',\n `download_id` int(11) unsigned NOT NULL default '0',\n `name` varchar(255) NOT NULL default '',\n `description` text NOT NULL,\n PRIMARY KEY (`lang_id`,`download_id`),\n FULLTEXT KEY `name` (`name`),\n FULLTEXT KEY `description` (`description`)\n ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_rel_download_category' => "CREATE TABLE `" . DBPREFIX . "module_downloads_rel_download_category` (\n `download_id` int(10) unsigned NOT NULL default '0',\n `category_id` int(10) unsigned NOT NULL default '0',\n `order` int(3) unsigned NOT NULL default '0',\n PRIMARY KEY (`download_id`,`category_id`)\n ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_rel_download_download' => "CREATE TABLE `" . DBPREFIX . "module_downloads_rel_download_download` (\n `id1` int(10) unsigned NOT NULL default '0',\n `id2` int(10) unsigned NOT NULL default '0',\n PRIMARY KEY (`id1`,`id2`)\n ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_settings' => "CREATE TABLE `" . DBPREFIX . "module_downloads_settings` (\n `id` int(11) NOT NULL auto_increment,\n `name` varchar(32) NOT NULL default '',\n `value` varchar(255) NOT NULL default '',\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM"); foreach ($tables as $name => $query) { #print_r($arrTables); if (in_array($name, $arrTables)) { continue; } if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_download', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'ENUM(\'file\',\'url\')', 'notnull' => true, 'default' => 'file'), 'mime_type' => array('type' => 'ENUM(\'image\',\'document\',\'pdf\',\'media\',\'archive\',\'application\',\'link\')', 'notnull' => true, 'default' => 'image'), 'source' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'source_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'icon' => array('type' => 'ENUM(\'_blank\',\'avi\',\'bmp\',\'css\',\'doc\',\'dot\',\'exe\',\'fla\',\'gif\',\'htm\',\'html\',\'inc\',\'jpg\',\'js\',\'mp3\',\'nfo\',\'pdf\',\'php\',\'png\',\'pps\',\'ppt\',\'rar\',\'swf\',\'txt\',\'wma\',\'xls\',\'zip\')', 'notnull' => true, 'default' => '_blank'), 'size' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'image' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'owner_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'license' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'version' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => ''), 'author' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'website' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'ctime' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'mtime' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'is_active' => array('type' => 'TINYINT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'visibility' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'order' => array('type' => 'INT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'views' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'download_count' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'expiration' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0')), array('is_active' => array('fields' => array('is_active')), 'visibility' => array('fields' => array('visibility')))); } catch (\Cx\Lib\UpdateException $e) { // we COULD do something else here.. return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /************************************************ * EXTENSION: Initial adding of the * * settings values * * ADDED: Contrexx v2.1.0 * ************************************************/ $arrSettings = array('overview_cols_count' => '2', 'overview_max_subcats' => '5', 'use_attr_size' => '1', 'use_attr_license' => '1', 'use_attr_version' => '1', 'use_attr_author' => '1', 'use_attr_website' => '1', 'most_viewed_file_count' => '5', 'most_downloaded_file_count' => '5', 'most_popular_file_count' => '5', 'newest_file_count' => '5', 'updated_file_count' => '5', 'new_file_time_limit' => '604800', 'updated_file_time_limit' => '604800', 'associate_user_to_groups' => ''); foreach ($arrSettings as $name => $value) { $query = "SELECT 1 FROM `" . DBPREFIX . "module_downloads_settings` WHERE `name` = '" . $name . "'"; $objResult = $objDatabase->SelectLimit($query, 1); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_downloads_settings` (`name`, `value`) VALUES ('" . $name . "', '" . $value . "')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } /************************************************ * BUGFIX: Set write access to the upload dir * ************************************************/ if (\Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOWNLOADS_IMAGES_PATH)) { if ($mediaDir = @opendir(ASCMS_DOWNLOADS_IMAGES_PATH)) { while ($file = readdir($mediaDir)) { if ($file != '.' && $file != '..') { if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOWNLOADS_IMAGES_PATH . '/' . $file)) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_DOWNLOADS_IMAGES_PATH . '/' . $file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_DOWNLOADS_IMAGES_PATH . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_DOWNLOADS_IMAGES_PATH . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } /************************************************ * EXTENSION: Groups * * ADDED: Contrexx v2.1.2 * ************************************************/ try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_group', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'is_active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1'), 'type' => array('type' => 'ENUM(\'file\',\'url\')', 'notnull' => true, 'default' => 'file'), 'info_page' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_group_locale', array('lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'group_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '')), array('name' => array('fields' => array('name'), 'type' => 'FULLTEXT'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_rel_group_category', array('group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'category_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true))); } catch (\Cx\Lib\UpdateException $e) { // we COULD do something else here.. return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /******************************************************* * EXTENSION: Localisation of download source fields * * ADDED: Contrexx v3.0.0 * ********************************************************/ try { $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_downloads_download_locale'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_downloads_download_locale')); return false; } if (!isset($arrColumns['SOURCE']) && !isset($arrColumns['SOURCE_NAME'])) { \Cx\Lib\UpdateUtil::sql(' ALTER TABLE `' . DBPREFIX . 'module_downloads_download_locale` ADD `source` VARCHAR(255) NULL DEFAULT NULL AFTER `name`, ADD `source_name` VARCHAR(255) NULL DEFAULT NULL AFTER `source`, ADD `metakeys` TEXT NOT NULL AFTER `description` '); \Cx\Lib\UpdateUtil::sql(' UPDATE `' . DBPREFIX . 'module_downloads_download` AS download INNER JOIN `' . DBPREFIX . 'module_downloads_download_locale` AS download_locale ON download.id = download_locale.download_id SET download_locale.source = download.source, download_locale.source_name = download.source_name '); \Cx\Lib\UpdateUtil::sql(' ALTER TABLE `' . DBPREFIX . 'module_downloads_download` DROP COLUMN `source`, DROP COLUMN `source_name` '); } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /********************************************************** * EXTENSION: Increase length of download source fields * * ADDED: Contrexx v3.1.0 * **********************************************************/ try { if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) { \Cx\Lib\UpdateUtil::sql(' ALTER TABLE `' . DBPREFIX . 'module_downloads_download_locale` CHANGE `source` `source` VARCHAR(1024) NULL DEFAULT NULL, CHANGE `source_name` `source_name` VARCHAR(1024) NULL DEFAULT NULL '); } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /********************************************************** * EXTENSION: Add access ids of "editing all downloads" * * to groups which had access to "administer"* * ADDED: Contrexx v3.1.1 * **********************************************************/ try { if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0.2')) { $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 142 GROUP BY `group_id`"); if ($result !== false) { while (!$result->EOF) { \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n VALUES (143, " . intval($result->fields['group_id']) . ")"); $result->MoveNext(); } } } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }
\DBG::msg('...and it\'s customized, so let\'s move it to customizing directory'); // changes, backup modified file if (!backupModifiedFile(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php')) { setUpdateMsg('Die Datei \'' . ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php\' konnte nicht kopiert werden.'); return false; } } else { \DBG::msg('...but it\'s not customized'); } // no non-backupped changes, can delete try { \DBG::msg('So let\'s remove it...'); $cadminIndex = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php'); $cadminIndex->delete(); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { setUpdateMsg('Die Datei \'' . ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php\' konnte nicht gelöscht werden.'); return false; } } /*************************************** * * CALENDAR: FIX TABLE * only for 3.1.0 * **************************************/ // fixing news container text setting which cannot be activated if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.1')) { try { $result = \Cx\Lib\UpdateUtil::sql('SELECT `name` FROM `' . DBPREFIX . 'module_news_settings` WHERE `name` = "news_use_teaser_text"'); if ($result && $result->RecordCount() == 0) { \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_news_settings` (`name`, `value`) VALUES ("news_use_teaser_text", 1)');
function _updateSettings() { global $objUpdate, $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG, $arrSettings, $arrSettingsByName; // TODO: Unused // $setVars = false; $arrSettings = array(3 => array('setname' => 'dnsServer', 'setvalue' => 'ns1.contrexxdns.net', 'setmodule' => 1), 4 => array('setname' => 'bannerStatus', 'setvalue' => '0', 'setmodule' => 28), 5 => array('setname' => 'spamKeywords', 'setvalue' => 'sex, viagra', 'setmodule' => 1), 11 => array('setname' => 'coreAdminName', 'setvalue' => 'Webmaster', 'setmodule' => 1), 18 => array('setname' => 'corePagingLimit', 'setvalue' => '30', 'setmodule' => 1), 19 => array('setname' => 'searchDescriptionLength', 'setvalue' => '150', 'setmodule' => 5), 23 => array('setname' => 'coreIdsStatus', 'setvalue' => 'off', 'setmodule' => 1), 24 => array('setname' => 'coreAdminEmail', 'setvalue' => '*****@*****.**', 'setmodule' => 1), 29 => array('setname' => 'contactFormEmail', 'setvalue' => '*****@*****.**', 'setmodule' => 6), 34 => array('setname' => 'sessionLifeTime', 'setvalue' => '3600', 'setmodule' => 1), 35 => array('setname' => 'lastAccessId', 'setvalue' => '1', 'setmodule' => 1), 37 => array('setname' => 'newsTeasersStatus', 'setvalue' => '0', 'setmodule' => 8), 39 => array('setname' => 'feedNewsMLStatus', 'setvalue' => '0', 'setmodule' => 22), 40 => array('setname' => 'calendarheadlines', 'setvalue' => '1', 'setmodule' => 21), 41 => array('setname' => 'calendarheadlinescount', 'setvalue' => '5', 'setmodule' => 21), 42 => array('setname' => 'blockStatus', 'setvalue' => '1', 'setmodule' => 7), 44 => array('setname' => 'calendarheadlinescat', 'setvalue' => '0', 'setmodule' => 21), 45 => array('setname' => 'calendardefaultcount', 'setvalue' => '16', 'setmodule' => 21), 48 => array('setname' => 'blockRandom', 'setvalue' => '1', 'setmodule' => 7), 49 => array('setname' => 'directoryHomeContent', 'setvalue' => '0', 'setmodule' => 12), 50 => array('setname' => 'cacheEnabled', 'setvalue' => 'off', 'setmodule' => 1), 51 => array('setname' => 'coreGlobalPageTitle', 'setvalue' => 'Contrexx Example Page', 'setmodule' => 1), 52 => array('setname' => 'cacheExpiration', 'setvalue' => '86400', 'setmodule' => 1), 53 => array('setname' => 'domainUrl', 'setvalue' => 'localhost', 'setmodule' => 1), 54 => array('setname' => 'xmlSitemapStatus', 'setvalue' => 'off', 'setmodule' => 1), 55 => array('setname' => 'systemStatus', 'setvalue' => 'on', 'setmodule' => 1), 56 => array('setname' => 'searchVisibleContentOnly', 'setvalue' => 'on', 'setmodule' => 1), 57 => array('setname' => 'protocolHttpsFrontend', 'setvalue' => 'off', 'setmodule' => 1), 58 => array('setname' => 'protocolHttpsBackend', 'setvalue' => 'off', 'setmodule' => 1), 59 => array('setname' => 'forceDomainUrl', 'setvalue' => 'off', 'setmodule' => 1), 60 => array('setname' => 'forumHomeContent', 'setvalue' => '0', 'setmodule' => 20), 62 => array('setname' => 'coreSmtpServer', 'setvalue' => '0', 'setmodule' => 1), 63 => array('setname' => 'languageDetection', 'setvalue' => 'on', 'setmodule' => 1), 64 => array('setname' => 'podcastHomeContent', 'setvalue' => '0', 'setmodule' => 35), 65 => array('setname' => 'googleMapsAPIKey', 'setvalue' => '', 'setmodule' => 1), 66 => array('setname' => 'forumTagContent', 'setvalue' => '0', 'setmodule' => 20), 68 => array('setname' => 'dataUseModule', 'setvalue' => '0', 'setmodule' => 48), 69 => array('setname' => 'frontendEditingStatus', 'setvalue' => 'off', 'setmodule' => 1), 71 => array('setname' => 'coreListProtectedPages', 'setvalue' => 'on', 'setmodule' => 1), 72 => array('setname' => 'useKnowledgePlaceholders', 'setvalue' => '0', 'setmodule' => 56), 73 => array('setname' => 'advancedUploadFrontend', 'setvalue' => 'off', 'setmodule' => 52), 74 => array('setname' => 'advancedUploadBackend', 'setvalue' => 'on', 'setmodule' => 52), 75 => array('setname' => 'installationId', 'setvalue' => '', 'setmodule' => 1), 76 => array('setname' => 'licenseKey', 'setvalue' => '', 'setmodule' => 1), 77 => array('setname' => 'contactCompany', 'setvalue' => 'Ihr Firmenname', 'setmodule' => 1), 78 => array('setname' => 'contactAddress', 'setvalue' => 'Musterstrasse 12', 'setmodule' => 1), 79 => array('setname' => 'contactZip', 'setvalue' => '3600', 'setmodule' => 1), 80 => array('setname' => 'contactPlace', 'setvalue' => 'Musterhausen', 'setmodule' => 1), 81 => array('setname' => 'contactCountry', 'setvalue' => 'Musterland', 'setmodule' => 1), 82 => array('setname' => 'contactPhone', 'setvalue' => '033 123 45 67', 'setmodule' => 1), 83 => array('setname' => 'contactFax', 'setvalue' => '033 123 45 68', 'setmodule' => 1), 84 => array('setname' => 'sessionLifeTimeRememberMe', 'setvalue' => '1209600', 'setmodule' => 1), 85 => array('setname' => 'dashboardNews', 'setvalue' => 'on', 'setmodule' => 1), 86 => array('setname' => 'dashboardStatistics', 'setvalue' => 'on', 'setmodule' => 1), 87 => array('setname' => 'timezone', 'setvalue' => 'Europe/Zurich', 'setmodule' => 1), 88 => array('setname' => 'googleAnalyticsTrackingId', 'setvalue' => '', 'setmodule' => 1), 89 => array('setname' => 'passwordComplexity', 'setvalue' => 'off', 'setmodule' => 1), 90 => array('setname' => 'licenseState', 'setvalue' => 'OK', 'setmodule' => 66), 91 => array('setname' => 'licenseValidTo', 'setvalue' => '', 'setmodule' => 66), 92 => array('setname' => 'coreCmsEdition', 'setvalue' => 'Trial', 'setmodule' => 66), 93 => array('setname' => 'licenseMessage', 'setvalue' => '', 'setmodule' => 66), 94 => array('setname' => 'licenseCreatedAt', 'setvalue' => '', 'setmodule' => 66), 95 => array('setname' => 'licenseDomains', 'setvalue' => '', 'setmodule' => 66), 96 => array('setname' => 'licenseGrayzoneMessages', 'setvalue' => '', 'setmodule' => 66), 97 => array('setname' => 'coreCmsVersion', 'setvalue' => '3.0.4', 'setmodule' => 66), 98 => array('setname' => 'coreCmsCodeName', 'setvalue' => 'Nikola Tesla', 'setmodule' => 66), 99 => array('setname' => 'coreCmsStatus', 'setvalue' => 'Stable', 'setmodule' => 66), 100 => array('setname' => 'coreCmsReleaseDate', 'setvalue' => '12.04.2013', 'setmodule' => 66), 101 => array('setname' => 'licensePartner', 'setvalue' => '', 'setmodule' => 66), 102 => array('setname' => 'licenseCustomer', 'setvalue' => '', 'setmodule' => 66), 103 => array('setname' => 'availableComponents', 'setvalue' => '', 'setmodule' => 66), 104 => array('setname' => 'upgradeUrl', 'setvalue' => 'http://license.contrexx.com/', 'setmodule' => 66), 105 => array('setname' => 'isUpgradable', 'setvalue' => 'off', 'setmodule' => 66), 106 => array('setname' => 'dashboardMessages', 'setvalue' => 'YToxOntzOjI6ImRlIjtPOjMxOiJDeFxDb3JlX01vZHVsZXNcTGljZW5zZVxNZXNzYWdlIjo2OntzOjQxOiIAQ3hcQ29yZV9Nb2R1bGVzXExpY2Vuc2VcTWVzc2FnZQBsYW5nQ29kZSI7czoyOiJkZSI7czozNzoiAEN4XENvcmVfTW9kdWxlc1xMaWNlbnNlXE1lc3NhZ2UAdGV4dCI7czo5MjoiU2llIGJlbnV0emVuIGRlbiBSZWxlYXNlIENhbmRpZGF0ZSB2b24gQ29udHJleHggMy4gS2xpY2tlbiBTaWUgaGllciB1bSBOZXVpZ2tlaXRlbiB6dSBzZWhlbiEiO3M6Mzc6IgBDeFxDb3JlX01vZHVsZXNcTGljZW5zZVxNZXNzYWdlAHR5cGUiO3M6MTA6Indhcm5pbmdib3giO3M6Mzc6IgBDeFxDb3JlX01vZHVsZXNcTGljZW5zZVxNZXNzYWdlAGxpbmsiO3M6MjE6ImluZGV4LnBocD9jbWQ9bGljZW5zZSI7czo0MzoiAEN4XENvcmVfTW9kdWxlc1xMaWNlbnNlXE1lc3NhZ2UAbGlua1RhcmdldCI7czo1OiJfc2VsZiI7czo0ODoiAEN4XENvcmVfTW9kdWxlc1xMaWNlbnNlXE1lc3NhZ2UAc2hvd0luRGFzaGJvYXJkIjtiOjE7fX0=', 'setmodule' => 66), 112 => array('setname' => 'coreCmsName', 'setvalue' => 'Contrexx', 'setmodule' => 66), 113 => array('setname' => 'useCustomizings', 'setvalue' => 'off', 'setmodule' => 1), 114 => array('setname' => 'licenseGrayzoneTime', 'setvalue' => '14', 'setmodule' => 66), 115 => array('setname' => 'licenseLockTime', 'setvalue' => '10', 'setmodule' => 66), 116 => array('setname' => 'licenseUpdateInterval', 'setvalue' => '24', 'setmodule' => 66), 117 => array('setname' => 'licenseFailedUpdate', 'setvalue' => '0', 'setmodule' => 66), 118 => array('setname' => 'licenseSuccessfulUpdate', 'setvalue' => '0', 'setmodule' => 66), 119 => array('setname' => 'cacheUserCache', 'setvalue' => 'off', 'setmodule' => 1), 120 => array('setname' => 'cacheOPCache', 'setvalue' => 'off', 'setmodule' => 1), 121 => array('setname' => 'cacheUserCacheMemcacheConfig', 'setvalue' => '{\\"ip":\\"127.0.0.1\\",\\"port\\":11211}', 'setmodule' => 1), 122 => array('setname' => 'cacheProxyCacheVarnishConfig', 'setvalue' => '{\\"ip":\\"127.0.0.1\\",\\"port\\":8080}', 'setmodule' => 1)); $arrSettingsByName = array(); foreach ($arrSettings as $setid => $data) { $arrSettingsByName[$data['setname']] = $setid; } // change googleSitemapStatus to xmlSitemapStatus $query = "SELECT 1 FROM `" . DBPREFIX . "settings` WHERE `setname`='googleSitemapStatus'"; $objResult = $objDatabase->SelectLimit($query, 1); if ($objResult) { if ($objResult->RecordCount() == 1) { $query = "UPDATE `" . DBPREFIX . "settings` SET `setname` = 'xmlSitemapStatus' WHERE `setname` = 'googleSitemapStatus'"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } try { //remove fileuploader setting \Cx\Lib\UpdateUtil::sql('DELETE FROM ' . DBPREFIX . 'settings WHERE setid=70 AND setname="fileUploaderStatus"'); } catch (\Cx\Lib\UpdateException $e) { DBG::trace(); return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } foreach ($arrSettings as $setId => $arrSetting) { if (!_updateSettingsTable($setId, $arrSetting)) { return false; } } $query = "UPDATE `" . DBPREFIX . "settings` SET `setmodule`=1 WHERE `setmodule`=0"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } //timezone (Contrexx 3.0.1) $arrTimezoneIdentifiers = timezone_identifiers_list(); if (isset($_POST['timezone']) && array_key_exists($_POST['timezone'], $arrTimezoneIdentifiers)) { $_SESSION['contrexx_update']['update']['timezone'] = $_POST['timezone']; } if (isset($_SESSION['contrexx_update']['update']['timezone']) && array_key_exists(ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['timezone']), $arrTimezoneIdentifiers)) { try { \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'settings` SET `setvalue` = "' . $arrTimezoneIdentifiers[$_SESSION['contrexx_update']['update']['timezone']] . '" WHERE `setname` = "timezone"'); // add timezone to $_CONFIG array so it will be written in configuration.php in components/core/core.php $_CONFIG['timezone'] = $arrTimezoneIdentifiers[$_SESSION['contrexx_update']['update']['timezone']]; } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } else { $selected = -1; if (($defaultTimezoneId = array_search(@date_default_timezone_get(), $arrTimezoneIdentifiers)) && !empty($defaultTimezoneId)) { $selected = $defaultTimezoneId; } $options = '<option value="-1"' . ($selected == -1 ? ' selected="selected"' : '') . '>' . $_CORELANG['TXT_PLEASE_SELECT'] . '</option>'; foreach ($arrTimezoneIdentifiers as $id => $name) { $dateTimeZone = new DateTimeZone($name); $dateTime = new DateTime('now', $dateTimeZone); $timeOffset = $dateTimeZone->getOffset($dateTime); $sign = $timeOffset < 0 ? '-' : '+'; $gmt = 'GMT ' . $sign . gmdate('g:i', $timeOffset); $options .= '<option value="' . $id . '"' . ($selected == $id ? ' selected="selected"' : '') . '>' . $name . ' (' . $gmt . ')' . '</option>'; } setUpdateMsg($_CORELANG['TXT_TIMEZONE'], 'title'); setUpdateMsg($_CORELANG['TXT_TIMEZONE_INTRODUCTION'] . ' <select name="timezone">' . $options . '</select>', 'msg'); setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_UPDATE_NEXT'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button'); return false; } // write settings $strFooter = ''; $arrModules = ''; \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOCUMENT_ROOT . '/config/'); if (!file_exists(ASCMS_DOCUMENT_ROOT . '/config/settings.php')) { if (!touch(ASCMS_DOCUMENT_ROOT . '/config/settings.php')) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_CREATE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/settings.php')); setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR'], ASCMS_DOCUMENT_ROOT . '/config/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } } \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOCUMENT_ROOT . '/config/settings.php'); if (is_writable(ASCMS_DOCUMENT_ROOT . '/config/settings.php')) { try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . '/config/settings.php'); //Header & Footer $strHeader = "<?php\n"; $strHeader .= "/**\n"; $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n"; $strHeader .= "* Do not try to edit it manually!\n"; $strHeader .= "*/\n\n"; $strFooter .= "?>"; //Get module-names $objResult = $objDatabase->Execute('SELECT id, name FROM ' . DBPREFIX . 'modules'); if ($objResult->RecordCount() > 0) { while (!$objResult->EOF) { $arrModules[$objResult->fields['id']] = $objResult->fields['name']; $objResult->MoveNext(); } } //Get values $objResult = $objDatabase->Execute('SELECT setname, setmodule, setvalue FROM ' . DBPREFIX . 'settings ORDER BY setmodule ASC, setname ASC '); $intMaxLen = 0; $arrValues = array(); while ($objResult && !$objResult->EOF) { $intMaxLen = strlen($objResult->fields['setname']) > $intMaxLen ? strlen($objResult->fields['setname']) : $intMaxLen; $arrValues[$objResult->fields['setmodule']][$objResult->fields['setname']] = $objResult->fields['setvalue']; $objResult->MoveNext(); } $intMaxLen += strlen('$_CONFIG[\'\']') + 1; //needed for formatted output $fileContent = $strHeader; foreach ($arrValues as $intModule => $arrInner) { $fileContent .= "/**\n"; $fileContent .= "* -------------------------------------------------------------------------\n"; if (isset($arrModules[$intModule])) { $fileContent .= "* " . ucfirst($arrModules[$intModule]) . "\n"; } else { $fileContent .= "* " . $intModule . "\n"; } $fileContent .= "* -------------------------------------------------------------------------\n"; $fileContent .= "*/\n"; foreach ($arrInner as $strName => $strValue) { $fileContent .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $strName . '\']'); $fileContent .= "= "; $fileContent .= (is_numeric($strValue) ? $strValue : '"' . $strValue . '"') . ";\n"; } $fileContent .= "\n"; } $fileContent .= $strFooter; $objFile->write($fileContent); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_WRITE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/settings.php')); setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_DOCUMENT_ROOT . '/config/settings.php', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg'); return false; } $query = "\n ALTER TABLE " . DBPREFIX . "settings\n CHANGE COLUMN setid setid integer(6) UNSIGNED NOT NULL auto_increment;\n "; if (!$objDatabase->Execute($query)) { return _databaseError($query, $objDatabase->ErrorMsg()); } try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'settings_image', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(50)', 'after' => 'id'), 'value' => array('type' => 'text', 'after' => 'name'))); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) { try { \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_cut_width', '500')); \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_cut_height', '500')); \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_scale_width', '800')); \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_scale_height', '800')); \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_compression', '100')); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } return true; }
function _directoryUpdate() { global $objDatabase, $_ARRAYLANG; /// 2.0 $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_directory_dir'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_directory_dir')); return false; } $arrNewCols = array('LONGITUDE' => array('type' => 'DECIMAL( 18, 15 )', 'default' => '0', 'after' => 'premium'), 'LATITUDE' => array('type' => 'DECIMAL( 18, 15 )', 'default' => '0', 'after' => 'longitude'), 'ZOOM' => array('type' => 'DECIMAL( 18, 15 )', 'default' => '1', 'after' => 'latitude'), 'COUNTRY' => array('type' => 'VARCHAR( 255 )', 'default' => '', 'after' => 'city')); foreach ($arrNewCols as $col => $arrAttr) { if (!isset($arrColumns[$col])) { $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir` ADD `" . strtolower($col) . "` " . $arrAttr['type'] . " NOT NULL DEFAULT '" . $arrAttr['default'] . "' AFTER `" . $arrAttr['after'] . "`"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } $inputColumns = '(`id`, `typ`, `name`, `title`, `active`, `active_backend`, `is_required`, `read_only`, `sort`, `exp_search`, `is_search`)'; $arrInputs = array(69 => "INSERT INTO `" . DBPREFIX . "module_directory_inputfields` " . $inputColumns . " VALUES (69, 13, 'googlemap', 'TXT_DIR_F_GOOGLEMAP', 1, 1, 0, 0, 6, 0, 0)", 70 => "INSERT INTO `" . DBPREFIX . "module_directory_inputfields` " . $inputColumns . " VALUES (70, 3, 'country', 'TXT_DIR_F_COUNTRY', 1, 1, 1, 0, 1, 0, 0)"); foreach ($arrInputs as $id => $queryInputs) { $query = "SELECT id FROM " . DBPREFIX . "module_directory_inputfields WHERE id=" . $id; $objCheck = $objDatabase->SelectLimit($query, 1); if ($objCheck !== false) { if ($objCheck->RecordCount() == 0) { if ($objDatabase->Execute($queryInputs) === false) { return _databaseError($queryInputs, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='country'"; $objCheck = $objDatabase->SelectLimit($query, 1); if ($objCheck !== false) { if ($objCheck->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` , `settyp` )\n VALUES (NULL, 'country', ',Schweiz,Deutschland,Österreich', 0)"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir` CHANGE `spez_field_21` `spez_field_21` VARCHAR( 255 ) NOT NULL DEFAULT ''"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir` CHANGE `spez_field_22` `spez_field_22` VARCHAR( 255 ) NOT NULL DEFAULT ''"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='pagingLimit'"; $objCheck = $objDatabase->SelectLimit($query, 1); if ($objCheck !== false) { if ($objCheck->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` , `settyp` )\n VALUES (NULL, 'pagingLimit', '20', '1')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='googlemap_start_location'"; $objCheck = $objDatabase->SelectLimit($query, 1); if ($objCheck !== false) { if ($objCheck->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` , `settyp` )\n VALUES (NULL, 'googlemap_start_location', '46:8:1', '1')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } /// 2.1 $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='youtubeWidth'"; $objCheck = $objDatabase->SelectLimit($query, 1); if ($objCheck !== false) { if ($objCheck->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` , `settyp` )\n VALUES (NULL , 'youtubeWidth', '400', '1')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='youtubeHeight'"; $objCheck = $objDatabase->SelectLimit($query, 1); if ($objCheck !== false) { if ($objCheck->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` , `settyp` )\n VALUES (NULL , 'youtubeHeight', '300', '1')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "SELECT id FROM " . DBPREFIX . "module_directory_inputfields WHERE name='youtube'"; $objCheck = $objDatabase->SelectLimit($query, 1); if ($objCheck !== false) { if ($objCheck->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_directory_inputfields` (`id` ,`typ` ,`name` ,`title` ,`active` ,`active_backend` ,`is_required` ,`read_only` ,`sort` ,`exp_search` ,`is_search`)\n VALUES (NULL , '1', 'youtube', 'TXT_DIRECTORY_YOUTUBE', '0', '0', '0', '0', '0', '0', '0')"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_directory_dir'); if ($arrColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_directory_dir')); return false; } if (!array_key_exists("YOUTUBE", $arrColumns)) { $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir` ADD `youtube` MEDIUMTEXT NOT NULL;"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir`\n CHANGE `logo` `logo` VARCHAR(50) NULL,\n CHANGE `map` `map` VARCHAR(255) NULL,\n CHANGE `lokal` `lokal` VARCHAR(255) NULL,\n CHANGE `spez_field_11` `spez_field_11` VARCHAR(255) NULL,\n CHANGE `spez_field_12` `spez_field_12` VARCHAR(255) NULL,\n CHANGE `spez_field_13` `spez_field_13` VARCHAR(255) NULL,\n CHANGE `spez_field_14` `spez_field_14` VARCHAR(255) NULL,\n CHANGE `spez_field_15` `spez_field_15` VARCHAR(255) NULL,\n CHANGE `spez_field_16` `spez_field_16` VARCHAR(255) NULL,\n CHANGE `spez_field_17` `spez_field_17` VARCHAR(255) NULL,\n CHANGE `spez_field_18` `spez_field_18` VARCHAR(255) NULL,\n CHANGE `spez_field_19` `spez_field_19` VARCHAR(255) NULL,\n CHANGE `spez_field_20` `spez_field_20` VARCHAR(255) NULL;"; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } //delete obsolete table contrexx_module_directory_access try { \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_directory_access'); } catch (\Cx\Lib\UpdateException $e) { DBG::trace(); return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /******************************** * EXTENSION: Fulltext key * * ADDED: Contrexx v3.0.0 * ********************************/ try { $objResult = \Cx\Lib\UpdateUtil::sql('SHOW KEYS FROM `' . DBPREFIX . 'module_directory_categories` WHERE `Key_name` = "directoryindex" and (`Column_name`= "name" OR `Column_name` = "description")'); if ($objResult && $objResult->RecordCount() == 0) { \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_directory_categories` ADD FULLTEXT KEY `directoryindex` (`name`, `description`)'); } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /********************************** * EXTENSION: Content Migration * * ADDED: Contrexx v3.0.0 * **********************************/ try { // migrate content page to version 3.0.1 $search = array('/(.*)/ms'); $callback = function ($matches) { $content = $matches[1]; if (empty($content)) { return $content; } // add missing placeholder {DIRECTORY_GOOGLEMAP_JAVASCRIPT_BLOCK} if (strpos($content, '{DIRECTORY_GOOGLEMAP_JAVASCRIPT_BLOCK}') === false) { $content .= "\n{DIRECTORY_GOOGLEMAP_JAVASCRIPT_BLOCK}"; } // move placeholder {DIRECTORY_JAVASCRIPT} to the end of the content page $content = str_replace('{DIRECTORY_JAVASCRIPT}', '', $content); $content .= "\n{DIRECTORY_JAVASCRIPT}"; return $content; }; \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'directory'), $search, $callback, array('content'), '3.0.1'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }
function _convertThemes2Component() { global $objDatabase, $_CORELANG; // Find all themes $result = $objDatabase->Execute('SELECT `themesname`, `foldername` FROM `' . DBPREFIX . 'skins`'); if ($result->EOF) { \DBG::msg('No themes found!'); return false; } $errorMessages = ''; $themeRepository = new \Cx\Core\View\Model\Repository\ThemeRepository(); while (!$result->EOF) { $themePath = ASCMS_THEMES_PATH . '/' . $result->fields['foldername']; if (!is_dir($themePath)) { \DBG::msg('Skipping theme "' . $result->fields['themesname'] . '"; No such folder!'); $errorMessages .= '<div class="message-warning">' . sprintf($_CORELANG['TXT_CSS_UPDATE_MISSING_FOLDER'], $result->fields['themesname']) . '</div>'; $result->MoveNext(); continue; } // create a new one if no component.yml exists if (!file_exists($themePath . '/component.yml')) { \DBG::msg('Converting theme "' . $result->fields['themesname'] . ' to component'); $themeRepository->convertThemeToComponent($result->fields['foldername']); } $result->MoveNext(); } if (!empty($errorMessages)) { setUpdateMsg($errorMessages, 'msg'); setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button'); $_SESSION['contrexx_update']['update']['done'][] = 'convertTemplates'; return false; } return true; }
/** * Cloudrexx * * @link http://www.cloudrexx.com * @copyright Cloudrexx AG 2007-2015 * * According to our dual licensing model, this program can be used either * under the terms of the GNU Affero General Public License, version 3, * or under a proprietary license. * * The texts of the GNU Affero General Public License with an additional * permission and of our proprietary license can be found at and * in the LICENSE file you have received along with this program. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * "Cloudrexx" is a registered trademark of Cloudrexx AG. * The licensing of the program under the AGPLv3 does not imply a * trademark license. Therefore any rights, title and interest in * our trademarks remain entirely with us. */ function _statsUpdate() { global $objDatabase, $objUpdate, $_CONFIG, $_ARRAYLANG; // remove redundancies if (!isset($_SESSION['contrexx_update']['update']['update_stats'])) { $_SESSION['contrexx_update']['update']['update_stats'] = array(); } foreach (array('stats_browser' => array('obsoleteIndex' => 'name', 'unique' => array('name'), 'change' => "`name` `name` VARCHAR(255) BINARY NOT NULL DEFAULT ''"), 'stats_colourdepth' => array('obsoleteIndex' => 'depth', 'unique' => array('depth')), 'stats_country' => array('obsoleteIndex' => 'country', 'unique' => array('country'), 'change' => "`country` `country` VARCHAR(100) BINARY NOT NULL DEFAULT ''"), 'stats_hostname' => array('obsoleteIndex' => 'hostname', 'unique' => array('hostname'), 'change' => "`hostname` `hostname` VARCHAR(255) BINARY NOT NULL DEFAULT ''"), 'stats_operatingsystem' => array('obsoleteIndex' => 'name', 'unique' => array('name'), 'change' => "`name` `name` VARCHAR(255) BINARY NOT NULL DEFAULT ''"), 'stats_referer' => array('obsoleteIndex' => 'uri', 'unique' => array('uri'), 'change' => "`uri` `uri` VARCHAR(255) BINARY NOT NULL DEFAULT ''"), 'stats_requests' => array('obsoleteIndex' => 'page', 'unique' => array('page'), 'count' => 'visits', 'change' => "`page` `page` VARCHAR(255) BINARY NOT NULL DEFAULT ''"), 'stats_requests_summary' => array('obsoleteIndex' => 'type', 'unique' => array('type', 'timestamp')), 'stats_screenresolution' => array('obsoleteIndex' => 'resolution', 'unique' => array('resolution')), 'stats_search' => array('change' => "`name` `name` VARCHAR(100) BINARY NOT NULL DEFAULT ''", 'unique' => array('name')), 'stats_spiders' => array('obsoleteIndex' => 'page', 'unique' => array('page'), 'change' => "`page` `page` VARCHAR(100) BINARY DEFAULT NULL"), 'stats_spiders_summary' => array('obsoleteIndex' => 'unqiue', 'unique' => array('name'), 'change' => "`name` `name` VARCHAR(255) BINARY NOT NULL DEFAULT ''"), 'stats_visitors_summary' => array('obsoleteIndex' => 'type', 'unique' => array('type', 'timestamp')), 'stats_visitors' => array('obsoleteIndex' => 'sid', 'unique' => array('sid'), 'count' => 'timestamp')) as $table => $arrUnique) { do { if (in_array($table, $_SESSION['contrexx_update']['update']['update_stats'])) { break; } elseif (!checkTimeoutLimit()) { return 'timeout'; } if (isset($arrUnique['change'])) { $query = 'ALTER TABLE `' . DBPREFIX . $table . '` CHANGE ' . $arrUnique['change']; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } $arrIndexes = $objDatabase->MetaIndexes(DBPREFIX . $table); if ($arrIndexes !== false) { if (isset($arrIndexes['unique'])) { $_SESSION['contrexx_update']['update']['update_stats'][] = $table; break; } elseif (isset($arrUnique['obsoleteIndex']) && isset($arrIndexes[$arrUnique['obsoleteIndex']])) { $query = 'ALTER TABLE `' . DBPREFIX . $table . '` DROP INDEX `' . $arrUnique['obsoleteIndex'] . '`'; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . $table)); return false; } #DBG::msg("table = $table"); #DBG::dump($arrUnique); if (isset($arrUnique['unique'])) { $query = 'SELECT `' . implode('`,`', $arrUnique['unique']) . '`, COUNT(`id`) AS redundancy FROM `' . DBPREFIX . $table . '` GROUP BY `' . implode('`,`', $arrUnique['unique']) . '` ORDER BY redundancy DESC'; $objEntry = $objDatabase->SelectLimit($query, 10); if ($objEntry !== false) { while (!$objEntry->EOF) { if (!checkTimeoutLimit()) { return 'timeout'; } $lastRedundancyCount = $objEntry->fields['redundancy']; if ($objEntry->fields['redundancy'] > 1) { $where = array(); foreach ($arrUnique['unique'] as $unique) { $where[] = "`" . $unique . "` = '" . addslashes($objEntry->fields[$unique]) . "'"; } $query = 'DELETE FROM `' . DBPREFIX . $table . '` WHERE ' . implode(' AND ', $where) . ' ORDER BY `' . (isset($arrUnique['count']) ? $arrUnique['count'] : 'count') . '` LIMIT ' . ($objEntry->fields['redundancy'] - 1); if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } else { break; } $objEntry->MoveNext(); } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } if ($objEntry->RecordCount() == 0 || $lastRedundancyCount < 2) { $query = 'ALTER IGNORE TABLE `' . DBPREFIX . $table . '` ADD UNIQUE `unique` (`' . implode('`,`', $arrUnique['unique']) . '`)'; if ($objDatabase->Execute($query) == false) { return _databaseError($query, $objDatabase->ErrorMsg()); } $_SESSION['contrexx_update']['update']['update_stats'][] = $table; break; } } while ($objEntry->RecordCount() > 1); } $arrIndexes = $objDatabase->MetaIndexes(DBPREFIX . 'stats_search'); if ($arrIndexes !== false) { if (isset($arrIndexes['unique'])) { $query = 'ALTER TABLE `' . DBPREFIX . 'stats_search` DROP INDEX `unique`'; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (empty($_SESSION['contrexx_update']['update']['update_stats']['utf8'])) { $query = "ALTER IGNORE TABLE `" . DBPREFIX . "stats_search` CHANGE `name` `name` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL"; if ($objDatabase->Execute($query)) { $_SESSION['contrexx_update']['update']['update_stats']['utf8'] = 1; $query = "ALTER IGNORE TABLE `" . DBPREFIX . "stats_search` CHANGE `name` `name` VARCHAR( 100 ) CHARACTER SET binary NOT NULL"; if ($_SESSION['contrexx_update']['update']['update_stats']['utf8'] == 1 && $objDatabase->Execute($query)) { $_SESSION['contrexx_update']['update']['update_stats']['utf8'] = 2; $query = "ALTER IGNORE TABLE `" . DBPREFIX . "stats_search` CHANGE `name` `name` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL"; if ($_SESSION['contrexx_update']['update']['update_stats']['utf8'] == 2 && $objDatabase->Execute($query)) { $_SESSION['contrexx_update']['update']['update_stats']['utf8'] = 3; $query = 'ALTER IGNORE TABLE `' . DBPREFIX . 'stats_search` ADD UNIQUE `unique` (`name`, `external`)'; if ($objDatabase->Execute($query) === false) { return _databaseError($query, $objDatabase->ErrorMsg()); } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'stats_search')); return false; } try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'stats_search', array('id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(100)', 'binary' => true, 'default' => ''), 'count' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'sid' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'external' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0')), array('unique' => array('fields' => array('name', 'external'), 'type' => 'UNIQUE'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'stats_requests', array('id' => array('type' => 'INT(9)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'timestamp' => array('type' => 'INT(11)', 'default' => '0', 'notnull' => false, 'after' => 'id'), 'pageId' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'timestamp'), 'page' => array('type' => 'VARCHAR(255)', 'after' => 'pageId', 'default' => '', 'binary' => true), 'visits' => array('type' => 'INT(9)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'page'), 'sid' => array('type' => 'VARCHAR(32)', 'after' => 'visits', 'default' => ''), 'pageTitle' => array('type' => 'VARCHAR(250)', 'after' => 'sid')), array('unique' => array('fields' => array('page'), 'type' => 'UNIQUE'))); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } try { //2.2.0: new config option 'exclude_identifying_info' \Cx\Lib\UpdateUtil::sql(' INSERT INTO ' . DBPREFIX . 'stats_config (id, name, value, status) VALUES (20, "exclude_identifying_info", 1, 0) ON DUPLICATE KEY UPDATE `id` = `id` '); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }
public function migrate() { try { if (empty($_SESSION['contrexx_update']['tables_created'])) { if (!\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'content')) { return true; } \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'content_page'); \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'content_node'); \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'log_entry'); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'content_node', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'id'), 'lft' => array('type' => 'INT(11)', 'after' => 'parent_id'), 'rgt' => array('type' => 'INT(11)', 'after' => 'lft'), 'lvl' => array('type' => 'INT(11)', 'after' => 'rgt')), array('IDX_E5A18FDD727ACA70' => array('fields' => array('parent_id'))), 'InnoDB', '', array('parent_id' => array('table' => DBPREFIX . 'content_node', 'column' => 'id', 'onDelete' => 'NO ACTION', 'onUpdate' => 'NO ACTION'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'content_page', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'node_id' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'id'), 'nodeIdShadowed' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'node_id'), 'lang' => array('type' => 'INT(11)', 'after' => 'nodeIdShadowed'), 'type' => array('type' => 'VARCHAR(16)', 'after' => 'lang'), 'caching' => array('type' => 'TINYINT(1)', 'after' => 'type'), 'updatedAt' => array('type' => 'timestamp', 'after' => 'caching', 'notnull' => false), 'updatedBy' => array('type' => 'CHAR(40)', 'after' => 'updatedAt'), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'updatedBy'), 'linkTarget' => array('type' => 'VARCHAR(16)', 'notnull' => false, 'after' => 'title'), 'contentTitle' => array('type' => 'VARCHAR(255)', 'after' => 'linkTarget'), 'slug' => array('type' => 'VARCHAR(255)', 'after' => 'contentTitle'), 'content' => array('type' => 'longtext', 'after' => 'slug'), 'sourceMode' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'content'), 'customContent' => array('type' => 'VARCHAR(64)', 'notnull' => false, 'after' => 'sourceMode'), 'useCustomContentForAllChannels' => array('type' => 'INT(2)', 'after' => 'customContent', 'notnull' => false), 'cssName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useCustomContentForAllChannels'), 'cssNavName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'cssName'), 'skin' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'cssNavName'), 'useSkinForAllChannels' => array('type' => 'INT(2)', 'after' => 'skin', 'notnull' => false), 'metatitle' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useSkinForAllChannels'), 'metadesc' => array('type' => 'text', 'after' => 'metatitle'), 'metakeys' => array('type' => 'text', 'after' => 'metadesc'), 'metarobots' => array('type' => 'VARCHAR(7)', 'notnull' => false, 'after' => 'metakeys'), 'start' => array('type' => 'timestamp', 'after' => 'metarobots', 'notnull' => false), 'end' => array('type' => 'timestamp', 'after' => 'start', 'notnull' => false), 'editingStatus' => array('type' => 'VARCHAR(16)', 'after' => 'end'), 'protection' => array('type' => 'INT(11)', 'after' => 'editingStatus'), 'frontendAccessId' => array('type' => 'INT(11)', 'after' => 'protection'), 'backendAccessId' => array('type' => 'INT(11)', 'after' => 'frontendAccessId'), 'display' => array('type' => 'TINYINT(1)', 'after' => 'backendAccessId'), 'active' => array('type' => 'TINYINT(1)', 'after' => 'display'), 'target' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'active'), 'module' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'target'), 'cmd' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'after' => 'module')), array('node_id' => array('fields' => array('node_id', 'lang'), 'type' => 'UNIQUE'), 'IDX_D8E86F54460D9FD7' => array('fields' => array('node_id'))), 'InnoDB', '', array('node_id' => array('table' => DBPREFIX . 'content_node', 'column' => 'id', 'onDelete' => 'SET NULL', 'onUpdate' => 'NO ACTION'))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'log_entry', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'action' => array('type' => 'VARCHAR(8)', 'after' => 'id'), 'logged_at' => array('type' => 'timestamp', 'after' => 'action', 'notnull' => false), 'version' => array('type' => 'INT(11)', 'after' => 'logged_at'), 'object_id' => array('type' => 'VARCHAR(32)', 'notnull' => false, 'after' => 'version'), 'object_class' => array('type' => 'VARCHAR(255)', 'after' => 'object_id'), 'data' => array('type' => 'longtext', 'after' => 'object_class', 'notnull' => false), 'username' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'data')), array('log_class_unique_version_idx' => array('fields' => array('version', 'object_id', 'object_class'), 'type' => 'UNIQUE'), 'log_class_lookup_idx' => array('fields' => array('object_class')), 'log_date_lookup_idx' => array('fields' => array('logged_at')), 'log_user_lookup_idx' => array('fields' => array('username'))), 'InnoDB'); $_SESSION['contrexx_update']['tables_created'] = true; if (!checkMemoryLimit() || !checkTimeoutLimit()) { return 'timeout'; } } } catch (\Cx\Lib\UpdateException $e) { \Cx\Lib\UpdateUtil::DefaultActionHandler($e); return false; } $pageRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $nodeRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node'); $this->nodeArr = array(); if (empty($_SESSION['contrexx_update']['root_node_added'])) { // This will be the root of the site-tree $root = new \Cx\Core\ContentManager\Model\Entity\Node(); self::$em->persist($root); self::$em->flush(); $_SESSION['contrexx_update']['root_node_added'] = true; } else { $root = $nodeRepo->getRoot(); } // Due to a bug in the old content manager, there happened to exist ghost-pages // that were never visible, neither in the frontend, nor in the backend. // Therefore, we'll need a list of these ghost-pages so that we won't migrate them. // (because those ghost-pages would probably break the new site-tree) $visiblePageIDs = $this->getVisiblePageIDs(); if ($visiblePageIDs === false) { return false; } if (empty($_SESSION['contrexx_update']['nodes_added'])) { // Fetch a list of all pages that have ever existed or still do. // (sql-note: join content tables to prevent to migrate body-less pages) try { $objNodeResult = \Cx\Lib\UpdateUtil::sql(' SELECT `catid`, `parcat`, `lang`, `displayorder` FROM `' . DBPREFIX . 'content_navigation_history` AS tnh INNER JOIN `' . DBPREFIX . 'content_history` AS tch ON tch.`id` = tnh.`id` WHERE tnh.`lang` IN (' . $this->migrateLangIds . ') UNION DISTINCT SELECT `catid`, `parcat`, `lang`, `displayorder` FROM `' . DBPREFIX . 'content_navigation` AS tn INNER JOIN `' . DBPREFIX . 'content` AS tc ON tc.`id` = tn.`catid` WHERE tn.`lang` IN (' . $this->migrateLangIds . ') ORDER BY `parcat`, `displayorder`, `lang` ASC '); } catch (\Cx\Lib\UpdateException $e) { \Cx\Lib\UpdateUtil::DefaultActionHandler($e); return false; } // Create a node for each page that ever existed or still does // and put them in the array $this->nodeArr $arrSortedNodes = $this->getSortedNodes($objNodeResult, $visiblePageIDs); if (!empty($_SESSION['contrexx_update']['nodes'])) { foreach ($_SESSION['contrexx_update']['nodes'] as $catId => $nodeId) { $node = $nodeRepo->find($nodeId); if ($node) { self::$em->remove($node); } } self::$em->flush(); unset($_SESSION['contrexx_update']['nodes']); } foreach ($arrSortedNodes as $node) { self::$em->persist($node); } self::$em->flush(); if (!isset($_SESSION['contrexx_update']['nodes'])) { $_SESSION['contrexx_update']['nodes'] = array(); } foreach ($this->nodeArr as $catId => $node) { $_SESSION['contrexx_update']['nodes'][$catId] = $node->getId(); } $_SESSION['contrexx_update']['nodes_added'] = true; if (!checkMemoryLimit() || !checkTimeoutLimit()) { return 'timeout'; } } else { if (!empty($_SESSION['contrexx_update']['nodes'])) { \DBG::msg('Load nodes..'); foreach ($_SESSION['contrexx_update']['nodes'] as $catId => $nodeId) { $node = $nodeRepo->find($nodeId); $this->nodeArr[$catId] = $node; } } } $p = array(); if (empty($_SESSION['contrexx_update']['history_pages_added'])) { // 1ST: MIGRATE PAGES FROM HISTORY try { $hasCustomContent = false; if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'content_navigation_history', 'custom_content')) { $hasCustomContent = true; } if (!empty($_SESSION['contrexx_update']['history_pages_index'])) { $limit = 'LIMIT ' . $_SESSION['contrexx_update']['history_pages_index'] . ', 18446744073709551615'; } else { $limit = ''; } $objResult = \Cx\Lib\UpdateUtil::sql(' SELECT cn.page_id, cn.content, cn.title, cn.metatitle, cn.metadesc, cn.metakeys, cn.metarobots, cn.css_name, cn.redirect, cn.expertmode, nav.catid, nav.parcat, nav.catname, nav.target, nav.displayorder, nav.displaystatus, nav.activestatus, nav.cachingstatus, nav.username, nav.changelog, nav.cmd, nav.lang, nav.module, nav.startdate, nav.enddate, nav.protected, nav.frontend_access_id, nav.backend_access_id, nav.themes_id, nav.css_name AS css_nav_name, ' . ($hasCustomContent ? 'nav.custom_content,' : '') . ' cnlog.action, cnlog.history_id, cnlog.is_validated FROM `' . DBPREFIX . 'content_history` AS cn INNER JOIN `' . DBPREFIX . 'content_navigation_history` AS nav ON cn.id = nav.id INNER JOIN `' . DBPREFIX . 'content_logfile` AS cnlog ON cn.id = cnlog.history_id WHERE nav.`lang` IN (' . $this->migrateLangIds . ') ORDER BY cnlog.id ASC ' . $limit . ' '); } catch (\Cx\Lib\UpdateException $e) { \Cx\Lib\UpdateUtil::DefaultActionHandler($e); return false; } // Migrate history if ($objResult !== false) { $historyPagesIndex = !empty($_SESSION['contrexx_update']['history_pages_index']) ? $_SESSION['contrexx_update']['history_pages_index'] : 0; while (!$objResult->EOF) { if (!checkMemoryLimit() || !checkTimeoutLimit()) { $_SESSION['contrexx_update']['history_pages_index'] = $historyPagesIndex; return 'timeout'; } $catId = $objResult->fields['catid']; // Skip ghosts if (!in_array($catId, $visiblePageIDs)) { $objResult->MoveNext(); continue; } // SET PARENT NODE if ($objResult->fields['parcat'] == 0 || !isset($this->nodeArr[$objResult->fields['parcat']])) { // Page was located on the first level in the site-tree. // Therefore, directly attach it to the ROOT-node $this->nodeArr[$catId]->setParent($root); } else { // Attach page to associated parent node $this->nodeArr[$catId]->setParent($this->nodeArr[$objResult->fields['parcat']]); } $page = null; if (!empty($_SESSION['contrexx_update']['pages'][$catId])) { $pageId = $_SESSION['contrexx_update']['pages'][$catId]; $page = $pageRepo->find($pageId); } if (!isset($_SESSION['contrexx_update']['pages'])) { $_SESSION['contrexx_update']['pages'] = array(); } // CREATE PAGE switch ($objResult->fields['action']) { case 'new': case 'update': if (empty($page)) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); } $this->_setPageRecords($objResult, $this->nodeArr[$catId], $page); self::$em->persist($page); self::$em->flush(); $_SESSION['contrexx_update']['pages'][$catId] = $page->getId(); break; case 'delete': if (!empty($page)) { self::$em->remove($page); self::$em->flush(); if (isset($_SESSION['contrexx_update']['pages'][$catId])) { unset($_SESSION['contrexx_update']['pages'][$catId]); } } break; } $historyPagesIndex++; $objResult->MoveNext(); } $_SESSION['contrexx_update']['history_pages_added'] = true; } } if (empty($_SESSION['contrexx_update']['pages_added'])) { // 2ND: MIGRATE CURRENT CONTENT try { $hasCustomContent = false; if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'content_navigation', 'custom_content')) { $hasCustomContent = true; } if (!empty($_SESSION['contrexx_update']['pages_index'])) { $limit = 'LIMIT ' . $_SESSION['contrexx_update']['pages_index'] . ', 18446744073709551615'; } else { $limit = ''; } $objRecords = \Cx\Lib\UpdateUtil::sql(' SELECT cn.id, cn.content, cn.title, cn.metatitle, cn.metadesc, cn.metakeys, cn.metarobots, cn.css_name, cn.redirect, cn.expertmode, nav.catid, nav.parcat, nav.catname, nav.target, nav.displayorder, nav.displaystatus, nav.activestatus, nav.cachingstatus, nav.username, nav.changelog, nav.cmd, nav.lang, nav.module, nav.startdate, nav.enddate, nav.protected, nav.frontend_access_id, nav.backend_access_id, nav.themes_id, nav.css_name AS css_nav_name ' . ($hasCustomContent ? ', nav.custom_content' : '') . ' FROM `' . DBPREFIX . 'content` AS cn INNER JOIN `' . DBPREFIX . 'content_navigation` AS nav ON cn.id = nav.catid WHERE cn.id AND nav.`lang` IN (' . $this->migrateLangIds . ') ORDER BY nav.parcat ASC, nav.displayorder ASC ' . $limit . ' '); } catch (\Cx\Lib\UpdateException $e) { \Cx\Lib\UpdateUtil::DefaultActionHandler($e); return false; } if ($objRecords !== false) { $pagesIndex = !empty($_SESSION['contrexx_update']['pages_index']) ? $_SESSION['contrexx_update']['pages_index'] : 0; while (!$objRecords->EOF) { if (!checkMemoryLimit() || !checkTimeoutLimit()) { $_SESSION['contrexx_update']['pages_index'] = $pagesIndex; return 'timeout'; } $catId = $objRecords->fields['catid']; // Skip ghosts if (!in_array($catId, $visiblePageIDs)) { $objRecords->MoveNext(); continue; } if (!isset($this->nodeArr[$catId])) { setUpdateMsg('Trying to migrate non-existing node: id ' . $catId); return false; } //$node = $this->nodeArr[$catId]; if ($objRecords->fields['parcat'] == 0 || !isset($this->nodeArr[$objRecords->fields['parcat']])) { // Page was located on the first level in the site-tree. // Therefore, directly attach it to the ROOT-node //$node->setParent($root); $this->nodeArr[$catId]->setParent($root); } else { // Attach page to associated parent node //$node->setParent($this->nodeArr[$objRecords->fields['parcat']]); $this->nodeArr[$catId]->setParent($this->nodeArr[$objRecords->fields['parcat']]); } \DBG::msg('Migrate page ' . $objRecords->fields['catname'] . ' (catid: ' . $catId . ' | lang: ' . $objRecords->fields['lang'] . ')'); self::$em->persist($this->nodeArr[$catId]); self::$em->flush(); $nodeRepo->moveDown($this->nodeArr[$catId], true); self::$em->persist($this->nodeArr[$catId]); if (!empty($_SESSION['contrexx_update']['pages'][$catId])) { $pageId = $_SESSION['contrexx_update']['pages'][$catId]; $page = $pageRepo->find($pageId); } else { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); } $this->_setPageRecords($objRecords, $this->nodeArr[$catId], $page); $page->setAlias(array('legacy_page_' . $catId)); self::$em->persist($page); self::$em->flush(); $_SESSION['contrexx_update']['pages'][$catId] = $page->getId(); $pagesIndex++; $objRecords->MoveNext(); } $_SESSION['contrexx_update']['pages_added'] = true; } } foreach ($this->arrMigrateLangIds as $langId) { $objResult = \Cx\Lib\UpdateUtil::sql(' SELECT `catid` FROM `' . DBPREFIX . 'content_navigation` WHERE `module` = 15 AND `cmd` = \'\' AND `lang` = ' . $langId . ' ORDER BY `parcat` ASC LIMIT 1 '); if ($objResult === false || $objResult && empty($objResult->fields['catid'])) { continue; } $homeCatId = $objResult->fields['catid']; $objResult = \Cx\Lib\UpdateUtil::sql(' SELECT `catid` FROM `' . DBPREFIX . 'content_navigation` WHERE `module` = 15 AND `cmd` = \'\' AND `catid` <> ' . $homeCatId . ' AND `lang` = ' . $langId . ' '); if ($objResult->RecordCount()) { $i = 1; while (!$objResult->EOF) { $catId = $objResult->fields['catid']; $aliasPage = $pageRepo->findOneBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS, 'slug' => 'legacy_page_' . $catId), true); if ($aliasPage) { $targetPage = $pageRepo->getTargetPage($aliasPage); if ($targetPage) { $this->_setCmd($targetPage, $i); self::$em->persist($targetPage); } } $objResult->MoveNext(); $i++; } self::$em->flush(); } } return true; }
private function processUpdate() { global $_CORELANG, $_CONFIG, $_ARRAYLANG; $this->objTemplate->addBlockfile('CONTENT', 'process', 'process.html'); if (($return = $this->_loadUpdateLanguage()) !== true) { $this->objTemplate->setVariable('UPDATE_ERROR_MSG', $return); $this->objTemplate->parse('updateProcessError'); } elseif (($arrVersions = $this->getAvailabeVersions()) === false || !@(include_once UPDATE_UPDATES . '/' . $_SESSION['contrexx_update']['version'] . '/' . $arrVersions[$_SESSION['contrexx_update']['version']]['script'])) { $this->objTemplate->setVariable('UPDATE_ERROR_MSG', $_CORELANG['TXT_UPDATE_UNABLE_TO_START']); $this->objTemplate->parse('updateProcessError'); } else { if (!$this->_isNewerVersion($_CONFIG['coreCmsVersion'], $_SESSION['contrexx_update']['version'])) { $result = true; } else { if (!empty($_POST['execution_time'])) { $_SESSION['contrexx_update']['max_execution_time'] = intval($_POST['execution_time']); if (intval($_POST['execution_time']) < 20) { setUpdateMsg('<div class="message-warning">' . $_CORELANG['TXT_UPDATE_EXECUTION_TIME'] . '</div>', 'msg'); setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button'); $result = false; } else { die('{"time": ' . intval($_POST['execution_time']) . '}'); } } else { try { if (!activateDebugging()) { throw new \Exception("The debugging file couldn't be created."); } $result = true; } catch (\Exception $e) { setUpdateMsg($_CORELANG['TXT_UPDATE_DBG_FILE'], 'msg'); setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="skipDebugMsg" id="skipDebugMsg" value="skipDebugMsg" />', 'button'); if (empty($_POST['skipDebugMsg'])) { $result = false; } } if ($result !== false) { DBG::msg('-------------------------------------------------------------'); DBG::msg('CLOUDREXX UPDATE - NEW REQUEST'); DBG::msg('Date: ' . date('d.m.Y H:i:s')); DBG::msg('Get-Params:'); DBG::dump($_GET); DBG::msg('User: '******'contrexx_update']['username']); DBG::msg('-------------------------------------------------------------'); $result = executeContrexxUpdate(); } } } if ($result !== true) { if (!empty($this->arrStatusMsg['error'])) { $this->objTemplate->setVariable('UPDATE_ERROR_MSG', implode('<br />', $this->arrStatusMsg['error'])); $this->objTemplate->parse('updateProcessError'); } if (empty($this->arrStatusMsg['title'])) { $this->arrStatusMsg['title'] = 'Update Fehler'; } if (empty($this->arrStatusMsg['button'])) { $this->arrStatusMsg['button'] = '<input type="submit" value="' . $_CORELANG['TXT_UPDATE_TRY_AGAIN'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />'; } if (!empty($this->arrStatusMsg['dialog']) && empty($this->arrStatusMsg['error'])) { $this->objTemplate->hideBlock('processStatus'); $dialogContent = implode('<br />', $this->arrStatusMsg['msg']); if (!$this->ajax) { $dialogContent = str_replace(array('\'', "\r\n"), array('\\\'', ''), $dialogContent); } $this->objTemplate->setVariable('PROCESS_DIALOG_CONTENT', $dialogContent); if ($this->ajax) { $this->html['dialog'] = $this->arrStatusMsg['dialog']; $this->objTemplate->parse('ajaxDialogContent'); } else { $this->objTemplate->parse('dialogContent'); } } else { if (!empty($this->arrStatusMsg['timeout']) && empty($this->arrStatusMsg['error'])) { $this->html['timeout'] = $this->arrStatusMsg['timeout']; } else { $this->objTemplate->hideBlock('dialogContent'); $this->objTemplate->hideBlock('ajaxDialogContent'); $this->objTemplate->setVariable(array('UPDATE_PROCESS_TITLE' => $_CORELANG['TXT_UPDATE_UPDATE_PROCESS'], 'UPDATE_STATUS_TITLE' => $this->arrStatusMsg['title'], 'UPDATE_STATUS' => str_replace('[[SQL_INFO_TITLE]]', $this->arrStatusMsg['title'], implode('<br />', $this->arrStatusMsg['msg'])))); $this->setNavigation($this->arrStatusMsg['button']); } } } else { $this->objTemplate->hideBlock('dialogContent'); $this->objTemplate->hideBlock('ajaxDialogContent'); $this->objTemplate->hideBlock('processStatus'); $urlFrontend = ASCMS_PATH_OFFSET !== '' ? ASCMS_PATH_OFFSET : '/'; if (!empty($_SESSION['contrexx_update']['modified_files']) && count($_SESSION['contrexx_update']['modified_files'])) { foreach ($_SESSION['contrexx_update']['modified_files'] as $arrFile) { $this->objTemplate->setVariable(array('BACKUP_FILE_SRC' => $arrFile['src'], 'BACKUP_FILE_DST' => $arrFile['dst'])); $this->objTemplate->parse('backed_file'); } $this->objTemplate->parse('backed_files'); } else { $this->objTemplate->hideblock('backed_files'); } if (!empty($_SESSION['contrexx_update']['modified_cmds']) && count($_SESSION['contrexx_update']['modified_cmds'])) { foreach ($_SESSION['contrexx_update']['modified_cmds'] as $arrCmds) { $this->objTemplate->setVariable(array('CHANGED_CMD_PAGE_TITLE' => $arrCmds['pageTitle'], 'CHANGED_CMD_ORIG_CMD' => $arrCmds['origCmd'], 'CHANGED_CMD_NEW_CMD' => $arrCmds['newCmd'])); $this->objTemplate->parse('changed_cmd'); } $this->objTemplate->parse('changed_cmds'); } else { $this->objTemplate->hideblock('changed_cmds'); } $this->objTemplate->setVariable(array('TXT_UPDATE_UPDATE_FINISHED' => $_CORELANG['TXT_UPDATE_UPDATE_FINISHED'], 'URL_FRONTEND' => $urlFrontend, 'URL_BACKEND' => ASCMS_PATH_OFFSET . ASCMS_BACKEND_PATH, 'UPDATE_VERSION_INSTALLED' => $this->getLiteralRepresentationOfVersion($_SESSION['contrexx_update']['version']), 'UPDATE_VERSION_NUMBER' => $_SESSION['contrexx_update']['version'])); $this->objTemplate->parse('finish'); $_SESSION['contrexx_update']['step'] = 0; $_SESSION['contrexx_update']['update'] = array(); } } $this->objTemplate->parse('process'); if ($this->ajax) { $this->html['content'] = $this->objTemplate->get('process'); } }
function _guestbookUpdate() { global $objDatabase, $_ARRAYLANG; $arrGuestbookColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_guestbook'); if ($arrGuestbookColumns === false) { setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_guestbook')); return false; } if (isset($arrGuestbookColumns['NICKNAME']) and !isset($arrGuestbookColumns['NAME'])) { $query = "ALTER TABLE " . DBPREFIX . "module_guestbook\n CHANGE `nickname` `name` varchar(255) NOT NULL default ''"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } if (!isset($arrGuestbookColumns['FORENAME'])) { $query = "ALTER TABLE " . DBPREFIX . "module_guestbook\n ADD `forename` varchar(255) NOT NULL default '' AFTER `name`"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // this addidional structure update/check is required due that the full version's structure isn't as it should be try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_guestbook', array('id' => array('type' => 'INT(6)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => 0), 'name' => array('type' => 'VARCHAR(255)'), 'forename' => array('type' => 'VARCHAR(255)'), 'gender' => array('type' => 'CHAR(1)', 'notnull' => true, 'default' => ''), 'url' => array('type' => 'TINYTEXT'), 'email' => array('type' => 'TINYTEXT'), 'comment' => array('type' => 'TEXT'), 'ip' => array('type' => 'VARCHAR(15)'), 'location' => array('type' => 'TINYTEXT'), 'lang_id' => array('type' => 'TINYINT(2)', 'default' => '1'), 'datetime' => array('type' => 'DATETIME', 'default' => '0000-00-00 00:00:00')), array('comment' => array('fields' => array('comment'), 'type' => 'FULLTEXT'))); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /******************************** * EXTENSION: Timezone * * ADDED: Contrexx v3.0.0 * ********************************/ try { \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_guestbook` CHANGE `datetime` `datetime` TIMESTAMP NOT NULL DEFAULT "0000-00-00 00:00:00"'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } /******************************** * EXTENSION: Captcha * * ADDED: Contrexx v3.0.0 * ********************************/ try { // switch to source mode for guestbook content page \Cx\Lib\UpdateUtil::setSourceModeOnContentPage(array('module' => 'guestbook', 'cmd' => 'post'), '3.0.1'); // migrate content page to version 3.0.1 $search = array('/(.*)/ms'); $callback = function ($matches) { $content = $matches[1]; if (empty($content)) { return $content; } $content = str_replace(array('nickname', 'NICKNAME'), array('name', 'NAME'), $content); if (!preg_match('/<!--\\s+BEGIN\\s+guestbookForm\\s+-->.*<!--\\s+END\\s+guestbookForm\\s+-->/ms', $content)) { $content = '<!-- BEGIN guestbookForm -->' . $content . '<!-- END guestbookForm -->'; } if (!preg_match('/<!--\\s+BEGIN\\s+guestbookStatus\\s+-->.*<!--\\s+END\\s+guestbookStatus\\s+-->/ms', $content)) { $content .= <<<STATUS_HTML <!-- BEGIN guestbookStatus --> {GUESTBOOK_STATUS}<br /><br /> <a href="index.php?section=guestbook">Zurück zum Gästebuch</a> <!-- END guestbookStatus --> STATUS_HTML; } if (!preg_match('/<!--\\s+BEGIN\\s+guestbook_captcha\\s+-->.*<!--\\s+END\\s+guestbook_captcha\\s+-->/ms', $content)) { // migrate captcha stuff $newCaptchaCode = <<<CAPTCHA_HTML <!-- BEGIN guestbook_captcha --> <p><label for="coreCaptchaCode">{TXT_GUESTBOOK_CAPTCHA}</label>{GUESTBOOK_CAPTCHA_CODE}</p> <!-- END guestbook_captcha --> CAPTCHA_HTML; $content = preg_replace('/<[^>]+\\{IMAGE_URL\\}.*\\{CAPTCHA_OFFSET\\}[^>]+>/ms', $newCaptchaCode, $content); } // this adds the missing placeholders [[FEMALE_CHECKED]], [[MALE_CHECKED]] $pattern = '/(<input[^>]+name=[\'"]malefemale[\'"])([^>]*>)/ms'; if (preg_match_all($pattern, $content, $match)) { foreach ($match[0] as $idx => $input) { // check if "checked"-placeholder is missing inputfield if (!preg_match('/\\{(FE)?MALE_CHECKED\\}/ms', $input)) { if (preg_match('/value\\s*=\\s*[\'"]F[\'"]/', $input)) { $content = str_replace($input, $match[1][$idx] . ' {FEMALE_CHECKED} ' . $match[2][$idx], $content); } elseif (preg_match('/value\\s*=\\s*[\'"]M[\'"]/', $input)) { $content = str_replace($input, $match[1][$idx] . ' {MALE_CHECKED} ' . $match[2][$idx], $content); } } } } return $content; }; \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'guestbook', 'cmd' => 'post'), $search, $callback, array('content'), '3.0.1'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }