/** * <p>Метод удаляет файл из таблицы зарегистрированных файлов (b_file) и с диска. Статичный метод.</p> * * * @param int $id Цифровой идентификатор файла. * * @return mixed * * <h4>Example</h4> * <pre> * <? * // удаляем изображение формы * $arFilter = array("ID" => 1, "ID_EXACT_MATCH" => "Y"); * $rsForm = CForm::GetList($by, $order, $arFilter, $is_filtered); * if ($arForm = $rsForm->Fetch()) * { * if (intval($arForm["IMAGE_ID"])>0) <b>CFile::Delete</b>($arForm["IMAGE_ID"]); * } * ?> * </pre> * * * <h4>See Also</h4> * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/file/deletedirfiles.php">DeleteDirFiles</a> </li> * <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/file/deletedirfilesex.php">DeleteDirFilesEx</a> </li> * </ul><a name="examples"></a> * * * @static * @link http://dev.1c-bitrix.ru/api_help/main/reference/cfile/delete.php * @author Bitrix */ public static function Delete($ID) { global $DB; $io = CBXVirtualIo::GetInstance(); $ID = intval($ID); if ($ID <= 0) { return; } $res = CFile::GetByID($ID); if ($res = $res->Fetch()) { $delete_size = 0; $upload_dir = COption::GetOptionString("main", "upload_dir", "upload"); $dname = $_SERVER["DOCUMENT_ROOT"] . "/" . $upload_dir . "/" . $res["SUBDIR"]; $fname = $dname . "/" . $res["FILE_NAME"]; $file = $io->GetFile($fname); if ($file->isExists() && $file->unlink()) { $delete_size += $res["FILE_SIZE"]; } $delete_size += CFile::ResizeImageDelete($res); $DB->Query("DELETE FROM b_file WHERE ID = " . $ID); $directory = $io->GetDirectory($dname); if ($directory->isExists() && $directory->isEmpty()) { $directory->rmdir(); } CFile::CleanCache($ID); foreach (GetModuleEvents("main", "OnFileDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($res)); } /****************************** QUOTA ******************************/ if ($delete_size > 0 && COption::GetOptionInt("main", "disk_space") > 0) { CDiskQuota::updateDiskQuota("file", $delete_size, "delete"); } /****************************** QUOTA ******************************/ } }
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']; } } }
/** * @static * @param $id * @return \BitrixHelperLib\Classes\Block\File * @throws \Exception */ static function fromId($id) { if (!($file = \CFile::GetByID($id)->GetNext())) { throw new \Exception('File with id ' . $id . ' does not exist'); } $className = get_called_class(); return new $className($file); }
public function getImageUrl($key) { if (!$this->hasImage($key)) { throw new \Exception(__CLASS__ . ' with ID ' . $this->id . ' does not have image ' . $key); } if (empty($this->imagesSrc[$key])) { if ($file = \CFile::GetByID($this->getImageId($key))->GetNext()) { $this->imagesSrc[$key] = \CFile::GetFileSRC($file); } } return $this->imagesSrc[$key]; }
/** * {@inheritdoc} */ public function generateRow(&$row, $data) { $html = ''; if ($this->getSettings('MULTIPLE')) { } else { $path = \CFile::GetPath($data[$this->code]); $rsFile = \CFile::GetByID($data[$this->code]); $file = $rsFile->Fetch(); if ($path) { $html = '<a href="' . $path . '" >' . $file['FILE_NAME'] . ' (' . $file['FILE_DESCRIPTION'] . ')' . '</a>'; } $row->AddViewField($this->code, $html); } }
function __get_file_array($id, &$res) { static $arFilesCache = array(); if (!array_key_exists($id, $arFilesCache)) { $db_res = CFile::GetByID($id); $arFilesCache[$id] = $db_res->GetNext(); $arFilesCache[$id]["FILE_ARRAY"] = array(); __parse_file_size($arFilesCache[$id]["FILE_ARRAY"], $arFilesCache[$id]); } if (!array_key_exists($id, $arFilesCache)) { $res = $arFilesCache[$id]; return true; } return false; }
public static function getAvatar($uid = false) { global $USER; if ($uid === false) { $uid = $USER->GetID(); } $rsUser = CUser::GetByID($uid); $arResult = $rsUser->GetNext(false); if (!empty($arResult) && !empty($arResult['PERSONAL_PHOTO'])) { $db_img = CFile::GetByID($arResult['PERSONAL_PHOTO']); $db_img_arr = $db_img->Fetch(); if (!empty($db_img_arr)) { $strImageStorePath = COption::GetOptionString('main', 'upload_dir', 'upload'); $sImagePath = '/' . $strImageStorePath . '/' . $db_img_arr['SUBDIR'] . '/' . $db_img_arr['FILE_NAME']; $sImagePath = str_replace('//', '/', $sImagePath); return $sImagePath; } } return false; }
/** * Возвращает информацию о файле * * @param int|array $fid ID файла, либо массив ID файлов * @return array - данные информация о файле */ public static function getFileData($fid) { if (!isset($fid)) { return; } if (is_array($fid)) { $rsFile = CFile::GetList(array(), array("@ID" => implode(",", $fid))); } else { $rsFile = CFile::GetByID($fid); } $ret = array(); while ($ifile = $rsFile->Fetch()) { $ret[$ifile['ID']] = array("SRC" => P_UPLOAD . $ifile["SUBDIR"] . "/" . $ifile['FILE_NAME'], "WIDTH" => $ifile["WIDTH"], "HEIGHT" => $ifile["HEIGHT"], "DATA" => $ifile); } if (is_array($fid)) { return $ret; } else { return $ret[$fid]; } }
static function getAvatar($uid = false) { global $USER; if ($uid === false) { $uid = $USER->GetID(); } $rsUser = CUser::GetByID($uid); $arResult = $rsUser->GetNext(false); if (!empty($arResult) && !empty($arResult["PERSONAL_PHOTO"])) { $db_img = CFile::GetByID($arResult["PERSONAL_PHOTO"]); $db_img_arr = $db_img->Fetch(); if (!empty($db_img_arr)) { $strImageStorePath = COption::GetOptionString("main", "upload_dir", "upload"); $sImagePath = "/" . $strImageStorePath . "/" . $db_img_arr["SUBDIR"] . "/" . $db_img_arr["FILE_NAME"]; $sImagePath = str_replace("//", "/", $sImagePath); return $sImagePath; } } return false; }
public static function Edit($Params) { global $DB; $source_id = false; $arFields = $Params['arFields']; $bNew = !isset($arFields['ID']) || $arFields['ID'] <= 0; $bFile_FD = $Params['path'] && strlen($Params['path']) > 0; $bFile_PC = $Params['file'] && strlen($Params['file']['name']) > 0 && $Params['file']['size'] > 0; $io = CBXVirtualIo::GetInstance(); if ($bFile_FD || $bFile_PC) { if ($bFile_FD) { $DocRoot = CSite::GetSiteDocRoot(false); $tmp_name = $DocRoot . $Params['path']; if ($io->FileExists($tmp_name)) { $flTmp = $io->GetFile($tmp_name); $file_name = substr($Params['path'], strrpos($Params['path'], '/') + 1); $arFile = array("name" => $file_name, "size" => $flTmp->GetFileSize(), "tmp_name" => $tmp_name, "type" => CFile::IsImage($file_name) ? 'image' : 'file'); } } else { if ($bFile_PC) { $arFile = $Params['file']; } } if (!CMedialib::CheckFileExtention($arFile["name"])) { return false; } if (!$bNew) { $arFile["old_file"] = CMedialibItem::GetSourceId($arFields['ID']); $arFile["del"] = "Y"; } // Resizing Image if (CFile::IsImage($arFile["name"])) { $arSize = array('width' => COption::GetOptionInt('fileman', "ml_max_width", 1024), 'height' => COption::GetOptionInt('fileman', "ml_max_height", 1024)); $res = CFile::ResizeImage($arFile, $arSize); } $arFile["MODULE_ID"] = "fileman"; $source_id = CFile::SaveFile($arFile, "medialibrary"); if ($source_id) { $r = CFile::GetByID($source_id); if ($arFile = $r->Fetch()) { if (CFile::IsImage($arFile['FILE_NAME'])) { CMedialibItem::GenerateThumbnail($arFile, array('width' => COption::GetOptionInt('fileman', "ml_thumb_width", 140), 'height' => COption::GetOptionInt('fileman', "ml_thumb_height", 105))); } $arFile['PATH'] = CMedialibItem::GetFullPath($arFile); } } } // TODO: Add error handling if ($bNew && !$source_id) { return false; } // 2. Add to b_medialib_item if (!isset($arFields['~DATE_UPDATE'])) { $arFields['~DATE_UPDATE'] = $DB->CurrentTimeFunction(); } if (!CMedialibItem::CheckFields($arFields)) { return false; } if (CModule::IncludeModule("search")) { $arStem = stemming($arFields['NAME'] . ' ' . $arFields['DESCRIPTION'] . ' ' . $arFields['KEYWORDS'], LANGUAGE_ID); if (count($arStem) > 0) { $arFields['SEARCHABLE_CONTENT'] = '{' . implode('}{', array_keys($arStem)) . '}'; } else { $arFields['SEARCHABLE_CONTENT'] = ''; } } if ($bNew) { unset($arFields['ID']); $arFields['SOURCE_ID'] = $source_id; $arFields['~DATE_CREATE'] = $arFields['~DATE_UPDATE']; $arFields['ITEM_TYPE'] = ''; $ID = CDatabase::Add("b_medialib_item", $arFields, array("DESCRIPTION", "SEARCHABLE_CONTENT")); } else { if ($source_id) { $arFields['SOURCE_ID'] = $source_id; } $ID = $arFields['ID']; unset($arFields['ID']); $strUpdate = $DB->PrepareUpdate("b_medialib_item", $arFields); $strSql = "UPDATE b_medialib_item SET " . $strUpdate . " WHERE ID=" . IntVal($ID); $DB->QueryBind($strSql, array("DESCRIPTION" => $arFields["DESCRIPTION"], "SEARCHABLE_CONTENT" => $arFields["SEARCHABLE_CONTENT"]), false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } // 3. Set fields to b_medialib_collection_item if (!$bNew) { $strSql = "DELETE FROM b_medialib_collection_item WHERE ITEM_ID=" . IntVal($ID); $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); } $strCollections = "0"; for ($i = 0, $l = count($Params['arCollections']); $i < $l; $i++) { $strCollections .= "," . IntVal($Params['arCollections'][$i]); } $strSql = "INSERT INTO b_medialib_collection_item(ITEM_ID, COLLECTION_ID) " . "SELECT " . intVal($ID) . ", ID " . "FROM b_medialib_collection " . "WHERE ID in (" . $strCollections . ")"; $res = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); if (!$arFields['ID']) { $arFields['ID'] = $ID; } if ($source_id) { $arFields = array_merge($arFile, $arFields); } return $arFields; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (CModule::IncludeModule("catalog")) { $ajaxResult = array(); if (IntVal($_REQUEST["PRODUCT_ID"]) > 0) { $itemId = Add2BasketByProductID(IntVal($_REQUEST["PRODUCT_ID"])); if ($itemId !== false) { $arInfo = CIBlockElement::GetByID(IntVal($_REQUEST["PRODUCT_ID"]))->GetNext(); $strImageStorePath = COption::GetOptionString("main", "upload_dir", "upload"); $imageId = empty($arInfo["DETAIL_PICTURE"]) ? $arInfo["PREVIEW_PICTURE"] : $arInfo["DETAIL_PICTURE"]; if (!empty($imageId)) { $sPath = CFile::GetByID($imageId)->GetNext(); $sPath = "/" . $strImageStorePath . "/" . $sPath["SUBDIR"] . "/" . $sPath["FILE_NAME"]; } else { $sPath = ""; } $ajaxResult["MSG"]["NAME"] = $arInfo["NAME"]; $ajaxResult["MSG"]["URL"] = $arInfo["DETAIL_PAGE_URL"]; $ajaxResult["MSG"]["IMG"] = $sPath; } else { $ajaxResult["MSG"] = "Ошибка добавления товара в корзину"; } echo json_encode($ajaxResult); } }
$bGannt = (bool) $_POST['bGannt']; } // Override CHECK_PERMISSIONS, if it was given in $_POST['filter'] $arFilter['CHECK_PERMISSIONS'] = 'Y'; $rsTasks = CTasks::GetList($arOrder, $arFilter); $arTasks = array(); $arTasksIDs = array(); $arViewed = array(); while ($task = $rsTasks->GetNext()) { $arTasks[$task["ID"]] = $task; $arTasksIDs[] = $task["ID"]; $arViewed[$task["ID"]] = $task["VIEWED_DATE"] ? $task["VIEWED_DATE"] : $task["CREATED_DATE"]; $rsTaskFiles = CTaskFiles::GetList(array(), array("TASK_ID" => $task["ID"])); $task["FILES"] = array(); while ($arTaskFile = $rsTaskFiles->Fetch()) { $rsFile = CFile::GetByID($arTaskFile["FILE_ID"]); if ($arFile = $rsFile->Fetch()) { $task["FILES"][] = $arFile; } } $arTasks[$task["ID"]] = $task; } unset($arFilter["PARENT_ID"]); $rsChildrenCount = CTasks::GetChildrenCount($arFilter, $arTasksIDs); if ($rsChildrenCount) { while ($arChildrens = $rsChildrenCount->Fetch()) { $arChildrenCount["PARENT_" . $arChildrens["PARENT_ID"]] = $arChildrens["CNT"]; } } $arUpdatesCount = CTasks::GetUpdatesCount($arViewed); $APPLICATION->RestartBuffer();
COption::SetOptionString("eshop", "shopEmail", $shopEmail, false, WIZARD_SITE_ID); $siteName = $wizard->GetVar("siteName"); COption::SetOptionString("eshop", "siteName", $siteName, false, WIZARD_SITE_ID); $obSite = new CSite; $obSite->Update(WIZARD_SITE_ID, Array( "EMAIL" => $shopEmail, "SITE_NAME" => $siteName, "SERVER_NAME" => $_SERVER["SERVER_NAME"], )); if(strlen($siteStamp)>0) { if(IntVal($siteStamp) > 0) { $ff = CFile::GetByID($siteStamp); if($zr = $ff->Fetch()) { $strOldFile = str_replace("//", "/", WIZARD_SITE_ROOT_PATH."/".(COption::GetOptionString("main", "upload_dir", "upload"))."/".$zr["SUBDIR"]."/".$zr["FILE_NAME"]); @copy($strOldFile, WIZARD_SITE_PATH."include/stamp.gif"); CFile::Delete($zr["ID"]); $siteStamp = WIZARD_SITE_DIR."include/stamp.gif"; COption::SetOptionString("eshop", "siteStamp", $siteStamp, false, WIZARD_SITE_ID); } } } else { $siteStamp = "/bitrix/templates/".WIZARD_TEMPLATE_ID."_".WIZARD_THEME_ID."/images/pechat.gif"; }
public static function GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue) { $result = $fieldValue; switch ($arFieldType['Type']) { case "user": $result = CBPHelper::UsersArrayToString($fieldValue, null, $documentType); break; case "bool": if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { $result[] = strtoupper($r) == "Y" ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"); } } else { $result = strtoupper($fieldValue) == "Y" ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"); } break; case "file": if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { $r = intval($r); $dbImg = CFile::GetByID($r); if ($arImg = $dbImg->Fetch()) { $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $r . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]"; } } } else { $fieldValue = intval($fieldValue); $dbImg = CFile::GetByID($fieldValue); if ($arImg = $dbImg->Fetch()) { $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]"; } } break; case "select": if (isset($arFieldType["Options"][$fieldValue])) { $result = $arFieldType["Options"][$fieldValue]; } break; } return $result; }
function GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue) { if ($storage = self::needProxyToDiskByDocType($documentType)) { return self::proxyToDisk(__FUNCTION__, array(\Bitrix\Disk\BizProcDocumentCompatible::generateDocumentType($storage->getId()), $arFieldType, $fieldValue)); } $result = $fieldValue; switch ($arFieldType['Type']) { case "user": if (!is_array($fieldValue)) { $fieldValue = array($fieldValue); } $result = CBPHelper::UsersArrayToString($fieldValue, null, array("webdav", "CIBlockDocumentWebdavSocnet", $documentType)); break; case "bool": if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { $result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"); } } else { $result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"); } break; case "file": if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { $r = intval($r); $dbImg = CFile::GetByID($r); if ($arImg = $dbImg->Fetch()) { $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . urlencode($arImg["FILE_NAME"]) . "&i=" . $r . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]"; } } } else { $fieldValue = intval($fieldValue); $dbImg = CFile::GetByID($fieldValue); if ($arImg = $dbImg->Fetch()) { $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . urlencode($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]"; } } break; case "select": if (is_array($arFieldType["Options"])) { if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { if (array_key_exists($r, $arFieldType["Options"])) { $result[] = $arFieldType["Options"][$r]; } } } else { if (array_key_exists($fieldValue, $arFieldType["Options"])) { $result = $arFieldType["Options"][$fieldValue]; } } } break; } if (strpos($arFieldType['Type'], ":") !== false) { $arCustomType = CIBlockProperty::GetUserType(substr($arFieldType['Type'], 2)); if (array_key_exists("GetPublicViewHTML", $arCustomType)) { if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) { $result = array(); foreach ($fieldValue as $value) { $r = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $value), "")); $result[] = HTMLToTxt($r); } } else { $result = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $fieldValue), "")); $result = HTMLToTxt($result); } } } return $result; }
protected static function _getAllFormFields($WEB_FORM_ID, $RESULT_ID, $arAnswers) { global $APPLICATION; $strResult = ""; $w = CFormField::GetList($WEB_FORM_ID, "ALL", $by, $order, array("ACTIVE" => "Y"), $is_filtered); while ($wr=$w->Fetch()) { $answer = ""; $answer_raw = ''; if (is_array($arAnswers[$wr["SID"]])) { $bHasDiffTypes = false; $lastType = ''; foreach ($arAnswers[$wr['SID']] as $arrA) { if ($lastType == '') $lastType = $arrA['FIELD_TYPE']; elseif ($arrA['FIELD_TYPE'] != $lastType) { $bHasDiffTypes = true; break; } } foreach($arAnswers[$wr["SID"]] as $arrA) { if ($wr['ADDITIONAL'] == 'Y') { $arrA['FIELD_TYPE'] = $wr['FIELD_TYPE']; } $USER_TEXT_EXIST = (strlen(trim($arrA["USER_TEXT"]))>0); $ANSWER_TEXT_EXIST = (strlen(trim($arrA["ANSWER_TEXT"]))>0); $ANSWER_VALUE_EXIST = (strlen(trim($arrA["ANSWER_VALUE"]))>0); $USER_FILE_EXIST = (intval($arrA["USER_FILE_ID"])>0); if ( $bHasDiffTypes && !$USER_TEXT_EXIST && ( $arrA['FIELD_TYPE'] == 'text' || $arrA['FIELD_TYPE'] == 'textarea' ) ) { continue; } if (strlen(trim($answer)) > 0) $answer .= "\n"; if (strlen(trim($answer_raw)) > 0) $answer_raw .= ","; if ($ANSWER_TEXT_EXIST) $answer .= $arrA["ANSWER_TEXT"].': '; switch ($arrA['FIELD_TYPE']) { case 'text': case 'textarea': case 'email': case 'url': case 'hidden': case 'date': case 'password': if ($USER_TEXT_EXIST) { $answer .= trim($arrA["USER_TEXT"]); $answer_raw .= trim($arrA["USER_TEXT"]); } break; case 'checkbox': case 'multiselect': case 'radio': case 'dropdown': if ($ANSWER_TEXT_EXIST) { $answer = substr($answer, 0, -2).' '; $answer_raw .= $arrA['ANSWER_TEXT']; } if ($ANSWER_VALUE_EXIST) { $answer .= '('.$arrA['ANSWER_VALUE'].') '; if (!$ANSWER_TEXT_EXIST) { $answer_raw .= $arrA['ANSWER_VALUE']; } } if (!$ANSWER_VALUE_EXIST && !$ANSWER_TEXT_EXIST) { $answer_raw .= $arrA['ANSWER_ID']; } $answer .= '['.$arrA['ANSWER_ID'].']'; break; case 'file': case 'image': if ($USER_FILE_EXIST) { $f = CFile::GetByID($arrA["USER_FILE_ID"]); if ($fr = $f->Fetch()) { $file_size = CFile::FormatSize($fr["FILE_SIZE"]); $url = ($APPLICATION->IsHTTPS() ? "https://" : "http://").$_SERVER["HTTP_HOST"]. "/freetrix/tools/form_show_file.php?rid=".$RESULT_ID. "&hash=".$arrA["USER_FILE_HASH"]."&action=download&lang=".LANGUAGE_ID; if ($arrA["USER_FILE_IS_IMAGE"]=="Y") { $answer .= $arrA["USER_FILE_NAME"]." [".$fr["WIDTH"]." x ".$fr["HEIGHT"]."] (".$file_size.")\n".$url; } else { $answer .= $arrA["USER_FILE_NAME"]." (".$file_size.")\n".$url."&action=download"; } } $answer_raw .= $arrA['USER_FILE_NAME']; } break; } } } $strResult .= $wr["TITLE"].":\r\n".(strlen($answer)<=0 ? " " : $answer)."\r\n\r\n"; } return $strResult; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $APPLICATION->ShowPanel = false; global $USER; if ($USER->IsAuthorized()) { $UserData = CustomUser::SearchUser(array("ID" => $USER->GetID())); if ($UserData[0]["PERSONAL_PHOTO"] > 0) { $UserData[0]["PERSONAL_PHOTO_RESIZE"] = CFile::ResizeImageGet(CFile::GetByID($UserData[0]["PERSONAL_PHOTO"])->Fetch(), array("width" => 60, "height" => 60), BX_RESIZE_IMAGE_PROPORTIONAL, true); } } else { if ($_SERVER["PHP_SELF"] != "/amplifiers/auth/index.php") { LocalRedirect("/amplifiers/auth/"); } } ?> <!DOCTYPE html> <html> <head> <script type="text/javascript" src="/js/plugins/jquery-1.11.2.min.js"></script> <link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico" /> <title><?php $APPLICATION->ShowTitle(); ?> </title> <script type="text/javascript"> $(document).ready(function(){ $("#CheckIn").bind("click",function(){ if(navigator.geolocation) {
function MakeFileArray($path, $mimetype = false) { $io = CBXVirtualIo::GetInstance(); $arFile = array(); if (intval($path) > 0) { $res = CFile::GetByID($path); if ($ar = $res->Fetch()) { $bExternalStorage = false; foreach (GetModuleEvents("main", "OnMakeFileArray", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ar, &$arFile))) { $bExternalStorage = true; break; } } if (!$bExternalStorage) { $arFile["name"] = strlen($ar['ORIGINAL_NAME']) > 0 ? $ar['ORIGINAL_NAME'] : $ar['FILE_NAME']; $arFile["size"] = $ar['FILE_SIZE']; $arFile["type"] = $ar['CONTENT_TYPE']; $arFile["description"] = $ar['DESCRIPTION']; $arFile["tmp_name"] = $io->GetPhysicalName(preg_replace("#[\\\\\\/]+#", "/", $_SERVER['DOCUMENT_ROOT'] . '/' . COption::GetOptionString('main', 'upload_dir', 'upload') . '/' . $ar['SUBDIR'] . '/' . $ar['FILE_NAME'])); } return $arFile; } } $path = preg_replace("#(?<!:)[\\\\\\/]+#", "/", $path); if (strlen($path) == 0 || $path == "/") { return NULL; } if (preg_match("#^(http[s]?)://#", $path)) { $temp_path = ''; $bExternalStorage = false; foreach (GetModuleEvents("main", "OnMakeFileArray", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($path, &$temp_path))) { $bExternalStorage = true; break; } } if (!$bExternalStorage) { $temp_path = CFile::GetTempName('', bx_basename($path)); $ob = new CHTTP(); $ob->follow_redirect = true; if ($ob->Download($path, $temp_path)) { $arFile = CFile::MakeFileArray($temp_path); } } elseif ($temp_path) { $arFile = CFile::MakeFileArray($temp_path); } } elseif (preg_match("#^(ftp[s]?|php)://#", $path)) { if ($fp = fopen($path, "rb")) { $content = ""; while (!feof($fp)) { $content .= fgets($fp, 4096); } if (strlen($content) > 0) { $temp_path = CFile::GetTempName('', bx_basename($path)); if (RewriteFile($temp_path, $content)) { $arFile = CFile::MakeFileArray($temp_path); } } fclose($fp); } } else { if (!file_exists($path)) { if (file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) { $path = $_SERVER["DOCUMENT_ROOT"] . $path; } else { return NULL; } } if (is_dir($path)) { return NULL; } $arFile["name"] = $io->GetLogicalName(bx_basename($path)); $arFile["size"] = filesize($path); $arFile["tmp_name"] = $path; $arFile["type"] = $mimetype; if (strlen($arFile["type"]) <= 0) { $arFile["type"] = CFile::GetContentType($path, true); } } if (strlen($arFile["type"]) <= 0) { $arFile["type"] = "unknown"; } return $arFile; }
function CheckFields(&$arFields, $ID = false) { /** * @global CMain $APPLICATION */ global $APPLICATION; $arMsg = array(); if (!is_set($arFields, "TASK_ID")) { $arMsg[] = array("text" => GetMessage("TASKS_BAD_TASK_ID"), "id" => "ERROR_TASKS_BAD_TASK_ID"); } else { /** @noinspection PhpDeprecationInspection */ $r = CTasks::GetByID($arFields["TASK_ID"], false); if (!$r->Fetch()) { $arMsg[] = array("text" => GetMessage("TASKS_BAD_TASK_ID_EX"), "id" => "ERROR_TASKS_BAD_TASK_ID_EX"); } } if (!is_set($arFields, "FILE_ID")) { $arMsg[] = array("text" => GetMessage("TASKS_BAD_FILE_ID"), "id" => "ERROR_TASKS_BAD_FILE_ID"); } else { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $r = CFile::GetByID($arFields["FILE_ID"]); if (!$r->Fetch()) { $arMsg[] = array("text" => GetMessage("TASKS_BAD_FILE_ID_EX"), "id" => "ERROR_TASKS_BAD_FILE_ID_EX"); } } if (!empty($arMsg)) { $e = new CAdminException($arMsg); $APPLICATION->ThrowException($e); return false; } return true; }
CFile::Delete($file_id); } foreach ($_SESSION[$varKey] as $key => $session_file_id) { if ($session_file_id == $file_id) { unset($_SESSION[$varKey][$key]); break; } } echo CUtil::PhpToJsObject(array('SUCCESS' => 'Y', "FILE_ID" => $file_id)); } } if (isset($_REQUEST["post_id"]) && intval($_REQUEST["post_id"]) > 0) { // Blog Images $varKey = "MFU_UPLOADED_IMAGES_" . $GLOBALS["USER"]->GetId() . "_" . intval($_REQUEST["post_id"]); if (in_array($file_id, $_SESSION[$varKey])) { $rsFile = CFile::GetByID($file_id); if ($arFile = $rsFile->Fetch()) { $bFileFound = true; if (CModule::IncludeModule('blog')) { $rsBlogImage = CBlogImage::GetList(array(), array("FILE_ID" => $file_id)); if ($arBlogImage = $rsBlogImage->Fetch()) { CBlogImage::Delete($arBlogImage["ID"]); BXClearCache(true, "/blog/socnet_post/" . intval($_REQUEST["post_id"]) . "/"); BXClearCache(true, "/blog/socnet_post/gen/" . intval($_REQUEST["post_id"]) . "/"); } } CFile::Delete($file_id); foreach ($_SESSION[$varKey] as $key => $session_file_id) { if ($session_file_id == $file_id) { unset($_SESSION[$varKey][$key]); break;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $APPLICATION->IncludeComponent("bitrix:catalog.section.list", "", array("IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arParams["IBLOCK_ID"], "DISPLAY_PANEL" => $arParams["DISPLAY_PANEL"], "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], "SECTION_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["section"]), $component); if (CModule::IncludeModule("iblock") && ($arIBlock = GetIBlock($arParams['IBLOCK_ID'], $arParams['~IBLOCK_TYPE']))) { ?> <div class="sect_text sect_catalog clearfix"> <?php //trace($arIBlock); ?> <?php if ($arIBlock['PICTURE']) { ?> <?php $rsFile = CFile::GetByID($arIBlock['PICTURE']); $arFile = $rsFile->Fetch(); //trace($arFile); ?> <img class="iblock-pic" src="/upload/<?php echo $arFile['SUBDIR']; ?> /<?php echo $arFile['FILE_NAME']; ?> " alt="<?php echo $arIBlock['NAME']; ?> " /> <?php }
/** * <p>Создает почтовое событие для отсылки данных <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#result">результата</a> по e-mail. Возвращает "true" в случае успеха, в противном случае - "false".</p> * * * * * @param int $result_id ID <a href="http://dev.1c-bitrix.ru/api_help/form/terms.php#result">результата</a>. * * * * @param mixed $template_id = false ID почтового шаблона.<br><br> Параметр необязательный. По умолчанию - * "false" (будут использованы почтовые шаблоны из настроек * соответствующей веб-формы). * * * * @return bool * * * <h4>Example</h4> * <pre> * <? * $RESULT_ID = 189; // ID результата * * // создадим почтовое событие для отсылки по EMail данных результата * if (<b>CFormResult::Mail</b>($RESULT_ID)) * { * echo "Почтовое событие успешно создано."; * } * else // ошибка * { * global $strError; * echo $strError; * } * ?> * </pre> * * * @static * @link http://dev.1c-bitrix.ru/api_help/form/classes/cformresult/mail.php * @author Bitrix */ public static function Mail($RESULT_ID, $TEMPLATE_ID = false) { global $APPLICATION, $DB, $MESS, $strError; $err_mess = (CAllFormResult::err_mess())."<br>Function: Mail<br>Line: "; $RESULT_ID = intval($RESULT_ID); CTimeZone::Disable(); $arrResult = CFormResult::GetDataByID($RESULT_ID, array(), $arrRES, $arrANSWER); CTimeZone::Enable(); if ($arrResult) { $z = CForm::GetByID($arrRES["FORM_ID"]); if ($arrFORM = $z->Fetch()) { $TEMPLATE_ID = intval($TEMPLATE_ID); $arrFormSites = CForm::GetSiteArray($arrRES["FORM_ID"]); $arrFormSites = (is_array($arrFormSites)) ? $arrFormSites : array(); if (!defined('SITE_ID') || !in_array(SITE_ID, $arrFormSites)) return true; $rs = CSite::GetList(($by="sort"), ($order="asc"), array('ID' => implode('|', $arrFormSites))); $arrSites = array(); while ($ar = $rs->Fetch()) { if ($ar["DEF"]=="Y") $def_site_id = $ar["ID"]; $arrSites[$ar["ID"]] = $ar; } $arrFormTemplates = CForm::GetMailTemplateArray($arrRES["FORM_ID"]); $arrFormTemplates = (is_array($arrFormTemplates)) ? $arrFormTemplates : array(); $arrTemplates = array(); $rs = CEventMessage::GetList($by="id", $order="asc", array( "ACTIVE" => "Y", "SITE_ID" => SITE_ID, "EVENT_NAME" => $arrFORM["MAIL_EVENT_TYPE"] )); while ($ar = $rs->Fetch()) { if ($TEMPLATE_ID>0) { if ($TEMPLATE_ID == $ar["ID"]) { $arrTemplates[$ar["ID"]] = $ar; break; } } elseif (in_array($ar["ID"],$arrFormTemplates)) $arrTemplates[$ar["ID"]] = $ar; } foreach($arrTemplates as $arrTemplate) { $OLD_MESS = $MESS; $MESS = array(); IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/form/admin/form_mail.php", $arrSites[$arrTemplate["SITE_ID"]]["LANGUAGE_ID"]); $USER_AUTH = " "; if (intval($arrRES["USER_ID"])>0) { $w = CUser::GetByID($arrRES["USER_ID"]); $arrUSER = $w->Fetch(); $USER_ID = $arrUSER["ID"]; $USER_EMAIL = $arrUSER["EMAIL"]; $USER_NAME = $arrUSER["NAME"]." ".$arrUSER["LAST_NAME"]; if ($arrRES["USER_AUTH"]!="Y") $USER_AUTH="(".GetMessage("FORM_NOT_AUTHORIZED").")"; } else { $USER_ID = GetMessage("FORM_NOT_REGISTERED"); $USER_NAME = ""; $USER_AUTH = ""; $USER_EMAIL = ""; } $arEventFields = array( "RS_FORM_ID" => $arrFORM["ID"], "RS_FORM_NAME" => $arrFORM["NAME"], "RS_FORM_VARNAME" => $arrFORM["SID"], "RS_FORM_SID" => $arrFORM["SID"], "RS_RESULT_ID" => $arrRES["ID"], "RS_DATE_CREATE" => $arrRES["DATE_CREATE"], "RS_USER_ID" => $USER_ID, "RS_USER_EMAIL" => $USER_EMAIL, "RS_USER_NAME" => $USER_NAME, "RS_USER_AUTH" => $USER_AUTH, "RS_STAT_GUEST_ID" => $arrRES["STAT_GUEST_ID"], "RS_STAT_SESSION_ID" => $arrRES["STAT_SESSION_ID"] ); $w = CFormField::GetList($arrFORM["ID"], "ALL", $by, $order, array(), $is_filtered); while ($wr=$w->Fetch()) { $answer = ""; $answer_raw = ''; if (is_array($arrResult[$wr["SID"]])) { //echo '<pre>'; print_r($wr); echo '</pre>'; //echo '<pre>'; print_r($arrResult[$wr['SID']]); $bHasDiffTypes = false; $lastType = ''; foreach ($arrResult[$wr['SID']] as $arrA) { if ($lastType == '') $lastType = $arrA['FIELD_TYPE']; elseif ($arrA['FIELD_TYPE'] != $lastType) { $bHasDiffTypes = true; break; } } foreach($arrResult[$wr["SID"]] as $arrA) { if ($wr['ADDITIONAL'] == 'Y') $arrA['FIELD_TYPE'] = $wr['FIELD_TYPE']; $USER_TEXT_EXIST = (strlen(trim($arrA["USER_TEXT"]))>0); $ANSWER_TEXT_EXIST = (strlen(trim($arrA["ANSWER_TEXT"]))>0); $ANSWER_VALUE_EXIST = (strlen(trim($arrA["ANSWER_VALUE"]))>0); $USER_FILE_EXIST = (intval($arrA["USER_FILE_ID"])>0); //echo 'USER_TEXT_EXIST '.$USER_TEXT_EXIST.' '.$USER_TEXT.'<br />'; //echo 'ANSWER_TEXT_EXIST '.$ANSWER_TEXT_EXIST.' '.$ANSWER_TEXT.'<br />'; //echo 'ANSWER_VALUE_EXIST '.$ANSWER_VALUE_EXIST.' '.$ANSWER_VALUE.'<br />'; //echo 'USER_FILE_EXIST '.$USER_FILE_EXIST.' '.$USER_FILE.'<br />'; if ($arrTemplate["BODY_TYPE"]=="html") { if ( $bHasDiffTypes && !$USER_TEXT_EXIST && ( $arrA['FIELD_TYPE'] == 'text' || $arrA['FIELD_TYPE'] == 'textarea' ) ) continue; if (strlen(trim($answer))>0) $answer .= "<br />"; if (strlen(trim($answer_raw))>0) $answer_raw .= ","; if ($ANSWER_TEXT_EXIST) $answer .= $arrA["ANSWER_TEXT"].': '; switch ($arrA['FIELD_TYPE']) { case 'text': case 'textarea': case 'hidden': case 'date': case 'password': case 'integer': if ($USER_TEXT_EXIST) { $answer .= trim($arrA["USER_TEXT"]); $answer_raw .= trim($arrA["USER_TEXT"]); } break; case 'email': case 'url': if ($USER_TEXT_EXIST) { $answer .= '<a href="'.($arrA['FIELD_TYPE'] == 'email' ? 'mailto:' : '').trim($arrA["USER_TEXT"]).'">'.trim($arrA["USER_TEXT"]).'</a>'; $answer_raw .= trim($arrA["USER_TEXT"]); } break; case 'checkbox': case 'multiselect': case 'radio': case 'dropdown': if ($ANSWER_TEXT_EXIST) { $answer = substr($answer, 0, -2).' '; $answer_raw .= $arrA['ANSWER_TEXT']; } if ($ANSWER_VALUE_EXIST) { $answer .= '('.$arrA['ANSWER_VALUE'].') '; if (!$ANSWER_TEXT_EXIST) $answer_raw .= $arrA['ANSWER_VALUE']; } if (!$ANSWER_VALUE_EXIST && !$ANSWER_TEXT_EXIST) $answer_raw .= $arrA['ANSWER_ID']; $answer .= '['.$arrA['ANSWER_ID'].']'; break; case 'file': case 'image': if ($USER_FILE_EXIST) { $f = CFile::GetByID($arrA["USER_FILE_ID"]); if ($fr = $f->Fetch()) { $file_size = CFile::FormatSize($fr["FILE_SIZE"]); $url = ($APPLICATION->IsHTTPS() ? "https://" : "http://").$_SERVER["HTTP_HOST"]. "/bitrix/tools/form_show_file.php?rid=".$RESULT_ID. "&hash=".$arrA["USER_FILE_HASH"]."&lang=".LANGUAGE_ID; if ($arrA["USER_FILE_IS_IMAGE"]=="Y") { $answer .= "<a href=\"$url\">".$arrA["USER_FILE_NAME"]."</a> [".$fr["WIDTH"]." x ".$fr["HEIGHT"]."] (".$file_size.")"; } else { $answer .= "<a href=\"$url&action=download\">".$arrA["USER_FILE_NAME"]."</a> (".$file_size.")"; } $answer_raw .= $arrA['USER_FILE_NAME']; } } break; } } else { //echo $bHasDiffTypes.'*'.$USER_TEXT_EXIST.'<br />'; if ( $bHasDiffTypes && !$USER_TEXT_EXIST && ( $arrA['FIELD_TYPE'] == 'text' || $arrA['FIELD_TYPE'] == 'textarea' ) ) continue; if (strlen(trim($answer)) > 0) $answer .= "\n"; if (strlen(trim($answer_raw)) > 0) $answer_raw .= ","; if ($ANSWER_TEXT_EXIST) $answer .= $arrA["ANSWER_TEXT"].': '; switch ($arrA['FIELD_TYPE']) { case 'text': case 'textarea': case 'email': case 'url': case 'hidden': case 'date': case 'password': case 'integer': if ($USER_TEXT_EXIST) { $answer .= trim($arrA["USER_TEXT"]); $answer_raw .= trim($arrA["USER_TEXT"]); } break; case 'checkbox': case 'multiselect': case 'radio': case 'dropdown': if ($ANSWER_TEXT_EXIST) { $answer = substr($answer, 0, -2).' '; $answer_raw .= $arrA['ANSWER_TEXT']; } if ($ANSWER_VALUE_EXIST) { $answer .= '('.$arrA['ANSWER_VALUE'].') '; if (!$ANSWER_TEXT_EXIST) { $answer_raw .= $arrA['ANSWER_VALUE']; } } if (!$ANSWER_VALUE_EXIST && !$ANSWER_TEXT_EXIST) { $answer_raw .= $arrA['ANSWER_ID']; } $answer .= '['.$arrA['ANSWER_ID'].']'; break; case 'file': case 'image': if ($USER_FILE_EXIST) { $f = CFile::GetByID($arrA["USER_FILE_ID"]); if ($fr = $f->Fetch()) { $file_size = CFile::FormatSize($fr["FILE_SIZE"]); $url = ($APPLICATION->IsHTTPS() ? "https://" : "http://").$_SERVER["HTTP_HOST"]. "/bitrix/tools/form_show_file.php?rid=".$RESULT_ID. "&hash=".$arrA["USER_FILE_HASH"]."&action=download&lang=".LANGUAGE_ID; if ($arrA["USER_FILE_IS_IMAGE"]=="Y") { $answer .= $arrA["USER_FILE_NAME"]." [".$fr["WIDTH"]." x ".$fr["HEIGHT"]."] (".$file_size.")\n".$url; } else { $answer .= $arrA["USER_FILE_NAME"]." (".$file_size.")\n".$url."&action=download"; } } $answer_raw .= $arrA['USER_FILE_NAME']; } break; } } } } $arEventFields[$wr["SID"]] = (strlen($answer)<=0) ? " " : $answer; $arEventFields[$wr["SID"].'_RAW'] = (strlen($answer_raw)<=0) ? " " : $answer_raw; } CEvent::Send($arrTemplate["EVENT_NAME"], $arrTemplate["SITE_ID"], $arEventFields, "Y", $arrTemplate["ID"]); $MESS = $OLD_MESS; } //foreach($arrTemplates as $arrTemplate) return true; } else $strError .= GetMessage("FORM_ERROR_FORM_NOT_FOUND")."<br>"; } else $strError .= GetMessage("FORM_ERROR_RESULT_NOT_FOUND")."<br>"; return false; }
protected static function PreparePrintableValue($arDocumentID, $fieldName, $arFieldType, $fieldValue) { global $USER_FIELD_MANAGER, $APPLICATION; if (empty($arDocumentID)) { throw new CBPArgumentNullException('documentId'); } $result = $fieldValue; switch ($arFieldType['Type']) { case 'date': case 'datetime': if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $_fieldValue) { $result[] = empty($_fieldValue) ? FormatDate('x', MakeTimeStamp($_fieldValue)) : ''; } } else { $result = !empty($fieldValue) ? FormatDate('x', MakeTimeStamp($fieldValue)) : ''; } break; case 'user': if (!is_array($fieldValue)) { $fieldValue = array($fieldValue); } $result = CBPHelper::UsersArrayToString($fieldValue, null, $arDocumentID["DOCUMENT_TYPE"]); break; case 'bool': if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { $result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage('BPVDX_YES') : GetMessage('BPVDX_NO'); } } else { $result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage('BPVDX_YES') : GetMessage('BPVDX_NO'); } break; case 'file': if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { $r = intval($r); $dbImg = CFile::GetByID($r); if ($arImg = $dbImg->Fetch()) { $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $r . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]"; } } } else { $fieldValue = intval($fieldValue); $dbImg = CFile::GetByID($fieldValue); if ($arImg = $dbImg->Fetch()) { $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]"; } } break; case 'select': if (is_array($arFieldType["Options"])) { if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { if (array_key_exists($r, $arFieldType["Options"])) { $result[] = $arFieldType["Options"][$r]; } } } else { if (array_key_exists($fieldValue, $arFieldType["Options"])) { $result = $arFieldType["Options"][$fieldValue]; } } } break; case 'web': case 'im': case 'email': case 'phone': $result = array(); if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) { $fieldValue = $fieldValue[0]; } if (is_array($fieldValue) && is_array($fieldValue[strtoupper($arFieldType['Type'])])) { foreach ($fieldValue[strtoupper($arFieldType['Type'])] as $val) { if (!empty($val)) { $result[] = CCrmFieldMulti::GetEntityNameByComplex(strtoupper($arFieldType['Type']) . '_' . $val['VALUE_TYPE'], false) . ': ' . $val['VALUE']; } } } break; } if (strpos($arFieldType['Type'], 'UF:') === 0) { $sType = str_replace('UF:', '', $arFieldType['Type']); if ($sType === 'crm') { $options = isset($arFieldType['Options']) && is_array($arFieldType['Options']) ? $arFieldType['Options'] : array(); $defaultTypeName = ''; foreach ($options as $typeName => $flag) { if ($flag === 'Y') { $defaultTypeName = $typeName; break; } } if ($defaultTypeName === '') { $defaultTypeName = 'LEAD'; } if (isset($arFieldType['Multiple']) && $arFieldType['Multiple'] > 0 && is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $value) { $result[] = self::PrepareCrmUserTypeValueView($value, $defaultTypeName); } } else { $result = self::PrepareCrmUserTypeValueView($fieldValue, $defaultTypeName); } } else { $arUserFieldType = $USER_FIELD_MANAGER->GetUserType($sType); $arUserField = array('ENTITY_ID' => 'CRM_LEAD', 'FIELD_NAME' => 'UF_XXXXXXX', 'USER_TYPE_ID' => $sType, 'SORT' => 100, 'MULTIPLE' => $arFieldType['Multiple'] ? 'Y' : 'N', 'MANDATORY' => $arFieldType['Required'] ? 'Y' : 'N', 'EDIT_FORM_LABEL' => $arUserFieldType['DESCRIPTION'], 'VALUE' => $fieldValue, 'USER_TYPE' => $arUserFieldType); if ($arFieldType['Type'] == 'UF:iblock_element' || $arFieldType['Type'] == 'UF:iblock_section') { $arUserField['SETTINGS']['IBLOCK_ID'] = $arFieldType['Options']; } elseif ($arFieldType['Type'] == 'UF:crm_status') { $arUserField['SETTINGS']['ENTITY_TYPE'] = $arFieldType['Options']; } ob_start(); $APPLICATION->IncludeComponent('bitrix:system.field.view', $sType, array('arUserField' => $arUserField, 'bVarsFromForm' => false, 'form_name' => "", 'FILE_MAX_HEIGHT' => 400, 'FILE_MAX_WIDTH' => 400, 'FILE_SHOW_POPUP' => true), false, array('HIDE_ICONS' => 'Y')); $result = ob_get_contents(); $result = HTMLToTxt($result); ob_end_clean(); } } return $result; }
} } if ($bNoActiveGroup) { continue; } $strTmpOff .= "<offer id=\"" . $arAcc["ID"] . "\">\n"; $strTmpOff .= "<url>http://" . COption::GetOptionString("main", "server_name", "") . $arAcc["DETAIL_PAGE_URL"] . "&r1=<?echo \$_GET[\"referer1\"] ?>&r2=<?echo \$_GET[\"referer2\"] ?></url>\n"; $strTmpOff .= "<price>" . $minPrice . "</price>\n"; $strTmpOff .= "<currencyId>" . $minPriceCurrency . "</currencyId>\n"; $strTmpOff .= $strTmpOff_tmp; if (IntVal($arAcc["DETAIL_PICTURE"]) > 0 || IntVal($arAcc["PREVIEW_PICTURE"]) > 0) { $pictNo = IntVal($arAcc["DETAIL_PICTURE"]); if ($pictNo <= 0) { $pictNo = IntVal($arAcc["PREVIEW_PICTURE"]); } $db_file = CFile::GetByID($pictNo); if ($ar_file = $db_file->Fetch()) { $strFile = "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/" . $ar_file["SUBDIR"] . "/" . $ar_file["FILE_NAME"]; $strFile = str_replace("//", "/", $strFile); $strTmpOff .= "<picture>http://" . COption::GetOptionString("main", "server_name", "") . $strFile . "</picture>\n"; } } $strTmpOff .= "<name>" . yandex_text2xml($arAcc["NAME"], true) . "</name>\n"; $strTmpOff .= "<description>" . yandex_text2xml(TruncateText($arAcc["PREVIEW_TEXT_TYPE"] == "html" ? strip_tags(preg_replace_callback("'&[^;]*;'", "replace_special", $arAcc["~PREVIEW_TEXT"])) : $arAcc["PREVIEW_TEXT"], 255), true) . "</description>\n"; $strTmpOff .= "</offer>\n"; } @fwrite($fp, "<categories>\n"); @fwrite($fp, $strTmpCat); @fwrite($fp, "</categories>\n"); @fwrite($fp, "<offers>\n"); @fwrite($fp, $strTmpOff);
function GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue) { $result = $fieldValue; switch ($arFieldType['Type']) { case "user": if (!is_array($fieldValue)) { $fieldValue = array($fieldValue); } $result = CBPHelper::UsersArrayToString($fieldValue, null, array("iblock", "CIBlockDocument", $documentType)); break; case "bool": if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { $result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"); } } else { $result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"); } break; case "file": if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { $r = intval($r); $dbImg = CFile::GetByID($r); if ($arImg = $dbImg->Fetch()) { $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $r . "&h=" . md5($arImg["SUBDIR"]) . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]"; } } } else { $fieldValue = intval($fieldValue); $dbImg = CFile::GetByID($fieldValue); if ($arImg = $dbImg->Fetch()) { $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "&h=" . md5($arImg["SUBDIR"]) . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]"; } } break; case "select": if (is_array($arFieldType["Options"])) { if (is_array($fieldValue)) { $result = array(); foreach ($fieldValue as $r) { if (array_key_exists($r, $arFieldType["Options"])) { $result[] = $arFieldType["Options"][$r]; } } } else { if (array_key_exists($fieldValue, $arFieldType["Options"])) { $result = $arFieldType["Options"][$fieldValue]; } } } break; } if (strpos($arFieldType['Type'], ":") !== false) { if ($arFieldType["Type"] == "S:employee") { $fieldValue = CBPHelper::StripUserPrefix($fieldValue); } $arCustomType = CIBlockProperty::GetUserType(substr($arFieldType['Type'], 2)); if (array_key_exists("GetPublicViewHTML", $arCustomType)) { if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) { $result = array(); foreach ($fieldValue as $value) { $r = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $value), "")); $result[] = HTMLToTxt($r); } } else { $result = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $fieldValue), "")); $result = HTMLToTxt($result); } } } return $result; }
for ($inds = 0, $intSectCount = count($arResSections); $inds < $intSectCount; $inds++) { $arResFields = array(); for ($i = 0, $intNFCount = count($arNeedFields); $i < $intNFCount; $i++) { $bFieldOut = False; if (is_set($arAvailProdFields_names, $arNeedFields[$i])) { $bFieldOut = True; $arResFields[$i] = $res1[$arAvailProdFields_names[$arNeedFields[$i]]["field"]]; if ($arNeedFields[$i]=="IE_PREVIEW_PICTURE" || $arNeedFields[$i]=="IE_DETAIL_PICTURE") { if (intval($arResFields[$i])>0) { $db_z = CFile::GetByID(intval($arResFields[$i])); if ($z = $db_z->Fetch()) { $arResFields[$i] = $z["FILE_NAME"]; } } else { $arResFields[$i] = ""; } } } if ($boolCatalog) { if (!$bFieldOut && is_set($arAvailPriceFields_names, $arNeedFields[$i]))
function ShowFileField($name, $arAttributes = array()) { $wizard = $this->GetWizard(); $strReturn = ""; if (array_key_exists("max_file_size", $arAttributes)) { $strReturn .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . intval($arAttributes["max_file_size"]) . '" />'; unset($arAttributes["max_file_size"]); } $strReturn .= '<input type="file" name="' . htmlspecialcharsbx($wizard->GetRealName($name . "_new")) . '"' . $this->_ShowAttributes($arAttributes) . ' />'; $fileID = intval($wizard->GetVar($name)); if ($fileID > 0) { $obFile = CFile::GetByID($fileID); if ($arFile = $obFile->Fetch()) { $deleteName = $wizard->GetRealName($name . "_del"); $oldName = $wizard->GetRealName($name . "_old"); $show_file_info = isset($arAttributes["show_file_info"]) && $arAttributes["show_file_info"] == "N" ? false : true; if ($show_file_info) { $strReturn .= "<br /> " . GetMessage("MAIN_WIZARD_FILE_NAME") . ": " . htmlspecialcharsEx($arFile["ORIGINAL_NAME"]); if ($arFile["HEIGHT"] > 0 && $arFile["WIDTH"]) { $strReturn .= "<br /> " . GetMessage("MAIN_WIZARD_FILE_WIDTH") . ": " . intval($arFile["WIDTH"]); $strReturn .= "<br /> " . GetMessage("MAIN_WIZARD_FILE_HEIGHT") . ": " . intval($arFile["HEIGHT"]); } $sizes = array("b", "Kb", "Mb", "Gb"); $pos = 0; $size = $arFile["FILE_SIZE"]; while ($size >= 1024) { $size /= 1024; $pos++; } $strReturn .= "<br /> " . GetMessage("MAIN_WIZARD_FILE_SIZE") . ": " . round($size, 2) . " " . $sizes[$pos]; } $strReturn .= '<br />'; $strReturn .= '<input type="checkbox" name="' . $deleteName . '" value="Y" id="' . $deleteName . '" />'; $strReturn .= '<label for="' . $deleteName . '">' . GetMessage("MAIN_WIZARD_FILE_DELETE") . '</label>'; } } return $strReturn; }
$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 $intFileID = $arrAdvert['PARENTS'][$intParentId][$arrFieldProp[$strNameField]]; $rsFile = CFile::GetByID($intFileID[0]); if ($arFile = $rsFile->Fetch()) $arrResult['original_name'] = $arFile['ORIGINAL_NAME']; }//\\ if }//\\if }//\\ if }//\\ if CIBlockElement::SetPropertyValueCode($intAdvertID, 'MODERATION', array('VALUE' => 984)); }//\\ if //$arrResult['percent'] = rand(0, 100); }//\\ if $arrResult['advert_id'] = $intAdvertID; // Проверим валидацию
$arResult['PREVIEW'] = 'Y'; $arResult['ELEMENT_PREVIEW'] = array(); $arCat = array(); $arResult['ELEMENT_PREVIEW']['DETAIL_TEXT'] = $CWikiParser->parseBeforeSave($arResult['ELEMENT']['~DETAIL_TEXT'], $arCat); $arResult['ELEMENT_PREVIEW']['DETAIL_TEXT'] = $CWikiParser->Parse($arResult['ELEMENT_PREVIEW']['DETAIL_TEXT'], $arResult['ELEMENT']['DETAIL_TEXT_TYPE'], $arResult['ELEMENT']['IMAGES']); $arResult['ELEMENT_PREVIEW']['DETAIL_TEXT'] = $CWikiParser->Clear($arResult['ELEMENT_PREVIEW']['DETAIL_TEXT']); $arResult['ELEMENT']['TAGS'] = htmlspecialcharsbx($_POST['TAGS']); $arResult['ELEMENT']['~TAGS'] = htmlspecialcharsbx($_POST['TAGS']); } } } // obtain a list of pictures page $arResult['IMAGES'] = array(); if (!empty($arResult['ELEMENT']['IMAGES'])) { foreach ($arResult['ELEMENT']['IMAGES'] as $_imgID) { $rsFile = CFile::GetByID($_imgID); $arFile = $rsFile->Fetch(); $aImg = array(); $aImg['ID'] = $_imgID; $aImg['ORIGINAL_NAME'] = $arFile['ORIGINAL_NAME']; $aImg['FILE_SHOW'] = CFile::ShowImage($_imgID, 100, 100, "id=\"{$_imgID}\" border=\"0\" style=\"cursor:pointer;\" onclick=\"doInsert('[File:" . CUtil::JSEscape(htmlspecialcharsbx($arFile['ORIGINAL_NAME'])) . "]','',false, '{$_imgID}')\" title='" . GetMessage('WIKI_IMAGE_INSERT') . "'"); $arResult['IMAGES'][] = $aImg; } } include_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/components/bitrix/wiki/include/nav.php'; $arResult['PATH_TO_POST_EDIT'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_POST_EDIT'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), $arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N' ? array($arParams['OPER_VAR'] => $arResult['WIKI_oper']) : array()); $arResult['~PATH_TO_POST_EDIT'] = urldecode($arResult['PATH_TO_POST_EDIT']); //because it can change the page name, and hence the path for the parameter "Action" in tag "Form" if (strpos(POST_FORM_ACTION_URI, 'SEF_APPLICATION_CUR_PAGE_URL=') !== false) { $arResult['PATH_TO_POST_EDIT_SUBMIT'] = CHTTP::urlAddParams(CHTTP::urlDeleteParams(POST_FORM_ACTION_URI, array('SEF_APPLICATION_CUR_PAGE_URL')), array('SEF_APPLICATION_CUR_PAGE_URL' => urlencode($arResult['~PATH_TO_POST_EDIT']))); } else {
if (!empty($arParams["UNIQUE_SALT"])) { $hash = md5("ucresizeimg" . $arParams["UNIQUE_SALT"]); } else { $hash = md5("ucresizeimg" // salt .$arParams["INPUT_FILE_PATH"].$arParams["INPUT_IMAGE_ID"] .$arParams["WIDTH"].$arParams["HEIGHT"] .$arParams["RESIZE_TYPE"].$arParams["CROP_POS_X"].$arParams["CROP_POS_Y"] .$arParams["KEEP_SIZE"].$arParams["FILL_COLOR"].$arParams["JPEG_OUTPUT"] .$arParams["JPEG_QUALITY"].$arParams["PNG_QUALITY"] ); } $arResult["SOURCE_IMAGE"] = array(); if (!empty($arParams["INPUT_IMAGE_ID"])) { $rsFile = CFile::GetByID($arParams["INPUT_IMAGE_ID"]); $arFile = $rsFile->GetNext(); $arResult["SOURCE_IMAGE"]["SRC"] = CFile::GetPath($arParams["INPUT_IMAGE_ID"]); $arResult["SOURCE_IMAGE"]["WIDTH"] = $arFile["WIDTH"]; $arResult["SOURCE_IMAGE"]["HEIGHT"] = $arFile["HEIGHT"]; $arResult["DESCRIPTION"] = str_replace( "#IMAGE_ID_DESCRIPTION#", $arFile["DESCRIPTION"], $arParams["DESCRIPTION"]); } else { if (empty($arParams["INPUT_FILE_PATH"])) { $arResult["ERROR"] = GetMessage("E_EMPTY_INPUT_FILE"); return $abort($this); } else { $arResult["SOURCE_IMAGE"]["SRC"] = $arParams["INPUT_FILE_PATH"]; if (!$inputFileSize = GetImageSize($absPath($arResult["SOURCE_IMAGE"]["SRC"]))) { $arResult["ERROR"] = GetMessage("E_GET_IMG_FILE_SIZE"); return $abort($this);