public function urlToPath($fileUrl) { if (Lms_Text::pos($fileUrl, 'file:///localhost/') === 0) { $filePath = Lms_Text::replace("\\", '/', Lms_Text::replace('file:///localhost/', '', $fileUrl)); } elseif (Lms_Text::pos($fileUrl, 'file://localhost/') === 0) { $filePath = Lms_Text::replace("\\", '/', Lms_Text::replace('file://localhost/', '', $fileUrl)); } elseif (Lms_Text::pos($fileUrl, 'file:///') === 0) { $filePath = Lms_Text::replace("\\", '/', Lms_Text::replace('file:///', '', $fileUrl)); } elseif (Lms_Text::pos($fileUrl, 'file://') === 0) { $filePath = Lms_Text::replace("\\", '/', Lms_Text::replace('file://', '', $fileUrl)); } else { $filePath = $fileUrl; } if ($filePath[Lms_Text::length($filePath) - 1] == '/') { $filePath = Lms_Text::substring($filePath, 0, strlen($filePath) - 1); } return $filePath; }
private function _getFileEncoding($file) { $tmp = array(); foreach ($this->config as $key => $value) { $keyt = $key; $keyt = Lms_Text::replace("\\", '/', $key); if ($keyt[strlen($keyt) - 1] == '/') { $keyt = substr($keyt, 0, strlen($keyt) - 1); } if (Lms_Text::pos($file, $keyt) === 0) { $tmp[$keyt] = $value; if ($keyt == $file) { return $value; } } } $path = explode('/', $file); $i = count($path); while ($i > 0) { $f = ''; for ($j = 0; $j < $i; $j++) { $f = $f . $path[$j] . "/"; } foreach ($tmp as $key => $value) { if ($key == $f || Lms_Text::substring($keyt, 0, Lms_Item::length($f) - 1) == $key) { return $value; } } $i--; } return 'UTF-8'; }