Example #1
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 #2
0
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'];
        }
    }
}
Example #3
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;
 }
 function __MPF_ImageResizeHandler(&$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;
     }
     $fileID = $arCustomFile['fileID'];
     $arFile = CFile::MakeFileArray($fileID);
     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'];
         }
     }
 }
Example #5
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 #6
0
    public function go()
    {
        require_once $_SERVER["DOCUMENT_ROOT"] . "/classes/XML.php";
        $xml = file_get_contents("http://alfabank.by/a-blog.xml");
        $rss = new \XML($xml);
        foreach ($rss->rss->channel->item as $it) {
            $dom = \phpQuery::newDocumentHTML($it->childByName("content:encoded"));
            $date = date_create($it->pubDate->getData());
            $arResult = array(
                "IBLOCK_ID" => self::ABLOG_IBLOCK_ID,
                "NAME" => $it->title->getData(),
                "DATE_ACTIVE_FROM" => date_format($date, 'd.m.Y'),
                "PREVIEW_TEXT" => $it->description->getData(),
                "PREVIEW_PICTURE" => \CFile::MakeFileArray($dom->find('img')->attr('src')),
                "DETAIL_TEXT" => $it->childByName("content:encoded"),
                "CODE" => \Ns\Bitrix\Helper::Create('iblock')->useVariant('text')->translite($it->title->getData()),
                "PROPERTY_VALUES" => array("ORIGINAL_LINK" => $it->link->getData())
            );
            $this->objElement->Add($arResult);
            if ($this->objElement->LAST_ERROR) {
                prentExpection($this->objElement->LAST_ERROR);
            }
        }

        return true;
	}
Example #7
0
 function getData()
 {
     $data = array();
     $svg = new SimpleXMLElement(file_get_contents($this->xml));
     foreach ($svg->deals->deal as $var) {
         $id = $var->id;
         $url = preg_replace("#http://#i", "", $var->vendor_website_url);
         $url = preg_replace("#^([^/]+)/.*#i", "\\1", $url);
         $url = str_replace("www.", "", $url);
         $arSelect = array("ID", "NAME");
         if ($this->filterSite($url)) {
             $arFilter = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_SITE" => "%" . $url . "%");
             if ($res = CIBlockElement::GetList(array("SORT" => "DESC"), $arFilter, FALSE, FALSE, $arSelect)->Fetch()) {
                 if (!($resStock = CIBlockElement::GetList(array("SORT" => "DESC"), array("CODE" => $id, "TAGS" => $this->tags), FALSE, FALSE, $arSelect)->Fetch())) {
                     $PROP = array();
                     $PROP["URL"] = $var->deal_url;
                     // �������� � ����� 12 ����������� �������� "�����"
                     $PROP["CLUB_ID"] = $res["ID"];
                     // �������� � ����� 3 ����������� �������� 38
                     $PROP["PRICE"] = intval($var->value);
                     // �������� � ����� 3 ����������� �������� 38
                     $PROP["DISCOUNT"] = intval($var->discount_percent);
                     // �������� � ����� 3 ����������� �������� 38
                     $PROP["DISCOUNTPRICE"] = intval($var->discount_amount);
                     // �������� � ����� 3 ����������� �������� 38
                     $PROP["PRICECOUPON"] = intval($var->price);
                     // �������� � ����� 3 ����������� �������� 38
                     $arLoadProductArray = array("IBLOCK_ID" => IB_SUB_STOCK_ID, "PROPERTY_VALUES" => $PROP, "NAME" => $var->title, "ACTIVE_FROM" => date("d.m.Y H:m:s", intval($var->start_timestamp)), "ACTIVE_TO" => date("d.m.Y H:m:s", intval($var->end_timestamp)), "CODE" => $id, "TAGS" => $this->tags, "ACTIVE" => "Y", "PREVIEW_TEXT" => strip_tags($var->conditions), "DETAIL_PICTURE" => CFile::MakeFileArray($var->large_image_url));
                     $data[] = $arLoadProductArray;
                 }
             }
         }
     }
     return count($data) ? $data : false;
 }
Example #8
0
    public function Authorize()
    {
        $GLOBALS["APPLICATION"]->RestartBuffer();
        $bSuccess = 1;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '') {
            if (CSocServAuthManager::CheckUniqueKey()) {
                if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
                    $redirect_uri = self::CONTROLLER_URL . "/redirect.php?redirect_to=" . urlencode(CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code")));
                } else {
                    $redirect_uri = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code"));
                }
                $appID = trim(self::GetOption("facebook_appid"));
                $appSecret = trim(self::GetOption("facebook_appsecret"));
                $fb = new CFacebookInterface($appID, $appSecret, $_REQUEST["code"]);
                if ($fb->GetAccessToken($redirect_uri) !== false) {
                    $arFBUser = $fb->GetCurrentUser();
                    if (is_array($arFBUser) && isset($arFBUser["id"])) {
                        $email = $arFBUser["email"] != '' ? $arFBUser["email"] : '';
                        $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arFBUser["id"], 'LOGIN' => "FB_" . $arFBUser["id"], 'EMAIL' => $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"];
                        if (strlen(SITE_ID) > 0) {
                            $arFields["SITE_ID"] = SITE_ID;
                        }
                        $bSuccess = $this->AuthorizeUser($arFields);
                    }
                }
            }
        }
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");
        $url = $GLOBALS['APPLICATION']->GetCurPageParam($bSuccess === true ? '' : 'auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess, $aRemove);
        if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
            $url = preg_match("/\\?/", $url) ? $url . "&current_fieldset=SOCSERV" : $url . "?current_fieldset=SOCSERV";
        }
        echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \'' . CUtil::JSEscape($url) . '\';
window.close();
</script>
';
        die;
    }
Example #9
0
    public function Authorize()
    {
        $GLOBALS["APPLICATION"]->RestartBuffer();
        $bSuccess = 1;
        $appID = trim(self::GetOption("twitter_key"));
        $appSecret = trim(self::GetOption("twitter_secret"));
        if (!isset($_REQUEST["oauth_token"]) || $_REQUEST["oauth_token"] == '') {
            $tw = new CTwitterInterface($appID, $appSecret);
            $callback = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID);
            //$callback = 'http://algerman.sam:6448/script.php?auth_service_id='.self::ID;
            if ($tw->GetRequestToken($callback)) {
                $tw->RedirectAuthUrl();
            }
        } elseif (CSocServAuthManager::CheckUniqueKey()) {
            $tw = new CTwitterInterface($appID, $appSecret, $_REQUEST["oauth_token"], $_REQUEST["oauth_verifier"]);
            if (($arResult = $tw->GetAccessToken()) !== false && $arResult["user_id"] != '') {
                $twUser = $tw->GetUserInfo($arResult["user_id"]);
                $first_name = $last_name = "";
                if ($twUser["name"] != '') {
                    $aName = explode(" ", $twUser["name"]);
                    $first_name = $aName[0];
                    if (isset($aName[1])) {
                        $last_name = $aName[1];
                    }
                }
                $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arResult["user_id"], 'LOGIN' => $arResult["screen_name"], 'NAME' => $first_name, 'LAST_NAME' => $last_name);
                if (isset($twUser["profile_image_url"]) && self::CheckPhotoURI($twUser["profile_image_url"])) {
                    if ($arPic = CFile::MakeFileArray($twUser["profile_image_url"])) {
                        $arFields["PERSONAL_PHOTO"] = $arPic;
                    }
                }
                $arFields["PERSONAL_WWW"] = "https://twitter.com/" . $arResult["screen_name"];
                if (strlen(SITE_ID) > 0) {
                    $arFields["SITE_ID"] = SITE_ID;
                }
                if (COption::GetOptionString('socialservices', 'last_twit_id', '1') == 1) {
                    if (isset($twUser["status"]["id_str"])) {
                        COption::SetOptionString('socialservices', 'last_twit_id', $twUser["status"]["id_str"]);
                    }
                }
                $bSuccess = $this->AuthorizeUser($arFields);
            }
        }
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "oauth_token", "oauth_verifier", "check_key", "current_fieldset");
        $url = $GLOBALS['APPLICATION']->GetCurPageParam($bSuccess === true ? '' : 'auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess, $aRemove);
        if (CModule::IncludeModule("socialnetwork")) {
            $url = preg_match("/\\?/", $url) ? $url . "&current_fieldset=SOCSERV" : $url . "?current_fieldset=SOCSERV";
        }
        echo '
<script type="text/javascript">
if(window.opener)
	window.opener.location = \'' . CUtil::JSEscape($url) . '\';
window.close();
</script>
';
        die;
    }
Example #10
0
 /**
  * @param $path
  * @return \WS\Tools\ORM\BitrixEntity\File|null
  * @throws \Exception
  */
 public function createByTemporaryPath($path)
 {
     $file = \CFile::MakeFileArray($path);
     $fileId = \CFile::SaveFile($file, '/upload/');
     if ($fileId) {
         $filter = $this->createFilter()->equal('id', $fileId)->toArray();
         return $this->findOne($filter);
     }
     return null;
 }
Example #11
0
function OnAfterUserAuthorizeHandler(&$arFields)
{
    $f = fopen($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/md/log.txt', 'a+');
    global $USER;
    $rsUser = CUser::GetByID($USER->GetId());
    $arUser = $rsUser->Fetch();
    fwrite($f, "---start\n");
    if ($arUser['ID'] > 0 && $arUser['EXTERNAL_AUTH_ID'] == 'Facebook' && $arUser['UF_RULES'] != '1') {
        $facebook = new Facebook_Facebook(array('appId' => '447579571927341', 'secret' => '2f2cf9cd60f9e98d6cf3309e6b7bde5d'));
        $id = $arUser["XML_ID"];
        $user_info = $facebook->api('/' . $id . '?fields=id,name,first_name,middle_name,last_name,gender,birthday,email,picture');
        $props = array();
        if (!$arUser['PERSONAL_GENDER']) {
            if (isset($user_info['gender']) && $user_info['gender']) {
                $props['PERSONAL_GENDER'] = $user_info['gender'] == 'male' ? 'M' : 'F';
            }
        }
        if (!empty($props)) {
            $user = new CUser();
            $user->Update($arUser["ID"], $props);
        }
        CModule::IncludeModule("blog");
        $blogUser = CBlogUser::GetByID($USER->GetId(), BLOG_BY_USER_ID);
        $props = array();
        if (!$blogUser['AVATAR']) {
            if (isset($user_info['picture']) && $user_info['picture']) {
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, "http://graph.facebook.com/{$id}/picture?type=large");
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
                $output = curl_exec($ch);
                if ($output) {
                    $fileName = md5($user_info['picture']);
                    $fullPath = $_SERVER['DOCUMENT_ROOT'] . "/bitrix/cache/social_pictures/{$fileName}.jpg";
                    if (file_put_contents($fullPath, $output) !== false) {
                        $picture = CFile::MakeFileArray($fullPath);
                        $props['AVATAR'] = $picture;
                        $user = new CBlogUser();
                        $user->Update($blogUser["ID"], $props);
                        unlink($fullPath);
                    }
                }
            }
        }
    }
    fwrite($f, "---finish\n");
    fclose($f);
}
Example #12
0
 function UploadAvatar($Url = "", $Folder = "", $FileName = 0, $type = 0)
 {
     $NewAvatar = array();
     if (strlen($Url) > 0) {
         if ($type == 0) {
             $Url = "http://" . parse_url($Url, PHP_URL_HOST) . parse_url($Url, PHP_URL_PATH);
         } elseif ($type == 1) {
             $Url = "https://graph.facebook.com/" . $Url . "/picture?type=large";
         }
         $Avatar = file_get_contents($Url);
         $AvatarPach = $_SERVER["DOCUMENT_ROOT"] . "/upload/" . $Folder . $FileName . ".jpg";
         file_put_contents($AvatarPach, $Avatar);
         if (file_exists($AvatarPach)) {
             $NewAvatar = CFile::MakeFileArray($AvatarPach);
         }
     }
     return $NewAvatar;
 }
Example #13
0
 protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
 {
     $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
     if (empty($file->error)) {
         global $USER;
         $uid = $USER->GetID();
         $rsUser = CUser::GetByID($uid);
         $arUser = $rsUser->Fetch();
         $arFile = CFile::MakeFileArray($_SERVER['DOCUMENT_ROOT'] . "/upload/avatar/thumbnail/" . $file->name);
         $arFile['del'] = "Y";
         $arFile['old_file'] = $arUser['PERSONAL_PHOTO'];
         $arFile["MODULE_ID"] = "main";
         $fields['PERSONAL_PHOTO'] = $arFile;
         $cuser = new CUser();
         $cuser->Update($uid, $fields);
     }
     return $file;
 }
Example #14
0
 function __MPF_ImageResizeHandler(&$arCustomFile)
 {
     $arResizeParams = array("width" => 400, "height" => 400);
     if (!is_array($arCustomFile) || !isset($arCustomFile['fileID'])) {
         return false;
     }
     $fileID = $arCustomFile['fileID'];
     $arFile = CFile::MakeFileArray($fileID);
     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'];
         }
     }
 }
Example #15
0
 private function getArImage($images, $xmlID)
 {
     $arImage = array();
     foreach ($images as $arImg) {
         $img = \CFile::MakeFileArray($arImg);
         //\Helper::pR($img);
         //die();
         if ($img['type'] != 'application/octet-stream') {
             $arImage[] = $img;
         }
         if (!file_exists($img['tmp_name'])) {
             $this->errors = \Helper::boldColorText("Не удалось добавить картинку {$arImg}, для элемента {$xmlID}", "red");
         }
     }
     /*if (!empty($arImage)) {
           \Helper::pR($arImage);
           die();
       }*/
     return $arImage;
 }
Example #16
0
 /**
  * Функция копирования
  * @param $From - откуда $To - куда, $ID
  * @return bool
  */
 static function Copy($From, $To, $ID)
 {
     $result = array();
     foreach ($ID as $key => $value) {
         $res = CIBlockElement::GetByID($value);
         while ($ob = $res->GetNextElement()) {
             $arFields = $ob->GetFields();
             $arProps = $ob->GetProperties();
         }
         foreach ($arProps as $key => $value) {
             $arProp[$key] = $value["VALUE"];
         }
         $el = new CIBlockElement();
         $arLoadProductArray = array("NAME" => str_replace("&nbsp;", " ", htmlspecialchars_decode($arFields["NAME"])), "IBLOCK_ID" => $To, "ACTIVE" => $arFields["ACTIVE"], "DATE_ACTIVE_FROM" => $arFields["DATE_ACTIVE_FROM"], "DATE_ACTIVE_TO" => $arFields["DATE_ACTIVE_TO"], "SORT" => $arFields["SORT"], "PREVIEW_PICTURE" => CFile::MakeFileArray($arFields["PREVIEW_PICTURE"]), "PREVIEW_TEXT" => str_replace("&nbsp;", " ", htmlspecialchars_decode($arFields["PREVIEW_TEXT"])), "PREVIEW_TEXT_TYPE" => $arFields["PREVIEW_TEXT_TYPE"], "DETAIL_PICTURE" => CFile::MakeFileArray($arFields["DETAIL_PICTURE"]), "DETAIL_TEXT" => str_replace("&nbsp;", " ", htmlspecialchars_decode($arFields["DETAIL_TEXT"])), "DETAIL_TEXT_TYPE" => $arFields["DETAIL_TEXT_TYPE"], "SEARCHABLE_CONTENT" => $arFields["SEARCHABLE_CONTENT"], "DATE_CREATE" => $arFields["DATE_CREATE"], "CREATED_BY" => $arFields["CREATED_BY"], "CREATED_USER_NAME" => $arFields["CREATED_USER_NAME"], "TIMESTAMP_X" => $arFields["TIMESTAMP_X"], "MODIFIED_BY" => $arFields["MODIFIED_BY"], "USER_NAME" => $arFields["USER_NAME"], "LANG_DIR" => $arFields["LANG_DIR"], "LIST_PAGE_URL" => $arFields["LIST_PAGE_URL"], "DETAIL_PAGE_URL" => $arFields["DETAIL_PAGE_URL"], "SHOW_COUNTER" => $arFields["SHOW_COUNTER"], "SHOW_COUNTER_START" => $arFields["SHOW_COUNTER_START"], "WF_COMMENTS" => $arFields["WF_COMMENTS"], "WF_STATUS_ID" => $arFields["WF_STATUS_ID"], "LOCK_STATUS" => $arFields["LOCK_STATUS"], "TAGS" => $arFields["TAGS"], "PROPERTY_VALUES" => $arProp);
         if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
             $result[] = "Yes";
         }
     }
     return $result;
 }
Example #17
0
 /**
  * @param array $data
  * @return Main\Entity\AddResult
  */
 public static function send(array $data)
 {
     $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 #18
0
 function __makeFileArray($data, $del = false)
 {
     global $APPLICATION;
     $emptyFile = array("name" => null, "type" => null, "tmp_name" => null, "error" => 4, "size" => 0);
     $result = false;
     if ($del) {
         $result = $emptyFile + array("del" => "Y");
     } elseif (is_null($data)) {
         $result = $emptyFile;
     } elseif (is_string($data)) {
         $io = CBXVirtualIo::GetInstance();
         $normPath = $io->CombinePath("/", $data);
         $absPath = $io->CombinePath($_SERVER["DOCUMENT_ROOT"], $normPath);
         if ($io->ValidatePathString($absPath) && $io->FileExists($absPath)) {
             $perm = $APPLICATION->GetFileAccessPermission($normPath);
             if ($perm >= "W") {
                 $result = CFile::MakeFileArray($io->GetPhysicalName($absPath));
             }
         }
         if ($result === false) {
             $result = $emptyFile;
         }
     } elseif (is_array($data)) {
         if (is_uploaded_file($data["tmp_name"])) {
             $result = $data;
         } else {
             $emptyFile = array("name" => null, "type" => null, "tmp_name" => null, "error" => 4, "size" => 0);
             if ($data == $emptyFile) {
                 $result = $emptyFile;
             }
         }
         if ($result === false) {
             $result = $emptyFile;
         }
     } else {
         $result = $emptyFile;
     }
     return $result;
 }
Example #19
0
 function __CSVExportFile($intFileID, $strExportPath, $strFilePath, $strExportFromClouds = 'Y')
 {
     if ('Y' != $strExportFromClouds) {
         $strExportFromClouds = 'N';
     }
     $arFile = CFile::GetFileArray($intFileID);
     if ($arFile) {
         if ('N' == $strExportFromClouds && 0 < $arFile["HANDLER_ID"]) {
             return serialize($arFile);
         } else {
             $arTempFile = CFile::MakeFileArray($intFileID);
             if (isset($arTempFile["tmp_name"]) && $arTempFile["tmp_name"] != "") {
                 $strFile = $arFile["SUBDIR"] . "/" . $arFile["FILE_NAME"];
                 $strNewFile = str_replace("//", "/", $strExportPath . $strFilePath . $strFile);
                 CheckDirPath($_SERVER['DOCUMENT_ROOT'] . $strNewFile);
                 if (@copy($arTempFile["tmp_name"], $_SERVER['DOCUMENT_ROOT'] . $strNewFile)) {
                     return $strFilePath . $strFile;
                 }
             }
         }
     }
     return '';
 }
Example #20
0
function GetFilrIcon($compPath, $pathQ, $arParams, $arF)
{
    $arMime = array('pdf' => 'pdf.png', 'doc' => 'doc.png', 'docx' => 'doc.png', 'ppt' => 'ppt.png', 'pptx' => 'ppt.png', 'rar' => 'rar.png', 'xls' => 'xls.png', 'xlsx' => 'xls.png', 'zip' => 'zip.png');
    $fIcon = $compPath . "/images/" . "blank.png";
    $fExtQ = strtolower(GetFileExtension($pathQ));
    if ($arParams["RESOURCE_TYPE"] == "IBLOCK") {
        if (CFile::isImage($arF['NAME'])) {
            return $compPath . "/images/img.png";
        }
        $icon = isset($arMime[$fExtQ]) ? $arMime[$fExtQ] : 'blank.png';
        return $compPath . "/images/{$icon}";
    }
    $fileID = $pathQ;
    $arFile = CFile::MakeFileArray($fileID);
    $isPictureExt = false;
    $arPExt = explode(",", CFile::GetImageExtensions());
    foreach ($arPExt as $v) {
        if (strtolower(trim($v)) == $fExtQ) {
            $isPictureExt = true;
            break;
        }
    }
    $isPicture = false;
    if ($isPictureExt && isset($arFile["tmp_name"])) {
        $imgArray = CFile::GetImageSize($arFile["tmp_name"], true);
        if (is_array($imgArray)) {
            if ($arFIcon = CFile::ResizeImageGet($fileID, array("width" => "58", "height" => "58"), BX_RESIZE_IMAGE_EXACT, true)) {
                $fIcon = $arFIcon["src"];
                $isPicture = true;
            }
        }
    }
    if (!$isPicture && array_key_exists($fExtQ, $arMime)) {
        $fIcon = $compPath . "/images/" . $arMime[$fExtQ];
    }
    return $fIcon;
}
Example #21
0
 function getData()
 {
     $data = array();
     $svg = new SimpleXMLElement(file_get_contents($this->xml));
     foreach ($svg->offers->offer as $var) {
         $id = $var->id;
         $url = preg_replace("#http://#i", "", $var->supplier->url);
         $url = preg_replace("#^([^/]+)/.*#i", "\\1", $url);
         $url = str_replace("www.", "", $url);
         $arSelect = array("ID", "NAME");
         if ($this->filterSite($url)) {
             $arFilter = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_SITE" => "%" . $url . "%");
             if ($res = CIBlockElement::GetList(array("SORT" => "DESC"), $arFilter, FALSE, FALSE, $arSelect)->Fetch()) {
                 if (!($resStock = CIBlockElement::GetList(array("SORT" => "DESC"), array("CODE" => $id, "TAGS" => $this->tags), FALSE, FALSE, $arSelect)->Fetch())) {
                     $PROP = array();
                     $PROP["URL"] = trim($var->url);
                     // свойству с кодом 12 присваиваем значение "Белый"
                     $PROP["CLUB_ID"] = intval($res["ID"]);
                     // свойству с кодом 3 присваиваем значение 38
                     $PROP["PRICE"] = intval($var->price);
                     // свойству с кодом 3 присваиваем значение 38
                     $PROP["DISCOUNT"] = intval($var->discount);
                     // свойству с кодом 3 присваиваем значение 38
                     $PROP["DISCOUNTPRICE"] = intval($var->discountprice);
                     // свойству с кодом 3 присваиваем значение 38
                     $PROP["PRICECOUPON"] = intval($var->pricecoupon);
                     // свойству с кодом 3 присваиваем значение 38
                     $PROP["PUBLIC"] = PROP_STOCK_PUBLIC;
                     // свойству с кодом 3 присваиваем значение 38
                     $arLoadProductArray = array("IBLOCK_ID" => IB_SUB_STOCK_ID, "PROPERTY_VALUES" => $PROP, "NAME" => str_replace(array(' "', '" '), array(" «", "» "), trim($var->name)), "ACTIVE_FROM" => date("d.m.Y H:m:s", strtotime($var->beginsell)), "ACTIVE_TO" => date("d.m.Y H:m:s", strtotime($var->endsell)), "CODE" => $id, "TAGS" => trim($this->tags), "ACTIVE" => "Y", "PREVIEW_TEXT" => trim(strip_tags($var->description)), "DETAIL_PICTURE" => CFile::MakeFileArray(trim($var->picture)));
                     $data[] = $arLoadProductArray;
                 }
             }
         }
     }
     return count($data) ? $data : false;
 }
Example #22
0
 public function OnAfterUserAuthorizeHandler(&$arFields)
 {
     global $USER;
     $rsUser = CUser::GetByID($USER->GetId());
     $arUser = $rsUser->Fetch();
     $social = MH_Social_SocialFabric::getSocial($arUser['EXTERNAL_AUTH_ID'], $arUser["XML_ID"]);
     if ($arUser['ID'] > 0 && $arUser['UF_RULES'] != '1') {
         $props = array();
         if (!$arUser['PERSONAL_GENDER']) {
             $props['PERSONAL_GENDER'] = $social->getGender();
         }
         if (!$arUser['PERSONAL_BIRTHDAY']) {
             $props['PERSONAL_BIRTHDAY'] = $social->getBirthday();
         }
         if (!empty($props)) {
             $user = new CUser();
             $user->Update($arUser["ID"], $props);
         }
         CModule::IncludeModule("blog");
         $blogUser = CBlogUser::GetByID($arUser['ID'], BLOG_BY_USER_ID);
         if (!$blogUser || !$blogUser['AVATAR']) {
             $props = array('USER_ID' => $arUser['ID']);
             if ($path = $social->getPicture()) {
                 $picture = CFile::MakeFileArray($path);
                 $props['AVATAR'] = $picture;
                 $user = new CBlogUser();
                 if ($blogUser) {
                     $user->Update($blogUser["ID"], $props);
                 } else {
                     $user->Add($props);
                 }
                 unlink($path);
             }
         }
     }
 }
Example #23
0
 public function prepareUser($arVkUser, $short = false)
 {
     $first_name = $last_name = $gender = "";
     if ($arVkUser['response']['0']['first_name'] != '') {
         $first_name = $arVkUser['response']['0']['first_name'];
     }
     if ($arVkUser['response']['0']['last_name'] != '') {
         $last_name = $arVkUser['response']['0']['last_name'];
     }
     if (isset($arVkUser['response']['0']['sex']) && $arVkUser['response']['0']['sex'] != '') {
         if ($arVkUser['response']['0']['sex'] == '2') {
             $gender = 'M';
         } elseif ($arVkUser['response']['0']['sex'] == '1') {
             $gender = 'F';
         }
     }
     $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arVkUser['response']['0']['uid'], 'LOGIN' => "VKuser" . $arVkUser['response']['0']['uid'], 'EMAIL' => $this->entityOAuth->GetCurrentUserEmail(), 'NAME' => $first_name, 'LAST_NAME' => $last_name, 'PERSONAL_GENDER' => $gender, 'OATOKEN' => $this->entityOAuth->getToken(), 'OATOKEN_EXPIRES' => $this->entityOAuth->getAccessTokenExpires());
     if (isset($arVkUser['response']['0']['photo_max_orig']) && self::CheckPhotoURI($arVkUser['response']['0']['photo_max_orig'])) {
         if (!$short) {
             $arPic = CFile::MakeFileArray($arVkUser['response']['0']['photo_max_orig']);
             if ($arPic) {
                 $arFields["PERSONAL_PHOTO"] = $arPic;
             }
         }
         if (isset($arVkUser['response']['0']['bdate'])) {
             if ($date = MakeTimeStamp($arVkUser['response']['0']['bdate'], "DD.MM.YYYY")) {
                 $arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
             }
         }
         $arFields["PERSONAL_WWW"] = self::getProfileUrl($arVkUser['response']['0']['uid']);
         if (strlen(SITE_ID) > 0) {
             $arFields["SITE_ID"] = SITE_ID;
         }
     }
     return $arFields;
 }
Example #24
0
 if ($arRes["PREVIEW_PICTURE"] > 0) {
     $arImg = CFile::MakeFileArray($arRes["PREVIEW_PICTURE"]);
     CFile::ImageRotate($arImg['tmp_name'], $angle);
     $arFields["PREVIEW_PICTURE"] = CFile::MakeFileArray($arImg['tmp_name']);
 }
 // Detail
 if ($arRes["DETAIL_PICTURE"] > 0) {
     $arImg = CFile::MakeFileArray($arRes["DETAIL_PICTURE"]);
     CFile::ImageRotate($arImg['tmp_name'], $angle);
     $arFields["DETAIL_PICTURE"] = CFile::MakeFileArray($arImg['tmp_name']);
 }
 // Real
 if ($arRes["PROPERTY_REAL_PICTURE_VALUE"] > 0) {
     $arImg = CFile::MakeFileArray($arRes["PROPERTY_REAL_PICTURE_VALUE"]);
     CFile::ImageRotate($arImg['tmp_name'], $angle);
     CIBlockElement::SetPropertyValues($arParams["ELEMENT_ID"], $arParams["IBLOCK_ID"], array("REAL_PICTURE" => CFile::MakeFileArray($arImg['tmp_name'])), "REAL_PICTURE");
 }
 $bs = new CIBlockElement();
 if ($res = $bs->Update($arParams["ELEMENT_ID"], $arFields)) {
     $db_res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
     if ($arRes1 = $db_res->Fetch()) {
         $w = 0;
         $h = 0;
         $src = '';
         $thumb_src = '';
         if ($arRes1["PREVIEW_PICTURE"] > 0) {
             $file = CFile::GetFileArray($arRes1["PREVIEW_PICTURE"]);
             $thumb_src = $file['SRC'];
         }
         if ($arRes1["PROPERTY_REAL_PICTURE_VALUE"] > 0) {
             $file = CFile::GetFileArray($arRes1["PROPERTY_REAL_PICTURE_VALUE"]);
Example #25
0
 function ImportUser()
 {
     if ($this->isErrorOccured) {
         return false;
     }
     $this->errorMessage = "";
     $defaultEmail = $this->GetDefaultEmail();
     if (!($arUser = $this->csv->FetchDelimiter())) {
         return false;
     }
     $arFields = array();
     foreach ($this->arHeader as $index => $key) {
         if (($f = trim($arUser[$index])) != '') {
             $arFields[$key] = $f;
         }
     }
     if (!array_key_exists("NAME", $arFields) || strlen($arFields["NAME"]) < 1) {
         $this->errorMessage = GetMessage("CSV_IMPORT_NO_NAME") . " (" . implode(", ", $arFields) . ").<br>";
         return true;
     }
     if (!array_key_exists("LAST_NAME", $arFields) || strlen($arFields["LAST_NAME"]) < 1) {
         $this->errorMessage = GetMessage("CSV_IMPORT_NO_LASTNAME") . " (" . implode(", ", $arFields) . ").<br>";
         return true;
     }
     if (!array_key_exists("PASSWORD", $arFields) || strlen($arFields["PASSWORD"]) < 1) {
         $arFields["PASSWORD"] = $this->GenerateUserPassword(6);
     }
     $arFields["CONFIRM_PASSWORD"] = $arFields["PASSWORD"];
     if (!array_key_exists("EMAIL", $arFields) || strlen($arFields["EMAIL"]) < 3 || !check_email($arFields["EMAIL"])) {
         $arFields["EMAIL"] = $defaultEmail;
     }
     if (!array_key_exists("LOGIN", $arFields)) {
         $arFields["LOGIN"] = ToLower($arFields["NAME"] . " " . $arFields["LAST_NAME"]);
     }
     if (array_key_exists("PERSONAL_BIRTHDAY", $arFields) && (strlen($arFields["PERSONAL_BIRTHDAY"]) < 2 || !CheckDateTime($arFields["PERSONAL_BIRTHDAY"]))) {
         unset($arFields["PERSONAL_BIRTHDAY"]);
     }
     if (array_key_exists("DATE_REGISTER", $arFields) && (strlen($arFields["DATE_REGISTER"]) < 2 || !CheckDateTime($arFields["DATE_REGISTER"]))) {
         unset($arFields["DATE_REGISTER"]);
     }
     if ($this->externalAuthID !== null && !array_key_exists("EXTERNAL_AUTH_ID", $arFields)) {
         $arFields["EXTERNAL_AUTH_ID"] = $this->externalAuthID;
     }
     if (!array_key_exists("XML_ID", $arFields)) {
         $arFields["XML_ID"] = md5(uniqid(rand(), true));
     }
     if (!array_key_exists("CHECKWORD", $arFields) || strlen($arFields["CHECKWORD"]) <= 0) {
         $arFields["CHECKWORD"] = md5(CMain::GetServerUniqID() . uniqid());
     }
     if ($this->imageFilePath !== null) {
         if (array_key_exists("PERSONAL_PHOTO", $arFields) && strlen($arFields["PERSONAL_PHOTO"]) > 0) {
             $arFile = CFile::MakeFileArray($this->imageFilePath . "/" . $arFields["PERSONAL_PHOTO"]);
             $arFile["MODULE_ID"] = "main";
             $arFields["PERSONAL_PHOTO"] = $arFile;
         }
         if (array_key_exists("WORK_LOGO", $arFields) && strlen($arFields["WORK_LOGO"]) > 0) {
             $arFile = CFile::MakeFileArray($this->imageFilePath . "/" . $arFields["WORK_LOGO"]);
             $arFile["MODULE_ID"] = "main";
             $arFields["WORK_LOGO"] = $arFile;
         }
     } else {
         unset($arFields["PERSONAL_PHOTO"]);
         unset($arFields["WORK_LOGO"]);
     }
     $arFields["GROUP_ID"] = $this->userGroups;
     $user = new CUser();
     $userID = (int) $user->Add($arFields);
     if ($userID <= 0) {
         if ($user->LAST_ERROR != '') {
             $this->errorMessage = $arFields["NAME"] . " " . $arFields["LAST_NAME"] . ": " . $user->LAST_ERROR;
         }
     }
     if ($userID <= 0 && $this->ignoreDuplicate === false) {
         $postFix = 2;
         $login = $arFields["LOGIN"];
         do {
             $rsUser = CUser::GetByLogin($arFields["LOGIN"]);
             if (!$rsUser->Fetch()) {
                 break;
             }
             $arFields["LOGIN"] = $login . $postFix;
             $userID = (int) $user->Add($arFields);
             if ($userID > 1) {
                 break;
             }
             $postFix++;
         } while (true);
     }
     if ($userID > 0) {
         if ($this->attachIBlockID > 0) {
             $iblockSectionID = $this->__GetIBlockSectionID($arFields);
             if ($iblockSectionID > 0) {
                 if (!$this->isUserPropertyCreate) {
                     $this->isUserPropertyCreate = $this->__CreateUserProperty();
                 }
                 $arUpdate = array();
                 $arUpdate[$this->userPropertyName] = array($iblockSectionID);
                 $user->Update($userID, $arUpdate);
             }
         }
         if ($this->callback !== null) {
             call_user_func_array($this->callback, array(&$arFields, &$userID));
         }
     }
     return true;
 }
     }
 }
 //add logotip
 $arPicture = array();
 if (array_key_exists("LOGOTIP_" . $arPersonType["ID"], $_FILES) && $_FILES["LOGOTIP_" . $arPersonType["ID"]]["error"] == 0) {
     $arPicture = $_FILES["LOGOTIP_" . $arPersonType["ID"]];
 } elseif ($actionID <= 0) {
     $logo = "";
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . ${"ACTION_FILE_" . $arPersonType["ID"]} . "/logo.png")) {
         $logo = $_SERVER["DOCUMENT_ROOT"] . ${"ACTION_FILE_" . $arPersonType["ID"]} . "/logo.png";
     } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . ${"ACTION_FILE_" . $arPersonType["ID"]} . "/logo.jpg")) {
         $logo = $_SERVER["DOCUMENT_ROOT"] . ${"ACTION_FILE_" . $arPersonType["ID"]} . "/logo.jpg";
     } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . ${"ACTION_FILE_" . $arPersonType["ID"]} . "/logo.gif")) {
         $logo = $_SERVER["DOCUMENT_ROOT"] . ${"ACTION_FILE_" . $arPersonType["ID"]} . "/logo.gif";
     }
     $arPicture = CFile::MakeFileArray($logo);
 }
 $arPicture["old_file"] = $arPSAction["LOGOTIP"];
 $arPicture["del"] = trim($_POST["LOGOTIP_" . $arPersonType["ID"] . "_del"]);
 $arFields = array("PAY_SYSTEM_ID" => $ID, "PERSON_TYPE_ID" => $arPersonType["ID"], "NAME" => ${"NAME_" . $arPersonType["ID"]}, "ACTION_FILE" => ${"ACTION_FILE_" . $arPersonType["ID"]}, "NEW_WINDOW" => ${"NEW_WINDOW_" . $arPersonType["ID"]} == "Y" ? "Y" : "N", "PARAMS" => CSalePaySystemAction::SerializeParams($arParams), "HAVE_PREPAY" => "N", "HAVE_RESULT" => "N", "HAVE_ACTION" => "N", "HAVE_PAYMENT" => "N", "HAVE_RESULT_RECEIVE" => "N", "ENCODING" => trim(${"ENCODING_" . $arPersonType["ID"]}), "LOGOTIP" => $arPicture);
 $pathToAction = $_SERVER["DOCUMENT_ROOT"] . ${"ACTION_FILE_" . $arPersonType["ID"]};
 $pathToAction = str_replace("\\", "/", $pathToAction);
 while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") {
     $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1);
 }
 if (file_exists($pathToAction)) {
     if (is_dir($pathToAction)) {
         if (file_exists($pathToAction . "/pre_payment.php")) {
             $arFields["HAVE_PREPAY"] = "Y";
         }
         if (file_exists($pathToAction . "/result.php")) {
Example #27
0
function add_elements_from_file($filename, $iblock_id, $section_id, $series_name, $series_title_prefix, $price_multiplier, $common_options)
{
    $file = file($filename);
    $e1 = array_map(function ($row2) {
        return explode(';', $row2);
    }, $file);
    $el_count = count($e1);
    for ($i = 1; $i < $el_count; $i++) {
        test_dump($i);
        $row = $e1[$i];
        test_dump($row);
        $BRAND_REF = "itprom";
        $TB_WIDTH = $row[3];
        $TB_HEIGHT = $row[2];
        $TB_DEPTH = $row[4];
        $PRICE_EUR = $row[7];
        $w = intval($TB_WIDTH);
        $h = intval($TB_HEIGHT);
        $d = intval($TB_DEPTH);
        test_dump(array($w, $h, $d));
        $TP_IP_CLASS = "";
        if ($row[1] == "21-30") {
            $TP_IP_CLASS = 164;
        } elseif ($row[1] == "21-32") {
            $TP_IP_CLASS = 165;
        } elseif ($row[1] == "21-33") {
            $TP_IP_CLASS = 166;
        } elseif ($row[1] == "21-35") {
            $TP_IP_CLASS = 167;
        }
        //Раннев сказал везде делать 31
        $TP_IP_CLASS = 168;
        $ARTNUMBER = "arm19" . "-" . $w / 10 . $h / 10 . $d . "_" . $TP_IP_CLASS;
        $NAME = $row[0];
        $MORE_PHOTO = array();
        $MORE_PHOTO_2D = array();
        if ($h > 1100) {
            $DETAIL_PICTURE = CFile::MakeFileArray("images/19inch/shkaf3.jpg");
            $MORE_PHOTO[] = array();
        } else {
            $DETAIL_PICTURE = CFile::MakeFileArray("images/19inch/shkaf1.jpg");
            $MORE_PHOTO[] = array(CFile::MakeFileArray("images/19inch/shkaf2.jpg"));
        }
        $TB_SERIES = "";
        $P = array("ARTNUMBER" => $ARTNUMBER, "BRAND_REF" => $BRAND_REF, "TB_SERIES" => $TB_SERIES, "TB_WIDTH" => $TB_WIDTH, "TB_HEIGHT" => $TB_HEIGHT, "TB_DEPTH" => $TB_DEPTH, "TP_IP_CLASS" => $TP_IP_CLASS, "MORE_PHOTO" => $MORE_PHOTO, "DESCRIPTION_TEXT" => $row[5]);
        $PRICE_EUR = floatval($PRICE_EUR) * $price_multiplier;
        if ($w * $w + $h * $h + $d * $d != 0) {
            test_dump(array($iblock_id, $section_id, $series_title_prefix . " " . $NAME, $PRICE_EUR, $P, $DETAIL_PICTURE));
            add_element($iblock_id, $section_id, $series_title_prefix . " " . $NAME, $PRICE_EUR, $P, $DETAIL_PICTURE);
        } else {
            echo "Не добавлен!<br>";
            echo $w . " " . $h . " " . $d . "<br>";
        }
    }
}
Example #28
0
                     }
                 }
                 if (!isset($arPropertyListCache[$cur_prop_id][$propValueHash])) {
                     $arPropertyListCache[$cur_prop_id][$propValueHash] = CIBlockPropertyEnum::Add(array("PROPERTY_ID" => $arIBlockProperty[$cur_prop_id]['ID'], "VALUE" => $arRes[$i], "TMP_ID" => $tmpid));
                 }
                 if (isset($arPropertyListCache[$cur_prop_id][$propValueHash])) {
                     $arRes[$i] = $arPropertyListCache[$cur_prop_id][$propValueHash];
                 } else {
                     $arRes[$i] = '';
                 }
             }
         } elseif ($arIBlockProperty[$cur_prop_id]["PROPERTY_TYPE"] == "F") {
             if (preg_match("/^(http|https):\\/\\//", $arRes[$i])) {
                 $arRes[$i] = CFile::MakeFileArray($arRes[$i]);
             } else {
                 $arRes[$i] = CFile::MakeFileArray($io->GetPhysicalName($_SERVER["DOCUMENT_ROOT"] . $PATH2IMAGE_FILES . '/' . $arRes[$i]));
             }
             if (!is_array($arRes[$i]) || !array_key_exists("tmp_name", $arRes[$i])) {
                 $arRes[$i] = '';
             }
         }
         if ($arIBlockProperty[$cur_prop_id]["MULTIPLE"] == "Y") {
             if (!isset($arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id]) || !is_array($arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id]) || !in_array(trim($arRes[$i]), $arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id])) {
                 $arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id][] = is_array($arRes[$i]) ? $arRes[$i] : trim($arRes[$i]);
             }
             $PROP[$cur_prop_id] = $arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id];
         } else {
             $PROP[$cur_prop_id][] = is_array($arRes[$i]) ? $arRes[$i] : trim($arRes[$i]);
         }
     }
 }
Example #29
0
 function OnCommentAdd($entityType, $entityID, &$arPost)
 {
     global $USER;
     $arParams =& $this->component->arParams;
     $arResult =& $this->component->arResult;
     $arForum =& $arResult['FORUM'];
     $iFileSize = intval(COption::GetOptionString("forum", "file_max_size", 50000));
     $arCommentParams = array("FORUM_ID" => $arParams["FORUM_ID"], "TOPIC_ID" => null, "USER_ID" => $USER->IsAuthorized() ? $USER->GetID() : null);
     $arFiles = $arNewFiles = array();
     if (isset($_REQUEST['FILE_NEW']) && is_array($_REQUEST['FILE_NEW'])) {
         foreach ($_REQUEST['FILE_NEW'] as $val) {
             $arNewFiles[$val] = array("FILE_ID" => $val);
         }
     }
     if (isset($_REQUEST['FILES']) && is_array($_REQUEST['FILES'])) {
         foreach ($_REQUEST['FILES'] as $val) {
             if (in_array($val, $_REQUEST["FILES_TO_UPLOAD"])) {
                 $arFiles[$val] = array("FILE_ID" => $val);
             }
         }
     }
     if (!empty($arNewFiles)) {
         CForumFiles::Add(array_keys($arNewFiles), $arCommentParams);
     }
     $arFiles = $arFiles + $arNewFiles;
     if (!isset($arPost['FILES'])) {
         $arPost['FILES'] = array();
     }
     $arPost['FILES'] = array_merge($arPost['FILES'], $arFiles);
     foreach ($arPost['FILES'] as $fileIndex => $fileArr) {
         $fileID = $fileArr['FILE_ID'];
         $attach_file = CFile::MakeFileArray(intval($fileID));
         $attach = "";
         if ($attach_file && is_set($attach_file, "name")) {
             // Y - Image files		F - Files of specified type		A - All files
             if ($arForum["ALLOW_UPLOAD"] == "Y") {
                 $attach = CFile::CheckImageFile($attach_file, $iFileSize, 0, 0);
             } elseif ($arForum["ALLOW_UPLOAD"] == "F") {
                 $attach = CFile::CheckFile($attach_file, $iFileSize, false, $arForum["ALLOW_UPLOAD_EXT"]);
             } elseif ($arForum["ALLOW_UPLOAD"] == "A") {
                 $attach = CFile::CheckFile($attach_file, $iFileSize, false, false);
             }
             if ($attach != '') {
                 unset($arPost['FILES'][$fileIndex]);
                 $arPost['ERROR'] = $attach_file['name'] . ': ' . $attach;
                 return false;
             }
         }
     }
 }
Example #30
0
            if ($delivery["russianpost"] != "Y") {
                $arFields["ACTIVE"] = "N";
            }
            CSaleDeliveryHandler::Set("russianpost", $arFields);
        }
        $arFields = array("LID" => "", "ACTIVE" => "Y", "HID" => "ups", "NAME" => "UPS", "SORT" => 300, "DESCRIPTION" => GetMessage("SALE_WIZARD_UPS"), "HANDLERS" => "/bitrix/modules/sale/delivery/delivery_ups.php", "SETTINGS" => "/bitrix/modules/sale/delivery/ups/ru_csv_zones.csv;/bitrix/modules/sale/delivery/ups/ru_csv_export.csv", "PROFILES" => "", "TAX_RATE" => 0);
        if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/delivery/" . $arFields["HID"] . "_logo.gif")) {
            $arFields["LOGOTIP"] = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/delivery/" . $arFields["HID"] . "_logo.gif");
        }
        if ($delivery["ups"] != "Y") {
            $arFields["ACTIVE"] = "N";
        }
        CSaleDeliveryHandler::Set("ups", $arFields);
        $arFields = array("LID" => "", "ACTIVE" => "Y", "HID" => "dhlusa", "NAME" => "DHL (USA)", "SORT" => 300, "DESCRIPTION" => GetMessage("SALE_WIZARD_UPS"), "HANDLERS" => "/bitrix/modules/sale/delivery/delivery_dhl_usa.php ", "SETTINGS" => "", "PROFILES" => "", "TAX_RATE" => 0);
        if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/delivery/" . $arFields["HID"] . "_logo.gif")) {
            $arFields["LOGOTIP"] = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/delivery/" . $arFields["HID"] . "_logo.gif");
        }
        if ($delivery["dhl"] != "Y") {
            $arFields["ACTIVE"] = "N";
        }
        CSaleDeliveryHandler::Set("dhlusa", $arFields);
    }
}
if (CModule::IncludeModule('subscribe')) {
    $templates_dir = $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/subscribe/templates";
    $template = $templates_dir . "/store_news_" . WIZARD_SITE_ID;
    //Copy template from module if where was no template
    if (!file_exists($template)) {
        CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/subscribe/install/php_interface/subscribe/templates/news", $template, false, true);
        $fname = $template . "/template.php";
        if (file_exists($fname) && is_file($fname) && ($fh = fopen($fname, "rb"))) {