All pastes #466907 Raw Edit

Anonymous

public php v1 · immutable
·published 2007-05-02 05:18 UTC
rendered paste body
<?  /*   * Online.php - Online plugin to display online users   *   * BeBot - An Anarchy Online Chat Automaton   * Copyright (C) 2004 Jonas Jax   *   * Developed by Blondengy (RK1)   * Special thanks goes out to Khalem (RK1) for his support.   *   * File last changed at $LastChangedDate: 2004-12-29 01:41:32 +0100 (Wed, 29 Dec 2004) $   * Revision: $Id: Online.php 8 2004-12-29 00:41:32Z blondengy $   */    $online = new Online($bot);  $commands["tell"]["online"] = &$online;  $commands["pgmsg"]["online"] = &$online;  $commands["gc"]["online"] = &$online;    $commands["pgjoin"][] = &$online;  $commands["pgleave"][] = &$online;  $commands["buddy"][] = &$online;  $commands["connect"][] = &$online;  $commands["disconnect"][] = &$online;  /*    The Class itself...  */  class Online  {    var $bot;    var $guild;    var $pgroup;    var $connected;            /*      Constructor:        Hands over a referance to the "Bot" class.    */    function Online (&$bot)    {      $this -> bot = &$bot;      $this -> guild = array();      $this -> pgroup = array();    }    /*      This gets called on a tell with the command    */    function tell($name, $msg)    {    	$disponline = (($this -> bot -> guildbot) ? "both": "pgroup");    	$this -> bot -> send_tell($name, $this -> online_msg($msg, $disponline));    }    /*      This gets called on a msg in the privgroup with the command    */    function pgmsg($name, $msg)    {      if ($this -> bot -> is_member($name))      {      	$disponline = (($this -> bot -> guildbot) ? "both": "pgroup");      	$this -> bot -> send_pgroup($this -> online_msg($msg, $disponline));      }    }    /*      Gets called on a GC message    */    function gc($name, $msg)    {    	$disponline = (($this -> bot -> guildbot) ? "both": "pgroup");    	$this -> bot -> send_gc($this -> online_msg($msg, $disponline));    }    /*      This gets called if someone joins the privgroup    */    function pgjoin($name)    {      $this -> pgroup[$name] = $this -> whois($name);    }    /*      This gets called if someone leaves the privgroup    */    function pgleave($name)    {      if (isset($this -> pgroup[$name]))        unset($this -> pgroup[$name]);    }    /*      This gets called if a buddy logs on/off    */    function buddy($name, $msg)    {      if ($this -> bot -> is_member($name))      {        if ($msg == 1)          $this -> guild[$name] = $this -> whois($name);                  else if (isset($this -> guild[$name]))          unset($this -> guild[$name]);      }    }     /*      This gets called when bot disconnects    */    function disconnect()    {      $this -> guild = array();      $this -> pgroup = array();    }     /*      This gets called when bot connects    */    function connect()    {      $this -> connected = time() + 120;    }		/*			Makes the message.		*/		function online_msg($msg, $what)		{      preg_match("/^" . $this -> bot -> commpre . "online (.+)$/i", $msg, $info);            if ($info[1] == "all")				$info[1] = "";				      $guild = $this -> online_list($this -> guild, $info[1]);      $pgroup = $this -> online_list($this -> pgroup, $info[1]);            $online = "";      $msg = "";            if (($what == "both") || ($what == "guild"))      {        $online .= "<font color=CCInfoHeadline>::: " . $guild[0] . " members online in Guild :::</font>\n" . $guild[1];        $online .= "\n<font color=CCCCTextColor>------------------------------\n";        $msg .= "<font color=#ffff00>" . $guild[0] . "</font> members online in Guild. ";    	}    	if (($what == "both") || ($what == "pgroup"))    	{      	$online .= "<font color=CCInfoHeadline>::: " . $pgroup[0] . " players in Privategroup :::</font>\n" . $pgroup[1];        $msg .= "<font color=#ffff00>" . $pgroup[0] . "</font> members in Privategroup. ";      }      $msg .= ":: " . $this -> bot -> make_blob("click to view", $online);      return $msg;		}						    /*      Gets info on player    */    function whois($name)    {    	$second = (($this -> bot -> guildbot) ? "rank_name" : "guild");      $result = $this -> bot -> db -> select("SELECT nickname, level, $second, profession, id FROM members WHERE id = " . $this -> bot -> aoc -> get_uid($name));      if (empty($result))      {       $content = $this -> bot -> get_site("http://www.anarchy-online.com/character/bio/d/" . $this -> bot -> dimension . "/name/" . strtolower($name) . "/bio.xml");        $result[0] = $name;        $result[1] = $this -> bot -> xmlparse($content, "level");        $result[2] = $this -> bot -> xmlparse($content, "organization_name");        $result[3] = $this -> bot -> xmlparse($content, "profession");        $result[4] = $this -> bot -> aoc -> get_uid($name);		$result[5] = $this -> bot -> xmlparse($content, "defender_rank_id");      }      else	  {        $result = $result[0];		$content = $this -> bot -> get_site("http://www.anarchy-online.com/character/bio/d/" . $this -> bot -> dimension . "/name/" . strtolower($name) . "/bio.xml");		$result[5] = $this -> bot -> xmlparse($content, "defender_rank_id");	  }      if (empty($result[3]))        $result[3] = "Unknown";      if (empty($result[1]))        $result[1] = "?";      if (empty($result[2]))        $result[2] = "<i>soloer</i>";      if (empty($result[5]))        $result[5] = "?";      	  $result[6] = "none";	        return $result;    }    /*     make the list of online players     */     function online_list($online, $like)     {         $profgfx["Meta-Physicist"] = "16308";        $profgfx["Adventurer"] = "84203";        $profgfx["Engineer"] = "16252";        $profgfx["Soldier"] = "16237";        $profgfx["Keeper"] = "84197";        $profgfx["Shade"] = "39290";        $profgfx["Fixer"] = "16300";        $profgfx["Agent"] = "16186";        $profgfx["Trader"] = "117993";        $profgfx["Doctor"] = "44235";        $profgfx["Enforcer"] = "100998";        $profgfx["Bureaucrat"] = "16341";        $profgfx["Martial Artist"] = "16196";        $profgfx["Nano-Technician"] = "16283";        $prof_based = "";         $online_list = "";         $online_num = 0;         if (!empty($online))         {             foreach ($online as $player)             {                 $prof_based[$player[3]][(sprintf("%03d", (220 - $player[1])) . $player[0])] = $player;             }             ksort($prof_based);             foreach ($prof_based as $key => $prof)             {                 if (preg_match("/" . $like . "/i", $key))                 {                     $online_list .= "\n<img src=tdb://id:GFX_GUI_FRIENDLIST_SPLITTER>\n";                    $online_list .= "<img src=rdb://" . $profgfx[$key] . ">";                    $online_list .= " <font color=CCInfoHeader>" . $key . "</font>\n";                     $online_list .= "<img src=tdb://id:GFX_GUI_FRIENDLIST_SPLITTER>\n";                    ksort($prof);                     foreach ($prof as $player)                     {                         $admin = "";                        $online_num++;                         $main = $this -> bot -> alts -> main($player[4]);                         $alts = $this -> bot -> alts -> get_alts($main);                         if ($this -> bot -> admin -> in_group($player[0], "superadmin"))                        {                            $admin = " :: <font color=#FF0000>Superadmin</font> ";                         }                        else if ($this -> bot -> admin -> in_group($player[0], "admin"))                        {                            $admin = " :: <font color=#FF0000>Admin</font> ";                        }                        else if ($this -> bot -> admin -> in_group($player[0], "raidleader"))                        {                            $admin = " :: <font color=#FF0000>Raidleader</font> ";                        }                        if (empty($alts))                        {                             $alts = "";                        }                         else if ($main == $this -> bot -> aoc -> get_uname($player[4]))                        {                             $alts = ":: <a href='chatcmd:///tell <botname> <pre>alts " . $player[0] . "'>Alts</a> ::";                         }                        else                        {                             $alts = ":: <a href='chatcmd:///tell <botname> <pre>alts " . $player[0] . "'>" . $main . "'s Alts</a> ";                         }                        if ($player[6] != "none")                        {                             $chatclient = "(" . $player[6] . ") ";                        }                         else                        {                             $chatclient = "";                        }                        $online_list .= "<font color=CCCCTextColor> - L " . $player[1] . " / AL " . $player[5] . " <font color=CCInfoText>" . $player[0] . "</font> (" . $player[2] . ") " . $admin . $chatclient . $alts . "</font>";                         if($this -> bot -> commands["tell"]["afk"] -> afk[$player[0]])                         {                             $online_list .= ":: <font color=#FFFFFF>( AFK )</font>\n";                         }                         else                         {                             $online_list .= "\n";                         }                     }                 }             }         }         return array($online_num, $online_list);     }    /*      Is called if user is using a chat client...    */    function chatclient($name, $type)    {      if (isset($this -> guild[$name]))      {        $this -> guild[$name][5] = $type;      }      if (isset($this -> pgroup[$name]))      {        $this -> pgroup[$name][5] = $type;      }    }  }?>