2namespace Bitrix\Main\UI\Uploader;
4use Bitrix\Main\AccessDeniedException;
5use Bitrix\Main\ArgumentOutOfRangeException;
6use Bitrix\Main\HttpRequest;
7use Bitrix\Main\NotImplementedException;
8use Bitrix\Main\UI\FileInputUtility;
9use Bitrix\Main\Web\Json;
10use Bitrix\Main\Context;
11use Bitrix\Main\Loader;
12use Bitrix\Main\Localization\Loc;
15Loc::loadMessages(__FILE__);
19 "bitrix\\main\\ui\\uploader\\storage" =>
"lib/ui/uploader/storage.php",
20 "bitrix\\main\\ui\\uploader\\cloudstorage" =>
"lib/ui/uploader/storage.php"
23class Log implements \ArrayAccess
42 if ($this->file->IsExists())
44 $data = unserialize($this->file->GetContents(), [
"allowed_classes" =>
false]);
47 if (array_key_exists(
$key , $this->data) && is_array($this->data[
$key]) && is_array(
$val))
48 $this->data[
$key] = array_merge($this->data[
$key],
$val);
68 if (array_key_exists(
$key, $this->data) && is_array($this->data) && is_array($value))
69 $this->data[
$key] = array_merge($this->data[
$key], $value);
71 $this->data[
$key] = $value;
83 return $this->data[
$key];
93 $this->file->PutContents(serialize($this->data));
117 $this->file->unlink();
119 catch (\Throwable $e)
131 return array_key_exists($offset, $this->data);
138 #[\ReturnTypeWillChange]
141 if (array_key_exists($offset, $this->data))
142 return $this->data[$offset];
152 $this->
setLog($offset, $value);
160 if (array_key_exists($offset, $this->data))
162 unset($this->data[$offset]);
173 "allowUpload" =>
"A",
174 "allowUploadExt" =>
"",
186 "moduleId" =>
"main",
227 $params[
"storage"][
"moduleId"] = preg_replace(
"/[^a-z_-]/i",
"_",
$params[
"storage"][
"moduleId"]);
229 if (array_key_exists(
"controlId",
$params))
230 $this->controlId =
$params[
"controlId"];
231 if (array_key_exists(
"events",
$params) && is_array(
$params[
"events"]))
238 unset($this->params[
"events"]);
240 $this->
path = \CTempFile::GetDirectoryName(
244 $this->params[
"storage"][
"moduleId"],
248 \CMain::GetServerUniqID()
253 $this->request = Context::getCurrent()->getRequest();
275 if (array_key_exists(
"tmp_name", $item))
277 unset($item[
"tmp_name"]);
281 if (
$key ==
"chunksInfo")
286 else if (is_array(
$val))
297 array_walk_recursive(
302 $v = preg_replace(
"/<(.+?)>/isu",
"", $v);
318 if (!in_array($this->mode,
array(
"upload",
"delete",
"view")))
327 $directoryExists = $directory->IsExists();
328 if (!$directory->Create())
330 if (!$directoryExists)
333 $content =
'<?$PERM["'.$directory->GetName().
'"]["*"]="X";?>';
337 if (($fd =
$access->Open(
'ab')))
350 if (!defined(
"PUBLIC_AJAX_MODE"))
351 define(
"PUBLIC_AJAX_MODE",
true);
352 if (!defined(
"NO_KEEP_STATISTIC"))
353 define(
"NO_KEEP_STATISTIC",
"Y");
354 if (!defined(
"NO_AGENT_STATISTIC"))
355 define(
"NO_AGENT_STATISTIC",
"Y");
356 if (!defined(
"NO_AGENT_CHECK"))
357 define(
"NO_AGENT_CHECK",
true);
358 if (!defined(
"DisableEventsCheck"))
359 define(
"DisableEventsCheck",
true);
368 header(
'Content-Type:application/json; charset=UTF-8');
371 \CMain::finalActions();
382 foreach ($this->requestMethods as
$method => $value)
392 if ($this->requestMethods[
"post"] &&
393 is_array($this->request->getPost(self::INFO_NAME)) &&
394 array_key_exists(
$key, $this->request->getPost(self::INFO_NAME)))
396 $res = $this->request->getPost(self::INFO_NAME);
399 if ($this->requestMethods[
"get"] &&
400 is_array($this->request->getQuery(self::INFO_NAME)) &&
401 array_key_exists(
$key, $this->request->getQuery(self::INFO_NAME)))
403 $res = $this->request->getQuery(self::INFO_NAME);
416 return $this->params[
$key];
425 if ($checkPost ===
false && !is_array($this->request->getQuery(self::INFO_NAME)) ||
426 $checkPost !==
false && !is_array($this->request->getPost(self::INFO_NAME)))
429 if ($checkPost ===
false)
437 if ($this->mode ==
"upload")
445 ->setStorage($this->params[
"storage"])
446 ->setCopies($this->params[
"copies"]);
448 $response = $package->checkPost($this->params);
452 $response2 =
array();
456 "hash" => $r[
"hash"],
457 "status" => $r[
"status"],
460 if (isset($r[
"error"]))
461 $response2[
$k][
"error"] = $r[
"error"];
464 "status" => $package->getLog(
"uploadStatus") ==
"uploaded" ?
"done" :
"inprogress",
466 $package->getIndex() => array_merge(
469 "executed" => $package->getLog(
"executeStatus") ==
"executed",
470 "filesCount" => $package->getLog(
"filesCount")
475 "uploading" =>
array(
476 $package->getCid() => $package->getCidLog()
479 "files" => self::prepareData($response2)
484 else if ($this->mode ==
"delete")
499 "error" =>
"Something went wrong with the temporary file."
502 catch (\Exception $e)
506 "error" => $e->getMessage()
521 if (!empty($watermark))
524 $file[
"files"][
"default"],
525 $file[
"files"][
"default"],
530 if (is_array($canvases))
532 foreach ($canvases as $canvas => $canvasParams)
534 if (!array_key_exists($canvas, $file[
"files"]))
536 $source = $file[
"files"][
"default"];
540 "tmp_name" => mb_substr($source[
"tmp_name"], 0, -7).$canvas,
541 "url" => mb_substr($source[
"url"], 0, -7).$canvas
542 ), $canvasParams, $watermark);
561 if (($tempRoot = \CTempFile::GetAbsoluteRoot()) && ($strFilePath = $tempRoot.$tmpName) &&
566 "tmp_name" => $strFilePath
572 "tmp_url" => $tmpName,
573 "tmp_name" => $strFilePath
577 mb_strpos($tmpName,
$docRoot) === 0)
580 "tmp_url" => str_replace(
"//",
"/",
"/".mb_substr($tmpName, mb_strlen(
$docRoot))),
581 "tmp_name" => $tmpName
static registerAutoLoadClasses($moduleName, array $classes)
static viewFile($cid, $hash, $path)
static createCanvas($source, $dest, $canvasParams=array(), $watermarkParams=array())
static getUrlFromRelativePath($tmpName)
static deleteFile($cid, $hash, $path)
offsetSet($offset, $value)
static getPaths($tmpName)
static prepareData($data)
__construct($params=array())
checkCanvases($hash, &$file, $canvases=array(), $watermark=array())
checkPost($checkPost=true)
setHandler($name, $callback)
setRequestMethodToCheck(array $methods)
static removeTmpPath($item)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_array($deviceNotifyCodes)) $access
check_bitrix_sessid($varname='sessid')
AddEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $SORT=100, $FULL_PATH=false)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"