当前位置: 首页>>代码示例>>PHP>>正文


PHP CFile::GetTempName方法代码示例

本文整理汇总了PHP中CFile::GetTempName方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::GetTempName方法的具体用法?PHP CFile::GetTempName怎么用?PHP CFile::GetTempName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFile的用法示例。


在下文中一共展示了CFile::GetTempName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareUser

 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;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:facebook.php

示例2: prepareUser

 public function prepareUser($yandexUser, $short = false)
 {
     $id = $yandexUser['id'];
     $userFields = array('EXTERNAL_AUTH_ID' => static::ID, 'XML_ID' => $id, 'LOGIN' => static::LOGIN_PREFIX . $id, 'NAME' => $yandexUser['first_name'], 'LAST_NAME' => $yandexUser['last_name'], 'OATOKEN' => $this->entityOAuth->getToken(), 'OATOKEN_EXPIRES' => $this->entityOAuth->getAccessTokenExpires());
     if (strlen($userFields["NAME"]) <= 0) {
         $userFields["NAME"] = $yandexUser["login"];
     }
     if (isset($yandexUser["emails"]) && is_array($yandexUser["emails"]) && count($yandexUser["emails"]) > 0) {
         $userFields["EMAIL"] = $yandexUser['emails'][0];
     }
     if (!$short && !empty($yandexUser['default_avatar_id'])) {
         $picture_url = "https://avatars.yandex.net/get-yapic/" . $yandexUser["default_avatar_id"] . "/islands-200";
         $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) {
             $userFields["PERSONAL_PHOTO"] = $arPic;
         }
     }
     if (strlen(SITE_ID) > 0) {
         $userFields["SITE_ID"] = SITE_ID;
     }
     return $userFields;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:25,代码来源:yandex.php

示例3: MakeFileArray

 function MakeFileArray($path, $mimetype = false)
 {
     $io = CBXVirtualIo::GetInstance();
     $arFile = array();
     if (intval($path) > 0) {
         $res = CFile::GetByID($path);
         if ($ar = $res->Fetch()) {
             $bExternalStorage = false;
             foreach (GetModuleEvents("main", "OnMakeFileArray", true) as $arEvent) {
                 if (ExecuteModuleEventEx($arEvent, array($ar, &$arFile))) {
                     $bExternalStorage = true;
                     break;
                 }
             }
             if (!$bExternalStorage) {
                 $arFile["name"] = strlen($ar['ORIGINAL_NAME']) > 0 ? $ar['ORIGINAL_NAME'] : $ar['FILE_NAME'];
                 $arFile["size"] = $ar['FILE_SIZE'];
                 $arFile["type"] = $ar['CONTENT_TYPE'];
                 $arFile["description"] = $ar['DESCRIPTION'];
                 $arFile["tmp_name"] = $io->GetPhysicalName(preg_replace("#[\\\\\\/]+#", "/", $_SERVER['DOCUMENT_ROOT'] . '/' . COption::GetOptionString('main', 'upload_dir', 'upload') . '/' . $ar['SUBDIR'] . '/' . $ar['FILE_NAME']));
             }
             return $arFile;
         }
     }
     $path = preg_replace("#(?<!:)[\\\\\\/]+#", "/", $path);
     if (strlen($path) == 0 || $path == "/") {
         return NULL;
     }
     if (preg_match("#^(http[s]?)://#", $path)) {
         $temp_path = '';
         $bExternalStorage = false;
         foreach (GetModuleEvents("main", "OnMakeFileArray", true) as $arEvent) {
             if (ExecuteModuleEventEx($arEvent, array($path, &$temp_path))) {
                 $bExternalStorage = true;
                 break;
             }
         }
         if (!$bExternalStorage) {
             $temp_path = CFile::GetTempName('', bx_basename($path));
             $ob = new CHTTP();
             $ob->follow_redirect = true;
             if ($ob->Download($path, $temp_path)) {
                 $arFile = CFile::MakeFileArray($temp_path);
             }
         } elseif ($temp_path) {
             $arFile = CFile::MakeFileArray($temp_path);
         }
     } elseif (preg_match("#^(ftp[s]?|php)://#", $path)) {
         if ($fp = fopen($path, "rb")) {
             $content = "";
             while (!feof($fp)) {
                 $content .= fgets($fp, 4096);
             }
             if (strlen($content) > 0) {
                 $temp_path = CFile::GetTempName('', bx_basename($path));
                 if (RewriteFile($temp_path, $content)) {
                     $arFile = CFile::MakeFileArray($temp_path);
                 }
             }
             fclose($fp);
         }
     } else {
         if (!file_exists($path)) {
             if (file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) {
                 $path = $_SERVER["DOCUMENT_ROOT"] . $path;
             } else {
                 return NULL;
             }
         }
         if (is_dir($path)) {
             return NULL;
         }
         $arFile["name"] = $io->GetLogicalName(bx_basename($path));
         $arFile["size"] = filesize($path);
         $arFile["tmp_name"] = $path;
         $arFile["type"] = $mimetype;
         if (strlen($arFile["type"]) <= 0) {
             $arFile["type"] = CFile::GetContentType($path, true);
         }
     }
     if (strlen($arFile["type"]) <= 0) {
         $arFile["type"] = "unknown";
     }
     return $arFile;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:85,代码来源:file.php

示例4: OnMakeFileArray

 public static function OnMakeFileArray($arSourceFile, &$arDestination)
 {
     if (!is_array($arSourceFile)) {
         $file = $arSourceFile;
         if (substr($file, 0, strlen($_SERVER["DOCUMENT_ROOT"])) == $_SERVER["DOCUMENT_ROOT"]) {
             $file = ltrim(substr($file, strlen($_SERVER["DOCUMENT_ROOT"])), "/");
         }
         if (!preg_match("/^http:\\/\\//", $file)) {
             return false;
         }
         $bucket = CCloudStorage::FindBucketByFile($file);
         if (!is_object($bucket)) {
             return false;
         }
         $filePath = substr($file, strlen($bucket->GetFileSRC("/")) - 1);
         $filePath = urldecode($filePath);
         $target = CFile::GetTempName('', bx_basename($filePath));
         $target = preg_replace("#[\\\\\\/]+#", "/", $target);
         if ($bucket->DownloadToFile($filePath, $target)) {
             $arDestination = $target;
         }
         return true;
     } else {
         if ($arSourceFile["HANDLER_ID"] <= 0) {
             return false;
         }
         $bucket = new CCloudStorageBucket($arSourceFile["HANDLER_ID"]);
         if (!$bucket->Init()) {
             return false;
         }
         $target = CFile::GetTempName('', $arSourceFile["FILE_NAME"]);
         $target = preg_replace("#[\\\\\\/]+#", "/", $target);
         if ($bucket->DownloadToFile($arSourceFile, $target)) {
             $arDestination["name"] = strlen($arSourceFile['ORIGINAL_NAME']) > 0 ? $arSourceFile['ORIGINAL_NAME'] : $arSourceFile['FILE_NAME'];
             $arDestination["size"] = $arSourceFile['FILE_SIZE'];
             $arDestination["type"] = $arSourceFile['CONTENT_TYPE'];
             $arDestination["description"] = $arSourceFile['DESCRIPTION'];
             $arDestination["tmp_name"] = $target;
         }
         return true;
     }
 }
开发者ID:rasuldev,项目名称:torino,代码行数:42,代码来源:storage.php

示例5: prepareUser

 public function prepareUser($boxUser, $short = false)
 {
     $nameDetails = explode(" ", $boxUser['name'], 2);
     $id = $boxUser['id'];
     $arFields = array('EXTERNAL_AUTH_ID' => static::ID, 'XML_ID' => $id, 'LOGIN' => static::LOGIN_PREFIX . $id, 'NAME' => $nameDetails[0], 'LAST_NAME' => $nameDetails[1], 'EMAIL' => $boxUser["login"], 'OATOKEN' => $this->entityOAuth->getToken(), 'OATOKEN_EXPIRES' => $this->entityOAuth->getAccessTokenExpires(), 'REFRESH_TOKEN' => $this->entityOAuth->getRefreshToken());
     if (!$short && !empty($boxUser['avatar_url'])) {
         $picture_url = $boxUser['avatar_url'];
         $temp_path = CFile::GetTempName('', 'picture.jpg');
         $ob = new HttpClient(array("redirect" => true));
         $ob->download($picture_url, $temp_path);
         $arPic = CFile::MakeFileArray($temp_path);
         if ($arPic) {
             $arFields["PERSONAL_PHOTO"] = $arPic;
         }
     }
     if (strlen(SITE_ID) > 0) {
         $arFields["SITE_ID"] = SITE_ID;
     }
     return $arFields;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:20,代码来源:box.php

示例6: saveImage

 /**
  * @param string $url Image's URL.
  * @return integer Saved file identifier
  */
 protected static function saveImage($url)
 {
     $fileId = false;
     $file = new \CFile();
     $httpClient = new HttpClient();
     $httpClient->setTimeout(5);
     $httpClient->setStreamTimeout(5);
     $urlComponents = parse_url($url);
     if ($urlComponents && strlen($urlComponents["path"]) > 0) {
         $tempPath = $file->GetTempName('', bx_basename($urlComponents["path"]));
     } else {
         $tempPath = $file->GetTempName('', bx_basename($url));
     }
     $httpClient->download($url, $tempPath);
     $fileName = $httpClient->getHeaders()->getFilename();
     $localFile = \CFile::MakeFileArray($tempPath);
     if (is_array($localFile)) {
         if (strlen($fileName) > 0) {
             $localFile['name'] = $fileName;
         }
         if (\CFile::CheckImageFile($localFile, 0, 0, 0, array("IMAGE")) === null) {
             $fileId = $file->SaveFile($localFile, 'urlpreview', true);
         }
     }
     return $fileId === false ? null : $fileId;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:30,代码来源:urlpreview.php

示例7: Authorize

    public function Authorize()
    {
        global $APPLICATION;
        $APPLICATION->RestartBuffer();
        $authError = SOCSERV_AUTHORISATION_ERROR;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && 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"));
            }
            $this->entityOAuth = new CFacebookInterface(false, false, $_REQUEST["code"]);
            if ($this->entityOAuth->GetAccessToken($redirect_uri) !== false) {
                $arFBUser = $this->entityOAuth->GetCurrentUser();
                if (is_array($arFBUser) && isset($arFBUser["id"])) {
                    $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 (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;
                    }
                    $authError = $this->AuthorizeUser($arFields);
                }
            }
        }
        $bSuccess = $authError === true;
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");
        if ($bSuccess) {
            CSocServUtil::checkOAuthProxyParams();
            $url = $GLOBALS["APPLICATION"]->GetCurDir() == "/login/" ? "" : $GLOBALS["APPLICATION"]->GetCurDir();
            if (isset($_REQUEST['backurl'])) {
                $parseUrl = parse_url($_REQUEST['backurl']);
                $urlPath = $parseUrl["path"];
                $arUrlQuery = explode('&', $parseUrl["query"]);
                foreach ($arUrlQuery as $key => $value) {
                    foreach ($aRemove as $param) {
                        if (strpos($value, $param . "=") === 0) {
                            unset($arUrlQuery[$key]);
                            break;
                        }
                    }
                }
                $url = !empty($arUrlQuery) ? $urlPath . '?' . implode("&", $arUrlQuery) : $urlPath;
            }
        }
        if ($authError === SOCSERV_REGISTRATION_DENY) {
            $url = preg_match("/\\?/", $url) ? $url . '&' : $url . '?';
            $url .= 'auth_service_id=' . self::ID . '&auth_service_error=' . $authError;
        } elseif ($bSuccess !== true) {
            $url = isset($urlPath) ? $urlPath . '?auth_service_id=' . self::ID . '&auth_service_error=' . $authError : $GLOBALS['APPLICATION']->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $authError, $aRemove);
        }
        if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
            $url .= (strpos($url, "?") === false ? '?' : '&') . "current_fieldset=SOCSERV";
        }
        ?>
<script type="text/javascript">
if(window.opener)
	window.opener.location = '<?php 
        echo CUtil::JSEscape($url);
        ?>
';
window.close();
</script>
<?php 
        die;
    }
开发者ID:rasuldev,项目名称:torino,代码行数:87,代码来源:facebook.php


注:本文中的CFile::GetTempName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。