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


PHP FileUtil::downloadFileFromHttp方法代码示例

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


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

示例1: validate

 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     // check if file is uploaded or linked
     if (!empty($this->file['tmp_name'])) {
         $this->backup = $this->file['tmp_name'];
     } else {
         if ($this->fileLink != '') {
             //check if file is external url
             if (FileUtil::isURL($this->fileLink)) {
                 try {
                     //download file
                     $this->backup = FileUtil::downloadFileFromHttp($this->fileLink, 'cms_backup');
                 } catch (SystemException $e) {
                     //download failed
                     throw new UserInputException('fileLink', 'downloadFailed');
                 }
             } else {
                 //file not found
                 if (!file_exists($this->fileLink)) {
                     throw new UserInputException('fileLink', 'notFound');
                 } else {
                     $this->backup = $this->fileLink;
                 }
             }
         } else {
             throw new UserInputException('file', 'empty');
         }
     }
 }
开发者ID:knzo,项目名称:Fireball,代码行数:33,代码来源:CMSImportForm.class.php

示例2: execute

 /**
  * @see wcf\system\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     $filename = FileUtil::downloadFileFromHttp('http://www.woltlab.com/spiderlist/spiderlist.xml', 'spiders');
     $xml = new XML();
     $xml->load($filename);
     $xpath = $xml->xpath();
     // fetch spiders
     $spiders = $xpath->query('/spiderlist/spider');
     if (count($spiders)) {
         // delete old entries
         $sql = "DELETE FROM wcf" . WCF_N . "_spider";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute();
         $statementParameters = array();
         foreach ($spiders as $spider) {
             $identifier = StringUtil::toLowerCase($spider->getAttribute('ident'));
             $name = $xpath->query('name', $spider)->item(0);
             $info = $xpath->query('info', $spider)->item(0);
             $statementParameters[$identifier] = array('spiderIdentifier' => $identifier, 'spiderName' => $name->nodeValue, 'spiderURL' => $info ? $info->nodeValue : '');
         }
         if (!empty($statementParameters)) {
             $sql = "INSERT INTO\twcf" . WCF_N . "_spider\n\t\t\t\t\t\t\t(spiderIdentifier, spiderName, spiderURL)\n\t\t\t\t\tVALUES\t\t(?, ?, ?)";
             $statement = WCF::getDB()->prepareStatement($sql);
             foreach ($statementParameters as $parameters) {
                 $statement->execute(array($parameters['spiderIdentifier'], $parameters['spiderName'], $parameters['spiderURL']));
             }
         }
         // clear spider cache
         CacheHandler::getInstance()->clear(WCF_DIR . 'cache', 'cache.spiders.php');
     }
     // delete tmp file
     @unlink($filename);
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:36,代码来源:RefreshSearchRobotsCronjob.class.php

示例3: execute

 /**
  * @see	\wcf\system\ICronjob::execute()
  */
 public function execute(Cronjob $cronjob)
 {
     $filename = FileUtil::downloadFileFromHttp('http://assets.woltlab.com/spiderlist/typhoon/list.xml', 'spiders');
     $xml = new XML();
     $xml->load($filename);
     $xpath = $xml->xpath();
     // fetch spiders
     $spiders = $xpath->query('/ns:data/ns:spider');
     if (!empty($spiders)) {
         $existingSpiders = SpiderCacheBuilder::getInstance()->getData();
         $statementParameters = array();
         foreach ($spiders as $spider) {
             $identifier = mb_strtolower($spider->getAttribute('ident'));
             $name = $xpath->query('ns:name', $spider)->item(0);
             $info = $xpath->query('ns:url', $spider)->item(0);
             $statementParameters[$identifier] = array('spiderIdentifier' => $identifier, 'spiderName' => $name->nodeValue, 'spiderURL' => $info ? $info->nodeValue : '');
         }
         if (!empty($statementParameters)) {
             $sql = "INSERT INTO\t\t\twcf" . WCF_N . "_spider\n\t\t\t\t\t\t\t\t\t(spiderIdentifier, spiderName, spiderURL)\n\t\t\t\t\tVALUES\t\t\t\t(?, ?, ?)\n\t\t\t\t\tON DUPLICATE KEY UPDATE\t\tspiderName = VALUES(spiderName),\n\t\t\t\t\t\t\t\t\tspiderURL = VALUES(spiderURL)";
             $statement = WCF::getDB()->prepareStatement($sql);
             WCF::getDB()->beginTransaction();
             foreach ($statementParameters as $parameters) {
                 $statement->execute(array($parameters['spiderIdentifier'], $parameters['spiderName'], $parameters['spiderURL']));
             }
             WCF::getDB()->commitTransaction();
         }
         // delete obsolete entries
         $sql = "DELETE FROM wcf" . WCF_N . "_spider WHERE spiderIdentifier = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         foreach ($existingSpiders as $spider) {
             if (!isset($statementParameters[$spider->spiderIdentifier])) {
                 $statement->execute(array($spider->spiderIdentifier));
             }
         }
         // clear spider cache
         SpiderCacheBuilder::getInstance()->reset();
     }
     // delete tmp file
     @unlink($filename);
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:43,代码来源:RefreshSearchRobotsCronjob.class.php

示例4: test

 /**
  * Checks a given email address for gravatar support.
  * 
  * @param	string		$email
  * @return	boolean
  */
 public static function test($email)
 {
     $gravatarURL = sprintf(self::GRAVATAR_BASE, md5(mb_strtolower($email)), 80, GRAVATAR_DEFAULT_TYPE);
     try {
         $tmpFile = FileUtil::downloadFileFromHttp($gravatarURL, 'gravatar');
         @unlink($tmpFile);
         return true;
     } catch (SystemException $e) {
         return false;
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:17,代码来源:Gravatar.class.php

示例5: downloadArchive

	/**
	 * Downloads the package archive.
	 * 
	 * @return	string		path to the dowloaded file
	 */
	public function downloadArchive() {
		$prefix = 'package';
		
		// file transfer via hypertext transfer protocol.
		$this->archive = FileUtil::downloadFileFromHttp($this->archive, $prefix);
		
		// unzip tar
		$this->archive = self::unzipPackageArchive($this->archive);
		
		return $this->archive;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:16,代码来源:PackageArchive.class.php


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