Example #1
1
 function executeComponent()
 {
     $arFilter = array('IBLOCK_ID' => $this->arParams['IBLOCK_ID'], 'ACTIVE' => 'Y');
     if (true || $this->StartResultCache()) {
         $CIBlockElement = new CIBlockElement();
         $CFile = new \CFile();
         $aElts = array();
         $eltsSelectFields = array_merge(array('ID', 'NAME', 'CODE', 'PREVIEW_PICTURE', 'DETAIL_PICTURE', 'DETAIL_PAGE_URL'), $this->getIBlockProperties($this->arParams['IBLOCK_ID']));
         $rsElts = $CIBlockElement->GetList(array('SORT' => 'asc', 'date_active_from' => 'DESC'), $arFilter, false, false, array('ID', 'NAME'));
         if (intval($rsElts->SelectedRowsCount())) {
             while ($arElt = $rsElts->Fetch()) {
                 $aElts[] = array('ID' => $arElt['ID'], 'NAME' => $arElt['NAME']);
             }
             $arElt = $CIBlockElement->GetList(array('SORT' => 'asc', 'ID' => 'DESC'), array_merge($arFilter, array('ID' => $aElts[0]['ID'])), false, false, $eltsSelectFields)->GetNext();
             if ($arElt['DETAIL_PICTURE']) {
                 $arElt['DETAIL_PICTURE'] = $CFile->GetPath($arElt['DETAIL_PICTURE']);
             } elseif ($arElt['PREVIEW_PICTURE']) {
                 $arElt['DETAIL_PICTURE'] = $CFile->GetPath($arElt['PREVIEW_PICTURE']);
             }
             $arPrice = CPrice::GetList(array(), array("PRODUCT_ID" => $arElt['ID']))->Fetch();
             $arElt['PRICE'] = $arPrice['PRICE'];
             $this->arResult['ITEMS'] = $aElts;
             $this->arResult['ITEM'] = $arElt;
             $this->IncludeComponentTemplate();
         }
     }
 }
 function saveFileAction()
 {
     if (!($img = $_FILES['Filedata'])) {
         print json_encode(array('success' => false, 'text' => "Не получены данные", 'debug' => $_FILES['Filedata']));
         return false;
     }
     if (front::$_req["type"] == "img") {
         list($width, $height, $type, $attr) = getimagesize($img['tmp_name']);
         $ext = array('gif', 'jpeg', 'png');
         $ext_format = array('gif' => 1, 'jpeg' => 2, 'png' => 3);
         if ($type < 1 || $type > 3) {
             print json_encode(array('success' => false, 'text' => "Формат не поддерживается", 'debug' => $_FILES['Filedata']));
             return false;
         }
         if (front::$_req["width"] > 0 && $width > front::$_req["width"] || front::$_req["height"] > 0 && $height > front::$_req["height"]) {
             print json_encode(array('success' => false, 'text' => "Слишком большое разрешение", 'debug' => $_FILES['Filedata']));
             return false;
         }
     }
     $b_file = new CFile($_FILES['Filedata']);
     $b_file->max_size = 1048576;
     $b_file->server_root = 1;
     $f_name = $b_file->MoveUploadedFile("temp/");
     echo json_encode(array("success" => true, "id" => $f_name, "path" => WDCPREFIX . "/temp/" . $f_name));
 }
 function saveFileAction()
 {
     if (!($img = $_FILES['Filedata'])) {
         print json_encode(array('success' => false, 'text' => "Не получены данные", 'debug' => $_FILES['Filedata']));
         return false;
     }
     if (front::$_req["type"] == "img") {
         list($width, $height, $type, $attr) = getimagesize($img['tmp_name']);
         $ext = array('gif', 'jpeg', 'png');
         $ext_format = array('gif' => 1, 'jpeg' => 2, 'png' => 3);
         if ($type < 1 || $type > 3) {
             print json_encode(array('success' => false, 'text' => "Формат не поддерживается", 'debug' => $_FILES['Filedata']));
             return false;
         }
         if (front::$_req["width"] > 0 && $width > front::$_req["width"] || front::$_req["height"] > 0 && $height > front::$_req["height"]) {
             print json_encode(array('success' => false, 'text' => "Слишком большое разрешение", 'debug' => $_FILES['Filedata']));
             return false;
         }
     }
     $b_file = new CFile($_FILES['Filedata']);
     $b_file->max_size = 1048576;
     $b_file->server_root = 1;
     $f_name = $b_file->MoveUploadedFile("temp/");
     echo json_encode(array("success" => true, "id" => $f_name, "path" => WDCPREFIX . "/temp/" . $f_name));
 }
Example #4
0
 public function process_event(&$event)
 {
     if ($event->type == 'check' && $event->data['id']) {
         $file = new CFile($event->data['id']);
         $file->antivirus();
         if ($file->virus == 0) {
             $status = 'Clear.';
         } else {
             if ($file->virus == 1) {
                 $status = 'Infected. ' . $file->virusName . '.';
             } else {
                 if ($file->virus == 2) {
                     $status = 'Skipped by archive restrictions.';
                 } else {
                     if ($file->virus == 16) {
                         $status = 'No need check. Skipped.';
                     } else {
                         $status = 'Error.';
                     }
                 }
             }
         }
         $this->log->notice("File \"{$file->name}\" ({$file->table}) ({$file->id}). {$status}");
     }
     return PGQ_EVENT_OK;
 }
 public function saveFileAction()
 {
     //die("1ssss");
     if (!($img = $_FILES['Filedata'])) {
         print json_encode(array('success' => false, 'text' => 'Не получены данные', 'debug' => $_FILES['Filedata']));
         return false;
     }
     if (front::$_req['type'] == 'img') {
         list($width, $height, $type, $attr) = getimagesize($img['tmp_name']);
         $ext = array('gif', 'jpeg', 'png');
         $ext_format = array('gif' => 1, 'jpeg' => 2, 'png' => 3);
         if ($type < 1 || $type > 3) {
             //   print(json_encode(array ('success' => false, 'text'=>"Формат не поддерживается", 'debug' => $_FILES['Filedata'])));
             //  return false;
         }
         if (front::$_req['width'] > 0 && $width > front::$_req['width'] || front::$_req['height'] > 0 && $height > front::$_req['height']) {
             print json_encode(array('success' => false, 'text' => 'Слишком большое разрешение', 'debug' => $_FILES['Filedata']));
             return false;
         }
     }
     $b_file = new CFile($_FILES['Filedata']);
     $b_file->max_size = 1048576;
     $b_file->server_root = 1;
     $f_name = $b_file->MoveUploadedFile('temp/');
     echo json_encode(array('success' => true, 'id' => $f_name, 'path' => WDCPREFIX . '/temp/' . $f_name, 'name' => $_FILES['Filedata']['name']));
 }
 /**
  *                                  
  */
 function rotate()
 {
     if (file_exists($this->_file) && filesize($this->_file) >= $this->_size * 1024 * 1024) {
         //                                                              ,
         //                       ,
         //
         $LockFileHandler = new CFile($this->_file . '.lock');
         $LockFileHandler->open('w');
         if (!$LockFileHandler->isError()) {
             $LockFileHandler->lock(LOCK_EX);
         }
         //                         ,                                  (               )
         //        $renames                          array(exists_files, new_file)
         //           new_file               ,      $renames
         //                     .
         //         ,        $renames                             :
         // array(
         //         array('/var/log/logfile', '/var/log/logfile.1'),
         //         array('/var/log/logfile.1', '/var/log/logfile.2'),
         //         array('/var/log/logfile.2', '/var/log/logfile.3'),
         // )
         //          :
         //    1.                ,                /var/log/logfile.3 -              ,              rename
         //    2.                                                     !
         $cnt = 1;
         $renames = array();
         $filename = $this->_file . '.' . $cnt;
         $cnt++;
         $renames[] = array($this->_file, $filename);
         while (file_exists($filename)) {
             $new_filename = $this->_file . '.' . $cnt;
             $cnt++;
             $renames[] = array($filename, $new_filename);
             $filename = $new_filename;
         }
         //           ,
         $removes = array();
         if (count($renames) > $this->_rotate) {
             $removes = array_slice($renames, $this->_rotate);
             $renames = array_slice($renames, 0, $this->_rotate);
         }
         //
         foreach ($removes as $f) {
             @unlink($f[0]);
         }
         //
         $renames = array_reverse($renames);
         foreach ($renames as $f) {
             rename($f[0], $f[1]);
         }
         //
         touch($this->_file);
         $LockFileHandler->unlock();
         $LockFileHandler->close();
     }
 }
Example #7
0
 /**
  * Удалить отзыв
  *
  * @param  int $msg ID отзыва
  * @param  int $admin Является ли пользователь администратором 1 - да, 0 - нет (типа is_admin из stdf)
  * @return array сообщение об ошибке
  */
 function Del($msg, $admin = 0)
 {
     if (!$admin) {
         return 0;
     }
     if ($ret = $GLOBALS['DB']->val("DELETE FROM sopinions WHERE (id = ?) RETURNING logo", $msg)) {
         $file = new CFile();
         $file->Delete(0, "about/opinions/", $ret);
     }
     return $DB->error;
 }
 /**
  * parse file for indexing
  * @todo convert to using the FileSystem methods
  */
 public function index(CFile $file)
 {
     /* Workaround for indexing large files:
      ** Based on the value defined in config data,
      ** files with file_size greater than specified limit
      ** are not indexed for searching.
      ** Negative value :<=> no filesize limit
      */
     $index_max_file_size = w2PgetConfig('index_max_file_size', 0);
     if ($file->file_size > 0 && ($index_max_file_size < 0 || (int) $file->file_size <= $index_max_file_size * 1024)) {
         // get the parser application
         $parser = w2PgetConfig('parser_' . $file->file_type);
         if (!$parser) {
             $parser = w2PgetConfig('parser_default');
         }
         if (!$parser) {
             return false;
         }
         // buffer the file
         $file->_filepath = W2P_BASE_DIR . '/files/' . $file->file_project . '/' . $file->file_real_filename;
         if (file_exists($file->_filepath)) {
             $fp = fopen($file->_filepath, 'rb');
             $x = fread($fp, $file->file_size);
             fclose($fp);
             $ignore = w2PgetSysVal('FileIndexIgnoreWords');
             $ignore = $ignore['FileIndexIgnoreWords'];
             $ignore = explode(',', $ignore);
             $x = strtolower($x);
             $x = preg_replace("/[^A-Za-z0-9 ]/", "", $x);
             foreach ($ignore as $ignoreWord) {
                 $x = str_replace(" {$ignoreWord} ", ' ', $x);
             }
             $x = str_replace('  ', ' ', $x);
             $words = explode(' ', $x);
             foreach ($words as $index => $word) {
                 if ('' == trim($word)) {
                     continue;
                 }
                 $q = $this->query;
                 $q->addTable('files_index');
                 $q->addInsert('file_id', $file->file_id);
                 $q->addInsert('word', $word);
                 $q->addInsert('word_placement', $index);
                 $q->exec();
                 $q->clear();
             }
         } else {
             //TODO: if the file doesn't exist.. should we delete the db record?
         }
     }
     $file->file_indexed = 1;
     $file->store();
     return count($words);
 }
Example #9
0
 public function delete(CFile $file)
 {
     $file->file_project = (int) $file->file_project;
     if ('' == $file->file_real_filename || !file_exists(W2P_BASE_DIR . '/files/' . $file->file_project . '/' . $file->file_real_filename)) {
         return true;
     }
     if ($file->canDelete()) {
         return @unlink(W2P_BASE_DIR . '/files/' . $file->file_project . '/' . $file->file_real_filename);
     }
     return false;
 }
Example #10
0
 /**
  * Count unsent document items
  *
  * @return void
  */
 function countUnsentDocItems()
 {
     $where["file_category_id"] = "= '{$this->_id}'";
     $where["etat_envoi"] = "!= 'oui'";
     $where["object_id"] = "IS NOT NULL";
     $file = new CFile();
     $this->_count_unsent_files = $file->countList($where);
     $document = new CCompteRendu();
     $this->_count_unsent_documents = $document->countList($where);
     $this->_count_unsent_doc_items = $this->_count_unsent_documents + $this->_count_unsent_files;
 }
Example #11
0
 /**
  * Сохраняем документ на сайте.
  * 
  * @return \CFile
  */
 public function saveFile()
 {
     $login = '******';
     $content = $this->getOutput();
     $file = new CFile();
     $file->path = 'users/' . substr($login, 0, 2) . "/{$login}/upload/";
     $file->name = basename($file->secure_tmpname($file->path, '.odt'));
     $file->size = strlen($content);
     if ($file->putContent($file->path . $file->name, $content)) {
         return $file;
     }
 }
Example #12
0
 /**
  * Выводит икону и задданный внешний URL для определенного файла
  *
  * @param string  $ulogin   	Логин пользователя
  * @param string  $filename 	Имя файла 
  * @param string  $dir      	Папка файла
  * @param string  $url		 	Ссылка на файл
  * @param integer $bigtext  	Вместо иконкки будет большой текст расширения файла(TXT, PDF, etc...) если переменная принимает значение 1
  * @return string HTML-code
  */
 function viewattachExternal($ulogin, $filename, $dir, $url, $bigtext = 0)
 {
     $l_dir = substr($ulogin, 0, 2) . "/" . $ulogin;
     $cfile = new CFile("users/{$l_dir}/" . $dir . "/" . $filename);
     if (!$cfile->size) {
         return "";
     }
     $ext = $cfile->getext($filename);
     $ico = getICOFile($ext, true);
     echo $ico;
     $fsize = ConvertBtoMB($cfile->size);
     return '<p><img src="/pda/images/mime/' . $ico . '.png" alt="' . $ext . '" width="18" height="16"> <a href="' . $url . '" target="_blank">Скачать</a> | ' . ucfirst($ext) . ', ' . $fsize . ' </p>';
 }
Example #13
0
function deleteFiles($order_id, $types)
{
    $types = !is_array($types) ? array($types) : $types;
    $rows = CFile::selectFilesBySrc('file_reserves_order', $order_id);
    if (!$rows) {
        return 0;
    }
    foreach ($rows as $row) {
        if (!in_array($row['doc_type'], $types)) {
            continue;
        }
        $file = new CFile();
        $file->Delete($row['id']);
    }
}
Example #14
0
 /**
  * Редактировать документ.
  * 
  * @param array $doc     новые данные по документу.
  * @param array $old_doc старые данные по документу.
  *
  * @return bool успешно?
  */
 public function editDoc($doc, $old_doc)
 {
     $sql_data = $doc;
     $sql_data['name'] = pg_escape_string(change_q_x($sql_data['name']));
     $act_time = self::$docs_ss[$sql_data['status']][1];
     $file_set = $doc['file_id'] ? ", file_id = {$doc['file_id']}" : '';
     $sql_data['stage_id'] = $sql_data['stage_id'] ? (int) $sql_data['stage_id'] : 'NULL';
     $sql = "\n          UPDATE sbr_docs\n             SET name = '{$sql_data['name']}',\n                 status = {$sql_data['status']},\n                 access_role = {$sql_data['access_role']},\n                 stage_id = {$sql_data['stage_id']},\n                 {$act_time} = COALESCE({$act_time}, now()),\n                 type = {$sql_data['type']}\n                 {$file_set}\n           WHERE id = {$sql_data['id']}\n        ";
     $ok = $this->_eventQuery($sql);
     if ($ok && $file_set) {
         $cfile = new CFile();
         $cfile->Delete(0, $old_doc['file_path'], $old_doc['file_name']);
     }
     return $ok;
 }
Example #15
0
 private function loadData()
 {
     if (empty($this->arParams['PARAMS']['arUserField'])) {
         return array();
     }
     $userId = $this->getUser()->getId();
     $values = $this->arParams['PARAMS']['arUserField']['VALUE'];
     if (!is_array($this->arParams['PARAMS']['arUserField']['VALUE'])) {
         $values = array($values);
     }
     $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager();
     $versions = array();
     foreach ($values as $value) {
         $attachedObjectId = (int) $value;
         if ($attachedObjectId <= 0) {
             continue;
         }
         /** @var \Bitrix\Disk\AttachedObject $attachedModel */
         $attachedModel = \Bitrix\Disk\AttachedObject::loadById($attachedObjectId, array('VERSION.OBJECT'));
         if (!$attachedModel) {
             continue;
         }
         $version = $attachedModel->getVersion();
         if (!$version) {
             continue;
         }
         $extension = $version->getExtension();
         $versions[] = array('ID' => $attachedModel->getId(), 'NAME' => $version->getName(), 'CONVERT_EXTENSION' => DocumentHandler::isNeedConvertExtension($extension), 'EDITABLE' => DocumentHandler::isEditable($extension), 'CAN_UPDATE' => $attachedModel->canUpdate($userId), 'FROM_EXTERNAL_SYSTEM' => $version->getObject()->getContentProvider() && $version->getObject()->getCreatedBy() == $userId, 'EXTENSION' => $extension, 'SIZE' => \CFile::formatSize($version->getSize()), 'HISTORY_URL' => $urlManager->getUrlUfController('history', array('attachedId' => $attachedModel->getId())), 'DOWNLOAD_URL' => $urlManager->getUrlUfController('download', array('attachedId' => $attachedModel->getId())), 'COPY_TO_ME_URL' => $urlManager->getUrlUfController('copyTome', array('attachedId' => $attachedModel->getId())), 'VIEW_URL' => $urlManager->getUrlToShowAttachedFileByService($attachedModel->getId(), 'gvdrive'), 'EDIT_URL' => $urlManager->getUrlToStartEditUfFileByService($attachedModel->getId(), 'gdrive'), 'GLOBAL_CONTENT_VERSION' => $version->getGlobalContentVersion(), 'ATTRIBUTES_FOR_VIEWER' => Ui\Viewer::getAttributesByAttachedObject($attachedModel, array('version' => $version->getGlobalContentVersion(), 'canUpdate' => $attachedModel->canUpdate($userId), 'showStorage' => false, 'externalId' => false, 'relativePath' => false)));
     }
     unset($value);
     return $versions;
 }
Example #16
0
 function UnInstallDB($arParams = array())
 {
     global $DB, $APPLICATION;
     $errors = false;
     if (array_key_exists("savedata", $arParams) && $arParams["savedata"] != "Y") {
         $errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/support/install/db/' . strtolower($DB->type) . '/uninstall.sql');
         if (!is_array($errors)) {
             @set_time_limit(600);
             COption::RemoveOption('support');
             $db_res = $DB->Query("SELECT ID FROM b_file WHERE MODULE_ID = 'support'");
             while ($arRes = $db_res->Fetch()) {
                 CFile::Delete($arRes['ID']);
             }
             if ($arParams['admin'] == 'Y') {
                 $this->UnInstallEvents();
             }
         }
     }
     if (is_array($errors)) {
         $APPLICATION->ThrowException(implode(' ', $errors));
         return false;
     }
     CAgent::RemoveModuleAgents('support');
     UnRegisterModuleDependences('mail', 'OnGetFilterList', 'support', 'CSupportEMail', 'OnGetFilterList');
     UnRegisterModule('support');
     return true;
 }
Example #17
0
 /**
  * Возвращаем данные столика
  * @param $arData
  * @return CDBResult|CIBlockResult|string
  */
 function getInfo($tableID, $arData = false, $GetNext = false)
 {
     $arFilterTable = array("IBLOCK_ID" => IB_TABLE_ID, "PROPERTY_CLUB" => $this->clubID, "ID" => intval($tableID));
     $arSelectTable = array("ID");
     $arOrderTable = array();
     $arOrder = is_array($arData["arSelect"]) ? array_merge($arData["arOrder"], $arOrderTable) : $arOrderTable;
     $arGroupBy = is_array($arData["arGroupBy"]) ? array_merge($arData["arGroupBy"], array()) : false;
     $arNavStartParams = is_array($arData["arGroupBy"]) ? array_merge($arData["arNavStartParams"], array()) : false;
     $arSelect = is_array($arData["arSelect"]) ? array_merge($arData["arSelect"], $arSelectTable) : $arSelectTable;
     $arFilter = is_array($arData["arFilter"]) ? array_merge($arData["arFilter"], $arFilterTable) : $arFilterTable;
     $res = CIBlockElement::GetList($arOrder, $arFilter, $arGroupBy, $arNavStartParams, $arSelect);
     if (!$res) {
         return Errors::run("404");
     }
     $ob = $GetNext ? $res->GetNext() : $res->Fetch();
     if (isset($ob["PREVIEW_PICTURE"])) {
         $arFile = CFile::GetFileArray($ob["PREVIEW_PICTURE"]);
         $ob["PREVIEW_PICTURE"] = $arFile["SRC"];
     }
     if (isset($ob["PROPERTY_PRICE_GROUP_VALUE"])) {
         $res = CIBlockElement::GetList(array(), array("ID" => intval($ob["PROPERTY_PRICE_GROUP_VALUE"]), "IBLOCK_ID" => IB_PRICE_GROUP), false, false, array("NAME", "ID", "PROPERTY_PRICE"));
         $ob["PROPERTY_PRICE_GROUP"] = $res->Fetch();
     }
     return $ob;
 }
Example #18
0
 /**
  * ’эндлер, отслеживающий изменени¤ в инфоблоках
  * @param $arFields
  * @return bool
  */
 static function getCradoBaners()
 {
     //$arResult = array();
     CModule::IncludeModule('iblock');
     global $DB;
     $result = $DB->Query('SELECT * FROM b_cradobaners');
     $arResult = array();
     $i = 0;
     while ($res = $result->fetch()) {
         $arResult[$i]['ID'] = $res['ID'];
         $arResult[$i]['COUNT_CLICK'] = $res['UF_COUNTCLICK'];
         $arResult[$i]['COUNT_VIEW'] = $res['UF_COUNTVIEW'];
         $arResult[$i]['DATE_LAST_CLICK'] = $res['UF_DATECLICK'];
         $obElement = CIBlockElement::GetByID($res['UF_IDBANERS']);
         if ($arEl = $obElement->GetNext()) {
             //$arResult[$i]['BANNER'] = $arEl;
             $arResult[$i]['BANNER']['ID'] = $arEl['ID'];
             $arResult[$i]['BANNER']['NAME'] = $arEl['NAME'];
             //Баннер в категории
             if ($arEl['PREVIEW_PICTURE'] != '') {
                 $arResult[$i]['BANNER']['BANNER_CATEGORY'] = CFile::ResizeImageGet($arEl['PREVIEW_PICTURE'], array('width' => 140, 'height' => 95), BX_RESIZE_IMAGE_PROPORTIONAL, true);
             }
             if ($arEl['DETAIL_PICTURE'] != '') {
                 $arResult[$i]['BANNER']['BANNER_ELEMENT'] = CFile::ResizeImageGet($arEl['DETAIL_PICTURE'], array('width' => 82, 'height' => 140), BX_RESIZE_IMAGE_PROPORTIONAL, true);
             }
         }
         $i++;
     }
     return $arResult;
 }
Example #19
0
	/**
	 * Choose picture dependence on type
	 */
	public function chooseFileIcoClass($id)
	{
		$fileInfo = \CFile::GetFileArray($id);
		if ($fileInfo["CONTENT_TYPE"] == PDF)
		{
			return "ico_pdf";
		}
		elseif ($fileInfo["CONTENT_TYPE"] == DOC)
		{
			return "ico_doc";
		}
		elseif ($fileInfo["CONTENT_TYPE"] == JPG)
		{
			return "ico_jpg";
		}
		elseif ($fileInfo["CONTENT_TYPE"] == ZIP)
		{
			return "ico_zip";
		}
		else
		{
			return "ico_cd";
		}
		throw new \Exception("An error wa occured in " . __CLASS__, 1);

	}
Example #20
0
	public function Authorize()
	{
		$GLOBALS["APPLICATION"]->RestartBuffer();
		$bSuccess = false;

			if(isset($_REQUEST["code"]) && $_REQUEST["code"] <> '')
			{
				if(CSocServAuthManager::CheckUniqueKey())
				{
				$redirect_uri = CSocServUtil::GetCurUrl('auth_service_id='.self::ID, array("code"));

				$appID = self::GetOption("facebook_appid");
				$appSecret = self::GetOption("facebook_appsecret");

				$fb = new CFacebookInterface($appID, $appSecret, $_REQUEST["code"]);

				if($fb->GetAccessToken($redirect_uri) !== false)
				{
					$arFBUser = $fb->GetCurrentUser();
					if(isset($arFBUser["id"]))
					{
						$arFields = array(
							'EXTERNAL_AUTH_ID' => self::ID,
							'XML_ID' => $arFBUser["id"],
							'LOGIN' => "FB_".$arFBUser["email"],
							'EMAIL' => $arFBUser["email"],
							'NAME'=> $arFBUser["first_name"],
							'LAST_NAME'=> $arFBUser["last_name"],
						);

						if(isset($arFBUser['picture']['data']['url']) && self::CheckPhotoURI($arFBUser['picture']['data']['url']))
							if ($arPic = CFile::MakeFileArray($arFBUser['picture']['data']['url']))
								$arFields["PERSONAL_PHOTO"] = $arPic;
						if(isset($arFBUser['birthday']))
							if ($date = MakeTimeStamp($arFBUser['birthday'], "MM/DD/YYYY"))
								$arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
						if(isset($arFBUser['gender']) && $arFBUser['gender'] != '')
						{
							if ($arFBUser['gender'] == 'male')
								$arFields["PERSONAL_GENDER"] = 'M';
							elseif ($arFBUser['gender'] == 'female')
								$arFields["PERSONAL_GENDER"] = 'F';
						}
						$arFields["PERSONAL_WWW"] = "http://www.facebook.com/".$arFBUser["id"];
						$bSuccess = $this->AuthorizeUser($arFields);
					}
				}
			}
		}
		$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key");
		$url = $GLOBALS['APPLICATION']->GetCurPageParam(($bSuccess? '':'auth_service_id='.self::ID.'&auth_service_error=1'), $aRemove);
		echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \''.CUtil::JSEscape($url).'\';
window.close();
</script>
';
		die();
	}
Example #21
0
 /**
  * @param array $data
  * @return Main\Entity\AddResult
  */
 public static function send(array $data)
 {
     $manageCache = Application::getInstance()->getManagedCache();
     if (CACHED_b_event !== false && $manageCache->read(CACHED_b_event, "events")) {
         $manageCache->clean('events');
     }
     $arFiles = array();
     if (isset($data['FILE'])) {
         if (is_array($data['FILE'])) {
             $arFiles = $data['FILE'];
         }
         unset($data['FILE']);
     }
     $result = MailInternal\EventTable::add($data);
     if ($result->isSuccess()) {
         $id = $result->getId();
         foreach ($arFiles as $file) {
             $arFile = \CFile::MakeFileArray($file);
             $arFile["MODULE_ID"] = "main";
             $fid = \CFile::SaveFile($arFile, "main");
             $dataAttachment = array('EVENT_ID' => $id, 'FILE_ID' => $fid);
             MailInternal\EventAttachmentTable::add($dataAttachment);
         }
     }
     return $result;
 }
Example #22
0
 function __MPF_ImageResizeHandler(&$arCustomFile, $params = array(), $result = array())
 {
     static $arParams = array();
     if (!empty($params)) {
         $arParams = $params;
     }
     static $arResult = array();
     if (!empty($result)) {
         $arResult = $result;
     }
     $fileIdForDelete = 0;
     $arFields = array();
     foreach (array("MELODY_WELCOME", "MELODY_WAIT", "MELODY_HOLD", "MELODY_VOICEMAIL") as $controlID => $inputName) {
         if ($_REQUEST["controlID"] == "voximplant" . $controlID) {
             $fileIdForDelete = $arResult["ITEM"][$inputName];
             $arFields = array($inputName => $arCustomFile["fileID"]);
             break;
         }
     }
     if (!empty($arFields)) {
         $arFile = CFile::GetFileArray($arCustomFile['fileID']);
         $arCustomFile["fileURL"] = CHTTP::URN2URI($arFile["SRC"]);
         Bitrix\Voximplant\ConfigTable::update($arParams["ID"], $arFields);
         CFile::Delete($fileIdForDelete);
     }
 }
Example #23
0
 function UnInstallDB($arParams = array())
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     if (!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y") {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/install/db/" . strtolower($DB->type) . "/uninstall.sql");
     }
     //delete agents
     CAgent::RemoveModuleAgents("vote");
     $db_res = $DB->Query("SELECT ID FROM b_file WHERE MODULE_ID = 'vote'");
     while ($arRes = $db_res->Fetch()) {
         CFile::Delete($arRes["ID"]);
     }
     // Events
     include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/install/events/del_events.php";
     UnRegisterModuleDependences("im", "OnGetNotifySchema", "vote", "CVoteNotifySchema", "OnGetNotifySchema");
     UnRegisterModuleDependences("main", "OnUserLogin", "vote", "CVoteUser", "OnUserLogin", 200);
     UnRegisterModuleDependences("main", "OnUserTypeBuildList", "vote", "CUserTypeVote", "GetUserTypeDescription", 200);
     UnRegisterModuleDependences("main", "OnBeforeProlog", "main", "", "", "/modules/vote/keepvoting.php");
     UnRegisterModule("vote");
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     }
     return true;
 }
 private function getFileInfo($file)
 {
     switch (true) {
         case !$file:
             return false;
             break;
         case is_array($file):
             $path_parts = pathinfo($file["name"]);
             $ext = $path_parts['extension'];
             $fileName = $file["tmp_name"];
             break;
         case file_exists($file):
             $path_parts = pathinfo($file);
             $ext = $path_parts['extension'];
             $fileName = $file;
             break;
         case is_numeric($file):
             $file_info = CFile::GetFileArray($file);
             if (is_array($file_info)) {
                 return $this->getFileInfo($_SERVER['DOCUMENT_ROOT'] . $file_info['SRC']);
             }
             break;
         default:
             $path_parts = pathinfo($file);
             $fileName = ini_get('upload_tmp_dir') . '/' . $path_parts["basename"];
             file_put_contents($fileName, file_get_contents($file));
             return $this->getFileInfo($fileName);
             break;
     }
     $ext = strtolower($ext);
     return array('FILE_NAME' => $fileName, 'EXT' => $ext);
 }
 function DoValidate($arParams, $arQuestion, $arAnswers, $arValues)
 {
     global $APPLICATION;
     if (count($arValues) > 0) {
         foreach ($arValues as $arImage) {
             // if image successfully uploaded
             if (strlen($arImage["tmp_name"]) > 0 && ($arImageInfo = CFile::GetImageSize($arImage["tmp_name"]))) {
                 // check minimum image width
                 if ($arParams["WIDTH_FROM"] > 0 && $arImageInfo[0] < $arParams["WIDTH_FROM"]) {
                     $APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_IMAGE_SIZE_ERROR_WIDTH_LESS"));
                     return false;
                 }
                 // check maximum image width
                 if ($arParams["WIDTH_TO"] > 0 && $arImageInfo[0] > $arParams["WIDTH_TO"]) {
                     $APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_IMAGE_SIZE_ERROR_WIDTH_MORE"));
                     return false;
                 }
                 // check minimum image height
                 if ($arParams["HEIGHT_FROM"] > 0 && $arImageInfo[1] < $arParams["HEIGHT_FROM"]) {
                     $APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_IMAGE_SIZE_ERROR_HEIGHT_LESS"));
                     return false;
                 }
                 // check maximum image height
                 if ($arParams["HEIGHT_TO"] > 0 && $arImageInfo[1] > $arParams["HEIGHT_TO"]) {
                     $APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_IMAGE_SIZE_ERROR_HEIGHT_MORE"));
                     return false;
                 }
             }
         }
     }
     return true;
 }
Example #26
0
 private function getGridData($gridId)
 {
     $grid = array('ID' => $gridId);
     $securityContext = $this->storage->getCurrentUserSecurityContext();
     $parameters = array('with' => array('FILE', 'CREATE_USER'), 'filter' => array('IS_EXPIRED' => false, 'OBJECT.STORAGE_ID' => $this->storage->getId(), 'CREATED_BY' => $this->getUser()->getId()));
     $parameters = Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('OBJECT_ID', 'OBJECT.CREATED_BY'));
     $items = ExternalLink::getModelList($parameters);
     Collection::sortByColumn($items, array('CREATE_TIME' => array(SORT_NUMERIC, SORT_ASC)));
     $urlManager = Driver::getInstance()->getUrlManager();
     $rows = array();
     foreach ($items as $externalLink) {
         /** @var ExternalLink $externalLink */
         $exportData = $externalLink->toArray();
         $nameSpecialChars = htmlspecialcharsbx($externalLink->getFile()->getName());
         $createDateText = htmlspecialcharsbx((string) $externalLink->getCreateTime());
         $columnName = "\n\t\t\t\t<table class=\"bx-disk-object-name\"><tr>\n\t\t\t\t\t\t<td style=\"width: 45px;\"><div data-object-id=\"{$externalLink->getId()}\" class=\"draggable bx-file-icon-container-small bx-disk-file-icon\"></div></td>\n\t\t\t\t\t\t<td><a class=\"bx-disk-folder-title\" id=\"disk_obj_{$externalLink->getId()}\" href=\"\" data-bx-dateModify=\"{$createDateText}\">{$nameSpecialChars}</a></td>\n\t\t\t\t</tr></table>\n\t\t\t";
         $createdByLink = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_USER'], array("user_id" => $externalLink->getCreatedBy()));
         $rows[] = array('data' => $exportData, 'columns' => array('CREATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'UPDATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'NAME' => $columnName, 'FORMATTED_SIZE' => CFile::formatSize($externalLink->getFile()->getSize()), 'CREATE_USER' => "\n\t\t\t\t\t\t<div class=\"bx-disk-user-link\"><a target='_blank' href=\"{$createdByLink}\" id=\"\">" . htmlspecialcharsbx($externalLink->getCreateUser()->getFormattedName()) . "</a></div>\n\t\t\t\t\t"), 'actions' => array(array("PSEUDO_NAME" => "download", "DEFAULT" => true, "ICONCLASS" => "download", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DOWNLOAD'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $urlManager->getUrlForDownloadFile($externalLink->getFile()) . "')"), array("PSEUDO_NAME" => "disable_external_link", "ICONCLASS" => "disable_external_link", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK'), "SHORT_TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK_SHORT'), "ONCLICK" => "BX.Disk['ExternalLinkListClass_{$this->getComponentId()}'].disableExternalLink({$externalLink->getId()}, {$externalLink->getObjectId()})")));
     }
     unset($externalLink);
     $grid['MODE'] = 'list';
     $grid['HEADERS'] = array(array('id' => 'ID', 'name' => 'ID', 'default' => false, 'show_checkbox' => true), array('id' => 'NAME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_NAME'), 'default' => true), array('id' => 'CREATE_TIME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_TIME'), 'default' => true), array('id' => 'CREATE_USER', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_USER'), 'default' => false), array('id' => 'FORMATTED_SIZE', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_FORMATTED_SIZE'), 'default' => true));
     $grid['ROWS'] = $rows;
     $grid['ROWS_COUNT'] = count($rows);
     $grid['FOOTER'] = array();
     return $grid;
 }
Example #27
0
	function __mpl_get_avatar()
	{
		global $USER;
		static $avatar = null;
		if ($avatar == null)
		{
			$avatar = '/bitrix/images/1.gif';
			if ($USER->IsAuthorized())
			{
				$u = CUser::GetByID($USER->GetID())->Fetch();
				if ($u["PERSONAL_PHOTO"])
				{
					$res = CFile::ResizeImageGet(
						$u["PERSONAL_PHOTO"],
						array('width' => 58, 'height' => 58),
						BX_RESIZE_IMAGE_EXACT,
						false
					);
					if ($res["src"])
						$avatar = $res["src"];
				}
			}
		}
		return $avatar;
	}
Example #28
0
 public function prepareUser($arFBUser, $short = false)
 {
     $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arFBUser["id"], 'LOGIN' => "FB_" . $arFBUser["id"], 'EMAIL' => $arFBUser["email"] != '' ? $arFBUser["email"] : '', 'NAME' => $arFBUser["first_name"], 'LAST_NAME' => $arFBUser["last_name"], 'OATOKEN' => $this->entityOAuth->getToken(), 'OATOKEN_EXPIRES' => $this->entityOAuth->getAccessTokenExpires());
     if (!$short && isset($arFBUser['picture']['data']['url']) && !$arFBUser['picture']['data']['is_silhouette']) {
         $picture_url = CFacebookInterface::GRAPH_URL . '/' . $arFBUser['id'] . '/picture?type=large';
         $temp_path = CFile::GetTempName('', 'picture.jpg');
         $ob = new \Bitrix\Main\Web\HttpClient(array("redirect" => true));
         $ob->download($picture_url, $temp_path);
         $arPic = CFile::MakeFileArray($temp_path);
         if ($arPic) {
             $arFields["PERSONAL_PHOTO"] = $arPic;
         }
     }
     if (isset($arFBUser['birthday'])) {
         if ($date = MakeTimeStamp($arFBUser['birthday'], "MM/DD/YYYY")) {
             $arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
         }
     }
     if (isset($arFBUser['gender']) && $arFBUser['gender'] != '') {
         if ($arFBUser['gender'] == 'male') {
             $arFields["PERSONAL_GENDER"] = 'M';
         } elseif ($arFBUser['gender'] == 'female') {
             $arFields["PERSONAL_GENDER"] = 'F';
         }
     }
     $arFields["PERSONAL_WWW"] = $this->getProfileUrl($arFBUser['id']);
     if (strlen(SITE_ID) > 0) {
         $arFields["SITE_ID"] = SITE_ID;
     }
     return $arFields;
 }
Example #29
0
 /** Returns an array, containing information about the product block on its ID.
  * @param $elementId
  * @return array|string
  */
 public static function getProductInfo($elementId)
 {
     $elementId = intval($elementId);
     $result = "";
     if ($elementId <= 0) {
         return $result;
     }
     $dbProduct = CIBlockElement::GetList(array(), array("ID" => $elementId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'NAME', 'XML_ID'));
     while ($arProduct = $dbProduct->GetNext()) {
         $imgCode = "";
         if ($arProduct["IBLOCK_ID"] > 0) {
             $arProduct["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arProduct["IBLOCK_ID"], $elementId, array("find_section_section" => $arProduct["IBLOCK_SECTION_ID"]));
         }
         if ($arProduct["DETAIL_PICTURE"] > 0) {
             $imgCode = $arProduct["DETAIL_PICTURE"];
         } elseif ($arProduct["PREVIEW_PICTURE"] > 0) {
             $imgCode = $arProduct["PREVIEW_PICTURE"];
         }
         $arProduct["NAME"] = $arProduct["NAME"];
         $arProduct["DETAIL_PAGE_URL"] = htmlspecialcharsex($arProduct["DETAIL_PAGE_URL"]);
         if ($imgCode > 0) {
             $arFile = CFile::GetFileArray($imgCode);
             $arImgProduct = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
             $arProduct["IMG_URL"] = $arImgProduct['src'];
         }
         return $arProduct;
     }
     return $result;
 }
Example #30
0
function GetResizedImage($id, $width, $height)
{
    $arSize = array("width" => $width, "height" => $height);
    $file = CFile::GetFileArray($id);
    $resized = CFile::ResizeImageGet($file, $arSize);
    return $resized;
}