Example #1
0
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;
}
Example #2
0
/**
 * 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;
}
Example #3
0
function _dataUpdate()
{
    global $objDatabase;
    $arrTables = $objDatabase->MetaTables('TABLES');
    if (!sizeof($arrTables)) {
        return _databaseError("MetaTables('TABLES')", 'Could not read Table metadata');
    }
    // Create neccessary tables if not present
    $tables = array('module_data_categories' => "CREATE TABLE `" . DBPREFIX . "module_data_categories` (\n              `category_id` int(4) unsigned NOT NULL default '0',\n              `lang_id` int(2) unsigned NOT NULL default '0',\n              `is_active` enum('0','1') NOT NULL default '1',\n              `parent_id` int(10) unsigned NOT NULL default '0',\n              `name` varchar(100) NOT NULL default '',\n              `active` enum('0','1') NOT NULL default '1',\n              `cmd` int(10) unsigned NOT NULL default '1',\n              `action` enum('content','overlaybox','subcategories') NOT NULL default 'content',\n              `sort` int(10) unsigned NOT NULL default '1',\n              `box_height` int(10) unsigned NOT NULL default '500',\n              `box_width` int(11) NOT NULL default '350',\n              `template` text NOT NULL,\n              PRIMARY KEY (`category_id`,`lang_id`)\n            ) ENGINE=InnoDB", 'module_data_message_to_category' => "CREATE TABLE `" . DBPREFIX . "module_data_message_to_category` (\n              `message_id` int(6) unsigned NOT NULL default '0',\n              `category_id` int(4) unsigned NOT NULL default '0',\n              `lang_id` int(2) unsigned NOT NULL default '0',\n              PRIMARY KEY (`message_id`,`category_id`,`lang_id`),\n              KEY `category_id` (`category_id`)\n            ) ENGINE=InnoDB", 'module_data_messages' => "CREATE TABLE `" . DBPREFIX . "module_data_messages` (\n              `message_id` int(6) unsigned NOT NULL auto_increment,\n              `user_id` int(5) unsigned NOT NULL default '0',\n              `time_created` int(14) unsigned NOT NULL default '0',\n              `time_edited` int(14) unsigned NOT NULL default '0',\n              `hits` int(7) unsigned NOT NULL default '0',\n              `active` enum('0','1') NOT NULL default '1',\n              `sort` int(10) unsigned NOT NULL default '1',\n              `mode` set('normal','forward') NOT NULL default 'normal',\n              `release_time` int(15) NOT NULL default '0',\n              `release_time_end` int(15) NOT NULL default '0',\n              PRIMARY KEY (`message_id`)\n            ) ENGINE=InnoDB", 'module_data_settings' => "CREATE TABLE `" . DBPREFIX . "module_data_settings` (\n              `name` varchar(50) NOT NULL default '',\n              `value` text NOT NULL,\n              PRIMARY KEY (`name`)\n            ) ENGINE=InnoDB");
    ///////////////////////////////////////////////////////////////////
    // Create tables                                                 //
    ///////////////////////////////////////////////////////////////////
    foreach ($tables as $name => $query) {
        if (in_array(DBPREFIX . $name, $arrTables)) {
            continue;
        }
        if (!$objDatabase->Execute($query)) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
        // TODO: Unused
        //        $installed[] = $name;
    }
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_data_placeholders', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'SET(\'cat\',\'entry\')', 'notnull' => true, 'default' => ''), 'ref_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'placeholder' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '')), array('placeholder' => array('fields' => array('placeholder'), 'type' => 'UNIQUE'), 'type' => array('fields' => array('type', 'ref_id'), 'type' => 'UNIQUE')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $settings_query = "\nINSERT INTO `" . DBPREFIX . "module_data_settings` (`name`, `value`) VALUES\n('data_block_activated', '0'),\n('data_block_messages', '3'),\n('data_comments_activated', '1'),\n('data_comments_anonymous', '1'),\n('data_comments_autoactivate', '1'),\n('data_comments_editor', 'wysiwyg'),\n('data_comments_notification', '1'),\n('data_comments_timeout', '30'),\n('data_entry_action', 'overlaybox'),\n('data_general_introduction', '150'),\n('data_rss_activated', '0'),\n('data_rss_comments', '10'),\n('data_rss_messages', '5'),\n('data_tags_hitlist', '5'),\n('data_target_cmd', '1'),\n('data_template_category',\n'<!-- BEGIN datalist_category -->\n<!-- this displays the category and the subcategories -->\n<div class=\\\"datalist_block\\\">\n<dl>\n  <!-- BEGIN category -->\n  <dt class=\\\"cattitle\\\"><div class=\\\"bg\\\"><h4>[[CATTITLE]]</h4></div></dt>\n  <dd class=\\\"catcontent\\\">\n    <dl>\n      <!-- BEGIN entry -->\n      <dt>[[TITLE]]</dt>\n      <dd>\n        [[IMAGE]] [[CONTENT]] <a href=\\\"[[HREF]]\\\" [[CLASS]] [[TARGET]]>[[TXT_MORE]]</a>\n        <br style=\\\"clear: both;\\\" />\n      </dd>\n      <!-- END entry -->\n    </dl>\n  </dd>\n  <!-- END category -->\n</dl>\n</div>\n<!-- END datalist_category -->\n<!-- BEGIN datalist_single_category-->\n<!-- this displays just the entries of the category -->\n<div class=\\\"datalist_block\\\">\n<dl>\n  <!-- BEGIN single_entry -->\n  <dt class=\\\"cattitle\\\"><div class=\\\"bg\\\"><h4>[[TITLE]]</h4></div></dt>\n  <dd class=\\\"catcontent2\\\">\n    [[IMAGE]] <p>[[CONTENT]] <a href=\\\"[[HREF]]\\\" [[CLASS]] [[TARGET]]>[[TXT_MORE]]</a></p>\n    <div style=\\\"clear: both;\\\" />\n  </dd>\n  <!-- END single_entry -->\n</dl>\n</div>\n<!-- END datalist_single_category -->\n'),\n('data_template_entry',\n'<!-- BEGIN datalist_entry-->\n<div class=\\\"datalist_block\\\">\n<dl>\n  <dt>[[TITLE]]</dt>\n  <dd>\n    [[IMAGE]] [[CONTENT]] <a href=\\\"[[HREF]]\\\" [[CLASS]]>[[TXT_MORE]]</a>\n    <br style=\\\"clear: both;\\\" />\n  </dd>\n</dl>\n</div>\n<!-- END datalist_entry -->\n    '),\n('data_template_thickbox',\n'<!-- BEGIN thickbox -->\n<dl class=\\\"data_module\\\">\n  <dt><h6 style=\\\"margin-bottom:10px;\\\">[[TITLE]]</h6></dt>\n  <dd style=\\\"clear:left;\\\">\n    <!-- BEGIN image -->\n    <img src=\\\"[[PICTURE]]\\\" style=\\\"float: left; margin-right: 5px;\\\" />\n    <!-- END image -->\n    [[CONTENT]]\n    <!-- BEGIN attachment -->\n    <img src=\\\"/themes/default/images/arrow.gif\\\" width=\\\"16\\\" height=\\\"8\\\" />\n    <a href=\\\"javascript:void(0);\\\" onclick=\\\"window.open(\\'[[HREF]]\\', \\'attachment\\');\\\">[[TXT_DOWNLOAD]]</a>\n    <!-- END attachment -->\n  </dd>\n</dl>\n<!--<br /><img src=\\\"/themes/default/images/arrow.gif\\\" width=\\\"16\\\" height=\\\"8\\\" /><a onclick=\\\"Javascript:window.print();\\\" style=\\\"cursor:pointer;\\\">Drucken</a>-->\n<!-- END thickbox -->\n'),\n('data_thickbox_height', '450'),\n('data_thickbox_width', '400'),\n('data_voting_activated', '0');\n";
    ///////////////////////////////////////////////////////////////////
    // data module settings                                          //
    ///////////////////////////////////////////////////////////////////
    $query = "SELECT COUNT(*) AS recordcount FROM `" . DBPREFIX . "module_data_settings`";
    $objResult = $objDatabase->Execute($query);
    if ($objResult === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    if ($objResult->fields['recordcount'] == 0) {
        // module_data_settings table is empty. Fill it with default data.
        if (!$objDatabase->Execute($settings_query)) {
            return _databaseError($settings_query, $objDatabase->ErrorMsg());
        }
    }
    /*********************************************************
     * EXTENSION:	Thunbmail Image & Attachment description *
     * ADDED:		Contrexx v2.1.0					         *
     *********************************************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_data_messages_lang', array('message_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'is_active' => array('type' => 'ENUM(\'0\',\'1\')', 'default' => '1'), 'subject' => array('type' => 'VARCHAR(250)', 'default' => ''), 'content' => array('type' => 'text'), 'tags' => array('type' => 'VARCHAR(250)', 'default' => ''), 'image' => array('type' => 'VARCHAR(250)', 'default' => ''), 'thumbnail' => array('type' => 'VARCHAR(250)'), 'thumbnail_type' => array('type' => 'ENUM(\'original\',\'thumbnail\')', 'default' => 'original', 'after' => 'thumbnail'), 'thumbnail_width' => array('type' => 'TINYINT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'thumbnail_height' => array('type' => 'TINYINT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'attachment' => array('type' => 'VARCHAR(255)', 'default' => ''), 'attachment_description' => array('type' => 'VARCHAR(255)', 'default' => ''), 'mode' => array('type' => 'SET(\'normal\',\'forward\')', 'default' => 'normal'), 'forward_url' => array('type' => 'VARCHAR(255)', 'default' => ''), 'forward_target' => array('type' => 'VARCHAR(40)', 'notnull' => false)), array(), 'InnoDB');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Example #4
0
function _galleryUpdate()
{
    global $objDatabase, $_ARRAYLANG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_gallery_categories', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'pid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'sorting' => array('type' => 'INT(6)', 'notnull' => true, 'default' => '0'), 'status' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'), 'comment' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'voting' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'backendProtected' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'backend_access_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'frontendProtected' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'frontend_access_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_gallery_pictures', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'catid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'validated' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'status' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'), 'catimg' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'sorting' => array('type' => 'INT(6) UNSIGNED', 'notnull' => true, 'default' => '999'), 'size_show' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'), 'path' => array('type' => 'TEXT', 'notnull' => true), 'link' => array('type' => 'TEXT', 'notnull' => true), 'lastedit' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'size_type' => array('type' => "SET('abs', 'proz')", 'notnull' => true, 'default' => 'proz'), 'size_proz' => array('type' => "INT(3)", 'notnull' => true, 'default' => '0'), 'size_abs_h' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'size_abs_w' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'quality' => array('type' => 'TINYINT(3)', 'notnull' => true, 'default' => '0')), array('galleryPicturesIndex' => array('type' => 'FULLTEXT', 'fields' => array('path'))));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $arrSettings = array('1' => array('name' => 'max_images_upload', 'value' => '10'), '2' => array('name' => 'standard_quality', 'value' => '95'), '3' => array('name' => 'standard_size_proz', 'value' => '25'), '4' => array('name' => 'standard_width_abs', 'value' => '140'), '6' => array('name' => 'standard_height_abs', 'value' => '0'), '7' => array('name' => 'standard_size_type', 'value' => 'abs'), '8' => array('name' => 'validation_show_limit', 'value' => '10'), '9' => array('name' => 'validation_standard_type', 'value' => 'all'), '11' => array('name' => 'show_names', 'value' => 'off'), '12' => array('name' => 'quality', 'value' => '95'), '13' => array('name' => 'show_comments', 'value' => 'off'), '14' => array('name' => 'show_voting', 'value' => 'off'), '15' => array('name' => 'enable_popups', 'value' => 'on'), '16' => array('name' => 'image_width', 'value' => '1200'), '17' => array('name' => 'paging', 'value' => '30'), '18' => array('name' => 'show_latest', 'value' => 'on'), '19' => array('name' => 'show_random', 'value' => 'on'), '20' => array('name' => 'header_type', 'value' => 'hierarchy'), '21' => array('name' => 'show_ext', 'value' => 'off'), '22' => array('name' => 'show_file_name', 'value' => 'on'), '23' => array('name' => 'slide_show', 'value' => 'slideshow'), '24' => array('name' => 'slide_show_seconds', 'value' => '3'));
    foreach ($arrSettings as $id => $arrSetting) {
        $query = "SELECT 1 FROM `" . DBPREFIX . "module_gallery_settings` WHERE `name`= '" . $arrSetting['name'] . "'";
        if (($objRS = $objDatabase->Execute($query)) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
        if ($objRS->RecordCount() == 0) {
            $query = "\n                INSERT INTO `" . DBPREFIX . "module_gallery_settings` (`id`, `name`, `value`)\n                VALUES (" . $id . ", '" . $arrSetting['name'] . "', '" . $arrSetting['value'] . "')\n                ON DUPLICATE KEY UPDATE `id` = `id`\n            ";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    /**************************************************************************
     * EXTENSION:   cleanup: delete translations, comments and                *
     *              votes of inexisting pictures                              *
     * ADDED:       Contrexx v3.0.1                                           *
     **************************************************************************/
    try {
        \Cx\Lib\UpdateUtil::sql('
            DELETE `language_pics`
            FROM `' . DBPREFIX . 'module_gallery_language_pics` as `language_pics` LEFT JOIN `' . DBPREFIX . 'module_gallery_pictures` as `pictures` ON `pictures`.`id` = `language_pics`.`picture_id`
            WHERE `pictures`.`id` IS NULL
        ');
        \Cx\Lib\UpdateUtil::sql('
            DELETE `comments`
            FROM `' . DBPREFIX . 'module_gallery_comments` as `comments` LEFT JOIN `' . DBPREFIX . 'module_gallery_pictures` as `pictures` ON `pictures`.`id` = `comments`.`picid`
            WHERE `pictures`.`id` IS NULL
        ');
        \Cx\Lib\UpdateUtil::sql('
            DELETE `votes`
            FROM `' . DBPREFIX . 'module_gallery_votes` as `votes` LEFT JOIN `' . DBPREFIX . 'module_gallery_pictures` as `pictures` ON `pictures`.`id` = `votes`.`picid`
            WHERE `pictures`.`id` IS NULL
        ');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // remove the script tag at the beginning of the gallery page
    \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'gallery'), '/^\\s*(<script[^>]+>.+?Shadowbox.+?<\\/script>)+/sm', '', array('content'), '3.0.3');
    return true;
}
Example #5
0
function _updateBackendAreas()
{
    global $objDatabase, $objUpdate, $_CONFIG;
    $arrBackendAreas = array(array('area_id' => 1, 'parent_area_id' => 0, 'type' => 'group', 'scope' => 'backend', 'area_name' => 'TXT_CONTENT_MANAGEMENT', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 2, 'access_id' => 1), array('area_id' => 2, 'parent_area_id' => 0, 'type' => 'group', 'scope' => 'backend', 'area_name' => 'TXT_MODULE', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 6, 'access_id' => 2), array('area_id' => 3, 'parent_area_id' => 0, 'type' => 'group', 'scope' => 'backend', 'area_name' => 'TXT_ADMINISTRATION', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 8, 'access_id' => 3), array('area_id' => 8, 'parent_area_id' => 0, 'type' => 'group', 'scope' => 'backend', 'area_name' => 'TXT_CORE_ECOMMERCE', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 4, 'access_id' => 4), array('area_id' => 15, 'parent_area_id' => 0, 'type' => 'group', 'scope' => 'backend', 'area_name' => 'TXT_CORE_MEDIA', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 3, 'access_id' => 162), array('area_id' => 28, 'parent_area_id' => 0, 'type' => 'group', 'scope' => 'backend', 'area_name' => 'TXT_CORE_STATS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 7, 'access_id' => 163), array('area_id' => 29, 'parent_area_id' => 0, 'type' => 'group', 'scope' => 'backend', 'area_name' => 'TXT_CORE_EMAIL_MARKETING', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 5, 'access_id' => 152), array('area_id' => 188, 'parent_area_id' => 0, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'Nettools', 'is_active' => 1, 'uri' => 'index.php?cmd=nettools', 'target' => '_self', 'module_id' => 32, 'order_id' => 0, 'access_id' => 0), array('area_id' => 177, 'parent_area_id' => 0, 'type' => 'function', 'scope' => 'global', 'area_name' => 'Json Adapter', 'is_active' => 1, 'uri' => 'index.php?cmd=jsondata', 'target' => '_self', 'module_id' => 63, 'order_id' => 0, 'access_id' => 0), array('area_id' => 178, 'parent_area_id' => 0, 'type' => 'function', 'scope' => 'global', 'area_name' => 'File Browser', 'is_active' => 1, 'uri' => 'index.php?cmd=fileBrowser', 'target' => '_self', 'module_id' => 26, 'order_id' => 0, 'access_id' => 0), array('area_id' => 180, 'parent_area_id' => 0, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_SEARCH', 'is_active' => 1, 'uri' => 'index.php?cmd=search', 'target' => '_self', 'module_id' => 5, 'order_id' => 0, 'access_id' => 0), array('area_id' => 181, 'parent_area_id' => 0, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_UPLOAD', 'is_active' => 1, 'uri' => 'index.php?cmd=upload', 'target' => '_self', 'module_id' => 52, 'order_id' => 0, 'access_id' => 0), array('area_id' => 183, 'parent_area_id' => 0, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_LOGOUT', 'is_active' => 1, 'uri' => 'index.php?cmd=logout', 'target' => '_self', 'module_id' => 67, 'order_id' => 0, 'access_id' => 0), array('area_id' => 184, 'parent_area_id' => 0, 'type' => 'group', 'scope' => 'backend', 'area_name' => 'TXT_HOME', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 1, 'order_id' => 1, 'access_id' => 0), array('area_id' => 5, 'parent_area_id' => 1, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_NEW_PAGE', 'is_active' => 1, 'uri' => 'index.php?cmd=content&amp;act=new', 'target' => '_self', 'module_id' => 1, 'order_id' => 1, 'access_id' => 5), array('area_id' => 6, 'parent_area_id' => 1, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CONTENT_MANAGER', 'is_active' => 1, 'uri' => 'index.php?cmd=content', 'target' => '_self', 'module_id' => 1, 'order_id' => 2, 'access_id' => 6), array('area_id' => 10, 'parent_area_id' => 1, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_NEWS_MANAGER', 'is_active' => 1, 'uri' => 'index.php?cmd=news', 'target' => '_self', 'module_id' => 8, 'order_id' => 4, 'access_id' => 10), array('area_id' => 75, 'parent_area_id' => 1, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CONTENT_HISTORY', 'is_active' => 1, 'uri' => 'index.php?cmd=workflow', 'target' => '_self', 'module_id' => 1, 'order_id' => 3, 'access_id' => 75), array('area_id' => 76, 'parent_area_id' => 1, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_BLOCK_SYSTEM', 'is_active' => 1, 'uri' => 'index.php?cmd=block', 'target' => '_self', 'module_id' => 7, 'order_id' => 7, 'access_id' => 76), array('area_id' => 90, 'parent_area_id' => 1, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CONTACTS', 'is_active' => 1, 'uri' => 'index.php?cmd=contact', 'target' => '_self', 'module_id' => 6, 'order_id' => 5, 'access_id' => 84), array('area_id' => 9, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_GUESTBOOK', 'is_active' => 1, 'uri' => 'index.php?cmd=guestbook', 'target' => '_self', 'module_id' => 10, 'order_id' => 0, 'access_id' => 9), array('area_id' => 11, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_DOC_SYS_MANAGER', 'is_active' => 1, 'uri' => 'index.php?cmd=docsys', 'target' => '_self', 'module_id' => 19, 'order_id' => 0, 'access_id' => 11), array('area_id' => 12, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_THUMBNAIL_GALLERY', 'is_active' => 1, 'uri' => 'index.php?cmd=gallery', 'target' => '_self', 'module_id' => 3, 'order_id' => 0, 'access_id' => 12), array('area_id' => 14, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_VOTING', 'is_active' => 1, 'uri' => 'index.php?cmd=voting', 'target' => '_self', 'module_id' => 17, 'order_id' => 0, 'access_id' => 14), array('area_id' => 16, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CALENDAR', 'is_active' => 1, 'uri' => 'index.php?cmd=calendar', 'target' => '_self', 'module_id' => 21, 'order_id' => 0, 'access_id' => 16), array('area_id' => 27, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_NEWS_SYNDICATION', 'is_active' => 1, 'uri' => 'index.php?cmd=feed', 'target' => '_self', 'module_id' => 22, 'order_id' => 0, 'access_id' => 27), array('area_id' => 59, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_LINKS_MODULE_DESCRIPTION', 'is_active' => 1, 'uri' => 'index.php?cmd=directory', 'target' => '_self', 'module_id' => 12, 'order_id' => 0, 'access_id' => 59), array('area_id' => 64, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_RECOMMEND', 'is_active' => 1, 'uri' => 'index.php?cmd=recommend', 'target' => '_self', 'module_id' => 27, 'order_id' => 0, 'access_id' => 64), array('area_id' => 82, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_LIVECAM', 'is_active' => 1, 'uri' => 'index.php?cmd=livecam', 'target' => '_self', 'module_id' => 30, 'order_id' => 0, 'access_id' => 82), array('area_id' => 89, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_MEMBERDIR', 'is_active' => 1, 'uri' => 'index.php?cmd=memberdir', 'target' => '_self', 'module_id' => 31, 'order_id' => 0, 'access_id' => 83), array('area_id' => 93, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_PODCAST', 'is_active' => 1, 'uri' => 'index.php?cmd=podcast', 'target' => '_self', 'module_id' => 35, 'order_id' => 0, 'access_id' => 87), array('area_id' => 98, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_MARKET_MODULE_DESCRIPTION', 'is_active' => 1, 'uri' => 'index.php?cmd=market', 'target' => '_self', 'module_id' => 33, 'order_id' => 0, 'access_id' => 98), array('area_id' => 106, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_FORUM', 'is_active' => 1, 'uri' => 'index.php?cmd=forum', 'target' => '_self', 'module_id' => 20, 'order_id' => 0, 'access_id' => 106), array('area_id' => 109, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_EGOVERNMENT', 'is_active' => 1, 'uri' => 'index.php?cmd=egov', 'target' => '_self', 'module_id' => 38, 'order_id' => 0, 'access_id' => 109), array('area_id' => 119, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_BLOG_MODULE', 'is_active' => 1, 'uri' => 'index.php?cmd=blog', 'target' => '_self', 'module_id' => 47, 'order_id' => 0, 'access_id' => 119), array('area_id' => 128, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_DATA_MODULE', 'is_active' => 1, 'uri' => 'index.php?cmd=data', 'target' => '_self', 'module_id' => 48, 'order_id' => 0, 'access_id' => 146), array('area_id' => 130, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_ECARD', 'is_active' => 1, 'uri' => 'index.php?cmd=ecard', 'target' => '_self', 'module_id' => 49, 'order_id' => 0, 'access_id' => 151), array('area_id' => 134, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_U2U_MODULE', 'is_active' => 1, 'uri' => 'index.php?cmd=u2u', 'target' => '_self', 'module_id' => 54, 'order_id' => 0, 'access_id' => 149), array('area_id' => 135, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_KNOWLEDGE', 'is_active' => 1, 'uri' => 'index.php?cmd=knowledge', 'target' => '_self', 'module_id' => 56, 'order_id' => 0, 'access_id' => 129), array('area_id' => 141, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_JOBS_MODULE', 'is_active' => 1, 'uri' => 'index.php?cmd=jobs', 'target' => '_self', 'module_id' => 57, 'order_id' => 0, 'access_id' => 148), array('area_id' => 153, 'parent_area_id' => 2, 'type' => 'navigation', 'scope' => 'global', 'area_name' => 'TXT_MEDIADIR_MODULE', 'is_active' => 1, 'uri' => 'index.php?cmd=mediadir', 'target' => '_self', 'module_id' => 60, 'order_id' => 0, 'access_id' => 153), array('area_id' => 163, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_SYSTEM_LOGS', 'is_active' => 1, 'uri' => 'index.php?cmd=log', 'target' => '_self', 'module_id' => 1, 'order_id' => 10, 'access_id' => 55), array('area_id' => 17, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_SYSTEM_SETTINGS', 'is_active' => 1, 'uri' => 'index.php?cmd=settings', 'target' => '_self', 'module_id' => 1, 'order_id' => 1, 'access_id' => 17), array('area_id' => 18, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_USER_ADMINISTRATION', 'is_active' => 1, 'uri' => 'index.php?cmd=access', 'target' => '_self', 'module_id' => 1, 'order_id' => 3, 'access_id' => 18), array('area_id' => 20, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_DATABASE_MANAGER', 'is_active' => 1, 'uri' => 'index.php?cmd=dbm', 'target' => '_self', 'module_id' => 1, 'order_id' => 8, 'access_id' => 20), array('area_id' => 21, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_DESIGN_MANAGEMENT', 'is_active' => 1, 'uri' => 'index.php?cmd=skins', 'target' => '_self', 'module_id' => 1, 'order_id' => 4, 'access_id' => 21), array('area_id' => 22, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_LANGUAGE_SETTINGS', 'is_active' => 1, 'uri' => 'index.php?cmd=language', 'target' => '_self', 'module_id' => 64, 'order_id' => 5, 'access_id' => 22), array('area_id' => 23, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_MODULE_MANAGER', 'is_active' => 1, 'uri' => 'index.php?cmd=modulemanager', 'target' => '_self', 'module_id' => 1, 'order_id' => 6, 'access_id' => 23), array('area_id' => 24, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_SERVER_INFO', 'is_active' => 1, 'uri' => 'index.php?cmd=server', 'target' => '_self', 'module_id' => 1, 'order_id' => 9, 'access_id' => 24), array('area_id' => 110, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_ALIAS_ADMINISTRATION', 'is_active' => 1, 'uri' => 'index.php?cmd=alias', 'target' => '_self', 'module_id' => 41, 'order_id' => 7, 'access_id' => 115), array('area_id' => 182, 'parent_area_id' => 3, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_LICENSE', 'is_active' => 1, 'uri' => 'index.php?cmd=license', 'target' => '_self', 'module_id' => 66, 'order_id' => 2, 'access_id' => 0), array('area_id' => 127, 'parent_area_id' => 5, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_NEW_PAGE_ON_FIRST_LEVEL', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 1, 'order_id' => 1, 'access_id' => 127), array('area_id' => 26, 'parent_area_id' => 6, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_DELETE_PAGES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 26), array('area_id' => 35, 'parent_area_id' => 6, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_EDIT_PAGES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 35), array('area_id' => 36, 'parent_area_id' => 6, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_ACCESS_CONTROL', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 36), array('area_id' => 53, 'parent_area_id' => 6, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_COPY_DELETE_SITES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 53), array('area_id' => 161, 'parent_area_id' => 6, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_MOVE_NODE', 'is_active' => 1, 'uri' => 'index.php?cmd=content', 'target' => '_self', 'module_id' => 1, 'order_id' => 8, 'access_id' => 160), array('area_id' => 38, 'parent_area_id' => 7, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_MODIFY_MEDIA_FILES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 38), array('area_id' => 39, 'parent_area_id' => 7, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_UPLOAD_MEDIA_FILES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 39), array('area_id' => 13, 'parent_area_id' => 8, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_SHOP', 'is_active' => 1, 'uri' => 'index.php?cmd=shop', 'target' => '_self', 'module_id' => 16, 'order_id' => 1, 'access_id' => 13), array('area_id' => 162, 'parent_area_id' => 8, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CHECKOUT_MODULE', 'is_active' => 1, 'uri' => 'index.php?cmd=checkout', 'target' => '_self', 'module_id' => 62, 'order_id' => 2, 'access_id' => 161), array('area_id' => 152, 'parent_area_id' => 10, 'type' => 'function', 'scope' => 'frontend', 'area_name' => 'TXT_SUBMIT_NEWS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 8, 'order_id' => 0, 'access_id' => 61), array('area_id' => 65, 'parent_area_id' => 12, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_GALLERY_MENU_OVERVIEW', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 3, 'order_id' => 1, 'access_id' => 65), array('area_id' => 66, 'parent_area_id' => 12, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_GALLERY_MENU_NEW_CATEGORY', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 3, 'order_id' => 2, 'access_id' => 66), array('area_id' => 67, 'parent_area_id' => 12, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_GALLERY_MENU_UPLOAD', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 3, 'order_id' => 3, 'access_id' => 67), array('area_id' => 68, 'parent_area_id' => 12, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_GALLERY_MENU_IMPORT', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 3, 'order_id' => 4, 'access_id' => 68), array('area_id' => 69, 'parent_area_id' => 12, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_GALLERY_MENU_VALIDATE', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 3, 'order_id' => 5, 'access_id' => 69), array('area_id' => 70, 'parent_area_id' => 12, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_GALLERY_MENU_SETTINGS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 3, 'order_id' => 6, 'access_id' => 70), array('area_id' => 7, 'parent_area_id' => 15, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_MEDIA_MANAGER', 'is_active' => 1, 'uri' => 'index.php?cmd=media&amp;archive=archive1', 'target' => '_self', 'module_id' => 1, 'order_id' => 2, 'access_id' => 7), array('area_id' => 32, 'parent_area_id' => 15, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_IMAGE_ADMINISTRATION', 'is_active' => 1, 'uri' => 'index.php?cmd=media&amp;archive=content', 'target' => '_self', 'module_id' => 1, 'order_id' => 1, 'access_id' => 32), array('area_id' => 132, 'parent_area_id' => 15, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_DOWNLOADS', 'is_active' => 1, 'uri' => 'index.php?cmd=downloads', 'target' => '_self', 'module_id' => 53, 'order_id' => 4, 'access_id' => 141), array('area_id' => 187, 'parent_area_id' => 15, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_FILESHARING_MODULE', 'is_active' => 1, 'uri' => 'index.php?cmd=media&amp;archive=filesharing', 'target' => '_self', 'module_id' => 68, 'order_id' => 3, 'access_id' => 8), array('area_id' => 144, 'parent_area_id' => 16, 'type' => 'function', 'scope' => 'frontend', 'area_name' => 'TXT_ACCESS_COMMUNITY_EVENTS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 21, 'order_id' => 0, 'access_id' => 145), array('area_id' => 31, 'parent_area_id' => 18, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_EDIT_USERINFOS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 31), array('area_id' => 40, 'parent_area_id' => 19, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_SETTINGS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 40), array('area_id' => 41, 'parent_area_id' => 20, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_DBM_MAINTENANCE_TITLE', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 41), array('area_id' => 46, 'parent_area_id' => 21, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_ACTIVATE_SKINS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 46), array('area_id' => 47, 'parent_area_id' => 21, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_EDIT_SKINS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 47), array('area_id' => 92, 'parent_area_id' => 21, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_THEME_IMPORT_EXPORT', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 102), array('area_id' => 48, 'parent_area_id' => 22, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_EDIT_LANGUAGE_SETTINGS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 48), array('area_id' => 49, 'parent_area_id' => 22, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_DELETE_LANGUAGES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 49), array('area_id' => 50, 'parent_area_id' => 22, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_LANGUAGE_SETTINGS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 50), array('area_id' => 51, 'parent_area_id' => 23, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_REGISTER_MODULES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 51), array('area_id' => 52, 'parent_area_id' => 23, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_INST_REMO_MODULES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 0, 'access_id' => 52), array('area_id' => 166, 'parent_area_id' => 28, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CORE_VISITOR_DETAILS', 'is_active' => 1, 'uri' => 'index.php?cmd=stats&amp;stat=visitors', 'target' => '_self', 'module_id' => 1, 'order_id' => 1, 'access_id' => 166), array('area_id' => 164, 'parent_area_id' => 28, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CORE_VISITORS_AND_PAGE_VIEWS', 'is_active' => 1, 'uri' => 'index.php?cmd=stats&amp;stat=requests', 'target' => '_self', 'module_id' => 1, 'order_id' => 2, 'access_id' => 164), array('area_id' => 167, 'parent_area_id' => 28, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CORE_REFERER', 'is_active' => 1, 'uri' => 'index.php?cmd=stats&amp;stat=referer', 'target' => '_self', 'module_id' => 1, 'order_id' => 3, 'access_id' => 167), array('area_id' => 168, 'parent_area_id' => 28, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CORE_SEARCH_ENGINES', 'is_active' => 1, 'uri' => 'index.php?cmd=stats&amp;stat=spiders', 'target' => '_self', 'module_id' => 1, 'order_id' => 4, 'access_id' => 168), array('area_id' => 169, 'parent_area_id' => 28, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CORE_SEARCH_TERMS', 'is_active' => 1, 'uri' => 'index.php?cmd=stats&amp;stat=search', 'target' => '_self', 'module_id' => 1, 'order_id' => 5, 'access_id' => 169), array('area_id' => 170, 'parent_area_id' => 28, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_SETTINGS', 'is_active' => 1, 'uri' => 'index.php?cmd=stats&amp;stat=settings', 'target' => '_self', 'module_id' => 1, 'order_id' => 6, 'access_id' => 170), array('area_id' => 172, 'parent_area_id' => 29, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CORE_LISTS', 'is_active' => 1, 'uri' => 'index.php?cmd=newsletter&amp;act=lists', 'target' => '_self', 'module_id' => 4, 'order_id' => 2, 'access_id' => 172), array('area_id' => 171, 'parent_area_id' => 29, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CORE_EMAIL_CAMPAIGNS', 'is_active' => 1, 'uri' => 'index.php?cmd=newsletter&amp;act=mails', 'target' => '_self', 'module_id' => 4, 'order_id' => 1, 'access_id' => 171), array('area_id' => 174, 'parent_area_id' => 29, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CORE_RECIPIENTS', 'is_active' => 1, 'uri' => 'index.php?cmd=newsletter&amp;act=users', 'target' => '_self', 'module_id' => 4, 'order_id' => 4, 'access_id' => 174), array('area_id' => 175, 'parent_area_id' => 29, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_CORE_NEWS', 'is_active' => 1, 'uri' => 'index.php?cmd=newsletter&amp;act=news', 'target' => '_self', 'module_id' => 4, 'order_id' => 5, 'access_id' => 175), array('area_id' => 176, 'parent_area_id' => 29, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_SETTINGS', 'is_active' => 1, 'uri' => 'index.php?cmd=newsletter&amp;act=dispatch', 'target' => '_self', 'module_id' => 4, 'order_id' => 6, 'access_id' => 176), array('area_id' => 145, 'parent_area_id' => 59, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_ADD_FILES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 12, 'order_id' => 0, 'access_id' => 96), array('area_id' => 146, 'parent_area_id' => 59, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_MANAGE_FILES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 12, 'order_id' => 1, 'access_id' => 94), array('area_id' => 147, 'parent_area_id' => 59, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_MANAGE_CONFIGURATION', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 12, 'order_id' => 2, 'access_id' => 92), array('area_id' => 148, 'parent_area_id' => 59, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_CATEGORY_AND_LEVEL_MANAGEMENT', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 12, 'order_id' => 3, 'access_id' => 97), array('area_id' => 77, 'parent_area_id' => 75, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_DELETED_RESTORE', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 1, 'access_id' => 77), array('area_id' => 78, 'parent_area_id' => 75, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_WORKFLOW_VALIDATE', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 0, 'order_id' => 1, 'access_id' => 78), array('area_id' => 91, 'parent_area_id' => 90, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_CONTACT_SETTINGS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 6, 'order_id' => 0, 'access_id' => 85), array('area_id' => 149, 'parent_area_id' => 98, 'type' => 'function', 'scope' => 'frontend', 'area_name' => 'TXT_ADD_ADVERTISEMENT', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 33, 'order_id' => 0, 'access_id' => 99), array('area_id' => 150, 'parent_area_id' => 98, 'type' => 'function', 'scope' => 'frontend', 'area_name' => 'TXT_MODIFY_ADVERTISEMENT', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 33, 'order_id' => 1, 'access_id' => 100), array('area_id' => 151, 'parent_area_id' => 98, 'type' => 'function', 'scope' => 'frontend', 'area_name' => 'TXT_DELETE_ADVERTISEMENT', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 33, 'order_id' => 2, 'access_id' => 101), array('area_id' => 107, 'parent_area_id' => 106, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_FORUM_MENU_CATEGORIES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 20, 'order_id' => 1, 'access_id' => 107), array('area_id' => 108, 'parent_area_id' => 106, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_FORUM_MENU_SETTINGS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 20, 'order_id' => 2, 'access_id' => 108), array('area_id' => 120, 'parent_area_id' => 119, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_BLOG_ENTRY_MANAGE_TITLE', 'is_active' => 1, 'uri' => 'index.php?cmd=blog&act=manageEntry', 'target' => '_self', 'module_id' => 47, 'order_id' => 1, 'access_id' => 120), array('area_id' => 121, 'parent_area_id' => 119, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_BLOG_ENTRY_ADD_TITLE', 'is_active' => 1, 'uri' => 'index.php?cmd=blog&act=addEntry', 'target' => '_self', 'module_id' => 47, 'order_id' => 2, 'access_id' => 121), array('area_id' => 122, 'parent_area_id' => 119, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_BLOG_CATEGORY_MANAGE_TITLE', 'is_active' => 1, 'uri' => 'index.php?cmd=blog&act=manageCategory', 'target' => '_self', 'module_id' => 47, 'order_id' => 3, 'access_id' => 122), array('area_id' => 123, 'parent_area_id' => 119, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_BLOG_CATEGORY_ADD_TITLE', 'is_active' => 1, 'uri' => 'index.php?cmd=blog&act=addCategory', 'target' => '_self', 'module_id' => 47, 'order_id' => 4, 'access_id' => 123), array('area_id' => 124, 'parent_area_id' => 119, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_BLOG_SETTINGS_TITLE', 'is_active' => 1, 'uri' => 'index.php?cmd=blog&act=settings', 'target' => '_self', 'module_id' => 47, 'order_id' => 6, 'access_id' => 124), array('area_id' => 125, 'parent_area_id' => 119, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_BLOG_NETWORKS_TITLE', 'is_active' => 1, 'uri' => 'index.php?cmd=blog&act=networks', 'target' => '_self', 'module_id' => 47, 'order_id' => 5, 'access_id' => 125), array('area_id' => 129, 'parent_area_id' => 128, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_DATA_ENTRY_MANAGE_TITLE', 'is_active' => 1, 'uri' => 'index.php?cmd=data&act=manageEntry', 'target' => '_self', 'module_id' => 48, 'order_id' => 1, 'access_id' => 147), array('area_id' => 133, 'parent_area_id' => 132, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_DOWNLOADS_ADMINISTER', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 53, 'order_id' => 1, 'access_id' => 142), array('area_id' => 136, 'parent_area_id' => 135, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_KNOWLEDGE_ACCESS_OVERVIEW', 'is_active' => 1, 'uri' => 'index.php?cmd=knowledge&section=articles', 'target' => '_self', 'module_id' => 56, 'order_id' => 1, 'access_id' => 130), array('area_id' => 137, 'parent_area_id' => 135, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_KNOWLEDGE_ACCESS_EDIT_ARTICLES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 56, 'order_id' => 2, 'access_id' => 131), array('area_id' => 138, 'parent_area_id' => 135, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_KNOWLEDGE_ACCESS_CATEGORIES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 56, 'order_id' => 3, 'access_id' => 132), array('area_id' => 139, 'parent_area_id' => 135, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_KNOWLEDGE_ACCESS_EDIT_CATEGORIES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 56, 'order_id' => 4, 'access_id' => 133), array('area_id' => 140, 'parent_area_id' => 135, 'type' => 'function', 'scope' => 'backend', 'area_name' => 'TXT_KNOWLEDGE_ACCESS_SETTINGS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 56, 'order_id' => 5, 'access_id' => 134), array('area_id' => 154, 'parent_area_id' => 153, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_MEDIADIR_ADD_ENTRY', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 60, 'order_id' => 0, 'access_id' => 154), array('area_id' => 155, 'parent_area_id' => 153, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_MEDIADIR_MODIFY_ENTRY', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 60, 'order_id' => 0, 'access_id' => 155), array('area_id' => 156, 'parent_area_id' => 153, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_MEDIADIR_MANAGE_LEVELS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 60, 'order_id' => 0, 'access_id' => 156), array('area_id' => 157, 'parent_area_id' => 153, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_MEDIADIR_MANAGE_CATEGORIES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 60, 'order_id' => 0, 'access_id' => 157), array('area_id' => 158, 'parent_area_id' => 153, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_MEDIADIR_INTERFACES', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 60, 'order_id' => 0, 'access_id' => 158), array('area_id' => 160, 'parent_area_id' => 153, 'type' => 'function', 'scope' => 'global', 'area_name' => 'TXT_MEDIADIR_SETTINGS', 'is_active' => 1, 'uri' => '', 'target' => '_self', 'module_id' => 60, 'order_id' => 0, 'access_id' => 159), array('area_id' => 185, 'parent_area_id' => 184, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_DASHBOARD', 'is_active' => 1, 'uri' => 'index.php', 'target' => '_self', 'module_id' => 1, 'order_id' => 1, 'access_id' => 0), array('area_id' => 186, 'parent_area_id' => 184, 'type' => 'navigation', 'scope' => 'backend', 'area_name' => 'TXT_FRONTEND', 'is_active' => 1, 'uri' => '../index.php', 'target' => '_blank', 'module_id' => 1, 'order_id' => 2, 'access_id' => 0));
    $objDatabase->Execute("TRUNCATE TABLE " . DBPREFIX . "backend_areas");
    // add backend areas
    foreach ($arrBackendAreas as $arrBackendArea) {
        $query = "INSERT INTO " . DBPREFIX . "backend_areas (`area_id`, `parent_area_id` , `type` , `scope`, `area_name` , `is_active` , `uri` , `target` , `module_id` , `order_id` , `access_id`\n\t\t\t) VALUES (\n\t\t\t" . $arrBackendArea['area_id'] . ", '" . $arrBackendArea['parent_area_id'] . "', '" . $arrBackendArea['type'] . "', '" . $arrBackendArea['scope'] . "', '" . $arrBackendArea['area_name'] . "', '" . $arrBackendArea['is_active'] . "', '" . $arrBackendArea['uri'] . "', '" . $arrBackendArea['target'] . "', '" . $arrBackendArea['module_id'] . "', '" . $arrBackendArea['order_id'] . "', '" . $arrBackendArea['access_id'] . "')";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    // add permission to stats settings if the user had permission to stats
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        try {
            $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 163 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 (170, " . intval($result->fields['group_id']) . ")");
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /***************************************************
     * BUGFIX:	Clean up duplicate usage of access ids *
     ***************************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.2')) {
        $arrAccessIds = array(116 => 145, 122 => 146, 123 => 147, 140 => 148, 141 => 149);
        $query = 'SELECT `group_id`, `access_id` FROM `' . DBPREFIX . 'access_group_static_ids` WHERE `access_id` IN (' . implode(',', array_keys($arrAccessIds)) . ')';
        $objResult = $objDatabase->Execute($query);
        if ($objResult) {
            while (!$objResult->EOF) {
                $query = 'INSERT IGNORE INTO `' . DBPREFIX . 'access_group_static_ids` (`access_id`, `group_id`) VALUES (' . $arrAccessIds[$objResult->fields['access_id']] . ', ' . $objResult->fields['group_id'] . ')';
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
                $objResult->MoveNext();
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    return true;
}
Example #6
0
function _u2uUpdate()
{
    global $objDatabase;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_u2u_address_list', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'user_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'buddies_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0')), array(), 'InnoDB');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_u2u_message_log', array('message_id' => array('type' => 'INT(11) UNSIGNED', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'message_text' => array('type' => 'TEXT', 'notnull' => true), 'message_title' => array('type' => 'TEXT', 'notnull' => true)), array(), 'InnoDB');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_u2u_sent_messages', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'userid' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'message_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'receiver_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'mesage_open_status' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'date_time' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00')), array(), 'InnoDB');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_u2u_settings', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(50)'), 'value' => array('type' => 'TEXT')), array(), 'InnoDB');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_u2u_settings', array('id' => array('type' => 'INT(11) UNSIGNED', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'name' => array('type' => 'VARCHAR(50)', 'notnull' => true), 'value' => array('type' => 'TEXT', 'notnull' => true)), array(), 'InnoDB');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_u2u_user_log', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'userid' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'user_sent_items' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'user_unread_items' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'user_status' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '1')), array(), 'InnoDB');
    } 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.2                       *
     *******************************************************/
    $arrSettings = array('max_posting_size' => '2000', 'max_posting_chars' => '2000', 'wysiwyg_editor' => '1', 'subject' => 'Eine neue Nachricht von [senderName]', 'from' => 'Contrexx U2U Nachrichtensystem', 'email_message' => 'Hallo <strong>[receiverName]</strong>,<br />\\r\\n<br />\\r\\n<strong>[senderName]</strong> hat Ihnen eine private Nachricht gesendet. Um die Nachricht zu lesen, folgen Sie bitte folgendem Link:<br />\\r\\n<br />\\r\\nhttp://[domainName]/index.php?section=u2u&amp;cmd=notification<br />\\r\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />\\r\\n<br />');
    foreach ($arrSettings as $name => $value) {
        $query = "SELECT 1 FROM `" . DBPREFIX . "module_u2u_settings` WHERE `name` = '" . $name . "'";
        $objResult = $objDatabase->SelectLimit($query, 1);
        if ($objResult) {
            if ($objResult->RecordCount() == 0) {
                $query = "INSERT INTO `" . DBPREFIX . "module_u2u_settings` (`name`, `value`) VALUES ('" . $name . "', '" . $value . "')";
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /********************************
     * EXTENSION:   Timezone        *
     * ADDED:       Contrexx v3.0.0 *
     ********************************/
    try {
        \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_u2u_sent_messages` CHANGE `date_time` `date_time` TIMESTAMP NOT NULL DEFAULT "0000-00-00 00:00:00"');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Example #7
0
function _knowledgeUpdate()
{
    global $objDatabase;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_knowledge_article_content', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'article' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'lang' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'question' => array('type' => 'TEXT', 'notnull' => true, 'default' => 0), 'answer' => array('type' => 'TEXT', 'notnull' => true, 'default' => 0)), array('module_knowledge_article_content_lang' => array('fields' => array('lang')), 'module_knowledge_article_content_article' => array('fields' => array('article'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_knowledge_articles', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'category' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 1), 'hits' => array('type' => 'INT', 'notnull' => true, 'default' => 0), 'votes' => array('type' => 'INT', 'notnull' => true, 'default' => 0), 'votevalue' => array('type' => 'INT', 'notnull' => true, 'default' => 0), 'sort' => array('type' => 'INT', 'notnull' => true, 'default' => 0), 'date_created' => array('type' => 'INT(14)', 'notnull' => true, 'default' => 0), 'date_updated' => array('type' => 'INT(14)', 'notnull' => true, 'default' => 0)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_knowledge_categories', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 1, 'unsigned' => true), 'parent' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'sort' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 1, 'unsigned' => true)), array('module_knowledge_categories_sort' => array('fields' => array('sort')), 'module_knowledge_categories_parent' => array('fields' => array('parent'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_knowledge_categories_content', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'category' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'lang' => array('type' => 'INT(11)', 'notnull' => true, 'default' => 1)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_knowledge_settings', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'value' => array('type' => 'TEXT', 'notnull' => true, 'default' => 0)), array('module_knowledge_settings_name' => array('fields' => array('name'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_knowledge_tags', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'lang' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 1, 'unsigned' => true)), array('module_knowledge_tags_name' => array('fields' => array('name'))));
        if (strpos(\Cx\Lib\UpdateUtil::sql('SHOW CREATE TABLE `' . DBPREFIX . 'module_knowledge_tags_articles`')->fields['Create Table'], 'UNIQUE KEY') === false) {
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_knowledge_tags_articles', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'article' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'tag' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true)), array('module_knowledge_tags_articles_tag' => array('fields' => array('tag')), 'module_knowledge_tags_articles_article' => array('fields' => array('article'))));
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $arrSettings = array(array('name' => 'max_subcategories', 'value' => '5'), array('name' => 'column_number', 'value' => '2'), array('name' => 'max_rating', 'value' => '8'), array('name' => 'best_rated_sidebar_template', 'value' => '<h2>Bestbewertete Artikel</h2>\\r\\n<div class="clearfix">\\r\\n<ul class="knowledge_sidebar">\\r\\n<!-- BEGIN article -->\\r\\n<li><a href="[[URL]]">[[ARTICLE]]</a></li>\\r\\n<!-- END article -->\\r\\n</ul>\\r\\n</div>'), array('name' => 'best_rated_sidebar_length', 'value' => '82'), array('name' => 'best_rated_sidebar_amount', 'value' => '5'), array('name' => 'tag_cloud_sidebar_template', 'value' => '[[CLOUD]] <br style="clear: both;" />'), array('name' => 'most_read_sidebar_template', 'value' => '<h2>Bestbewertete Artikel 2</h2>\\r\\n<div class="clearfix">\\r\\n<ul class="knowledge_sidebar">\\r\\n<!-- BEGIN article -->\\r\\n<li><a href="[[URL]]">[[ARTICLE]]</a></li>\\r\\n<!-- END article -->\\r\\n</ul>\\r\\n</div>'), array('name' => 'most_read_sidebar_length', 'value' => '79'), array('name' => 'most_read_sidebar_amount', 'value' => '5'), array('name' => 'best_rated_siderbar_template', 'value' => ''), array('name' => 'most_read_amount', 'value' => '5'), array('name' => 'best_rated_amount', 'value' => '5'));
    foreach ($arrSettings as $arrSetting) {
        $query = "SELECT 1 FROM `" . DBPREFIX . "module_knowledge_settings` WHERE `name` = '" . $arrSetting['name'] . "'";
        $objResult = $objDatabase->SelectLimit($query, 1);
        if ($objResult !== false) {
            if ($objResult->RecordCount() == 0) {
                $query = "INSERT INTO `" . DBPREFIX . "module_knowledge_settings` (`name`, `value`) VALUES ('" . $arrSetting['name'] . "', '" . $arrSetting['value'] . "')";
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /*******************************************
     * EXTENSION:    Duplicate entries clean up *
     * ADDED:        Contrexx v3.0.2            *
     *******************************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_knowledge_tags_articles', array('article' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'tag' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'article')), array('article' => array('fields' => array('article', 'tag'), 'type' => 'UNIQUE', 'force' => true)), 'MyISAM');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Example #8
0
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;
}
Example #9
0
/**
 * 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 _jobsUpdate()
{
    global $objDatabase;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_jobs', array('id' => array('type' => 'INT(6)', 'notnull' => true, 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'date' => array('type' => 'INT(14)', 'notnull' => false), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'author' => array('type' => 'VARCHAR(150)', 'notnull' => true, 'default' => ''), 'text' => array('type' => 'MEDIUMTEXT'), 'workloc' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'workload' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'work_start' => array('type' => 'INT(14)', 'notnull' => true, 'default' => 0), 'catid' => array('type' => 'INT(2)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'lang' => array('type' => 'INT(2)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'userid' => array('type' => 'INT(6)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'startdate' => array('type' => 'DATE', 'notnull' => true, 'default' => '0000-00-00'), 'enddate' => array('type' => 'DATE', 'notnull' => true, 'default' => '0000-00-00'), 'status' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => 1), 'changelog' => array('type' => 'INT(14)', 'notnull' => true, 'default' => 0)), array('newsindex' => array('fields' => array('title', 'text'), 'type' => 'fulltext')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_jobs_categories', array('catid' => array('type' => 'INT(2)', 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'name' => array('type' => 'VARCHAR(100)', 'default' => ''), 'lang' => array('type' => 'INT(2)', 'default' => 1, 'unsigned' => true), 'sort_style' => array('type' => "ENUM('alpha', 'date', 'date_alpha')", 'default' => 'alpha')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_jobs_location', array('id' => array('type' => 'INT(10)', 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'name' => array('type' => 'VARCHAR(100)', 'default' => '')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_jobs_rel_loc_jobs', array('job' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'location' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_jobs_settings', array('id' => array('type' => 'INT(10)', 'primary' => true, 'auto_increment' => true, 'unsigned' => true), 'name' => array('type' => 'VARCHAR(250)', 'default' => ''), 'value' => array('type' => 'TEXT', 'default' => '')));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $arrSettings = array(array('name' => 'footnote', 'value' => 'Hat Ihnen diese Bewerbung zugesagt? \\r\\nDann können Sie sich sogleich telefonisch, per E-mail oder Web Formular bewerben.'), array('name' => 'link', 'value' => 'Online für diese Stelle bewerben.'), array('name' => 'url', 'value' => 'index.php?section=contact&cmd=5&44=%URL%&43=%TITLE%'), array('name' => 'show_location_fe', 'value' => '1'));
    foreach ($arrSettings as $arrSetting) {
        $query = "SELECT 1 FROM `" . DBPREFIX . "module_jobs_settings` WHERE `name` = '" . $arrSetting['name'] . "'";
        $objResult = $objDatabase->SelectLimit($query, 1);
        if ($objResult !== false) {
            if ($objResult->RecordCount() == 0) {
                $query = "INSERT INTO `" . DBPREFIX . "module_jobs_settings` (`name`, `value`) VALUES ('" . $arrSetting['name'] . "', '" . $arrSetting['value'] . "')";
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /********************************
     * EXTENSION:   Timezone        *
     * ADDED:       Contrexx v3.0.0 *
     ********************************/
    try {
        \Cx\Lib\UpdateUtil::sql('
            ALTER TABLE `' . DBPREFIX . 'module_jobs`
            CHANGE `startdate` `startdate` TIMESTAMP NOT NULL DEFAULT "0000-00-00 00:00:00",
            CHANGE `enddate` `enddate` TIMESTAMP NOT NULL DEFAULT "0000-00-00 00:00:00"
        ');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Example #10
0
/**
 * 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;
}
Example #11
0
function _calendarUpdate()
{
    global $objDatabase;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'id'), 'catid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'active'), 'startdate' => array('type' => 'INT(14)', 'notnull' => false, 'after' => 'catid'), 'enddate' => array('type' => 'INT(14)', 'notnull' => false, 'after' => 'startdate'), 'priority' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '3', 'after' => 'enddate'), 'access' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'priority'), 'name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'access'), 'comment' => array('type' => 'text', 'after' => 'name'), 'placeName' => array('type' => 'VARCHAR(255)', 'after' => 'comment'), 'link' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => 'http://', 'after' => 'placeName'), 'pic' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'link'), 'attachment' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'pic'), 'placeStreet' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'attachment'), 'placeZip' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeStreet'), 'placeCity' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeZip'), 'placeLink' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeCity'), 'placeMap' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeLink'), 'organizerName' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeMap'), 'organizerStreet' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerName'), 'organizerZip' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerStreet'), 'organizerPlace' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerZip'), 'organizerMail' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerPlace'), 'organizerLink' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerMail'), 'key' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerLink'), 'num' => array('type' => 'INT(5)', 'notnull' => true, 'default' => '0', 'after' => 'key'), 'mailTitle' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'num'), 'mailContent' => array('type' => 'text', 'after' => 'mailTitle'), 'registration' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'mailContent'), 'groups' => array('type' => 'text', 'after' => 'registration'), 'all_groups' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'groups'), 'public' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'all_groups'), 'notification' => array('type' => 'INT(1)', 'after' => 'public'), 'notification_address' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'notification'), 'series_status' => array('type' => 'TINYINT(4)', 'after' => 'notification_address'), 'series_type' => array('type' => 'INT(11)', 'after' => 'series_status'), 'series_pattern_count' => array('type' => 'INT(11)', 'after' => 'series_type'), 'series_pattern_weekday' => array('type' => 'VARCHAR(7)', 'after' => 'series_pattern_count'), 'series_pattern_day' => array('type' => 'INT(11)', 'after' => 'series_pattern_weekday'), 'series_pattern_week' => array('type' => 'INT(11)', 'after' => 'series_pattern_day'), 'series_pattern_month' => array('type' => 'INT(11)', 'after' => 'series_pattern_week'), 'series_pattern_type' => array('type' => 'INT(11)', 'after' => 'series_pattern_month'), 'series_pattern_dourance_type' => array('type' => 'INT(11)', 'after' => 'series_pattern_type'), 'series_pattern_end' => array('type' => 'INT(11)', 'after' => 'series_pattern_dourance_type'), 'series_pattern_begin' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_end'), 'series_pattern_exceptions' => array('type' => 'longtext', 'after' => 'series_pattern_begin')), array('name' => array('fields' => array('name', 'comment', 'placeName'), 'type' => 'FULLTEXT')));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    //2.1.1
    $query = "SELECT status FROM " . DBPREFIX . "modules WHERE id='21'";
    $objResultCheck = $objDatabase->SelectLimit($query, 1);
    if ($objResultCheck !== false) {
        if ($objResultCheck->fields['status'] == 'y') {
            $calendarStatus = true;
        } else {
            $calendarStatus = false;
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    if ($calendarStatus) {
        $arrContentSites = array();
        $arrContentSites[0]['module'] = 'calendar';
        $arrContentSites[0]['cmd'] = '';
        $arrContentSites[1]['module'] = 'calendar';
        $arrContentSites[1]['cmd'] = 'eventlist';
        $arrContentSites[2]['module'] = 'calendar';
        $arrContentSites[2]['cmd'] = 'boxes';
        //insert new link placeholder in content, if module is active
        foreach ($arrContentSites as $key => $siteArray) {
            $module = $siteArray['module'];
            $cmd = $siteArray['cmd'];
            try {
                \Cx\Lib\UpdateUtil::migrateContentPage($module, $cmd, '<a href="index.php?section=calendar&amp;cmd=event&amp;id={CALENDAR_ID}">{CALENDAR_TITLE}</a>', '{CALENDAR_DETAIL_LINK}', '3.0.0');
            } catch (\Cx\Lib\UpdateException $e) {
                return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
            }
        }
        try {
            \Cx\Lib\UpdateUtil::migrateContentPage('calendar', 'sign', '<input type="hidden" name="id" value="{CALENDAR_NOTE_ID}" />', '<input type="hidden" name="id" value="{CALENDAR_NOTE_ID}" /><input type="hidden" name="date" value="{CALENDAR_NOTE_DATE}" />', '3.0.0');
            \Cx\Lib\UpdateUtil::migrateContentPage('calendar', 'sign', '<a href="index.php?section=calendar&amp;id={CALENDAR_NOTE_ID}">{TXT_CALENDAR_BACK}</a>', '{CALENDAR_LINK_BACK}', '3.0.0');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    try {
        // delete obsolete table  contrexx_module_calendar_access
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_calendar_access');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_form_data', array('reg_id' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '0'), 'field_id' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '0'), 'data' => array('type' => 'TEXT', 'notnull' => true)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_form_fields', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'note_id' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '0'), 'name' => array('type' => 'TEXT'), 'type' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0'), 'required' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0'), 'order' => array('type' => 'INT(3)', 'notnull' => true, 'default' => '0'), 'key' => array('type' => 'INT(7)', 'notnull' => true, 'default' => '0')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_registrations', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'note_id' => array('type' => 'INT(7)', 'notnull' => true, 'default' => '0'), 'note_date' => array('type' => 'INT(11)', 'notnull' => true, 'after' => 'note_id'), 'time' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'host' => array('type' => 'VARCHAR(255)'), 'ip_address' => array('type' => 'VARCHAR(15)'), 'type' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0')));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    global $objUpdate;
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        $CalendarUpdate31 = new CalendarUpdate31();
        $calendarUpdateFeedback = $CalendarUpdate31->run();
        if ($calendarUpdateFeedback !== true) {
            return $calendarUpdateFeedback;
        }
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.2.0')) {
        try {
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_event', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'startdate' => array('type' => 'INT(14)', 'notnull' => false, 'after' => 'type'), 'enddate' => array('type' => 'INT(14)', 'notnull' => false, 'after' => 'startdate'), 'startdate_timestamp' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'enddate'), 'enddate_timestamp' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'startdate_timestamp'), 'use_custom_date_display' => array('type' => 'TINYINT(1)', 'after' => 'enddate_timestamp'), 'showStartDateList' => array('type' => 'INT(1)', 'after' => 'use_custom_date_display'), 'showEndDateList' => array('type' => 'INT(1)', 'after' => 'showStartDateList'), 'showStartTimeList' => array('type' => 'INT(1)', 'after' => 'showEndDateList'), 'showEndTimeList' => array('type' => 'INT(1)', 'after' => 'showStartTimeList'), 'showTimeTypeList' => array('type' => 'INT(1)', 'after' => 'showEndTimeList'), 'showStartDateDetail' => array('type' => 'INT(1)', 'after' => 'showTimeTypeList'), 'showEndDateDetail' => array('type' => 'INT(1)', 'after' => 'showStartDateDetail'), 'showStartTimeDetail' => array('type' => 'INT(1)', 'after' => 'showEndDateDetail'), 'showEndTimeDetail' => array('type' => 'INT(1)', 'after' => 'showStartTimeDetail'), 'showTimeTypeDetail' => array('type' => 'INT(1)', 'after' => 'showEndTimeDetail'), 'google' => array('type' => 'INT(11)', 'after' => 'showTimeTypeDetail'), 'access' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'google'), 'priority' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '3', 'after' => 'access'), 'price' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'priority'), 'link' => array('type' => 'VARCHAR(255)', 'after' => 'price'), 'pic' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'link'), 'attach' => array('type' => 'VARCHAR(255)', 'after' => 'pic'), 'place_mediadir_id' => array('type' => 'INT(11)', 'after' => 'attach'), 'catid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'place_mediadir_id'), 'show_in' => array('type' => 'VARCHAR(255)', 'after' => 'catid'), 'invited_groups' => array('type' => 'VARCHAR(45)', 'notnull' => false, 'after' => 'show_in'), 'invited_mails' => array('type' => 'mediumtext', 'notnull' => false, 'after' => 'invited_groups'), 'invitation_sent' => array('type' => 'INT(1)', 'after' => 'invited_mails'), 'invitation_email_template' => array('type' => 'VARCHAR(255)', 'after' => 'invitation_sent'), 'registration' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'invitation_email_template'), 'registration_form' => array('type' => 'INT(11)', 'after' => 'registration'), 'registration_num' => array('type' => 'VARCHAR(45)', 'notnull' => false, 'after' => 'registration_form'), 'registration_notification' => array('type' => 'VARCHAR(1024)', 'notnull' => false, 'after' => 'registration_num'), 'email_template' => array('type' => 'VARCHAR(255)', 'after' => 'registration_notification'), 'ticket_sales' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'email_template'), 'num_seating' => array('type' => 'text', 'after' => 'ticket_sales'), 'series_status' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '0', 'after' => 'num_seating'), 'series_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_status'), 'series_pattern_count' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_type'), 'series_pattern_weekday' => array('type' => 'VARCHAR(7)', 'after' => 'series_pattern_count'), 'series_pattern_day' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_weekday'), 'series_pattern_week' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_day'), 'series_pattern_month' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_week'), 'series_pattern_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_month'), 'series_pattern_dourance_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_type'), 'series_pattern_end' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_dourance_type'), 'series_pattern_end_date' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'series_pattern_end'), 'series_pattern_begin' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_end_date'), 'series_pattern_exceptions' => array('type' => 'longtext', 'after' => 'series_pattern_begin'), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'series_pattern_exceptions'), 'confirmed' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'status'), 'author' => array('type' => 'VARCHAR(255)', 'after' => 'confirmed'), 'all_day' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'author'), 'location_type' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'all_day'), 'place' => array('type' => 'VARCHAR(255)', 'after' => 'location_type'), 'place_id' => array('type' => 'INT(11)', 'after' => 'place'), 'place_street' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_id'), 'place_zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'after' => 'place_street'), 'place_city' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_zip'), 'place_country' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_city'), 'place_link' => array('type' => 'VARCHAR(255)', 'after' => 'place_country'), 'place_map' => array('type' => 'VARCHAR(255)', 'after' => 'place_link'), 'host_type' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'place_map'), 'org_name' => array('type' => 'VARCHAR(255)', 'after' => 'host_type'), 'org_street' => array('type' => 'VARCHAR(255)', 'after' => 'org_name'), 'org_zip' => array('type' => 'VARCHAR(10)', 'after' => 'org_street'), 'org_city' => array('type' => 'VARCHAR(255)', 'after' => 'org_zip'), 'org_country' => array('type' => 'VARCHAR(255)', 'after' => 'org_city'), 'org_link' => array('type' => 'VARCHAR(255)', 'after' => 'org_country'), 'org_email' => array('type' => 'VARCHAR(255)', 'after' => 'org_link'), 'host_mediadir_id' => array('type' => 'INT(11)', 'after' => 'org_email')), array('fk_contrexx_module_calendar_notes_contrexx_module_calendar_ca1' => array('fields' => array('catid'))));
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        try {
            \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_calendar_event` SET `startdate_timestamp` = FROM_UNIXTIME(`startdate`), `enddate_timestamp` = FROM_UNIXTIME(`enddate`)');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        try {
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_event', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'startdate' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'type'), 'enddate' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'startdate'), 'startdate_timestamp' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'enddate'), 'enddate_timestamp' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'startdate_timestamp'), 'use_custom_date_display' => array('type' => 'TINYINT(1)', 'after' => 'enddate_timestamp'), 'showStartDateList' => array('type' => 'INT(1)', 'after' => 'use_custom_date_display'), 'showEndDateList' => array('type' => 'INT(1)', 'after' => 'showStartDateList'), 'showStartTimeList' => array('type' => 'INT(1)', 'after' => 'showEndDateList'), 'showEndTimeList' => array('type' => 'INT(1)', 'after' => 'showStartTimeList'), 'showTimeTypeList' => array('type' => 'INT(1)', 'after' => 'showEndTimeList'), 'showStartDateDetail' => array('type' => 'INT(1)', 'after' => 'showTimeTypeList'), 'showEndDateDetail' => array('type' => 'INT(1)', 'after' => 'showStartDateDetail'), 'showStartTimeDetail' => array('type' => 'INT(1)', 'after' => 'showEndDateDetail'), 'showEndTimeDetail' => array('type' => 'INT(1)', 'after' => 'showStartTimeDetail'), 'showTimeTypeDetail' => array('type' => 'INT(1)', 'after' => 'showEndTimeDetail'), 'google' => array('type' => 'INT(11)', 'after' => 'showTimeTypeDetail'), 'access' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'google'), 'priority' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '3', 'after' => 'access'), 'price' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'priority'), 'link' => array('type' => 'VARCHAR(255)', 'after' => 'price'), 'pic' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'link'), 'attach' => array('type' => 'VARCHAR(255)', 'after' => 'pic'), 'place_mediadir_id' => array('type' => 'INT(11)', 'after' => 'attach'), 'catid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'place_mediadir_id'), 'show_in' => array('type' => 'VARCHAR(255)', 'after' => 'catid'), 'invited_groups' => array('type' => 'VARCHAR(45)', 'notnull' => false, 'after' => 'show_in'), 'invited_mails' => array('type' => 'mediumtext', 'notnull' => false, 'after' => 'invited_groups'), 'invitation_sent' => array('type' => 'INT(1)', 'after' => 'invited_mails'), 'invitation_email_template' => array('type' => 'VARCHAR(255)', 'after' => 'invitation_sent'), 'registration' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'invitation_email_template'), 'registration_form' => array('type' => 'INT(11)', 'after' => 'registration'), 'registration_num' => array('type' => 'VARCHAR(45)', 'notnull' => false, 'after' => 'registration_form'), 'registration_notification' => array('type' => 'VARCHAR(1024)', 'notnull' => false, 'after' => 'registration_num'), 'email_template' => array('type' => 'VARCHAR(255)', 'after' => 'registration_notification'), 'ticket_sales' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'email_template'), 'num_seating' => array('type' => 'text', 'after' => 'ticket_sales'), 'series_status' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '0', 'after' => 'num_seating'), 'series_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_status'), 'series_pattern_count' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_type'), 'series_pattern_weekday' => array('type' => 'VARCHAR(7)', 'after' => 'series_pattern_count'), 'series_pattern_day' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_weekday'), 'series_pattern_week' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_day'), 'series_pattern_month' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_week'), 'series_pattern_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_month'), 'series_pattern_dourance_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_type'), 'series_pattern_end' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_dourance_type'), 'series_pattern_end_date' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'series_pattern_end'), 'series_pattern_begin' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_end_date'), 'series_pattern_exceptions' => array('type' => 'longtext', 'after' => 'series_pattern_begin'), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'series_pattern_exceptions'), 'confirmed' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'status'), 'author' => array('type' => 'VARCHAR(255)', 'after' => 'confirmed'), 'all_day' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'author'), 'location_type' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'all_day'), 'place' => array('type' => 'VARCHAR(255)', 'after' => 'location_type'), 'place_id' => array('type' => 'INT(11)', 'after' => 'place'), 'place_street' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_id'), 'place_zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'after' => 'place_street'), 'place_city' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_zip'), 'place_country' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_city'), 'place_link' => array('type' => 'VARCHAR(255)', 'after' => 'place_country'), 'place_map' => array('type' => 'VARCHAR(255)', 'after' => 'place_link'), 'host_type' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'place_map'), 'org_name' => array('type' => 'VARCHAR(255)', 'after' => 'host_type'), 'org_street' => array('type' => 'VARCHAR(255)', 'after' => 'org_name'), 'org_zip' => array('type' => 'VARCHAR(10)', 'after' => 'org_street'), 'org_city' => array('type' => 'VARCHAR(255)', 'after' => 'org_zip'), 'org_country' => array('type' => 'VARCHAR(255)', 'after' => 'org_city'), 'org_link' => array('type' => 'VARCHAR(255)', 'after' => 'org_country'), 'org_email' => array('type' => 'VARCHAR(255)', 'after' => 'org_link'), 'host_mediadir_id' => array('type' => 'INT(11)', 'after' => 'org_email')), array('fk_contrexx_module_calendar_notes_contrexx_module_calendar_ca1' => array('fields' => array('catid'))));
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        try {
            \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_calendar_event` SET `startdate` = `startdate_timestamp`, `enddate` = `enddate_timestamp`');
            if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_calendar_event', 'startdate_timestamp')) {
                \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_calendar_event` DROP COLUMN `startdate_timestamp`');
            }
            if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_calendar_event', 'enddate_timestamp')) {
                \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_calendar_event` DROP COLUMN `enddate_timestamp`');
            }
            \Cx\LIb\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_calendar_event` SET `series_pattern_end_date` = FROM_UNIXTIME(`series_pattern_end`)');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    // update calendar data to version 3.2.0
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.2.0')) {
        $languages = FWLanguage::getLanguageArray();
        try {
            $result = \Cx\Lib\UpdateUtil::sql('SELECT `id`, `invitation_email_template`, `email_template` FROM `' . DBPREFIX . 'module_calendar_event`');
            if ($result && $result->RecordCount() > 0) {
                while (!$result->EOF) {
                    // if the event has been already migrated, continue
                    if (intval($result->fields['invitation_email_template']) != $result->fields['invitation_email_template']) {
                        $result->MoveNext();
                        continue;
                    }
                    $invitationEmailTemplate = array();
                    $emailTemplate = array();
                    foreach ($languages as $langId => $langData) {
                        $invitationEmailTemplate[$langId] = $result->fields['invitation_email_template'];
                        $emailTemplate[$langId] = $result->fields['email_template'];
                    }
                    $invitationEmailTemplate = json_encode($invitationEmailTemplate);
                    $emailTemplate = json_encode($emailTemplate);
                    \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_calendar_event` SET
                                            `invitation_email_template`=\'' . contrexx_raw2db($invitationEmailTemplate) . '\',
                                            `email_template`=\'' . contrexx_raw2db($emailTemplate) . '\' WHERE `id`=' . intval($result->fields['id']));
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
Example #12
0
function _blogUpdate()
{
    global $objDatabase, $_ARRAYLANG, $_CORELANG, $objUpdate, $_CONFIG;
    /*
     * Check for missing setting "blog_comments_editor" in database. In the update-package for 1.2 this value somehow
     * got lost.
     */
    $query = '	SELECT 	name
				FROM	`' . DBPREFIX . 'module_blog_settings`
				WHERE	name="blog_comments_editor"
				LIMIT	1';
    $objResult = $objDatabase->Execute($query);
    if ($objResult !== false) {
        if ($objResult->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_blog_settings` ( `name` , `value` ) VALUES ('blog_comments_editor', 'wysiwyg')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_blog_categories', array('category_id' => array('type' => 'INT(4)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'is_active' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '1'), 'name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_blog_comments', array('comment_id' => array('type' => 'INT(7)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'message_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'is_active' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '1'), 'time_created' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'ip_address' => array('type' => 'VARCHAR(15)', 'notnull' => true, 'default' => '0.0.0.0'), 'user_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'user_name' => array('type' => 'VARCHAR(50)', 'notnull' => false), 'user_mail' => array('type' => 'VARCHAR(250)', 'notnull' => false), 'user_www' => array('type' => 'VARCHAR(255)', 'notnull' => false), 'subject' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'comment' => array('type' => 'TEXT')), array('message_id' => array('fields' => array('message_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_blog_message_to_category', array('message_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'category_id' => array('type' => 'INT(4)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true)), array('category_id' => array('fields' => array('category_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_blog_messages', array('message_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'user_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'time_created' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'time_edited' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'hits' => array('type' => 'INT(7)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_blog_networks_lang', array('network_id' => array('type' => 'INT(8)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_blog_votes', array('vote_id' => array('type' => 'INT(8)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'message_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'time_voted' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'ip_address' => array('type' => 'VARCHAR(15)', 'notnull' => true, 'default' => '0.0.0.0'), 'vote' => array('type' => 'ENUM(\'1\',\'2\',\'3\',\'4\',\'5\',\'6\',\'7\',\'8\',\'9\',\'10\')', 'notnull' => true, 'default' => '1')), array('message_id' => array('fields' => array('message_id'))));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        //update to 2.2.3 in this block
        if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.2.3')) {
            //we've hidden the wysiwyg - let's default to textarea
            \Cx\Lib\UpdateUtil::sql('UPDATE ' . DBPREFIX . 'module_blog_settings SET value="textarea" WHERE name="blog_comments_editor"');
            //comments: convert escaped db entries to their unescaped equivalents
            $rs = \Cx\Lib\UpdateUtil::sql('SELECT comment_id, comment FROM  ' . DBPREFIX . 'module_blog_comments');
            while (!$rs->EOF) {
                $content = $rs->fields['comment'];
                $id = $rs->fields['comment_id'];
                $content = contrexx_raw2db(html_entity_decode($content, ENT_QUOTES, CONTREXX_CHARSET));
                \Cx\Lib\UpdateUtil::sql('UPDATE ' . DBPREFIX . 'module_blog_comments SET comment="' . $content . '" WHERE comment_id=' . $id);
                $rs->MoveNext();
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        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;
            }
            // replace placeholder {TXT_COMMENT_ADD_SPAM} with {TXT_COMMENT_CAPTCHA}
            $content = str_replace('{TXT_COMMENT_ADD_SPAM}', '{TXT_COMMENT_CAPTCHA}', $content);
            // replace <img src="[[BLOG_DETAILS_COMMENT_ADD_SPAM_URL]]" alt="[[BLOG_DETAILS_COMMENT_ADD_SPAM_ALT]]" title="[[BLOG_DETAILS_COMMENT_ADD_SPAM_ALT]]" /> with {COMMENT_CAPTCHA_CODE}
            $content = preg_replace('/<img[^>]+\\{BLOG_DETAILS_COMMENT_ADD_SPAM_URL\\}[^>]+>/ms', '{COMMENT_CAPTCHA_CODE}', $content);
            // remove <input type="text" name="frmAddComment_Captcha" />
            $content = preg_replace('/<input[^>]+name\\s*=\\s*[\'"]frmAddComment_Captcha[^>]+>/ms', '', $content);
            // remove <input type="hidden" name="frmAddComment_Offset" value="[[BLOG_DETAILS_COMMENT_ADD_SPAM_OFFSET]]" />
            $content = preg_replace('/<(div|p)[^>]*>\\s*<input[^>]+name\\s*=\\s*[\'"]frmAddComment_Offset[^>]+>\\s*<\\/(div|p)>/ms', '', $content);
            // add missing comment_captcha template block
            if (!preg_match('/<!--\\s+BEGIN\\s+comment_captcha\\s+-->.*<!--\\s+END\\s+comment_captcha\\s+-->/ms', $content)) {
                $content = preg_replace('/(.*)(<(div|p)[^{]*?>.*?\\{TXT_COMMENT_CAPTCHA\\}.*?\\{COMMENT_CAPTCHA_CODE\\}.*?<\\/\\3>)/ms', '$1<!-- BEGIN comment_captcha -->$2<!-- END comment_captcha -->', $content, -1, $count);
                if (!$count) {
                    $content = preg_replace('/(.*)(<(div|p)[^{]*?>.*?\\{COMMENT_CAPTCHA_CODE\\}.*?<\\/\\3>)/ms', '$1<!-- BEGIN comment_captcha -->$2<!-- END comment_captcha -->', $content, -1, $count);
                }
            }
            return $content;
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'blog', 'cmd' => 'details'), $search, $callback, array('content'), '3.0.1');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /**
     * Everything went fine. Return without any errors.
     */
    return true;
}
Example #13
0
/**
 * 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;
}
Example #14
0
function _updateModuleRepository()
{
    global $_CORELANG, $objUpdate, $objDatabase;
    $count = 0;
    $dh = opendir(dirname(__FILE__) . '/components/core');
    if ($dh) {
        $query = "TRUNCATE TABLE " . DBPREFIX . "module_repository";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
        try {
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_repository', array('id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true), 'moduleid' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'id'), 'content' => array('type' => 'mediumtext', 'after' => 'moduleid'), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'content'), 'cmd' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'title'), 'expertmode' => array('type' => 'SET(\'y\',\'n\')', 'notnull' => true, 'default' => 'n', 'after' => 'cmd'), 'parid' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'expertmode'), 'displaystatus' => array('type' => 'SET(\'on\',\'off\')', 'notnull' => true, 'default' => 'on', 'after' => 'parid'), 'username' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'displaystatus'), 'displayorder' => array('type' => 'SMALLINT(6)', 'notnull' => true, 'default' => '100', 'after' => 'username')), array('contentid' => array('fields' => array('id'), 'type' => 'UNIQUE'), 'fulltextindex' => array('fields' => array('title', 'content'), 'type' => 'FULLTEXT')));
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        while (($file = readdir($dh)) !== false) {
            if (preg_match('#^repository_([0-9]+)\\.php$#', $file, $arrFunction)) {
                if (!in_array($file, ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
                    if (function_exists('memory_get_usage')) {
                        if (!checkMemoryLimit()) {
                            return false;
                        }
                    } else {
                        $count++;
                    }
                    if (!(include_once dirname(__FILE__) . '/components/core/' . $file)) {
                        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/components/core/' . $file));
                        return false;
                    }
                    $function = '_updateModuleRepository_' . $arrFunction[1];
                    if (function_exists($function)) {
                        DBG::msg("---------------------- update: calling {$function}() ---------");
                        $result = $function();
                        if ($result === false) {
                            DBG::msg("---------------------- update: calling {$function}() failed ---------");
                            if (empty($objUpdate->arrStatusMsg['title'])) {
                                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $file), 'title');
                            }
                            return false;
                        }
                    } else {
                        DBG::msg("---------------------- update: calling {$function}() failed, function does not exist ---------");
                        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UPDATE_COMPONENT_CORRUPT'], $_CORELANG['TXT_UPDATE_MODULE_REPOSITORY'], $arrFunction[1]));
                        return false;
                    }
                    $_SESSION['contrexx_update']['update']['done'][] = $file;
                    if ($count == 10) {
                        setUpdateMsg($_CORELANG['TXT_UPDATE_PROCESS_HALTED'], 'title');
                        setUpdateMsg($_CORELANG['TXT_UPDATE_PROCESS_HALTED_RAM_MSG'] . '<br /><br />', 'msg');
                        setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
                        return false;
                    }
                }
            }
        }
    } else {
        setUpdateMsg($_CORELANG['TXT_UPDATE_UNABLE_LOAD_REPOSITORY_PARTS']);
        return false;
    }
    closedir($dh);
    return true;
}
Example #15
0
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;
}
Example #16
0
 public static function DefaultActionHandler($e)
 {
     if ($e instanceof Update_DatabaseException) {
         return _databaseError($e->sql, $e->getMessage());
     }
     setUpdateMsg($e->getMessage());
     return false;
 }
Example #17
0
/**
 * 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 _coreUpdate()
{
    global $objUpdate, $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG;
    $query = "SELECT `id` FROM `" . DBPREFIX . "languages` WHERE `charset` != 'UTF-8'";
    $objResult = $objDatabase->Execute($query);
    if ($objResult !== false) {
        while (!$objResult->EOF) {
            $query = "UPDATE `" . DBPREFIX . "languages` SET `charset` = 'UTF-8' WHERE `id`=" . $objResult->fields['id'];
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            $objResult->MoveNext();
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $query = "SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE `access_id` = '5' GROUP BY `group_id`";
    $objGroup = $objDatabase->Execute($query);
    if ($objGroup !== false) {
        while (!$objGroup->EOF) {
            $query = "INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`) VALUES ('127', '" . $objGroup->fields['group_id'] . "')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            $objGroup->MoveNext();
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /*if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) {
            $query = "SELECT `catid` FROM `".DBPREFIX."content_navigation`";
            $objContentNavigation = $objDatabase->Execute($query);
            if ($objContentNavigation !== false) {
                $arrContentSiteIds = array();
                while (!$objContentNavigation->EOF) {
                    array_push($arrContentSiteIds, $objContentNavigation->fields['catid']);
                    $objContentNavigation->MoveNext();
                }
    
                $query = "DELETE FROM `".DBPREFIX."content` WHERE `id` != ".implode(' AND `id` != ', $arrContentSiteIds);
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
    
            try {
                \Cx\Lib\UpdateUtil::table(
                    DBPREFIX.'content_navigation',
                    array(
                        'catid'                  => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true),
                        'is_validated'           => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'),
                        'parcat'                 => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0'),
                        'catname'                => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''),
                        'target'                 => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => ''),
                        'displayorder'           => array('type' => 'SMALLINT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '1000'),
                        'displaystatus'          => array('type' => 'SET(\'on\',\'off\')', 'notnull' => true, 'default' => 'on'),
                        'activestatus'           => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'),
                        'cachingstatus'          => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'),
                        'username'               => array('type' => 'VARCHAR(40)', 'notnull' => true, 'default' => ''),
                        'changelog'              => array('type' => 'INT(14)', 'notnull' => false),
                        'cmd'                    => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''),
                        'lang'                   => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1'),
                        'module'                 => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'),
                        'startdate'              => array('type' => 'DATE', 'notnull' => true, 'default' => '0000-00-00'),
                        'enddate'                => array('type' => 'DATE', 'notnull' => true, 'default' => '0000-00-00'),
                        'protected'              => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '0'),
                        'frontend_access_id'     => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'),
                        'backend_access_id'      => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'),
                        'themes_id'              => array('type' => 'INT(4)', 'notnull' => true, 'default' => '0'),
                        'css_name'               => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''),
                        'custom_content'         => array('type' => 'VARCHAR(64)', 'after' => 'css_name', 'default' => '')
                    ),
                    array(
                        'parcat'                 => array('fields' => array('parcat')),
                        'module'                 => array('fields' => array('module')),
                        'catname'                => array('fields' => array('catname'))
                    )
                );
    
                \Cx\Lib\UpdateUtil::table(
                    DBPREFIX.'content_navigation_history',
                    array(
                        'id'                     => array('type' => 'INT(7)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true),
                        'is_active'              => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'),
                        'catid'                  => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0'),
                        'parcat'                 => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0'),
                        'catname'                => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''),
                        'target'                 => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => ''),
                        'displayorder'           => array('type' => 'SMALLINT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '1000'),
                        'displaystatus'          => array('type' => 'SET(\'ON\',\'OFF\')', 'notnull' => true, 'default' => 'on'),
                        'activestatus'           => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'),
                        'cachingstatus'          => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'),
                        'username'               => array('type' => 'VARCHAR(40)', 'notnull' => true, 'default' => ''),
                        'changelog'              => array('type' => 'INT(14)', 'notnull' => false),
                        'cmd'                    => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''),
                        'lang'                   => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1'),
                        'module'                 => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'),
                        'startdate'              => array('type' => 'DATE', 'notnull' => true, 'default' => '0000-00-00'),
                        'enddate'                => array('type' => 'DATE', 'notnull' => true, 'default' => '0000-00-00'),
                        'protected'              => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '0'),
                        'frontend_access_id'     => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'),
                        'backend_access_id'      => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'),
                        'themes_id'              => array('type' => 'INT(4)', 'notnull' => true, 'default' => '0'),
                        'css_name'               => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''),
                        'custom_content'         => array('type' => 'VARCHAR(64)', 'after' => 'css_name', 'default' => '')
                    ),
                    array(
                        'catid'                  => array('fields' => array('catid'))
                    )
                );
            } catch (\Cx\Lib\UpdateException $e) {
                return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
            }
        }*/
    // migrate modules table to new scheme
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'modules', array('id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => false), 'name' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'distributor' => array('type' => 'CHAR(50)', 'after' => 'name'), 'description_variable' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'after' => 'distributor'), 'status' => array('type' => 'SET(\'y\',\'n\')', 'notnull' => true, 'default' => 'n', 'after' => 'description_variable'), 'is_required' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'status'), 'is_core' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '0', 'after' => 'is_required'), 'is_active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'is_core'), 'is_licensed' => array('type' => 'TINYINT(1)', 'after' => 'is_active')), array('id' => array('fields' => array('id'), 'type' => 'UNIQUE')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'log', array('id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'userid' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => false), 'datetime' => array('type' => 'datetime', 'notnull' => false, 'default' => '0000-00-00 00:00:00'), 'useragent' => array('type' => 'VARCHAR(250)', 'notnull' => false, 'default_expr' => 'NULL'), 'userlanguage' => array('type' => 'VARCHAR(250)', 'notnull' => false, 'default_expr' => 'NULL'), 'remote_addr' => array('type' => 'VARCHAR(250)', 'notnull' => false, 'default_expr' => 'NULL'), 'remote_host' => array('type' => 'VARCHAR(250)', 'notnull' => false, 'default_expr' => 'NULL'), 'http_via' => array('type' => 'VARCHAR(250)'), 'http_client_ip' => array('type' => 'VARCHAR(250)'), 'http_x_forwarded_for' => array('type' => 'VARCHAR(250)'), 'referer' => array('type' => 'VARCHAR(250)')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /**********************************************
     *                                            *
     * MIGRATE BACKEND_AREAS TO NEW ACCESS SYSTEM *
     * BUGFIX: Add UNIQUE key on access_id        *
     *                                            *
     *********************************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'backend_areas', array('area_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_area_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'type' => array('type' => 'ENUM(\'group\',\'function\',\'navigation\')', 'notnull' => false, 'default' => 'navigation'), 'scope' => array('type' => 'ENUM(\'global\',\'frontend\',\'backend\')', 'notnull' => true, 'default' => 'global', 'after' => 'type'), 'area_name' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default_expr' => 'NULL'), 'is_active' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '1'), 'uri' => array('type' => 'VARCHAR(255)'), 'target' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '_self'), 'module_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'order_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'access_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0')), array('area_name' => array('fields' => array('area_name'))));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /*********************
     *
     * ADD COUNTRY TABLE
     *
     ********************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'lib_country', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(64)', 'after' => 'id'), 'iso_code_2' => array('type' => 'CHAR(2)', 'after' => 'name'), 'iso_code_3' => array('type' => 'CHAR(3)', 'notnull' => false, 'after' => 'iso_code_2')), array('unique' => array('fields' => array('iso_code_2'), 'type' => 'UNIQUE'), 'INDEX_COUNTRIES_NAME' => array('fields' => array('name'))), 'InnoDB');
        $arrCountries = array(1 => array('name' => 'Afghanistan', 'iso_2' => 'AF', 'iso_3' => 'AFG'), 2 => array('name' => 'Albania', 'iso_2' => 'AL', 'iso_3' => 'ALB'), 3 => array('name' => 'Algeria', 'iso_2' => 'DZ', 'iso_3' => 'DZA'), 4 => array('name' => 'American Samoa', 'iso_2' => 'AS', 'iso_3' => 'ASM'), 5 => array('name' => 'Andorra', 'iso_2' => 'AD', 'iso_3' => 'AND'), 6 => array('name' => 'Angola', 'iso_2' => 'AO', 'iso_3' => 'AGO'), 7 => array('name' => 'Anguilla', 'iso_2' => 'AI', 'iso_3' => 'AIA'), 8 => array('name' => 'Antarctica', 'iso_2' => 'AQ', 'iso_3' => 'ATA'), 9 => array('name' => 'Antigua and Barbuda', 'iso_2' => 'AG', 'iso_3' => 'ATG'), 10 => array('name' => 'Argentina', 'iso_2' => 'AR', 'iso_3' => 'ARG'), 11 => array('name' => 'Armenia', 'iso_2' => 'AM', 'iso_3' => 'ARM'), 12 => array('name' => 'Aruba', 'iso_2' => 'AW', 'iso_3' => 'ABW'), 13 => array('name' => 'Australia', 'iso_2' => 'AU', 'iso_3' => 'AUS'), 14 => array('name' => 'Österreich', 'iso_2' => 'AT', 'iso_3' => 'AUT'), 15 => array('name' => 'Azerbaijan', 'iso_2' => 'AZ', 'iso_3' => 'AZE'), 16 => array('name' => 'Bahamas', 'iso_2' => 'BS', 'iso_3' => 'BHS'), 17 => array('name' => 'Bahrain', 'iso_2' => 'BH', 'iso_3' => 'BHR'), 18 => array('name' => 'Bangladesh', 'iso_2' => 'BD', 'iso_3' => 'BGD'), 19 => array('name' => 'Barbados', 'iso_2' => 'BB', 'iso_3' => 'BRB'), 20 => array('name' => 'Belarus', 'iso_2' => 'BY', 'iso_3' => 'BLR'), 21 => array('name' => 'Belgium', 'iso_2' => 'BE', 'iso_3' => 'BEL'), 22 => array('name' => 'Belize', 'iso_2' => 'BZ', 'iso_3' => 'BLZ'), 23 => array('name' => 'Benin', 'iso_2' => 'BJ', 'iso_3' => 'BEN'), 24 => array('name' => 'Bermuda', 'iso_2' => 'BM', 'iso_3' => 'BMU'), 25 => array('name' => 'Bhutan', 'iso_2' => 'BT', 'iso_3' => 'BTN'), 26 => array('name' => 'Bolivia', 'iso_2' => 'BO', 'iso_3' => 'BOL'), 27 => array('name' => 'Bosnia and Herzegowina', 'iso_2' => 'BA', 'iso_3' => 'BIH'), 28 => array('name' => 'Botswana', 'iso_2' => 'BW', 'iso_3' => 'BWA'), 29 => array('name' => 'Bouvet Island', 'iso_2' => 'BV', 'iso_3' => 'BVT'), 30 => array('name' => 'Brazil', 'iso_2' => 'BR', 'iso_3' => 'BRA'), 31 => array('name' => 'British Indian Ocean Territory', 'iso_2' => 'IO', 'iso_3' => 'IOT'), 32 => array('name' => 'Brunei Darussalam', 'iso_2' => 'BN', 'iso_3' => 'BRN'), 33 => array('name' => 'Bulgaria', 'iso_2' => 'BG', 'iso_3' => 'BGR'), 34 => array('name' => 'Burkina Faso', 'iso_2' => 'BF', 'iso_3' => 'BFA'), 35 => array('name' => 'Burundi', 'iso_2' => 'BI', 'iso_3' => 'BDI'), 36 => array('name' => 'Cambodia', 'iso_2' => 'KH', 'iso_3' => 'KHM'), 37 => array('name' => 'Cameroon', 'iso_2' => 'CM', 'iso_3' => 'CMR'), 38 => array('name' => 'Canada', 'iso_2' => 'CA', 'iso_3' => 'CAN'), 39 => array('name' => 'Cape Verde', 'iso_2' => 'CV', 'iso_3' => 'CPV'), 40 => array('name' => 'Cayman Islands', 'iso_2' => 'KY', 'iso_3' => 'CYM'), 41 => array('name' => 'Central African Republic', 'iso_2' => 'CF', 'iso_3' => 'CAF'), 42 => array('name' => 'Chad', 'iso_2' => 'TD', 'iso_3' => 'TCD'), 43 => array('name' => 'Chile', 'iso_2' => 'CL', 'iso_3' => 'CHL'), 44 => array('name' => 'China', 'iso_2' => 'CN', 'iso_3' => 'CHN'), 45 => array('name' => 'Christmas Island', 'iso_2' => 'CX', 'iso_3' => 'CXR'), 46 => array('name' => 'Cocos (Keeling) Islands', 'iso_2' => 'CC', 'iso_3' => 'CCK'), 47 => array('name' => 'Colombia', 'iso_2' => 'CO', 'iso_3' => 'COL'), 48 => array('name' => 'Comoros', 'iso_2' => 'KM', 'iso_3' => 'COM'), 49 => array('name' => 'Congo', 'iso_2' => 'CG', 'iso_3' => 'COG'), 50 => array('name' => 'Cook Islands', 'iso_2' => 'CK', 'iso_3' => 'C*K'), 51 => array('name' => 'Costa Rica', 'iso_2' => 'CR', 'iso_3' => 'CRI'), 52 => array('name' => 'Cote D\'Ivoire', 'iso_2' => 'CI', 'iso_3' => 'CIV'), 53 => array('name' => 'Croatia', 'iso_2' => 'HR', 'iso_3' => 'HRV'), 54 => array('name' => 'Cuba', 'iso_2' => 'CU', 'iso_3' => 'CUB'), 55 => array('name' => 'Cyprus', 'iso_2' => 'CY', 'iso_3' => 'CYP'), 56 => array('name' => 'Czech Republic', 'iso_2' => 'CZ', 'iso_3' => 'CZE'), 57 => array('name' => 'Denmark', 'iso_2' => 'DK', 'iso_3' => 'DNK'), 58 => array('name' => 'Djibouti', 'iso_2' => 'DJ', 'iso_3' => 'DJI'), 59 => array('name' => 'Dominica', 'iso_2' => 'DM', 'iso_3' => 'DMA'), 60 => array('name' => 'Dominican Republic', 'iso_2' => 'DO', 'iso_3' => 'DOM'), 61 => array('name' => 'East Timor', 'iso_2' => 'TP', 'iso_3' => 'TMP'), 62 => array('name' => 'Ecuador', 'iso_2' => 'EC', 'iso_3' => 'ECU'), 63 => array('name' => 'Egypt', 'iso_2' => 'EG', 'iso_3' => 'EGY'), 64 => array('name' => 'El Salvador', 'iso_2' => 'SV', 'iso_3' => 'SLV'), 65 => array('name' => 'Equatorial Guinea', 'iso_2' => 'GQ', 'iso_3' => 'GNQ'), 66 => array('name' => 'Eritrea', 'iso_2' => 'ER', 'iso_3' => 'ERI'), 67 => array('name' => 'Estonia', 'iso_2' => 'EE', 'iso_3' => 'EST'), 68 => array('name' => 'Ethiopia', 'iso_2' => 'ET', 'iso_3' => 'ETH'), 69 => array('name' => 'Falkland Islands (Malvinas)', 'iso_2' => 'FK', 'iso_3' => 'FLK'), 70 => array('name' => 'Faroe Islands', 'iso_2' => 'FO', 'iso_3' => 'FRO'), 71 => array('name' => 'Fiji', 'iso_2' => 'FJ', 'iso_3' => 'FJI'), 72 => array('name' => 'Finland', 'iso_2' => 'FI', 'iso_3' => 'FIN'), 73 => array('name' => 'France', 'iso_2' => 'FR', 'iso_3' => 'FRA'), 74 => array('name' => 'France, Metropolitan', 'iso_2' => 'FX', 'iso_3' => 'FXX'), 75 => array('name' => 'French Guiana', 'iso_2' => 'GF', 'iso_3' => 'GUF'), 76 => array('name' => 'French Polynesia', 'iso_2' => 'PF', 'iso_3' => 'PYF'), 77 => array('name' => 'French Southern Territories', 'iso_2' => 'TF', 'iso_3' => 'ATF'), 78 => array('name' => 'Gabon', 'iso_2' => 'GA', 'iso_3' => 'GAB'), 79 => array('name' => 'Gambia', 'iso_2' => 'GM', 'iso_3' => 'GMB'), 80 => array('name' => 'Georgia', 'iso_2' => 'GE', 'iso_3' => 'GEO'), 81 => array('name' => 'Deutschland', 'iso_2' => 'DE', 'iso_3' => 'DEU'), 82 => array('name' => 'Ghana', 'iso_2' => 'GH', 'iso_3' => 'GHA'), 83 => array('name' => 'Gibraltar', 'iso_2' => 'GI', 'iso_3' => 'GIB'), 84 => array('name' => 'Greece', 'iso_2' => 'GR', 'iso_3' => 'GRC'), 85 => array('name' => 'Greenland', 'iso_2' => 'GL', 'iso_3' => 'GRL'), 86 => array('name' => 'Grenada', 'iso_2' => 'GD', 'iso_3' => 'GRD'), 87 => array('name' => 'Guadeloupe', 'iso_2' => 'GP', 'iso_3' => 'GLP'), 88 => array('name' => 'Guam', 'iso_2' => 'GU', 'iso_3' => 'GUM'), 89 => array('name' => 'Guatemala', 'iso_2' => 'GT', 'iso_3' => 'GTM'), 90 => array('name' => 'Guinea', 'iso_2' => 'GN', 'iso_3' => 'GIN'), 91 => array('name' => 'Guinea-bissau', 'iso_2' => 'GW', 'iso_3' => 'GNB'), 92 => array('name' => 'Guyana', 'iso_2' => 'GY', 'iso_3' => 'GUY'), 93 => array('name' => 'Haiti', 'iso_2' => 'HT', 'iso_3' => 'HTI'), 94 => array('name' => 'Heard and Mc Donald Islands', 'iso_2' => 'HM', 'iso_3' => 'HMD'), 95 => array('name' => 'Honduras', 'iso_2' => 'HN', 'iso_3' => 'HND'), 96 => array('name' => 'Hong Kong', 'iso_2' => 'HK', 'iso_3' => 'HKG'), 97 => array('name' => 'Hungary', 'iso_2' => 'HU', 'iso_3' => 'HUN'), 98 => array('name' => 'Iceland', 'iso_2' => 'IS', 'iso_3' => 'ISL'), 99 => array('name' => 'India', 'iso_2' => 'IN', 'iso_3' => 'IND'), 100 => array('name' => 'Indonesia', 'iso_2' => 'ID', 'iso_3' => 'IDN'), 101 => array('name' => 'Iran (Islamic Republic of)', 'iso_2' => 'IR', 'iso_3' => 'IRN'), 102 => array('name' => 'Iraq', 'iso_2' => 'IQ', 'iso_3' => 'IRQ'), 103 => array('name' => 'Ireland', 'iso_2' => 'IE', 'iso_3' => 'IRL'), 104 => array('name' => 'Israel', 'iso_2' => 'IL', 'iso_3' => 'ISR'), 105 => array('name' => 'Italy', 'iso_2' => 'IT', 'iso_3' => 'ITA'), 106 => array('name' => 'Jamaica', 'iso_2' => 'JM', 'iso_3' => 'JAM'), 107 => array('name' => 'Japan', 'iso_2' => 'JP', 'iso_3' => 'JPN'), 108 => array('name' => 'Jordan', 'iso_2' => 'JO', 'iso_3' => 'JOR'), 109 => array('name' => 'Kazakhstan', 'iso_2' => 'KZ', 'iso_3' => 'KAZ'), 110 => array('name' => 'Kenya', 'iso_2' => 'KE', 'iso_3' => 'KEN'), 111 => array('name' => 'Kiribati', 'iso_2' => 'KI', 'iso_3' => 'KIR'), 112 => array('name' => 'Korea, Democratic People\'s Republic of', 'iso_2' => 'KP', 'iso_3' => 'PRK'), 113 => array('name' => 'Korea, Republic of', 'iso_2' => 'KR', 'iso_3' => 'KOR'), 114 => array('name' => 'Kuwait', 'iso_2' => 'KW', 'iso_3' => 'KWT'), 115 => array('name' => 'Kyrgyzstan', 'iso_2' => 'KG', 'iso_3' => 'KGZ'), 116 => array('name' => 'Lao People\'s Democratic Republic', 'iso_2' => 'LA', 'iso_3' => 'LAO'), 117 => array('name' => 'Latvia', 'iso_2' => 'LV', 'iso_3' => 'LVA'), 118 => array('name' => 'Lebanon', 'iso_2' => 'LB', 'iso_3' => 'LBN'), 119 => array('name' => 'Lesotho', 'iso_2' => 'LS', 'iso_3' => 'LSO'), 120 => array('name' => 'Liberia', 'iso_2' => 'LR', 'iso_3' => 'LBR'), 121 => array('name' => 'Libyan Arab Jamahiriya', 'iso_2' => 'LY', 'iso_3' => 'LBY'), 122 => array('name' => 'Liechtenstein', 'iso_2' => 'LI', 'iso_3' => 'LIE'), 123 => array('name' => 'Lithuania', 'iso_2' => 'LT', 'iso_3' => 'LTU'), 124 => array('name' => 'Luxembourg', 'iso_2' => 'LU', 'iso_3' => 'LUX'), 125 => array('name' => 'Macau', 'iso_2' => 'MO', 'iso_3' => 'MAC'), 126 => array('name' => 'Macedonia, The Former Yugoslav Republic of', 'iso_2' => 'MK', 'iso_3' => 'MKD'), 127 => array('name' => 'Madagascar', 'iso_2' => 'MG', 'iso_3' => 'MDG'), 128 => array('name' => 'Malawi', 'iso_2' => 'MW', 'iso_3' => 'MWI'), 129 => array('name' => 'Malaysia', 'iso_2' => 'MY', 'iso_3' => 'MYS'), 130 => array('name' => 'Maldives', 'iso_2' => 'MV', 'iso_3' => 'MDV'), 131 => array('name' => 'Mali', 'iso_2' => 'ML', 'iso_3' => 'MLI'), 132 => array('name' => 'Malta', 'iso_2' => 'MT', 'iso_3' => 'MLT'), 133 => array('name' => 'Marshall Islands', 'iso_2' => 'MH', 'iso_3' => 'MHL'), 134 => array('name' => 'Martinique', 'iso_2' => 'MQ', 'iso_3' => 'MTQ'), 135 => array('name' => 'Mauritania', 'iso_2' => 'MR', 'iso_3' => 'MRT'), 136 => array('name' => 'Mauritius', 'iso_2' => 'MU', 'iso_3' => 'MUS'), 137 => array('name' => 'Mayotte', 'iso_2' => 'YT', 'iso_3' => 'MYT'), 138 => array('name' => 'Mexico', 'iso_2' => 'MX', 'iso_3' => 'MEX'), 139 => array('name' => 'Micronesia, Federated States of', 'iso_2' => 'FM', 'iso_3' => 'FSM'), 140 => array('name' => 'Moldova, Republic of', 'iso_2' => 'MD', 'iso_3' => 'MDA'), 141 => array('name' => 'Monaco', 'iso_2' => 'MC', 'iso_3' => 'MCO'), 142 => array('name' => 'Mongolia', 'iso_2' => 'MN', 'iso_3' => 'MNG'), 143 => array('name' => 'Montserrat', 'iso_2' => 'MS', 'iso_3' => 'MSR'), 144 => array('name' => 'Morocco', 'iso_2' => 'MA', 'iso_3' => 'MAR'), 145 => array('name' => 'Mozambique', 'iso_2' => 'MZ', 'iso_3' => 'MOZ'), 146 => array('name' => 'Myanmar', 'iso_2' => 'MM', 'iso_3' => 'MMR'), 147 => array('name' => 'Namibia', 'iso_2' => 'NA', 'iso_3' => 'NAM'), 148 => array('name' => 'Nauru', 'iso_2' => 'NR', 'iso_3' => 'NRU'), 149 => array('name' => 'Nepal', 'iso_2' => 'NP', 'iso_3' => 'NPL'), 150 => array('name' => 'Netherlands', 'iso_2' => 'NL', 'iso_3' => 'NLD'), 151 => array('name' => 'Netherlands Antilles', 'iso_2' => 'AN', 'iso_3' => 'ANT'), 152 => array('name' => 'New Caledonia', 'iso_2' => 'NC', 'iso_3' => 'NCL'), 153 => array('name' => 'New Zealand', 'iso_2' => 'NZ', 'iso_3' => 'NZL'), 154 => array('name' => 'Nicaragua', 'iso_2' => 'NI', 'iso_3' => 'NIC'), 155 => array('name' => 'Niger', 'iso_2' => 'NE', 'iso_3' => 'NER'), 156 => array('name' => 'Nigeria', 'iso_2' => 'NG', 'iso_3' => 'NGA'), 157 => array('name' => 'Niue', 'iso_2' => 'NU', 'iso_3' => 'NIU'), 158 => array('name' => 'Norfolk Island', 'iso_2' => 'NF', 'iso_3' => 'NFK'), 159 => array('name' => 'Northern Mariana Islands', 'iso_2' => 'MP', 'iso_3' => 'MNP'), 160 => array('name' => 'Norway', 'iso_2' => 'NO', 'iso_3' => 'NOR'), 161 => array('name' => 'Oman', 'iso_2' => 'OM', 'iso_3' => 'OMN'), 162 => array('name' => 'Pakistan', 'iso_2' => 'PK', 'iso_3' => 'PAK'), 163 => array('name' => 'Palau', 'iso_2' => 'PW', 'iso_3' => 'PLW'), 164 => array('name' => 'Panama', 'iso_2' => 'PA', 'iso_3' => 'PAN'), 165 => array('name' => 'Papua New Guinea', 'iso_2' => 'PG', 'iso_3' => 'PNG'), 166 => array('name' => 'Paraguay', 'iso_2' => 'PY', 'iso_3' => 'PRY'), 167 => array('name' => 'Peru', 'iso_2' => 'PE', 'iso_3' => 'PER'), 168 => array('name' => 'Philippines', 'iso_2' => 'PH', 'iso_3' => 'PHL'), 169 => array('name' => 'Pitcairn', 'iso_2' => 'PN', 'iso_3' => 'PCN'), 170 => array('name' => 'Poland', 'iso_2' => 'PL', 'iso_3' => 'POL'), 171 => array('name' => 'Portugal', 'iso_2' => 'PT', 'iso_3' => 'PRT'), 172 => array('name' => 'Puerto Rico', 'iso_2' => 'PR', 'iso_3' => 'PRI'), 173 => array('name' => 'Qatar', 'iso_2' => 'QA', 'iso_3' => 'QAT'), 174 => array('name' => 'Reunion', 'iso_2' => 'RE', 'iso_3' => 'REU'), 175 => array('name' => 'Romania', 'iso_2' => 'RO', 'iso_3' => 'ROM'), 176 => array('name' => 'Russian Federation', 'iso_2' => 'RU', 'iso_3' => 'RUS'), 177 => array('name' => 'Rwanda', 'iso_2' => 'RW', 'iso_3' => 'RWA'), 178 => array('name' => 'Saint Kitts and Nevis', 'iso_2' => 'KN', 'iso_3' => 'KNA'), 179 => array('name' => 'Saint Lucia', 'iso_2' => 'LC', 'iso_3' => 'LCA'), 180 => array('name' => 'Saint Vincent and the Grenadines', 'iso_2' => 'VC', 'iso_3' => 'VCT'), 181 => array('name' => 'Samoa', 'iso_2' => 'WS', 'iso_3' => 'WSM'), 182 => array('name' => 'San Marino', 'iso_2' => 'SM', 'iso_3' => 'SMR'), 183 => array('name' => 'Sao Tome and Principe', 'iso_2' => 'ST', 'iso_3' => 'STP'), 184 => array('name' => 'Saudi Arabia', 'iso_2' => 'SA', 'iso_3' => 'SAU'), 185 => array('name' => 'Senegal', 'iso_2' => 'SN', 'iso_3' => 'SEN'), 186 => array('name' => 'Seychelles', 'iso_2' => 'SC', 'iso_3' => 'SYC'), 187 => array('name' => 'Sierra Leone', 'iso_2' => 'SL', 'iso_3' => 'SLE'), 188 => array('name' => 'Singapore', 'iso_2' => 'SG', 'iso_3' => 'SGP'), 189 => array('name' => 'Slovakia (Slovak Republic)', 'iso_2' => 'SK', 'iso_3' => 'SVK'), 190 => array('name' => 'Slovenia', 'iso_2' => 'SI', 'iso_3' => 'SVN'), 191 => array('name' => 'Solomon Islands', 'iso_2' => 'SB', 'iso_3' => 'SLB'), 192 => array('name' => 'Somalia', 'iso_2' => 'SO', 'iso_3' => 'SOM'), 193 => array('name' => 'South Africa', 'iso_2' => 'ZA', 'iso_3' => 'ZAF'), 194 => array('name' => 'South Georgia and the South Sandwich Islands', 'iso_2' => 'GS', 'iso_3' => 'SGS'), 195 => array('name' => 'Spain', 'iso_2' => 'ES', 'iso_3' => 'ESP'), 196 => array('name' => 'Sri Lanka', 'iso_2' => 'LK', 'iso_3' => 'LKA'), 197 => array('name' => 'St. Helena', 'iso_2' => 'SH', 'iso_3' => 'SHN'), 198 => array('name' => 'St. Pierre and Miquelon', 'iso_2' => 'PM', 'iso_3' => 'SPM'), 199 => array('name' => 'Sudan', 'iso_2' => 'SD', 'iso_3' => 'SDN'), 200 => array('name' => 'Suriname', 'iso_2' => 'SR', 'iso_3' => 'SUR'), 201 => array('name' => 'Svalbard and Jan Mayen Islands', 'iso_2' => 'SJ', 'iso_3' => 'SJM'), 202 => array('name' => 'Swaziland', 'iso_2' => 'SZ', 'iso_3' => 'SWZ'), 203 => array('name' => 'Sweden', 'iso_2' => 'SE', 'iso_3' => 'SWE'), 204 => array('name' => 'Schweiz', 'iso_2' => 'CH', 'iso_3' => 'CHE'), 205 => array('name' => 'Syrian Arab Republic', 'iso_2' => 'SY', 'iso_3' => 'SYR'), 206 => array('name' => 'Taiwan', 'iso_2' => 'TW', 'iso_3' => 'TWN'), 207 => array('name' => 'Tajikistan', 'iso_2' => 'TJ', 'iso_3' => 'TJK'), 208 => array('name' => 'Tanzania, United Republic of', 'iso_2' => 'TZ', 'iso_3' => 'TZA'), 209 => array('name' => 'Thailand', 'iso_2' => 'TH', 'iso_3' => 'THA'), 210 => array('name' => 'Togo', 'iso_2' => 'TG', 'iso_3' => 'TGO'), 211 => array('name' => 'Tokelau', 'iso_2' => 'TK', 'iso_3' => 'TKL'), 212 => array('name' => 'Tonga', 'iso_2' => 'TO', 'iso_3' => 'TON'), 213 => array('name' => 'Trinidad and Tobago', 'iso_2' => 'TT', 'iso_3' => 'TTO'), 214 => array('name' => 'Tunisia', 'iso_2' => 'TN', 'iso_3' => 'TUN'), 215 => array('name' => 'Turkey', 'iso_2' => 'TR', 'iso_3' => 'TUR'), 216 => array('name' => 'Turkmenistan', 'iso_2' => 'TM', 'iso_3' => 'TKM'), 217 => array('name' => 'Turks and Caicos Islands', 'iso_2' => 'TC', 'iso_3' => 'TCA'), 218 => array('name' => 'Tuvalu', 'iso_2' => 'TV', 'iso_3' => 'TUV'), 219 => array('name' => 'Uganda', 'iso_2' => 'UG', 'iso_3' => 'UGA'), 220 => array('name' => 'Ukraine', 'iso_2' => 'UA', 'iso_3' => 'UKR'), 221 => array('name' => 'United Arab Emirates', 'iso_2' => 'AE', 'iso_3' => 'ARE'), 222 => array('name' => 'United Kingdom', 'iso_2' => 'GB', 'iso_3' => 'GBR'), 223 => array('name' => 'United States', 'iso_2' => 'US', 'iso_3' => 'USA'), 224 => array('name' => 'United States Minor Outlying Islands', 'iso_2' => 'UM', 'iso_3' => 'UMI'), 225 => array('name' => 'Uruguay', 'iso_2' => 'UY', 'iso_3' => 'URY'), 226 => array('name' => 'Uzbekistan', 'iso_2' => 'UZ', 'iso_3' => 'UZB'), 227 => array('name' => 'Vanuatu', 'iso_2' => 'VU', 'iso_3' => 'VUT'), 228 => array('name' => 'Vatican City State (Holy See)', 'iso_2' => 'VA', 'iso_3' => 'VAT'), 229 => array('name' => 'Venezuela', 'iso_2' => 'VE', 'iso_3' => 'VEN'), 230 => array('name' => 'Viet Nam', 'iso_2' => 'VN', 'iso_3' => 'VNM'), 231 => array('name' => 'Virgin Islands (British)', 'iso_2' => 'VG', 'iso_3' => 'VGB'), 232 => array('name' => 'Virgin Islands (U.S.)', 'iso_2' => 'VI', 'iso_3' => 'VIR'), 233 => array('name' => 'Wallis and Futuna Islands', 'iso_2' => 'WF', 'iso_3' => 'WLF'), 234 => array('name' => 'Western Sahara', 'iso_2' => 'EH', 'iso_3' => 'ESH'), 235 => array('name' => 'Yemen', 'iso_2' => 'YE', 'iso_3' => 'YEM'), 236 => array('name' => 'Yugoslavia', 'iso_2' => 'YU', 'iso_3' => 'YUG'), 237 => array('name' => 'Zaire', 'iso_2' => 'ZR', 'iso_3' => 'ZAR'), 238 => array('name' => 'Zambia', 'iso_2' => 'ZM', 'iso_3' => 'ZMB'), 239 => array('name' => 'Zimbabwe', 'iso_2' => 'ZW', 'iso_3' => 'ZWE'));
        foreach ($arrCountries as $countryId => $arrCountry) {
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "lib_country` VALUES (" . $countryId . ", '" . addslashes($arrCountry['name']) . "', '" . $arrCountry['iso_2'] . "', '" . $arrCountry['iso_3'] . "') ON DUPLICATE KEY UPDATE `id` = `id`");
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        /**********************************************************
         * NEW IN VERSION 2.1: templates for mobile devices!       *
         ***********************************************************/
        /**********************************************************
         * EXTENSION:    Fallback language and app device template *
         * ADDED:        Contrexx v3.0.0                           *
         ***********************************************************/
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'languages', array('id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'lang' => array('type' => 'VARCHAR(5)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'name' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'lang'), 'charset' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => 'iso-8859-1', 'after' => 'name'), 'themesid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'charset'), 'print_themes_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'themesid'), 'pdf_themes_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'print_themes_id'), 'frontend' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'pdf_themes_id'), 'backend' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'frontend'), 'is_default' => array('type' => 'SET(\'true\',\'false\')', 'notnull' => true, 'default' => 'false', 'after' => 'backend'), 'mobile_themes_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'is_default'), 'fallback' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'mobile_themes_id'), 'app_themes_id' => array('type' => 'INT(2)', 'after' => 'fallback')), array('lang' => array('fields' => array('lang'), 'type' => 'UNIQUE'), 'defaultstatus' => array('fields' => array('is_default'))));
        \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'languages` SET `app_themes_id` = `themesid` WHERE `app_themes_id` = 0');
        \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'languages` SET `mobile_themes_id` = `themesid` WHERE `mobile_themes_id` = 0');
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        /********************************************************************
         * NEW IN VERSION 3.1.1: no fallback language should be possible
         ********************************************************************/
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'languages', array('id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'lang' => array('type' => 'VARCHAR(5)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'name' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'lang'), 'charset' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => 'iso-8859-1', 'after' => 'name'), 'themesid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'charset'), 'print_themes_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'themesid'), 'pdf_themes_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'print_themes_id'), 'frontend' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'pdf_themes_id'), 'backend' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'frontend'), 'is_default' => array('type' => 'SET(\'true\',\'false\')', 'notnull' => true, 'default' => 'false', 'after' => 'backend'), 'mobile_themes_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'is_default'), 'fallback' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => false, 'default' => '0', 'after' => 'mobile_themes_id'), 'app_themes_id' => array('type' => 'INT(2)', 'after' => 'fallback')), array('lang' => array('fields' => array('lang'), 'type' => 'UNIQUE'), 'defaultstatus' => array('fields' => array('is_default')), 'name' => array('fields' => array('name')), 'name_2' => array('fields' => array('name'), 'type' => 'FULLTEXT')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /**********************************************************
     * Add unique index on theme name. Who needs multiple
     * themes with the same name anyways? Are there people
     * who know the difference between "aaa" and "aaa"? Guess
     * not. It's just useless.
     * NOTE THIS KICKS OUT ALL DUPLICATE DESIGNS WITH THE
     * SAME NAME FROM THE DATABASE. WHICH I CONSIDER A
     * NECCESSARY EVIL.
     **********************************************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'skins', array('id' => array('type' => 'INT(2) UNSIGNED', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'themesname' => array('type' => 'VARCHAR(50)', 'notnull' => true), 'foldername' => array('type' => 'VARCHAR(50)', 'notnull' => true), 'expert' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '1')), array('theme_unique' => array('fields' => array('themesname'), 'type' => 'UNIQUE', 'force' => true), 'folder_unique' => array('fields' => array('foldername'), 'type' => 'UNIQUE', 'force' => true)));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /***********************************************************
     * EXTENSION:    css class instead of id for auto generated *
     *               submenu in nested navigation               *
     * ADDED:        Contrexx v3.0.0                            *
     ************************************************************/
    function changeNestedNavigationCss($directory)
    {
        if ($handle = opendir($directory)) {
            while (($file = readdir($handle)) !== false) {
                if (!in_array($file, array('.', '..', '.svn'))) {
                    $file = $directory . '/' . $file;
                    if (is_dir($file)) {
                        changeNestedNavigationCss($file);
                    } else {
                        if (substr($file, -4) == '.css') {
                            try {
                                $objFile = new \Cx\Lib\FileSystem\File($file);
                                if (($data = $objFile->getData()) && !empty($data)) {
                                    $objFile->write(preg_replace('/#menu_level_(\\d+)(?!([\\w-_]+))/i', '.menu_level_\\1', $data));
                                }
                            } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                                \DBG::msg($e->getMessage());
                                return false;
                            }
                        }
                    }
                }
            }
            closedir($handle);
        }
    }
    $path = ASCMS_DOCUMENT_ROOT . '/themes';
    foreach (scandir($path) as $theme) {
        if (!in_array($theme, array('.', '..'))) {
            $theme = $path . '/' . $theme;
            $changeNestedNavigationCss = false;
            $navigationFiles = array('navbar.html', 'navbar2.html', 'navbar3.html', 'subnavbar.html', 'subnavbar2.html', 'subnavbar3.html');
            foreach ($navigationFiles as $file) {
                $file = $theme . '/' . $file;
                if (file_exists($file)) {
                    try {
                        $objFile = new \Cx\Lib\FileSystem\File($file);
                        if (($data = $objFile->getData()) && !empty($data)) {
                            if (strpos($data, 'nested_navigation') !== false) {
                                $changeNestedNavigationCss = true;
                            }
                        }
                    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                        \DBG::msg($e->getMessage());
                    }
                }
            }
            if ($changeNestedNavigationCss) {
                changeNestedNavigationCss($theme);
            }
        }
    }
    /*****************************************
     * EXTENSION:   {JAVASCRIPT} placeholder *
     * ADDED:       Contrexx v2.1.0     *
     *****************************************/
    $path = ASCMS_DOCUMENT_ROOT . '/themes';
    foreach (scandir($path) as $theme) {
        if (!in_array($theme, array('.', '..', '.svn'))) {
            $theme = $path . '/' . $theme;
            $file = $theme . '/index.html';
            if (file_exists($file)) {
                try {
                    $objFile = new \Cx\Lib\FileSystem\File($file);
                    if (($data = $objFile->getData()) && !empty($data)) {
                        if (strpos($data, '{JAVASCRIPT}') === false) {
                            $data = preg_replace('/(\\s*)<\\/head>/ms', "\$1    {JAVASCRIPT}\$1</head>", $data);
                            if ($data) {
                                $objFile->write($data);
                            }
                        }
                    }
                } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                    \DBG::msg($e->getMessage());
                }
            }
        }
    }
    /********************************
     * EXTENSION:   Timezone        *
     * ADDED:       Contrexx v3.0.0 *
     ********************************/
    try {
        \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'log` CHANGE `datetime` `datetime` TIMESTAMP NULL DEFAULT "0000-00-00 00:00:00"');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /**********************************************************
     * EXTENSION:    Session garbage collector considers now   *
     *               the individual lifetime of each session   *
     *               (needed since remember me is implemented) *
     * ADDED:        Contrexx v3.0.1                           *
     ***********************************************************/
    try {
        $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'sessions');
        if ($arrColumns === false) {
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'sessions'));
            return false;
        }
        if (!isset($arrColumns['REMEMBER_ME'])) {
            \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'sessions` ADD `remember_me` INT(1) NOT NULL DEFAULT 0 AFTER `sessionid`');
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /**********************************************************
     * EXTENSION:    Delete old cache class which causes       *
     *               classloader confliction.                  *
     * ADDED:        Contrexx v3.0.1                           *
     ***********************************************************/
    $path = ASCMS_DOCUMENT_ROOT . '/lib/FRAMEWORK/Cache.class.php';
    if (file_exists($path)) {
        if (!\Cx\Lib\FileSystem\FileSystem::delete_file($path)) {
            setUpdateMsg('Die Datei "/lib/FRAMEWORK/Cache.class.php" konnte nicht gelöscht werden. Bitte löschen Sie diese manuell.', 'error');
            setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_UPDATE_TRY_AGAIN'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
            return false;
        }
    }
    /********************************************************
     * EXTENSION:    Add new access id (178) to those groups *
     *               having access to the news (10) or       *
     *               blog (119) module.                      *
     * ADDED:        Contrexx v3.1.0                         *
     ********************************************************/
    try {
        \Cx\Lib\UpdateUtil::sql('
            INSERT INTO `' . DBPREFIX . 'access_group_static_ids` (`access_id`, `group_id`)
            SELECT 178, `group_id` FROM `' . DBPREFIX . 'access_group_static_ids` WHERE (`access_id` = 10) OR (`access_id` = 119) GROUP BY `group_id`
            ON DUPLICATE KEY UPDATE `access_id` = `access_id`
        ');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        Text::errorHandler();
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        \Cx\Core\Setting\Controller\Setting::errorHandler();
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /********************************************************
     * EXTENSION:    ADD COMPONENTS TABLE                    *
     * ADDED:        Contrexx v3.1.0                         *
     ********************************************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'component', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(100)', 'after' => 'id'), 'type' => array('type' => 'ENUM(\'core\',\'core_module\',\'module\')', 'after' => 'name')), null, 'InnoDB');
        \Cx\Lib\UpdateUtil::sql("\n            INSERT IGNORE INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES\n                (70, 'Workbench', 'core_module'),\n                (71, 'FrontendEditing', 'core_module'),\n                (72, 'ContentManager', 'core')\n        ");
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Example #18
0
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;
}
Example #19
0
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;
}
Example #20
0
/**
 * 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;
}
Example #21
0
/**
 * 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}">&nbsp;{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;
}
Example #22
0
/**
 * 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 _livecamUpdate()
{
    global $objDatabase, $objUpdate, $_CONFIG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_livecam', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'primary' => true), 'currentImagePath' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '/webcam/cam1/current.jpg'), 'archivePath' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '/webcam/cam1/archive/'), 'thumbnailPath' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '/webcam/cam1/thumbs/'), 'maxImageWidth' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '400'), 'thumbMaxSize' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '200'), 'shadowboxActivate' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '1', 'renamefrom' => 'lightboxActivate'), 'showFrom' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'showTill' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_livecam_settings', array('setid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'setname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'setvalue' => array('type' => 'TEXT')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $query = "SELECT 1 FROM `" . DBPREFIX . "module_livecam_settings` WHERE `setname` = 'amount_of_cams'";
    $objResult = $objDatabase->SelectLimit($query, 1);
    if ($objResult !== false) {
        if ($objResult->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_livecam_settings` (`setname`, `setvalue`) VALUES ('amount_of_cams', '1')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /************************************************
     * BUGFIX:   Migrate settings                    *
     * ADDED:    2.1.2                               *
     ************************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) {
        $arrFormerSettings = array('currentImageUrl' => '', 'archivePath' => '', 'thumbnailPath' => '');
        $query = "SELECT 1 FROM `" . DBPREFIX . "module_livecam` WHERE `id` = 1";
        $objResult = $objDatabase->SelectLimit($query, 1);
        if ($objResult !== false) {
            if ($objResult->RecordCount() == 0) {
                $query = "SELECT `setname`, `setvalue` FROM `" . DBPREFIX . "module_livecam_settings` WHERE `setname` IN ('" . implode("','", array_keys($arrFormerSettings)) . "')";
                $objResult = $objDatabase->Execute($query);
                if ($objResult !== false) {
                    while (!$objResult->EOF) {
                        $arrFormerSettings[$objResult->fields['setname']] = $objResult->fields['setvalue'];
                        $objResult->MoveNext();
                    }
                    $query = "INSERT INTO `" . DBPREFIX . "module_livecam` (`id`, `currentImagePath`, `archivePath`, `thumbnailPath`, `maxImageWidth`, `thumbMaxSize`, `shadowboxActivate`) VALUES\n                            ('1', '" . addslashes($arrFormerSettings['currentImageUrl']) . "', '" . addslashes($arrFormerSettings['archivePath']) . "', '" . addslashes($arrFormerSettings['thumbnailPath']) . "', '400', '120', '0')";
                    if ($objDatabase->Execute($query) === false) {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                } else {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
        foreach (array_keys($arrFormerSettings) as $setting) {
            $query = "DELETE FROM `" . DBPREFIX . "module_livecam_settings` WHERE `setname` = '" . $setting . "'";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    $defaultFrom = mktime(0, 0);
    $defaultTill = mktime(23, 59);
    //set new default settings
    $query = "UPDATE `" . DBPREFIX . "module_livecam` SET `showFrom`={$defaultFrom}, `showTill`={$defaultTill} WHERE `showFrom` = '0'";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /************************************************
     * BUGFIX:   Update content page                 *
     * ADDED:    2.1.3                               *
     ************************************************/
    // both spaces in the search and replace pattern are required in that case
    try {
        \Cx\Lib\UpdateUtil::migrateContentPage('livecam', null, ' {LIVECAM_IMAGE_SHADOWBOX}', ' rel="{LIVECAM_IMAGE_SHADOWBOX}"', '2.1.3');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Example #23
0
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;
}
Example #24
0
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;
}
Example #25
0
function _updateSettingsTable($setId, $arrSetting)
{
    global $objDatabase, $arrSettings, $arrSettingsByName, $arrCurrentSettingsTable, $_CONFIG;
    if (!isset($arrCurrentSettingsTable)) {
        $arrCurrentSettingsTable = array();
    }
    $query = "SELECT setid FROM `" . DBPREFIX . "settings` WHERE `setname`='" . $arrSetting['setname'] . "'";
    // select stored ID of option
    if (($objSettings = $objDatabase->SelectLimit($query, 1)) !== false) {
        if ($objSettings->RecordCount() == 0) {
            // option isn't yet present => ok, check if the associated ID isn't already used
            $query = "SELECT `setname` FROM `" . DBPREFIX . "settings` WHERE `setid` = " . intval($setId);
            if (($objSettings = $objDatabase->SelectLimit($query, 1)) !== false) {
                if ($objSettings->RecordCount() == 0) {
                    // option ID isn't already in use => ok, add it
                    $value = $arrSetting['setvalue'];
                    // we must set coreCmsVersion to the currently installed version,
                    // otherwise if we would set it to the new version,
                    // the update will be stopped before getting everything done
                    if ($arrSetting['setname'] == 'coreCmsVersion') {
                        $value = $_CONFIG['coreCmsVersion'];
                    }
                    $query = "INSERT INTO `" . DBPREFIX . "settings` ( `setid` , `setname` , `setvalue` , `setmodule` ) VALUES (" . intval($setId) . ", '" . $arrSetting['setname'] . "', '" . $value . "', '" . intval($arrSetting['setmodule']) . "')";
                    if ($objDatabase->Execute($query) !== false) {
                        return true;
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                } else {
                    // option ID is already in use => update the option who uses the wrong ID to it's right ID
                    $setname = $objSettings->fields['setname'];
                    if (in_array($setname, $arrCurrentSettingsTable)) {
                        // set a free ID which could be used as a temporary ID
                        $query = "SELECT MAX(`setid`) AS lastInsertId FROM `" . DBPREFIX . "settings`";
                        if (($objSettings = $objDatabase->SelectLimit($query, 1)) !== false) {
                            $query = "UPDATE `" . DBPREFIX . "settings` SET `setid` = " . ($objSettings->fields['lastInsertId'] + 1) . " WHERE `setid` = " . intval($setId);
                            // associated a temportary ID to the option who uses the wrong ID
                            if ($objDatabase->Execute($query) !== false) {
                                unset($arrCurrentSettingsTable[$setname]);
                                if (_updateSettingsTable($setId, $arrSetting)) {
                                    return true;
                                } else {
                                    return false;
                                }
                            } else {
                                return _databaseError($query, $objDatabase->ErrorMsg());
                            }
                        } else {
                            return _databaseError($query, $objDatabase->ErrorMsg());
                        }
                    } else {
                        $arrCurrentSettingsTable[] = $setname;
                        if (_updateSettingsTable($arrSettingsByName[$setname], $arrSettings[$arrSettingsByName[$setname]]) && _updateSettingsTable($setId, $arrSetting)) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        } elseif ($objSettings->fields['setid'] != intval($setId)) {
            $currentSetId = $objSettings->fields['setid'];
            // option is already present but uses a wrong ID => check if the right associated ID of the option is already used by an other option
            $query = "SELECT `setname` FROM `" . DBPREFIX . "settings` WHERE `setid` = " . intval($setId);
            if (($objSettings = $objDatabase->SelectLimit($query, 1)) !== false) {
                if ($objSettings->RecordCount() == 0) {
                    // ID isn't already used => ok, set the correct ID of the option
                    $query = "UPDATE `" . DBPREFIX . "settings` SET `setid` = " . intval($setId) . " WHERE `setid` = " . $currentSetId;
                    if ($objDatabase->Execute($query) !== false) {
                        return true;
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                } else {
                    // option ID is already in use => update the option who uses the wrong ID to it's right ID
                    $setname = $objSettings->fields['setname'];
                    if (in_array($setname, $arrCurrentSettingsTable)) {
                        // set a free ID which could be used as a temporary ID
                        $query = "SELECT MAX(`setid`) AS lastInsertId FROM `" . DBPREFIX . "settings`";
                        if (($objSettings = $objDatabase->SelectLimit($query, 1)) !== false) {
                            $query = "UPDATE `" . DBPREFIX . "settings` SET `setid` = " . ($objSettings->fields['lastInsertId'] + 1) . " WHERE `setid` = " . intval($setId);
                            // associated a temportary ID to the option who uses the wrong ID
                            if ($objDatabase->Execute($query) !== false) {
                                unset($arrCurrentSettingsTable[$setname]);
                                if (_updateSettingsTable($setId, $arrSetting)) {
                                    return true;
                                } else {
                                    return false;
                                }
                            } else {
                                return _databaseError($query, $objDatabase->ErrorMsg());
                            }
                        } else {
                            return _databaseError($query, $objDatabase->ErrorMsg());
                        }
                    } else {
                        $arrCurrentSettingsTable[] = $setname;
                        if (_updateSettingsTable($arrSettingsByName[$setname], $arrSettings[$arrSettingsByName[$setname]]) && _updateSettingsTable($setId, $arrSetting)) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        } else {
            return true;
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
}
Example #26
0
/**
 * 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 _shopUpdate()
{
    global $objDatabase, $_ARRAYLANG, $objUpdate;
    if (!defined('MODULE_INDEX')) {
        define('MODULE_INDEX', '');
    }
    try {
        $table_name = DBPREFIX . 'module_shop_config';
        // Mind that this table does no longer exist from version 3
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            // Shop settings
            // Shop thumbnail default settings: shop_thumbnail_max_width
            $query = "\n                SELECT 1 FROM `{$table_name}`\n                WHERE name='shop_thumbnail_max_width'";
            $objResult = $objDatabase->Execute($query);
            if ($objResult) {
                if ($objResult->RecordCount() == 0) {
                    $query = "\n                        INSERT INTO `{$table_name}` (\n                            name, value\n                        ) VALUES (\n                            'shop_thumbnail_max_width', '120'\n                        )";
                    $objResult = $objDatabase->Execute($query);
                    if ($objResult) {
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            // Shop thumbnail default settings: shop_thumbnail_max_height
            $query = "\n                SELECT 1 FROM `{$table_name}`\n                WHERE name='shop_thumbnail_max_height'";
            $objResult = $objDatabase->Execute($query);
            if ($objResult) {
                if ($objResult->RecordCount() == 0) {
                    $query = "\n                        INSERT INTO `{$table_name}` (\n                            name, value\n                        ) VALUES (\n                            'shop_thumbnail_max_height', '90'\n                        )";
                    $objResult = $objDatabase->Execute($query);
                    if ($objResult) {
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            // Shop thumbnail default settings: shop_thumbnail_quality
            $query = "\n                SELECT 1 FROM `{$table_name}`\n                WHERE name='shop_thumbnail_quality'";
            $objResult = $objDatabase->Execute($query);
            if ($objResult) {
                if ($objResult->RecordCount() == 0) {
                    $query = "\n                        INSERT INTO `{$table_name}` (\n                            name, value\n                        ) VALUES (\n                            'shop_thumbnail_quality', '80'\n                        )";
                    $objResult = $objDatabase->Execute($query);
                    if ($objResult) {
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            // Add Yellowpay payment methods default settings:
            // Accepted payment methods
            $query = "\n                SELECT 1 FROM `{$table_name}`\n                WHERE name='yellowpay_accepted_payment_methods'";
            $objResult = $objDatabase->Execute($query);
            if ($objResult) {
                if ($objResult->RecordCount() == 0) {
                    $query = "\n                        INSERT INTO `{$table_name}` (\n                            `id`, `name`, `value`, `status`\n                        ) VALUES (\n                            NULL, 'yellowpay_accepted_payment_methods', '', '1'\n                        )";
                    $objResult = $objDatabase->Execute($query);
                    if ($objResult) {
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            // Change old yellowpay_delivery_payment_type setting
            // to new yellowpay_authorization_type
            $query = "\n                SELECT 1 FROM `{$table_name}`\n                WHERE `name`='yellowpay_delivery_payment_type'";
            $objResult = $objDatabase->Execute($query);
            if ($objResult) {
                if ($objResult->RecordCount() == 1) {
                    $query = "\n                        UPDATE `{$table_name}`\n                           SET `name`='yellowpay_authorization_type'\n                         WHERE `name`='yellowpay_delivery_payment_type'";
                    $objResult = $objDatabase->Execute($query);
                    if ($objResult) {
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            // Add yellowpay test server flag setting
            $query = "\n                SELECT 1 FROM `{$table_name}`\n                WHERE `name`='yellowpay_use_testserver'";
            $objResult = $objDatabase->Execute($query);
            if ($objResult) {
                if ($objResult->RecordCount() == 0) {
                    $query = "\n                        INSERT INTO `{$table_name}` (\n                            `id`, `name`, `value`, `status`\n                        ) VALUES (\n                            NULL, 'yellowpay_use_testserver', '1', '1'\n                        )";
                    $objResult = $objDatabase->Execute($query);
                    if ($objResult) {
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            // Add weight enable flag setting
            $query = "\n                SELECT 1 FROM `{$table_name}`\n                WHERE `name`='shop_weight_enable'";
            $objResult = $objDatabase->Execute($query);
            if ($objResult) {
                if ($objResult->RecordCount() == 0) {
                    $query = "\n                        INSERT INTO `{$table_name}` (\n                            `id`, `name`, `value`, `status`\n                        ) VALUES (\n                            NULL, 'shop_weight_enable', '1', '1'\n                        )";
                    $objResult = $objDatabase->Execute($query);
                    if ($objResult) {
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                }
            } else {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            // Add shop_show_products_default:
            // Which products are shown on the first shop page?
            $query = "\n                SELECT 1 FROM `{$table_name}`\n                WHERE `name`='shop_show_products_default'";
            $objResult = $objDatabase->Execute($query);
            if (!$objResult) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            if ($objResult->RecordCount() == 0) {
                $query = "\n                    INSERT INTO `{$table_name}` (\n                        `name`, `value`\n                    ) VALUES (\n                        'shop_show_products_default', '1'\n                    )";
                $objResult = $objDatabase->Execute($query);
                if (!$objResult) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
            // Update VAT settings
            $query = "\n                SELECT `value` FROM `{$table_name}`\n                WHERE `name`='tax_enabled'";
            $objResult = $objDatabase->Execute($query);
            if (!$objResult) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            if ($objResult->RecordCount()) {
                $flagVatEnabled = $objResult->fields['value'];
                $arrVatEnabled = array('vat_enabled_foreign_customer', 'vat_enabled_foreign_reseller', 'vat_enabled_home_customer', 'vat_enabled_home_reseller');
                foreach ($arrVatEnabled as $strSetting) {
                    $query = "\n                        SELECT 1 FROM `{$table_name}`\n                        WHERE `name`='{$strSetting}'";
                    $objResult = $objDatabase->Execute($query);
                    if (!$objResult) {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                    if ($objResult->RecordCount() == 0) {
                        $query = "\n                            INSERT INTO `{$table_name}` (\n                                `name`, `value`\n                            ) VALUES (\n                                '{$strSetting}', '{$flagVatEnabled}'\n                            )";
                        $objResult = $objDatabase->Execute($query);
                        if (!$objResult) {
                            return _databaseError($query, $objDatabase->ErrorMsg());
                        }
                    }
                }
            }
            $query = "\n                SELECT `value` FROM `{$table_name}`\n                WHERE `name`='tax_included'";
            $objResult = $objDatabase->Execute($query);
            if (!$objResult) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            if ($objResult->RecordCount()) {
                $flagVatIncluded = $objResult->fields['value'];
                $arrVatIncluded = array('vat_included_foreign_customer', 'vat_included_foreign_reseller', 'vat_included_home_customer', 'vat_included_home_reseller');
                foreach ($arrVatIncluded as $strSetting) {
                    $query = "\n                        SELECT 1 FROM `{$table_name}`\n                        WHERE `name`='{$strSetting}'";
                    $objResult = $objDatabase->Execute($query);
                    if (!$objResult) {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                    if ($objResult->RecordCount() == 0) {
                        $query = "\n                            INSERT INTO `{$table_name}` (\n                                `name`, `value`\n                            ) VALUES (\n                                '{$strSetting}', '{$flagVatIncluded}'\n                            )";
                        $objResult = $objDatabase->Execute($query);
                        if (!$objResult) {
                            return _databaseError($query, $objDatabase->ErrorMsg());
                        }
                    }
                }
            }
            $query = "\n                DELETE FROM `{$table_name}`\n                WHERE `name`='tax_enabled' OR `name`='tax_included'";
            $objResult = $objDatabase->Execute($query);
            if (!$objResult) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
        // Update Attribute price to signed.
        // price_prefix is removed for version 3.  See Attribute::errorHandler()
        $table_name = DBPREFIX . 'module_shop_products_attributes_value';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'price_prefix') && Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'module_shop_order_items_attributes') && Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_shop_order_items_attributes', 'price_prefix')) {
            $query = "\n                UPDATE `{$table_name}`\n                   SET `price`=-`price`,\n                       `price_prefix`='+'\n                WHERE `price`>0\n                  AND `price_prefix`='-'";
            $objResult = $objDatabase->Execute($query);
            if (!$objResult) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            $query = "\n                UPDATE `" . DBPREFIX . "module_shop_order_items_attributes`\n                   SET `product_option_values_price`=-`product_option_values_price`\n                WHERE `product_option_values_price`>0\n                  AND `price_prefix`='-'";
            $objResult = $objDatabase->Execute($query);
            if (!$objResult) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
        // Update tables' field types and indices
        $table_name = DBPREFIX . 'module_shop_article_group';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'renamefrom' => 'name')));
        }
        $table_name = DBPREFIX . 'module_shop_customer_group';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '')));
        }
        $table_name = DBPREFIX . 'module_shop_discountgroup_count_name';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'unit' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '')));
        }
        $table_name = DBPREFIX . 'module_shop_discountgroup_count_rate';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('group_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'default' => 0), 'count' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'default' => '1'), 'rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.0')));
        }
        $table_name = DBPREFIX . 'module_shop_rel_discount_group';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('customer_group_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'default' => '0'), 'article_group_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'default' => '0'), 'rate' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.0')));
        }
        $table_name = DBPREFIX . 'module_shop_lsv';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'order_id'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'holder' => array('type' => 'TINYTEXT'), 'bank' => array('type' => 'TINYTEXT'), 'blz' => array('type' => 'TINYTEXT')), array('order_id' => array('fields' => array('order_id'), 'type' => 'UNIQUE')));
        }
        $table_name = DBPREFIX . 'module_shop_shipment_cost';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'price_free')) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'shipper_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'max_weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'cost' => array('type' => 'DECIMAL(10,2)', 'unsigned' => true, 'notnull' => false), 'price_free' => array('type' => 'DECIMAL(10,2)', 'unsigned' => true, 'notnull' => false)));
        }
        $table_name = DBPREFIX . 'module_shop_shipper';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'TINYTEXT'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        }
        // Note that countries are migrated to the core_countries table
        // for version 3, and this table is then dropped.
        // See Country::errorHandler()
        $table_name = DBPREFIX . 'module_shop_countries';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('countries_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'countries_name' => array('type' => 'VARCHAR(64)', 'notnull' => true, 'default' => ''), 'countries_iso_code_2' => array('type' => 'CHAR(2)', 'notnull' => true, 'default' => ''), 'countries_iso_code_3' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'activation_status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1')), array('countries_name' => array('fields' => array('countries_name'))));
        }
        // Add Category description to old table version with "catid"
        // primary key only!  Fulltext indices are added when migrating
        // to core_text anyway, so don't bother with text fields here.
        $table_name = DBPREFIX . 'module_shop_categories';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'catid')) {
            Cx\Lib\UpdateUtil::table($table_name, array('catid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'parentid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'catname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'catdesc' => array('type' => 'TEXT', 'notnull' => true, 'default' => ''), 'catsorting' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '100'), 'catstatus' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'picture' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'flags' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '')), array('flags' => array('fields' => array('flags'), 'type' => 'FULLTEXT')));
        }
        // Settings table fields -- this is supposed to exist; see above
        /*        $table_name = DBPREFIX.'module_shop_config';
                if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
                    Cx\Lib\UpdateUtil::table($table_name,
                        array(
                            'id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true),
                            'name' => array('type' => 'VARCHAR(64)', 'notnull' => true, 'default' => ''),
                            'value' => array('type' => 'VARCHAR(255)', 'notnull', 'default' => ''),
                            'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'),
                        )
                    );
                }*/
        $table_name = DBPREFIX . 'module_shop_currencies';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
            $query = "\n                UPDATE `{$table_name}`\n                SET sort_order = 0 WHERE sort_order IS NULL";
            Cx\Lib\UpdateUtil::sql($query);
            // Currencies table fields
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'code' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'symbol' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'name' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'rate' => array('type' => 'DECIMAL(10,4)', 'unsigned' => true, 'notnull' => true, 'default' => '1.0000'), 'sort_order' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'is_default' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        }
        // Note that this table is migrated to access_users for version 3,
        // then dropped.
        $table_name = DBPREFIX . 'module_shop_customers';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('customerid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'username' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'password' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'prefix' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'company' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'firstname' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'lastname' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'address' => array('type' => 'VARCHAR(40)', 'notnull' => true, 'default' => ''), 'city' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'zip' => array('type' => 'VARCHAR(10)', 'notnull' => false), 'country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'phone' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'fax' => array('type' => 'VARCHAR(25)', 'notnull' => true, 'default' => ''), 'email' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'ccnumber' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'ccdate' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => ''), 'ccname' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'cvc_code' => array('type' => 'VARCHAR(5)', 'notnull' => true, 'default' => ''), 'company_note' => array('type' => 'TEXT', 'notnull' => true), 'is_reseller' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'register_date' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'customer_status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false)));
        }
        $table_name = DBPREFIX . 'module_shop_importimg';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('img_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'img_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'img_cats' => array('type' => 'TEXT', 'notnull' => true, 'default' => ''), 'img_fields_file' => array('type' => 'TEXT', 'notnull' => true, 'default' => ''), 'img_fields_db' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '')));
        }
        // Note that the following two tables are migrated to MailTemplate
        // for version 3, then dropped.
        $table_name = DBPREFIX . 'module_shop_mail';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'tplname' => array('type' => 'VARCHAR(60)', 'notnull' => true, 'default' => ''), 'protected' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        }
        $table_name = DBPREFIX . 'module_shop_mail_content';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'tpl_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'from_mail' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'xsender' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'subject' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'message' => array('type' => 'TEXT', 'notnull' => true)));
        }
        // Note:  No changes necessary; the manufacturer table will be
        // completely modified in Manufacturer::errorHandler() below.
        /*        $table_name = DBPREFIX.'module_shop_manufacturer';
                if (   Cx\Lib\UpdateUtil::table_exist($table_name)
                    && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
                    Cx\Lib\UpdateUtil::table($table_name,
                        DBPREFIX.'',
                        array(
                            'id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true),
                            'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''),
                            'url' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''),
                        )
                    );
                }*/
        $table_name = DBPREFIX . 'module_shop_order_items';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'order_items_id')) {
            Cx\Lib\UpdateUtil::table($table_name, array('order_items_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'orderid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'productid' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'product_name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'quantity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'vat_percent' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => false), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false)));
        }
        // Note: Removed field price_prefix for version 2.2; no changes since
        $table_name = DBPREFIX . 'module_shop_order_items_attributes';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'price_prefix')) {
            Cx\Lib\UpdateUtil::table($table_name, array('orders_items_attributes_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'order_items_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'product_option_name' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'product_option_value' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'product_option_values_price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00')));
        }
        $table_name = DBPREFIX . 'module_shop_orders';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'orderid')) {
            Cx\Lib\UpdateUtil::table($table_name, array('orderid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'customerid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'selected_currency_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'order_sum' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'currency_order_sum' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'order_date' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'order_status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'ship_prefix' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'ship_company' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'ship_firstname' => array('type' => 'VARCHAR(40)', 'notnull' => true, 'default' => ''), 'ship_lastname' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'ship_address' => array('type' => 'VARCHAR(40)', 'notnull' => true, 'default' => ''), 'ship_city' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'ship_zip' => array('type' => 'VARCHAR(10)', 'notnull' => false), 'ship_country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'ship_phone' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'tax_price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'currency_ship_price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'shipping_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'currency_payment_price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'customer_ip' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'customer_host' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'customer_lang' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'customer_browser' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'customer_note' => array('type' => 'TEXT'), 'last_modified' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'modified_by' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '')), array('order_status' => array('fields' => array('order_status'))));
        }
        $table_name = DBPREFIX . 'module_shop_payment';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(50)', 'notnull' => false), 'processor_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'costs' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'costs_free_sum' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'sort_order' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => false, 'default' => '0'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => false, 'default' => '1')));
        }
        // Note:  No changes (still single language in version 3)
        $table_name = DBPREFIX . 'module_shop_payment_processors';
        Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'ENUM(\'internal\',\'external\')', 'notnull' => true, 'default' => 'internal'), 'name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'description' => array('type' => 'TEXT'), 'company_url' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => false, 'default' => '1'), 'picture' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '')));
        Cx\Lib\UpdateUtil::sql('
            INSERT IGNORE INTO `' . DBPREFIX . 'module_shop_payment_processors` (`id`, `type`, `name`, `description`, `company_url`, `status`, `picture`)
            VALUES (12,"external","paymill_cc","","https://www.paymill.com",1,""),
                   (13,"external","paymill_elv","","https://www.paymill.com",1,""),
                   (14,"external","paymill_iban","","https://www.paymill.com",1,"")
        ');
        // Note:  No changes (still single language in version 3)
        $table_name = DBPREFIX . 'module_shop_pricelists';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(25)', 'notnull' => true, 'default' => ''), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'border_on' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'header_on' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'header_left' => array('type' => 'TEXT', 'notnull' => false), 'header_right' => array('type' => 'TEXT', 'notnull' => false), 'footer_on' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'footer_left' => array('type' => 'TEXT', 'notnull' => false), 'footer_right' => array('type' => 'TEXT', 'notnull' => false), 'categories' => array('type' => 'TEXT')));
        }
        $table_name = DBPREFIX . 'module_shop_products';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'title')) {
            $query = "\n                UPDATE `{$table_name}`\n                   SET `description`=''\n                 WHERE `description` IS NULL";
            if ($objDatabase->Execute($query) == false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'product_id' => array('type' => 'VARCHAR(100)'), 'picture' => array('type' => 'TEXT'), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'catid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'handler' => array('type' => 'ENUM(\'none\',\'delivery\',\'download\')', 'notnull' => true, 'default' => 'delivery'), 'normalprice' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'resellerprice' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'shortdesc' => array('type' => 'TEXT'), 'description' => array('type' => 'TEXT'), 'stock' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '10'), 'stock_visibility' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'discountprice' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'is_special_offer' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'property1' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => ''), 'property2' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => ''), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'b2b' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'b2c' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), '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'), 'thumbnail_percent' => array('type' => 'TINYINT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'thumbnail_quality' => array('type' => 'TINYINT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'manufacturer' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'manufacturer_url' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'external_link' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'sort_order' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'vat_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'flags' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'usergroups' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'article_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'keywords' => array('type' => 'TEXT')), array('group_id' => array('fields' => array('group_id')), 'article_id' => array('fields' => array('article_id')), 'shopindex' => array('fields' => array('title', 'description'), 'type' => 'FULLTEXT'), 'flags' => array('fields' => array('flags'), 'type' => 'FULLTEXT'), 'keywords' => array('fields' => array('keywords'), 'type' => 'FULLTEXT')));
        }
        // Note:  The following three tables are renamed for version 3.
        // See Attribute::errorHandler()
        $table_name = DBPREFIX . 'module_shop_products_attributes';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'attributes_name_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'attributes_value_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'sort_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        }
        $table_name = DBPREFIX . 'module_shop_products_attributes_name';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'display_type' => array('type' => 'TINYINT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        }
        $table_name = DBPREFIX . 'module_shop_products_attributes_value';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'value' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'price' => array('type' => 'DECIMAL(9,2)', 'notnull' => false, 'default' => '0.00')));
        }
        // Note:  Obsolete for a while already
        $table_name = DBPREFIX . 'module_shop_products_downloads';
        if (Cx\Lib\UpdateUtil::table_exist($table_name)) {
            Cx\Lib\UpdateUtil::drop_table($table_name);
        }
        // Note:  The id field is removed for version 3 from the following
        // three tables
        $table_name = DBPREFIX . 'module_shop_rel_countries';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'id')) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'zones_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'countries_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        }
        $table_name = DBPREFIX . 'module_shop_rel_payment';
        Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'zones_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        Cx\Lib\UpdateUtil::sql('
            INSERT IGNORE INTO `' . DBPREFIX . 'module_shop_rel_payment` (`zones_id`, `payment_id`)
            VALUES (1,16),
                   (1,17),
                   (1,18)
        ');
        // Note: This is renamed to module_shop_rel_shipper for version 3.0
        $table_name = DBPREFIX . 'module_shop_rel_shipment';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'id')) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'zones_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'shipment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        }
        $table_name = DBPREFIX . 'module_shop_vat';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'class')) {
            Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'class' => array('type' => 'TINYTEXT'), 'percent' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.00')));
        }
        $table_name = DBPREFIX . 'module_shop_zones';
        if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'zones_id')) {
            Cx\Lib\UpdateUtil::table($table_name, array('zones_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'zones_name' => array('type' => 'VARCHAR(64)', 'notnull' => true, 'default' => ''), 'activation_status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1')));
        }
        // Contrexx 3.0.0 updates from here.
        // NOTE: All of these methods return false.
        Attribute::errorHandler();
        Coupon::errorHandler();
        // Prerequisites:
        //        ShopSettings::errorHandler();
        //ShopSettings::errorHandler(); // Called by Coupon::errorHandler();Customer::errorHandler();Order::errorHandler();ShopCategory::errorHandler();
        // Prerequisites:
        //        \Cx\Core\Setting\Controller\Setting::errorHandler();
        Currency::errorHandler();
        // Prerequisites:
        //        Text::errorHandler();
        //Text::errorHandler(); // Called by Currency::errorHandler();Product::errorHandler();Payment::errorHandler();ShopCategory::errorHandler();
        Product::errorHandler();
        // Prerequisites:
        //        Text::errorHandler();
        //        Discount::errorHandler(); // Called by Customer::errorHandler();
        //        Manufacturer::errorHandler();
        // Postrequisites:
        //        Customer::errorHandler();
        //Discount::errorHandler(); // Called by Customer::errorHandler();
        //Manufacturer::errorHandler(); // Called by Product::errorHandler();
        // Prerequisites:
        //        Text::errorHandler();
        //Customer::errorHandler(); // Called by Product::errorHandler();
        // Prerequisites:
        //        ShopSettings::errorHandler();
        //        Country::errorHandler(); // Called by Order::errorHandler();
        //        Order::errorHandler(); // Calls required Country::errorHandler();
        //        Discount::errorHandler(); // Called by Product::errorHandler();
        //Order::errorHandler(); // Called by Customer::errorHandler();
        // Prerequisites:
        //        ShopSettings::errorHandler();
        //        Country::errorHandler();
        ShopMail::errorHandler();
        // Prerequisites:
        //        MailTemplate::errorHandler();
        Payment::errorHandler();
        // Prerequisites:
        //        Text::errorHandler();
        //        Zones::errorHandler();
        //        Yellowpay::errorHandler();
        //Zones::errorHandler(); // Called by Payment::errorHandler();Shipment::errorHandler();
        // Prerequisites:
        //        Text::errorHandler();
        //Yellowpay::errorHandler(); // Called by Payment::errorHandler();
        // Prerequisites:
        //        \Cx\Core\Setting\Controller\Setting::errorHandler();
        PaymentProcessing::errorHandler();
        Shipment::errorHandler();
        // Prerequisites:
        //        Zones::errorHandler();
        // TODO: Check for and resolve recursion!
        ShopCategory::errorHandler();
        // Prerequisites:
        //        Text::errorHandler();
        //        ShopSettings::errorHandler();
        Vat::errorHandler();
        // Update page templates
        // Remove
        //        [[SHOP_JAVASCRIPT_CODE]]
        Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop'), '/{SHOP_JAVASCRIPT_CODE}[\\r\\n]*/', '', array('content'), '3.0.0');
        // Replace
        // In <!-- BEGIN subCategoriesRow -->...<!-- END subCategoriesRow -->
        //    [[SHOP_PRODUCT_DETAILLINK_IMAGE]] =>
        //    index.php?section=shop[[MODULE_INDEX]]&amp;catId=[[SHOP_CATEGORY_ID]]
        Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop'), '/(<!-- *BEGIN *subCategoriesRow *-->.+?)' . '{SHOP_PRODUCT_DETAILLINK_IMAGE}' . '(.+?<!-- *END *subCategoriesRow *-->)/s', '$1index.php?section=shop{MODULE_INDEX}&amp;catId={SHOP_CATEGORY_ID}$2', array('content'), '3.0.0');
        //    [[TXT_SEE_LARGE_PICTURE]] => [[TXT_SHOP_GO_TO_CATEGORY]]
        Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop'), '/(<!-- *BEGIN *subCategoriesRow *-->.+?)' . '{TXT_SEE_LARGE_PICTURE}' . '(.+?<!-- *END *subCategoriesRow *-->)/s', '$1{TXT_SHOP_GO_TO_CATEGORY}$2', array('content'), '3.0.0');
        //    [[SHOP_PRODUCT_...]] => [[SHOP_CATEGORY_...]]
        // There may be up to nine different such placeholders!
        $subject = NULL;
        Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'shop'), '/(<!-- *BEGIN *subCategoriesRow *-->.+?)' . '{SHOP_PRODUCT_(.*?)}' . '(.+?<!-- *END *subCategoriesRow *-->)/s', function ($subject) {
            preg_replace('/{SHOP_PRODUCT_(.*?)}/', '{SHOP_CATEGORY_$1}', $subject);
        }, array('content'), '3.0.0');
        // shop/account
        // Needs to be replaced completely
        Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop', 'cmd' => 'account'), '/^.+$/s', <<<EOF
<div id="shop"><!-- BEGIN core_message -->
  <span class="{MESSAGE_CLASS}">{MESSAGE_TEXT}</span><!-- END core_message -->
  <div id="shop_acc_data">
    <form name="account" action="{SHOP_ACCOUNT_ACTION}" method="post"
          onsubmit="copy_address()" onreset="return shopReset()">
      <div class="customer_address">
        <h2>{TXT_CUSTOMER_ADDRESS}</h2>
        <div class="shop_text">
          <p><label>{TXT_COMPANY}</label>
            <input type="text" tabindex="1" name="company" value="{SHOP_ACCOUNT_COMPANY}" />
          </p>
          <p><label>{TXT_GREETING}<font color="#ff0000">&nbsp;*</font></label>
            <select tabindex="2" name="gender">{SHOP_ACCOUNT_PREFIX}</select>
          </p>
          <p><label>{TXT_SURNAME}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="3" name="lastname" value="{SHOP_ACCOUNT_LASTNAME}" />
          </p>
          <p><label>{TXT_FIRSTNAME}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="4" name="firstname" value="{SHOP_ACCOUNT_FIRSTNAME}" />
          </p>
          <p><label>{TXT_ADDRESS}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="5" name="address" value="{SHOP_ACCOUNT_ADDRESS}" />
          </p>
          <p><label>{TXT_POSTALE_CODE}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="6" name="zip" value="{SHOP_ACCOUNT_ZIP}" />
          </p>
          <p><label>{TXT_CITY}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="7" name="city" value="{SHOP_ACCOUNT_CITY}" />
          </p>
          <p><label>{TXT_COUNTRY}</label>
            <select name="countryId" id="countryId" tabindex="8">
            {SHOP_ACCOUNT_COUNTRY_MENUOPTIONS}
            </select>
          </p>
          <p><label>{TXT_PHONE_NUMBER}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="9" name="phone" value="{SHOP_ACCOUNT_PHONE}" />
          </p>
          <p><label>{TXT_FAX_NUMBER}</label>
            <input type="text" tabindex="10" name="fax" value="{SHOP_ACCOUNT_FAX}" />
          </p>
        </div>
      </div><!-- BEGIN shipping_address -->
      <div class="shipping_address">
        <h2>{TXT_SHIPPING_ADDRESS}</h2>
        <p><input type="checkbox" tabindex="21" value="1" onclick="copy_address();"
          id="equal_address" name="equal_address" {SHOP_EQUAL_ADDRESS_CHECKED} />
          <label class="description" for="equal_address">{TXT_SAME_BILLING_ADDRESS}</label>
        </p>
      </div>
      <div id="shipping_address" style="display: {SHOP_EQUAL_ADDRESS_DISPLAY};">
        <div class="shop_text">
          <p><label>{TXT_COMPANY}</label>
            <input type="text" tabindex="31" name="company2" value="{SHOP_ACCOUNT_COMPANY2}" />
          </p>
          <p><label>{TXT_GREETING}<font color="#ff0000">&nbsp;*</font></label>
            <select tabindex="32" name="gender2">{SHOP_ACCOUNT_PREFIX2}</select>
          </p>
          <p><label>{TXT_SURNAME}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="33" name="lastname2" value="{SHOP_ACCOUNT_LASTNAME2}" />
          </p>
          <p><label>{TXT_FIRSTNAME}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="34" name="firstname2" value="{SHOP_ACCOUNT_FIRSTNAME2}" />
          </p>
          <p><label>{TXT_ADDRESS}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="35" name="address2" value="{SHOP_ACCOUNT_ADDRESS2}" />
          </p>
          <p><label>{TXT_POSTALE_CODE}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="36" name="zip2" value="{SHOP_ACCOUNT_ZIP2}" size="6" />
          </p>
          <p><label>{TXT_CITY}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="37" name="city2" value="{SHOP_ACCOUNT_CITY2}" />
          </p>
          <p><label>{TXT_COUNTRY}</label>
            <input type="hidden" name="countryId2" id="countryId2" value="{SHOP_ACCOUNT_COUNTRY2_ID}" />{SHOP_ACCOUNT_COUNTRY2}
          </p>
          <p><label>{TXT_PHONE_NUMBER}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="38" name="phone2" value="{SHOP_ACCOUNT_PHONE2}" />
          </p>
        </div>
      </div><!-- END shipping_address --><!-- BEGIN account_details -->
      <div class="account_details">
        <h2>{TXT_YOUR_ACCOUNT_DETAILS}</h2><!-- BEGIN dont_register -->
        <p>
          <input type="checkbox" tabindex="61" value="1" id="dont_register"
                 name="dont_register" {SHOP_DONT_REGISTER_CHECKED}
                 onClick="document.getElementById('account_password').style.display = (this.checked ? 'none' : 'block');" />
          <label class="description" for="dont_register">{TXT_SHOP_ACCOUNT_DONT_REGISTER}</label>
          <br />
          {TXT_SHOP_ACCOUNT_DONT_REGISTER_NOTE}
        </p><!-- END dont_register -->
        <div class="shop_text">
          <p>
            <label>{TXT_EMAIL}<font color="#ff0000">&nbsp;*</font></label>
            <input type="text" tabindex="51" name="email" value="{SHOP_ACCOUNT_EMAIL}" />
          </p>
          <div id="account_password" style="{SHOP_ACCOUNT_PASSWORD_DISPLAY};">
            <p>
              <label>{TXT_PASSWORD}<font color="#ff0000">&nbsp;*</font></label>
              <input type="password" tabindex="52" name="password" value="" />
            </p>
            <p>{TXT_SHOP_ACCOUNT_PASSWORD_HINT}</p>
          </div>
        </div>
      </div><!-- END account_details -->
      <p>
        <input type="reset" value="{TXT_RESET}" name="reset" tabindex="71" />
        <input type="submit" value="{TXT_SHOP_CONTINUE_ARROW}" name="bsubmit" tabindex="72" />
      </p>
    </form>
  </div>
</div>
<script type="text/javascript">//<![CDATA[
function copy_address() {
  with (document.account) {
    if (jQuery("#equal_address:checked").length) {
      gender2.value = gender.value;
      company2.value = company.value;
      lastname2.value = lastname.value;
      firstname2.value = firstname.value;
      address2.value = address.value;
      zip2.value = zip.value;
      city2.value = city.value;
      phone2.value = phone.value;
      countryId2.value = countryId.value;
      jQuery("#shipping_address").hide();
    } else {
      jQuery("#shipping_address").show();
// Optionally clear the shipment address
//      gender2.value = "";
//      company2.value = "";
//      lastname2.value = "";
//      firstname2.value = "";
//      address2.value = "";
//      zip2.value = "";
//      city2.value = "";
//      phone2.value = "";
    }
  }
}
jQuery(function () {
  jQuery(".customer_address").delegate("input", "blur", function() {
    if (jQuery("#equal_address:checked").length) {
      copy_address();
    }
  });
});
// Redisplay the shipping address after the reset button has been clicked
function shopReset()
{
  if (!confirm("{TXT_SHOP_FORM_RESET_CONFIRM}")) {
    return false;
  }
  jQuery("#shipping_address").show();
  return true;
}
copy_address();
//}></script>
EOF
, array('content'), '3.0.0');
        // shop/login
        // Needs to be replaced completely
        Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop', 'cmd' => 'login'), '/^.+$/s', <<<EOF
<div id="shop">
  <!-- BEGIN core_message -->
  <span class="{MESSAGE_CLASS}">{MESSAGE_TEXT}</span>
  <!-- END core_message -->
  <div class="customer_old">
    <form name="shop_login" action="index.php?section=login" method="post">
      <input name="redirect" type="hidden" value="{SHOP_LOGIN_REDIRECT}" />
      <h2>{TXT_SHOP_ACCOUNT_EXISTING_CUSTOMER}</h2>
      <p>
        <label for="username">{TXT_SHOP_EMAIL_ADDRESS}</label>
        <input type="text" maxlength="250" value="{SHOP_LOGIN_EMAIL}" id="username" name="USERNAME" />
      </p>
      <p>
        <label for="password">{TXT_SHOP_PASSWORD}</label>
        <input type="password" maxlength="50" id="password" name="PASSWORD" />
      </p>
      <p>
        <input type="submit" value="{TXT_SHOP_ACCOUNT_LOGIN}" name="login" />
      </p>
      <p>
        <a class="lostpw" href="index.php?section=login&amp;cmd=lostpw" title="{TXT_SHOP_ACCOUNT_LOST_PASSWORD}">
        {TXT_SHOP_ACCOUNT_LOST_PASSWORD}
        </a>
      </p>
    </form>
  </div>
  <div class="customer_new">
    <form name="shop_register" action="index.php?section=shop&amp;cmd=login" method="post">
      <h2>{TXT_SHOP_ACCOUNT_NEW_CUSTOMER}</h2>
      {TXT_SHOP_ACCOUNT_NOTE}<br />
      <br />
      <!-- BEGIN register -->
      <input type="submit" value="{TXT_SHOP_BUTTON_REGISTRATION}" name="baccount" />
      <!-- END register -->
      <!-- BEGIN dont_register -->
      <input type="submit" value="{TXT_SHOP_BUTTON_NO_REGISTRATION}" name="bnoaccount" />
      <!-- END dont_register -->
    </form>
  </div>
</div>
EOF
, array('content'), '3.0.0');
        // Note:  Other templates may contain new placeholders and/or blocks,
        // however, these need to be added manually for version 3.0.0 features
        // to work.
    } catch (Cx\Lib\UpdateException $e) {
        return Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    //update settingsDB for missing values
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) {
        try {
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`)
                                    VALUES (\'shop\', \'orderitems_amount_min\', \'config\', \'text\', \'0\')');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    // add access id 4 for user groups which had access to 13 or 161
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        try {
            $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 13 OR access_id = 161 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 (4, " . intval($result->fields['group_id']) . ")");
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    try {
        // add some necessary buttons to the confirmation page
        // fix of http://bugs.contrexx.com/contrexx/ticket/2015
        Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'shop', 'cmd' => 'confirm'), '/.*/s', function ($content) {
            $content .= '<a href="{NODE_SHOP_ACCOUNT}">{TXT_ORDER_BACK_TO_ACCOUNT}</a><br />
                             <a href="{NODE_SHOP_CART}">{TXT_ORDER_BACK_TO_CART}</a>';
        }, array('content'), '3.2.0');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        $queries = array('INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","payment_lsv_active","config","text","1","",18)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_active","config","text","1","",3)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_live_private_key","config","text","","",0)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_live_public_key","config","text","","",0)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_live_public_key","config","text","","",0)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_test_private_key","config","text","","",2)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_test_public_key","config","text","","",16)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_use_test_account","config","text","0","",15)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES (\'shop\',\'orderitems_amount_min\',\'config\',\'text\',\'0\',\'\',0);');
        foreach ($queries as $query) {
            \Cx\Lib\UpdateUtil::sql($query);
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Example #27
0
/**
 * 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 _forumUpdate()
{
    global $objDatabase, $_ARRAYLANG;
    $arrSettings = array('9' => array('name' => 'banned_words', 'value' => 'penis enlargement,free p**n,(?i:buy\\\\s*?(?:cheap\\\\s*?)?viagra)'), '10' => array('name' => 'wysiwyg_editor', 'value' => '1'), '11' => array('name' => 'tag_count', 'value' => '10'), '12' => array('name' => 'latest_post_per_thread', 'value' => '1'), '13' => array('name' => 'allowed_extensions', 'value' => '7z,aiff,asf,avi,bmp,csv,doc,fla,flv,gif,gz,gzip, jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf, png,ppt,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf, sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xml ,zip'));
    $arrTables = $objDatabase->MetaTables();
    $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . "module_forum_postings");
    if (!in_array('rating', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` ADD `rating` INT NOT NULL DEFAULT '0' AFTER `is_sticky`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('keywords', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` ADD `keywords` TEXT NOT NULL AFTER `icon`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    $arrIndexes = $objDatabase->MetaIndexes(DBPREFIX . "module_forum_postings");
    if (is_array($arrIndexes['fulltext'])) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` DROP INDEX `fulltext`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    $query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` ADD FULLTEXT `fulltext` (\n                `keywords`,\n                `subject`,\n                `content`\n                );";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    if (!in_array('attachment', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` ADD `attachment` VARCHAR(250) NOT NULL DEFAULT '' AFTER `content`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    foreach ($arrSettings as $id => $arrSetting) {
        $query = "SELECT 1 FROM `" . DBPREFIX . "module_forum_settings` WHERE `name`= '" . $arrSetting['name'] . "'";
        if (($objRS = $objDatabase->Execute($query)) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
        if ($objRS->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_forum_settings`\n                             (`id`, `name`, `value`)\n                      VALUES (" . $id . ", '" . $arrSetting['name'] . "', '" . addslashes($arrSetting['value']) . "')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_forum_rating', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'user_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'post_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'time' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0')), array('user_id' => array('fields' => array('user_id', 'post_id'))));
    } 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;
            }
            // replace message textarea with {FORUM_MESSAGE_INPUT}
            $content = preg_replace('/<textarea[^>]+name\\s*=\\s*[\'"]message[\'"][^>]*>.*?\\{FORUM_MESSAGE\\}.*?<\\/textarea>/ms', '{FORUM_MESSAGE_INPUT}', $content);
            if (!preg_match('/<!--\\s+BEGIN\\s+captcha\\s+-->.*<!--\\s+END\\s+captcha\\s+-->/ms', $content)) {
                // migration for versions < 2.0
                // add missing template block captcha
                $content = preg_replace('/(.*)(<tr[^>]*>.*?<td[^>]*>.*?\\{FORUM_CAPTCHA_IMAGE_URL\\}.*?<\\/td>.*?<\\/tr>)/ms', '$1<!-- BEGIN captcha -->$2<!-- END captcha -->', $content);
            }
            // add missing placeholder {FORUM_JAVASCRIPT_SCROLLTO}
            if (strpos($content, '{FORUM_JAVASCRIPT_SCROLLTO}') === false) {
                $content = '{FORUM_JAVASCRIPT_SCROLLTO}' . $content;
            }
            // hide deprecated marckup buttons
            $content = preg_replace('/(<!--\\s+)?(<input[^>]+onclick\\s*=\\s*[\'"]\\s*addText\\([^>]+>)(?:\\s+-->)?/ms', '<!-- $2 -->', $content);
            // replace image with {FORUM_CAPTCHA_CODE}
            $content = preg_replace('/(<!--\\s+BEGIN\\s+captcha\\s+-->.*)<img[^>]+\\{FORUM_CAPTCHA_IMAGE_URL\\}[^>]+>(?:<br\\s*\\/?>)?(.*<!--\\s+END\\s+captcha\\s+-->)/ms', '$1{FORUM_CAPTCHA_CODE}$2', $content);
            // replace text "Captcha-Code" with {TXT_FORUM_CAPTCHA}
            $content = preg_replace('/(<!--\\s+BEGIN\\s+captcha\\s+-->.*)Captcha-Code:?(.*<!--\\s+END\\s+captcha\\s+-->)/ms', '$1{TXT_FORUM_CAPTCHA}$2', $content);
            // remove <input type="text" name="captcha" id="captcha" />
            $content = preg_replace('/(<!--\\s+BEGIN\\s+captcha\\s+-->.*)<input[^>]+name\\s*=\\s*[\'"]captcha[\'"][^>]*>(.*<!--\\s+END\\s+captcha\\s+-->)/ms', '$1$2', $content);
            // remove <input type="hidden" name="offset" value="[[FORUM_CAPTCHA_OFFSET]]" />
            $content = preg_replace('/(<!--\\s+BEGIN\\s+captcha\\s+-->.*)<input[^>]+name\\s*=\\s*[\'"]offset[\'"][^>]*>(.*<!--\\s+END\\s+captcha\\s+-->)/ms', '$1$2', $content);
            // add missing block threadActions
            if (!preg_match('/<!--\\s+BEGIN\\s+threadActions\\s+-->.*<!--\\s+END\\s+threadActions\\s+-->/ms', $content)) {
                $threadActionHtml = <<<FORUM
<!-- BEGIN threadActions --><br />
    <span style="color: rgb(255, 0, 0);">{TXT_THREAD_ACTION_ERROR}&nbsp;</span><br />
    <span style="color: #006900;">{TXT_THREAD_ACTION_SUCCESS}&nbsp;</span> <!-- BEGIN moveForm -->
    <form action="index.php?section=forum&amp;cmd=thread&amp;action=move&amp;id={FORUM_THREAD_ID}" method="POST" name="frmThreadMove">
        <select name="moveToThread" size="32" style="width:225px;"> {FORUM_THREADS} </select><br />
        <input type="submit" value="{TXT_FORUM_THREAD_ACTION_MOVE}" />&nbsp;</form>
    <!-- END moveForm --><!-- END threadActions -->
FORUM;
                $content = preg_replace('/(<!--\\s+END\\s+addPost\\s+-->)/ms', '$1' . $threadActionHtml, $content);
            }
            return $content;
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'forum'), $search, $callback, array('content'), '3.0.1');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Example #28
0
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;
}