首先将includes下的cls_mysql.php重命名为cls_mysqli.php。然后打开,将类名修改为cls_mysqli。修改构造方法。
将与类名相同的方法名全部改为__construct,如果有__construct构造方法,删去。总之只有一个__construct构造方法。以下简称修改构造方法。
参考:http://php.net/manual/zh/language.oop5.decon.php
将cls_mysqli.php里面的mysql_全部替换为mysqli_,区分大小写。
将所有依赖于cls_mysql.php的文件全部修改了。
admin/includes/init.php api/init.php api/client/includes/init.php includes/init.php includes/fckeditor/editor/filemanager/connectors/php/config.php mobile/init.php wap/init.php
搜索以下三种方法,这三种方法的参数第一个都是mysql资源id,而,mysql_的这三种方法最后一个参数是mysql资源id,所以要一个一个改了。还好工程量不大。注意,mysqli_connect方法最后要加$dbname参数。
mysqli_connect
mysqli_query
mysqli_select_db
修改下列文件的构造方法
/api uc.php:uc_note /admin/includes cls_exchange.php:exchange cls_google_sitemap.php:google_sitemap_item cls_sql_dump.php:cls_sql_dump /includes cls_captcha.php:captcha cls_ecshop.php:ECS cls_error.php:ecs_error cls_iconv.php:Chinese cls_image.php:cls_image cls_mysql.php:cls_mysql cls_rss.php:RSS_Base;RSS_Builder;RSSItem cls_session.php:cls_session cls_sms.php:sms cls_smtp.php:smtp cls_sql_executor.php:sql_executor cls_template.php:cls_template cls_transport.php:transport /includes/fckeditor fckeditor_php4.php:FCKeditor /includes/modules/convert shopex46.php:shopex46 shopex47.php:shopex47 shopex48.php:shopex48 /includes/modules/integrates discuz55.php:discuz55 dvbbs.php:dvbbs ecshop.php:ecshop integrate.php:intergrate phpbb.php:phpbb phpwind6.php:phpwind6 ucenter.php:ucenter vbb.php:vbb /includes/modules/payment alipay.php:alipay balance.php:balance bank.php:bank cappay.php chinabank.php cod.php ips.php kuaiqian.php paypal.php paypal_ec.php post.php shenzhou.php tenpay.php tenpayc2c.php upop.php /includes/modules/shipping cac.php city_express.php ems.php flat.php fpd.php post_express.php post_mail.php presswork.php sf_express.php sto_expres.php yto.php zto.php
修改includes/lib_base.php
function gd_version() { include_once(ROOT_PATH . 'includes/cls_image.php'); $gd = new cls_image; return $gd->gd_version(); }
接下来修改includes/cls_template.php,将所有/e模式的preg_replace全部换为preg_replace_callback
<?php function fetch_str($source) //line 300 //return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source); return preg_replace_callback("/{([^\}\{\n]*)}/", 'self::select', $source); function select($tag) //line 370 //$tag = stripslashes(trim($tag)); $tag = stripslashes(trim($tag[1])); //line 493 //$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n"; $out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" , function($m){return stripslashes(trim($m[1],'\''));}, var_export($t, true)) . ";\n"; function get_val($val) //line 552 //$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val); $val = preg_replace_callback("/\[([^\[\]]*)\]/is", function($m){return '.'.str_replace('$','$',$m[1]);}, $val);//或者下面这种形式 $val = preg_replace_callback("/\[([^\[\]]*)\]/is", function($m){return '.'.$m[1];}, $val); function smarty_prefilter_preCompile($source) //line 1069-1071 /* $pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se'; $replacement = "'{include file='.strtolower('\\1'). '}'"; $source = preg_replace($pattern, $replacement, $source); */ $pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s'; //$replacement = "'{include file='.strtolower('\\1'). '}'"; //这行用不着咯,当然要注释掉 $val = preg_replace_callback("/\[([^\[\]]*)\]/is", function($m){return '.'.$m[1];}, $val);
然后是includes/lib_debug.php
function pre( $string, $return_mode = false, $tabwidth = 3 ) //line 580 $string = preg_replace('/\t+/em', "str_repeat( ' ', strlen('\\0') * $tabwidth );", $string); //$string = preg_replace_callback('/\t+/m', function($m){global $tabwidth;return str_repeat( ' ', strlen($m[0]) * $tabwidth );}, $string);
最后是/admin/template.php
//line 763 //$pattern = '/(?:<!--\\s*TemplateBeginEditable\\sname="('. implode('|',array_keys($regions)) .')"\\s*-->)(?:.*?)(?:<!--\\s*TemplateEndEditable\\s*-->)/se'; $pattern = '/(?:<!--\\s*TemplateBeginEditable\\sname="('. implode('|',array_keys($regions)) .')"\\s*-->)(?:.*?)(?:<!--\\s*TemplateEndEditable\\s*-->)/s'; //$template_content = preg_replace($pattern, "'<!-- TemplateBeginEditable name=\"\\1\" -->\r\n' . \$regions['\\1'] . '\r\n<!-- TemplateEndEditable -->';", $template_content); $template_content = preg_replace_callback($pattern, function($m){return '<!-- TemplateBeginEditable name="' . $m[1] . '" -->' . "\r\n" . $regions["'$m[1]'"] . "\r\n<!-- TemplateEndEditable -->";}, $template_content);
将下列文件的mktime()换成time()
admin/cloud.php admin/shop_config.php admin/sms_url.php<br>
将下列文件end()方法中嵌套调用的全部分解开来写
admin/flashpay.php admin/shipping.php admin/topic.php includes/lib_main.php
将下列文件array_shift()方法中嵌套调用的全部分解开来写
includes/cls_template.php
将admin/sitemap.php内 & new 全部改为 new
将下列文件中的静态调用全部修改了
admin/article.php admin/database.php admin/picture_batch.php admin/includes/cls_sql_dump.php
冒着被打骚扰的危险注册了云起帐号,下载了ecshop3.0,发现,除了主题好看了点,添加了过滤之外,其他都然并卵。。。云服务多多少少还是有点用处的
不过,里面几个补丁合适可以参考参考的
//includes_admin_template_restore_backup.php $template = $this; return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) use(&$template){return $template->select($r[1]);}, $source); //includes_cls_template_fetch_str.php $template = $this; return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) use(&$template){return $template->select($r[1]);}, $source); //includes_cls_template_get_val.php $val = preg_replace_callback("/\[([^\[\]]*)\]/is", function($r){return '.' . $r[1];}, $val); //includes_cls_template_select.php $out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/", function($r){return stripcslashes(trim($r[1], '\''));}, var_export($t, true)) . ";\n"; //includes_cls_template_smarty_prefilter_preCompile.php $pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s'; $source = preg_replace_callback($pattern, function($r){return '{include file=' . strtolower($r[1]). '}';}, $source); //includes_lib.debug_pre.php $string = preg_replace_callback('/\t+/m', function($r) use($tabwidth){return str_repeat(' ', strlen($r[0]) * $tabwidth);}, $string); //至少比我那global优雅多了
万事大吉,高版本php全都可以运行了。有问题请留言。有错误请指教。
666,支持大神!!!
非常清楚了。这的确是新版本php跑老版本的一个痛点。