本文整理汇总了PHP中Cx\Lib\UpdateUtil::migrateContentPageUsingRegex方法的典型用法代码示例。如果您正苦于以下问题:PHP UpdateUtil::migrateContentPageUsingRegex方法的具体用法?PHP UpdateUtil::migrateContentPageUsingRegex怎么用?PHP UpdateUtil::migrateContentPageUsingRegex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cx\Lib\UpdateUtil
的用法示例。
在下文中一共展示了UpdateUtil::migrateContentPageUsingRegex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _galleryUpdate
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;
}
示例2: _newsletterUpdate
//.........这里部分代码省略.........
} 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) {
示例3: _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;
示例4: _accessUpdate
//.........这里部分代码省略.........
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
*
*****************************/
示例5: array
\Cx\Lib\UpdateUtil::setSourceModeOnContentPage(array('module' => 'shop', 'cmd' => 'payment'), '3.0.3');
// replace comments placeholder with a sigma block , news module
$search = array('/.*\\{NEWS_COUNT_COMMENTS\\}.*/ms');
$callback = function ($matches) {
$placeholder = '{NEWS_COUNT_COMMENTS}';
$htmlCode = '<!-- BEGIN news_comments_count -->' . $placeholder . '<!-- END news_comments_count -->';
if (!preg_match('/<!--\\s+BEGIN\\s+news_comments_count\\s+-->.*<!--\\s+END\\s+news_comments_count\\s+-->/ms', $matches[0])) {
return str_replace($placeholder, $htmlCode, $matches[0]);
} else {
return $matches[0];
}
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'news', 'cmd' => ''), $search, $callback, array('content'), '3.0.3');
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'news', 'cmd' => 'details'), $search, $callback, array('content'), '3.0.3');
// 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');
} 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;
}
// 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);