當前位置: 首頁>>代碼示例>>PHP>>正文


PHP text::clearWhitespaces方法代碼示例

本文整理匯總了PHP中text::clearWhitespaces方法的典型用法代碼示例。如果您正苦於以下問題:PHP text::clearWhitespaces方法的具體用法?PHP text::clearWhitespaces怎麽用?PHP text::clearWhitespaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在text的用法示例。


在下文中一共展示了text::clearWhitespaces方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validateExtension

 protected function validateExtension($ext, $type)
 {
     $ext = trim(strtolower($ext));
     if (!isset($this->types[$type])) {
         return false;
     }
     $exts = strtolower(text::clearWhitespaces($this->config['deniedExts']));
     if (strlen($exts)) {
         $exts = explode(" ", $exts);
         if (in_array($ext, $exts)) {
             return false;
         }
     }
     $exts = trim($this->types[$type]);
     if (!strlen($exts) || substr($exts, 0, 1) == "*") {
         return true;
     }
     if (substr($exts, 0, 1) == "!") {
         $exts = explode(" ", trim(strtolower(substr($exts, 1))));
         return !in_array($ext, $exts);
     }
     $exts = explode(" ", trim(strtolower($exts)));
     return in_array($ext, $exts);
 }
開發者ID:mikegrahamjones,項目名稱:kcfinder,代碼行數:24,代碼來源:uploader.php

示例2: act_rename

 protected function act_rename()
 {
     $dir = $this->postDir();
     if (!isset($this->post['dir']) || !isset($this->post['file']) || !isset($this->post['newName']) || false === ($file = "{$dir}/{$this->post['file']}") || !file_exists($file) || !is_readable($file) || !file::isWritable($file)) {
         $this->errorMsg("Unknown error.");
     }
     $newName = text::clearWhitespaces($this->post['newName']);
     if (!strlen($newName)) {
         $this->errorMsg("Please enter new file name.");
     }
     if (preg_match('/\\//s', $newName)) {
         $this->errorMsg("Unallowable characters in file name.");
     }
     if (substr($newName, 0, 1) == ".") {
         $this->errorMsg("File name shouldn't begins with '.'");
     }
     $newName = "{$dir}/{$newName}";
     if (file_exists($newName)) {
         $this->errorMsg("A file or folder with that name already exists.");
     }
     $ext = file::getExtension($newName);
     if (!$this->validateExtension($ext, $this->type)) {
         $this->errorMsg("Denied file extension.");
     }
     if (!@rename($file, $newName)) {
         $this->errorMsg("Unknown error.");
     }
     $thumbDir = "{$this->thumbsTypeDir}/{$this->post['dir']}";
     $thumbFile = "{$thumbDir}/{$this->post['file']}";
     if (file_exists($thumbFile)) {
         @rename($thumbFile, "{$thumbDir}/" . basename($newName));
     }
     return true;
 }
開發者ID:rozlemieux,項目名稱:fissionstrategy.com,代碼行數:34,代碼來源:browser.php


注:本文中的text::clearWhitespaces方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。