作者 lyh

gx

@@ -123,8 +123,19 @@ class LoginController extends BaseController @@ -123,8 +123,19 @@ class LoginController extends BaseController
123 $templateModel = new TemplateModule(); 123 $templateModel = new TemplateModule();
124 $list = $templateModel->list(); 124 $list = $templateModel->list();
125 foreach ($list as $k => $v){ 125 foreach ($list as $k => $v){
126 - $html = $this->re($v['html'],'https://develop.globalso.com/a/image/','https://ecdn6.globalso.com/public/template/');  
127 - $html = $this->re($v['html'],'https://develop.globalso.com/b/image/','https://ecdn6.globalso.com/public/template/'); 126 + preg_match_all('/\"https:\/\/develop.globalso.com\/a\/image\/(.*?)\"/', $v['html'], $matches);
  127 + if (!empty($matches[1])) {
  128 + $srcValues = $matches[1];
  129 + $imageModel = new Image();
  130 + $html = $v['html'];
  131 + foreach ($srcValues as $srcValue) {
  132 + $image_info = $imageModel->read(['hash' => $srcValue]);
  133 + if ($image_info !== false) {
  134 + $path = basename($image_info['path']);
  135 + $html = $this->re($html, $srcValue, $path);
  136 + }
  137 + }
  138 + }
128 $templateModel->edit(['html'=>$html],['id'=>$v['id']]); 139 $templateModel->edit(['html'=>$html],['id'=>$v['id']]);
129 } 140 }
130 return 1; 141 return 1;
@@ -139,17 +150,10 @@ class LoginController extends BaseController @@ -139,17 +150,10 @@ class LoginController extends BaseController
139 return $html; 150 return $html;
140 } 151 }
141 152
142 - /* // 使用正则表达式和 preg_match_all 函数来匹配多个 img 标签的 src 值  
143 - preg_match_all('/\"https:\/\/develop.globalso.com\/a\/image\/(.*?)\"/', $v['html'], $matches);  
144 - if (!empty($matches[1])) {  
145 - $srcValues = $matches[1];  
146 - $imageModel = new Image();  
147 - $html = $v['html'];  
148 - foreach ($srcValues as $srcValue) {  
149 - $image_info = $imageModel->read(['hash'=>$srcValue]);  
150 - if($image_info !== false){  
151 - $path = basename($image_info['path']);  
152 - $html = $this->re($html,$srcValue,$path);  
153 - }  
154 - }*/ 153 + public function updateHtml(){
  154 + $html = $this->re($v['html'],'https://develop.globalso.com/a/image/','https://ecdn6.globalso.com/public/template/');
  155 + $html = $this->re($v['html'],'https://develop.globalso.com/b/image/','https://ecdn6.globalso.com/public/template/');
  156 + }
  157 +
  158 +
155 } 159 }