20.06.2017 07:02:56 am
Вот наконец то и у меня появился PHP 7! Теперь надо кое что переписывать в движке для совместимости, так как в PHP 7 есть большие изменения. Видимо работы будет много... Всё делаю на скорую руку, в хаотичном порядке, так, что возможно будут баги, но со временем всё исправлю...
Не рекомендую делать на живом сайте.
Начал я с переключения в настройках сайта на PHP 7 и включения отладчика на тройку, в админке свой соц сети. Сразу получил ошибку:
В этом файле: include/library/phpfox/setting/setting.class.php, в строке 269, у меня:
Меняю эту строку на:
Дальше исправляю. Открываем: include/library/phpfox/parse/output.class.php, находим:
Меняем на:
Открываем: module/user/include/service/group/setting/setting.class.php, находим:
Меняем на:
Открываем: module/admincp/include/service/setting/setting.class.php, находим:
Меняем на:
Не рекомендую делать на живом сайте.
Начал я с переключения в настройках сайта на PHP 7 и включения отладчика на тройку, в админке свой соц сети. Сразу получил ошибку:
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead - include/library/phpfox/setting/setting.class.php (269)
В этом файле: include/library/phpfox/setting/setting.class.php, в строке 269, у меня:
$aRow['value_actual'] = preg_replace("/s:(.*):\"(.*?)\";/ies", "'s:'.strlen('$2').':\"$2\";'", $aRow['value_actual']);
Меняю эту строку на:
$aRow['value_actual'] = preg_replace_callback(
'/s:(.*):\"(.*?)\";/is',
function($match)
{
return 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
},
$aRow['value_actual']);
Дальше исправляю. Открываем: include/library/phpfox/parse/output.class.php, находим:
$sStr = preg_replace('/\[x=(\d+)\].+?\[\/x\]/ise', "''.stripslashes(\$this->_parseUserTagged('$1')).''", $sStr);
Меняем на:
$sStr = preg_replace_callback(
'/\[x=(\d+)\].+?\[\/x\]/is',
function($match)
{
return stripslashes($this->_parseUserTagged($match[1]));
},
$sStr);
Открываем: module/user/include/service/group/setting/setting.class.php, находим:
$aRow['value_actual'] = preg_replace("/s:(.*):\"(.*?)\";/ise", "'s:'.strlen('$2').':\"$2\";'", (isset($aRow['user_group_id2']) && isset($aRow[$aRow['user_group_id']])) ? $aRow[$aRow['user_group_id']] : $aRow['value_actual']);
Меняем на:
$aRow['value_actual'] = preg_replace_callback(
'/s:(.*):\"(.*?)\";/is',
function($match)
{
return 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
},
(isset($aRow['user_group_id2']) && isset($aRow[$aRow['user_group_id']])) ? $aRow[$aRow['user_group_id']] : $aRow['value_actual']);
Открываем: module/admincp/include/service/setting/setting.class.php, находим:
$aRow['value_actual'] = preg_replace("/s:(.*):\"(.*?)\";/ise", "'s:'.strlen('$2').':\"$2\";'", $aRow['value_actual']);
Меняем на:
$aRow['value_actual'] = preg_replace_callback(
'/s:(.*):\"(.*?)\";/is',
function($match)
{
return 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
},
$aRow['value_actual']);
- Жалоба
20.06.2017 07:52:13 am
Правки для файла: bbcode.class.php
Открываем (в этом файле много менять): include/library/phpfox/parse/bbcode.class.php, находим:
$sTxt = preg_replace('/\[code\](.*?)\[\/code\]/ise', "''.stripslashes(\$this->_code('$1', 'code')).''", $sTxt);
$sTxt = preg_replace('/\[html\](.*?)\[\/html\]/ise', "''.stripslashes(\$this->_code('$1', 'html')).''", $sTxt);
$sTxt = preg_replace('/\[php\](.*?)\[\/php\]/ise', "''.stripslashes(\$this->_code('$1', 'php')).''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\[code\](.*?)\[\/code\]/is',
function($match)
{
return stripslashes($this->_code($match[1], 'code'));
},
$sTxt);
$sTxt = preg_replace_callback(
'/\[html\](.*?)\[\/html\]/is',
function($match)
{
return stripslashes($this->_code($match[1], 'html'));
},
$sTxt);
$sTxt = preg_replace_callback(
'/\[php\](.*?)\[\/php\]/is',
function($match)
{
return stripslashes($this->_code($match[1], 'code'));
},
$sTxt);
Находим:
$sTxt = preg_replace('/\[' . $sBbcode . '\]/ise', "''.\$this->_replaceBbCode('' . \$sBbcode . '').''", $sTxt);
$sTxt = preg_replace('/\[\/' . $sBbcode . '\]/ise', "''.\$this->_replaceBbCode('' . \$sBbcode . '', 'suffix').''", $sTxt);
$sTxt = preg_replace('/\[' . $sBbcode . '=(.*?)\]/ise', "''.\$this->_replaceBbCode('' . \$sBbcode . '', 'prefix', true, '$1').''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\[' . $sBbcode . '\]/is',
function($match) use($sBbcode)
{
return $this->_replaceBbCode($sBbcode);
},
$sTxt);
$sTxt = preg_replace_callback(
'/\[\/' . $sBbcode . '\]/is',
function($match) use($sBbcode)
{
return $this->_replaceBbCode($sBbcode, 'suffix');
},
$sTxt);
$sTxt = preg_replace_callback(
'/\[' . $sBbcode . '=(.*?)\]/is',
function($match) use($sBbcode)
{
return $this->_replaceBbCode($sBbcode, 'prefix', true, $match[1]);
},
$sTxt);
Находим:
$sTxt = preg_replace('/\[table=(.*?)\](.*?)\[\/table\]/ise', "''.\$this->_parseTable('$1','$2').''", $sTxt);
$sTxt = preg_replace('/\(.+?)\[\/user\]/ise', "''.stripslashes(\$this->_parseMember('user', '$1')).''", $sTxt);
$sTxt = preg_replace('/\[profile\](.+?)\[\/profile\]/ise', "''.stripslashes(\$this->_parseMember('profile', '$1')).''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\[table=(.*?)\](.*?)\[\/table\]/is',
function($match)
{
return $this->_parseTable($match[1], $match[2]);
},
$sTxt);
$sTxt = preg_replace_callback(
'/\(.+?)\[\/user\]/is',
function($match)
{
return stripslashes($this->_parseMember('user', $match[1]));
},
$sTxt);
$sTxt = preg_replace_callback(
'/\[profile\](.+?)\[\/profile\]/is',
function($match)
{
return stripslashes($this->_parseMember('profile', $match[1]));
},
$sTxt);
Находим:
$sTxt = preg_replace('/\[quote(.*?)\](.*?)\[\/quote\]/ise', "''.stripslashes(\$this->_quote('$1','$2')).''", $sTxt);<e>
Меняем на:
$sTxt = preg_replace_callback(
'/\[quote(.*?)\](.*?)\[\/quote\]/is',
function($match)
{
return stripslashes($this->_quote($match[1], $match[2]));
},
$sTxt);
Находим:
$sTxt = preg_replace('/\[img\](.*?)\[\/img\]/ise', "''.stripslashes(\$this->_image('$1')).''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\[img\](.*?)\[\/img\]/is',
function($match)
{
return stripslashes($this->_image($match[1]));
},
$sTxt);
Находим:
$sTxt = preg_replace('/\[attachment(.*?)\](.*?)\[\/attachment\]/ise', "''.stripslashes(\$this->_attachment('$1', '$2')).''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\[attachment(.*?)\](.*?)\[\/attachment\]/is',
function($match)
{
return stripslashes($this->_attachment($match[1], $match[2]));
},
$sTxt);
Находим:
$sTxt = preg_replace('/\[attachment(.*?)\](.*?)\[\/attachment\]/ise', "''.stripslashes(\$this->_parseAttachment('$1', '$2')).''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\[attachment(.*?)\](.*?)\[\/attachment\]/is',
function($match)
{
return stripslashes($this->_parseAttachment($match[1], $match[2]));
},
$sTxt);
Находим:
$sTxt = preg_replace('/\[video\](.*?)\[\/video\]/ise', "''.stripslashes(\$this->_video('$1')).''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\[video\](.*?)\[\/video\]/is',
function($match)
{
return stripslashes($this->_video($match[1]));
},
$sTxt);
Находим:
$sTxt = preg_replace('/\[video\](.*?)\[\/video\]/ise', "''.stripslashes(\$this->_parseVideo('$1')).''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\[video\](.*?)\[\/video\]/is',
function($match)
{
return stripslashes($this->_parseVideo($match[1]));
},
$sTxt);
Находим:
$sTxt = preg_replace('/\(.+?)\[\/user\]/ise', "''.stripslashes(\$this->_parseUser('user', '$1')).''", $sTxt);
$sTxt = preg_replace('/\[profile\](.+?)\[\/profile\]/ise', "''.stripslashes(\$this->_parseUser('profile', '$1')).''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\(.+?)\[\/user\]/is',
function($match)
{
return stripslashes($this->_parseUser('user', $match[1]));
},
$sTxt);
$sTxt = preg_replace_callback(
'/\[profile\](.+?)\[\/profile\]/is',
function($match)
{
return stripslashes($this->_parseUser('profile', $match[1]));
},
$sTxt);
Находим:
$sNewTxt = preg_replace('/<span style=(.*?)>(.*)<\/span>/ise', "'' . \$this->_cleanSpan('$1', '$2') . ''", $sNewTxt);
Меняем на:
$sNewTxt = preg_replace_callback(
'/<span style=(.*?)>(.*)<\/span>/is',
function($match)
{
return $this->_cleanSpan($match[1], $match[2]);
},
$sNewTxt);
Находим:
$sTxt = preg_replace("/\[{$sKey}(.*?)\](.*?)\[\/{$sKey}\]/ise", "'' . str_replace(array('{option}', '{value}'), array(\$this->_parseOption('$1'), \$this->_parseValue('$2')), '$sValue') . ''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/\[' . $sKey . '(.*?)\](.*?)\[\/' . $sKey . '\]/is',
function($match) use($sValue)
{
return str_replace(array('{option}', '{value}'), array($this->_parseOption($match[1]), $this->_parseValue($match[2])), $sValue);
},
$sTxt);
Дважды находим:
$sTxt = preg_replace('/<(.*?)>/ise', "'<'.Phpfox::getLib('parse.input')->removeEvilAttributes('\\1').'>'", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/<(.*?)>/is',
function($match)
{
return '<' . Phpfox::getLib('parse.input')->removeEvilAttributes($match[1]) . '>';
},
$sTxt);
20.06.2017 08:01:07 am
Открываем: include/library/phpfox/template/cache.class.php, находим:
Меняем на:
Открываем: include/library/phpfox/locale/locale.class.php, находим:
Меняем на:
Открываем: include/library/getid3/getid3/write.metaflac.php, находим:
Меняем на:
Открываем: include/library/getid3/getid3/write.vorbiscomment.php, находим:
Меняем на:
Открываем: include/library/phpfox/request/request.class.php, находим:
Меняем на:
Открываем: include/library/phpmailer/default/class.phpmailer.php, находим:
Меняем на:
$sArguments = preg_replace('/\\$([A-Za-z0-9]+)/ise', "'' . \$this->_parseVariable('\$$1') . ''", $sArguments);
Меняем на:
$sArguments = preg_replace_callback(
'/\\$([A-Za-z0-9]+)/is',
function($match)
{
return $this->_parseVariable('$' . $match[1]);
},
$sArguments);
Открываем: include/library/phpfox/locale/locale.class.php, находим:
$sTxt = preg_replace("/&\#(.*?)\;/ise", "'' . \$this->_parse('$1') . ''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/&\#(.*?)\;/is',
function($match)
{
return $this->_parse($match[1]);
},
$sTxt);
Открываем: include/library/getid3/getid3/write.metaflac.php, находим:
return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
Меняем на:
return strtoupper(preg_replace('/[^ -<>-}]/', ' ', str_replace("\x00", ' ', $originalcommentname)));
Открываем: include/library/getid3/getid3/write.vorbiscomment.php, находим:
return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
Меняем на:
return strtoupper(preg_replace('/[^ -<>-}]/', ' ', str_replace("\x00", ' ', $originalcommentname)));
Открываем: include/library/phpfox/request/request.class.php, находим:
$aAux = split("\r\n", $sData);
Меняем на:
$aAux = explode("\r\n", $sData);
Открываем: include/library/phpmailer/default/class.phpmailer.php, находим:
$fileParts = split("\.", $filename);
Меняем на:
$fileParts = explode('.', $filename);
20.06.2017 08:02:55 am
[size]Правки для файла: mail.class.php
Открываем: include/library/phpfox/mail/mail.class.php, находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Открываем: include/library/phpfox/mail/mail.class.php, находим:
$sMessage = preg_replace('/\{setting var=\'(.*)\'\}/ise', "'' . Phpfox::getParam('\\1') . ''", $sMessage);
$sMessage = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1',{$this->_sArray}, false, null, '".$aUser['language_id']."') . ''", $sMessage);
$sMessagePlain = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1',{$this->_sArray}, false, null, '".$aUser['language_id']."') . ''", $sMessagePlain);
$sMessagePlain = preg_replace('/\{setting var=\'(.*)\'\}/ise', "'' . Phpfox::getParam('\\1') . ''", $sMessagePlain);
$sSubject = preg_replace('/\{setting var=\'(.*)\'\}/ise', "'' . Phpfox::getParam('\\1') . ''", $sSubject);
$sSubject = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1',{$this->_sArray}, false, null, '".$aUser['language_id']."') . ''", $sSubject);
Меняем на:
$sMessage = preg_replace_callback(
'/\{setting var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getParam($match[1]);
},
$sMessage);
$sMessage = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], $this->_sArray, false, null, $aUser['language_id']);
},
$sMessage);
$sMessagePlain = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], $this->_sArray, false, null, $aUser['language_id']);
},
$sMessagePlain);
$sMessagePlain = preg_replace_callback(
'/\{setting var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getParam($match[1]);
},
$sMessagePlain);
$sSubject = preg_replace_callback(
'/\{setting var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getParam($match[1]);
},
$sSubject);
$sSubject = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], $this->_sArray, false, null, $aUser['language_id']);
},
$sSubject);
Находим:
$sEmailSig = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1',{$this->_sArray}, false, null, '".$aUser['language_id']."') . ''", Phpfox::getParam('core.mail_signature'));
Меняем на:
$sEmailSig = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], $this->_sArray, false, null, $aUser['language_id']);
},
Phpfox::getParam('core.mail_signature'));
Находим:
$sEmailSig = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1', {$this->_sArray}, false, null, '". Phpfox::getParam('core.default_lang_id')."') . ''", Phpfox::getParam('core.mail_signature'));
$sMessagePlain = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1', {$this->_sArray}, false, null, '". Phpfox::getParam('core.default_lang_id')."') . ''", $sMessagePlain);
$sMessage = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1', {$this->_sArray}, false, null, '". Phpfox::getParam('core.default_lang_id')."') . ''", $sMessage);
$sSubject = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1', {$this->_sArray}, false, null, '". Phpfox::getParam('core.default_lang_id')."') . ''", $sSubject);
Меняем на:
$sEmailSig = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], $this->_sArray, false, null, Phpfox::getParam('core.default_lang_id'));
},
Phpfox::getParam('core.mail_signature'));
$sMessagePlain = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], $this->_sArray, false, null, Phpfox::getParam('core.default_lang_id'));
},
$sMessagePlain);
$sMessage = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], $this->_sArray, false, null, Phpfox::getParam('core.default_lang_id'));
},
$sMessage);
$sSubject = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], $this->_sArray, false, null, Phpfox::getParam('core.default_lang_id'));
},
$sSubject);
20.06.2017 08:09:17 am
Открывает: include/library/phpfox/parse/input.class.php, находим:
Меняем на:
Находим:
Меняем на:
Открывает: include/library/phpfox/parse/output.class.php, находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
$sTxt = preg_replace("/<" . substr_replace($sAllowTag, '', -1) . "(.*)>/ise", "''.\$this->_cacheHtml('\\1', null, '$sAllowTag', true).''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/<' . substr_replace($sAllowTag, '', -1) . '(.*)>/is',
function($match) use($sAllowTag)
{
return $this->_cacheHtml($match[1], null, $sAllowTag, true);
},
$sTxt);
Находим:
$sTxt = preg_replace("/<{$sAllowTag}(.*?)>(.*)<\/{$sAllowTag}>/ise", "''.\$this->_cacheHtml('\\1', '\\2', '$sAllowTag').''", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/<' . $sAllowTag . '(.*?)>(.*)<\/' . $sAllowTag . '>/is',
function($match) use($sAllowTag)
{
return $this->_cacheHtml($match[1], $match[2], $sAllowTag);
},
$sTxt);
Открывает: include/library/phpfox/parse/output.class.php, находим:
$sTxt = preg_replace('/<(.*?)>/ise', "'<'. stripslashes(str_replace('[br]', '', '\\1')) .'>'", $sTxt);
Меняем на:
$sTxt = preg_replace_callback(
'/<(.*?)>/is',
function($match)
{
return '<' . stripslashes(str_replace('[br]', '', $match[1])) . '>';
},
$sTxt);
Находим:
private function _embedWmode($aMatches)
{
if (Phpfox::getParam('core.resize_embed_video'))
{
$aMatches[1] = ' ' . $aMatches[1] . ' ';
$aMatches[1] = preg_replace('/ width=([0-9"\' ]+)([ >]+)/ise', "'' . \$this->_fixEmbedWidth('$1', 'width', '$2') . ''", $aMatches[1]);
$aMatches[1] = trim($aMatches[1]);
$aMatches[1] = ' ' . $aMatches[1] . ' ';
$aMatches[1] = preg_replace('/ height=([0-9"\' ]+)([ >]+)/ise', "'' . \$this->_fixEmbedWidth('$1', 'height', '$2') . ''", $aMatches[1]);
$aMatches[1] = trim($aMatches[1]);
$aMatches[2] = ' ' . $aMatches[2] . ' ';
$aMatches[2] = preg_replace('/ width=([0-9"\' ]+)([ >]+)/ise', "'' . \$this->_fixEmbedWidth('$1', 'width', '$2') . ''", $aMatches[2]);
$aMatches[2] = trim($aMatches[2]);
$aMatches[2] = ' ' . $aMatches[2] . ' ';
$aMatches[2] = preg_replace('/ height=([0-9"\' ]+)([ >]+)/ise', "'' . \$this->_fixEmbedWidth('$1', 'height', '$2') . ''", $aMatches[2]);
$aMatches[2] = trim($aMatches[2]);
}
return '<object ' . $aMatches[1] . '><param name:"wmode" value="transparent"></param>' . str_replace('<embed ', '<embed wmode="transparent" ', $aMatches[2]) . '</object>';
}
Меняем на:
private function _embedWmode($aMatches)
{
if (Phpfox::getParam('core.resize_embed_video'))
{
$aMatches[1] = ' ' . $aMatches[1] . ' ';
$aMatches[1] = preg_replace_callback(
'/ width=([0-9"\' ]+)([ >]+)/is',
function($match)
{
return $this->_fixEmbedWidth($match[1], 'width', $match[2]);
},
$aMatches[1]);
$aMatches[1] = trim($aMatches[1]);
$aMatches[1] = ' ' . $aMatches[1] . ' ';
$aMatches[1] = preg_replace_callback(
'/ height=([0-9"\' ]+)([ >]+)/is',
function($match)
{
return $this->_fixEmbedWidth($match[1], 'height', $match[2]);
},
$aMatches[1]);
$aMatches[1] = trim($aMatches[1]);
$aMatches[2] = ' ' . $aMatches[2] . ' ';
$aMatches[2] = preg_replace_callback(
'/ width=([0-9"\' ]+)([ >]+)/is',
function($match)
{
return $this->_fixEmbedWidth($match[1], 'width', $match[2]);
},
$aMatches[2]);
$aMatches[2] = trim($aMatches[2]);
$aMatches[2] = ' ' . $aMatches[2] . ' ';
$aMatches[2] = preg_replace_callback(
'/ height=([0-9"\' ]+)([ >]+)/is',
function($match)
{
return $this->_fixEmbedWidth($match[1], 'height', $match[2]);
},
$aMatches[2]);
$aMatches[2] = trim($aMatches[2]);
}
return '<object ' . $aMatches[1] . '><param name:"wmode" value="transparent"></param>' . str_replace('<embed ', '<embed wmode="transparent" ', $aMatches[2]) . '</object>';
}
Находим:
if (Phpfox::getParam('core.resize_embed_video'))
{
$aMatches[1] = ' ' . $aMatches[1] . ' ';
$aMatches[1] = preg_replace('/ width=([0-9"\' ]+)([ >]+)/ise', "'' . \$this->_fixEmbedWidth('$1', 'width', '$2') . ''", $aMatches[1]);
$aMatches[1] = ' ' . $aMatches[1] . ' ';
$aMatches[1] = preg_replace('/ height=([0-9"\' ]+)([ >]+)/ise', "'' . \$this->_fixEmbedWidth('$1', 'height', '$2') . ''", $aMatches[1]);
$aMatches[1] = trim($aMatches[1]);
}
Меняем на:
if (Phpfox::getParam('core.resize_embed_video'))
{
$aMatches[1] = ' ' . $aMatches[1] . ' ';
$aMatches[1] = preg_replace_callback(
'/ width=([0-9"\' ]+)([ >]+)/is',
function($match)
{
return $this->_fixEmbedWidth($match[1], 'width', $match[2]);
},
$aMatches[1]);
$aMatches[1] = ' ' . $aMatches[1] . ' ';
$aMatches[1] = preg_replace_callback(
'/ height=([0-9"\' ]+)([ >]+)/is',
function($match)
{
return $this->_fixEmbedWidth($match[1], 'height', $match[2]);
},
$aMatches[1]);
$aMatches[1] = trim($aMatches[1]);
}
20.06.2017 08:11:12 am
Открываем: module/user/include/service/auth.class.php, находим:
Меняем на:
Находим точно такую же строчку кода:
И меняем её на:
Открываем: module/ban/include/service/ban.class.php, находим:
Меняем на:
Открываем: module/admincp/include/service/process.class.php, находим:
Меняем на:
Открываем: include/library/twitter/EpiTwitter.php, находим:
Меняем на:
$sReason = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1',array(), false, null, '" . Phpfox::getUserBy('language_id') . "') . ''", $aBanned['reason']);
Меняем на:
$sReason = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], array(), false, null, Phpfox::getUserBy('language_id'));
},
$aBanned['reason']);
Находим точно такую же строчку кода:
$sReason = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1',array(), false, null, '" . Phpfox::getUserBy('language_id') . "') . ''", $aBanned['reason']);
И меняем её на:
$sReason = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], array(), false, null, Phpfox::getUserBy('language_id'));
},
$aBanned['reason']);
Открываем: module/ban/include/service/ban.class.php, находим:
$sReason = preg_replace('/\{phrase var=\'(.*)\'\}/ise', "'' . Phpfox::getPhrase('\\1',array(), false, null, '" . Phpfox::getUserBy('language_id') . "') . ''", $aFilter['reason']);
Меняем на:
$sReason = preg_replace_callback(
'/\{phrase var=\'(.*)\'\}/is',
function($match)
{
return Phpfox::getPhrase($match[1], array(), false, null, Phpfox::getUserBy('language_id'));
},
$aFilter['reason']);
Открываем: module/admincp/include/service/process.class.php, находим:
$aSetting['value_actual'] = preg_replace("/s:(.*):\"(.*?)\";/ise", "'s:'.strlen('$2').':\"$2\";'", $aSetting['value_actual']);
Меняем на:
$aSetting['value_actual'] = preg_replace_callback(
'/s:(.*):\"(.*?)\";/is',
function($match)
{
return 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
},
$aSetting['value_actual']);
Открываем: include/library/twitter/EpiTwitter.php, находим:
$endpoint = '/' . preg_replace('/[A-Z]|[0-9]+/e', "'/'.strtolower('\\0')", $parts) . '.json';
Меняем на:
$endpoint = '/' . preg_replace_callback(
'/[A-Z]|[0-9]+/',
function($match)
{
return '/' . strtolower($match[0]);
},
$parts) . '.json';
20.06.2017 08:12:44 am
Открываем: include/library/phpmailer/default/class.phpmailer.php, находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Открываем: include/library/phpmailer/class.phpmailer.php, находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
$encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
Меняем на:
$encoded = preg_replace_callback(
'/([^A-Za-z0-9!*+\/ -])/',
function($match)
{
return '=' . sprintf('%02X', ord($match[1]));
},
$encoded);
Находим:
$encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
Меняем на:
$encoded = preg_replace_callback(
'/([\(\)\"])/',
function($match)
{
return '=' . sprintf('%02X', ord($match[1]));
},
$encoded);
Находим:
$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
"'='.sprintf('%02X', ord('\\1'))", $encoded);
Меняем на:
$encoded = preg_replace_callback(
'/([\000-\011\013\014\016-\037\075\077\137\177-\377])/',
function($match)
{
return '=' . sprintf('%02X', ord($match[1]));
},
$encoded);
Открываем: include/library/phpmailer/class.phpmailer.php, находим:
$encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
Меняем на:
$encoded = preg_replace_callback(
'/([^A-Za-z0-9!*+\/ -])/',
function($match)
{
return '=' . sprintf('%02X', ord($match[1]));
},
$encoded);
Находим:
$encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
Меняем на:
$encoded = preg_replace_callback(
'/([\(\)\"])/',
function($match)
{
return '=' . sprintf('%02X', ord($match[1]));
},
$encoded);
Находим:
$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
"'='.sprintf('%02X', ord('\\1'))", $encoded);
Меняем на:
$encoded = preg_replace_callback(
'/([\000-\011\013\014\016-\037\075\077\137\177-\377])/',
function($match)
{
return '=' . sprintf('%02X', ord($match[1]));
},
$encoded);
20.06.2017 08:21:06 am
Продолжаем переводить свой движок на PHP 7. Исправляем GetID3.
Лучший вариант: обновить библиотеку полностью: http://www.getid3.org (Что я и сделал). Но если, что, то вот пример замены кода:
Открываем: include/library/getid3/getid3/getid3.php, находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Открываем: include/library/getid3/getid3/getid3.lib.php, находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Открываем: include/library/getid3/getid3/module.archive.gzip.php, находим:
Меняем на:
Открываем: include/library/getid3/getid3/module.audio-video.riff.php, находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Открываем: include/library/getid3/getid3/module.audio.mod.php, находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Открываем: include/library/getid3/getid3/module.audio.mp3.php, находим:
Меняем на:
Открываем: include/library/getid3/getid3/module.audio.mpc.php, находим:
Меняем на:
Находим:
Меняем на:
Открываем: include/library/getid3/getid3/module.tag.id3v2.php, находим:
Меняем на:
Находим:
Меняем на:
Находим:
Меняем на:
Открываем: include/library/getid3/getid3/module.tag.lyrics3.php, находим:
Меняем на:
Находим:
Меняем на:
Открываем: include/library/getid3/getid3/write.apetag.php, находим:
Находим:
Меняем на:
Открываем: include/library/getid3/getid3/write.id3v2.php, находим:
Меняем на:
Лучший вариант: обновить библиотеку полностью: http://www.getid3.org (Что я и сделал). Но если, что, то вот пример замены кода:
Открываем: include/library/getid3/getid3/getid3.php, находим:
if (eregi('([0-9]+)M', $memory_limit, $matches)) {
Меняем на:
if (preg_match('/([0-9]+)M/i', $memory_limit, $matches)) {
Находим:
if (eregi('1 File\(s\)[ ]+([0-9]+) bytes', $dir_output, $matches)) {
Меняем на:
if (preg_match('/1 File\(s\)[ ]+([0-9]+) bytes/i', $dir_output, $matches)) {
Находим:
if (eregi('([0-9]+) ([0-9]{4}-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}) '.preg_quote($filename).'$', $dir_output, $matches)) {
Меняем на:
if (preg_match('/([0-9]+) ([0-9]{4}-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}) ' . preg_quote($filename) . '$/i', $dir_output, $matches)) {
Открываем: include/library/getid3/getid3/getid3.lib.php, находим:
$returnstring .= ' '.(ereg("[\x20-\x7E]", $string{$i}) ? $string{$i} : '¤');
Меняем на:
$returnstring .= ' ' . (preg_match('/[\x20-\x7E]/', $string{$i}) ? $string{$i} : '¤');
Находим:
if (ereg("^[\\]?([0-9a-f]{32})", strtolower(`$commandline`), $r)) {
Меняем на:
if (preg_match('/^[\\]?([0-9a-f]{32})/', strtolower(`$commandline`), $r)) {
Находим:
if (ereg("^([0-9a-f]{32})[ \t\n\r]", `md5sum "$file"`, $r)) {
Меняем на:
if (preg_match('/^([0-9a-f]{32})[ \t\n\r]/', `md5sum "$file"`, $r)) {
Находим:
if (ereg("^sha1=([0-9a-f]{40})", strtolower(`$commandline`), $r)) {
Меняем на:
if (preg_match('/^sha1=([0-9a-f]{40})/', strtolower(`$commandline`), $r)) {
Находим:
if (ereg("^([0-9a-f]{40})[ \t\n\r]", strtolower(`$commandline`), $r)) {
Меняем на:
if (preg_match('/^([0-9a-f]{40})[ \t\n\r]/', strtolower(`$commandline`), $r)) {
Открываем: include/library/getid3/getid3/module.archive.gzip.php, находим:
$thisThisFileInfo['filename'] = eregi_replace('.gz$', '', $ThisFileInfo['filename']);
Меняем на:
$thisThisFileInfo['filename'] = preg_replace('/.gz$/i', '', $ThisFileInfo['filename']);
Открываем: include/library/getid3/getid3/module.audio-video.riff.php, находим:
if (eregi('^(movi|rec )$', $listname)) {
Меняем на:
if (preg_match('/^(movi|rec )$/i', $listname)) {
Находим:
if (eregi('^[0-9]{2}(wb|pc|dc|db)$', $chunkname)) {
Меняем на:
if (preg_match('/^[0-9]{2}(wb|pc|dc|db)$/i', $chunkname)) {
Находим:
if (!ereg('^[0-9]{2}(wb|pc|dc|db)$', $chunkname) && !empty($LISTchunkParent) && (($RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size']) <= $LISTchunkMaxOffset)) {
Меняем на:
if (!preg_match('/^[0-9]{2}(wb|pc|dc|db)$/', $chunkname) && !empty($LISTchunkParent) && (($RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size']) <= $LISTchunkMaxOffset)) {
Открываем: include/library/getid3/getid3/module.audio.mod.php, находим:
if (!ereg('^(M.K.|[5-9]CHN|[1-3][0-9]CH)$', $FormatID)) {
Меняем на:
if (!preg_match('/^(M.K.|[5-9]CHN|[1-3][0-9]CH)$/', $FormatID)) {
Находим:
if (!ereg('^Extended Module$', $FormatID)) {
Меняем на:
if (!preg_match('/^Extended Module$/', $FormatID)) {
Находим:
if (!ereg('^SCRM$', $FormatID)) {
Меняем на:
if (!preg_match('/^SCRM$/', $FormatID)) {
Находим:
if (!ereg('^IMPM$', $FormatID)) {
Меняем на:
if (!preg_match('/^IMPM$/', $FormatID)) {
Открываем: include/library/getid3/getid3/module.audio.mp3.php, находим:
if (!eregi('_distribution$', $key1)) {
Меняем на:
if (!preg_match('/_distribution$/i', $key1)) {
Открываем: include/library/getid3/getid3/module.audio.mpc.php, находим:
if (ereg('^MPCK', $ThisFileInfo['mpc']['header']['preamble'])) {
Меняем на:
if (preg_match('/^MPCK/', $ThisFileInfo['mpc']['header']['preamble'])) {
Находим:
} elseif (ereg('^MP\+', $ThisFileInfo['mpc']['header']['preamble'])) {
Меняем на:
} elseif (preg_match('/^MP\+/', $ThisFileInfo['mpc']['header']['preamble'])) {
Открываем: include/library/getid3/getid3/module.tag.id3v2.php, находим:
if (!isset($thisfile_id3v2['comments']['year']) && ereg('^([0-9]{4})', trim(@$thisfile_id3v2['comments']['recording_time'][0]), $matches)) {
Меняем на:
if (!isset($thisfile_id3v2['comments']['year']) && preg_match('/^([0-9]{4})/', trim(@$thisfile_id3v2['comments']['recording_time'][0]), $matches)) {
Находим:
} elseif (eregi('^([0-9]+|CR|RX)$', $genrestring)) {
Меняем на:
} elseif (preg_match('/^([0-9]+|CR|RX)$/i', $genrestring)) {
Находим:
case 2:
return ereg('[A-Z][A-Z0-9]{2}', $framename);
break;
case 3:
case 4:
return ereg('[A-Z][A-Z0-9]{3}', $framename);
break;
Меняем на:
case 2:
return preg_match('/[A-Z][A-Z0-9]{2}/', $framename);
break;
case 3:
case 4:
return preg_match('/[A-Z][A-Z0-9]{3}/', $framename);
break;
Открываем: include/library/getid3/getid3/module.tag.lyrics3.php, находим:
if (ereg('^\\[([0-9]{2}):([0-9]{2})\\]$', $rawtimestamp, $regs)) {
Меняем на:
if (preg_match('/^\\[([0-9]{2}):([0-9]{2})\\]$/', $rawtimestamp, $regs)) {
Находим:
while (ereg('^(\\[[0-9]{2}:[0-9]{2}\\])', $lyricline, $regs)) {
Меняем на:
while (preg_match('/^(\\[[0-9]{2}:[0-9]{2}\\])/', $lyricline, $regs)) {
Открываем: include/library/getid3/getid3/write.apetag.php, находим:
Находим:
$itemkey = eregi_replace("[^\x20-\x7E]", '', $itemkey);
Меняем на:
$itemkey = preg_replace('/[^\x20-\x7E]/i', '', $itemkey);
Открываем: include/library/getid3/getid3/write.id3v2.php, находим:
} elseif (!eregi("^[[:alnum:]]([-.]?[0-9a-z])*\.[a-z]{2,3}$", $parts['host'], $regs) && !IsValidDottedIP($parts['host'])) {
return false;
} elseif (!eregi("^([[:alnum:]-]|[\_])*$", $parts['user'], $regs)) {
return false;
} elseif (!eregi("^([[:alnum:]-]|[\_])*$", $parts['pass'], $regs)) {
return false;
} elseif (!eregi("^[[:alnum:]/_\.@~-]*$", $parts['path'], $regs)) {
return false;
} elseif (!eregi("^[[:alnum:]?&=+:;_()%#/,\.-]*$", $parts['query'], $regs)) {
Меняем на:
} elseif (!preg_match('/^[[:alnum:]]([-.]?[0-9a-z])*\.[a-z]{2,3}$/i', $parts['host'], $regs) && !IsValidDottedIP($parts['host'])) {
return false;
} elseif (!preg_match('/^([[:alnum:]-]|[\_])*$/i', $parts['user'], $regs)) {
return false;
} elseif (!preg_match('/^([[:alnum:]-]|[\_])*$/i', $parts['pass'], $regs)) {
return false;
} elseif (!preg_match('/^[[:alnum:]/_\.@~-]*$/i', $parts['path'], $regs)) {
return false;
} elseif (!preg_match('/^[[:alnum:]?&=+:;_()%#/,\.-]*$/i', $parts['query'], $regs)) {
20.06.2017 08:24:43 am
Открываем: user/include/service/group/setting/process.class.php, находим:
Меняем на:
При включенном дебаге, на PHP 7, при просмотре фотографии, например, на стене, можно видить такую ошибку:
Я решил эту проблему так: открываю: include/library/phpfox/session/handler/file.class.php, нахожу:
И меняю на:
Готово!
return Phpfox_Error::set(mysql_real_escape_string(Phpfox::getPhrase('core.money_field_only_accepts_numbers_and_point')));
Меняем на:
return Phpfox_Error::set($this->database()->escape(Phpfox::getPhrase('core.money_field_only_accepts_numbers_and_point')));
При включенном дебаге, на PHP 7, при просмотре фотографии, например, на стене, можно видить такую ошибку:
Warning: Unknown: Session callback expects true/false return value
Warning: Unknown: Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/tmp)
Warning: Unknown: Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/tmp)
Я решил эту проблему так: открываю: include/library/phpfox/session/handler/file.class.php, нахожу:
$bReturn = fwrite($hFp, $mData);
fclose($hFp);
return $bReturn;
И меняю на:
$bReturn = fwrite($hFp, $mData);
fclose($hFp);
return (bool) $bReturn;
Готово!