<td class="username">' . $row['p_username'] . '</td> <td class="firstname">' . $row['p_first_name'] . '</td> <td class="lastname">' . $row['p_last_name'] . '</td> <td>' . $row['p_email'] . '</td> <td>' . date($CFG_SHORTDATE, $row['u_created']) . '</td> <td class="passbox"><input type="checkbox" name="resetpass[]" value="' . $row['p_id'] . '" /></td> <td class="adminbox"><input type="checkbox" name="admin[]" value="' . $row['p_id'] . '"' . $check . ' /></td> <td class="checkbox"><input type="checkbox" name="delete[]" value="' . $row['p_id'] . '" /></td> </tr>'; ++$i; } $contents .= ' </tbody> </table> '; $contents .= get_sorttable_script($table_id, 'Number,StringCI,StringCI,StringCI,StringCI,DateTime,None,None,None'); $contents .= ' <input type="submit" value="Continue" name="submit" class="button" /><br /> <br /> <div class="inputlabel"><input type="button" value="Email ALL registered users" onclick="javascript:window.open(\'massmail.php\',\'message\',\'resizable,width=600,height=500,top=100,left=100\',\'_blank\');return false;" /></div> </form> '; $hint = array('Here you can set users to be admin, or delete users.', 'When deleting users, the script will also delete all information regarding that user, such as games, messages, etc.', 'You can also send an e-mail to all registered users by clicking the link below the form.'); $html = get_item($contents, $hint); break; // ==================================================== // ==================================================== default: // do nothing, it's already been done in index.inc.php break; }
function get_game_table($label, $no_data_label, $data, $type = 'full') { global $mysql; global $CFG_CHESS960, $CFG_LONGDATE; if (!is_array($data) || 0 == count($data)) { $html = '<div class="notable">' . $no_data_label . '</div>'; } else { $sort_c960 = $CFG_CHESS960 ? ' , StringCI' : ''; $sort_finished = 'finished' == $type ? ' , StringCI' : ''; $sort_invite = 'invite' == $type ? ' , None' : ' , LongDate'; $sort_moves = 'invite' == $type ? ' , StringCI' : ' , Number'; $sort_gameid = 'invite' == $type ? '' : 'Number , '; $sort = $sort_gameid . 'StringCI , StringCI , StringCI ' . $sort_moves . $sort_c960 . $sort_finished . ' , LongDate ' . $sort_invite; call($sort); $table_id = get_table_id(); $link_table = 'invite' != $type ? ' link-table' : ''; $html = '<table class="sort-table' . $link_table . '" id="' . $table_id . '"> <caption>' . $label . '</caption> <thead> <tr> '; if ('invite' != $type) { $html .= '<th title="Game ID Number">Game</th>'; } $html .= ' <th title="White\'s username">White</th> <th title="Black\'s username">Black</th> <th title="Who\'s turn it is">Turn</th> '; if ('invite' != $type) { $html .= '<th title="Moves">Moves</th>'; } else { $html .= '<th title="Status">Status</th>'; } if ($CFG_CHESS960) { $html .= '<th title="Game Type">Type</th>'; } if ('finished' == $type) { $html .= '<th title="Game Result">Result</th>'; } $html .= ' <th title="Start Date of the Game">Start Date</th> '; if ('invite' != $type) { $html .= '<th title="Date / Time of Last Move">Last Move</th>'; } else { $html .= '<th title="Action">Action</th>'; } $html .= ' </tr> </thead> <tbody> '; $i = 0; foreach ($data as $game) { // we need some default values for some variables $myturn = false; $white = ''; $black = ''; $curMove = 0 == $game['num_moves'] % 2 ? 'white' : 'black'; switch ($type) { case 'mine': $link = ' onclick="loadGame(' . $game['g_id'] . ');"'; // based on number of moves, figure out who's turn it is $color = $game['g_white_player_id'] == $_SESSION['player_id'] ? 'white' : 'black'; if ($curMove == $color) { $myturn = true; } break; case 'others': $link = ' onclick="watchGame(' . $game['g_id'] . ');"'; break; case 'finished': $link = ' onclick="watchGame(' . $game['g_id'] . ');"'; if ($game['g_white_player_id'] == $_SESSION['player_id']) { $link = ' onclick="loadGame(' . $game['g_id'] . ');"'; $white = ' class="notice"'; } elseif ($game['g_black_player_id'] == $_SESSION['player_id']) { $link = ' onclick="loadGame(' . $game['g_id'] . ');"'; $black = ' class="notice"'; } if (is_null($game['g_game_message'])) { $result = ''; } else { if ('Draw' == $game['g_game_message']) { $result = '½-½'; } elseif ('Player Resigned' == $game['g_game_message']) { $result = 'white' == $game['g_message_from'] ? '0-1' : '1-0'; $result .= ' <abbr title="Resignation">R</abbr>'; } elseif ('Checkmate' == $game['g_game_message']) { $result = 'white' == $game['g_message_from'] ? '1-0' : '0-1'; $result .= ' <abbr title="Checkmate">CM</abbr>'; } else { $result = ''; } } break; case 'invite': $link = ''; $from = $game['white_username'] == $_SESSION['username'] ? 'white' : 'black'; $status = substr($game['g_game_message'], strrpos(trim($game['g_game_message']), ' ') + 1); $status = 'Declined' == $status ? '<span class="notice">' . $status . '</span>' : $status; // based on which it is, outvite or invite, make the buttons if (isset($game['invite'])) { $buttons = ' <input class="tblbutton" type="button" value="Accept" onclick="sendresponse(\'accepted\',\'' . $from . '\',' . $game['g_id'] . ')" /> <input class="tblbutton" type="button" value="Decline" onclick="sendresponse(\'declined\',\'' . $from . '\',' . $game['g_id'] . ')" /> '; } else { $buttons = ' <input class="tblbutton" type="button" value="Withdraw" onclick="withdrawrequest(' . $game['g_id'] . ')" /> '; } break; } // end type switch $alt = 0 == $i % 2 ? true : false; call($myturn); $class = ''; if ($myturn || $alt) { $class = ' class="'; if ($myturn && $alt) { $class .= 'myturn alt'; } elseif ($alt) { $class .= 'alt'; } else { $class .= 'myturn'; } $class .= '"'; } $html .= "<tr{$link}{$class}>\n"; if ('invite' != $type) { $html .= "\t<td class=\"numeric\">{$game['g_id']}</td>\n"; } $html .= "\t<td{$white}>{$game['white_username']}</td>\n"; $html .= "\t<td{$black}>{$game['black_username']}</td>\n"; $html .= "\t<td>" . ucfirst($curMove) . "</td>\n"; if ('invite' != $type) { $html .= "\t<td class=\"numeric\">" . floor($game['num_moves'] / 2) . "</td>\n"; } else { $html .= "\t<td>" . $status . "</td>\n"; } if ($CFG_CHESS960) { $gametype = 518 != $game['g_id960'] ? 'C960' : 'Normal'; $html .= "\t<td>{$gametype}</td>\n"; } if ('finished' == $type) { $html .= "\t<td>{$result}</td>\n"; } $html .= "\t<td class=\"date\">" . date($CFG_LONGDATE, $game['u_date_created']) . "</td>\n"; if ('invite' != $type) { $html .= "\t<td class=\"date\">" . date($CFG_LONGDATE, $game['u_last_move']) . "</td>\n"; } else { $html .= "\t<td class=\"buttons\">" . $buttons . "</td>\n"; } $html .= '</tr>'; ++$i; } $html .= ' </tbody> </table> '; $html .= get_sorttable_script($table_id, $sort); } return $html; }