<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; use ModStart\Core\Assets\AssetsUtil; use ModStart\Misc\Html\Purifier; class HtmlUtil { public static function replaceImageSrcToLazyLoad($vVYCS, $srPZF = 'data-src', $VV2wH = false) { goto rfYA6; NZsyO: if ($VV2wH) { foreach ($H_mB1[0] as $B34tD => $Xz28r) { $vVYCS = str_replace($Xz28r, $H_mB1[1][$B34tD] . $srPZF . '="' . AssetsUtil::fix($H_mB1[2][$B34tD]) . '"' . $H_mB1[3][$B34tD], $vVYCS); } } else { foreach ($H_mB1[0] as $B34tD => $Xz28r) { $vVYCS = str_replace($Xz28r, $H_mB1[1][$B34tD] . $srPZF . '="' . AssetsUtil::fix($H_mB1[2][$B34tD]) . '"' . $H_mB1[3][$B34tD], $vVYCS); } } goto fPPgb; fPPgb: return $vVYCS; goto Mb1KV; rfYA6: preg_match_all('/(<img.*?)src="(.*?)"(.*?>)/i', $vVYCS, $H_mB1); goto NZsyO; Mb1KV: } public static function replaceImageSrcToFull($vVYCS, $VV2wH = false, $Hbuf7 = null) { goto eIjv7; eK2fd: return $vVYCS; goto Pcl19; UyQC8: foreach ($H_mB1[0] as $B34tD => $Xz28r) { if ($Hbuf7) { $vVYCS = str_replace($Xz28r, $H_mB1[1][$B34tD] . 'src="' . AssetsUtil::fixFullWithCdn($H_mB1[2][$B34tD], $Hbuf7) . '"' . $H_mB1[3][$B34tD], $vVYCS); } else { if ($VV2wH) { $vVYCS = str_replace($Xz28r, $H_mB1[1][$B34tD] . 'src="' . AssetsUtil::fixFull($H_mB1[2][$B34tD]) . '"' . $H_mB1[3][$B34tD], $vVYCS); } else { $vVYCS = str_replace($Xz28r, $H_mB1[1][$B34tD] . 'src="' . AssetsUtil::fixCurrentDomain($H_mB1[2][$B34tD]) . '"' . $H_mB1[3][$B34tD], $vVYCS); } } } goto eK2fd; eIjv7: preg_match_all('/(<img.*?)src="(.*?)"(.*?>)/i', $vVYCS, $H_mB1); goto UyQC8; Pcl19: } public static function recordsReplaceImageSrcToFull(&$YDsPC, $l6tBV, $VV2wH = false, $Hbuf7 = null) { foreach ($YDsPC as $B34tD => $Xz28r) { $YDsPC[$B34tD][$l6tBV] = self::replaceImageSrcToFull($Xz28r[$l6tBV], $VV2wH, $Hbuf7); } } public static function extractTextAndImages($vVYCS) { goto vnoi5; nbshP: if (!empty($H_mB1[1])) { $pNhh1['images'] = $H_mB1[1]; } goto nfXj6; nfXj6: return $pNhh1; goto I91Tf; MXiDn: preg_match_all('/<img.*?src="(.*?)".*?>/i', $vVYCS, $H_mB1); goto nbshP; TiXpT: $pNhh1['text'] = $WKfeb; goto MXiDn; vnoi5: $pNhh1 = array('text' => '', 'images' => array()); goto AiMCq; AiMCq: $WKfeb = preg_replace('/<[^>]+>/', '', $vVYCS); goto TiXpT; I91Tf: } public static function cover($vVYCS) { goto uzwT5; veo67: if (!empty($H_mB1[1][0])) { return $H_mB1[1][0]; } goto Sohk_; uzwT5: preg_match_all('/<img.*?src="(.*?)".*?>/i', $vVYCS, $H_mB1); goto veo67; Sohk_: return null; goto Dqyk7; Dqyk7: } public static function text($vVYCS, $JAcjY = null) { goto UHLpT; ZLv_5: if (null !== $JAcjY) { $WKfeb = Str::limit($WKfeb, $JAcjY); } goto u4D_r; u4D_r: return str_replace(array('&nbsp;'), array(' '), $WKfeb); goto mzDoN; UHLpT: $WKfeb = preg_replace('/<[^>]+>/', '', $vVYCS); goto ZLv_5; mzDoN: } public static function filter($vVYCS) { if (empty($vVYCS)) { return $vVYCS; } return Purifier::cleanHtml($vVYCS); } public static function filter2($vVYCS) { if (empty($vVYCS)) { return $vVYCS; } return Purifier::cleanHtml($vVYCS); } public static function text2html($WKfeb, $GhlkT = true) { goto Dv64h; s0C23: return '<p>' . $WKfeb . '</p>'; goto TGxyV; hfDl9: $WKfeb = str_replace('
', '</p><p>', $WKfeb); goto cE2F1; cE2F1: $WKfeb = str_replace('<p></p>', '<p>&nbsp;</p>', $WKfeb); goto s0C23; Z5_fH: if ($GhlkT) { $WKfeb = htmlspecialchars($WKfeb, ENT_QUOTES, 'UTF-8', false); } goto vYfms; vYfms: $WKfeb = str_replace('
', '', $WKfeb); goto hfDl9; Dv64h: if (empty($WKfeb)) { return ''; } goto Z5_fH; TGxyV: } public static function text2htmlSimpleRich($WKfeb, $GhlkT = true) { goto cu39b; laqyd: return $vVYCS; goto UFlfJ; ZqQYC: $vVYCS = preg_replace('|([\\w\\d]*)\\s?(https?://([\\d\\w\\.-]+\\.[\\w\\.]{2,6})[^\\s\\]\\[\\<\\>]*/?)|i', '<a href="$2" target="_blank">$0</a>', $vVYCS); goto laqyd; cu39b: $vVYCS = self::text2html($WKfeb, $GhlkT); goto ZqQYC; UFlfJ: } public static function html2text($WKfeb) { return str_replace(array('</p>', '<p>'), array('
', ''), $WKfeb); } public static function workCount($vVYCS) { goto piZEz; Y3QZq: $LsTnz = count($H_mB1[0]); goto r8Bwz; piZEz: $vVYCS = preg_replace('/<[^>]+>/', '^', $vVYCS); goto UTBGY; bgOVM: return $LsTnz + $x0Ey7; goto Rr3iY; Dc3Pl: $x0Ey7 = mb_strlen($vVYCS, 'utf-8'); goto bgOVM; r8Bwz: $vVYCS = str_replace('^', '', $vVYCS); goto sMCj6; UTBGY: preg_match_all('/[a-z0-9]+/i', $vVYCS, $H_mB1); goto Y3QZq; sMCj6: $vVYCS = preg_replace('/[^\\x{4e00}-\\x{9fa5}]+/u', '', $vVYCS); goto Dc3Pl; Rr3iY: } }