* GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
include_once 'hndl/common.php';
include_once 'inc/game.php';
include_once 'inc/msg_functions.php';
$return_vars['page'] = 'player';
do {
    // Dummy Loop
    if (MESSAGE_TURN_COST > $spacegame['player']['turns']) {
        $return_codes[] = 1018;
        break;
    }
    if (!isset($_REQUEST['player']) || !validate_playername($_REQUEST['player'])) {
        $return_codes[] = 1011;
        break;
    }
    if (!isset($_REQUEST['message'])) {
        $return_codes[] = 1136;
        break;
    }
    $len = strlen($_REQUEST['message']);
    if ($len <= 0) {
        $return_codes[] = 1136;
        break;
    }
    if ($len > MAXIMUM_MESSAGE_LENGTH) {
        $return_codes[] = 1149;
        break;
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
define('CLOSE_SESSION', false);
include_once 'inc/page.php';
if (isset($_SESSION['form_id'])) {
    if (!isset($_REQUEST['form_id']) || $_SESSION['form_id'] != $_REQUEST['form_id']) {
        header('Location: viewport.php?rc=1181');
        die;
    }
}
$return_page = 'select_player';
do {
    /* Dummy loop for "break" support. */
    $player_name = $_POST['player_name'];
    $player_race = $_POST['player_race'];
    if (!validate_playername($player_name)) {
        // TODO: Log possible cheat attempt
        $return_codes[] = 1011;
        break;
    }
    if ($player_race < 0 || !is_numeric($player_race)) {
        error_log('User ' . USER_ID . ' from ' . $_SERVER['REMOTE_ADDR'] . ' attempted to access an invalid race.');
        $return_codes[] = 1009;
        break;
    }
    $race_list = array();
    $race_count = 0;
    $db = isset($db) ? $db : new DB();
    $rs = $db->get_db()->query("select record_id, caption from races order by record_id");
    $rs->data_seek(0);
    while ($row = $rs->fetch_assoc()) {
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
include_once 'tmpl/common.php';
define('SENT_MSG_TYPE', 1);
include_once 'inc/messages.php';
$name = '';
if (isset($_REQUEST['name']) && validate_playername($_REQUEST['name'])) {
    $name = $_REQUEST['name'];
}
?>
<div class="header2">Message Player</div>
<div class="docs_text">
	Sends a message to a specific <a href="alliance.php?page=players">player</a> by name.	
</div>
<div class="docs_text">
	<form action="handler.php" method="post">
		<table class="message">
			<tr class="message">
				<td class="message">Player:</td>
				<td class="message"><input class="msg_form_input" type="text" name="player" value="<?php 
echo $name;
?>