<?php

require_once "lib/menus/database/editTable_functions.php";
$tableDetails = getTableDetails();
$errors = getTableDetailErrors($schema);
if ($errors) {
    alert($errors);
}
showHeader();
?>

<form method="post" action="?" autocomplete="off">
<input type="submit" style="width: 0px; height: 0px; position: absolute; border: none; padding: 0px" /> <!-- bugfix: hitting enter in textfield submits first submit button on form -->
<input type="hidden" name="menu" value="database" />
<input type="hidden" name="_defaultAction" value="editTable" />
<input type="hidden" name="tableName" id="tableName" value="<?php 
echo htmlencode(getTableNameWithPrefix($_REQUEST['tableName']));
?>
" />
<input type="hidden" name="menuOrder" value="<?php 
echo htmlencode(@$schema['menuOrder']);
?>
" />
<?php 
echo security_getHiddenCsrfTokenField();
?>

<div class="content-box list-tables">

  <div class="content-box-header">
    <h3>
Example #2
0
		</table>
		</form>
	</td>
</tr>
</table>
</body>

</html>
<?php 
    exit;
}
// Two stages for every logged in user: viewing one table, viewing table list
// on a table
if (isset($_GET['table']) && ($arrTable = db_select(TABLE_TABLES, 'id = ' . (int) $_GET['table'])) && 1 == count($arrTable)) {
    define('TABLE_ID', (int) $arrTable[0]['id']);
    $arrTable = getTableDetails($arrTable[0]);
    $bPlaying = 0 < count($arrPlayer = db_select(TABLE_PLAYERS, 'table_id = ' . TABLE_ID . ' AND user_id = ' . USER_ID));
    if ($bPlaying) {
        db_update(TABLE_PLAYERS, 'online = ' . time(), 'user_id = ' . USER_ID . ' AND table_id = ' . TABLE_ID);
        $arrPlayer = $arrPlayer[0];
        // leave table //
        if (isset($_GET['leave_seat'])) {
            if (db_delete(TABLE_PLAYERS, 'table_id = ' . TABLE_ID . ' AND user_id = ' . USER_ID . ' AND balance = ' . (double) $arrPlayer['balance']) && 0 < db_affected_rows()) {
                db_update(TABLE_USERS, 'balance=balance+' . (double) $arrPlayer['balance'], 'id = ' . USER_ID);
            }
            header('Location: ?table=' . TABLE_ID);
            exit;
        }
        // post action / contribute //
        if (isset($_POST['action'])) {
            if ($arrPlayer['seat'] !== $arrTable['current_seat'] || '1' === $arrPlayer['sit_out'] || 'in' !== $arrPlayer['in_or_out']) {