News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

PasteBin - 1177045117

Started by Guest, Apr 20, 2007, 04:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SleePy


//start check
if (isset($_GET['libpath']) || isset($_POST['libpath'])) {
    //tampering detected
    exit("Variable Override Detected");
}
//end check
 

include_once($libpath."gsQuery.php");

/**
 * @brief Uses the FarCry protcol to communicate with the server
 */
class ase extends gsQuery
{

 

  function query_server($getPlayers=TRUE,$getRules=TRUE)
  {      
    $this->playerkeys=array();
    $this->debug=array();
    $this->errstr="";
    $this->password=-1;
   
    $cmd="s";
    if(!($response=$this->_sendCommand($this->address, $this->queryport, $cmd))) {
      $this->errstr="No reply received";
      return FALSE;
    }    
 
 
$gamearray = array();

        $pos = 4;
        $gamearray[0] = substr($response,0,4);
        for($i = 1;$i < 10;$i++) {
            $gamearray[$i] = substr($response,$pos+1,ord(substr($response,$pos,1))-1);
            $pos = $pos + ord(substr($response,$pos,1));
        }
$this->numplayers=$gamearray[8];
$this->maxplayers=$gamearray[9];
$this->gametype=$gamearray[1];
$this->gamename=$gamearray[1];
$this->gameversion=$gamearray[6];
$this->servertitle=$gamearray[3];
$this->mapname=$gamearray[5];
$this->hostport=$gamearray[2];
$this->gametype=$gamearray[4];
$this->password=$gamearray[7];

// get rules and basic infos
 $endrules=0;
if (ord(substr($response,$pos,1))!=1) //skip rules
 {
do {
    $rulename= substr($response,$pos+1,ord(substr($response,$pos,1))-1);
              $pos = $pos + ord(substr($response,$pos,1));
    $rulevalue=substr($response,$pos+1,ord(substr($response,$pos,1))-1);
          $pos = $pos + ord(substr($response,$pos,1));
             
    switch ($rulename)
    {
     case "gr_ScoreLimit":  
   $this->scorelimit=$rulevalue;
   break;
      case "gr_NextMap":
        $this->nextmap=$rulevalue;
   break;
     default:
   $rulename=strtolower($rulename);
   $this->rules[$rulename] = $rulevalue;
      }
     
   }while(ord(substr($response,$pos,1))!=1); // the \x01 at the end indicates transfer to player list.
     
  }
   $pos++;  
    $playerdata=substr($response,$pos,strlen($response));
  if ($playerdata!=NULL) $this->_processPlayers($playerdata);
   
    $this->online=TRUE;

   return TRUE;
  }

 

  /**
   * @internal @brief Extracts the players out of the given data
   *
   * @param rawPlayerData data with players
   * @return TRUE on success
   */
  function _processPlayers($rawchunk)
  {
 
    $pos=0;$endplayers=0;$i=0;$skipread=0;

    do {

      $delimiter=ord($rawchunk{$pos++}); // this is a flag byte
/*
   the flag byte is broken down the following way:
   
         XX111111
    ||||||||
    |||||||-----   Name is present
    ||||||------   Team Info is present
    |||||-------   Skin Info is present
    ||||--------   Score Info is present
    |||---------   Ping Info is present
    ||----------   Time Info is present
    |-----------   Undefined
    ------------   Undefined
   
*/


      for($j=0;$j<6;$j++)// there are 6 possible data types, cycle through and grab each if present
      {
        $flag=($delimiter & (1<<$j));

        switch($flag)
        {
         case 1: // name
          $datname="name";
         break;
         case 2: // team info
          $datname="team";
         break;
         case 4: // skin
          $datname="skin";
         break;
         case 8: // score
          $datname="score";
         break;
         case 16:// ping
          $datname="ping";
         break;
         case 32:// time
          $datname="time";
         break;
         default:// item not supported
          $skipread=1;
         break;
        }
         // read the data
        if (!$skipread) {
          $this->playerkeys[$datname]=TRUE;
          $this->players[$i][$datname] = substr($rawchunk,$pos+1,ord(substr($rawchunk,$pos,1))-1);
          $pos = $pos + ord(substr($rawchunk,$pos,1));
   if ($datname=="team") {
     
      switch($this->players[$i][$datname])
           {
           case "red":
      case "RED":
      $this->teamcnt2++;
      $this->playerteams[$i]=2;
      $this->players[$i]["team"]=2;
      break;
      case "blue":
      case "BLUE":
      $this->teamcnt1++;
      $this->playerteams[$i]=1;
      $this->players[$i]["team"]=1;
      break;
      case "spectators":
      $this->spec++;
      $this->playerteams[$i]=3;
      $this->players[$i]["team"]=3;
      break;
            default:// item not supported
             echo "New Team Type:".$this->players[$i][$datname];
            break;
           }
          }
        }
        $skipread=0;

      } // end for
      $i++; //next player

      if ($i==$this->numplayers) $endplayers++;   // we have reached the max # of players, stop looping.

    }while (!$endplayers);
 
    return TRUE;
  }


 function htmlize($str)
  {
    $colors = array("black", "white", "blue", "green", "red", "light-blue", "yellow", "pink", "orange", "grey");
   
    $str = htmlentities($str);
   
  $str=str_replace("\$\$","@!c!@",$str);
  $str=str_replace("\$=","",$str);
  $str=str_replace('$&','',$str);   
    $num_tags = preg_match_all("/\\$(\d)/", $str, $matches);
    $str = preg_replace("/\\$(\d)/e", "''", $str);
   
    return str_replace("@!c!@", "\$", $str) . str_repeat("
", $num_tags);
  }
 

  function _getClassName()
  {
    return "ase";
  }

/* this is for game specific cvar displays  */
function docvars($gameserver)
{
    switch ($gameserver->gamename)
{
   case "farcry":
$retval=""
  . "      "
  . "      "
  . "      "
  . "      "
  . "      
"
  . "      "
  . "      "
  . "      "
  . "      "
  . "      "
  . "      "
 . "      "
 
  . "      
".checkmark()." Time Limit:".$gameserver ->rules["gr_timelimit"]."
".checkmark()." Damage Scale:".$gameserver ->rules["gr_damagescale"]."
".checkmark()." PreWar:".($gameserver ->rules["gr_prewaron"] == 1 ? "Yes" : "No")."
".checkmark()." Respawn Time:".$gameserver ->rules["gr_respawntime"]."
".checkmark()." Friendly Fire:".($gameserver ->rules["gr_friendlyfire"] == 1 ? "Yes" : "No")."
".checkmark()." Headshot Mult:".$gameserver ->rules["gr_headshotmultiplier"]."
"
  . "      
"
  . "      "
. "      "
  . "      "
  . "      "
  . "      "
  . "      "
 
  . "      
".checkmark()." Min Team Limit:".$gameserver ->rules["gr_minteamlimit"]."
".checkmark()." Max Team Limit:".$gameserver ->rules["gr_maxteamlimit"]."
".checkmark()." DropFade Time:".$gameserver ->rules["gr_dropfadetime"]."
".checkmark()." Invuln Timer:".$gameserver ->rules["gr_invulnerabilitytimer"]."
".checkmark()." Dedicated:".$gameserver ->rules["gr_dedicatedserver"]."
"
  . "      
";
    break;
       case "chrome":
$retval=""
  . "      "
  . "      "
  . "      "
  . "      "
  . "      
"
  . "      "
  . "      "
  . "      "
  . "      "
  . "      "
  . "      "
 . "      "
 
  . "      
".checkmark()." Dedicated:".$gameserver ->rules["dedicated"]."
".checkmark()." Time Limit:".$gameserver ->rules["time limit"]."
".checkmark()." Point Limit:".$gameserver ->rules["points limit"]."
".checkmark()." Respawn Limit:".$gameserver ->rules["respawns limit"]."
".checkmark()." Respawn Delay:".$gameserver ->rules["respawn delay"]."
".checkmark()." Enemies on Map:".$gameserver ->rules["enemies visible on map"]."
"
  . "      
"
  . "      "
. "      "
  . "      "
  . "      "
 . "      "
  . "      "
  . "      "
 
  . "      
".checkmark()." Inventory Room:".$gameserver ->rules["available inventory room"]."
".checkmark()." Identify Enemies:".$gameserver ->rules["identify enemy players"]."
".checkmark()." Vehicles:".$gameserver ->rules["available vehicles"]."
".checkmark()." Vehicle Respawn:".$gameserver ->rules["vehicle respawn delay"]."
".checkmark()." Team Balance:".$gameserver ->rules["team balance"]."
".checkmark()." Friendly Fire:".$gameserver ->rules["friendly fire"]."
"
  . "      
";
   break;
   case "purge":
$retval=""
  . "      "
  . "      "
  . "      "
  . "      "
  . "      
"
  . "      "
  . "      "
  . "      "
  . "      "
  . "      "
 
  . "      
".checkmark()." Time:".nduration($gameserver ->rules["time"])."
".checkmark()." Dead Talk:".($gameserver ->rules["deadtalk"]== 1 ?"Yes":"No")."
".checkmark()." Max Level:".$gameserver ->rules["maxlevel"]."
".checkmark()." Altars:".$gameserver ->rules["altar"]."
"
  . "      
"
  . "      "
. "      "
  . "      "
  . "      "
 . "      "

  . "      
".checkmark()." Rounds:".$gameserver ->rules["rounds"]."
".checkmark()." Portals:".$gameserver ->rules["portal"]."
".checkmark()." Min Level:".$gameserver ->rules["minlevel"]."
".checkmark()." Lamer Guard:".($gameserver ->rules["lamerguard"]== 1 ?"Yes":"No")."
"
  . "      
";
   break;
   case "soldat":
$retval=""
  . "      "
  . "      "
  . "      "
  . "      "
  . "      
"
  . "      "
  . "      "
  . "      "
   
  . "      
".checkmark()." Respawn Time:".$gameserver ->rules["respawn time"]."
".checkmark()." Bonus Freq:".$gameserver ->rules["bonus frequency"]."
"
  . "      
"
  . "      "
. "      "
 
  . "      
".checkmark()." Realistic:".($gameserver ->rules["realistic mode"]==1? "Yes":"No")."
"
  . "      
";
   break;

}
return $retval;
}

}

?>
No siggy! :D