本文整理汇总了PHP中CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive方法的典型用法代码示例。如果您正苦于以下问题:PHP CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive方法的具体用法?PHP CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive怎么用?PHP CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKFinder_Connector_Utils_Misc
的用法示例。
在下文中一共展示了CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendResponse
* Handle FileUpload command
*
* @package CKFinder
* @subpackage CommandHandlers
* @copyright CKSource - Frederico Knabben
*/
class CKFinder_Connector_CommandHandler_FileUpload extends CKFinder_Connector_CommandHandler_CommandHandlerBase
{
/**
* Command name
*
* @access protected
* @var string
*/
protected $command = "FileUpload";
/**
* send response (save uploaded file, resize if required)
* @access public
*
*/
public function sendResponse()
{
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_NONE;
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
$oRegistry->set("FileUpload_fileName", "unknown file");
$uploadedFile = array_shift($_FILES);
if (!isset($uploadedFile['name'])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID);
}
$sUnsafeFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(CKFinder_Connector_Utils_Misc::mbBasename($uploadedFile['name']));
$sFileName = CKFinder_Connector_Utils_FileSystem::secureFileName($sUnsafeFileName);
if ($sFileName != $sUnsafeFileName) {
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
}
$oRegistry->set("FileUpload_fileName", $sFileName);
$this->checkConnector();
$this->checkRequest();
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
$_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $_resourceTypeConfig->checkIsHiddenFile($sFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
if (!$resourceTypeInfo->checkExtension($sFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
}
$oRegistry->set("FileUpload_fileName", $sFileName);
$oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
$maxSize = $resourceTypeInfo->getMaxSize();
if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size'] > $maxSize) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
}
$htmlExtensions = $_config->getHtmlExtensions();
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
if ($htmlExtensions && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions) && ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
}
$secureImageUploads = $_config->getSecureImageUploads();
if ($secureImageUploads && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
}
switch ($uploadedFile['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
break;
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
break;
case UPLOAD_ERR_NO_TMP_DIR:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
break;
case UPLOAD_ERR_CANT_WRITE:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
break;
case UPLOAD_ERR_EXTENSION:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
break;
}
$sServerDir = $this->_currentFolder->getServerPath();
//.........这里部分代码省略.........
示例2: sendResponse
/**
* send response (save uploaded file, resize if required)
* @access public
*
*/
public function sendResponse()
{
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_NONE;
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
$oRegistry->set("FileUpload_fileName", "unknown file");
$uploadedFile = array_shift($_FILES);
if (!isset($uploadedFile['name'])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID);
}
$sUnsafeFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(CKFinder_Connector_Utils_Misc::mbBasename($uploadedFile['name']));
$sFileName = str_replace(array(":", "*", "?", "|", "/"), "_", $sUnsafeFileName);
if ($_config->forceAscii()) {
$sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
}
if ($sFileName != $sUnsafeFileName) {
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
}
//file named with chinese charactor
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
$sFileName = date("Ymd") . "_" . date("His") . "." . $sExtension;
//end
$oRegistry->set("FileUpload_fileName", $sFileName);
$this->checkConnector();
$this->checkRequest();
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
$_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $_resourceTypeConfig->checkIsHiddenFile($sFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
if (!$resourceTypeInfo->checkExtension($sFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
}
$sFileNameOrginal = $sFileName;
$oRegistry->set("FileUpload_fileName", $sFileName);
$oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
$maxSize = $resourceTypeInfo->getMaxSize();
if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size'] > $maxSize) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
}
$htmlExtensions = $_config->getHtmlExtensions();
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
if ($htmlExtensions && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions) && ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
}
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
$secureImageUploads = $_config->getSecureImageUploads();
if ($secureImageUploads && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
}
switch ($uploadedFile['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
break;
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
break;
case UPLOAD_ERR_NO_TMP_DIR:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
break;
case UPLOAD_ERR_CANT_WRITE:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
break;
case UPLOAD_ERR_EXTENSION:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
break;
}
$sServerDir = $this->_currentFolder->getServerPath();
$iCounter = 0;
//personnal
$now = time();
$yearDir = $sServerDir . '/' . date('Y', $now) . '/';
if (!file_exists($yearDir) && !is_dir($yearDir)) {
mkdir($yearDir, 0777);
}
$monthDir = $yearDir . date('m', $now) . '/';
if (!file_exists($monthDir) && !is_dir($monthDir)) {
mkdir($monthDir, 0777);
}
$dayDir = $monthDir . date('d', $now);
if (!file_exists($dayDir) && !is_dir($dayDir)) {
mkdir($dayDir, 0777);
}
$sServerDir = $dayDir;
$oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl() . date('Y', $now) . '/' . date('m', $now) . '/' . date('d', $now) . '/');
//personnal end
//file_put_contents($_SERVER['DOCUMENT_ROOT'].'/s.txt',$this->_currentFolder->getUrl());
//
//.........这里部分代码省略.........
示例3: checkOneFile
/**
* Check one file for security reasons
*
* @param object $filePathInfo
* @param string $originalFileName
* @return mixed bool(false) - if security checks fails. Otherwise string - ralative zip archive path with secured filename.
*/
protected function checkOneFile($filePathInfo, $originalFileName)
{
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
// checked if it is a folder
$fileStat = $this->zip->statName($originalFileName);
if (empty($filePathInfo['extension']) && empty($fileStat['size'])) {
$sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(rtrim($fileStat['name'], '/'));
if ($this->_config->forceAscii()) {
$sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sNewFolderName);
}
if (!CKFinder_Connector_Utils_FileSystem::checkFolderPath($sNewFolderName) || $resourceTypeInfo->checkIsHiddenFolder($sNewFolderName)) {
$this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_NAME;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return false;
}
if (!is_writeable($this->_currentFolder->getServerPath())) {
$this->errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return false;
}
return $originalFileName;
}
$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($filePathInfo['basename']);
$sFileName = CKFinder_Connector_Utils_FileSystem::secureFileName($fileName);
// max file size
$maxSize = $resourceTypeInfo->getMaxSize();
if ($maxSize && $fileStat['size'] > $maxSize) {
$this->errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return false;
}
// extension
if (!$resourceTypeInfo->checkExtension($sFileName)) {
$this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return false;
}
// hidden file
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $resourceTypeInfo->checkIsHiddenFile($sFileName)) {
$this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return false;
}
// unpack file to tmp dir for detecting html and valid image
$dir = CKFinder_Connector_Utils_FileSystem::getTmpDir() . '/';
if (file_exists($dir . $sFileName) && !CKFinder_Connector_Utils_FileSystem::unlink($dir . $sFileName)) {
$this->errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return false;
}
if (copy('zip://' . $this->filePath . '#' . $originalFileName, $dir . $sFileName)) {
// html extensions
$htmlExtensions = $this->_config->getHtmlExtensions();
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($dir . $sFileName);
if ($htmlExtensions && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions) && CKFinder_Connector_Utils_FileSystem::detectHtml($dir . $sFileName) === true) {
$this->errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return false;
}
// proper image
$secureImageUploads = $this->_config->getSecureImageUploads();
if ($secureImageUploads && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($dir . $sFileName, $sExtension)) === false) {
$this->errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID;
$this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $originalFileName);
return false;
}
}
$sDirName = $filePathInfo['dirname'] != '.' ? $filePathInfo['dirname'] . '/' : '';
return $sDirName . $sFileName;
}
示例4: sendResponse
/**
* send response (save uploaded file, resize if required)
* @access public
*
*/
public function sendResponse()
{
global $met_wate_class, $met_wate_bigimg, $met_text_wate, $met_text_bigsize, $met_text_color, $met_text_angle, $met_watermark, $met_text_fonts, $met_big_wate, $met_file_maxsize, $met_img_rename;
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_NONE;
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
$oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
$oRegistry->set("FileUpload_fileName", "unknown file");
$uploadedFile = array_shift($_FILES);
if (!isset($uploadedFile['name'])) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID);
}
$sUnsafeFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(CKFinder_Connector_Utils_Misc::mbBasename($uploadedFile['name']));
$sFileName = str_replace(array(":", "*", "?", "|", "/", "——", " "), "_", $sUnsafeFileName);
if ($_config->getDisallowUnsafeCharacters()) {
$sFileName = str_replace(";", "_", $sFileName);
}
if ($_config->forceAscii()) {
$sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
}
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
$sFileName = str_replace(' ', '', $sFileName);
if ($met_img_rename) {
$sFileName = date("Ymd") . "_" . date("His") . "." . $sExtension;
}
if ($sFileName != $sUnsafeFileName) {
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
}
$oRegistry->set("FileUpload_fileName", $sFileName);
$this->checkConnector();
$this->checkRequest();
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
$_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $_resourceTypeConfig->checkIsHiddenFile($sFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
if (!$resourceTypeInfo->checkExtension($sFileName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
}
$sFileNameOrginal = $sFileName;
$oRegistry->set("FileUpload_fileName", $sFileName);
$oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
$maxSize = $resourceTypeInfo->getMaxSize();
if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size'] > $maxSize) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
}
if ($uploadedFile['size'] > $met_file_maxsize * 1024 * 1024) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG_MET);
}
$htmlExtensions = $_config->getHtmlExtensions();
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
if ($htmlExtensions && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions) && ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
}
$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
$secureImageUploads = $_config->getSecureImageUploads();
if ($secureImageUploads && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
}
switch ($uploadedFile['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
break;
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
break;
case UPLOAD_ERR_NO_TMP_DIR:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
break;
case UPLOAD_ERR_CANT_WRITE:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
break;
case UPLOAD_ERR_EXTENSION:
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
break;
}
$sServerDir = $this->_currentFolder->getServerPath();
$iCounter = 0;
while (true) {
$sFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($sServerDir, $sFileName);
if (file_exists($sFilePath)) {
$iCounter++;
$sFileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($sFileNameOrginal) . "(" . $iCounter . ")" . "." . CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
$oRegistry->set("FileUpload_fileName", $sFileName);
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_FILE_RENAMED;
} else {
//move_uploaded_file($uploadedFile['tmp_name'], $sFilePath)
if (false === copy($uploadedFile['tmp_name'], $sFilePath)) {
$iErrorNumber = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
//.........这里部分代码省略.........