TinyPortal

Development => Support => Topic started by: captjlucpicard on November 24, 2006, 01:39:41 AM

Title: Help with a phpblock
Post by: captjlucpicard on November 24, 2006, 01:39:41 AM
I'm using the America's Army block that was posted in the block snippet section. However, when I activate it, I get this following error....

Quote
Parse error: parse error in E:\inetpub\vhosts\teamucs.com\httpdocs\Sources\Load.php(1720) : eval()'d code(35) : eval()'d code on line 67




The code I put into the box is this....


Quote
//////////////////////////////////////////////
// America's Army Server Info Block
// based on the PHP Nuke block designed by DivideByZero
//
// Redesigned and converted by Ken McNicholas for TinyPortal block
// Complete Computer Services
// August 20, 2006
//
// TinyPortal 0.9.5 with SMF 1.1 RC3
//
// The America's Army Server Info Block displays current players
// on a particular America's Army server.
// Set up the configuration info for the server you wish to query
//
//////////////////////////////////////////////

function cleanup($string){
     $done = false;
     $count=0;
     while($done == false){
          $out = unpack("H*", $string);
          $pos = strpos($out[1], "1b");
          $len = "4";
         
          if ($pos === false){
               $done = true;
               break;
          }
          $count++;

          /* Calc true position */
          if($pos == 0){
               $loc = $pos;
          }else{
               $loc = $pos / 2;
          }

         $color=join(unpack("H*", substr($string, $loc+1, $len-1)))   ;
                 
             
         $substr='<' . 'font color="#' . $color . '">' ;
         $string = substr_replace($string, $substr, $loc, $len);


     }
     
while ( $count>0 ){
    $string = $string  . '<'  .'/font'.  '>' ;
    $count-- ;
  }
     return $string;
}


/*
****************************************
****************************************
*** !! User Configuration Section !! ***
****************************************
****************************************
*/

// Server IP you want to query
$aa_ip = '69.12.8.136';
// Server Name
$aa_server_name   = '-=UCS=- NAKED WOMEN INSIDE;
$aa_server_url   = 'http://www.forwardobserver.us/browser/foserverlist.php?ServerIP=';
$aa_lookup_server = 'http://www.aa-mbs.com/serverlookup.php?ip=' . $aa_ip . ':1716';

// Server Port - 1717 = default
$aa_port = '1717';

// URL to where you put the folder containing the map pics (include a trailing slash!)
$aa_image_path = 'aaomaps/';

// You should only need to change the map array if maps
// are added/deleted/changed, otherwise leave as is

// New maps added Steamroller, SF SnakePlain, Interdiction
$map   = array("Bridge Crossing" => "Bridge.jpg",
                     "Bridge SE" => "Bridge SE.jpg",
                     "Border" => "Border.jpg",
                     "Collapsed Tunnel" => "Tunnel-d.jpg",
                     "Dusk" => "Dusk.jpg",               
                     "FLS Assault" => "FLS-b.jpg",
                     "Headquarters Raid" => "HQ_Raid.jpg",
                     "Insurgent Camp" => "Insurgent_Camp-c.jpg",
             
             "Interdiction" =>"interdiction.jpg",
                     "JRTC Farm Raid" => "JRTC_Farm.jpg",
                     "Mountain Ambush" => "Mountain_Ambush-b.jpg",
                     "Mountain Pass" => "Mountain_Pass.jpg",
                     "Mountain Pass SE" => "Mountain Pass SE.jpg",
                     "Mout McKenna" => "MOUT_McKenna.jpg",
                     "Pipeline" => "Pipeline-b.jpg",
                     "Pipeline SF" => "Pipeline.jpg",
                     "Radio Tower" => "Radio_Tower.jpg",
                     "River Basin" => "River_Basin-c.jpg",
                     "SF Oasis" => "sf_oasis.jpg",
                     "SF Taiga" => "sf_taiga.jpg",
                     "SF Blizzard" => "sf_blizzard.jpg",
                     "SF Courtyard" => "sf_courtyard.jpg",
                     "SF Dockside" => "SFdockside.jpg",
                     "SF Extraction" => "SFextraction.jpg",
                     "SF PCR" => "sf_pcr.jpg",
                     "SF Water Treatment" => "sf_water_treatment.jpg",
                     "SF Arctic" => "sfarctic.jpg",
                     "SF Village" => "sfvillage.jpg",
                     "SF CSAR" => "sf_csar.jpg",
                     "SF Hospital" => "sf_hospital.jpg",
                     "SF Recon" => "sf_recon.jpg",
                     "SF SandStorm" => "sf_sandstorm.jpg",

             "SF SnakePlain" => "sf_snakeplain.jpg",
             
             "Steamroller" => "steamroller.jpg",
                     "Swamp Raid" => "Swamp_Raid-a.jpg",
                     "Weapons Cache" => "Weapons_Cache-d.jpg",
                     "Weapons Cache SE" => "Weapons_Cache-a.jpg",
                     "Woodland Outpost" => "woodland_outpost.jpg",
                     "Urban Assault" => "urban_assault.jpg");
                                   
/*
****************************************
****************************************
*/

//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////

// query server for game info
$aa_sock = fsockopen( "udp://" . $aa_ip, $aa_port);
if($aa_sock != false){
   socket_set_timeout($aa_sock, 0, 500000);
   fwrite($aa_sock, "\\info\\");
   $aa_info = @fread($aa_sock, 8192);
   fclose($aa_sock);
}   

// create array to hold game info
$aa_infoarr = explode("\\", $aa_info);
$aa_info = array();
$aa_infosize = count($aa_infoarr);
// since first element is unused (element 0) start at element 1
// and populate an associative array (nicer, and easier!)
for ($i = 1; $i < $aa_infosize; $i += 2){
   $aa_info[$aa_infoarr[$i]] = $aa_infoarr[$i+1];
}

// get player list
$players = "

";
$p = 1;
for ($i = 0; $i < $aa_info['numplayers']; $i++){
   $players .= $p . ' ' . $aa_info['player_' . $i] . '
';
   $p++;
}
$players .='

';

// display info

// Host name and link to detail from FO Online Server Browser
echo '<center><a href="' . $aa_server_url . $aa_ip . '">' . cleanup($aa_info['hostname']) . "</a>
";
//IP:Port address
echo 'IP: ' . $aa_ip . ':' . $aa_port . '
';
// Map Name
echo 'Map: ' . $aa_info['mapname'] . '
';
// Players / Max Players
echo 'Players: ' . $aa_info['numplayers'] . '/' . $aa_info['maxplayers'] . '
';
// Round
echo 'Round: ' . $aa_info['current_round'] . '
';
//Mission Time
echo 'Time: ' . $aa_info['mission_time'] . '
';

$mappic = "";
if (array_key_exists($aa_info['mapname'], $map)){
   echo '<img src="' . $aa_image_path . $map[$aa_info['mapname']] . '">
';
} else {
   echo 'Map Unavailable!
';
}
echo '<a href="' . $aa_lookup_server . '">* Server Intel *</a>
';
echo '<a href="aao://' . $aa_ip . '"><img src="' . $aa_image_path . 'joinserver.gif" border="0" alt="Join Server!!"></a>
';
echo 'Current Players:
';
echo '<a name="scrollingCode"></a>';
// display scrolling player list
echo '<marquee behavior="scroll" align="left" direction="up" height="80" width="90%" scrollamount="2" scrolldelay="100" bgcolor="232323"
         loop="infinite" onmouseover="this.stop()" onmouseout="this.start()">';
echo '<a href="' . $aa_lookup_server . '">' . $players . '</a></marquee></center>';




Thanks for any help in advance  :)
Title: Re: Help with a phpblock
Post by: JPDeni on November 24, 2006, 03:37:55 AM

$aa_server_name   = '-=UCS=- NAKED WOMEN INSIDE;

should be

$aa_server_name   = '-=UCS=- NAKED WOMEN INSIDE';


I guess it should be that. :) At the very least, your problem is that you have an opening single-quote and no closing one.

There may be other errors as well, but that's the one referred to in your error message.