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


PHP xml::getUrl方法代码示例

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


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

示例1: lookup

 public function lookup($url, $groupName, $filename, $isValidCallback, $maxCacheAge = 86400)
 {
     if (empty($groupName)) {
         throw new Exception("Cache group name cannot be empty");
     }
     $cacheResult = new CacheResult();
     // Check if a xml file of the person exists and if it is uptodate
     if ($this->cacheExists($groupName, $filename)) {
         $cacheAge = $this->getCacheAge($groupName, $filename);
         if ($cacheAge < $maxCacheAge) {
             $data = $this->retrieve($groupName, $filename);
             if (call_user_func($isValidCallback, $data)) {
                 $cacheResult->data = $data;
                 $cacheResult->cacheAge = $cacheAge;
                 $cacheResult->usedCache = true;
                 $cacheResult->oldCache = false;
                 $cacheResult->success = true;
             } else {
                 unset($data);
                 $this->remove($groupName, $filename);
             }
         }
     }
     //If no old history file was found or it was invalid try to update it from auno.org
     if ($cacheResult->success !== true) {
         $data = xml::getUrl($url, 20);
         if (call_user_func($isValidCallback, $data)) {
             $cacheResult->data = $data;
             $cacheResult->cacheAge = 0;
             $cacheResult->usedCache = false;
             $cacheResult->oldCache = false;
             $cacheResult->success = true;
         } else {
             unset($data);
         }
     }
     //If the site was not responding or the data was invalid and a xml file exists get that one
     if ($cacheResult->success !== true && $this->cacheExists($groupName, $filename)) {
         $data = $this->retrieve($groupName, $filename);
         if (call_user_func($isValidCallback, $data)) {
             $cacheResult->data = $data;
             $cacheResult->cacheAge = $this->getCacheAge($groupName, $filename);
             $cacheResult->usedCache = true;
             $cacheResult->oldCache = true;
             $cacheResult->success = true;
         } else {
             unset($data);
             $this->remove($groupName, $filename);
         }
     }
     // if a new file was downloaded, save it in the cache
     if ($cacheResult->usedCache === false) {
         $this->store($groupName, $filename, $cacheResult->data);
     }
     return $cacheResult;
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:56,代码来源:CacheManager.class.php

示例2: lookup_url

 private function lookup_url($url)
 {
     $playerbio = xml::getUrl($url);
     $xml = new stdClass();
     // parsing of the player data
     $xml->firstname = xml::spliceData($playerbio, '<firstname>', '</firstname>');
     $xml->name = xml::spliceData($playerbio, '<nick>', '</nick>');
     $xml->lastname = xml::spliceData($playerbio, '<lastname>', '</lastname>');
     $xml->level = xml::spliceData($playerbio, '<level>', '</level>');
     $xml->breed = xml::spliceData($playerbio, '<breed>', '</breed>');
     $xml->gender = xml::spliceData($playerbio, '<gender>', '</gender>');
     $xml->faction = xml::spliceData($playerbio, '<faction>', '</faction>');
     $xml->profession = xml::spliceData($playerbio, '<profession>', '</profession>');
     $xml->prof_title = xml::spliceData($playerbio, '<profession_title>', '</profession_title>');
     $xml->ai_rank = xml::spliceData($playerbio, '<defender_rank>', '</defender_rank>');
     $xml->ai_level = xml::spliceData($playerbio, '<defender_rank_id>', '</defender_rank_id>');
     $xml->guild_id = xml::spliceData($playerbio, '<organization_id>', '</organization_id>');
     $xml->guild = xml::spliceData($playerbio, '<organization_name>', '</organization_name>');
     $xml->guild_rank = xml::spliceData($playerbio, '<rank>', '</rank>');
     $xml->guild_rank_id = xml::spliceData($playerbio, '<rank_id>', '</rank_id>');
     return $xml;
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:22,代码来源:PlayerManager.class.php

示例3: lookup

 public function lookup($rk_num)
 {
     $serverstat = xml::getUrl("http://probes.funcom.com/ao.xml", 30);
     if ($serverstat == null) {
         return null;
     }
     $data = xml::spliceData($serverstat, "<dimension name=\"d{$rk_num}", "</dimension>");
     if (!$data) {
         return null;
     }
     $obj = new ServerStatus();
     preg_match("/locked=\"(0|1)\"/i", $data, $tmp);
     $obj->locked = $tmp[1];
     preg_match("/<omni percent=\"([0-9.]+)\"\\/>/i", $data, $tmp);
     $obj->omni = $tmp[1];
     preg_match("/<neutral percent=\"([0-9.]+)\"\\/>/i", $data, $tmp);
     $obj->neutral = $tmp[1];
     preg_match("/<clan percent=\"([0-9.]+)\"\\/>/i", $data, $tmp);
     $obj->clan = $tmp[1];
     preg_match("/<servermanager status=\"([0-9]+)\"\\/>/i", $data, $tmp);
     $obj->servermanager = $tmp[1];
     preg_match("/<clientmanager status=\"([0-9]+)\"\\/>/i", $data, $tmp);
     $obj->clientmanager = $tmp[1];
     preg_match("/<chatserver status=\"([0-9]+)\"\\/>/i", $data, $tmp);
     $obj->chatserver = $tmp[1];
     preg_match("/display-name=\"(.+)\" loadmax/i", $data, $tmp);
     $obj->name = $tmp[1];
     $data = xml::spliceMultiData($data, "<playfield", "/>");
     foreach ($data as $hdata) {
         if (preg_match("/id=\"(.+)\" name=\"(.+)\" status=\"(.+)\" load=\"(.+)\" players=\"(.+)%\"/i", $hdata, $arr)) {
             $playfield = new stdClass();
             $playfield->id = $arr[1];
             $playfield->long_name = $arr[2];
             $playfield->status = $arr[3];
             $playfield->load = $arr[4];
             $playfield->percent = $arr[5];
             $obj->data[$arr[1]] = $playfield;
         }
     }
     return $obj;
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:41,代码来源:ServerStatusController.class.php


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