Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('simple_html_dom.php');
- function getwowcenter($ranking)
- {
- $cacheKey="cache/wowcenter-$ranking.cache";
- $elapsed=file_exists($cacheKey)?filemtime($cacheKey):0;
- if (time() - $elapsed < 60*5)
- {
- $guilds=unserialize(file_get_contents($cacheKey));
- return $guilds;
- }
- $html=file_get_html("http://wowcenter.pl/Gildie/Ranking/$ranking");
- $rows=array_merge($html->find('.horde-row'),$html->find('.alliance-row'));
- foreach ($rows as $row)
- {
- $guild=$row->find('td.guild',0);
- $info=array();
- foreach ($row->find('td') as $td)
- $info[]=trim($td->plaintext);
- $row->class=' '.$row->class; //super php nie rozroznia FALSE od 0...
- if (strpos($row->class,"number-1")!=FALSE) $info[0]='1';
- if (strpos($row->class,"number-2")!=FALSE) $info[0]='2';
- if (strpos($row->class,"number-3")!=FALSE) $info[0]='3';
- if (strpos($row->class,"alliance-row")!=FALSE) $info[]='alliance';
- if (strpos($row->class,"horde-row")!=FALSE) $info[]='horde';
- $guilds[]=$info;
- }
- usort($guilds,function($x,$y) { return $x[0]-$y[0]; });
- file_put_contents($cacheKey,serialize($guilds));
- return $guilds;
- }
- var_dump(getwowcenter('Tier-13-25-Man'));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement