本文整理汇总了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;
}