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


PHP CHTTP::Download方法代码示例

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


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

示例1: DownloadToFile

 function DownloadToFile($arBucket, $arFile, $filePath)
 {
     $io = CBXVirtualIo::GetInstance();
     $obRequest = new CHTTP();
     $obRequest->follow_redirect = true;
     return $obRequest->Download($this->GetFileSRC($arBucket, $arFile), $io->GetPhysicalName($filePath));
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:7,代码来源:storage_service_google.php

示例2: 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

示例3: Scan

 function Scan($path)
 {
     $this->path = $path;
     if ($arCloudFiles = CBackup::GetBucketFileList($this->id, $path)) {
         foreach ($arCloudFiles['file'] as $k => $file) {
             if ($this->last_bucket_path) {
                 if ($path . '/' . $file == $this->last_bucket_path) {
                     $this->last_bucket_path = '';
                 } else {
                     continue;
                 }
             }
             $name = $this->path = $path . '/' . $file;
             if (!haveTime()) {
                 // Сохраняется путь файла, который еще предстоит сохранить, TODO: пошаговое скачивание больших файлов
                 return false;
             }
             $HTTP = new CHTTP();
             if ($HTTP->Download($this->obBucket->GetFileSRC(array("URN" => $name)), DOCUMENT_ROOT . BX_ROOT . '/backup/clouds/' . $this->id . $name)) {
                 $this->download_size += $arCloudFiles['file_size'][$k];
                 $this->download_cnt++;
             } else {
                 $this->arSkipped[] = $name;
             }
         }
     }
     foreach ($arCloudFiles['dir'] as $dir) {
         if ($this->last_bucket_path) {
             if ($path . '/' . $dir == $this->last_bucket_path) {
                 $this->last_bucket_path = '';
             } elseif (strpos($this->last_bucket_path, $path . '/' . $dir) !== 0) {
                 continue;
             }
         }
         if ($path . '/' . $dir == '/bitrix/backup') {
             continue;
         }
         if ($path . '/' . $dir == '/tmp') {
             continue;
         }
         if (!$this->Scan($path . '/' . $dir)) {
             // partial
             return false;
         }
     }
     return true;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:47,代码来源:backup.php

示例4: CHTTP

	function check_ca_file()
	{
		if (file_exists($this->cafile))
			unlink($this->cafile);
		CheckDirPath($this->cafile);
		$ob = new CHTTP();
		$ob->http_timeout = 5;
		if ($ob->Download('http://www.bitrixsoft.com/upload/lib/cafile.pem', $this->cafile) && is_file($this->cafile) && filesize($this->cafile) > 0)
			return true;
		return $this->Result(null, GetMessage("MAIN_SC_NO_ACCESS").'&quot;');
	}
开发者ID:nycmic,项目名称:bittest,代码行数:11,代码来源:site_checker.php

示例5: Scan

	public function Scan($path)
	{
		$this->path = $path;

		if ($arCloudFiles = CBackup::GetBucketFileList($this->id, $path))
		{
			foreach($arCloudFiles['file'] as $k=>$file)
			{
				if ($this->last_bucket_path)
				{
					if ($path.'/'.$file == $this->last_bucket_path)
						$this->last_bucket_path = '';
					else
						continue;
				}

				$name = $this->path = $path.'/'.$file;
				if (!haveTime()) // Сохраняется путь файла, который еще предстоит сохранить, TODO: пошаговое скачивание больших файлов
					return false;

				$HTTP = new CHTTP;
				if ($HTTP->Download($this->obBucket->GetFileSRC(array("URN" => $name)), DOCUMENT_ROOT.BX_ROOT.'/backup/clouds/'.$this->id.$name))
				{
					$this->download_size += $arCloudFiles['file_size'][$k];
					$this->download_cnt++;
				}
				else
					$this->arSkipped[] = $name;
			}
		}

		foreach($arCloudFiles['dir'] as $dir)
		{
			if ($this->last_bucket_path)
			{
				if ($path.'/'.$dir == $this->last_bucket_path)
					$this->last_bucket_path = '';
				elseif (strpos($this->last_bucket_path, $path.'/'.$dir) !== 0)
					continue;
			}

			if ($path.'/'.$dir == '/bitrix/backup')
				continue;

			if ($path.'/'.$dir == '/tmp')
				continue;

			if (!$this->Scan($path.'/'.$dir)) // partial
				return false;
		}

		return true;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:53,代码来源:backup.php


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