예제 #1
0
파일: market.php 프로젝트: Niggu/cloudrexx
/**
 * 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;
}
예제 #2
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;
}
예제 #3
0
파일: voting.php 프로젝트: Niggu/cloudrexx
/**
 * 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 _votingUpdate()
{
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'voting_system', array('id' => array('type' => 'INT', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'date' => array('type' => 'TIMESTAMP', 'notnull' => true, 'default_expr' => 'CURRENT_TIMESTAMP'), 'title' => array('type' => 'VARCHAR(60)', 'notnull' => true, 'default' => '', 'renamefrom' => 'name'), 'question' => array('type' => 'TEXT', 'notnull' => false), 'status' => array('type' => 'TINYINT(1)', 'notnull' => false, 'default' => 1), 'votes' => array('type' => 'INT(11)', 'notnull' => false, 'default' => 0), 'submit_check' => array('type' => "ENUM('cookie','email')", 'notnull' => true, 'default' => 'cookie'), 'additional_nickname' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0), 'additional_forename' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0), 'additional_surname' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0), 'additional_phone' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0), 'additional_street' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0), 'additional_zip' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0), 'additional_email' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0), 'additional_city' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0), 'additional_comment' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'voting_additionaldata', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'nickname' => array('type' => 'VARCHAR(80)', 'notnull' => true, 'default' => '', 'renamefrom' => 'name'), 'surname' => array('type' => 'VARCHAR(80)', 'notnull' => true, 'default' => ''), 'phone' => array('type' => 'VARCHAR(80)', 'notnull' => true, 'default' => ''), 'street' => array('type' => 'VARCHAR(80)', 'notnull' => true, 'default' => ''), 'zip' => array('type' => 'VARCHAR(30)', 'notnull' => true, 'default' => ''), 'city' => array('type' => 'VARCHAR(80)', 'notnull' => true, 'default' => ''), 'email' => array('type' => 'VARCHAR(80)', 'notnull' => true, 'default' => ''), 'comment' => array('type' => 'TEXT', 'after' => 'email'), 'voting_system_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'renamefrom' => 'voting_sytem_id'), 'date_entered' => array('type' => 'TIMESTAMP', 'notnull' => true, 'default_expr' => 'CURRENT_TIMESTAMP', 'on_update' => 'CURRENT_TIMESTAMP'), 'forename' => array('type' => 'VARCHAR(80)', 'notnull' => true, 'default' => '')), array('voting_system_id' => array('fields' => array('voting_system_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'voting_email', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'email' => array('type' => 'VARCHAR(255)'), 'valid' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0')), array('email' => array('fields' => array('email'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'voting_rel_email_system', array('email_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'system_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'voting_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'valid' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0')), array('email_id' => array('fields' => array('email_id', 'system_id'), 'type' => 'UNIQUE')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
예제 #4
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;
    try {
        \Cx\Lib\UpdateUtil::sql("UPDATE " . DBPREFIX . "module_downloads_download_locale l SET\n              l.source = (SELECT source FROM " . DBPREFIX . "module_downloads_download d WHERE d.id = l.download_id),\n              l.source_name = (SELECT source_name FROM " . DBPREFIX . "module_downloads_download d WHERE d.id = l.download_id);");
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_download', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true), 'type' => array('type' => 'ENUM(\'file\',\'url\')', 'notnull' => true, 'default' => 'file', 'after' => 'id'), 'mime_type' => array('type' => 'ENUM(\'image\',\'document\',\'pdf\',\'media\',\'archive\',\'application\',\'link\')', 'notnull' => true, 'default' => 'image', 'after' => 'type'), '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', 'after' => 'source_name'), 'size' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'icon'), 'image' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'size'), 'owner_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'image'), 'access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'owner_id'), 'license' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'access_id'), 'version' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => '', 'after' => 'license'), 'author' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'version'), 'website' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'author'), 'ctime' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'website'), 'mtime' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'ctime'), 'is_active' => array('type' => 'TINYINT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'mtime'), 'visibility' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'is_active'), 'order' => array('type' => 'INT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'visibility'), 'views' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'order'), 'download_count' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'views'), 'expiration' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'download_count'), 'validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'expiration')), array('is_active' => array('fields' => array('is_active')), 'visibility' => array('fields' => array('visibility'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_download_locale', array('lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'download_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'lang_id'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'download_id'), 'source' => array('type' => 'VARCHAR(255)', 'after' => 'name'), 'source_name' => array('type' => 'VARCHAR(255)', 'after' => 'source'), 'description' => array('type' => 'text', 'after' => 'source_name')), array('name' => array('fields' => array('name'), 'type' => 'FULLTEXT'), 'description' => array('fields' => array('description'), 'type' => 'FULLTEXT')));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
예제 #5
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;
}
예제 #6
0
파일: crm.php 프로젝트: nahakiole/cloudrexx
function _crmInstall()
{
    try {
        $result = \Cx\Lib\UpdateUtil::sql('SELECT `id` FROM `' . DBPREFIX . 'core_text` WHERE `section` = \'crm\'');
        if (!$result || $result->RecordCount() == 0) {
            // add core mail template table because it is possible it doesn't yet exist
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'core_mail_template', array('key' => array('type' => 'tinytext'), 'section' => array('type' => 'tinytext', 'after' => 'key'), 'text_id' => array('type' => 'INT(10)', 'unsigned' => true, 'after' => 'section'), 'html' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'text_id'), 'protected' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'html')), null, 'MyISAM', 'cx3upgrade');
            Cx\Lib\UpdateUtil::sql("\n                ALTER TABLE `" . DBPREFIX . "core_mail_template`\n                ADD PRIMARY KEY (`key` (32), `section` (32))\n            ");
            // migrate mail templates
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_bcc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_cc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_from\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_message\', \'Guten Tag,\\r\\n\\r\\nNachfolgend erhalten Sie Ihre persönlichen Zugangsdaten zur Website http://www.example.com/\\r\\n\\r\\nBenutzername: [CRM_CONTACT_USERNAME]\\r\\nKennwort: [CRM_CONTACT_PASSWORD]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_message_html\', \'<div>Guten Tag,<br />\\r\\n<br />\\r\\nNachfolgend erhalten Sie Ihre pers&ouml;nlichen Zugangsdaten zur Website <a href="http://www.example.com/">http://www.example.com/</a><br />\\r\\n<br />\\r\\nBenutzername: [CRM_CONTACT_USERNAME]<br />\\r\\nKennwort: [CRM_CONTACT_PASSWORD]</div>\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_name\', \'Benachrichtigung über Benutzerkonto\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_reply\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_sender\', \'Ihr Firmenname\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_subject\', \'Ihr persönlischer Zugang\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_to\', \'[CRM_CONTACT_EMAIL]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_bcc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_cc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_from\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_message\', \'Der Mitarbeiter [CRM_TASK_CREATED_USER] hat eine neue Aufgabe erstellt und Ihnen zugewiesen: [CRM_TASK_URL]\\r\\n\\r\\nBeschreibung: [CRM_TASK_DESCRIPTION_TEXT_VERSION]\\r\\n\\r\\nFällig am: [CRM_TASK_DUE_DATE]\\r\\n\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_message_html\', \'<div style="padding:0px; margin:0px; font-family:Tahoma, sans-serif; font-size:14px; width:620px; color: #333;">\\r\\n<div style="padding: 0px 20px; border:1px solid #e0e0e0; margin-bottom: 10px; width:618px;">\\r\\n<h1 style="background-color: #e0e0e0;color: #3d4a6b;font-size: 18px;font-weight: normal;padding: 15px 20px;margin-top: 0 !important;margin-bottom: 0 !important;margin-left: -20px !important;margin-right: -20px !important;-webkit-margin-before: 0 !important;-webkit-margin-after: 0 !important;-webkit-margin-start: -20px !important;-webkit-margin-end: -20px !important;">Neue Aufgabe wurde Ihnen zugewiesen</h1>\\r\\n\\r\\n<p style="margin-top: 20px;word-wrap: break-word !important;">Der Mitarbeiter [CRM_TASK_CREATED_USER] hat eine neue Aufgabe erstellt und Ihnen zugewiesen: [CRM_TASK_LINK]</p>\\r\\n\\r\\n<p style="margin-top: 20px;word-wrap: break-word !important;">Beschreibung: [CRM_TASK_DESCRIPTION_HTML_VERSION]<br />\\r\\nF&auml;llig am: [CRM_TASK_DUE_DATE]</p>\\r\\n</div>\\r\\n</div>\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_name\', \'Neue Aufgabe\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_reply\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_sender\', \'Ihr Firmenname\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_subject\', \'Neue Aufgabe : [CRM_TASK_NAME]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_to\', \'[CRM_ASSIGNED_USER_EMAIL]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_bcc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_cc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_from\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_message\', \'Im CRM wurde ein neuer Kontakt erfasst: [CRM_CONTACT_DETAILS_URL]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_message_html\', \'<div style="padding:0px; margin:0px; font-family:Tahoma, sans-serif; font-size:14px; width:620px; color: #333;">\\r\\n<div style="padding: 0px 20px; border:1px solid #e0e0e0; margin-bottom: 10px; width:618px;">\\r\\n<h1 style="background-color: #e0e0e0;color: #3d4a6b;font-size: 18px;font-weight: normal;padding: 15px 20px;margin-top: 0 !important;margin-bottom: 0 !important;margin-left: -20px !important;margin-right: -20px !important;-webkit-margin-before: 0 !important;-webkit-margin-after: 0 !important;-webkit-margin-start: -20px !important;-webkit-margin-end: -20px !important;">Neuer Kontakt im CRM</h1>\\r\\n\\r\\n<p style="margin-top: 20px;word-wrap: break-word !important;">Neuer Kontakt: [CRM_CONTACT_DETAILS_LINK].</p>\\r\\n</div>\\r\\n</div>\\r\\n\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_name\', \'Benachrichtigung an Mitarbeiter über neue Kontakte\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_reply\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_sender\', \'Ihr Firmenname\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_subject\', \'Neuer Kontakt erfasst\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_to\', \'[CRM_ASSIGNED_USER_EMAIL]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_mail_template` (`key`, `section`, `text_id`, `html`, `protected`) VALUES(\'crm_user_account_created\', \'crm\', 12, 1, 1)');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_mail_template` (`key`, `section`, `text_id`, `html`, `protected`) VALUES(\'crm_notify_staff_on_contact_added\', \'crm\', 14, 1, 1)');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_mail_template` (`key`, `section`, `text_id`, `html`, `protected`) VALUES(\'crm_task_assigned\', \'crm\', 13, 1, 1)');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES (\'crm\',\'numof_mailtemplate_per_page_backend\',\'config\',\'text\',\'25\',\'\',1001)');
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
}
예제 #7
0
파일: u2u.php 프로젝트: nahakiole/cloudrexx
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;
}
예제 #8
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;
}
예제 #9
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;
}
예제 #10
0
파일: jobs.php 프로젝트: Niggu/cloudrexx
/**
 * 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;
}
예제 #11
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 _media1Update()
{
    global $_ARRAYLANG, $_CORELANG;
    /*    require_once ASCMS_FRAMEWORK_PATH.'/File.class.php';
        $objFile = new File();
    
        $paths = glob(ASCMS_DOCUMENT_ROOT.'/media/archive*');
        foreach ($paths as $path) {
            $path = "$path/";
            $web_path = preg_replace("#".ASCMS_DOCUMENT_ROOT."/media/#", ASCMS_PATH_OFFSET . '/media/', $path);
            $status = $objFile->delFile($path, $web_path, '.htaccess');
    
            if ($status == 'error') {
                setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], "<pre>$web_path</pre>", $_CORELANG['TXT_UPDATE_TRY_AGAIN']));
                return false;
            }
            }*/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_media_settings', array('name' => array('type' => 'VARCHAR(50)'), 'value' => array('type' => 'VARCHAR(250)', 'after' => 'name')), array('name' => array('fields' => array('name'))), 'InnoDB');
        $arrValues = array(array("media1_frontend_changable", "off"), array("media2_frontend_changable", "off"), array("media3_frontend_changable", "off"), array("media4_frontend_changable", "off"), array("media1_frontend_managable", "off"), array("media2_frontend_managable", "off"), array("media3_frontend_managable", "off"), array("media4_frontend_managable", "off"));
        for ($i = 0; $i < count($arrValues); $i++) {
            $rs = \Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_media_settings WHERE name="' . $arrValues[$i][0] . '";');
            if ($rs->EOF) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO ' . DBPREFIX . 'module_media_settings VALUES ("' . $arrValues[$i][0] . '","' . $arrValues[$i][1] . '")');
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $arrContentSites = array('media1', 'media2', 'media3', 'media4');
    // replace source url to image
    foreach ($arrContentSites as $module) {
        try {
            \Cx\Lib\UpdateUtil::migrateContentPage($module, '', 'images/modules/media/_base.gif', 'core_modules/media/View/Media/_base.gif', '3.1.2');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
예제 #12
0
function _filesharingUpdate()
{
    try {
        /*********************************
         * EXTENSION:   Initial creation *
         * ADDED:       Contrexx v3.0.0  *
         *********************************/
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_filesharing', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'file' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'after' => 'id'), 'source' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'after' => 'file'), 'cmd' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'after' => 'source'), 'hash' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'after' => 'cmd'), 'check' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'after' => 'hash'), 'expiration_date' => array('type' => 'TIMESTAMP', 'notnull' => false, 'default' => NULL, 'after' => 'check'), 'upload_id' => array('type' => 'INT(10)', 'notnull' => false, 'default' => NULL, 'after' => 'expiration_date')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_filesharing_mail_template', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'lang_id' => array('type' => 'INT(1)', 'notnull' => true, 'after' => 'id'), 'subject' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'after' => 'lang_id'), 'content' => array('type' => 'TEXT', 'notnull' => true, 'after' => 'subject')));
        \Cx\Lib\UpdateUtil::sql('
            INSERT INTO `' . DBPREFIX . 'module_filesharing_mail_template` (`id`, `lang_id`, `subject`, `content`)
            VALUES  (1, 1, "Jemand teilt eine Datei mit Ihnen", "Guten Tag,\\r\\n\\r\\nJemand hat auf [[DOMAIN]] eine Datei mit Ihnen geteilt.\\r\\n\\r\\n<!-- BEGIN filesharing_file -->\\r\\nDownload-Link: [[FILE_DOWNLOAD]]\\r\\n<!-- END filesharing_file -->\\r\\n\\r\\nDie Person hat eine Nachricht hinterlassen:\\r\\n[[MESSAGE]]\\r\\n\\r\\nFreundliche Grüsse"),
                    (2, 2, "Somebody is sharing a file with you", "Hi,\\r\\n\\r\\nSomebody shared a file with you on [[DOMAIN]].\\r\\n\\r\\n<!-- BEGIN filesharing_file -->\\r\\nDownload link: [[FILE_DOWNLOAD]]\\r\\n<!-- END filesharing_file -->\\r\\n\\r\\nThe person has left a message for you:\\r\\n[[MESSAGE]]\\r\\n\\r\\nBest regards")
            ON DUPLICATE KEY UPDATE `id` = `id`
        ');
        \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`)
                                    VALUES (\'filesharing\',\'permission\',\'config\',\'text\',\'off\',\'\',0)');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
}
예제 #13
0
function _memberdirUpdate()
{
    global $objDatabase, $_ARRAYLANG, $_CORELANG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_directories', array('dirid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parentdir' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '1'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'description' => array('type' => 'TEXT'), 'displaymode' => array('type' => 'SET(\'0\',\'1\',\'2\')', 'notnull' => true, 'default' => '0'), 'sort' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '1'), 'pic1' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '0'), 'pic2' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')), array('memberdir_dir' => array('fields' => array('name', 'description'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_name', array('field' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'dirid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'active' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => ''), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_settings', array('setid' => array('type' => 'INT(4)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'setname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'setvalue' => array('type' => 'TEXT'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_values', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'dirid' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'pic1' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'pic2' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), '0' => array('type' => 'SMALLINT(5)', 'notnull' => true, 'unsigned' => true, 'default' => '0'), '1' => array('type' => 'TEXT'), '2' => array('type' => 'TEXT'), '3' => array('type' => 'TEXT'), '4' => array('type' => 'TEXT'), '5' => array('type' => 'TEXT'), '6' => array('type' => 'TEXT'), '7' => array('type' => 'TEXT'), '8' => array('type' => 'TEXT'), '9' => array('type' => 'TEXT'), '10' => array('type' => 'TEXT'), '11' => array('type' => 'TEXT'), '12' => array('type' => 'TEXT'), '13' => array('type' => 'TEXT'), '14' => array('type' => 'TEXT'), '15' => array('type' => 'TEXT'), '16' => array('type' => 'TEXT'), '17' => array('type' => 'TEXT'), '18' => array('type' => 'TEXT'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')));
        $arrSettings = array('default_listing' => array('1', '1'), 'max_height' => array('400', '1'), 'max_width' => array('500', '1'));
        foreach ($arrSettings as $key => $arrSetting) {
            if (!\Cx\Lib\UpdateUtil::sql("SELECT 1 FROM `" . DBPREFIX . "module_memberdir_settings` WHERE `setname` = '" . $key . "'")->RecordCount()) {
                \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "module_memberdir_settings`\n                    SET `setname`    = '" . $key . "',\n                        `setvalue`   = '" . $arrSetting[0] . "',\n                        `lang_id`    = '" . $arrSetting[1] . "'\n                ");
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_MEDIA_PATH . '/memberdir')) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_MEDIA_PATH . '/memberdir/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        return false;
    }
    return true;
}
예제 #14
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 _checkoutUpdate()
{
    try {
        /*********************************
         * EXTENSION:   Initial creation *
         * ADDED:       Contrexx v3.0.0  *
         *********************************/
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_checkout_settings_general', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'after' => 'id'), 'value' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'name')));
        \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_checkout_settings_general` (`id`, `name`, `value`) VALUES (1, "epayment_status", 1) ON DUPLICATE KEY UPDATE `id` = `id`');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_checkout_settings_mails', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'title' => array('type' => 'TEXT', 'notnull' => true, 'after' => 'id'), 'content' => array('type' => 'TEXT', 'notnull' => true, 'after' => 'title')));
        \Cx\Lib\UpdateUtil::sql('
            INSERT INTO `' . DBPREFIX . 'module_checkout_settings_mails` (`id`, `title`, `content`)
            VALUES  (1, "[[DOMAIN_URL]] - Neue Zahlung", "Guten Tag<br />\\r\\n<br />\\r\\nAuf [[DOMAIN_URL]] wurde eine neue Zahlung abgewickelt:<br />\\r\\n<br />\\r\\n<table border=\\"0\\" cellpadding=\\"0\\" cellspacing=\\"0\\">\\r\\n    <tbody>\\r\\n        <tr>\\r\\n            <td colspan=\\"2\\" nowrap=\\"nowrap\\" width=\\"150\\">\\r\\n                <strong>Angaben zur Transaktion</strong></td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td width=\\"150\\">\\r\\n                ID</td>\\r\\n            <td>\\r\\n                [[TRANSACTION_ID]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Status</td>\\r\\n            <td>\\r\\n                [[TRANSACTION_STATUS]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Datum und Uhrzeit</td>\\r\\n            <td>\\r\\n                [[TRANSACTION_TIME]]</td>\\r\\n        </tr>\\r\\n    </tbody>\\r\\n</table>\\r\\n<br />\\r\\n<table border=\\"0\\" cellpadding=\\"0\\" cellspacing=\\"0\\">\\r\\n    <tbody>\\r\\n        <tr>\\r\\n            <td colspan=\\"2\\" nowrap=\\"nowrap\\" width=\\"150\\">\\r\\n                <strong>Angaben zur beglichenen Rechnung</strong></td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td width=\\"150\\">\\r\\n                Nummer</td>\\r\\n            <td>\\r\\n                [[INVOICE_NUMBER]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Betrag</td>\\r\\n            <td>\\r\\n                [[INVOICE_AMOUNT]] [[INVOICE_CURRENCY]]</td>\\r\\n        </tr>\\r\\n    </tbody>\\r\\n</table>\\r\\n<br />\\r\\n<table border=\\"0\\" cellpadding=\\"0\\" cellspacing=\\"0\\">\\r\\n    <tbody>\\r\\n        <tr>\\r\\n            <td colspan=\\"2\\" nowrap=\\"nowrap\\" width=\\"150\\">\\r\\n                <strong>Angaben zur Kontaktperson</strong></td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td width=\\"150\\">\\r\\n                Anrede</td>\\r\\n            <td>\\r\\n                [[CONTACT_TITLE]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Vorname</td>\\r\\n            <td>\\r\\n                [[CONTACT_FORENAME]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Nachname</td>\\r\\n            <td>\\r\\n                [[CONTACT_SURNAME]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Firma</td>\\r\\n            <td>\\r\\n                [[CONTACT_COMPANY]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Strasse</td>\\r\\n            <td>\\r\\n                [[CONTACT_STREET]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                PLZ</td>\\r\\n            <td>\\r\\n                [[CONTACT_POSTCODE]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Ort</td>\\r\\n            <td>\\r\\n                [[CONTACT_PLACE]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Land</td>\\r\\n            <td>\\r\\n                [[CONTACT_COUNTRY]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Telefon</td>\\r\\n            <td>\\r\\n                [[CONTACT_PHONE]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                E-Mail-Adresse</td>\\r\\n            <td>\\r\\n                <a href=\\"[[CONTACT_EMAIL]]?csrf=ODg4MTM2Nzg1&amp;csrf=NDQzMzAwNjE0\\">[[CONTACT_EMAIL]]</a></td>\\r\\n        </tr>\\r\\n    </tbody>\\r\\n</table>\\r\\n<br />\\r\\nFreundliche Gr&uuml;sse<br />\\r\\nDas [[DOMAIN_URL]]&nbsp;Team"),
                    (2, "[[DOMAIN_URL]] - Zahlungsbestätigung", "Guten Tag<br />\\r\\n<br />\\r\\nGerne best&auml;tigen wir die erfolgreiche Abwicklung folgender Zahlung auf [[DOMAIN_URL]]:<br />\\r\\n<br />\\r\\n<table border=\\"0\\" cellpadding=\\"0\\" cellspacing=\\"0\\">\\r\\n    <tbody>\\r\\n        <tr>\\r\\n            <td colspan=\\"2\\" nowrap=\\"nowrap\\" width=\\"150\\">\\r\\n                <strong>Angaben zur Transaktion</strong></td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td width=\\"150\\">\\r\\n                ID</td>\\r\\n            <td>\\r\\n                [[TRANSACTION_ID]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Status</td>\\r\\n            <td>\\r\\n                [[TRANSACTION_STATUS]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Datum und Uhrzeit</td>\\r\\n            <td>\\r\\n                [[TRANSACTION_TIME]]</td>\\r\\n        </tr>\\r\\n    </tbody>\\r\\n</table>\\r\\n<br />\\r\\n<table border=\\"0\\" cellpadding=\\"0\\" cellspacing=\\"0\\">\\r\\n    <tbody>\\r\\n        <tr>\\r\\n            <td colspan=\\"2\\" nowrap=\\"nowrap\\" width=\\"150\\">\\r\\n                <strong>Angaben zur beglichenen Rechnung</strong></td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td width=\\"150\\">\\r\\n                Nummer</td>\\r\\n            <td>\\r\\n                [[INVOICE_NUMBER]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Betrag</td>\\r\\n            <td>\\r\\n                [[INVOICE_AMOUNT]] [[INVOICE_CURRENCY]]</td>\\r\\n        </tr>\\r\\n    </tbody>\\r\\n</table>\\r\\n<br />\\r\\n<table border=\\"0\\" cellpadding=\\"0\\" cellspacing=\\"0\\">\\r\\n    <tbody>\\r\\n        <tr>\\r\\n            <td colspan=\\"2\\" nowrap=\\"nowrap\\" width=\\"150\\">\\r\\n                <strong>Angaben zur Kontaktperson</strong></td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td width=\\"150\\">\\r\\n                Anrede</td>\\r\\n            <td>\\r\\n                [[CONTACT_TITLE]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Vorname</td>\\r\\n            <td>\\r\\n                [[CONTACT_FORENAME]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Nachname</td>\\r\\n            <td>\\r\\n                [[CONTACT_SURNAME]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Firma</td>\\r\\n            <td>\\r\\n                [[CONTACT_COMPANY]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Strasse</td>\\r\\n            <td>\\r\\n                [[CONTACT_STREET]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                PLZ</td>\\r\\n            <td>\\r\\n                [[CONTACT_POSTCODE]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Ort</td>\\r\\n            <td>\\r\\n                [[CONTACT_PLACE]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Land</td>\\r\\n            <td>\\r\\n                [[CONTACT_COUNTRY]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                Telefon</td>\\r\\n            <td>\\r\\n                [[CONTACT_PHONE]]</td>\\r\\n        </tr>\\r\\n        <tr>\\r\\n            <td>\\r\\n                E-Mail-Adresse</td>\\r\\n            <td>\\r\\n                <a href=\\"[[CONTACT_EMAIL]]?csrf=MTQ3ODg2NDkx&amp;csrf=ODg4NzYwNDE2\\">[[CONTACT_EMAIL]]</a></td>\\r\\n        </tr>\\r\\n    </tbody>\\r\\n</table>\\r\\n<br />\\r\\nFreundliche Gr&uuml;sse<br />\\r\\nDas [[DOMAIN_URL]]&nbsp;Team")
            ON DUPLICATE KEY UPDATE `id` = `id`
        ');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_checkout_settings_yellowpay', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'TEXT', 'notnull' => true, 'after' => 'id'), 'value' => array('type' => 'TEXT', 'notnull' => true, 'after' => 'name')));
        \Cx\Lib\UpdateUtil::sql('
            INSERT INTO `' . DBPREFIX . 'module_checkout_settings_yellowpay` (`id`, `name`, `value`)
            VALUES  (1, "pspid", "demoShop"),
                    (2, "sha_in", "sech10zeichenminimum"),
                    (3, "sha_out", "sech10zeichenminimum"),
                    (4, "testserver", 1),
                    (5, "operation", "SAL")
            ON DUPLICATE KEY UPDATE `id` = `id`
        ');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_checkout_transactions', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'time' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'status' => array('type' => 'ENUM(\'confirmed\',\'waiting\',\'cancelled\')', 'notnull' => true, 'after' => 'time'), 'invoice_number' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'after' => 'status'), 'invoice_currency' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '1', 'after' => 'invoice_number'), 'invoice_amount' => array('type' => 'INT(15)', 'notnull' => true, 'after' => 'invoice_currency'), 'contact_title' => array('type' => 'ENUM(\'mister\',\'miss\')', 'notnull' => true, 'after' => 'invoice_amount'), 'contact_forename' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'contact_title'), 'contact_surname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'contact_forename'), 'contact_company' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'contact_surname'), 'contact_street' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'contact_company'), 'contact_postcode' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'contact_street'), 'contact_place' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'contact_postcode'), 'contact_country' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '204', 'after' => 'contact_place'), 'contact_phone' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'contact_country'), 'contact_email' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'contact_phone')));
        \Cx\Lib\UpdateUtil::sql('
            INSERT INTO `' . DBPREFIX . 'module_checkout_transactions` (`id`, `time`, `status`, `invoice_number`, `invoice_currency`, `invoice_amount`, `contact_title`, `contact_forename`, `contact_surname`, `contact_company`, `contact_street`, `contact_postcode`, `contact_place`, `contact_country`, `contact_phone`, `contact_email`)
            VALUES (1, 1346661560, "confirmed", 987654321, 1, 48000, "mister", "Hans", "Muster", "Musterfirma", "Musterstrasse 123", 1234, "Musterort", 204, "012 345 67 89", "*****@*****.**")
            ON DUPLICATE KEY UPDATE `id` = `id`
        ');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
}
예제 #15
0
 /**
  * Handles database errors
  *
  * Also migrates text fields to the new structure
  * @return  boolean         False.  Always.
  * @static
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Product
     // Fix the Text, Discount, and Manufacturer tables first
     \Text::errorHandler();
     //        Discount::errorHandler(); // Called by Customer::errorHandler();
     Manufacturer::errorHandler();
     $table_name = DBPREFIX . 'module_shop_products';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'normalprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'resellerprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discountprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discount_active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'is_special_offer'), 'stock' => array('type' => 'INT(10)', 'default' => '10'), 'stock_visible' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'stock_visibility'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status'), 'b2b' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'b2c' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'date_start' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'startdate'), 'date_end' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'enddate'), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'category_id' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'catid'), 'vat_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'manufacturer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'manufacturer'), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'article_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'usergroup_ids' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_order'), 'distribution' => array('type' => 'VARCHAR(16)', 'default' => '', 'renamefrom' => 'handler'), 'picture' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'flags' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'minimum_order_quantity' => array('type' => 'INT(10)', 'unsigned' => false, 'default' => '0'));
     $table_index = array('group_id' => array('fields' => array('group_id')), 'article_id' => array('fields' => array('article_id')), 'flags' => array('fields' => array('flags'), 'type' => 'FULLTEXT'));
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'title')) {
             // Migrate all Product strings to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             \Text::deleteByKey('Shop', self::TEXT_SHORT);
             \Text::deleteByKey('Shop', self::TEXT_LONG);
             \Text::deleteByKey('Shop', self::TEXT_CODE);
             \Text::deleteByKey('Shop', self::TEXT_URI);
             \Text::deleteByKey('Shop', self::TEXT_KEYS);
             $query = "\n                    SELECT `id`, `title`, `shortdesc`, `description`,\n                           `product_id`, `external_link`, `keywords`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query Product strings", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $name = $objResult->fields['title'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product name '{$name}'");
                 }
                 $short = $objResult->fields['shortdesc'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_SHORT, $short)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product short '{$short}'");
                 }
                 $long = $objResult->fields['description'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_LONG, $long)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product long '{$long}'");
                 }
                 $code = $objResult->fields['product_id'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_CODE, $code)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product code '{$code}'");
                 }
                 $uri = $objResult->fields['external_link'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_URI, $uri)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product uri '{$uri}'");
                 }
                 $keys = $objResult->fields['keywords'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_KEYS, $keys)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product keys '{$keys}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Also fix Customer and some related tables
     Customer::errorHandler();
     // Always
     return false;
 }
예제 #16
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;
}
예제 #17
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;
}
예제 #18
0
function _newsletterUpdate()
{
    global $objDatabase, $objUpdate, $_CONFIG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_category', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'status'), 'notification_email' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'name')), array('name' => array('fields' => array('name'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_confirm_mail', array('id' => array('type' => 'INT(1)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'content' => array('type' => 'longtext', 'after' => 'title'), 'recipients' => array('type' => 'text', 'after' => 'content')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'subject' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'template' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'subject'), 'content' => array('type' => 'text', 'after' => 'template'), 'attachment' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'content'), 'priority' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'attachment'), 'sender_email' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'priority'), 'sender_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'sender_email'), 'return_path' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'sender_name'), 'smtp_server' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'return_path'), 'status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'smtp_server'), 'count' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'status'), 'recipient_count' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'count'), 'date_create' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'recipient_count'), 'date_sent' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'date_create'), 'tmp_copy' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'date_sent')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    DBG::msg("Done checking tables.. going to check settings");
    //the two values notifyOnUnsubscribe and notificationUnsubscribe have been merged into the latter.
    $unsubscribeVal = 1;
    try {
        DBG::msg("Retrieving old unsubscribe value if set.");
        $res = \Cx\Lib\UpdateUtil::sql("SELECT setvalue FROM " . DBPREFIX . "module_newsletter_settings WHERE setname='notifyOnUnsubscribe'");
        if (!$res->EOF) {
            $unsubscribeVal = $res->fields['setvalue'];
        } else {
            DBG::msg("Not found. Retrieving new unsubscribe value if set.");
            $res = \Cx\Lib\UpdateUtil::sql("SELECT setvalue FROM " . DBPREFIX . "module_newsletter_settings WHERE setname='notificatonUnsubscribe'");
            if (!$res->EOF) {
                $unsubscribeVal = $res->fields['setvalue'];
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $settings = array('sender_mail' => array('setid' => 1, 'setname' => 'sender_mail', 'setvalue' => '*****@*****.**', 'status' => 1), 'sender_name' => array('setid' => 2, 'setname' => 'sender_name', 'setvalue' => 'admin', 'status' => 1), 'reply_mail' => array('setid' => 3, 'setname' => 'reply_mail', 'setvalue' => '*****@*****.**', 'status' => 1), 'mails_per_run' => array('setid' => 4, 'setname' => 'mails_per_run', 'setvalue' => '30', 'status' => 1), 'text_break_after' => array('setid' => 5, 'setname' => 'text_break_after', 'setvalue' => '100', 'status' => 1), 'test_mail' => array('setid' => 6, 'setname' => 'test_mail', 'setvalue' => '*****@*****.**', 'status' => 1), 'overview_entries_limit' => array('setid' => 7, 'setname' => 'overview_entries_limit', 'setvalue' => '10', 'status' => 1), 'rejected_mail_operation' => array('setid' => 8, 'setname' => 'rejected_mail_operation', 'setvalue' => 'delete', 'status' => 1), 'defUnsubscribe' => array('setid' => 9, 'setname' => 'defUnsubscribe', 'setvalue' => '0', 'status' => 1), 'notificationSubscribe' => array('setid' => 11, 'setname' => 'notificationSubscribe', 'setvalue' => '1', 'status' => 1), 'notificationUnsubscribe' => array('setid' => 10, 'setname' => 'notificationUnsubscribe', 'setvalue' => $unsubscribeVal, 'status' => 1), 'recipient_attribute_status' => array('setid' => 12, 'setname' => 'recipient_attribute_status', 'setvalue' => '{"recipient_sex":{"active":true,"required":false},"recipient_salutation":{"active":true,"required":false},"recipient_title":{"active":false,"required":false},"recipient_firstname":{"active":true,"required":false},"recipient_lastname":{"active":true,"required":false},"recipient_position":{"active":false,"required":false},"recipient_company":{"active":true,"required":false},"recipient_industry":{"active":false,"required":false},"recipient_address":{"active":true,"required":false},"recipient_city":{"active":true,"required":false},"recipient_zip":{"active":true,"required":false},"recipient_country":{"active":true,"required":false},"recipient_phone":{"active":true,"required":false},"recipient_private":{"active":false,"required":false},"recipient_mobile":{"active":false,"required":false},"recipient_fax":{"active":false,"required":false},"recipient_birthday":{"active":true,"required":false},"recipient_website":{"active":false,"required":false}}', 'status' => 1), 'reject_info_mail_text' => array('setid' => 13, 'setname' => 'reject_info_mail_text', 'setvalue' => 'Der Newsletter konnte an folgende E-Mail-Adresse nicht versendet werden:\\r\\n[[EMAIL]]\\r\\n\\r\\nUm die E-Mail Adresse zu bearbeiten, klicken Sie bitte auf den folgenden Link:\\r\\n[[LINK]]', 'status' => 1));
    try {
        DBG::msg("Reading current settings");
        $res = \Cx\Lib\UpdateUtil::sql("SELECT * FROM " . DBPREFIX . "module_newsletter_settings");
        while (!$res->EOF) {
            $field = $res->fields['setname'];
            DBG::msg("...merging {$field} with default settings");
            if (isset($settings[$field])) {
                //do we have another value for this?
                $settings[$field]['setvalue'] = $res->fields['setvalue'];
            }
            $res->MoveNext();
        }
        DBG::msg("Updating settings");
        foreach ($settings as $entry) {
            $setid = intval($entry['setid']);
            $field = addslashes($entry['setname']);
            $value = addslashes($entry['setvalue']);
            $status = intval($entry['status']);
            DBG::msg("...deleting field {$field}");
            \Cx\Lib\UpdateUtil::sql("DELETE FROM " . DBPREFIX . "module_newsletter_settings WHERE setid = '{$setid}' OR setname = '{$field}'");
            DBG::msg("...rewriting field {$field}");
            \Cx\Lib\UpdateUtil::sql("\n                INSERT INTO " . DBPREFIX . "module_newsletter_settings\n                    (setid, setname, setvalue, status)\n                VALUES (\n                    '{$setid}', '{$field}', '{$value}', '{$status}'\n                );\n            ");
        }
        DBG::msg("Deleting old unsubscribe key if set");
        \Cx\Lib\UpdateUtil::sql("DELETE FROM " . DBPREFIX . "module_newsletter_settings WHERE setname='notifyOnUnsubscribe'");
        DBG::msg("Done with newsletter update");
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        DBG::msg("Setting recipient count");
        $objResult = \Cx\Lib\UpdateUtil::sql("SELECT `newsletter`, COUNT(1) AS recipient_count FROM `" . DBPREFIX . "module_newsletter_tmp_sending` GROUP BY `newsletter`");
        if ($objResult->RecordCount()) {
            while (!$objResult->EOF) {
                \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_newsletter` SET `recipient_count` = " . $objResult->fields['recipient_count'] . " WHERE `id`=" . $objResult->fields['newsletter']);
                $objResult->MoveNext();
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // Add notification recipients to confirm_mail table
    try {
        $objResult = \Cx\Lib\UpdateUtil::sql("SELECT id FROM `" . DBPREFIX . "module_newsletter_confirm_mail` WHERE id='3'");
        if ($objResult->RecordCount() == 0) {
            DBG::msg("inserting standard confirm mails");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "module_newsletter_confirm_mail` (`id` ,`title` ,`content` ,`recipients`) VALUES ('3', '[[url]] - Neue Newsletter Empfänger [[action]]', 'Hallo Admin Eine neue Empfänger [[action]] in ihrem Newsletter System. Automatisch generierte Nachricht [[date]]', '');");
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_access_user', array('accessUserID' => array('type' => 'INT(5)', 'unsigned' => true), 'newsletterCategoryID' => array('type' => 'INT(11)', 'after' => 'accessUserID'), 'code' => array('type' => 'VARCHAR(255)', 'after' => 'newsletterCategoryID', 'notnull' => true, 'default' => '')), array('rel' => array('fields' => array('accessUserID', 'newsletterCategoryID'), 'type' => 'UNIQUE'), 'accessUserID' => array('fields' => array('accessUserID'))));
        // set random newsletter code for access recipients
        \Cx\Lib\UpdateUtil::sql('UPDATE ' . DBPREFIX . 'module_newsletter_access_user SET `code` = SUBSTR(MD5(RAND()),1,12) WHERE `code` = \'\'');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_rel_usergroup_newsletter', array('userGroup' => array('type' => 'INT(10)', 'unsigned' => true), 'newsletter' => array('type' => 'INT(10)', 'unsigned' => true, 'after' => 'userGroup')), array('uniq' => array('fields' => array('userGroup', 'newsletter'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_settings', array('setid' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'setname' => array('type' => 'VARCHAR(250)', 'after' => 'setid', 'notnull' => true, 'default' => ''), 'setvalue' => array('type' => 'text', 'after' => 'setname'), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'setvalue')), array('setname' => array('fields' => array('setname'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_tmp_sending', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'newsletter' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'email' => array('type' => 'VARCHAR(255)', 'after' => 'newsletter', 'notnull' => true, 'default' => ''), 'sendt' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'email'), 'type' => array('type' => 'ENUM(\'access\',\'newsletter\',\'core\')', 'notnull' => true, 'default' => 'newsletter', 'after' => 'sendt'), 'code' => array('type' => 'VARCHAR(10)', 'after' => 'type')), array('unique_email' => array('fields' => array('newsletter', 'email'), 'type' => 'UNIQUE'), 'email' => array('fields' => array('email'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_email_link', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'email_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'id'), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'email_id'), 'url' => array('type' => 'VARCHAR(255)', 'after' => 'title')), array('email_id' => array('fields' => array('email_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_email_link_feedback', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'link_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'id'), 'email_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'link_id'), 'recipient_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'email_id'), 'recipient_type' => array('type' => 'ENUM(\'access\',\'newsletter\')', 'after' => 'recipient_id')), array('link_id' => array('fields' => array('link_id', 'email_id', 'recipient_id', 'recipient_type'), 'type' => 'UNIQUE'), 'email_id' => array('fields' => array('email_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_template', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'description' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'name'), 'html' => array('type' => 'text', 'after' => 'description'), 'required' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'html'), 'type' => array('type' => 'ENUM(\'e-mail\',\'news\')', 'notnull' => true, 'default' => 'e-mail', 'after' => 'required')));
        // migrate country field
        if (newsletter_migrate_country_field() == 'timeout') {
            return 'timeout';
        }
        // IMPORTANT: the table definition statement of module_newsletter_user must be AFTER newsletter_migrate_country_field() has been called!
        // fix missing columns & rename old columns if required
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_user', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'code' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'email' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'code'), 'uri' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'email'), 'sex' => array('type' => 'ENUM(\'m\',\'f\')', 'notnull' => false, 'after' => 'uri'), 'salutation' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'sex', 'renamefrom' => 'title'), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'salutation'), 'lastname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'title'), 'firstname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'lastname'), 'position' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'firstname'), 'company' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'position'), 'industry_sector' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'company'), 'address' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'industry_sector', 'renamefrom' => 'street'), 'zip' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'address'), 'city' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'zip'), 'country_id' => array('type' => 'SMALLINT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'city'), 'phone_office' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'country_id', 'renamefrom' => 'phone'), 'phone_private' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'phone_office'), 'phone_mobile' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'phone_private'), 'fax' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'phone_mobile'), 'notes' => array('type' => 'text', 'after' => 'fax'), 'birthday' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => '00-00-0000', 'after' => 'notes'), 'status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'birthday'), 'emaildate' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'status'), 'language' => array('type' => 'INT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'emaildate')), array('email' => array('fields' => array('email'), 'type' => 'UNIQUE'), 'status' => array('fields' => array('status'))));
        // fix user's SALUTATION of previews updates
        if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0') && $objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) {
            // set user's SALUTATION based of previews updates
            \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_newsletter_user` SET `salutation` = `title`, `title` = '' WHERE `salutation` = '0' AND `title` REGEXP '^[0-9]+\$'");
            // clear all user's TITLE attribute that consist only of a number (it is most likely not the case that a user's TITLE is a number,
            // so we assume that it is a left over of the preview update bug, which did not migrate the user's TITLE attribute to the user's SALUTATION attribute
            \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_newsletter_user` SET `title` = '' WHERE `title` REGEXP '^[0-9]+\$'");
        }
        // switch to source mode for all newsletter content pages
        \Cx\Lib\UpdateUtil::setSourceModeOnContentPage(array('module' => 'newsletter'), '3.0.1');
        // replace several placeholders that have changed
        $search = array('/TXT_NEWSLETTER_URI/', '/NEWSLETTER_URI/', '/TXT_NEWSLETTER_STREET/', '/NEWSLETTER_STREET/');
        $replace = array('TXT_NEWSLETTER_WEBSITE', 'NEWSLETTER_WEBSITE', 'TXT_NEWSLETTER_ADDRESS', 'NEWSLETTER_ADDRESS');
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'newsletter'), $search, $replace, array('content'), '3.0.1');
        // sorry, brainfuck coming up...
        // this adds the missing template block newsletter_list as well as the placeholder [[NEWSLETTER_LIST_SELECTED]]
        $search = array('/(<!--\\s+BEGIN\\s+newsletter_lists\\s+-->)(.*)(<!--\\s+END\\s+newsletter_lists\\s+-->)/ms');
        $callback = function ($matches) {
            if (preg_match('/^(.*)(<[^>]+[\'"]list\\[\\{NEWSLETTER_LIST_ID\\}\\][\'"])([^>]*>)(.*)$/ms', $matches[2], $listMatches)) {
                if (strpos($listMatches[2] . $listMatches[3], '{NEWSLETTER_LIST_SELECTED}') === false) {
                    $matches[2] = $listMatches[1] . $listMatches[2] . ' {NEWSLETTER_LIST_SELECTED} ' . $listMatches[3] . $listMatches[4];
                } else {
                    $matches[2] = $listMatches[1] . $listMatches[2] . $listMatches[3] . $listMatches[4];
                }
            }
            if (!preg_match('/<!--\\s+BEGIN\\s+newsletter_list\\s+-->.*<!--\\s+END\\s+newsletter_list\\s+-->/ms', $matches[2])) {
                return $matches[1] . '<!-- BEGIN newsletter_list -->' . $matches[2] . '<!-- END newsletter_list -->' . $matches[3];
            } else {
                return $matches[1] . $matches[2] . $matches[3];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'newsletter'), $search, $callback, array('content'), '3.0.1');
        // this adds the missing placeholders [[SELECTED_DAY]], [[SELECTED_MONTH]], [[SELECTED_YEAR]]
        $search = array('/(<option[^>]+\\{USERS_BIRTHDAY_(DAY|MONTH|YEAR)\\}[\'"])([^>]*>)/ms');
        $callback = function ($matches) {
            if (strpos($matches[1] . $matches[3], '{SELECTED_' . $matches[2] . '}') === false) {
                return $matches[1] . ' {SELECTED_' . $matches[2] . '} ' . $matches[3];
            } else {
                return $matches[1] . $matches[3];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'newsletter'), $search, $callback, array('content'), '3.0.1');
        // replace [[TXT_NEWSLETTER_TITLE]] to [[TXT_NEWSLETTER_SALUTATION]]
        // replace [[NEWSLETTER_TITLE]] to [[NEWSLETTER_SALUTATION]]
        $search = array('/.*\\{NEWSLETTER_TITLE\\}.*/ms');
        $callback = function ($matches) {
            if (!preg_match('/<!--\\s+BEGIN\\s+recipient_title\\s+-->.*\\{NEWSLETTER_TITLE\\}.*<!--\\s+END\\s+recipient_title\\s+-->/ms', $matches[0]) && !preg_match('/<!--\\s+BEGIN\\s+recipient_salutation\\s+-->/ms', $matches[0]) && !preg_match('/\\{NEWSLETTER_SALUTATION\\}/ms', $matches[0])) {
                return str_replace(array('TXT_NEWSLETTER_TITLE', '{NEWSLETTER_TITLE}'), array('TXT_NEWSLETTER_SALUTATION', '{NEWSLETTER_SALUTATION}'), $matches[0]);
            } else {
                return $matches[0];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'newsletter'), $search, $callback, array('content'), '3.0.1');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3') && empty($_SESSION['contrexx_update']['newsletter_links_decoded'])) {
        try {
            $objResult = \Cx\Lib\UpdateUtil::sql('SELECT `id`, `url` FROM `' . DBPREFIX . 'module_newsletter_email_link`');
            if ($objResult !== false && $objResult->RecordCount() > 0) {
                while (!$objResult->EOF) {
                    \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_newsletter_email_link` SET `url` = ? WHERE `id` = ?', array(html_entity_decode($objResult->fields['url'], ENT_QUOTES, CONTREXX_CHARSET), $objResult->fields['id']));
                    $objResult->MoveNext();
                }
            }
            $_SESSION['contrexx_update']['newsletter_links_decoded'] = true;
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) {
        // add access to access ids 152/171/172/174/175/176 for user groups which had access to access id 25
        try {
            $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 25 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\n                                                (152, " . intval($result->fields['group_id']) . "),\n                                                (171, " . intval($result->fields['group_id']) . "),\n                                                (172, " . intval($result->fields['group_id']) . "),\n                                                (174, " . intval($result->fields['group_id']) . "),\n                                                (175, " . intval($result->fields['group_id']) . "),\n                                                (176, " . intval($result->fields['group_id']) . ")\n                                                ");
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    // add access id 176 for user groups which had access to 172 if version is older than 3.1.0
    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 = 172 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 (176, " . intval($result->fields['group_id']) . ")");
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
예제 #19
0
 /**
  * Handles any kind of database errors
  *
  * Includes updating the payments table (I guess from version 1.2.0(?),
  * note that this is unconfirmed) to the current structure
  * @return  boolean               False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Payment
     // Fix the Text and Zones tables first
     \Text::errorHandler();
     Zones::errorHandler();
     \Yellowpay::errorHandler();
     $table_name = DBPREFIX . 'module_shop_payment';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'processor_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs_free_sum'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
             // Migrate all Payment names to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             $query = "\n                    SELECT `id`, `name`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query Payment names", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $name = $objResult->fields['name'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Payment name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Update Payments that use obsolete PSPs:
     //  - 05, 'Internal_CreditCard'
     //  - 06, 'Internal_Debit',
     // Uses 04, Internal
     \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n                SET `processor_id`=4 WHERE `processor_id` IN (5, 6)");
     // - 07, 'Saferpay_Mastercard_Multipay_CAR',
     // - 08, 'Saferpay_Visa_Multipay_CAR',
     // Uses 01, Saferpay
     \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n                SET `processor_id`=1 WHERE `processor_id` IN (7, 8)");
     $table_name = DBPREFIX . 'module_shop_rel_payment';
     $table_structure = array('payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
예제 #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 _contactUpdate()
{
    global $objUpdate, $_CONFIG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_recipient', array('id' => array('type' => 'INT', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'id_form' => array('type' => 'INT(11)', 'notnull' => true, 'default' => 0), 'name' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'email' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'sort' => array('type' => 'INT(11)', 'notnull' => true, 'default' => 0)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_field', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'id_form' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'type' => array('type' => 'ENUM(\'text\',\'label\',\'checkbox\',\'checkboxGroup\',\'date\',\'file\',\'multi_file\',\'hidden\',\'password\',\'radio\',\'select\',\'textarea\',\'recipient\')', 'notnull' => true, 'default' => 'text'), 'attributes' => array('type' => 'TEXT'), 'is_required' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'check_type' => array('type' => 'INT(3)', 'notnull' => true, 'default' => '1'), 'order_id' => array('type' => 'SMALLINT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0')));
        /****************************
         * ADDED:    Contrexx v3.0.0 *
         ****************************/
        /*
         * Create new table 'module_contact_form_field_lang'
         * to store language patameters of each field
         */
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_field_lang', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'fieldID' => array('type' => 'INT(10)', 'unsigned' => true, 'after' => 'id'), 'langID' => array('type' => 'INT(10)', 'unsigned' => true, 'after' => 'fieldID'), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'langID'), 'attributes' => array('type' => 'text', 'after' => 'name')), array('fieldID' => array('fields' => array('fieldID', 'langID'), 'type' => 'UNIQUE')));
        /*
         * Migrate name and attributes fields from 'module_contact_form_field' table
         * to 'module_contact_form_field_lang' table for active frontend language.
         * For other languages empty string
         */
        if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form_field', 'name') && \Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'langId')) {
            $query = "SELECT `field`.`id`, `field`.`id_form`, `field`.`name`, `field`.`attributes`, `form`.`langId`\n                          FROM `" . DBPREFIX . "module_contact_form_field` AS `field`\n                          JOIN `" . DBPREFIX . "module_contact_form` AS `form`\n                          ON `form`.`id` = `field`.`id_form`";
            $objResult = \Cx\Lib\UpdateUtil::sql($query);
            if ($objResult) {
                while (!$objResult->EOF) {
                    $rowCountResult = \Cx\Lib\UpdateUtil::sql("SELECT 1\n                                                        FROM `" . DBPREFIX . "module_contact_form_field_lang`\n                                                        WHERE `fieldID` = " . $objResult->fields['id'] . "\n                                                        AND `langID` = " . $objResult->fields['langId'] . "\n                                                        LIMIT 1");
                    if ($rowCountResult->RecordCount() == 0) {
                        $query = "INSERT INTO `" . DBPREFIX . "module_contact_form_field_lang` (\n                                 `fieldID`, `langID`, `name`, `attributes`\n                                 ) VALUES (\n                                 " . $objResult->fields['id'] . ",\n                                 " . $objResult->fields['langId'] . ",\n                                 '" . addslashes($objResult->fields['name']) . "',\n                                 '" . addslashes($objResult->fields['attributes']) . "')";
                        \Cx\Lib\UpdateUtil::sql($query);
                    }
                    $objResult->MoveNext();
                }
            }
        }
        /*
         * Create table 'module_contact_recipient_lang'
         */
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_recipient_lang', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'primary' => true, 'auto_increment' => true), 'recipient_id' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'after' => 'id'), 'langID' => array('type' => 'INT(11)', 'notnull' => true, 'after' => 'recipient_id'), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'langID')), array('recipient_id' => array('fields' => array('recipient_id', 'langID'), 'type' => 'UNIQUE')));
        /*
         * Transfer recipientId and name from 'module_contact_recipient'
         * to 'module_contact_recipient_lang'
         */
        if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_recipient', 'name')) {
            $query = "SELECT `id`, `id_form`, `name` FROM `" . DBPREFIX . "module_contact_recipient`";
            $objResult = \Cx\Lib\UpdateUtil::sql($query);
            while (!$objResult->EOF) {
                $langId = 1;
                if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'langId')) {
                    $query = "SELECT `langId`\n                                   FROM `" . DBPREFIX . "module_contact_form`\n                                   WHERE `id` = " . $objResult->fields['id_form'];
                    $formLangId = \Cx\Lib\UpdateUtil::sql($query);
                    $langId = $formLangId->fields['langId'] != null ? $formLangId->fields['langId'] : 1;
                } else {
                    $langId = 1;
                }
                /*
                 * Check for row already exsist
                 */
                $rowCountResult = \Cx\Lib\UpdateUtil::sql("SELECT 1 as count\n                                                    FROM `" . DBPREFIX . "module_contact_recipient_lang`\n                                                    WHERE `recipient_id` = " . $objResult->fields['id'] . "\n                                                    AND `langID` = " . $langId . "\n                                                    LIMIT 1");
                if ($rowCountResult->RecordCount() == 0) {
                    $query = "INSERT INTO `" . DBPREFIX . "module_contact_recipient_lang` (\n                              `recipient_id`, `langID`, `name`\n                              ) VALUES (\n                              " . $objResult->fields['id'] . ",\n                              {$langId},\n                              '" . addslashes($objResult->fields['name']) . "')";
                    \Cx\Lib\UpdateUtil::sql($query);
                }
                $objResult->MoveNext();
            }
        }
        /*
         * Drop column 'recipient name' from 'module_contact_recipient'
         */
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_recipient', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'id_form' => array('type' => 'INT(11)', 'notnull' => true, 'default' => 0, 'after' => 'id'), 'email' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'id_form'), 'sort' => array('type' => 'INT(11)', 'notnull' => true, 'default' => 0, 'after' => 'email')));
        /*
         * Create new table 'module_contact_form_submit_data'
         */
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_submit_data', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'id_entry' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'after' => 'id'), 'id_field' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'after' => 'id_entry'), 'formlabel' => array('type' => 'TEXT', 'after' => 'id_field'), 'formvalue' => array('type' => 'TEXT', 'after' => 'formlabel')));
        /*
         * Transfer 'data' field of 'module_contact_form_data' table to 'field_label' and 'field_value'
         * in 'module_contact_form_submit_data' after base64 decoding
         * Fetch fieldId from 'module_contact_form_field_lang' table by matching fieldLabel
         */
        if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form_data', 'data')) {
            /*
             * Execute migrate script for every 30 dataset
             */
            $query = "SELECT `id`, `id_form`, `data`\n                          FROM `" . DBPREFIX . "module_contact_form_data`\n                          WHERE `data` != ''\n                          LIMIT 30";
            while (($objResult = \Cx\Lib\UpdateUtil::sql($query)) && $objResult->RecordCount()) {
                while (!$objResult->EOF) {
                    $fields_attr = explode(";", $objResult->fields['data']);
                    foreach ($fields_attr as $key => $value) {
                        $field_attr = explode(",", $value);
                        $field_label = base64_decode($field_attr[0]);
                        $field_value = base64_decode($field_attr[1]);
                        /*
                         * In the contrexx 2.1.4, the recipient fields were stored as 'contactFormField_recipient' in the submitted data.
                         */
                        if ($field_label == "contactFormField_recipient" && \Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form_field', 'name')) {
                            $form_recipient_query = "SELECT `name`\n                                                    FROM `" . DBPREFIX . "module_contact_form_field`\n                                                    WHERE `type` = 'recipient'\n                                                    AND `id_form` = " . $objResult->fields['id_form'] . "\n                                                    LIMIT 1";
                            $formRecipientResult = \Cx\Lib\UpdateUtil::sql($form_recipient_query);
                            $field_label = $formRecipientResult->fields['name'];
                        }
                        $form_label_query = '
                            SELECT `lang`.`fieldID`
                            FROM `' . DBPREFIX . 'module_contact_form_field` AS `field`
                            LEFT JOIN `' . DBPREFIX . 'module_contact_form_field_lang` AS `lang` ON `lang`.`fieldID` = `field`.`id`
                            WHERE (`field`.`id_form` = ' . $objResult->fields['id_form'] . ') AND (`lang`.`name` = "' . contrexx_raw2db($field_label) . '")
                        ';
                        $formLabelResult = \Cx\Lib\UpdateUtil::sql($form_label_query);
                        $fieldId = $formLabelResult->fields['fieldID'] != null ? $formLabelResult->fields['fieldID'] : 0;
                        $submitCount = \Cx\Lib\UpdateUtil::sql("SELECT 1\n                                                        FROM `" . DBPREFIX . "module_contact_form_submit_data`\n                                                        WHERE `id_entry` = " . $objResult->fields['id'] . "\n                                                        AND `id_field` = " . $fieldId . "\n                                                        LIMIT 1");
                        if ($submitCount->RecordCount() == 0) {
                            $submitQuery = "INSERT INTO `" . DBPREFIX . "module_contact_form_submit_data` (\n                                      `id_entry`, `id_field`, `formlabel`, `formvalue`\n                                      ) VALUES (\n                                      " . $objResult->fields['id'] . ",\n                                      " . $fieldId . ",\n                                      '" . addslashes($field_label) . "',\n                                      '" . addslashes($field_value) . "')";
                            \Cx\Lib\UpdateUtil::sql($submitQuery);
                        }
                    }
                    /*
                     * Empty column 'data' of the current dataset
                     */
                    $updateQuery = "UPDATE `" . DBPREFIX . "module_contact_form_data`\n                              SET `data` = ''\n                              WHERE `id` = " . $objResult->fields['id'];
                    \Cx\Lib\UpdateUtil::sql($updateQuery);
                    $objResult->MoveNext();
                }
            }
        }
        /*
         * Alter table 'module_contact_form_data' by dropping 'data' field and adding 'id_lang'
         */
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_data', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'primary' => true, 'auto_increment' => true), 'id_form' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'id'), 'id_lang' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'default' => 1, 'after' => 'id_form'), 'time' => array('type' => 'INT(14)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'id_lang'), 'host' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'after' => 'time'), 'lang' => array('type' => 'VARCHAR(64)', 'notnull' => true, 'after' => 'host'), 'browser' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'after' => 'lang'), 'ipaddress' => array('type' => 'VARCHAR(15)', 'notnull' => true, 'after' => 'browser')));
        /*
         * Alter table 'module_contact_form_field' by dropping name and attributes column
         * Add 'special_type' column
         */
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_field', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'id_form' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'after' => 'id'), 'type' => array('type' => 'ENUM(\'text\',\'label\',\'checkbox\',\'checkboxGroup\',\'country\',\'date\',\'file\',\'multi_file\',\'fieldset\',\'hidden\',\'horizontalLine\',\'password\',\'radio\',\'select\',\'textarea\',\'recipient\',\'special\')', 'notnull' => true, 'default' => 'text', 'after' => 'id_form'), 'special_type' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'after' => 'type'), 'is_required' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'special_type'), 'check_type' => array('type' => 'INT(3)', 'notnull' => true, 'default' => 1, 'after' => 'is_required'), 'order_id' => array('type' => 'SMALLINT(5)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'check_type')));
        /*
         * Update 'id_lang' column with form language id
         */
        if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'langId')) {
            $query = "SELECT `id`, `id_form` FROM `" . DBPREFIX . "module_contact_form_data`";
            $objResult = \Cx\Lib\UpdateUtil::sql($query);
            if ($objResult) {
                while (!$objResult->EOF) {
                    $query = "UPDATE `" . DBPREFIX . "module_contact_form_data`\n                                SET `id_lang` = (\n                                    SELECT `langId` from `" . DBPREFIX . "module_contact_form`\n                                    WHERE `id` = " . $objResult->fields['id_form'] . "\n                                ) WHERE `id` = " . $objResult->fields['id'];
                    \Cx\Lib\UpdateUtil::sql($query);
                    $objResult->MoveNext();
                }
            }
        }
        /*
         * Create table 'module_contact_form_lang'
         */
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_lang', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'formID' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'after' => 'id'), 'langID' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'after' => 'formID'), 'is_active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => 1, 'after' => 'langID'), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'is_active'), 'text' => array('type' => 'TEXT', 'after' => 'name'), 'feedback' => array('type' => 'TEXT', 'after' => 'text'), 'mailTemplate' => array('type' => 'TEXT', 'after' => 'feedback'), 'subject' => array('type' => 'VARCHAR(255)', 'after' => 'mailTemplate')), array('formID' => array('fields' => array('formID', 'langID'), 'type' => 'UNIQUE')));
        /*
         * Migrate few fields from module_contact_form to module_contact_form_lang
         * and remaining fields to module_contact_form of new version
         */
        if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'name')) {
            $query = "SELECT `id`, `name`, `subject`, `text`, `feedback`, `langId`\n                          FROM `" . DBPREFIX . "module_contact_form`";
            $objResult = \Cx\Lib\UpdateUtil::sql($query);
            while (!$objResult->EOF) {
                /*
                 * Check for row already exsist
                 */
                $rowCountResult = \Cx\Lib\UpdateUtil::sql("SELECT 1\n                                                    FROM `" . DBPREFIX . "module_contact_form_lang`\n                                                    WHERE `formID` = " . $objResult->fields['id'] . "\n                                                    AND `langID` = " . $objResult->fields['langId'] . "\n                                                    LIMIT 1");
                if ($rowCountResult->RecordCount() == 0) {
                    $formLangQuery = "INSERT INTO `" . DBPREFIX . "module_contact_form_lang` (\n                            `formID`,\n                            `langID`,\n                            `is_active`,\n                            `name`,\n                            `text`,\n                            `feedback`,\n                            `mailTemplate`,\n                            `subject`\n                        ) VALUES (\n                            " . $objResult->fields['id'] . ",\n                            " . $objResult->fields['langId'] . ",\n                            1,\n                            '" . addslashes($objResult->fields['name']) . "',\n                            '" . addslashes($objResult->fields['text']) . "',\n                            '" . addslashes($objResult->fields['feedback']) . "',\n                            '" . addslashes('<table>
                                 <tbody>
                                 <!-- BEGIN form_field -->
                                    <tr>
                                        <td>
                                            [[FIELD_LABEL]]
                                        </td>
                                        <td>
                                            [[FIELD_VALUE]]
                                        </td>
                                    </tr>
                                 <!-- END form_field -->
                                 </tbody>
                             </table>') . "',\n                            '" . addslashes($objResult->fields['subject']) . "'\n                        )";
                    \Cx\Lib\UpdateUtil::sql($formLangQuery);
                }
                $objResult->MoveNext();
            }
        }
        /*
         * Alter table 'module_contact_form' by dropping name, subject, feedback and form text
         * Add new column 'html_mail'
         */
        if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'html_mail')) {
            $htmlMailIsNew = false;
        } else {
            $htmlMailIsNew = true;
        }
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'primary' => true, 'auto_increment' => true), 'mails' => array('type' => 'TEXT', 'after' => 'id'), 'showForm' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'mails'), 'use_captcha' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => 1, 'after' => 'showForm'), 'use_custom_style' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'use_captcha'), 'send_copy' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0, 'after' => 'use_custom_style'), 'use_email_of_sender' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0, 'after' => 'send_copy'), 'html_mail' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => 1, 'after' => 'use_email_of_sender'), 'send_attachment' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => '0')));
        if ($htmlMailIsNew) {
            \Cx\Lib\UpdateUtil::sql('UPDATE ' . DBPREFIX . 'module_contact_form SET html_mail = 0');
        }
        if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.1.5')) {
            // for all versions >= 2.2.0
            // change all fields currently set to 'file' to 'multi_file' ('multi_file' is same as former 'file' in previous versions)
            \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_contact_form_field` SET `type` = 'multi_file' WHERE `type` = 'file'");
        }
        /**
         * Update the content pages
         */
        if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) {
            $em = \Env::get('em');
            $cl = \Env::get('ClassLoader');
            $cl->loadFile(ASCMS_CORE_MODULE_PATH . '/contact/admin.class.php');
            $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
            $Contact = new \ContactManager();
            $Contact->initContactForms();
            foreach ($Contact->arrForms as $id => $form) {
                foreach ($form['lang'] as $langId => $lang) {
                    if ($lang['is_active'] == true) {
                        $page = $pageRepo->findOneByModuleCmdLang('contact', $id, $langId);
                        if ($page) {
                            $page->setContent($Contact->_getSourceCode($id, $langId));
                            $page->setUpdatedAtToNow();
                            $em->persist($page);
                        }
                    }
                }
            }
            $em->flush();
        }
        /*******************************************
         * EXTENSION:    Database structure changes *
         * ADDED:        Contrexx v3.1.0            *
         *******************************************/
        if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'mails' => array('type' => 'text', 'after' => 'id'), 'showForm' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'mails'), 'use_captcha' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'showForm'), 'use_custom_style' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'use_captcha'), 'save_data_in_crm' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'use_custom_style'), 'send_copy' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'save_data_in_crm'), 'use_email_of_sender' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'send_copy'), 'html_mail' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'use_email_of_sender'), 'send_attachment' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'html_mail')));
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
예제 #21
0
 /**
  * Handles database errors
  *
  * Also migrates old Currency names to the Text class,
  * and inserts default Currencyes if necessary
  * @return  boolean     false       Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     global $objDatabase;
     // Currency
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_currencies';
     $table_structure = 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' => ''), 'rate' => array('type' => 'DECIMAL(10,4)', 'unsigned' => true, 'notnull' => true, 'default' => '1.0000'), 'increment' => array('type' => 'DECIMAL(6,5)', 'unsigned' => true, 'notnull' => true, 'default' => '0.01'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'status'), 'default' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'is_default'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
             // Migrate all Currency names to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             $query = "\n                    SELECT `id`, `code`, `name`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query Currency names", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $name = $objResult->fields['name'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Currency name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
         return false;
     }
     // If the table did not exist, insert defaults
     $arrCurrencies = array('Schweizer Franken' => array('CHF', 'sFr.', 1.0, '0.05', 1, 1, 1), 'Euro' => array('EUR', html_entity_decode("&euro;"), 1.18, '0.01', 2, 1, 0), 'United States Dollars' => array('USD', '$', 0.88, '0.01', 3, 1, 0));
     // There is no previous version of this table!
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure);
     // And there aren't even records to migrate, so
     foreach ($arrCurrencies as $name => $arrCurrency) {
         $query = "\n                INSERT INTO `contrexx_module_shop_currencies` (\n                    `code`, `symbol`, `rate`, `increment`,\n                    `ord`, `active`, `default`\n                ) VALUES (\n                    '" . join("','", $arrCurrency) . "'\n                )";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to insert default Currencies");
         }
         $id = $objDatabase->Insert_ID();
         if (!\Text::replace($id, FRONTEND_LANG_ID, 'Shop', self::TEXT_NAME, $name)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to add Text for default Currency name '{$name}'");
         }
     }
     // Always
     return false;
 }
예제 #22
0
 /**
  * Tries to fix any database problems
  * @return  boolean           False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     //die("Discount::errorHandler(): Disabled!<br />");
     // Discount
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_article_group';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true));
     $table_index = array();
     //\DBG::activate(DBG_DB);
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_ARTICLE);
         $query = "\n                SELECT `id`, `name`\n                  FROM `{$table_name}`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to query article group names", $query);
         }
         while (!$objResult->EOF) {
             $group_id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_ARTICLE, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate article group names");
             }
             $objResult->MoveNext();
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_customer_group';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true));
     $table_index = array();
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_CUSTOMER);
         $query = "\n                SELECT `id`, `name`\n                  FROM `{$table_name}`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to query customer group names", $query);
         }
         while (!$objResult->EOF) {
             $group_id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_CUSTOMER, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate customer group names");
             }
             $objResult->MoveNext();
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_rel_discount_group';
     $table_structure = array('customer_group_id' => array('type' => 'int(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'article_group_id' => array('type' => 'int(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'rate' => array('type' => 'decimal(9,2)', 'notnull' => true, 'default' => '0.00'));
     $table_index = array();
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_discountgroup_count_name';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true));
     $table_index = array();
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_COUNT);
         \Text::deleteByKey('Shop', self::TEXT_UNIT_GROUP_COUNT);
         $query = "\n                SELECT `id`, `name`, `unit`\n                  FROM `{$table_name}`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to query count group names", $query);
         }
         while (!$objResult->EOF) {
             $group_id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             $unit = $objResult->fields['unit'];
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_COUNT, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate count group names");
             }
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_UNIT_GROUP_COUNT, $unit)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate count group units");
             }
             $objResult->MoveNext();
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_discountgroup_count_rate';
     $table_structure = array('group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'count' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 1, 'primary' => true), 'rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.00'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
예제 #23
0
 /**
  * Handles database errors
  *
  * Also migrates old ProductAttribute to new Attribute structures,
  * including Text records.
  * @return  boolean   false       Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Attribute
     $default_lang_id = \FWLanguage::getDefaultLangId();
     $table_name_old = DBPREFIX . 'module_shop_products_attributes_name';
     $table_name_new = DBPREFIX . 'module_shop_attribute';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'display_type'));
         $table_index = array();
         if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
             if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'name')) {
                 // Migrate all Product strings to the Text table first
                 \Text::deleteByKey('Shop', self::TEXT_ATTRIBUTE_NAME);
                 $query = "\n                        SELECT `id`, `name`\n                          FROM `{$table_name_old}`";
                 $objResult = \Cx\Lib\UpdateUtil::sql($query);
                 if (!$objResult) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to query Attribute names", $query);
                 }
                 while (!$objResult->EOF) {
                     $id = $objResult->fields['id'];
                     $name = $objResult->fields['name'];
                     if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_ATTRIBUTE_NAME, $name)) {
                         throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Attribute name '{$name}'");
                     }
                     $objResult->MoveNext();
                 }
             }
         }
         //DBG::activate(DBG_ADODB);
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Attribute table");
         }
     }
     $table_name_old = DBPREFIX . 'module_shop_products_attributes_value';
     $table_name_new = DBPREFIX . 'module_shop_option';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'renamefrom' => 'name_id'), 'price' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'));
         $table_index = array();
         if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
             if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'value')) {
                 // Migrate all Product strings to the Text table first
                 \Text::deleteByKey('Shop', self::TEXT_OPTION_NAME);
                 $query = "\n                        SELECT `id`, `value`\n                          FROM `{$table_name_old}`";
                 $objResult = \Cx\Lib\UpdateUtil::sql($query);
                 if (!$objResult) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to query option names", $query);
                 }
                 while (!$objResult->EOF) {
                     $id = $objResult->fields['id'];
                     $name = $objResult->fields['value'];
                     if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_OPTION_NAME, $name)) {
                         throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate option Text '{$name}'");
                     }
                     $objResult->MoveNext();
                 }
             }
         }
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Option table");
         }
     }
     $table_name_old = DBPREFIX . 'module_shop_products_attributes';
     $table_name_new = DBPREFIX . 'module_shop_rel_product_attribute';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'option_id' => array('type' => 'INT(10)', 'unsigned' => true, 'primary' => true, 'renamefrom' => 'attributes_value_id'), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_id'));
         $table_index = array();
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Product-Attribute relation table {$table_name_old} to {$table_name_new}");
         }
     }
     // Always
     return false;
 }
예제 #24
0
 /**
  * Tries to fix any database related problems
  * @return  boolean     false     Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     //die("Coupon::errorHandler(): Disabled");
     // Coupon
     // Fix settings first
     ShopSettings::errorHandler();
     $table_name = DBPREFIX . 'module_shop_discount_coupon';
     $table_structure = array('code' => array('type' => 'varchar(20)', 'default' => '', 'primary' => true), 'customer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'start_time' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'end_time' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'uses' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'uses_available'), 'global' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0'), 'minimum_amount' => array('type' => 'decimal(9,2)', 'unsigned' => true, 'default' => '0.00'), 'discount_amount' => array('type' => 'decimal(9,2)', 'unsigned' => true, 'default' => '0.00'), 'discount_rate' => array('type' => 'decimal(3,0)', 'unsigned' => true, 'default' => '0'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     $table_name = DBPREFIX . 'module_shop_rel_customer_coupon';
     $table_structure = array('code' => array('type' => 'varchar(20)', 'default' => '', 'primary' => true), 'customer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'count' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
예제 #25
0
 /**
  * Should be called whenever there's a problem with the settings table
  *
  * Tries to fix or recreate the settings table.
  * @return  boolean             False, always.
  *
  */
 function errorHandler()
 {
     $table_name = DBPREFIX . 'core_setting';
     $table_structure = array('section' => array('type' => 'VARCHAR(32)', 'default' => '', 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'default' => '', 'primary' => true), 'group' => array('type' => 'VARCHAR(32)', 'default' => '', 'primary' => true), 'type' => array('type' => 'VARCHAR(32)', 'default' => 'text'), 'value' => array('type' => 'TEXT', 'default' => ''), 'values' => array('type' => 'TEXT', 'notnull' => true, 'default' => null), 'ord' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'));
     // TODO: The index array structure is wrong here!
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     //echo("$this->errorHandler(): Created table ".DBPREFIX."core_setting<br />");
     //Use $this->add(); in your module code to add settings; example:
     //$this->init('core', 'country');
     //$this->add('numof_countries_per_page_backend', 30, 1, $this->TYPE_TEXT);
     //More to come...
     //Always!
     return false;
 }
예제 #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 _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;
}
예제 #27
0
파일: access.php 프로젝트: Niggu/cloudrexx
/**
 * 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;
}
예제 #28
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;
}
예제 #29
0
 /**
  * Handles database errors
  *
  * Also migrates old names to the new structure
  * @return  boolean         False.  Always.
  * @static
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Shipment
     static $break = false;
     if ($break) {
         die("\n                Shipment::errorHandler(): Recursion detected while handling an error.<br /><br />\n                This should not happen.  We are very sorry for the inconvenience.<br />\n                Please contact customer support: helpdesk@comvation.com");
     }
     $break = true;
     //die("Shipment::errorHandler(): Disabled!<br />");
     // Fix the Zones table first
     Zones::errorHandler();
     $table_name = DBPREFIX . 'module_shop_shipper';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'ord' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'status'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             $query = "\n                    SELECT `id`, `name`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query names", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $name = $objResult->fields['name'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     $table_name = DBPREFIX . 'module_shop_shipment_cost';
     $table_structure = 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, 'default' => null), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'cost'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'price_free'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always!
     return false;
 }
 /**
  * Handles all kinds of database errors
  *
  * Creates the processors' table, and creates default entries if necessary
  * @return  boolean                         False. Always.
  * @global  ADOConnection   $objDatabase
  */
 static function errorHandler()
 {
     // PaymentProcessing
     $table_name_old = DBPREFIX . 'module_shop_processors';
     $table_name_new = DBPREFIX . 'module_shop_payment_processors';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         \Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new);
     }
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'ENUM("internal", "external")', 'default' => 'internal'), 'name' => array('type' => 'VARCHAR(255)', 'default' => ''), 'description' => array('type' => 'TEXT', 'default' => ''), 'company_url' => array('type' => 'VARCHAR(255)', 'default' => ''), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => 1), 'picture' => array('type' => 'VARCHAR(255)', 'default' => ''));
     \Cx\Lib\UpdateUtil::table($table_name_new, $table_structure);
     $arrPsp = array(array(1, 'external', 'saferpay', 'Saferpay is a comprehensive Internet payment platform, specially developed for commercial applications. It provides a guarantee of secure payment processes over the Internet for merchants as well as for cardholders. Merchants benefit from the easy integration of the payment method into their e-commerce platform, and from the modularity with which they can take account of current and future requirements. Cardholders benefit from the security of buying from any shop that uses Saferpay.', 'http://www.saferpay.com/', 1, 'logo_saferpay.gif'), array(2, 'external', 'paypal', 'With more than 40 million member accounts in over 45 countries worldwide, PayPal is the world\'s largest online payment service. PayPal makes sending money as easy as sending email! Any PayPal member can instantly and securely send money to anyone in the U.S. with an email address. PayPal can also be used on a web-enabled cell phone. In the future, PayPal will be available to use on web-enabled pagers and other handheld devices.', 'http://www.paypal.com/', 1, 'logo_paypal.gif'), array(3, 'external', 'yellowpay', 'PostFinance vereinfacht das Inkasso im Online-Shop.', 'http://www.postfinance.ch/', 1, 'logo_postfinance.gif'), array(4, 'internal', 'internal', 'Internal no forms', '', 1, ''), array(9, 'internal', 'internal_lsv', 'LSV with internal form', '', 1, ''), array(10, 'external', 'datatrans', 'Die professionelle und komplette Payment-Lösung', 'http://datatrans.biz/', 1, 'logo_datatrans.gif'), array(11, 'external', 'mobilesolutions', 'PostFinance Mobile', 'https://postfinance.mobilesolutions.ch/', 1, 'logo_postfinance_mobile.gif'));
     $query_template = "\n            REPLACE INTO `{$table_name_new}` (\n                `id`, `type`, `name`,\n                `description`,\n                `company_url`, `status`, `picture`\n            ) VALUES (\n                ?, ?, ?, ?, ?, ?, ?\n            )";
     foreach ($arrPsp as $psp) {
         \Cx\Lib\UpdateUtil::sql($query_template, $psp);
     }
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     }
     // Drop obsolete PSPs -- see Payment::errorHandler()
     \Cx\Lib\UpdateUtil::sql("\n            DELETE FROM `" . DBPREFIX . "module_shop_payment_processors`\n             WHERE `id` IN (5, 6, 7, 8)");
     // Always
     return false;
 }