示例#1
0
文件: admin.php 项目: benjamw/pharaoh
    $contents .= '
		<form method="post" action="' . $_SERVER['REQUEST_URI'] . '"><div class="action">
			<input type="hidden" name="token" value="' . $_SESSION['token'] . '" />
			' . $table . '
			<select name="game_action" id="game_action">
				<option value="">With Selected:</option>
				<option value="pause">Pause</option>
				<option value="unpause">Unpause</option>
				<option value="delete">Delete</option>
			</select>
		</div></form>';
} else {
    $contents .= $table;
}
// get the setups
$setup_list = Setup::get_list();
// go through the setups list and remove any that currently have games
foreach ($setup_list as $key => $setup) {
    if ($setup['current_games']) {
        unset($setup_list[$key]);
    }
}
$table_meta = array('sortable' => true, 'no_data' => '<p>There are no setups to show</p><!-- NO_GAMES -->', 'caption' => 'Setups');
$table_format = array(array('SPECIAL_CLASS', '(0 != [[[current_games]]])', 'lowlight'), array('Setup', 'name'), array('Used', 'used'), array('Horus', '###(([[[has_horus]]]) ? \'Yes\' : \'No\')'), array('Reflection', 'reflection'), array('Created', '###date(Settings::read(\'long_date\'), strtotime(\'[[[created]]]\'))', null, ' class="date"'), array('Creator', '###((0 == [[[created_by]]]) ? \'Admin\' : $GLOBALS[\'_PLAYERS\'][[[[created_by]]]])'), array('<input type="checkbox" id="setup_all" />', '<input type="checkbox" name="ids[]" value="[[[setup_id]]]" class="setup_box" />', 'false', 'class="edit"'));
$table = get_table($table_format, $setup_list, $table_meta);
if (false === strpos($table, 'NO_GAMES')) {
    $contents .= '
		<form method="post" action="' . $_SERVER['REQUEST_URI'] . '"><div class="action">
			<input type="hidden" name="token" value="' . $_SESSION['token'] . '" />
			' . $table . '
			<select name="setup_action" id="setup_action">
示例#2
0
$players = array_diff($invite_players, $players_maxed);
$opponent_selection = '';
$opponent_selection .= '<option value="">-- Open --</option>';
foreach ($players_full as $player) {
    if ($_SESSION['player_id'] == $player['player_id']) {
        continue;
    }
    if (in_array($player['player_id'], $players)) {
        $opponent_selection .= '
			<option value="' . $player['player_id'] . '">' . $player['username'] . '</option>';
    }
}
$groups = array('Normal' => array(0, 0), 'Eye of Horus' => array(0, 1), 'Sphynx' => array(1, 0), 'Sphynx & Horus' => array(1, 1));
$group_names = array_keys($groups);
$group_markers = array_values($groups);
$setups = Setup::get_list();
$setup_selection = '<option value="0">Random</option>';
$setup_javascript = '';
$cur_group = false;
$group_open = false;
foreach ($setups as $setup) {
    $marker = array((int) $setup['has_sphynx'], (int) $setup['has_horus']);
    $group_index = array_search($marker, $group_markers, true);
    if ($cur_group !== $group_names[$group_index]) {
        if ($group_open) {
            $setup_selection .= '</optgroup>';
            $group_open = false;
        }
        $cur_group = $group_names[$group_index];
        $setup_selection .= '<optgroup label="' . $cur_group . '">';
        $group_open = true;
示例#3
0
 /** static public function get_setup_stats_list
  *		Gets the list of all the setups with
  *		additional stats included in the list
  *
  * @param void
  * @return array setups
  */
 public static function get_setup_stats_list()
 {
     $Mysql = Mysql::get_instance();
     $setups = Setup::get_list(true);
     if ($setups) {
         // add some more stats
         $query = "\n\t\t\t\tSELECT o.setup_id\n\t\t\t\t\t, COUNT(ww.win) AS white_wins\n\t\t\t\t\t, COUNT(bw.win) AS black_wins\n\t\t\t\t\t, COUNT(d.win) AS draws\n\t\t\t\tFROM " . self::GAME_STATS_TABLE . " AS o\n\t\t\t\t\tLEFT JOIN " . self::GAME_STATS_TABLE . " AS ww\n\t\t\t\t\t\tON (o.setup_id = ww.setup_id\n\t\t\t\t\t\t\tAND o.game_id = ww.game_id\n\t\t\t\t\t\t\tAND ww.win = 1\n\t\t\t\t\t\t\tAND ww.color = 'white')\n\t\t\t\t\tLEFT JOIN " . self::GAME_STATS_TABLE . " AS bw\n\t\t\t\t\t\tON (o.setup_id = bw.setup_id\n\t\t\t\t\t\t\tAND o.game_id = bw.game_id\n\t\t\t\t\t\t\tAND bw.win = 1\n\t\t\t\t\t\t\tAND bw.color = 'black')\n\t\t\t\t\tLEFT JOIN " . self::GAME_STATS_TABLE . " AS d\n\t\t\t\t\t\tON (o.setup_id = d.setup_id\n\t\t\t\t\t\t\tAND o.game_id = d.game_id\n\t\t\t\t\t\t\tAND d.win = 0\n\t\t\t\t\t\t\tAND d.color = 'white')\n\t\t\t\tGROUP BY o.player_id\n\t\t\t";
         $results = $Mysql->fetch_array($query);
         $stats = array();
         foreach ($results as $stat) {
             $stats[$stat['setup_id']] = $stat;
         }
         $empty = array('white_wins' => 0, 'black_wins' => 0, 'draws' => 0);
         foreach ($setups as &$setup) {
             // be careful with the reference
             if (isset($stats[$setup['setup_id']])) {
                 $setup = array_merge($setup, $stats[$setup['setup_id']]);
             } else {
                 $setup = array_merge($setup, $empty);
             }
         }
         unset($setup);
         // kill the reference
     }
     return $setups;
 }