Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problem with script

boriusborius Member Posts: 2
This is a bit long but please help me out, folks.
This script fetches a list of countries in an online game called Promisance.
It proceeds to extract certain information on each country from the HTML. The problem is, after the 10th country it bugs out. Does anyone see the solution?

<?php

function readline(&$buffer)
{
$str=substr($buffer, 0, strpos($buffer, "
"));
$buffer=substr($buffer, strpos($buffer, "
")+1);
return $str;
}

function error()
{
die("Error in country listing!");
}

$socket=fopen("http://prom.ezclan.org/dbtest.php3?Condition=Grab&Limit=2000", "r") or die("Couldn't connect!");

while (!feof($socket))
{
$buffer.=fgets($socket, 1024);
}

$buffer=substr($buffer, strpos($buffer, "<TR class=odd"));

$i=0;

echo "<h1>List of untagged countries
";

echo "
";

while (1)
{
set_time_limit(60);

if (!strstr(readline(&$buffer), "([1-9]+)<.+>", readline(&$buffer), $match) or error();
$rank=$match[1];

echo $rank; /* this is only for debugging */

ereg("^<.+>(.+)(#([0-9]+))<.+>", readline(&$buffer), $match) or error();
$country_name=$match[1];
$country_num=$match[2];

ereg("^<.+>[$](.+)<.+>", readline(&$buffer), $match) or error();
$networth=str_replace(",", "", $match[1]);

ereg("^<.+>(.+)<.+>", readline(&$buffer), $match) or error();
$land=str_replace(",", "", $match[1]);

ereg("^<.+>(.+)<.+>", readline(&$buffer), $match) or error();
$era=$match[1];

ereg("^<.+>(.*)<.+>", readline(&$buffer), $match) or error();
$clan=$match[1];

ereg("^<.+>(.+)<.+>", readline(&$buffer), $match) or error();
$race=$match[1];

readline(&$buffer);

$i++;

if (readline(&$buffer) != "") break;

if ($clan == "") echo " ";
}

echo "
$rank$country_name ($country_num)$networth$land$race$i
";

?>

Comments

  • Shawn CarterShawn Carter Member Posts: 0

    _______ / http://forcoder.org / free ebooks and video tutorials about < R, Assembly, Ruby, C, PHP, PL/SQL, Objective-C, JavaScript, Java, Visual Basic, Python, Perl, C++, Swift, C#, Visual Basic .NET, Go, Scratch, MATLAB, Delphi Scheme, Fortran, Logo, ML, Transact-SQL, Bash, Apex, Erlang, LabVIEW, Crystal, Awk, Alice, Lua, Ada, Scala, Clojure, Rust, COBOL, F#, Julia, SAS, VBScript, Lisp, Kotlin, Prolog, FoxPro, Hack, D, ABAP, Dart /> ______

Sign In or Register to comment.