<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; use ModStart\Core\Assets\AssetsUtil; class HtmlUtil { public static function replaceImageSrcToLazyLoad($xMSF0, $fLuN9 = 'data-src', $qFmoU = false) { goto M3rQu; Y_2I_: if ($qFmoU) { foreach ($zhVL6[0] as $U9AsU => $ohYVl) { $xMSF0 = str_replace($ohYVl, $zhVL6[1][$U9AsU] . $fLuN9 . '="' . AssetsUtil::fix($zhVL6[2][$U9AsU]) . '"' . $zhVL6[3][$U9AsU], $xMSF0); } } else { foreach ($zhVL6[0] as $U9AsU => $ohYVl) { $xMSF0 = str_replace($ohYVl, $zhVL6[1][$U9AsU] . $fLuN9 . '="' . AssetsUtil::fix($zhVL6[2][$U9AsU]) . '"' . $zhVL6[3][$U9AsU], $xMSF0); } } goto tC_TF; M3rQu: preg_match_all('/(<img.*?)src="(.*?)"(.*?>)/i', $xMSF0, $zhVL6); goto Y_2I_; tC_TF: return $xMSF0; goto GNy_6; GNy_6: } public static function replaceImageSrcToFull($xMSF0, $qFmoU = false) { goto NVYUs; NVYUs: preg_match_all('/(<img.*?)src="(.*?)"(.*?>)/i', $xMSF0, $zhVL6); goto Jro7F; xXBeb: return $xMSF0; goto J7RlC; Jro7F: foreach ($zhVL6[0] as $U9AsU => $ohYVl) { $xMSF0 = str_replace($ohYVl, $zhVL6[1][$U9AsU] . 'src="' . AssetsUtil::fixFull($zhVL6[2][$U9AsU]) . '"' . $zhVL6[3][$U9AsU], $xMSF0); } goto xXBeb; J7RlC: } public static function extractTextAndImages($xMSF0) { goto DGyuT; O3D9x: $PmoCK = preg_replace('/<[^>]+>/', '', $xMSF0); goto bwhMU; ditzE: return $bWYKS; goto tzGzh; CyhxQ: if (!empty($zhVL6[1])) { $bWYKS['images'] = $zhVL6[1]; } goto ditzE; FT9ua: preg_match_all('/<img.*?src="(.*?)".*?>/i', $xMSF0, $zhVL6); goto CyhxQ; bwhMU: $bWYKS['text'] = $PmoCK; goto FT9ua; DGyuT: $bWYKS = array('text' => '', 'images' => array()); goto O3D9x; tzGzh: } public static function cover($xMSF0) { goto z82mv; rk806: return null; goto onkY9; z82mv: preg_match_all('/<img.*?src="(.*?)".*?>/i', $xMSF0, $zhVL6); goto zTUbC; zTUbC: if (!empty($zhVL6[1][0])) { return $zhVL6[1][0]; } goto rk806; onkY9: } public static function text($xMSF0, $c0fAD = null) { goto YxA5f; uoXHb: return str_replace(array('&nbsp;'), array(' '), $PmoCK); goto G94F0; YxA5f: $PmoCK = preg_replace('/<[^>]+>/', '', $xMSF0); goto JZWc0; JZWc0: if (null !== $c0fAD) { $PmoCK = Str::limit($PmoCK, $c0fAD); } goto uoXHb; G94F0: } public static function filter($xMSF0) { if (empty($xMSF0)) { return ''; } return clean($xMSF0, array('HTML.Allowed' => 'b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[style|width|height|alt|src],span,br,h1,h2,h3,h4,h5,blockquote', 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align,max-width,border,width', 'AutoFormat.AutoParagraph' => true, 'AutoFormat.RemoveEmpty' => true, 'CSS.MaxImgLength' => null)); } public static function filter2($xMSF0) { goto VPPxk; VPPxk: preg_match_all('/<iframe.*?<\\/iframe>/i', $xMSF0, $q2Fl0); goto xG9Ip; eNnxk: $tmU3I = array('search' => array(), 'replace' => array()); goto o26ud; xG9Ip: preg_match_all('/<audio.*?<\\/audio>/i', $xMSF0, $h1LJN); goto eNnxk; FR_pN: return str_replace($tmU3I['replace'], $tmU3I['search'], $xMSF0); goto a2M70; FNGNg: $xMSF0 = str_replace($tmU3I['search'], $tmU3I['replace'], $xMSF0); goto BghYR; BghYR: $xMSF0 = clean($xMSF0, array('HTML.Allowed' => 'b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[style|width|height|alt|src],span,br,h1,h2,h3,h4,h5,blockquote', 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align,max-width,border,width', 'AutoFormat.AutoParagraph' => true, 'AutoFormat.RemoveEmpty' => true, 'CSS.MaxImgLength' => null)); goto FR_pN; mEGm5: foreach (array_merge($q2Fl0[0], $h1LJN[0]) as $ohYVl) { $tmU3I['search'][] = $ohYVl; $tmU3I['replace'][] = '--iframe--' . $XIWRg++ . '--'; } goto FNGNg; o26ud: $XIWRg = 0; goto mEGm5; a2M70: } public static function text2html($PmoCK, $ySGEb = true) { goto DHpiY; yScn4: if ($ySGEb) { $PmoCK = htmlspecialchars($PmoCK, ENT_QUOTES, 'UTF-8', false); } goto eudBA; eudBA: $PmoCK = str_replace('
', '', $PmoCK); goto V7T1p; DHpiY: if (empty($PmoCK)) { return ''; } goto yScn4; R3AZ3: return '<p>' . $PmoCK . '</p>'; goto gz2Wn; V7T1p: $PmoCK = str_replace('
', '</p><p>', $PmoCK); goto tMio4; tMio4: $PmoCK = str_replace('<p></p>', '<p>&nbsp;</p>', $PmoCK); goto R3AZ3; gz2Wn: } public static function text2htmlSimpleRich($PmoCK, $ySGEb = true) { goto hCTUT; RTwae: return $xMSF0; goto oh_fC; hCTUT: $xMSF0 = self::text2html($PmoCK, $ySGEb); goto Cz2n_; Cz2n_: $xMSF0 = preg_replace('|([\\w\\d]*)\\s?(https?://([\\d\\w\\.-]+\\.[\\w\\.]{2,6})[^\\s\\]\\[\\<\\>]*/?)|i', '<a href="$2" target="_blank">$0</a>', $xMSF0); goto RTwae; oh_fC: } public static function html2text($PmoCK) { return str_replace(array('</p>', '<p>'), array('
', ''), $PmoCK); } public static function workCount($xMSF0) { goto Mo7yO; kP1eO: $xMSF0 = preg_replace('/[^\\x{4e00}-\\x{9fa5}]+/u', '', $xMSF0); goto YREwz; Mo7yO: $xMSF0 = preg_replace('/<[^>]+>/', '^', $xMSF0); goto Ijbes; YREwz: $aCi_L = mb_strlen($xMSF0, 'utf-8'); goto XMdut; XMdut: return $Qcfgp + $aCi_L; goto RYFi1; uIYaZ: $Qcfgp = count($zhVL6[0]); goto H7fKe; H7fKe: $xMSF0 = str_replace('^', '', $xMSF0); goto kP1eO; Ijbes: preg_match_all('/[a-z0-9]+/i', $xMSF0, $zhVL6); goto uIYaZ; RYFi1: } }