- Timestamp:
- Aug 26, 2009, 3:07:07 PM (15 years ago)
- Location:
- trunk/inc
- Files:
-
- 3 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/inc/config.sample.php
r627 r630 20 20 'ScriptDev2Revision' => '137', 21 21 'ClientVersion' => '3.1.3', 22 'DatabaseHost' => 'localhost', 23 'DatabaseUser' => 'server1', 24 'DatabasePassword' => 'server1', 22 25 'DatabaseRealmd' => 'realmd', 23 26 'RequiredOnlinePlayers' => 70, … … 35 38 'Id' => 7, 36 39 'Name' => 'Realm 1' 40 'DatabaseHost' => 'localhost', 41 'DatabaseUser' => 'server1', 42 'DatabasePassword' => 'server1', 37 43 'DatabaseCharacters' => 'realm1_characters', 38 44 'DatabaseMangos' => 'realm1_mangos', 39 45 'DatabaseScriptDev2' => 'realm1_scriptdev2', 46 'Server' => 1, 40 47 'MaxOnlinePlayers' => 100, 41 48 'XPRate' => 1, … … 63 70 'BankAccount' => '670100-2202937132/6210', 64 71 'ServerList' => array( 65 array(72 1 => array( 66 73 'OS' => 'GNU/Linux', 67 74 'CPU' => 'AMD Athlon 64 X2 5600+, 2,8 GHz', … … 70 77 'Address' => 'localhost', 71 78 'Internet' => '16/16 Mbit/s, agregace 1:32', 72 'Realms' => array(1),73 79 'Statistic' => 'http://localhost/stat/', 74 80 }, -
trunk/inc/html.php
r614 r630 284 284 function QuickNew() 285 285 { 286 global $server, $Config ;286 global $server, $Config, $System; 287 287 288 288 if(isset($_COOKIE['hof-quick']) AND $_COOKIE['hof-quick'] == 'no') … … 297 297 '<tr>'. 298 298 '<td colspan="2">'. 299 '<strong>Server : </strong>'.$server-> ServerImg($server->ServerOnline($Config['Web']['WoWServerAddr'], 3724)).'<b> (<a href="?page=realmlist">'.$server->ServerMangosOnline().' hráčů celkem</a>) | Patch '.$Config['Mangos']['ClientVersion'].' | <a href="'.$Config['Web']['BaseURL'].'/pages/realmlist.wtf">Realmlist</a> | <a href="?page=server">Server info</a> | <a href="?page=realmlist">Seznam světů</a></b>'.299 '<strong>Server : </strong>'.$server->OnlineStateImage($System->NetworkPortState($Config['Web']['WoWServerAddr'], 3724)).'<b> (<a href="?page=realmlist">'.$server->OnlineCharactersCount().' hráčů celkem</a>) | Patch '.$Config['Mangos']['ClientVersion'].' | <a href="'.$Config['Web']['BaseURL'].'/pages/realmlist.wtf">Realmlist</a> | <a href="?page=server">Server info</a> | <a href="?page=realmlist">Seznam světů</a></b>'. 300 300 '</td></tr></table><br />'); 301 301 } -
trunk/inc/server.php
r627 r630 5 5 } 6 6 7 class Server 7 class Server extends Module 8 8 { 9 private $db; 10 11 public function __construct($db) 12 { 13 $this->db = $db; 14 } 15 16 public function HumanDate($date, $time = 1) 9 function __construct($System, $Id) 10 { 11 parent::__construct($System); 12 $this->Id = $Id; 13 } 14 15 function HumanDate($date, $time = 1) 17 16 { 18 17 // input date is 0000-00-00 00:00:00 … … 27 26 } 28 27 29 public function RealmOnline() 30 { 31 global $Config; 32 33 $this->db->select_db($Config['Mangos']['DatabaseRealmd']); 34 $DbResult = $this->db->query('SELECT COUNT(*) FROM `account` WHERE `online` = 1'); 28 function OnlineAccountCount() 29 { 30 $this->Database->select_db($this->Config['Mangos']['DatabaseRealmd']); 31 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `account` WHERE `online` = 1'); 35 32 $DbRow = $DbResult->fetch_row(); 36 33 return($DbRow[0]); 37 34 } 38 35 39 publicfunction ParseCopper($copper_in)36 function ParseCopper($copper_in) 40 37 { 41 38 $copper = $copper_in; … … 50 47 } 51 48 52 public function MangosOnline($RealmId) 53 { 54 global $Config; 55 56 $this->db->select_db($Config['Mangos']['RealmList'][$RealmId]['DatabaseCharacters']); 57 $DbResult = $this->db->query('SELECT COUNT(*) FROM `characters` WHERE `online` = 1'); 58 $DbRow = $DbResult->fetch_row(); 59 return($DbRow[0]); 60 } 61 62 public function ServerMangosOnline() 63 { 64 global $Config; 65 49 function OnlineCharactersCount() 50 { 66 51 $TotalCount = 0; 67 foreach($ Config['Mangos']['RealmList'] as $Index => $Realm)52 foreach($this->Config['Mangos']['RealmList'] as $Index => $Realm) 68 53 { 69 $TotalCount += $this->MangosOnline($Index); 54 $Realm = new Realm($this->System, $Index); 55 $TotalCount += $Realm->OnlineCharactersCount(); 70 56 } 71 57 return($TotalCount); 72 58 } 73 59 74 public function ServerOnline($Address, $Port, $Timeout = 0.5) 75 { 76 set_error_handler('NullErrorHandler'); 77 if($Socket = @fsockopen($Address, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout)) 60 function OnlineStateImage($Status) 61 { 62 if($Status) return('<img src="imgs/inc/on.gif" alt="online" /> <span style="text-color: #234303; text-size: 4;">Online</span>'); 63 else return('<img src="imgs/inc/off.gif" alt="offline" /> <span style="text-color: #990000; text-size: 4;">Offline</span>'); 64 } 65 66 function CharacterCount() 67 { 68 $TotalCount = 0; 69 foreach($this->Config['Mangos']['RealmList'] as $Index => $Realm) 78 70 { 79 fclose($Socket); 80 $Result = true; 81 } else $Result = false; 82 restore_error_handler(); 83 return($Result); } 84 85 public function ServerImg($status) 86 { 87 if($status) return('<img src="imgs/inc/on.gif" alt="online" /> <span style="text-color: #234303; text-size: 4;">Online</span>'); 88 else return('<img src="imgs/inc/off.gif" alt="offline" /> <span style="text-color: #990000; text-size: 4;">Offline</span>'); 89 } 90 91 public function ServerUptime() 92 { 93 global $Config; 94 95 $this->db->select_db($Config['Mangos']['DatabaseRealmd']); 96 $row = $this->db->query('SELECT `starttime`, `uptime` FROM `uptime` ORDER BY `starttime` DESC LIMIT 1') 97 ->fetch_array(); 98 $uptime = round($row['uptime'] / 3600); 99 return($uptime); 100 } 101 102 public function CharacterCount($RealmId) 103 { 104 global $Config; 105 106 $this->db->select_db($Config['Mangos']['RealmList'][$RealmId]['DatabaseCharacters']); 107 $DbResult = $this->db->query('SELECT COUNT(*) FROM `characters`'); 108 $DbRow = $DbResult->fetch_row(); 109 return($DbRow[0]); 110 } 111 112 public function ServerCharacterCount() 113 { 114 global $Config; 115 116 $TotalCount = 0; 117 foreach($Config['Mangos']['RealmList'] as $Index => $Realm) 118 { 119 $TotalCount += $this->CharacterCount($Index); 71 $Realm = new Realm($this->System, $Index); 72 $TotalCount += $Realm->CharacterCount($Index); 120 73 } 121 74 return($TotalCount); … … 124 77 public function AccountCount() 125 78 { 126 global $Config; 127 128 $this->db->select_db($Config['Mangos']['DatabaseRealmd']); 129 $row = $this->db->query('SELECT COUNT(*) FROM account')->fetch_row(); 79 $this->Database->select_db($this->Config['Mangos']['DatabaseRealmd']); 80 $row = $this->Database->query('SELECT COUNT(*) FROM account')->fetch_row(); 130 81 return($row[0]); 131 }132 133 public function GuidToCharName($guid)134 {135 global $Config;136 137 $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);138 $row = $this->db->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_array();139 return($row['name']);140 }141 142 public function ShowGmLog($log)143 {144 echo('<table border="1" width="540">'.145 '<tr>146 <th>Čas</th>147 <th>GM</th>148 <th>Příkaz</th>149 <th>Vybrán</th>150 </tr>');151 $gm_log = ereg_replace("\n",";",$log);152 $gm_log = explode(";",$gm_log);153 $gm_log = array_reverse($gm_log);154 foreach($gm_log as $row)155 {156 if (strpos($row,"Command:") == true)157 {158 $edited = str_replace(" Command: ", ";", $row); // 0 - time159 $edited = str_replace(" (Account: ", ";", $edited); // 1 - command160 $edited = str_replace(" [Player: ", ";", $edited); // 2 - gm161 $edited = str_replace(" Selected: ", ";", $edited); // 3 - position162 $edited = str_replace(" (GUID: ", ";", $edited); // 4 - selected163 $edited = str_replace(")]", ";", $edited); // 5 - selected guid164 $edited_arr = explode(";",$edited);165 if($edited_arr[4] == "player") $sel_name = " - ".$this -> GuidToCharName($edited_arr[5]);166 else $sel_name = '';167 $human_date = $this -> HumanDate ($edited_arr[0]);168 echo('<tr>169 <td><font size="2">'.$human_date.'</font></td>170 <td>'.$edited_arr[2].'</td>171 <td>'.$edited_arr[1].'</td>172 <td>'.$edited_arr[4].$sel_name.'</td>173 </tr>');174 }175 if(strpos($row, 'mail item:') == true)176 {177 $edited = str_replace(" GM ", ";", $row);178 $edited = str_replace(" (Account: ", ";", $edited);179 $edited = str_replace(") mail item: ", ";", $edited);180 $edited = str_replace(" (Account: ", ";", $edited);181 $edited = str_replace(")", "", $edited);182 $edited_arr = explode(";",$edited);183 $human_date = $this -> HumanDate ($edited_arr[0]);184 echo('<tr>185 <td><font size="2">'.$human_date.'</font></td>186 <td>'.$edited_arr[1].'</td>187 <td>Send : '.$edited_arr[3].')</td>188 <td>-</td>189 </tr>');190 }191 if(strpos($row,"trade:") == true)192 {193 $edited = str_replace(" GM ", ";", $row);194 $edited = str_replace(" (Account: ", ";", $edited);195 $edited = str_replace(") trade: ", ";", $edited);196 $edited = str_replace(" (Account: ", ";", $edited);197 $edited = str_replace(")", "", $edited);198 $edited_arr = explode(";",$edited);199 200 $human_date = $this -> HumanDate ($edited_arr[0]);201 echo('<tr>202 <td><font size="2">'.$human_date.'</font></td>203 <td>'.$edited_arr[1].'</td>204 <td>Trade : '.$edited_arr[3].')</td>205 <td>-</td>206 </tr>');207 }208 }209 echo('</table>');210 }211 212 public function SeoUrl($title)213 {214 $address = $title;215 $diakritika = array("á","ä","č","ď","é","ě","ë","í","ň","ó","ö","ř","š","ť","ú","ů","ü","ý","ž","Á","Ä","Č","Ď","É","Ě","Ë","Í","Ň","Ó","Ö","Ř","Š","Ť","Ú","Ů","Ü","Ý","Ž");216 $nediakritika = array("a","a","c","d","e","e","e","i","n","o","o","r","s","t","u","u","u","y","z","A","A","C","D","E","E","E","I","N","O","O","R","S","T","U","U","U","Y","Z");217 $address = str_replace($diakritika, $nediakritika, $address);218 $address = strtolower ($address);219 $address = preg_replace ("/[^[:alpha:][:digit:]]/", "-", $address);220 $address = trim ($address, "-");221 $address = preg_replace ("/[-]+/", "-", $address);222 return($address);223 82 } 224 83 … … 372 231 function RealmSelection($FormNameSufix = '') 373 232 { 374 global $Config;375 376 377 233 $Output = ''; 378 if(count($ Config['Mangos']['RealmList']) > 1)234 if(count($this->Config['Mangos']['RealmList']) > 1) 379 235 { 380 236 if(array_key_exists('page', $_GET)) $Target = '?page='.$_GET['page']; … … 382 238 $Output .= '<div style="text-align: center;"><form name="RealmSelection'.$FormNameSufix.'" action="'.$Target.'" method="post">'. 383 239 '<div>Výběr světa <select name="RealmIndex" onchange="document.RealmSelection'.$FormNameSufix.'.submit()">'; 384 foreach($ Config['Mangos']['RealmList'] as $Index => $Realm)240 foreach($this->Config['Mangos']['RealmList'] as $Index => $Realm) 385 241 { 386 242 if($_COOKIE['RealmIndex'] == $Index) $Selected = ' selected="selected"';
Note:
See TracChangeset
for help on using the changeset viewer.