<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; use ModStart\Core\Input\Request; class PathUtil { public static function isPublicNetPath($YhsOb) { goto wTiQl; ZlsY0: foreach ($KllIU as $Tx0ze) { if (Str::startsWith($YhsOb, $Tx0ze)) { return true; } } goto Ue_2X; wTiQl: $KllIU = array('//', 'http://', 'https://'); goto ZlsY0; Ue_2X: return false; goto N88a0; N88a0: } public static function fix($YhsOb, $Zw14k = null) { goto K3NrV; K3NrV: if (Str::startsWith($YhsOb, 'http://') || Str::startsWith($YhsOb, 'https://') || Str::startsWith($YhsOb, '//')) { return $YhsOb; } goto XlEE1; CsmWL: if ($Zw14k === null) { return $YhsOb; } goto eCWwf; XlEE1: if (!Str::startsWith($YhsOb, '/')) { $YhsOb = '/' . $YhsOb; } goto CsmWL; GKuj3: return $Zw14k . $YhsOb; goto QihS4; eCWwf: if (Str::endsWith($Zw14k, '/')) { $Zw14k = substr($Zw14k, 0, strlen($Zw14k) - 1); } goto GKuj3; QihS4: } public static function fixOrDefault($YhsOb, $jDU6Q, $Zw14k = null) { if (empty($YhsOb)) { return self::fix($jDU6Q, $Zw14k); } return self::fix($YhsOb, $Zw14k); } public static function fixFull($YhsOb, $Zw14k = null, $EqplL = null) { goto iEKHb; tU08P: if (Str::startsWith($YhsOb, '//')) { return $EqplL . ':' . $YhsOb; } goto cu7q1; rklaW: if (Str::endsWith($Zw14k, '/')) { $Zw14k = substr($Zw14k, 0, strlen($Zw14k) - 1); } goto Eklpc; r3gaI: if ($Zw14k === null) { $Zw14k = $EqplL . '://' . Request::domain(); } goto rklaW; Eklpc: return $Zw14k . $YhsOb; goto rCxF2; cu7q1: if (!Str::startsWith($YhsOb, '/')) { $YhsOb = '/' . $YhsOb; } goto r3gaI; YGpUD: if (null === $EqplL) { $EqplL = Request::schema(); } goto tU08P; iEKHb: if (Str::startsWith($YhsOb, 'http://') || Str::startsWith($YhsOb, 'https://')) { return $YhsOb; } goto YGpUD; rCxF2: } public static function fixFullOrDefault($YhsOb, $jDU6Q, $Zw14k = null, $EqplL = null) { if (empty($YhsOb)) { return self::fixFull($jDU6Q, $Zw14k, $EqplL); } return self::fixFull($YhsOb, $Zw14k, $EqplL); } public static function convertPublicToInternal($YhsOb) { goto nwXHz; PSXV6: $NTHcP = modstart_config('Site_PublicInternalUrlMap', array()); goto TFLP2; TFLP2: if (empty($NTHcP) || !is_array($NTHcP)) { return $YhsOb; } goto TKH1m; nwXHz: if (empty($YhsOb)) { return $YhsOb; } goto PSXV6; qPKlW: return $YhsOb; goto p8wgU; TKH1m: foreach ($NTHcP as $sOKqb) { if (!isset($sOKqb['public']) || !isset($sOKqb['internal'])) { continue; } $YhsOb = str_replace($sOKqb['public'], $sOKqb['internal'], $YhsOb); } goto qPKlW; p8wgU: } }