Jump to content


Photo

Snoopy Preg Match Help


  • Please log in to reply
No replies to this topic

#1 npsken

npsken

    Young Padawan

  • Members
  • Pip
  • 26 posts
  • Gender:Male
  • Interests:Computer Programming<br />Graphic Design

Posted 13 July 2007 - 08:16 PM

EDIT: PROBLEM SOLVED

Here is some code I am building off of:

<?phpif (!($_GET['timeout'])) {$timeout = 400;}if (!($_GET['tag'])) {$tag = "G2Ladmin";}$tag = str_replace(" ","%20",$tag);$file1 = file('./gamercard_cache.txt');$file = array_map('trim', $file1);$abstand = time() - $file[0];if ($abstand > $timeout || $tag != $file[1]) {include('./snoopy.php');$snoopy = new Snoopy; if($snoopy->fetch("http://gamercard.xbox.com/". $tag .".card")) $in = ($snoopy->results);preg_match('#<h3 class="XbcGamertag(.+?)">#',$in, $gamertagstyle1); preg_match('#width="64" src="(.+?)" /></a>#',$in, $gamertile1);preg_match('#XbcFRAR"><img src="(.+?)" /></span></p>#',$in, $gamerrep1);  preg_match('#Gamerscore" src="(.+?)" />#',$in, $gamerscore_img1);  preg_match_all('#<span class="XbcFRAR">(.+?)</span>#',$in, $gamer);preg_match_all('#<div class="XbcgcGames">(.+?)</div>#',$in, $gamesa);$gamerrep = "http://gamercard.xbox.com". $gamerrep1[1];$gamerscore_img = "http://gamercard.xbox.com". $gamerscore_img1[1];$gamerscore = $gamer[1][1];$gamerzone = $gamer[1][2];$gamerachivements = $gamesa[1][0];$cache_string = time() ."\n". $tag ."\n". $gamertagstyle1[1] ."\n". $gamertile1[1] ."\n". $gamerrep ."\n". $gamerscore ."\n". $gamerscore_img ."\n". $gamerzone ."\n". $gamerachivements;$cache = fopen ("./gamercard_cache.txt", "w");fwrite($cache, $cache_string );fclose($cache);$gamertagstyle = $gamertagstyle1[1];$gamertile = $gamertile1[1];$gamertag = str_replace("%20"," ", $tag);} else {$tag = $file[1];$gamertag = str_replace("%20"," ", $tag);$gamertagstyle = $file[2];$gamertile = $file[3];$gamerrep = $file[4];$gamerscore = $file[5];$gamerscore_img = $file[6];$gamerzone = $file[7];$gamerachivements = $file[8];}?>

Summary: It goes to http://gamercard.xbo...MERTAGHERE.card and gathers information about the supplied user and stores that information in variables and whatnot.

I am looking for a way to get the 5 game images at the bottom included into the code somehow so I could echo them, but I am having trouble. Can somebody help me?

EDIT: Also, I was wondering if somebody could help me convert this to not use a txt file if it doesn't have to store external data.

Any help is greatly appreciated.

Edited by npsken, 14 July 2007 - 05:52 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users