正在显示
1 个修改的文件
包含
18 行增加
和
10 行删除
| @@ -23,6 +23,7 @@ use App\Models\Project\Project; | @@ -23,6 +23,7 @@ use App\Models\Project\Project; | ||
| 23 | use App\Models\Service\Service; | 23 | use App\Models\Service\Service; |
| 24 | use App\Models\Sms\SmsLog; | 24 | use App\Models\Sms\SmsLog; |
| 25 | use App\Models\Template\Template; | 25 | use App\Models\Template\Template; |
| 26 | +use App\Models\Template\TemplateModule; | ||
| 26 | use App\Models\User\User as UserModel; | 27 | use App\Models\User\User as UserModel; |
| 27 | use App\Utils\EncryptUtils; | 28 | use App\Utils\EncryptUtils; |
| 28 | use \Illuminate\Support\Facades\Cache; | 29 | use \Illuminate\Support\Facades\Cache; |
| @@ -259,27 +260,34 @@ class LoginController extends BaseController | @@ -259,27 +260,34 @@ class LoginController extends BaseController | ||
| 259 | 260 | ||
| 260 | 261 | ||
| 261 | public function ceshi(){ | 262 | public function ceshi(){ |
| 262 | - $templateModel = new Template(); | ||
| 263 | - $lists = $templateModel->list(); | ||
| 264 | - foreach ($lists as $k => $v){ | 263 | + $templateModel = new TemplateModule(); |
| 264 | + $list = $templateModel->list(); | ||
| 265 | + foreach ($list as $k => $v){ | ||
| 265 | // 使用正则表达式和 preg_match_all 函数来匹配多个 img 标签的 src 值 | 266 | // 使用正则表达式和 preg_match_all 函数来匹配多个 img 标签的 src 值 |
| 266 | preg_match_all('/\"https:\/\/admin.item.globalso.site\/a\/image\/(.*?)\"/', $v['html'], $matches); | 267 | preg_match_all('/\"https:\/\/admin.item.globalso.site\/a\/image\/(.*?)\"/', $v['html'], $matches); |
| 267 | if (!empty($matches[1])) { | 268 | if (!empty($matches[1])) { |
| 268 | $srcValues = $matches[1]; | 269 | $srcValues = $matches[1]; |
| 269 | $imageModel = new Image(); | 270 | $imageModel = new Image(); |
| 271 | + $html = $v['html']; | ||
| 270 | foreach ($srcValues as $srcValue) { | 272 | foreach ($srcValues as $srcValue) { |
| 271 | $image_info = $imageModel->read(['hash'=>$srcValue]); | 273 | $image_info = $imageModel->read(['hash'=>$srcValue]); |
| 272 | if($image_info !== false){ | 274 | if($image_info !== false){ |
| 273 | - $path = $image_info['path']; | ||
| 274 | - $v['html'] = str_replace( | ||
| 275 | - '/a/image/'.$srcValue, | ||
| 276 | - $path, | ||
| 277 | - $v['html'] | ||
| 278 | - ); | ||
| 279 | - $templateModel->edit(['html'=>$v['html']],['id'=>$v['id']]); | 275 | + $path = basename($image_info['path']); |
| 276 | + $html = $this->re($html,'/a/image/'.$srcValue,$path); | ||
| 280 | } | 277 | } |
| 281 | } | 278 | } |
| 279 | + $templateModel->edit(['html'=>$html],['id'=>$v['id']]); | ||
| 282 | } | 280 | } |
| 283 | } | 281 | } |
| 282 | + return 1; | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | + public function re(&$html,$srcValue,$path){ | ||
| 286 | + $html = str_replace( | ||
| 287 | + $srcValue, | ||
| 288 | + $path, | ||
| 289 | + $html | ||
| 290 | + ); | ||
| 291 | + return $html; | ||
| 284 | } | 292 | } |
| 285 | } | 293 | } |
-
请 注册 或 登录 后发表评论