本文整理汇总了PHP中CFile::CheckFile方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::CheckFile方法的具体用法?PHP CFile::CheckFile怎么用?PHP CFile::CheckFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::CheckFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnCommentAdd
function OnCommentAdd($entityType, $entityID, &$arPost)
{
global $USER;
$arParams =& $this->component->arParams;
$arResult =& $this->component->arResult;
$iFileSize = intval(COption::GetOptionString("forum", "file_max_size", 5242880));
$_REQUEST['FILE_NEW'] = isset($_REQUEST['FILE_NEW']) && is_array($_REQUEST['FILE_NEW']) ? $_REQUEST['FILE_NEW'] : array();
$arPost["FILES"] = array();
foreach ($_REQUEST['FILE_NEW'] as $fileID) {
$arPost["FILES"][$fileID] = array("FILE_ID" => $fileID);
$attach_file = CFile::MakeFileArray(intval($fileID));
$attach = "";
if ($attach_file && is_set($attach_file, "name")) {
if ($arParams["ALLOW_UPLOAD"] == "Y") {
$attach = CFile::CheckImageFile($attach_file, $iFileSize, 0, 0);
} elseif ($arParams["ALLOW_UPLOAD"] == "F") {
$attach = CFile::CheckFile($attach_file, $iFileSize, false, $arParams["ALLOW_UPLOAD_EXT"]);
} elseif ($arParams["ALLOW_UPLOAD"] == "A") {
$attach = CFile::CheckFile($attach_file, $iFileSize, false, false);
}
if ($attach != '') {
unset($arPost['FILES'][$fileID]);
$arPost['ERROR'] = $attach_file['name'] . ': ' . $attach;
return false;
}
}
}
return true;
}
示例2: array
$arFile = array(
"name" => $fileName,
"size" => $_FILES["mfi_files"]["size"][$i],
"tmp_name" => $_FILES["mfi_files"]["tmp_name"][$i],
"type" => $_FILES["mfi_files"]["type"][$i],
"MODULE_ID" => $mid
);
$res = '';
if ($arParams["ALLOW_UPLOAD"] == "I"):
$res = CFile::CheckImageFile($arFile, $max_file_size, 0, 0);
elseif ($arParams["ALLOW_UPLOAD"] == "F"):
$res = CFile::CheckFile($arFile, $max_file_size, false, $arParams["ALLOW_UPLOAD_EXT"]);
else:
$res = CFile::CheckFile($arFile, $max_file_size, false, false);
endif;
if (strlen($res) <= 0)
{
$fileID = CFile::SaveFile($arFile, $mid);
$tmp = array(
"fileName" => $fileName,
"fileID" => $fileID
);
if ($fileID)
{
if (!isset($_SESSION["MFI_UPLOADED_FILES_".$cid]))
{
示例3: TryUploadFile
public static function TryUploadFile(&$result, $options = array())
{
//Options initialization -->
$ownerTypeID = isset($options['OWNER_TYPE_ID']) ? intval($options['OWNER_TYPE_ID']) : CCrmOwnerType::Undefined;
if ($ownerTypeID !== CCrmOwnerType::Undefined && !CCrmOwnerType::IsDefined($ownerTypeID)) {
$ownerTypeID = CCrmOwnerType::Undefined;
}
$ownerID = isset($options['OWNER_ID']) ? max(intval($options['OWNER_ID']), 0) : 0;
$scope = isset($options['SCOPE']) ? strtoupper($options['SCOPE']) : '';
if (!in_array($scope, array('I', 'A', 'F'), true)) {
$scope = '';
}
$extensions = isset($options['EXTENSIONS']) && is_array($options['EXTENSIONS']) ? $options['EXTENSIONS'] : array();
$maxFileSize = isset($options['MAX_FILE_SIZE']) ? max(intval($options['MAX_FILE_SIZE']), 0) : 0;
//<-- Options initialization
if (!is_array($result)) {
$result = array();
}
$file = is_array($_FILES) && isset($_FILES['file']) ? $_FILES['file'] : null;
if (!is_array($file)) {
$result['ERROR_MESSAGE'] = 'No files';
return false;
}
$file['MODULE_ID'] = 'crm';
if ($scope === 'I') {
$error = CFile::CheckImageFile($file, $maxFileSize, 0, 0);
} elseif ($scope === 'F') {
$error = CFile::CheckFile($file, $maxFileSize, false, implode(',', $extensions));
} else {
$error = CFile::CheckFile($file, $maxFileSize, false, false);
}
$isValid = !(is_string($error) && $error !== '');
if (!$isValid) {
$result['ERROR_MESSAGE'] = $error;
return false;
}
$fileID = CFile::SaveFile($file, 'crm');
if (!is_int($fileID) || $fileID <= 0) {
$result['ERROR_MESSAGE'] = 'General error.';
return false;
}
if ($ownerTypeID != CCrmOwnerType::Undefined) {
$key = 'CRM_MBL_' . CCrmOwnerType::ResolveName($ownerTypeID) . '_' . $ownerID . '_FILES';
if (!isset($_SESSION[$key])) {
$_SESSION[$key] = array();
}
$_SESSION[$key][] = $fileID;
}
$result['FILE_ID'] = $fileID;
return true;
}
示例4: array
if (isset($arrAdvert['PARENTS'][$intParentId][$arrFieldProp[$strNameField]]) && count($arrAdvert['PARENTS'][$intParentId][$arrFieldProp[$strNameField]])) {
foreach ($arrAdvert['PARENTS'][$intParentId][$arrFieldProp[$strNameField]] as $intPropID => $intFileID) {
if ($intFileID == intval($_REQUEST['file_id'])) {
CIBlockElement::SetPropertyValueCode($intParentId, $arrFieldProp[$strNameField], array($intPropID => array('VALUE' => array('MODULE_ID' => 'iblock', 'del' => 'Y'))));
break;
}//\\ if
}//\\ foreach
}//\\ if
}//\\ if
} elseif ($_REQUEST['action'] == 'file') {
// Сохраним файл
$arrFile = $_FILES[$strNameField];
$arrFile['MODULE_ID'] = 'iblock';
//$res = CFile::CheckImageFile($arrFile, 20971520, 4000, 4000);
$res = CFile::CheckFile($arrFile, 20971520, false, 'txt,doc,docx,xls,xlsx');
if (strlen($res)) {
$arrResult['error'] = $res;
$arrResult['result'] = 'fail';
} else {
if ($strTypeBlock == 'P' && $intParentId) {
// Это свойство родителя
CIBlockElement::SetPropertyValueCode($intParentId, $arrFieldProp[$strNameField], array('VALUE' => $arrFile));
// Получим заново свойство
$arrAdvert['PARENTS'][$intParentId][$arrFieldProp[$strNameField]] = array();
//$arrFileNew = array();
$res = CIBlockElement::GetProperty($intParentBlockID, $intParentId, 'sort', 'asc', array('ACTIVE' => 'Y', 'CODE' => $arrFieldProp[$strNameField]));
while ($ob = $res->GetNext()) {
if (intval($ob['VALUE'])) $arrAdvert['PARENTS'][$intParentId][$ob['CODE']][] = intval($ob['VALUE']);
}//\\ while
示例5: Header
$arResult['duplicate_url'] = SITE_DIR . 'bitrix/components/bitrix/crm.lead.import/show_file.php?name=duplicate';
}
Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
echo CUtil::PhpToJsObject($arResult);
die;
}
}
$strError = '';
$arResult['STEP'] = isset($_POST['step']) ? intval($_POST['step']) : 1;
if ($_SERVER['REQUEST_METHOD'] == 'POST' && check_bitrix_sessid()) {
if (isset($_POST['next'])) {
if ($arResult['STEP'] == 1) {
if ($_FILES['IMPORT_FILE']['error'] > 0) {
ShowError(GetMessage('CRM_CSV_NF_ERROR'));
} else {
$error = CFile::CheckFile($_FILES['IMPORT_FILE'], 0, 0, 'csv,txt');
if ($error !== '') {
ShowError($error);
} else {
if (isset($_SESSION['CRM_IMPORT_FILE'])) {
unset($_SESSION['CRM_IMPORT_FILE']);
}
$sTmpFilePath = CTempFile::GetDirectoryName(12, 'crm');
CheckDirPath($sTmpFilePath);
$_SESSION['CRM_IMPORT_FILE_SKIP_EMPTY'] = isset($_POST['IMPORT_FILE_SKIP_EMPTY']) && $_POST['IMPORT_FILE_SKIP_EMPTY'] == 'Y' ? true : false;
$_SESSION['CRM_IMPORT_FILE_FIRST_HEADER'] = isset($_POST['IMPORT_FILE_FIRST_HEADER']) && $_POST['IMPORT_FILE_FIRST_HEADER'] == 'Y' ? true : false;
$_SESSION['CRM_IMPORT_FILE'] = $sTmpFilePath . md5($_FILES['IMPORT_FILE']['tmp_name']) . '.tmp';
$_SESSION['CRM_IMPORT_FILE_POS'] = 0;
move_uploaded_file($_FILES['IMPORT_FILE']['tmp_name'], $_SESSION['CRM_IMPORT_FILE']);
@chmod($_SESSION['CRM_IMPORT_FILE'], BX_FILE_PERMISSIONS);
if (isset($_POST['IMPORT_FILE_ENCODING'])) {
示例6: OnCommentAdd
function OnCommentAdd($entityType, $entityID, &$arPost)
{
global $USER;
$arParams =& $this->component->arParams;
$arResult =& $this->component->arResult;
$arForum =& $arResult['FORUM'];
$iFileSize = intval(COption::GetOptionString("forum", "file_max_size", 50000));
$arCommentParams = array("FORUM_ID" => $arParams["FORUM_ID"], "TOPIC_ID" => null, "USER_ID" => $USER->IsAuthorized() ? $USER->GetID() : null);
$arFiles = $arNewFiles = array();
if (isset($_REQUEST['FILE_NEW']) && is_array($_REQUEST['FILE_NEW'])) {
foreach ($_REQUEST['FILE_NEW'] as $val) {
$arNewFiles[$val] = array("FILE_ID" => $val);
}
}
if (isset($_REQUEST['FILES']) && is_array($_REQUEST['FILES'])) {
foreach ($_REQUEST['FILES'] as $val) {
if (in_array($val, $_REQUEST["FILES_TO_UPLOAD"])) {
$arFiles[$val] = array("FILE_ID" => $val);
}
}
}
if (!empty($arNewFiles)) {
CForumFiles::Add(array_keys($arNewFiles), $arCommentParams);
}
$arFiles = $arFiles + $arNewFiles;
if (!isset($arPost['FILES'])) {
$arPost['FILES'] = array();
}
$arPost['FILES'] = array_merge($arPost['FILES'], $arFiles);
foreach ($arPost['FILES'] as $fileIndex => $fileArr) {
$fileID = $fileArr['FILE_ID'];
$attach_file = CFile::MakeFileArray(intval($fileID));
$attach = "";
if ($attach_file && is_set($attach_file, "name")) {
// Y - Image files F - Files of specified type A - All files
if ($arForum["ALLOW_UPLOAD"] == "Y") {
$attach = CFile::CheckImageFile($attach_file, $iFileSize, 0, 0);
} elseif ($arForum["ALLOW_UPLOAD"] == "F") {
$attach = CFile::CheckFile($attach_file, $iFileSize, false, $arForum["ALLOW_UPLOAD_EXT"]);
} elseif ($arForum["ALLOW_UPLOAD"] == "A") {
$attach = CFile::CheckFile($attach_file, $iFileSize, false, false);
}
if ($attach != '') {
unset($arPost['FILES'][$fileIndex]);
$arPost['ERROR'] = $attach_file['name'] . ': ' . $attach;
return false;
}
}
}
}
示例7: CheckFile
public static function CheckFile($arFile, $iMaxSize = 0, $iMaxWidth = 0, $iMaxHeight = 0, $access_typies = array(), $bForceMD5 = false, $bSkipExt = false)
{
if ($arFile["name"] == "") {
return "";
}
if (preg_match("#^php://filter#i", $arFile["tmp_name"])) {
return GetMessage("FILE_BAD_FILE_TYPE") . ".<br>";
}
$extension = GetFileExtension(strtolower($arFile["name"]));
switch ($extension) {
case "jpg":
case "jpeg":
case "gif":
case "bmp":
case "png":
$file_type = "IMAGE";
break;
case "swf":
$file_type = "FLASH";
break;
case "mp4":
case "webm":
case "ogg":
$file_type = "VIDEO";
break;
default:
$file_type = "UNKNOWN";
}
// IMAGE by default
$flashEnabled = false;
if (!in_array($file_type, $access_typies)) {
$file_type = "IMAGE";
}
if ($file_type == "FLASH") {
$flashEnabled = true;
static $flashMime = array("application/x-shockwave-flash", "application/vnd.adobe.flash.movie");
$res = CFile::CheckFile($arFile, $iMaxSize, $flashMime, CFile::GetFlashExtensions(), $bForceMD5, $bSkipExt);
} else {
if ($file_type == "VIDEO") {
$res = CFile::CheckFile($arFile, $iMaxSize, "video/", "mp4,webm,ogg", $bForceMD5, $bSkipExt);
} else {
$res = CFile::CheckFile($arFile, $iMaxSize, "image/", CFile::GetImageExtensions(), $bForceMD5, $bSkipExt);
}
}
if ($res != '') {
return $res;
}
if ($file_type == 'IMAGE' || $file_type == "FLASH") {
$imgArray = CFile::GetImageSize($arFile["tmp_name"], true, $flashEnabled);
if (is_array($imgArray)) {
$intWIDTH = $imgArray[0];
$intHEIGHT = $imgArray[1];
} else {
return GetMessage("FILE_BAD_FILE_TYPE") . ".<br>";
}
//check for dimensions
if ($iMaxWidth > 0 && ($intWIDTH > $iMaxWidth || $intWIDTH == 0) || $iMaxHeight > 0 && ($intHEIGHT > $iMaxHeight || $intHEIGHT == 0)) {
return GetMessage("FILE_BAD_MAX_RESOLUTION") . " (" . $iMaxWidth . " * " . $iMaxHeight . " " . GetMessage("main_include_dots") . ").<br>";
}
}
return null;
}
示例8: htmlspecialcharsbx
$arLang[$res["LID"]] = $res;
$arLangTitle["reference_id"][] = $res["LID"];
$arLangTitle["reference"][] = htmlspecialcharsbx($res["NAME"]);
}
$bInitVars = false;
$bImportComplete = false;
$APPLICATION->SetTitle(GetMessage("SMILE_IMPORT_TITLE"));
$fileName = '';
if ($REQUEST_METHOD == "POST" && (strlen($save) > 0 || strlen($apply) > 0)) {
$fileName = 'import' . $USER->GetID() . time() . '.zip';
if (!check_bitrix_sessid()) {
$arError[] = array("id" => "bad_sessid", "text" => GetMessage("ERROR_BAD_SESSID"));
} elseif (!empty($_FILES["IMPORT"]["tmp_name"])) {
$sUploadDir = CTempFile::GetDirectoryName(1);
CheckDirPath($sUploadDir);
$res = CFile::CheckFile($_FILES["IMPORT"], 500000, false, 'zip');
if (strLen($res) > 0) {
$arError[] = array("id" => "IMPORT", "text" => $res);
} elseif (file_exists($sUploadDir . $fileName)) {
$arError[] = array("id" => "IMPORT", "text" => GetMessage("ERROR_EXISTS_FILE"));
} elseif (!@copy($_FILES["IMPORT"]["tmp_name"], $sUploadDir . $fileName)) {
$arError[] = array("id" => "IMPORT", "text" => GetMessage("ERROR_COPY_FILE"));
} else {
@chmod($sUploadDir . $fileName, BX_FILE_PERMISSIONS);
}
} elseif (empty($_FILES["IMPORT"]["tmp_name"])) {
$arError[] = array("id" => "IMPORT", "text" => GetMessage("ERROR_EXISTS_FILE"));
}
if (empty($arError)) {
$GLOBALS["APPLICATION"]->ResetException();
$importCount = CSmile::import(array('FILE' => $sUploadDir . $fileName, 'SET_ID' => intval($_REQUEST['SET_ID'])));
示例9: CheckFields
public function CheckFields(&$arFields, $ID = false, $options = array())
{
global $APPLICATION, $USER_FIELD_MANAGER;
$this->LAST_ERROR = '';
if (($ID == false || isset($arFields['NAME']) && isset($arFields['LAST_NAME'])) && (empty($arFields['NAME']) && empty($arFields['LAST_NAME']))) {
$this->LAST_ERROR .= GetMessage('CRM_ERROR_REQUIRED_FIELDS') . "<br />";
}
if (isset($arFields['FM']) && is_array($arFields['FM'])) {
$CCrmFieldMulti = new CCrmFieldMulti();
if (!$CCrmFieldMulti->CheckComplexFields($arFields['FM'])) {
$this->LAST_ERROR .= $CCrmFieldMulti->LAST_ERROR;
}
}
if (isset($arFields['PHOTO']) && is_array($arFields['PHOTO'])) {
if (($strError = CFile::CheckFile($arFields['PHOTO'], 0, 0, CFile::GetImageExtensions())) != '') {
$this->LAST_ERROR .= $strError . "<br />";
}
}
if (isset($arFields['BIRTHDATE']) && $arFields['BIRTHDATE'] !== '' && !CheckDateTime($arFields['BIRTHDATE'])) {
$this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_INCORRECT', array('%FIELD_NAME%' => self::GetFieldCaption('BIRTHDATE'))) . "<br />";
}
$enableUserFildCheck = !(is_array($options) && isset($options['DISABLE_USER_FIELD_CHECK']) && $options['DISABLE_USER_FIELD_CHECK'] === true);
if ($enableUserFildCheck) {
// We have to prepare field data before check (issue #22966)
CCrmEntityHelper::NormalizeUserFields($arFields, self::$sUFEntityID, $USER_FIELD_MANAGER, array('IS_NEW' => $ID == false));
if (!$USER_FIELD_MANAGER->CheckFields(self::$sUFEntityID, $ID, $arFields)) {
$e = $APPLICATION->GetException();
$this->LAST_ERROR .= $e->GetString();
}
}
return $this->LAST_ERROR === '';
}
示例10: CheckFields
public function CheckFields(&$arFields, $ID = false, $options = array())
{
global $APPLICATION, $USER_FIELD_MANAGER;
$this->LAST_ERROR = '';
if (($ID == false || isset($arFields['TITLE'])) && empty($arFields['TITLE'])) {
$this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_IS_MISSING', array('%FIELD_NAME%' => GetMessage('CRM_FIELD_TITLE'))) . "<br />";
}
if (isset($arFields['FM']) && is_array($arFields['FM'])) {
$CCrmFieldMulti = new CCrmFieldMulti();
if (!$CCrmFieldMulti->CheckComplexFields($arFields['FM'])) {
$this->LAST_ERROR .= $CCrmFieldMulti->LAST_ERROR;
}
}
if (isset($arFields['LOGO']) && is_array($arFields['LOGO'])) {
if (($strError = CFile::CheckFile($arFields['LOGO'], 0, 0, CFile::GetImageExtensions())) != '') {
$this->LAST_ERROR .= $strError . "<br />";
}
}
$enableUserFildCheck = !(is_array($options) && isset($options['DISABLE_USER_FIELD_CHECK']) && $options['DISABLE_USER_FIELD_CHECK'] === true);
if ($enableUserFildCheck) {
// We have to prepare field data before check (issue #22966)
CCrmEntityHelper::NormalizeUserFields($arFields, self::$sUFEntityID, $USER_FIELD_MANAGER, array('IS_NEW' => $ID == false));
if (!$USER_FIELD_MANAGER->CheckFields(self::$sUFEntityID, $ID, $arFields)) {
$e = $APPLICATION->GetException();
$this->LAST_ERROR .= $e->GetString();
}
}
if (strlen($this->LAST_ERROR) > 0) {
return false;
}
return true;
}
示例11: checkFile
/**
* Checks file params
* @param $file
* @param $arFile
* @return mixed|null|string
*/
private function checkFile($file, &$arFile)
{
$error = "";
if ($file["error"] > 0)
$error = "BXU348: " . $file["error"];
else if (!is_uploaded_file($file['tmp_name']))
$error = "BXU348";
else if (!file_exists($file['tmp_name']))
$error = "BXU347";
elseif ($this->params["allowUpload"] == "F")
$error = CFile::CheckFile($file, $this->params["uploadMaxFilesize"], false, $this->params["allowUploadExt"]);
else
$error = CFile::CheckFile($file, $this->params["uploadMaxFilesize"]);
if (strlen($error) <= 0)
{
$key = (preg_match("/\\\\(.+?)\\\\/", $file["~name"], $matches) ? $matches[1] : "default");
$res = (array_key_exists($key, $arFile["files"]) ? $arFile["files"][$key] : array("copy" => $key));
if (preg_match("/\/(\d+)\/(\d+)\//", $file["~name"], $matches))
{
$file["package"] = $matches[2];
$file["packages"] = $matches[1];
$res["packages"] = $matches[1];
$res["chunks"] = (is_array($res["chunks"]) ? $res["chunks"] : array());
$res["chunks"][self::getChunkKey($file["packages"], $file["package"])] = $file;
$arFile["files"][$key] = $res;
}
else
{
if ($this->params["allowUpload"] == "I")
$error = CFile::CheckImageFile($file, $this->params["uploadMaxFilesize"], 0, 0);
if (strlen($error) <= 0)
{
$res = array_merge($res, $file);
$arFile["files"][$key] = $res;
}
}
}
if (strlen($error) > 0)
{
$arFile["error"] = $error;
}
return $error;
}
示例12: ForumMoveMessage
//.........这里部分代码省略.........
}
}
if (count($arError) <= 0)
{
// Move message
$db_res = CForumMessage::GetList(array(), array("@ID" => implode(",", $Message), "TOPIC_ID" => $TID));
if ($db_res && $res = $db_res->Fetch())
{
do
{
// echo "NewFID: ".$NewFID." -- FID:".$FID."<br/>";
$arMessage = array();
if ($NewFID != $FID)
{
$arMessage["APPROVED"] = ($arNewForum["MODERATION"] == "Y" ? "N" : "Y");
if ($arCurrUser["Perms"]["NewFID"] >= "Q")
$arMessage["APPROVED"] = "Y";
$arMessage["FORUM_ID"] = $NewFID;
$arMessage["POST_MESSAGE_HTML"] = "";
// check attach
if (false && intVal($res["ATTACH_IMG"]) > 0)
{
$iFileSize = COption::GetOptionString("forum", "file_max_size", 50000);
$attach_img = CFile::GetByID(intVal($res["ATTACH_IMG"]));
$attach = "";
if ($attach_img && is_set($attach_img, "ORIGINAL_NAME"))
{
// Y - Image files F - Files of specified type A - All files
if ($arNewForum["ALLOW_UPLOAD"]=="Y")
$attach = CFile::CheckImageFile($attach_img["ORIGINAL_NAME"], $iFileSize, 0, 0);
elseif ($arNewForum["ALLOW_UPLOAD"]=="F")
$attach = CFile::CheckFile($attach_img["ORIGINAL_NAME"], $iFileSize, false, $arNewForum["ALLOW_UPLOAD_EXT"]);
elseif ($arNewForum["ALLOW_UPLOAD"]=="A")
$attach = CFile::CheckFile($attach_img["ORIGINAL_NAME"], $iFileSize, false, false);
if (strLen($attach) > 0)
$arMessage["ATTACH_IMG"] = "";
}
}
}
if ($NewTID != $TID)
{
$arMessage["NEW_TOPIC"] = "N";
$arMessage["TOPIC_ID"] = $NewTID;
}
if (count($arMessage) > 0)
{
$MID = CForumMessage::Update($res["ID"], $arMessage, true);
$res_log = ($SendSubscribe == true ? GetMessage("F_MESSAGE_WAS_MOVED_TO_NEW") : GetMessage("F_MESSAGE_WAS_MOVED"));
$res_log = str_replace(array("#ID#", "#TOPIC_TITLE#", "#TOPIC_ID#", "#NEW_TOPIC_TITLE#", "#NEW_TOPIC_ID#"),
array($MID, $arTopic["TITLE"], $arTopic["ID"], $arNewTopic['TITLE'], $arNewTopic['ID']), $res_log);
$res["TITLE"] = $arNewTopic['TITLE'];
$res["TOPIC_ID"] = $arNewTopic['ID'];
$res["beforeTITLE"] = $arTopic["TITLE"];
$res["DESCRIPTION"] = $res_log;
CForumEventLog::Log("message", "move", $MID, serialize($res));
$db_res2 = CForumFiles::GetList(array(), array("FILE_MESSAGE_ID" => $res["ID"]));
if ($db_res2 && $res2 = $db_res2->Fetch())
{
$arFiles = array();
do
{
$arFiles[] = $res2["FILE_ID"];
示例13: CheckImageFile
public static function CheckImageFile($arFile, $iMaxSize = 0, $iMaxWidth = 0, $iMaxHeight = 0, $access_typies = array(), $bForceMD5 = false, $bSkipExt = false)
{
if ($arFile["name"] == "") {
return "";
}
if (preg_match("#^php://filter#i", $arFile["tmp_name"])) {
return GetMessage("FILE_BAD_FILE_TYPE") . ".<br>";
}
$file_type = GetFileType($arFile["name"]);
// IMAGE by default
$flashEnabled = false;
if (!in_array($file_type, $access_typies)) {
$file_type = "IMAGE";
}
if ($file_type == "FLASH") {
$flashEnabled = true;
static $flashMime = array("application/x-shockwave-flash", "application/vnd.adobe.flash.movie");
$res = CFile::CheckFile($arFile, $iMaxSize, $flashMime, CFile::GetFlashExtensions(), $bForceMD5, $bSkipExt);
} else {
$res = CFile::CheckFile($arFile, $iMaxSize, "image/", CFile::GetImageExtensions(), $bForceMD5, $bSkipExt);
}
if ($res != '') {
return $res;
}
$imgArray = CFile::GetImageSize($arFile["tmp_name"], true, $flashEnabled);
if (is_array($imgArray)) {
$intWIDTH = $imgArray[0];
$intHEIGHT = $imgArray[1];
} else {
return GetMessage("FILE_BAD_FILE_TYPE") . ".<br>";
}
//check for dimensions
if ($iMaxWidth > 0 && ($intWIDTH > $iMaxWidth || $intWIDTH == 0) || $iMaxHeight > 0 && ($intHEIGHT > $iMaxHeight || $intHEIGHT == 0)) {
return GetMessage("FILE_BAD_MAX_RESOLUTION") . " (" . $iMaxWidth . " * " . $iMaxHeight . " " . GetMessage("main_include_dots") . ").<br>";
}
return null;
}
示例14: CheckFields
//.........这里部分代码省略.........
break;
}
}
$bError = $bCount <= 0;
}
}
if ($arProperty["IS_REQUIRED"] == "Y" && $arProperty['PROPERTY_TYPE'] != 'F') {
$len = 0;
foreach ($property_values as $key2 => $property_value) {
if (array_key_exists("GetLength", $arUserType)) {
$len += call_user_func_array($arUserType["GetLength"], array($arProperty, array("VALUE" => $property_value)));
} else {
$len += strlen($property_value);
}
if ($len > 0) {
break;
}
}
$bError = $len <= 0;
}
if ($bError) {
$this->LAST_ERROR .= GetMessage("IBLOCK_BAD_PROPERTY", array("#PROPERTY#" => $arProperty["NAME"])) . "<br>";
}
// check file properties for correctness
if ($arProperty['PROPERTY_TYPE'] == 'F') {
$bImageOnly = False;
$arImageExtentions = explode(",", strtoupper(CFile::GetImageExtensions()));
if (strlen($arProperty["FILE_TYPE"])) {
$bImageOnly = True;
$arAvailTypes = explode(",", strtoupper($arProperty["FILE_TYPE"]));
foreach ($arAvailTypes as $avail_type) {
if (!in_array(trim($avail_type), $arImageExtentions)) {
$bImageOnly = False;
break;
}
}
}
foreach ($property_values as $key2 => $property_value) {
if (!is_array($property_value) && intval($property_value) > 0 && intval($arFields["WF_PARENT_ELEMENT_ID"]) > 0) {
if (CIBlockElement::DeleteFile($property_value, $ID, "PROPERTY", intval($arFields["WF_PARENT_ELEMENT_ID"]), $arFields["IBLOCK_ID"], true) <= 0) {
$this->LAST_ERROR .= GetMessage("IBLOCK_ERR_FILE_PROPERTY") . "<br>";
}
} elseif (is_array($property_value)) {
if (is_object($property_value["bucket"])) {
//This is trusted image from xml import
$error = "";
} else {
if ($bImageOnly) {
$error = CFile::CheckImageFile($property_value);
} else {
$error = CFile::CheckFile($property_value, 0, false, $arProperty["FILE_TYPE"]);
}
}
//For user without edit php permissions
//we allow only pictures upload
if (!is_object($USER) || !$USER->IsAdmin()) {
if (HasScriptExtension($property_value["name"])) {
$error = GetMessage("FILE_BAD_TYPE") . " (" . $property_value["name"] . ").";
}
}
if (strlen($error) > 0) {
$this->LAST_ERROR .= $error . "<br>";
}
}
}
}
}
}
$APPLICATION->ResetException();
if ($ID === false) {
$db_events = GetModuleEvents("iblock", "OnBeforeIBlockElementAdd", true);
} else {
$arFields["ID"] = $ID;
$db_events = GetModuleEvents("iblock", "OnBeforeIBlockElementUpdate", true);
}
foreach ($db_events as $arEvent) {
$bEventRes = ExecuteModuleEventEx($arEvent, array(&$arFields));
if ($bEventRes === false) {
if ($err = $APPLICATION->GetException()) {
$this->LAST_ERROR .= $err->GetString() . "<br>";
} else {
$APPLICATION->ThrowException("Unknown error");
$this->LAST_ERROR .= "Unknown error.<br>";
}
break;
}
}
/****************************** QUOTA ******************************/
if ($bCheckDiskQuota && empty($this->LAST_ERROR) && COption::GetOptionInt("main", "disk_space") > 0) {
$quota = new CDiskQuota();
if (!$quota->checkDiskQuota($arFields)) {
$this->LAST_ERROR = $quota->LAST_ERROR;
}
}
/****************************** QUOTA ******************************/
if (!empty($this->LAST_ERROR)) {
return false;
}
return true;
}
示例15: getErrorSingle
protected static function getErrorSingle(array $input, $value)
{
if (is_array($value)) {
switch ($value['error']) {
case UPLOAD_ERR_OK:
// success
$errors = array();
if ($input['MAXSIZE'] && $value['size'] > $input['MAXSIZE']) {
$errors['MAXSIZE'] = Loc::getMessage('INPUT_FILE_MAXSIZE_ERROR');
}
// TODO check: file name, mime type, extension
//$info = pathinfo($value['name']);
if ($error = \CFile::CheckFile($value, 0, false, $input['ACCEPT'])) {
$errors['CFILE'] = $error;
}
return $errors;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return array('MAXSIZE' => Loc::getMessage('INPUT_FILE_MAXSIZE_ERROR'));
case UPLOAD_ERR_PARTIAL:
return array('PARTIAL' => Loc::getMessage('INPUT_FILE_PARTIAL_ERROR'));
case UPLOAD_ERR_NO_FILE:
return $input['REQUIRED'] == 'Y' && (!is_numeric($value['ID']) || $value['DELETE']) ? array('REQUIRED' => Loc::getMessage('INPUT_REQUIRED_ERROR')) : array();
// TODO case UPLOAD_ERR_NO_TMP_DIR UPLOAD_ERR_CANT_WRITE UPLOAD_ERR_EXTENSION
// TODO case UPLOAD_ERR_NO_TMP_DIR UPLOAD_ERR_CANT_WRITE UPLOAD_ERR_EXTENSION
default:
return array('INVALID' => Loc::getMessage('INPUT_INVALID_ERROR'));
}
} elseif (is_numeric($value)) {
// TODO check if file id exists maybe ???
return array();
} else {
return array('INVALID' => Loc::getMessage('INPUT_INVALID_ERROR'));
}
}