Your IP : 18.116.23.178


Current Path : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/a537b/
Upload File :
Current File : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/a537b/handlers.tar

controller.php000066400000001744147736760240007470 0ustar00<?php
if(!\Bitrix\Main\Loader::includeModule('faceid'))
	return false;

if (is_object($APPLICATION))
	$APPLICATION->RestartBuffer();

\Bitrix\FaceId\Log::write($_POST, 'PORTAL HIT');

$params = $_POST;
$hash = $params["BX_HASH"];
unset($params["BX_HASH"]);

// CLOUD HITS

if(
	$params['BX_TYPE'] == \Bitrix\FaceId\Http::TYPE_BITRIX24 && \Bitrix\FaceId\Http::requestSign($params['BX_TYPE'], md5(implode("|", $params)."|".BX24_HOST_NAME)) === $hash ||
	$params['BX_TYPE'] == \Bitrix\FaceId\Http::TYPE_CP && \Bitrix\FaceId\Http::requestSign($params['BX_TYPE'], md5(implode("|", $params))) === $hash
)
{
	$params = \Bitrix\Main\Text\Encoding::convertEncoding($params, 'UTF-8', SITE_CHARSET);

	$result = \Bitrix\FaceId\Controller::receiveCommand($params['BX_COMMAND'], $params);
	if (is_null($result))
	{
		echo "You don't have access to this page.";
	}
	else
	{
		echo \Bitrix\Main\Web\Json::encode($result);
	}
}
else
{
	echo "You don't have access to this page.";
}

CMain::FinalActions();
die();controller.php.orig000066400000002126147736760240010422 0ustar00<?php
if(!(\Bitrix\Main\Loader::includeModule('im') && \Bitrix\Main\Loader::includeModule('imbot')))
	return false;

if (is_object($APPLICATION))
	$APPLICATION->RestartBuffer();

\Bitrix\ImBot\Log::write($_POST, 'PORTAL HIT');

$params = $_POST;
$hash = $params["BX_HASH"];
unset($params["BX_HASH"]);

// BOT CLOUD HITS
echo implode("|", $params)."|".BX24_HOST_NAME;
if(
	$params['BX_TYPE'] == \Bitrix\ImBot\Http::TYPE_BITRIX24 && \Bitrix\ImBot\Http::requestSign($params['BX_TYPE'], md5(implode("|", $params)."|".BX24_HOST_NAME)) === $hash ||
	$params['BX_TYPE'] == \Bitrix\ImBot\Http::TYPE_CP && \Bitrix\ImBot\Http::requestSign($params['BX_TYPE'], md5(implode("|", $params))) === $hash
)
{
	$params = \Bitrix\Main\Text\Encoding::convertEncodingArray($params, 'UTF-8', SITE_CHARSET);

	$result = \Bitrix\ImBot\Controller::sendAnswer($params['BX_BOT_NAME'], $params['BX_COMMAND'], $params);
	if (is_null($result))
	{
		echo "You don't have access to this page.";
	}
	else
	{
		echo \Bitrix\Main\Web\Json::encode($result);
	}
}
else
{
	echo "You don't have access to this page.";
}

CMain::FinalActions();
die();transformer_result.php000066400000010030147741316740011227 0ustar00<?
use Bitrix\Main\Web\Json;
use Bitrix\Transformer\Command;
use Bitrix\Transformer\FileUploader;
use Bitrix\Transformer\File;

global $APPLICATION;

if(is_object($APPLICATION))
	$APPLICATION->RestartBuffer();

if(!\Bitrix\Main\Loader::includeModule('transformer'))
{
	echo Json::encode(array(
		'error' => array(
			'code' => 'MODULE_NOT_INSTALLED',
			'msg' => 'Module transformer isn`t installed'
		)
	));
	return;
}

$httpRequest = \Bitrix\Main\Context::getCurrent()->getRequest();
$id = $httpRequest->getQuery('id');
if(!empty($id))
{
	$command = Command::getByGuid($id);
	if(!$command)
	{
		$message = 'Command '.$id.' not found';
		\Bitrix\Transformer\Log::write($message);
		echo Json::encode(array(
			'error' => $message,
		));
		return;
	}
	if($command->getStatus() != Command::STATUS_SEND)
	{
		$message = 'Error: Wrong command status '.$command->getStatus();
		\Bitrix\Transformer\Log::write($message);
		echo Json::encode(array(
			'error' => $message,
		));
		return;
	}
	$fileSize = $httpRequest->getPost('file_size');
	if($httpRequest->getPost('upload') == 'where')
	{
		$fileId = $httpRequest->getPost('file_id');
		$uploadInfo = FileUploader::getUploadInfo($id, $fileId, $fileSize);
		echo Json::encode($uploadInfo);
		return;
	}
	$fileName = $httpRequest->getPost('file_name');
	$uploadedFile = $httpRequest->getFile('file');
	if($uploadedFile)
	{
		if(isset($uploadedFile['error']) && $uploadedFile['error'] > 0)
		{
			$message = 'client web-server error uploading file part';
			echo Json::encode(array(
				'error' => $message,
			));
			return;
		}
		$file = fopen($uploadedFile['tmp_name'], 'rb');
		if($file)
		{
			$filePart = fread($file, filesize($uploadedFile['tmp_name']));
		}
	}
	else
	{
		$filePart = $httpRequest->getPost('file');
	}
	$isLastPart = ($httpRequest->getPost('last_part') === 'y');
	$bucket = intval($httpRequest->getPost('bucket'));
	if($fileName && $filePart)
	{
		$saveResult = FileUploader::saveUploadedPart($fileName, $filePart, $fileSize, $isLastPart, $bucket);
		if($saveResult->isSuccess())
		{
			$saveData = $saveResult->getData();
			$message = 'file saved to '.$saveData['result'];
			echo Json::encode(array(
				'success' => $message,
			));
		}
		else
		{
			$message = $saveResult->getErrorMessages();
			\Bitrix\Transformer\Log::write($message);
			echo Json::encode(array(
				'error' => $message,
				)
			);
		}
		return;
	}
	$error = $httpRequest->getPost('error');
	$errorCode = intval($httpRequest->getPost('errorCode'));
	if($error || $errorCode)
	{
		if($errorCode && !$error)
		{
			$error = $errorCode;
		}
		if(!$errorCode)
		{
			$errorCode = Command::ERROR_CONTROLLER_UNKNOWN_ERROR;
		}
		\Bitrix\Transformer\Log::write('Error on server: '.$error);
		$result = $httpRequest->getPost('result');
		if(is_array($result['files']))
		{
			foreach($result['files'] as $key => $fileName)
			{
				$file = new File($fileName);
				$file->delete();
			}
		}
		$command->updateStatus(Command::STATUS_ERROR, $error, $errorCode);
		$command->callback(array('error' => $error));
		echo Json::encode(array(
			'success' => 'error received'
		));
		return;
	}
	$finish = ($httpRequest->getPost('finish') == 'y');
	if($finish)
	{
		/** @var File[] $files */
		$files = array();
		$command->updateStatus(Command::STATUS_UPLOAD);
		$result = $httpRequest->getPost('result');
		if(!is_array($result['files']))
		{
			$result['files'] = [];
		}
		foreach($result['files'] as $key => $fileName)
		{
			$files[$key] = new File($fileName);
			$result['files'][$key] = $files[$key]->getAbsolutePath();
		}
		try
		{
			if($command->callback($result))
			{
				$command->updateStatus(Command::STATUS_SUCCESS);
				$command->push();
				echo Json::encode(array(
					'success' => 'OK'
				));
			}
			else
			{
				$command->updateStatus(Command::STATUS_ERROR, 'Callback error', Command::ERROR_CALLBACK);
				echo Json::encode(array(
					'error' => 'Error of the callback',
				));
			}
		}
		finally
		{
			foreach($result['files'] as $key => $file)
			{
				$files[$key]->delete();
			}
		}
		return;
	}
}

echo Json::encode(array(
	'error' => 'Wrong request',
));