本文整理汇总了PHP中CFile::CheckImageFile方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::CheckImageFile方法的具体用法?PHP CFile::CheckImageFile怎么用?PHP CFile::CheckImageFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::CheckImageFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __MPF_ImageResizeHandler
function __MPF_ImageResizeHandler(&$arCustomFile, $arParams = null)
{
static $arResizeParams = array();
if ($arParams !== null) {
if (is_array($arParams) && array_key_exists("width", $arParams) && array_key_exists("height", $arParams)) {
$arResizeParams = $arParams;
} elseif (intVal($arParams) > 0) {
$arResizeParams = array("width" => intVal($arParams), "height" => intVal($arParams));
}
}
if (!is_array($arCustomFile) || !isset($arCustomFile['fileID'])) {
return false;
}
$fileID = $arCustomFile['fileID'];
$arFile = CFile::MakeFileArray($fileID);
if (CFile::CheckImageFile($arFile) === null) {
$aImgThumb = CFile::ResizeImageGet($fileID, array("width" => 90, "height" => 90), BX_RESIZE_IMAGE_EXACT, true);
$arCustomFile['img_thumb_src'] = $aImgThumb['src'];
if (!empty($arResizeParams)) {
$aImgSource = CFile::ResizeImageGet($fileID, array("width" => $arResizeParams["width"], "height" => $arResizeParams["height"]), BX_RESIZE_IMAGE_PROPORTIONAL, true);
$arCustomFile['img_source_src'] = $aImgSource['src'];
$arCustomFile['img_source_width'] = $aImgSource['width'];
$arCustomFile['img_source_height'] = $aImgSource['height'];
}
}
}
示例2: __main_post_form_image_resize
function __main_post_form_image_resize(&$arCustomFile, $arParams = null)
{
static $arResizeParams = array();
if ($arParams !== null) {
if (is_array($arParams) && array_key_exists("width", $arParams) && array_key_exists("height", $arParams)) {
$arResizeParams = $arParams;
} elseif (intVal($arParams) > 0) {
$arResizeParams = array("width" => intVal($arParams), "height" => intVal($arParams));
}
}
if (!is_array($arCustomFile) || !isset($arCustomFile['fileID'])) {
return false;
}
if (array_key_exists("ID", $arCustomFile)) {
$arFile = $arCustomFile;
$fileID = $arCustomFile['ID'];
} else {
$fileID = $arCustomFile['fileID'];
$arFile = CFile::MakeFileArray($fileID);
$arFile1 = CFile::GetByID($fileID)->fetch();
if (is_array($arFile) && is_array($arFile1)) {
$arCustomFile = array_merge($arFile, $arFile1, $arCustomFile);
}
}
if (CFile::CheckImageFile($arFile) === null) {
$aImgThumb = CFile::ResizeImageGet($fileID, array("width" => 90, "height" => 90), BX_RESIZE_IMAGE_EXACT, true);
$arCustomFile['img_thumb_src'] = $aImgThumb['src'];
if (!empty($arResizeParams)) {
$aImgSource = CFile::ResizeImageGet($fileID, array("width" => $arResizeParams["width"], "height" => $arResizeParams["height"]), BX_RESIZE_IMAGE_PROPORTIONAL, true);
$arCustomFile['img_source_src'] = $aImgSource['src'];
$arCustomFile['img_source_width'] = $aImgSource['width'];
$arCustomFile['img_source_height'] = $aImgSource['height'];
}
}
}
示例3: CheckFields
public function CheckFields(&$arFields, $ID = false)
{
global $DB, $USER;
$arMsg = array();
if ((is_set($arFields, "NAME") || $ID === false) && strlen(trim($arFields["NAME"])) <= 0) {
$arMsg[] = array("id" => "NAME", "text" => GetMessage("LEARNING_BAD_NAME"));
}
if (is_set($arFields, "FILE_ID")) {
$error = CFile::CheckImageFile($arFields["FILE_ID"]);
if (strlen($error) > 0) {
$arMsg[] = array("id" => "FILE_ID", "text" => $error);
}
}
if (strlen($this->LAST_ERROR) <= 0) {
if ($ID === false && !is_set($arFields, "LESSON_ID") || is_set($arFields, "LESSON_ID") && intval($arFields["LESSON_ID"]) < 1) {
$arMsg[] = array("id" => "LESSON_ID", "text" => GetMessage("LEARNING_BAD_LESSON_ID"));
} elseif (is_set($arFields, "LESSON_ID")) {
$res = CLearnLesson::GetByID($arFields["LESSON_ID"]);
if ($arRes = $res->Fetch()) {
$oAccess = CLearnAccess::GetInstance($USER->GetID());
$bAccessLessonModify = $oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_WRITE) || $oAccess->IsLessonAccessible($arFields["LESSON_ID"], CLearnAccess::OP_LESSON_WRITE);
if (!$bAccessLessonModify) {
$arMsg[] = array("id" => "LESSON_ID", "text" => GetMessage("LEARNING_BAD_LESSON_ID_EX"));
}
} else {
$arMsg[] = array("id" => "LESSON_ID", "text" => GetMessage("LEARNING_BAD_LESSON_ID_EX"));
}
}
}
if (!empty($arMsg)) {
$e = new CAdminException($arMsg);
$GLOBALS["APPLICATION"]->ThrowException($e);
return false;
}
if (is_set($arFields, "QUESTION_TYPE") && !in_array($arFields["QUESTION_TYPE"], array("S", "M", "T", "R"))) {
$arFields["QUESTION_TYPE"] = "S";
}
if (is_set($arFields, "DESCRIPTION_TYPE") && $arFields["DESCRIPTION_TYPE"] != "html") {
$arFields["DESCRIPTION_TYPE"] = "text";
}
if (is_set($arFields, "DIRECTION") && $arFields["DIRECTION"] != "H") {
$arFields["DIRECTION"] = "V";
}
if (is_set($arFields, "SELF") && $arFields["SELF"] != "Y") {
$arFields["SELF"] = "N";
}
if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
$arFields["ACTIVE"] = "N";
}
if (is_set($arFields, "EMAIL_ANSWER") && $arFields["EMAIL_ANSWER"] != "Y") {
$arFields["EMAIL_ANSWER"] = "N";
}
if (is_set($arFields, "CORRECT_REQUIRED") && $arFields["CORRECT_REQUIRED"] != "Y") {
$arFields["CORRECT_REQUIRED"] = "N";
}
return true;
}
示例4: CheckFields
function CheckFields($ACTION, &$arFields, $ID = 0)
{
global $DB;
if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GU_EMPTY_USER_ID"), "EMPTY_USER_ID");
return false;
} elseif (is_set($arFields, "USER_ID")) {
$dbResult = CUser::GetByID($arFields["USER_ID"]);
if (!$dbResult->Fetch()) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GU_ERROR_NO_USER_ID"), "ERROR_NO_USER_ID");
return false;
}
}
if (is_set($arFields, "ALIAS") && strlen($arFields["ALIAS"]) > 0) {
$dbResult = CBlogUser::GetList(array(), array("ALIAS" => $arFields["ALIAS"], "!ID" => IntVal($ID)), false, false, array("ID"));
if ($dbResult->Fetch()) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GU_ERROR_DUPL_ALIAS"), "ERROR_DUPL_ALIAS");
return false;
}
}
if (is_set($arFields, "LAST_VISIT") && !$DB->IsDate($arFields["LAST_VISIT"], false, LANG, "FULL")) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GU_ERROR_LAST_VISIT"), "ERROR_LAST_VISIT");
return false;
}
if (is_set($arFields, "DATE_REG") && !$DB->IsDate($arFields["DATE_REG"], false, LANG, "FULL")) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GU_ERROR_DATE_REG"), "ERROR_DATE_REG");
return false;
}
if ((is_set($arFields, "ALLOW_POST") || $ACTION == "ADD") && $arFields["ALLOW_POST"] != "Y" && $arFields["ALLOW_POST"] != "N") {
$arFields["ALLOW_POST"] = "Y";
}
if (is_set($arFields, "AVATAR") && strlen($arFields["AVATAR"]["name"]) <= 0 && strlen($arFields["AVATAR"]["del"]) <= 0) {
unset($arFields["AVATAR"]);
}
if (is_set($arFields, "AVATAR")) {
$max_size = COption::GetOptionInt("blog", "avatar_max_size", 30000);
//$max_width = COption::GetOptionInt("blog", "avatar_max_width", 100);
//$max_height = COption::GetOptionInt("blog", "avatar_max_height", 100);
$res = CFile::CheckImageFile($arFields["AVATAR"], $max_size, 0, 0);
if (strlen($res) > 0) {
$GLOBALS["APPLICATION"]->ThrowException($res, "ERROR_AVATAR");
return false;
}
}
return True;
}
示例5: __MPF_ImageResizeHandler
function __MPF_ImageResizeHandler(&$arCustomFile)
{
$arResizeParams = array("width" => 400, "height" => 400);
if (!is_array($arCustomFile) || !isset($arCustomFile['fileID'])) {
return false;
}
$fileID = $arCustomFile['fileID'];
$arFile = CFile::MakeFileArray($fileID);
if (CFile::CheckImageFile($arFile) === null) {
$aImgThumb = CFile::ResizeImageGet($fileID, array("width" => 90, "height" => 90), BX_RESIZE_IMAGE_EXACT, true);
$arCustomFile['img_thumb_src'] = $aImgThumb['src'];
if (!empty($arResizeParams)) {
$aImgSource = CFile::ResizeImageGet($fileID, array("width" => $arResizeParams["width"], "height" => $arResizeParams["height"]), BX_RESIZE_IMAGE_PROPORTIONAL, true);
$arCustomFile['img_source_src'] = $aImgSource['src'];
$arCustomFile['img_source_width'] = $aImgSource['width'];
$arCustomFile['img_source_height'] = $aImgSource['height'];
}
}
}
示例6: CheckFields
function CheckFields($arFields, $ID = false)
{
global $DB;
$arMsg = array();
if ((is_set($arFields, "NAME") || $ID === false) && strlen(trim($arFields["NAME"])) <= 0) {
$arMsg[] = array("id" => "NAME", "text" => GetMessage("LEARNING_BAD_NAME"));
}
if (is_set($arFields, "ACTIVE_FROM") && strlen($arFields["ACTIVE_FROM"]) > 0 && !$DB->IsDate($arFields["ACTIVE_FROM"], false, LANG, "FULL")) {
$arMsg[] = array("id" => "ACTIVE_FROM", "text" => GetMessage("LEARNING_BAD_ACTIVE_FROM"));
}
if (is_set($arFields, "ACTIVE_TO") && strlen($arFields["ACTIVE_TO"]) > 0 && !$DB->IsDate($arFields["ACTIVE_TO"], false, LANG, "FULL")) {
$arMsg[] = array("id" => "ACTIVE_TO", "text" => GetMessage("LEARNING_BAD_ACTIVE_TO"));
}
if (is_set($arFields, "PREVIEW_PICTURE") && is_array($arFields["PREVIEW_PICTURE"])) {
$error = CFile::CheckImageFile($arFields["PREVIEW_PICTURE"]);
if (strlen($error) > 0) {
$arMsg[] = array("id" => "PREVIEW_PICTURE", "text" => $error);
}
}
//Sites
if ($ID === false && !is_set($arFields, "SITE_ID") || is_set($arFields, "SITE_ID") && (!is_array($arFields["SITE_ID"]) || empty($arFields["SITE_ID"]))) {
$arMsg[] = array("id" => "SITE_ID[]", "text" => GetMessage("LEARNING_BAD_SITE_ID"));
} elseif (is_set($arFields, "SITE_ID")) {
$tmp = "";
foreach ($arFields["SITE_ID"] as $lang) {
$res = CSite::GetByID($lang);
if (!$res->Fetch()) {
$tmp .= "'" . $lang . "' - " . GetMessage("LEARNING_BAD_SITE_ID_EX") . "<br>";
}
}
if ($tmp != "") {
$arMsg[] = array("id" => "SITE_ID[]", "text" => $tmp);
}
}
if (!empty($arMsg)) {
$e = new CAdminException($arMsg);
$GLOBALS["APPLICATION"]->ThrowException($e);
return false;
}
return true;
}
示例7: IncludeModuleLangFile
}
}
IncludeModuleLangFile(__FILE__);
ClearVars();
$errorMessage = '';
$bVarsFromForm = false;
$userId = (int) $USER->GetID();
$entityId = "CAT_STORE";
if ($_SERVER["REQUEST_METHOD"] == "POST" && strlen($_REQUEST["Update"]) > 0 && !$bReadOnly && check_bitrix_sessid()) {
$arPREVIEW_PICTURE = $_FILES["IMAGE_ID"];
$arPREVIEW_PICTURE["del"] = $IMAGE_ID_del;
$arPREVIEW_PICTURE["MODULE_ID"] = "catalog";
$ISSUING_CENTER = $_POST["ISSUING_CENTER"] == 'Y' ? 'Y' : 'N';
$SHIPPING_CENTER = $_POST["SHIPPING_CENTER"] == 'Y' ? 'Y' : 'N';
$fileId = 0;
$isImage = CFile::CheckImageFile($arPREVIEW_PICTURE);
if (trim($ADDRESS) == '') {
$errorMessage .= GetMessage("ADDRESS_EMPTY") . "<br>";
}
if (strlen($isImage) == 0 && (strlen($arPREVIEW_PICTURE["name"]) > 0 || strlen($arPREVIEW_PICTURE["del"]) > 0)) {
$fileId = CFile::SaveFile($arPREVIEW_PICTURE, "catalog");
} elseif (strlen($isImage) > 0) {
$errorMessage .= $isImage . "<br>";
}
$arFields = array("TITLE" => isset($_POST['TITLE']) ? $_POST['TITLE'] : '', "SORT" => isset($_POST['CSTORE_SORT']) ? (int) $_POST['CSTORE_SORT'] : 0, "ACTIVE" => isset($_POST['ACTIVE']) && $_POST['ACTIVE'] == 'Y' ? 'Y' : 'N', "ADDRESS" => isset($_POST['ADDRESS']) ? $_POST['ADDRESS'] : '', "DESCRIPTION" => isset($_POST['DESCRIPTION']) ? $_POST['DESCRIPTION'] : '', "GPS_N" => isset($_POST['GPS_N']) ? $_POST['GPS_N'] : '', "GPS_S" => isset($_POST['GPS_S']) ? $_POST['GPS_S'] : '', "PHONE" => isset($_POST['PHONE']) ? $_POST['PHONE'] : '', "SCHEDULE" => isset($_POST['SCHEDULE']) ? $_POST['SCHEDULE'] : '', "XML_ID" => isset($_POST['XML_ID']) ? $_POST['XML_ID'] : '', "USER_ID" => $userId, "MODIFIED_BY" => $userId, "EMAIL" => isset($_POST["EMAIL"]) ? $_POST["EMAIL"] : '', "ISSUING_CENTER" => $ISSUING_CENTER, "SHIPPING_CENTER" => $SHIPPING_CENTER, "SITE_ID" => $_POST["SITE_ID"]);
$USER_FIELD_MANAGER->EditFormAddFields($entityId, $arFields);
if (intval($fileId) > 0) {
$arFields["IMAGE_ID"] = intval($fileId);
} elseif ($fileId === "NULL") {
$arFields["IMAGE_ID"] = "null";
}
示例8: CheckFields
protected function CheckFields($action, &$arFields)
{
if (isset($arFields["EXTERNAL_AUTH_ID"]) && strlen($arFields["EXTERNAL_AUTH_ID"]) <= 0) {
return false;
}
if (isset($arFields["SITE_ID"]) && strlen($arFields["SITE_ID"]) <= 0) {
$arFields["SITE_ID"] = SITE_ID;
}
if (!isset($arFields["USER_ID"])) {
$arFields["USER_ID"] = $GLOBALS["USER"]->GetID();
}
if (is_set($arFields, "PERSONAL_PHOTO")) {
$res = CFile::CheckImageFile($arFields["PERSONAL_PHOTO"]);
if (strlen($res) > 0) {
unset($arFields["PERSONAL_PHOTO"]);
} else {
$arFields["PERSONAL_PHOTO"]["MODULE_ID"] = "socialservices";
CFile::SaveForDB($arFields, "PERSONAL_PHOTO", "socialservices");
}
}
return true;
}
示例9: SaveFile
function SaveFile($name, $arRestriction = array())
{
$wizard = $this->GetWizard();
$deleteFile = $wizard->GetVar($name . "_del");
$wizard->UnSetVar($name . "_del");
$oldFileID = $wizard->GetVar($name);
$fileNew = $wizard->GetRealName($name . "_new");
if (!array_key_exists($fileNew, $_FILES) || strlen($_FILES[$fileNew]["name"]) <= 0 && $deleteFile === null) {
return;
}
if (strlen($_FILES[$fileNew]["tmp_name"]) <= 0 && $deleteFile === null) {
$this->SetError(GetMessage("MAIN_WIZARD_FILE_UPLOAD_ERROR"), $name . "_new");
return;
}
$arFile = $_FILES[$fileNew] + array("del" => $deleteFile == "Y" ? "Y" : "", "old_file" => intval($oldFileID) > 0 ? intval($oldFileID) : 0, "MODULE_ID" => "tmp_wizard");
$max_file_size = array_key_exists("max_file_size", $arRestriction) ? intval($arRestriction["max_file_size"]) : 0;
$max_width = array_key_exists("max_width", $arRestriction) ? intval($arRestriction["max_width"]) : 0;
$max_height = array_key_exists("max_height", $arRestriction) ? intval($arRestriction["max_height"]) : 0;
$extensions = array_key_exists("extensions", $arRestriction) && strlen($arRestriction["extensions"]) > 0 ? trim($arRestriction["extensions"]) : false;
$make_preview = array_key_exists("make_preview", $arRestriction) && $arRestriction["make_preview"] == "Y" ? true : false;
$error = CFile::CheckFile($arFile, $max_file_size, false, $extensions);
if (strlen($error) > 0) {
$this->SetError($error, $name . "_new");
return;
}
if ($make_preview && $max_width > 0 && $max_height > 0) {
list($sourceWidth, $sourceHeight, $type, $attr) = CFile::GetImageSize($arFile["tmp_name"]);
if ($sourceWidth > $max_width || $sourceHeight > $max_height) {
$success = CWizardUtil::CreateThumbnail($arFile["tmp_name"], $arFile["tmp_name"], $max_width, $max_height);
if ($success) {
$arFile["size"] = @filesize($arFile["tmp_name"]);
}
}
} elseif ($max_width > 0 || $max_height > 0) {
$error = CFile::CheckImageFile($arFile, $max_file_size, $max_width, $max_height);
if (strlen($error) > 0) {
$this->SetError($error, $name . "_new");
return;
}
}
$fileID = (int) CFile::SaveFile($arFile, "tmp");
if ($fileID > 0) {
$wizard->SetVar($name, $fileID);
} else {
$wizard->UnSetVar($name);
}
return $fileID;
}
示例10: RemoveScriptExtension
$fileName = '';
if ($REQUEST_METHOD == "POST" && $forumPermissions >= "W" && (strlen($save) > 0 || strlen($apply) > 0)) {
if (isset($_FILES["IMAGE"]["name"])) {
$fileName = RemoveScriptExtension($_FILES["IMAGE"]["name"]);
}
if (!check_bitrix_sessid()) {
$arError[] = array("id" => "bad_sessid", "text" => GetMessage("ERROR_BAD_SESSID"));
} elseif ($ID > 0 && !CForumNew::CanUserUpdateForum($ID, $USER->GetUserGroupArray(), $USER->GetID())) {
$arError[] = array("id" => "not_right_for_edit", "text" => GetMessage("FE_NO_PERMS2UPDATE"));
} elseif ($ID <= 0 && !CForumNew::CanUserAddForum($USER->GetUserGroupArray(), $USER->GetID())) {
$arError[] = array("id" => "not_right_for_add", "text" => GetMessage("FE_NO_PERMS2ADD"));
} elseif (!empty($_FILES["IMAGE"]["tmp_name"])) {
$sUploadDir = $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/images/forum/" . ($_REQUEST["TYPE"] == "I" ? "icon" : "smile") . "/";
CheckDirPath($sUploadDir);
$arSmile = $ID > 0 ? CForumSmile::GetByID($ID) : $arSmile;
$res = CFile::CheckImageFile($_FILES["IMAGE"], COption::GetOptionString("forum", "file_max_size", 50000), 0, 0);
if (strLen($res) > 0) {
$arError[] = array("id" => "IMAGE", "text" => $res);
} elseif (file_exists($sUploadDir . $fileName) && !(isset($arSmile["IMAGE"]) && $arSmile["IMAGE"] != $fileName)) {
$arError[] = array("id" => "IMAGE", "text" => GetMessage("ERROR_EXISTS_IMAGE", array("#FILE#" => str_replace("//", "/", "/" . BX_ROOT . "/images/forum/" . ($_REQUEST["TYPE"] == "I" ? "icon" : "smile") . "/" . $fileName))));
} elseif (!@copy($_FILES["IMAGE"]["tmp_name"], $sUploadDir . $fileName)) {
$arError[] = array("id" => "IMAGE", "text" => GetMessage("ERROR_COPY_IMAGE"));
} else {
@chmod($sUploadDir . $fileName, BX_FILE_PERMISSIONS);
}
}
if (empty($arError)) {
$GLOBALS["APPLICATION"]->ResetException();
$arFields = array("SORT" => $_REQUEST["SORT"], "TYPE" => $_REQUEST["TYPE"], "TYPING" => trim($_REQUEST["TYPING"]), "DESCRIPTION" => $_REQUEST["DESCRIPTION"], "LANG" => array());
if (!empty($_FILES["IMAGE"]["tmp_name"])) {
$arFields["IMAGE"] = $fileName;
示例11: _PrepareDataForQuery
/**
* Prepares array of fields with values for query to DB.
* Also, uploads/removes files, if there are.
* @throws LearnException on error. Errcodes are: LearnException::EXC_ERR_GN_CHECK_PARAMS,
* LearnException::EXC_ERR_GN_FILE_UPLOAD
*/
protected static function _PrepareDataForQuery($arFieldsMap, $arFields, $lessonId)
{
global $DB;
$arLessonData = false;
// if data prepartation for update - cache data about lesson to be updated
if ($lessonId !== false) {
// if lesson data not cached - get it
if ($arLessonData === false) {
$arLessonData = self::GetByID($lessonId);
}
}
$arFieldsToDb = array();
foreach ($arFields as $field => $value) {
$fieldNameInDB = $arFieldsMap[$field]['field'];
if ($field === 'PREVIEW_PICTURE' || $field === 'DETAIL_PICTURE' || $fieldNameInDB === 'PREVIEW_PICTURE' || $fieldNameInDB === 'DETAIL_PICTURE') {
$error = CFile::CheckImageFile($value);
if (strlen($error) > 0) {
throw new LearnException('EA_PARAMS: ' . $error, LearnException::EXC_ERR_GN_CHECK_PARAMS);
}
// if data prepartation for update - gets prev pictures names
if ($lessonId !== false) {
if (!array_key_exists($field, $arLessonData)) {
throw new LearnException('EA_LOGIC', LearnException::EXC_ERR_ALL_LOGIC);
}
$arFields[$field]['old_file'] = $arLessonData[$field];
$value = $arFields[$field];
}
// throws LearnException on error, returns FALSE if id of image not updated
$fileId = self::_UploadFile($fieldNameInDB, $value);
if ($fileId === false) {
continue;
}
// id of image not updated
// replace value for current field to fileId
$value = $arFields[$field] = $fileId;
}
if ($value === NULL) {
$arFieldsToDb[$fieldNameInDB] = false;
} else {
$arFieldsToDb[$fieldNameInDB] = $value;
}
}
return $arFieldsToDb;
}
示例12: CheckFields
public static function CheckFields($ACTION, &$arFields, $ID = 0)
{
$aMsg = array();
$ID = intVal($ID);
$arVote = array();
if ($ID > 0) {
$db_res = CVote::GetByID($ID);
if ($db_res && ($res = $db_res->Fetch())) {
$arVote = $res;
}
}
unset($arFields["ID"]);
if (is_set($arFields, "CHANNEL_ID") || $ACTION == "ADD") {
$arFields["CHANNEL_ID"] = intVal($arFields["CHANNEL_ID"]);
if ($arFields["CHANNEL_ID"] <= 0) {
$aMsg[] = array("id" => "CHANNEL_ID", "text" => GetMessage("VOTE_EMPTY_CHANNEL_ID"));
} else {
$rChannel = CVoteChannel::GetList($by, $order, array('ID' => intval($arFields['CHANNEL_ID'])), $filtered);
if (!($rChannel && ($arChannel = $rChannel->Fetch()))) {
$aMsg[] = array("id" => "CHANNEL_ID", "text" => GetMessage("VOTE_WRONG_CHANNEL_ID"));
}
}
}
if (is_set($arFields, "C_SORT")) {
$arFields["C_SORT"] = intval($arFields["C_SORT"]);
}
if (is_set($arFields, "ACTIVE") || $ACTION == "ADD") {
$arFields["ACTIVE"] = $arFields["ACTIVE"] == "N" ? "N" : "Y";
}
unset($arFields["TIMESTAMP_X"]);
$date_start = false;
if (is_set($arFields, "DATE_START") || $ACTION == "ADD") {
$arFields["DATE_START"] = trim($arFields["DATE_START"]);
$date_start = MakeTimeStamp($arFields["DATE_START"]);
if (!$date_start) {
$aMsg[] = array("id" => "DATE_START", "text" => GetMessage("VOTE_WRONG_DATE_START"));
}
}
if (is_set($arFields, "DATE_END") || $ACTION == "ADD") {
$arFields["DATE_END"] = trim($arFields["DATE_END"]);
if (strlen($arFields["DATE_END"]) <= 0) {
if ($date_start != false) {
$date_end = $date_start + 2592000;
$arFields["DATE_END"] = GetTime($date_end, "FULL");
} else {
$date_end = 1924984799;
// '31.12.2030 23:59:59'
$arFields["DATE_END"] = GetTime($date_end, "FULL");
}
} else {
$date_end = MakeTimeStamp($arFields["DATE_END"]);
}
if (!$date_end) {
$aMsg[] = array("id" => "DATE_END", "text" => GetMessage("VOTE_WRONG_DATE_END"));
} elseif ($date_start >= $date_end && !empty($arFields["DATE_START"])) {
$aMsg[] = array("id" => "DATE_END", "text" => GetMessage("VOTE_WRONG_DATE_TILL"));
}
}
if (empty($aMsg) && (is_set($arFields, "DATE_START") || is_set($arFields, "DATE_END") || is_set($arFields, "CHANNEL_ID") || is_set($arFields, "ACTIVE"))) {
$vid = 0;
if ($ACTION == "ADD" && $arFields["ACTIVE"] == "Y") {
$vid = CVote::WrongDateInterval(0, $arFields["DATE_START"], $arFields["DATE_END"], $arFields["CHANNEL_ID"]);
} elseif ($ACTION != "ADD" && !(is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y")) {
$res = array("DATE_START" => is_set($arFields, "DATE_START") ? $arFields["DATE_START"] : false, "DATE_END" => is_set($arFields, "DATE_END") ? $arFields["DATE_END"] : false, "CHANNEL_ID" => is_set($arFields, "CHANNEL_ID") ? $arFields["CHANNEL_ID"] : false);
$vid = CVote::WrongDateInterval($ID, $res["DATE_START"], $res["DATE_END"], $res["CHANNEL_ID"]);
}
if (intVal($vid) > 0) {
$aMsg[] = array("id" => "DATE_START", "text" => str_replace("#ID#", $vid, GetMessage("VOTE_WRONG_INTERVAL")));
}
}
if (is_set($arFields, "IMAGE_ID") && strLen($arFields["IMAGE_ID"]["name"]) <= 0 && strLen($arFields["IMAGE_ID"]["del"]) <= 0) {
unset($arFields["IMAGE_ID"]);
} elseif (is_set($arFields, "IMAGE_ID")) {
if ($str = CFile::CheckImageFile($arFields["IMAGE_ID"])) {
$aMsg[] = array("id" => "IMAGE_ID", "text" => $str);
} else {
$arFields["IMAGE_ID"]["MODULE_ID"] = "vote";
if (!empty($arVote)) {
$arFields["IMAGE_ID"]["old_file"] = $arVote["IMAGE_ID"];
}
}
}
if (is_set($arFields, "COUNTER")) {
$arFields["COUNTER"] = intVal($arFields["COUNTER"]);
}
if (is_set($arFields, "TITLE")) {
$arFields["TITLE"] = trim($arFields["TITLE"]);
}
if (is_set($arFields, "DESCRIPTION")) {
$arFields["DESCRIPTION"] = trim($arFields["DESCRIPTION"]);
}
if (is_set($arFields, "DESCRIPTION_TYPE") || $ACTION == "ADD") {
$arFields["DESCRIPTION_TYPE"] = $arFields["DESCRIPTION_TYPE"] == "html" ? "html" : "text";
}
if (is_set($arFields, "EVENT1")) {
$arFields["EVENT1"] = trim($arFields["EVENT1"]);
}
if (is_set($arFields, "EVENT2")) {
$arFields["EVENT2"] = trim($arFields["EVENT2"]);
}
//.........这里部分代码省略.........
示例13: convert_attachment
function convert_attachment($fileID = "", $p = "", $type = "", $text = "")
{
if (is_array($fileID)) {
$text = $fileID[0];
$p = $fileID[3];
$fileID = $fileID[2];
}
$fileID = intval($fileID);
$type = strtolower(empty($type) ? $this->type : $type);
$type = in_array($type, array("html", "mail", "bbcode", "rss")) ? $type : "html";
$this->arFiles = is_array($this->arFiles) ? $this->arFiles : array($this->arFiles);
if ($fileID <= 0 || !array_key_exists($fileID, $this->arFiles) && !in_array($fileID, $this->arFiles)) {
return $text;
}
if (!array_key_exists($fileID, $this->arFiles) && in_array($fileID, $this->arFiles)) {
// array(fileID10, fileID12, fileID14)
unset($this->arFiles[array_search($fileID, $this->arFiles)]);
$this->arFiles[$fileID] = $fileID;
// array(fileID10 => fileID10, fileID12 => fileID12, fileID14 => fileID14)
}
if (!is_array($this->arFiles[$fileID])) {
$this->arFiles[$fileID] = CFile::GetFileArray($fileID);
}
// array(fileID10 => array about file, ....)
if (!is_array($this->arFiles[$fileID])) {
// if file does not exist
unset($this->arFiles[$fileID]);
return $text;
}
if (!array_key_exists($fileID, $this->arFilesParsed) || empty($this->arFilesParsed[$fileID][$type])) {
$arFile = $this->arFiles[$fileID];
if ($type == "html" || $type == "rss") {
$width = 0;
$height = 0;
if (preg_match_all("/width\\=(?P<width>\\d+)|height\\=(?P<height>\\d+)/is" . BX_UTF_PCRE_MODIFIER, $p, $matches)) {
$width = intval(!empty($matches["width"][0]) ? $matches["width"][0] : $matches["width"][1]);
$height = intval(!empty($matches["height"][0]) ? $matches["height"][0] : $matches["height"][1]);
}
$arFile[$type] = $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:forum.interface", "show_file", array("FILE" => $arFile, "SHOW_MODE" => $type == "html" ? "THUMB" : "RSS", "SIZE" => array("width" => $width, "height" => $height), "MAX_SIZE" => array("width" => $this->imageWidth, "height" => $this->imageHeight), "HTML_SIZE" => array("width" => $this->imageHtmlWidth, "height" => $this->imageHtmlHeight), "CONVERT" => "N", "NAME_TEMPLATE" => $this->userNameTemplate, "FAMILY" => "FORUM", "SINGLE" => "Y", "RETURN" => "Y"), $this->component, array("HIDE_ICONS" => "Y"));
} else {
$path = '/bitrix/components/bitrix/forum.interface/show_file.php?fid=' . $arFile["ID"];
$bIsImage = CFile::CheckImageFile(CFile::MakeFileArray($fileID)) === null;
// $path = ($bIsImage && !empty($arFile["SRC"]) ? $arFile["SRC"] : !$bIsImage && !empty($arFile["URL"]) ? $arFile["URL"] : $path);
$path = preg_replace("'(?<!:)/+'s", "/", substr($path, 0, 1) == "/" ? CHTTP::URN2URI($path, $this->serverName) : $path);
switch ($type) {
case "bbcode":
$arFile["bbcode"] = $bIsImage ? '[IMG]' . $path . '[/IMG]' : '[URL=' . $path . ']' . $arFile["ORIGINAL_NAME"] . '[/URL]';
break;
case "mail":
$arFile["mail"] = $arFile["ORIGINAL_NAME"] . ($bIsImage ? " (IMAGE: " . $path . ")" : " (URL: " . $path . ")");
break;
}
}
$this->arFilesParsed[$fileID] = $arFile;
}
$this->arFilesIDParsed[] = $fileID;
return $this->arFilesParsed[$fileID][$type];
}
示例14: LocalRedirect
// Unique ID of the Image uploader on the page
if (isset($_REQUEST["view_mode"])) {
$arParams["VIEW_MODE"] = $_REQUEST["view_mode"] == "form" ? "form" : "applet";
CUserOptions::SetOption('photogallery', "view_mode_" . $arParams["UPLOADER_ID"], $arParams["VIEW_MODE"]);
return LocalRedirect($arParams["ACTION_URL"]);
} else {
$arParams["VIEW_MODE"] = CUserOptions::GetOption('photogallery', "view_mode_" . $arParams["UPLOADER_ID"], "form");
}
$arParams["VIEW_MODE"] = $arParams["VIEW_MODE"] == "form" ? "form" : "applet";
if ($arParams["USE_WATERMARK"] == "Y") {
if (isset($_REQUEST['watermark_iframe']) && $_REQUEST['watermark_iframe'] == 'Y' && check_bitrix_sessid()) {
$UploadError = false;
$pathto = '';
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$file = $_FILES['watermark_img'];
$checkImgMsg = CFile::CheckImageFile($file);
if ($file['error'] != 0) {
$UploadError = "[IU_WM01] " . GetMessage("P_WM_IMG_ERROR01");
} elseif (strlen($checkImgMsg) > 0 || $checkImgMsg === "") {
$UploadError = "[IU_WM02] " . ($checkImgMsg === "" ? GetMessage("P_WM_IMG_ERROR02") : $checkImgMsg);
} else {
$imgArray = CFile::GetImageSize($file["tmp_name"]);
if (is_array($imgArray)) {
$width = $imgArray[0];
$height = $imgArray[1];
}
$pathto = CTempFile::GetDirectoryName(1) . '/' . "watermark_" . md5($file["name"]) . GetFileExtension($file["name"]);
CheckDirPath($pathto);
$pathtoRel = substr($pathto, strlen($_SERVER["DOCUMENT_ROOT"]));
if (!move_uploaded_file($file["tmp_name"], $pathto)) {
$UploadError = "[IU_WM03] " . GetMessage("P_WM_IMG_ERROR03");
示例15: isset
if (!isset($arResult["strMessage"])) {
$moduleId = "uf";
$arFile = $_FILES["file"];
$arFile["MODULE_ID"] = $moduleId;
$ufCode = isset($arFileStorage["DISC_FOLDER"]) || isset($arFileStorage["WEBDAV_DATA"]) ? "UF_SONET_COM_DOC" : "UF_SONET_COM_FILE";
$arPostFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("SONET_COMMENT", 0, LANGUAGE_ID);
if (empty($arPostFields[$ufCode])) {
$arResult["strMessage"] = "Userfield not exists";
}
}
if (!isset($arResult["strMessage"])) {
$pos = strpos($arFile["name"], '?');
if ($pos !== false) {
$arFile["name"] = substr($arFile["name"], 0, $pos);
}
$res = '' . CFile::CheckImageFile($arFile, intval($arPostFields[$ufCode]['SETTINGS']['MAX_ALLOWED_SIZE']) > 0 ? $arPostFields[$ufCode]['SETTINGS']['MAX_ALLOWED_SIZE'] : 5000000, 0, 0);
if ($res !== '') {
$arResult["strMessage"] = "Incorrect file";
}
}
if (!isset($arResult["strMessage"])) {
$arSaveResult = CMobileHelper::SaveFile($arFile, $arFileStorage);
if (!$arSaveResult || !isset($arSaveResult["ID"])) {
$arResult["strMessage"] = "Can't save file";
}
}
if (!isset($arResult["strMessage"])) {
if (isset($arFileStorage["DISC_FOLDER"])) {
$comment_text = "[DISK FILE ID=n" . $arSaveResult["ID"] . "]";
} elseif (isset($arFileStorage["WEBDAV_DATA"])) {
$comment_text = "[DOCUMENT ID=" . $arSaveResult["ID"] . "]";