Changeset 6
- Timestamp:
- Jun 4, 2008, 9:01:09 AM (17 years ago)
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pages/a_servers.php
r3 r6 10 10 switch ($order_index) 11 11 { 12 case 0: $order = ' order by `name` desc'; break;12 case 0: $order = ' order by `name`'; break; 13 13 case 1: $order = ' order by `rating` desc '; break; 14 14 case 2: $order = ' order by `version` desc '; break; … … 34 34 } 35 35 36 $pa = new CleverPager('select `id`,`wss_partner`,LEFT(`name`, 25) as `name`, `place`, `rating_sum`/`ratings` as `rating`, `version`, `type`, `xp`, `online` /`online_checks` as `online`, `online_players_sum`/`player_checks` as `players` from `servers` where `place`=2 '.$order, 'p');36 $pa = new CleverPager('select `id`,`wss_partner`,LEFT(`name`, 25) as `name`, `place`, `rating_sum`/`ratings` as `rating`, `version`, `type`, `xp`, `online`, `online_players_sum`/`player_checks` as `players` from `servers` where `place`=2 '.$order, 'p'); 37 37 $pa->PageSize = 20; 38 38 $pa->PageLinksDisplayed = 5; … … 66 66 $tpl->output['servers_data'] .='<td>'.$xp.'</td>'; 67 67 $tpl->output['servers_data'] .='<td>'.(int)$row['players'].'</td>'; 68 $tpl->output['servers_data'] .='<td>'.( 100*$row['online']).'%</td>';68 $tpl->output['servers_data'] .='<td>'.($row['online']).'%</td>'; 69 69 $tpl->output['servers_data'] .='</tr>'; 70 70 } -
pages/server.php
r1 r6 30 30 $tpl->output['server_online_players']='0'; 31 31 } 32 $tpl->output['server_online'] = 100*@round($server_info['online']/$server_info['online_checks'],2).'%';32 $tpl->output['server_online'] = @round($server_info['online'], 2).'%'; 33 33 switch ($server_info['xp']) 34 34 { -
pages/servers.php
r3 r6 9 9 switch ($order_index) 10 10 { 11 case 0: $order = ' order by `name` desc'; break;11 case 0: $order = ' order by `name`'; break; 12 12 case 1: $order = ' order by `rating` desc '; break; 13 13 case 2: $order = ' order by `version` desc '; break; … … 33 33 } 34 34 35 $pa = new CleverPager('select `id`,`wss_partner`, LEFT(`name`, 25) as `name`, `place`, `rating_sum`/`ratings` as `rating`, `version`, `type`, `xp`, `online` /`online_checks` as `online`, `online_players_sum`/`player_checks` as `players` from `servers` where `place`=1 '.$order, 'p');35 $pa = new CleverPager('select `id`,`wss_partner`, LEFT(`name`, 25) as `name`, `place`, `rating_sum`/`ratings` as `rating`, `version`, `type`, `xp`, `online`, `online_players_sum`/`player_checks` as `players` from `servers` where `place`=1 '.$order, 'p'); 36 36 $pa->PageSize = $Config['DisplayServerCountPerPage']; 37 37 $pa->PageLinksDisplayed = 5; … … 65 65 $tpl->output['servers_data'] .='<td>'.$xp.'</td>'; 66 66 $tpl->output['servers_data'] .='<td>'.(int)$row['players'].'</td>'; 67 $tpl->output['servers_data'] .='<td>'. (100*$row['online']).'%</td>';67 $tpl->output['servers_data'] .='<td>'.$row['online'].'%</td>'; 68 68 $tpl->output['servers_data'] .='</tr>'; 69 69 } -
pages/wss_partners.php
r3 r6 5 5 $tpl->output['place'] = $text['info_place']; 6 6 $tpl->output['wss_partners_h2'] = $menu['mm2']; 7 if(!array_key_exists('order', $_GET)) $_GET['order'] = 0; 7 8 $order_index = (int) $_GET['order']; 8 9 switch ($order_index) 9 10 { 10 case 0: $order = ' order by `name` desc'; break;11 case 0: $order = ' order by `name`'; break; 11 12 case 1: $order = ' order by `rating` desc '; break; 12 13 case 2: $order = ' order by `version` desc '; break; … … 32 33 } 33 34 34 $pa = new CleverPager('select `id`,`wss_partner`, LEFT(`name`, 25) as `name`, `place`, `rating_sum`/`ratings` as `rating`, `version`, `type`, `xp`, `online` /`online_checks` as `online`, `online_players_sum`/`player_checks` as `players` from `servers` where `wss_partner`=1 '.$order, 'p');35 $pa = new CleverPager('select `id`,`wss_partner`, LEFT(`name`, 25) as `name`, `place`, `rating_sum`/`ratings` as `rating`, `version`, `type`, `xp`, `online`, `online_players_sum`/`player_checks` as `players` from `servers` where `wss_partner`=1 '.$order, 'p'); 35 36 $pa->PageSize = 20; 36 37 $pa->PageLinksDisplayed = 5; … … 64 65 $tpl->output['servers_data'] .='<td>'.$xp.'</td>'; 65 66 $tpl->output['servers_data'] .='<td>'.(int)$row['players'].'</td>'; 66 $tpl->output['servers_data'] .='<td>'. (100*$row['online']).'%</td>';67 $tpl->output['servers_data'] .='<td>'.$row['online'].'%</td>'; 67 68 $tpl->output['servers_data'] .='</tr>'; 68 69 } -
scripts/check.php
r3 r6 1 1 <?php 2 /* 2 3 require ('../includes/config.php'); 3 4 $db = new tMySql; … … 8 9 $db->connect(); 9 10 10 $db->query('del', 'select `id`, `created` from `servers` where (`online` /`online_checks`) < 0.8');11 $db->query('del', 'select `id`, `created` from `servers` where (`online`) < 0.8'); 11 12 while ($row = $db->fetch_assoc('del')) 12 13 { … … 16 17 } 17 18 } 19 */ 20 18 21 ?> -
scripts/online.php
r5 r6 3 3 require ('../includes/config.php'); 4 4 5 mysql_connect($db_config['host'], $db_config['user'], $db_config['pass']);6 mysql_select_db($db_config['name']);5 $Database = new mysqli($db_config['host'], $db_config['user'], $db_config['pass']); 6 $Database->select_db($db_config['name']); 7 7 8 8 function CheckPortStatus($Ip, $Port) … … 12 12 { 13 13 fclose($Socket); 14 return( true);14 return(1); 15 15 } else 16 16 { 17 return( false);17 return(0); 18 18 } 19 19 } 20 20 21 $TextState = array('Offline', 'Online'); 22 21 23 echo("Kontroluji stav serveru...<br>\n"); 24 $PlayersCount = 0; 22 25 $OnlineCount = 0; 23 26 $OfflineCount = 0; 24 $Servers = mysql_query("SELECT `id`,`ip`,`port`,`name` FROM `servers`");25 while($Server = mysql_fetch_array($Servers))27 $Servers = $Database->query("SELECT `id`,`ip`,`port`,`name` FROM `servers`"); 28 while($Server = $Servers->fetch_array()) 26 29 { 27 30 echo($Server['name'].' - '); 28 if(CheckPortStatus($Server['ip'], $Server['port'])) 29 { 30 mysql_query("UPDATE `servers` SET `online_checks` = `online_checks` + 1, `online` = `online` + 1 WHERE `id`=".$Server['id']); 31 echo('Online'); 32 $OnlineCount++; 33 } else 34 { 35 mysql_query("UPDATE `servers` SET `online_checks` = `online_checks` + 1 WHERE `id` =".$Server['id']); 36 echo('Offline'); 37 $OfflineCount++; 38 } 39 echo("<br>\n"); 31 $OnlineState = CheckPortStatus($Server['ip'], $Server['port']); 32 $OnlineCount += $OnlineState; 33 $OfflineCount += 1 - $OnlineState; 34 // Insert new online state 35 $Database->query("INSERT INTO `servers_online` (`server` ,`time` ,`state` ,`players_count`) VALUES (".$Server['id'].", NOW() , ".$OnlineState.", ".$PlayersCount.")"); 36 37 // Delete old records 38 $Database->query("DELETE FROM `servers_online` WHERE `server` = ".$Server['id']." AND time < DATE_SUB(NOW(), INTERVAL 1 DAY)"); 39 40 // Calculate cached percentage online state 41 $DbResult = $Database->query("SELECT COUNT(*) as `count`, SUM(`state`) as `online` FROM `servers_online` WHERE `server` = ".$Server['id']); 42 $DbRow = $DbResult->fetch_array(); 43 $Database->query("UPDATE `servers` SET `online` = ".round($DbRow['online'] / $DbRow['count'] * 100, 2)." WHERE `id` = ".$Server['id']); 44 $DbResult->free(); 45 echo($TextState[$OnlineState]."<br>\n"); 46 flush(); 40 47 } 41 mysql_free_result($Servers);48 $Servers->free(); 42 49 43 50 echo('Total: '.($OnlineCount + $OfflineCount).', Online: '.$OnlineCount.', Offline: '.$OfflineCount."<br>\n");
Note:
See TracChangeset
for help on using the changeset viewer.