本文整理匯總了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);
}
示例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;
}