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


PHP xml::spliceData方法代码示例

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


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

示例1: lookup

    public function lookup($name, $rk_num)
    {
        $name = ucfirst(strtolower($name));
        $url = "http://auno.org/ao/char.php?output=xml&dimension={$rk_num}&name={$name}";
        $groupName = "player_history";
        $filename = "{$name}.{$rk_num}.history.xml";
        $maxCacheAge = 86400;
        $cb = create_function('$data', 'if (xml::spliceData($data, "<nick>", "</nick>") != "") {
				return true;
			} else {
				return false;
			}');
        $cacheResult = $this->cacheManager->lookup($url, $groupName, $filename, $cb, $maxCacheAge);
        $obj = new PlayerHistory();
        $obj->name = $name;
        //if there is still no valid data available give an error back
        if ($cacheResult->success !== true) {
            return null;
        } else {
            //parsing of the xml file
            $data = xml::spliceData($cacheResult->data, "<history>", "</history>");
            $data = xml::splicemultidata($data, "<entry", "/>");
            foreach ($data as $hdata) {
                preg_match("/date=\"(.+)\" level=\"(.+)\" ailevel=\"(.*)\" faction=\"(.+)\" guild=\"(.*)\" rank=\"(.*)\"/i", $hdata, $arr);
                $entry = new stdClass();
                $entry->date = $arr[1];
                $entry->level = $arr[2];
                $entry->aiLevel = $arr[3];
                $entry->faction = $arr[4];
                $entry->guild = $arr[5];
                $entry->rank = $arr[6];
                $obj->data[] = $entry;
            }
        }
        return $obj;
    }
开发者ID:jibinam,项目名称:budabot2,代码行数:36,代码来源:PlayerHistoryManager.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

示例4: get_by_id

    public function get_by_id($guild_id, $rk_num = 0, $force_update = false)
    {
        // if no server number is specified use the one on which the bot is logged in
        if ($rk_num == 0) {
            $rk_num = $this->chatBot->vars["dimension"];
        }
        $name = ucfirst(strtolower($name));
        $url = "http://people.anarchy-online.com/org/stats/d/{$rk_num}/name/{$guild_id}/basicstats.xml";
        $groupName = "guild_roster";
        $filename = "{$guild_id}.{$rk_num}.xml";
        if ($this->chatBot->vars["my_guild_id"] == $guild_id) {
            $maxCacheAge = 21600;
        } else {
            $maxCacheAge = 86400;
        }
        $cb = create_function('$data', 'if (xml::spliceData($data, "<id>", "</id>") != "") {
				return true;
			} else {
				return false;
			}');
        $cacheResult = $this->cacheManager->lookup($url, $groupName, $filename, $cb, $maxCacheAge);
        // if there is still no valid data available give an error back
        if ($cacheResult->success !== true) {
            return null;
        }
        $guild = new stdClass();
        $guild->guild_id = $guild_id;
        // parsing of the memberdata
        $members = xml::splicemultidata($cacheResult->data, "<member>", "</member>");
        $guild->orgname = xml::spliceData($cacheResult->data, "<name>", "</name>");
        $guild->orgside = xml::spliceData($cacheResult->data, "<side>", "</side");
        // pre fetch the charids...this speeds things up immensely
        foreach ($members as $xmlmember) {
            $name = xml::splicedata($xmlmember, "<nickname>", "</nickname>");
            if (!isset($this->chatBot->id[$name])) {
                $this->chatBot->send_packet(new AOChatPacket("out", AOCP_CLIENT_LOOKUP, $name));
            }
        }
        foreach ($members as $member) {
            $name = xml::splicedata($member, "<nickname>", "</nickname>");
            $charid = $this->chatBot->get_uid($name);
            if ($charid == null) {
                $charid = 0;
            }
            $guild->members[$name] = new stdClass();
            $guild->members[$name]->charid = $charid;
            $guild->members[$name]->firstname = xml::spliceData($member, '<firstname>', '</firstname>');
            $guild->members[$name]->name = xml::spliceData($member, '<nickname>', '</nickname>');
            $guild->members[$name]->lastname = xml::spliceData($member, '<lastname>', '</lastname>');
            $guild->members[$name]->level = xml::spliceData($member, '<level>', '</level>');
            $guild->members[$name]->breed = xml::spliceData($member, '<breed>', '</breed>');
            $guild->members[$name]->gender = xml::spliceData($member, '<gender>', '</gender>');
            $guild->members[$name]->faction = $guild->orgside;
            $guild->members[$name]->profession = xml::spliceData($member, '<profession>', '</profession>');
            $guild->members[$name]->prof_title = xml::spliceData($member, '<profession_title>', '</profession_title>');
            $guild->members[$name]->ai_rank = xml::spliceData($member, '<defender_rank>', '</defender_rank>');
            $guild->members[$name]->ai_level = xml::spliceData($member, '<defender_rank_id>', '</defender_rank_id>');
            $guild->members[$name]->guild_id = $guild->guild_id;
            $guild->members[$name]->guild = $guild->orgname;
            $guild->members[$name]->guild_rank = xml::spliceData($member, '<rank_name>', '</rank_name>');
            $guild->members[$name]->guild_rank_id = xml::spliceData($member, '<rank>', '</rank>');
            $guild->members[$name]->dimension = $rk_num;
            $guild->members[$name]->source = 'org_roster';
        }
        // this is done separately from the loop above to prevent nested transaction errors from occuring
        // when looking up charids for characters
        if ($cacheResult->usedCache === false) {
            $this->db->begin_transaction();
            $sql = "UPDATE players SET guild_id = 0, guild = '' WHERE guild_id = ? AND dimension = ?";
            $this->db->exec($sql, $guild->guild_id, $rk_num);
            foreach ($guild->members as $member) {
                $this->playerManager->update($member);
            }
            $this->db->commit();
        }
        return $guild;
    }
开发者ID:jibinam,项目名称:budabot2,代码行数:77,代码来源:GuildManager.class.php

示例5: weatherCommand

 /**
  * @HandlesCommand("weather")
  * @Matches("/^weather (.+)$/i")
  */
 public function weatherCommand($message, $channel, $sender, $sendto, $args)
 {
     $location = $args[1];
     $blob = '';
     $host = "api.wunderground.com";
     $geolookup = "/auto/wui/geo/GeoLookupXML/index.xml?query=" . urlencode($location);
     $current = "/auto/wui/geo/WXCurrentObXML/index.xml?query=" . urlencode($location);
     $forecast = "/auto/wui/geo/ForecastXML/index.xml?query=" . urlencode($location);
     $alerts = "/auto/wui/geo/AlertsXML/index.xml?query=" . urlencode($location);
     $geolookup = $this->getweatherdata("api.wunderground.com", 80, $geolookup);
     // Geolookup
     if (xml::spliceData($geolookup, "<wui_error>", "</wui_error>") != "") {
         $sendto->reply("No information is available for <highlight>" . $location . "<end>.");
         return;
     }
     $locations = xml::spliceMultiData($geolookup, "<name>", "</name>");
     if (count($locations) > 1) {
         $blob .= "Multiple hits for {$location}.\n\n";
         foreach ($locations as $spot) {
             $blob .= $this->text->make_chatcmd($spot, "/tell <myname> weather {$spot}") . "\n";
         }
         $msg = $this->text->make_blob('Weather Locations', $blob);
         $sendto->reply($msg);
         return;
     }
     $sendto->reply("Collecting data for <highlight>" . $location . "<end>.");
     $current = $this->getweatherdata("api.wunderground.com", 80, $current);
     $forecast = $this->getweatherdata("api.wunderground.com", 80, $forecast);
     $alerts = $this->getweatherdata("api.wunderground.com", 80, $alerts);
     // CURRENT
     $updated = xml::spliceData($current, "<observation_time_rfc822>", "</observation_time_rfc822>");
     if ($updated == ", :: GMT") {
         $sendto->reply("No information is available for <highlight>" . $location . "<end>.");
         return;
     }
     $credit = xml::spliceData($current, "<credit>", "</credit>");
     $crediturl = xml::spliceData($current, "<credit_URL>", "</credit_URL>");
     $observeLoc = xml::spliceData($current, "<observation_location>", "</observation_location>");
     $fullLoc = xml::spliceData($observeLoc, "<full>", "</full>");
     $country = xml::spliceData($observeLoc, "<country>", "</country>");
     $lat = xml::spliceData($observeLoc, "<latitude>", "</latitude>");
     $lon = xml::spliceData($observeLoc, "<longitude>", "</longitude>");
     $elevation = xml::spliceData($observeLoc, "<elevation>", "</elevation>");
     $weather = xml::spliceData($current, "<weather>", "</weather>");
     $tempstr = xml::spliceData($current, "<temperature_string>", "</temperature_string>");
     $humidity = xml::spliceData($current, "<relative_humidity>", "</relative_humidity>");
     $windstr = xml::spliceData($current, "<wind_string>", "</wind_string>");
     $windgust = xml::spliceData($current, "<wind_gust_mph>", "</wind_gust_mph>");
     $pressurestr = xml::spliceData($current, "<pressure_string>", "</pressure_string>");
     $dewstr = xml::spliceData($current, "<dewpoint_string>", "</dewpoint_string>");
     $heatstr = xml::spliceData($current, "<heat_index_string>", "</heat_index_string>");
     $windchillstr = xml::spliceData($current, "<windchill_string>", "</windchill_string>");
     $visibilitymi = xml::spliceData($current, "<visibility_mi>", "</visibility_mi>");
     $visibilitykm = xml::spliceData($current, "<visibility_km>", "</visibility_km>");
     $latlonstr = number_format(abs($lat), 1);
     if (abs($lat) == $lat) {
         $latlonstr .= "N ";
     } else {
         $latlonstr .= "S ";
     }
     $latlonstr .= number_format(abs($lon), 1);
     if (abs($lon) == $lon) {
         $latlonstr .= "E ";
     } else {
         $latlonstr .= "W ";
     }
     $latlonstr .= $this->text->make_chatcmd("Google Map", "/start http://maps.google.com/maps?q={$lat},{$lon}") . " ";
     $latlonstr .= $this->text->make_chatcmd("Wunder Map", "/start http://www.wunderground.com/wundermap/?lat={$lat}&lon={$lon}&zoom=10") . "\n\n";
     $blob .= "Credit: <highlight>" . $this->text->make_chatcmd($credit, "/start {$crediturl}") . "<end>\n";
     $blob .= "Last Updated: <highlight>{$updated}<end>\n\n";
     $blob .= "Location: <highlight>{$fullLoc}, {$country}<end>\n";
     $blob .= "Lat/Lon: <highlight>{$latlonstr}<end>";
     $blob .= "Currently: <highlight>{$tempstr}, {$weather}<end>\n";
     $blob .= "Humidity: <highlight>{$humidity}<end>\n";
     $blob .= "Dew Point: <highlight>{$dewstr}<end>\n";
     $blob .= "Wind: <highlight>{$windstr}<end>";
     if ($windgust) {
         $blob .= " (Gust:{$windgust} mph)\n";
     } else {
         $blob .= "\n";
     }
     if ($heatstr != "NA") {
         $blob .= "Heat Index: <highlight>{$heatstr}<end>\n";
     }
     if ($windchillstr != "NA") {
         $blob .= "Windchill: <highlight>{$windchillstr}<end>\n";
     }
     $blob .= "Pressure: <highlight>{$pressurestr}<end>\n";
     $blob .= "Visibility: <highlight>{$visibilitymi} miles, {$visibilitykm} km<end>\n";
     $blob .= "Elevation: <highlight>{$elevation}<end>\n";
     // ALERTS
     $alertitems = xml::spliceMultiData($alerts, "<AlertItem>", "</AlertItem>");
     if (count($alertitems) == 0) {
         $blob .= "\n<header2>Alerts:<end> None reported.\n\n";
     } else {
         foreach ($alertitems as $thisalert) {
//.........这里部分代码省略.........
开发者ID:jibinam,项目名称:budabot2,代码行数:101,代码来源:WeatherController.class.php


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