本文整理汇总了PHP中Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback方法的典型用法代码示例。如果您正苦于以下问题:PHP UpdateUtil::migrateContentPageUsingRegexCallback方法的具体用法?PHP UpdateUtil::migrateContentPageUsingRegexCallback怎么用?PHP UpdateUtil::migrateContentPageUsingRegexCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cx\Lib\UpdateUtil
的用法示例。
在下文中一共展示了UpdateUtil::migrateContentPageUsingRegexCallback方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _loginUpdate
/**
* 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 _loginUpdate()
{
global $objUpdate, $_CONFIG;
// 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 null;
}
// add missing captcha template block
if (!preg_match('/<!--\\s+BEGIN\\s+captcha\\s+-->.*<!--\\s+END\\s+captcha\\s+-->/ms', $content)) {
$content = preg_replace('/(<input[^>]+name\\s*=\\s*[\'"]PASSWORD[\'"][^>]*>.*?<\\/p>)(\\s+)/ms', '$1$2<!-- BEGIN captcha -->$2<p><label for="coreCaptchaCode">{TXT_CORE_CAPTCHA}</label>{CAPTCHA_CODE}</p>$2<!-- END captcha -->', $content);
}
return $content;
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'login', 'cmd' => ''), $search, $callback, array('content'), '3.0.1');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
}
return true;
}
示例2: _recommendUpdate
function _recommendUpdate()
{
global $objDatabase;
/********************************
* EXTENSION: Captcha *
* ADDED: Contrexx v3.0.0 *
********************************/
try {
// migrate content page to version 3.0.1
$search = array('/(.*)/ms');
$callback = function ($matches) {
$content = $matches[1];
if (empty($content)) {
return $content;
}
if (!preg_match('/<!--\\s+BEGIN\\s+recommend_captcha\\s+-->.*<!--\\s+END\\s+recommend_captcha\\s+-->/ms', $content)) {
// migrate captcha stuff
$content = preg_replace('/<img[^>]+\\{RECOM_CAPTCHA_URL\\}.*\\{RECOM_CAPTCHA_OFFSET\\}[^>]+>/ms', '{RECOM_CAPTCHA_CODE}', $content);
// migration for very old versions
$content = preg_replace('/(.*)(<tr[^>]*>.*?<td[^>]*>.*?\\{RECOM_CAPTCHA_CODE\\}.*?<\\/td>.*?<\\/tr>)/ms', '$1<!-- BEGIN recommend_captcha -->$2<!-- END recommend_captcha -->', $content, -1, $count);
// migration for newer versions
if (!$count) {
$content = preg_replace('/(.*)(<p[^>]*>.*?\\{RECOM_CAPTCHA_.*?\\}.*?<\\/p>)/ms', '$1<!-- BEGIN recommend_captcha -->$2<!-- END recommend_captcha -->', $content);
}
$content = preg_replace('/(.*)(<p[^>]*><label.*<\\/label>)(.*?\\{RECOM_CAPTCHA_.*?\\}.*?)(<\\/p>)/ms', '$1$2{RECOM_CAPTCHA_CODE}$4', $content);
}
return $content;
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'recommend'), $search, $callback, array('content'), '3.0.1');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
return true;
}
示例3: _podcastUpdate
function _podcastUpdate()
{
global $objDatabase, $_ARRAYLANG, $objUpdate, $_CONFIG;
//move podcast images directory
$path = ASCMS_DOCUMENT_ROOT . '/images';
$oldImagesPath = '/content/podcast';
$newImagesPath = '/podcast';
if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '1.2.1')) {
if (!file_exists($path . $newImagesPath) && file_exists($path . $oldImagesPath)) {
\Cx\Lib\FileSystem\FileSystem::makeWritable($path . $oldImagesPath);
if (!\Cx\Lib\FileSystem\FileSystem::copy_folder($path . $oldImagesPath, $path . $newImagesPath)) {
setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_TO_MOVE_DIRECTORY'], $path . $oldImagesPath, $path . $newImagesPath));
return false;
}
}
\Cx\Lib\FileSystem\FileSystem::makeWritable($path . $newImagesPath);
\Cx\Lib\FileSystem\FileSystem::makeWritable($path . $newImagesPath . '/youtube_thumbnails');
//change thumbnail paths
$query = "UPDATE `" . DBPREFIX . "module_podcast_medium` SET `thumbnail` = REPLACE(`thumbnail`, '/images/content/podcast/', '/images/podcast/')";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
//set new default settings
$query = "UPDATE `" . DBPREFIX . "module_podcast_settings` SET `setvalue` = '50' WHERE `setname` = 'thumb_max_size' AND `setvalue` = ''";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
$query = "UPDATE `" . DBPREFIX . "module_podcast_settings` SET `setvalue` = '85' WHERE `setname` = 'thumb_max_size_homecontent' AND `setvalue` = ''";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
// only update if installed version is at least a version 2.0.0
// older versions < 2.0 have a complete other structure of the content page and must therefore completely be reinstalled
if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) {
try {
// migrate content page to version 3.0.1
$search = array('/(.*)/ms');
$callback = function ($matches) {
$content = $matches[1];
if (empty($content)) {
return $content;
}
// add missing placeholder {PODCAST_JAVASCRIPT}
if (strpos($content, '{PODCAST_JAVASCRIPT}') === false) {
$content .= "\n{PODCAST_JAVASCRIPT}";
}
// add missing placeholder {PODCAST_PAGING}
if (strpos($content, '{PODCAST_PAGING}') === false) {
$content = preg_replace('/(\\s+)(<!--\\s+END\\s+podcast_media\\s+-->)/ms', '$1$2$1<div class="noMedium">$1 {PODCAST_PAGING}$1</div>', $content);
}
return $content;
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'podcast'), $search, $callback, array('content'), '3.0.1');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
}
return true;
}
示例4: _blogUpdate
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;
}
示例5: _newsletterUpdate
//.........这里部分代码省略.........
// 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();
}
示例6: _newsUpdate
//.........这里部分代码省略.........
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;
示例7: _accessUpdate
//.........这里部分代码省略.........
return _databaseError($query, $objDatabase->ErrorMsg());
}
// Currently, this is only here to create the u2u_active field.. but instead of adding
// 10 lines for each new field in the future, why not just extend this block
try {
\Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_users', array('id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'is_admin' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'id'), 'username' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'is_admin'), 'password' => array('type' => 'VARCHAR(32)', 'notnull' => false, 'after' => 'username'), 'regdate' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'password'), 'expiration' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'regdate'), 'validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'expiration'), 'last_auth' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'validity'), 'last_auth_status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '1', 'after' => 'last_auth'), 'last_activity' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'last_auth_status'), 'email' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'last_activity'), 'email_access' => array('type' => 'ENUM(\'everyone\',\'members_only\',\'nobody\')', 'notnull' => true, 'default' => 'nobody', 'after' => 'email'), 'frontend_lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'email_access'), 'backend_lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'frontend_lang_id'), 'active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'backend_lang_id'), 'primary_group' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'active'), 'profile_access' => array('type' => 'ENUM(\'everyone\',\'members_only\',\'nobody\')', 'notnull' => true, 'default' => 'members_only', 'after' => 'primary_group'), 'restore_key' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => '', 'after' => 'profile_access'), 'restore_key_time' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'restore_key'), 'u2u_active' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '1', 'after' => 'restore_key_time')), array('username' => array('fields' => array('username'))));
\Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_groups', array('group_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'group_name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'group_id'), 'group_description' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'group_name'), 'is_active' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '1', 'after' => 'group_description'), 'type' => array('type' => 'ENUM(\'frontend\',\'backend\')', 'notnull' => true, 'default' => 'frontend', 'after' => 'is_active'), 'homepage' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'type')));
} catch (\Cx\Lib\UpdateException $e) {
// we COULD do something else here..
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
\DBG::msg('004');
// only update if installed version is at least a version 2.0.0
// older versions < 2.0 have a complete other structure of the content page and must therefore completely be reinstalled
if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) {
try {
// migrate content page to version 3.0.1
$search = array('/(.*)/ms');
$callback = function ($matches) {
$content = $matches[1];
if (empty($content)) {
return $content;
}
// add missing access_captcha template block
if (!preg_match('/<!--\\s+BEGIN\\s+access_captcha\\s+-->.*<!--\\s+END\\s+access_captcha\\s+-->/ms', $content)) {
$content = preg_replace('/(<\\/fieldset>|)(\\s*)(<p[^>]*>|)(\\{ACCESS_SIGNUP_BUTTON\\})(<\\/p>|)/ms', '$2<!-- BEGIN access_captcha -->$2$3<label>{TXT_ACCESS_CAPTCHA}</label>{ACCESS_CAPTCHA_CODE}$5$2<!-- END access_captcha -->$2$1$2$3$4$5', $content);
}
// add missing access_newsletter template block
if (!preg_match('/<!--\\s+BEGIN\\s+access_newsletter\\s+-->.*<!--\\s+END\\s+access_newsletter\\s+-->/ms', $content)) {
$content = preg_replace('/(\\s*)(<p[^>]*>|)(\\{ACCESS_SIGNUP_BUTTON\\})(<\\/p>|)/ms', '$1<!-- BEGIN access_newsletter -->$1<fieldset><legend>Newsletter abonnieren</legend>$1 <!-- BEGIN access_newsletter_list -->$1 <p>$1 <label for="access_user_newsletters-{ACCESS_NEWSLETTER_ID}"> {ACCESS_NEWSLETTER_NAME}</label>$1 <input type="checkbox" name="access_user_newsletters[]" id="access_user_newsletters-{ACCESS_NEWSLETTER_ID}" value="{ACCESS_NEWSLETTER_ID}"{ACCESS_NEWSLETTER_SELECTED} />$1 </p>$1 <!-- END access_newsletter_list -->$1</fieldset>$1<!-- END access_newsletter -->$1$2$3$4', $content);
}
return $content;
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'access', 'cmd' => 'signup'), $search, $callback, array('content'), '3.0.1');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
}
/***************************************
*
* ADD NETWORK TABLE FOR SOCIAL LOGIN
*
**************************************/
if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) {
try {
\Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_network', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'oauth_provider' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'oauth_id' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'oauth_provider'), 'user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'oauth_id')), array(), 'InnoDB');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/***************************************
*
* ADD NEW VALUES FOR SOCIAL LOGIN
*
**************************************/
try {
\Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin', '', '0') ON DUPLICATE KEY UPDATE `key` = `key`");
\Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_show_signup', '', 0) ON DUPLICATE KEY UPDATE `key` = `key`");
\Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('use_usernames', '0', '1') ON DUPLICATE KEY UPDATE `key` = `key`");
\Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_assign_to_groups', '3', '0') ON DUPLICATE KEY UPDATE `key` = `key`");
\Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_active_automatically', '', '1') ON DUPLICATE KEY UPDATE `key` = `key`");
\Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ('access', 'providers', 'sociallogin', 'text', '{\"facebook\":{\"active\":\"0\",\"settings\":[\"\",\"\"]},\"twitter\":{\"active\":\"0\",\"settings\":[\"\",\"\"]},\"google\":{\"active\":\"0\",\"settings\":[\"\",\"\",\"\"]}}', '', '0') ON DUPLICATE KEY UPDATE `section` = `section`");
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/**
* Content page
示例8: _forumUpdate
//.........这里部分代码省略.........
if (!in_array('rating', $arrColumns)) {
$query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` ADD `rating` INT NOT NULL DEFAULT '0' AFTER `is_sticky`";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
if (!in_array('keywords', $arrColumns)) {
$query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` ADD `keywords` TEXT NOT NULL AFTER `icon`";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
$arrIndexes = $objDatabase->MetaIndexes(DBPREFIX . "module_forum_postings");
if (is_array($arrIndexes['fulltext'])) {
$query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` DROP INDEX `fulltext`";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
$query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` ADD FULLTEXT `fulltext` (\n `keywords`,\n `subject`,\n `content`\n );";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
if (!in_array('attachment', $arrColumns)) {
$query = "ALTER TABLE `" . DBPREFIX . "module_forum_postings` ADD `attachment` VARCHAR(250) NOT NULL DEFAULT '' AFTER `content`";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
foreach ($arrSettings as $id => $arrSetting) {
$query = "SELECT 1 FROM `" . DBPREFIX . "module_forum_settings` WHERE `name`= '" . $arrSetting['name'] . "'";
if (($objRS = $objDatabase->Execute($query)) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
if ($objRS->RecordCount() == 0) {
$query = "INSERT INTO `" . DBPREFIX . "module_forum_settings`\n (`id`, `name`, `value`)\n VALUES (" . $id . ", '" . $arrSetting['name'] . "', '" . addslashes($arrSetting['value']) . "')";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
}
try {
\Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_forum_rating', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'user_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'post_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'time' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0')), array('user_id' => array('fields' => array('user_id', 'post_id'))));
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/**********************************
* EXTENSION: Content Migration *
* ADDED: Contrexx v3.0.0 *
**********************************/
try {
// migrate content page to version 3.0.1
$search = array('/(.*)/ms');
$callback = function ($matches) {
$content = $matches[1];
if (empty($content)) {
return $content;
}
// replace message textarea with {FORUM_MESSAGE_INPUT}
$content = preg_replace('/<textarea[^>]+name\\s*=\\s*[\'"]message[\'"][^>]*>.*?\\{FORUM_MESSAGE\\}.*?<\\/textarea>/ms', '{FORUM_MESSAGE_INPUT}', $content);
if (!preg_match('/<!--\\s+BEGIN\\s+captcha\\s+-->.*<!--\\s+END\\s+captcha\\s+-->/ms', $content)) {
// migration for versions < 2.0
// add missing template block captcha
$content = preg_replace('/(.*)(<tr[^>]*>.*?<td[^>]*>.*?\\{FORUM_CAPTCHA_IMAGE_URL\\}.*?<\\/td>.*?<\\/tr>)/ms', '$1<!-- BEGIN captcha -->$2<!-- END captcha -->', $content);
}
// add missing placeholder {FORUM_JAVASCRIPT_SCROLLTO}
if (strpos($content, '{FORUM_JAVASCRIPT_SCROLLTO}') === false) {
$content = '{FORUM_JAVASCRIPT_SCROLLTO}' . $content;
}
// hide deprecated marckup buttons
$content = preg_replace('/(<!--\\s+)?(<input[^>]+onclick\\s*=\\s*[\'"]\\s*addText\\([^>]+>)(?:\\s+-->)?/ms', '<!-- $2 -->', $content);
// replace image with {FORUM_CAPTCHA_CODE}
$content = preg_replace('/(<!--\\s+BEGIN\\s+captcha\\s+-->.*)<img[^>]+\\{FORUM_CAPTCHA_IMAGE_URL\\}[^>]+>(?:<br\\s*\\/?>)?(.*<!--\\s+END\\s+captcha\\s+-->)/ms', '$1{FORUM_CAPTCHA_CODE}$2', $content);
// replace text "Captcha-Code" with {TXT_FORUM_CAPTCHA}
$content = preg_replace('/(<!--\\s+BEGIN\\s+captcha\\s+-->.*)Captcha-Code:?(.*<!--\\s+END\\s+captcha\\s+-->)/ms', '$1{TXT_FORUM_CAPTCHA}$2', $content);
// remove <input type="text" name="captcha" id="captcha" />
$content = preg_replace('/(<!--\\s+BEGIN\\s+captcha\\s+-->.*)<input[^>]+name\\s*=\\s*[\'"]captcha[\'"][^>]*>(.*<!--\\s+END\\s+captcha\\s+-->)/ms', '$1$2', $content);
// remove <input type="hidden" name="offset" value="[[FORUM_CAPTCHA_OFFSET]]" />
$content = preg_replace('/(<!--\\s+BEGIN\\s+captcha\\s+-->.*)<input[^>]+name\\s*=\\s*[\'"]offset[\'"][^>]*>(.*<!--\\s+END\\s+captcha\\s+-->)/ms', '$1$2', $content);
// add missing block threadActions
if (!preg_match('/<!--\\s+BEGIN\\s+threadActions\\s+-->.*<!--\\s+END\\s+threadActions\\s+-->/ms', $content)) {
$threadActionHtml = <<<FORUM
<!-- BEGIN threadActions --><br />
<span style="color: rgb(255, 0, 0);">{TXT_THREAD_ACTION_ERROR} </span><br />
<span style="color: #006900;">{TXT_THREAD_ACTION_SUCCESS} </span> <!-- BEGIN moveForm -->
<form action="index.php?section=forum&cmd=thread&action=move&id={FORUM_THREAD_ID}" method="POST" name="frmThreadMove">
<select name="moveToThread" size="32" style="width:225px;"> {FORUM_THREADS} </select><br />
<input type="submit" value="{TXT_FORUM_THREAD_ACTION_MOVE}" /> </form>
<!-- END moveForm --><!-- END threadActions -->
FORUM;
$content = preg_replace('/(<!--\\s+END\\s+addPost\\s+-->)/ms', '$1' . $threadActionHtml, $content);
}
return $content;
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'forum'), $search, $callback, array('content'), '3.0.1');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
return true;
}
示例9: _directoryUpdate
//.........这里部分代码省略.........
return _databaseError($query, $objDatabase->ErrorMsg());
}
/// 2.1
$query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='youtubeWidth'";
$objCheck = $objDatabase->SelectLimit($query, 1);
if ($objCheck !== false) {
if ($objCheck->RecordCount() == 0) {
$query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` , `settyp` )\n VALUES (NULL , 'youtubeWidth', '400', '1')";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
} else {
return _databaseError($query, $objDatabase->ErrorMsg());
}
$query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='youtubeHeight'";
$objCheck = $objDatabase->SelectLimit($query, 1);
if ($objCheck !== false) {
if ($objCheck->RecordCount() == 0) {
$query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` , `settyp` )\n VALUES (NULL , 'youtubeHeight', '300', '1')";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
} else {
return _databaseError($query, $objDatabase->ErrorMsg());
}
$query = "SELECT id FROM " . DBPREFIX . "module_directory_inputfields WHERE name='youtube'";
$objCheck = $objDatabase->SelectLimit($query, 1);
if ($objCheck !== false) {
if ($objCheck->RecordCount() == 0) {
$query = "INSERT INTO `" . DBPREFIX . "module_directory_inputfields` (`id` ,`typ` ,`name` ,`title` ,`active` ,`active_backend` ,`is_required` ,`read_only` ,`sort` ,`exp_search` ,`is_search`)\n VALUES (NULL , '1', 'youtube', 'TXT_DIRECTORY_YOUTUBE', '0', '0', '0', '0', '0', '0', '0')";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
} else {
return _databaseError($query, $objDatabase->ErrorMsg());
}
$arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_directory_dir');
if ($arrColumns === false) {
setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_directory_dir'));
return false;
}
if (!array_key_exists("YOUTUBE", $arrColumns)) {
$query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir` ADD `youtube` MEDIUMTEXT NOT NULL;";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
$query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir`\n CHANGE `logo` `logo` VARCHAR(50) NULL,\n CHANGE `map` `map` VARCHAR(255) NULL,\n CHANGE `lokal` `lokal` VARCHAR(255) NULL,\n CHANGE `spez_field_11` `spez_field_11` VARCHAR(255) NULL,\n CHANGE `spez_field_12` `spez_field_12` VARCHAR(255) NULL,\n CHANGE `spez_field_13` `spez_field_13` VARCHAR(255) NULL,\n CHANGE `spez_field_14` `spez_field_14` VARCHAR(255) NULL,\n CHANGE `spez_field_15` `spez_field_15` VARCHAR(255) NULL,\n CHANGE `spez_field_16` `spez_field_16` VARCHAR(255) NULL,\n CHANGE `spez_field_17` `spez_field_17` VARCHAR(255) NULL,\n CHANGE `spez_field_18` `spez_field_18` VARCHAR(255) NULL,\n CHANGE `spez_field_19` `spez_field_19` VARCHAR(255) NULL,\n CHANGE `spez_field_20` `spez_field_20` VARCHAR(255) NULL;";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
//delete obsolete table contrexx_module_directory_access
try {
\Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_directory_access');
} catch (\Cx\Lib\UpdateException $e) {
DBG::trace();
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/********************************
* EXTENSION: Fulltext key *
* ADDED: Contrexx v3.0.0 *
********************************/
try {
$objResult = \Cx\Lib\UpdateUtil::sql('SHOW KEYS FROM `' . DBPREFIX . 'module_directory_categories` WHERE `Key_name` = "directoryindex" and (`Column_name`= "name" OR `Column_name` = "description")');
if ($objResult && $objResult->RecordCount() == 0) {
\Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_directory_categories` ADD FULLTEXT KEY `directoryindex` (`name`, `description`)');
}
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/**********************************
* EXTENSION: Content Migration *
* ADDED: Contrexx v3.0.0 *
**********************************/
try {
// migrate content page to version 3.0.1
$search = array('/(.*)/ms');
$callback = function ($matches) {
$content = $matches[1];
if (empty($content)) {
return $content;
}
// add missing placeholder {DIRECTORY_GOOGLEMAP_JAVASCRIPT_BLOCK}
if (strpos($content, '{DIRECTORY_GOOGLEMAP_JAVASCRIPT_BLOCK}') === false) {
$content .= "\n{DIRECTORY_GOOGLEMAP_JAVASCRIPT_BLOCK}";
}
// move placeholder {DIRECTORY_JAVASCRIPT} to the end of the content page
$content = str_replace('{DIRECTORY_JAVASCRIPT}', '', $content);
$content .= "\n{DIRECTORY_JAVASCRIPT}";
return $content;
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'directory'), $search, $callback, array('content'), '3.0.1');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
return true;
}
示例10: str_replace
<p>
<label>[[TXT_FILESHARING_FILE_NAME]]</label>[[FILESHARING_FILE_NAME]]
</p>
<p>
<input name="delete" type="submit" value="[[TXT_FILESHARING_CONFIRM_DELETE]]" />
</p>
</form>
<!-- END confirm_delete -->
HTMLCODE;
if (!preg_match('/<!--\\s+BEGIN\\s+confirm_delete\\s+-->.*<!--\\s+END\\s+confirm_delete\\s+-->/ms', $matches[0])) {
return str_replace('<!-- END upload_form -->', $newHtmlCode, $matches[0]);
} else {
return $matches[0];
}
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'filesharing', 'cmd' => ''), $search, $callback, array('content'), '3.1.0');
if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0') && (!\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'module_news_categories_catid') || \Cx\Lib\UpdateUtil::table_empty(DBPREFIX . 'module_news_categories_catid'))) {
try {
/************************************************
* EXTENSION: Categories as NestedSet *
* ADDED: Contrexx v3.1.0 *
************************************************/
$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)');
示例11: _guestbookUpdate
function _guestbookUpdate()
{
global $objDatabase, $_ARRAYLANG;
$arrGuestbookColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_guestbook');
if ($arrGuestbookColumns === false) {
setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_guestbook'));
return false;
}
if (isset($arrGuestbookColumns['NICKNAME']) and !isset($arrGuestbookColumns['NAME'])) {
$query = "ALTER TABLE " . DBPREFIX . "module_guestbook\n CHANGE `nickname` `name` varchar(255) NOT NULL default ''";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
if (!isset($arrGuestbookColumns['FORENAME'])) {
$query = "ALTER TABLE " . DBPREFIX . "module_guestbook\n ADD `forename` varchar(255) NOT NULL default '' AFTER `name`";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
// this addidional structure update/check is required due that the full version's structure isn't as it should be
try {
\Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_guestbook', array('id' => array('type' => 'INT(6)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => 0), 'name' => array('type' => 'VARCHAR(255)'), 'forename' => array('type' => 'VARCHAR(255)'), 'gender' => array('type' => 'CHAR(1)', 'notnull' => true, 'default' => ''), 'url' => array('type' => 'TINYTEXT'), 'email' => array('type' => 'TINYTEXT'), 'comment' => array('type' => 'TEXT'), 'ip' => array('type' => 'VARCHAR(15)'), 'location' => array('type' => 'TINYTEXT'), 'lang_id' => array('type' => 'TINYINT(2)', 'default' => '1'), 'datetime' => array('type' => 'DATETIME', 'default' => '0000-00-00 00:00:00')), array('comment' => array('fields' => array('comment'), 'type' => 'FULLTEXT')));
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/********************************
* EXTENSION: Timezone *
* ADDED: Contrexx v3.0.0 *
********************************/
try {
\Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_guestbook` CHANGE `datetime` `datetime` TIMESTAMP NOT NULL DEFAULT "0000-00-00 00:00:00"');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/********************************
* EXTENSION: Captcha *
* ADDED: Contrexx v3.0.0 *
********************************/
try {
// switch to source mode for guestbook content page
\Cx\Lib\UpdateUtil::setSourceModeOnContentPage(array('module' => 'guestbook', 'cmd' => 'post'), '3.0.1');
// migrate content page to version 3.0.1
$search = array('/(.*)/ms');
$callback = function ($matches) {
$content = $matches[1];
if (empty($content)) {
return $content;
}
$content = str_replace(array('nickname', 'NICKNAME'), array('name', 'NAME'), $content);
if (!preg_match('/<!--\\s+BEGIN\\s+guestbookForm\\s+-->.*<!--\\s+END\\s+guestbookForm\\s+-->/ms', $content)) {
$content = '<!-- BEGIN guestbookForm -->' . $content . '<!-- END guestbookForm -->';
}
if (!preg_match('/<!--\\s+BEGIN\\s+guestbookStatus\\s+-->.*<!--\\s+END\\s+guestbookStatus\\s+-->/ms', $content)) {
$content .= <<<STATUS_HTML
<!-- BEGIN guestbookStatus -->
{GUESTBOOK_STATUS}<br /><br />
<a href="index.php?section=guestbook">Zurück zum Gästebuch</a>
<!-- END guestbookStatus -->
STATUS_HTML;
}
if (!preg_match('/<!--\\s+BEGIN\\s+guestbook_captcha\\s+-->.*<!--\\s+END\\s+guestbook_captcha\\s+-->/ms', $content)) {
// migrate captcha stuff
$newCaptchaCode = <<<CAPTCHA_HTML
<!-- BEGIN guestbook_captcha -->
<p><label for="coreCaptchaCode">{TXT_GUESTBOOK_CAPTCHA}</label>{GUESTBOOK_CAPTCHA_CODE}</p>
<!-- END guestbook_captcha -->
CAPTCHA_HTML;
$content = preg_replace('/<[^>]+\\{IMAGE_URL\\}.*\\{CAPTCHA_OFFSET\\}[^>]+>/ms', $newCaptchaCode, $content);
}
// this adds the missing placeholders [[FEMALE_CHECKED]], [[MALE_CHECKED]]
$pattern = '/(<input[^>]+name=[\'"]malefemale[\'"])([^>]*>)/ms';
if (preg_match_all($pattern, $content, $match)) {
foreach ($match[0] as $idx => $input) {
// check if "checked"-placeholder is missing inputfield
if (!preg_match('/\\{(FE)?MALE_CHECKED\\}/ms', $input)) {
if (preg_match('/value\\s*=\\s*[\'"]F[\'"]/', $input)) {
$content = str_replace($input, $match[1][$idx] . ' {FEMALE_CHECKED} ' . $match[2][$idx], $content);
} elseif (preg_match('/value\\s*=\\s*[\'"]M[\'"]/', $input)) {
$content = str_replace($input, $match[1][$idx] . ' {MALE_CHECKED} ' . $match[2][$idx], $content);
}
}
}
}
return $content;
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'guestbook', 'cmd' => 'post'), $search, $callback, array('content'), '3.0.1');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
return true;
}