1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
fileinputunclouder.php
См. документацию.
1<?php
2namespace Bitrix\Main\UI;
3
4use Bitrix\Main\Security\Sign\Signer;
5
7{
8 protected $id;
9 protected $signature;
10 protected $file;
11 protected static $salt = "fileinput";
12
13 public static function getSrc($file = array())
14 {
15 $src = $file['SRC'];
16 if ($file['HANDLER_ID'] > 0)
17 {
18 $src = "/".\COption::GetOptionString("main", "upload_dir", "upload")."/".$file["SUBDIR"]."/".$file["FILE_NAME"];
19 $path = $_SERVER["DOCUMENT_ROOT"].$src;
20 if (!(is_file($path) && file_exists($path)))
21 {
22 $sign = new Signer();
23 $s = $sign->sign($file["ID"], self::$salt);
24 $src = \COption::GetOptionString("main.fileinput", "entryPointUrl", "/bitrix/tools/upload.php")."?".
25 http_build_query(array(
26 "action" => "uncloud",
27 "file" => $file["ID"],
28 "signature" => $s
29 ));
30 }
31 }
32 else
33 {
35 }
36 return $src;
37 }
38
39 public static function getSrcWithResize($file = array(), $size = array())
40 {
41 $file1 = \CFile::ResizeImageGet($file["ID"], $size, BX_RESIZE_IMAGE_PROPORTIONAL, false);
42 $src = $file1['src'];
43 if ($file['HANDLER_ID'] > 0)
44 {
45 $src = "/".\COption::GetOptionString("main", "upload_dir", "upload")."/".$file["SUBDIR"]."/".$file["FILE_NAME"];
46 $path = $_SERVER["DOCUMENT_ROOT"].$src;
47 if (!(is_file($path) && file_exists($path)))
48 {
49 $sign = new Signer();
50 $s = $sign->sign($file["ID"] . "x" . $size["width"]. "x" . $size["height"], self::$salt);
51 $src = \COption::GetOptionString("main.fileinput", "entryPointUrl", "/bitrix/tools/upload.php")."?".
52 http_build_query(array(
53 "action" => "uncloud",
54 "mode" => "resize",
55 "file" => $file["ID"],
56 "width" => $size["width"],
57 "height" => $size["height"],
58 "signature" => $s
59 ));
60 }
61 }
62 else
63 {
65 }
66 return $src;
67 }
68
69
70 public function setValue($id)
71 {
72 $this->id = (int) $id;
73 return $this;
74 }
75
76 public function setSignature($signature)
77 {
78 $this->signature = $signature;
79 return $this;
80 }
81
82 protected function check($params = array())
83 {
84 $sign = new Signer;
85
86 $str = (string) $sign->unsign($this->signature, self::$salt);
87 $str2 = (string) $this->id;
88
89 if (is_array($params) && array_key_exists("width", $params) && $params["width"] > 0 && array_key_exists("height", $params) && $params["height"] > 0)
90 {
91 $str2 = $this->id . "x" . $params["width"] . "x" . $params["height"];
92 }
93 return ($str == $str2);
94 }
95
96 public function exec($mode = "basic", $params = array())
97 {
98 $res = $this->check($params);
99 if ($this->check($params))
100 {
101 $this->file = \CFile::getFileArray($this->id);
102 if ($mode == "resize")
103 {
104 $file = \CFile::ResizeImageGet($this->file, $params, BX_RESIZE_IMAGE_PROPORTIONAL, true, false, true);
105 if ($file)
106 {
107 $this->file["SRC"] = $file["src"];
108 $this->file["WIDTH"] = $file["width"];
109 $this->file["HEIGHT"] = $file["height"];
110 $this->file["FILE_SIZE"] = $file["size"];
111 }
112 }
113 \CFile::ViewByUser($this->file, array("force_download" => false, "cache_time" => 0));
114 }
115 }
116}
$path
Определения access_edit.php:21
static convertLogicalToUri($path)
Определения path.php:164
exec($mode="basic", $params=array())
Определения fileinputunclouder.php:96
static getSrcWithResize($file=array(), $size=array())
Определения fileinputunclouder.php:39
check($params=array())
Определения fileinputunclouder.php:82
static getSrc($file=array())
Определения fileinputunclouder.php:13
$str
Определения commerceml2.php:63
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
const BX_RESIZE_IMAGE_PROPORTIONAL
Определения constants.php:11
$sign
Определения payment.php:69
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799