Example #1
0
        unset($_SESSION['userschema']);
        unset($_SESSION['userrights']);
        header('refresh: 0');
        header('url: ' . $_SESSION['PHP_SELF'], false);
        echo "<body bgcolor=#203264></body>";
        //		header('Location: '.$_SESSION['PHP_SELF']);
        //		die('<p align=center>Back to <a href="' . $_SESSION['PHP_SELF'] . '">phpCommish</a>.</p>');
    } else {
        echo $ht_first . "<form method=post action=" . $_SERVER['PHP_SELF'] . "><input type=image src=\"../img/logout.png\" alt=\"Logout\" name=logout value=\"Logout!\"></form>" . $ht_sec;
    }
} else {
    if (isset($_POST['login'])) {
        //They have posted something!
        include 'sql_connect.php';
        $sql = "select * from t_user u, t_schema s where u.t_schema_id = s.t_schema_id AND t_user_name = '" . $_POST['user'] . "' and t_user_pass = MD5('" . $_POST['pass'] . "')";
        $result = mysql_query($sql) or die(b_error('Select user failed', $sql));
        if (mysql_num_rows($result) >= 1) {
            $line = mysql_fetch_array($result);
            //They have sent us the correct login information!
            $_SESSION['userid'] = $line['t_user_id'];
            $_SESSION['userschema'] = $line['s.t_schema_id'];
            $_SESSION['userrights'] = $line['t_schema_rights'];
            header('refresh: 0');
            header('url: ' . $_SESSION['PHP_SELF'], false);
            echo "<body bgcolor=#203264></body>";
            die('<p align=center>Back to <a href="' . $_SESSION['PHP_SELF'] . '">phpCommish</a>.</p>');
            //The user has been redirected back to the main page and it should say they they have logged in!
        } else {
            //They failed to send us the correct username or password!
            die($ht_first . $ht_sec . '<center><b>Incorrect username or password!</b></center></body></html>');
        }
Example #2
0
include 'sql_connect.php';
include 'library.inc.php';
?>
</head>
<body bgcolor="#203264">

<center>

<P><table border=1 cellpadding=1 cellspacing=1 bgcolor="#ffffff"><tr><td>

<table summary="Main View">

<tr><td bgcolor="#ffffff" colspan=2 align=center>
<table border=1 cellpadding=0 cellspacing=0>
<tr><th>Username</th><th>User schema</th></tr>
<?php 
$sql = 'SELECT t_user_id, t_user_name, s.t_schema_id, t_schema_name FROM t_user u, t_schema s WHERE u.t_schema_id = s.t_schema_id';
$r_sql = mysql_query($sql) or die(b_error('Select users failed', $sql));
while ($n_sql = mysql_fetch_array($r_sql)) {
    echo "<tr><td>" . $n_sql['t_user_name'] . "</td><td>" . $n_sql['t_schema_name'] . "</td>";
    echo "<td>" . ($_SESSION['userrights'] == 255 ? "<td><form method=post action=\"" . $PHP_SELF . "\"><input type=submit name=user_edit value=Edit></form>" : "&nbsp;") . "</td></tr>";
}
?>
</table>
</td></tr>
</table>
</td></tr>
</table>
</center>
</body>
</html>
Example #3
0
function viewtable($division)
{
    // Prints a table of the league standings in a given division
    // sql to use when selecting from views (does not work as there is no views currently)
    //$sql = 'SELECT * FROM v_table WHERE t_division_ID = ' . $division ;
    // sql to use when selecting from plain sql
    $sql = 'SELECT' . ' t_division_ID,' . ' t_team_name, ' . ' count(t_team_name) n_games, ' . ' sum(win) s_win, ' . ' sum(draw) s_draw, ' . ' sum(loss) s_loss, ' . ' sum(h_td) s_h_td, ' . ' sum(a_td) s_a_td, ' . ' sum(td_diff) s_td_diff, ' . ' sum(h_cas) s_h_cas, ' . ' sum(a_cas) s_a_cas, ' . ' sum(cas_diff) s_cas_diff, ' . ' sum(pts) s_pts' . ' FROM ' . ' ((' . ' SELECT ' . ' t_division_ID,' . ' ta.t_team_name, ' . ' t_game_h_td h_td, ' . ' t_game_a_td a_td, ' . ' t_game_h_td-t_game_a_td td_diff,' . ' t_game_h_cas h_cas, ' . ' t_game_a_cas a_cas, ' . ' t_game_h_cas-t_game_a_cas cas_diff,' . ' (t_game_h_td>t_game_a_td) win, ' . ' (t_game_h_td=t_game_a_td) draw, ' . ' (t_game_h_td<t_game_a_td) loss,' . ' ((t_game_h_td-t_game_a_td)=0)+((t_game_h_td-t_game_a_td)>0)*3 pts' . ' FROM t_game ga, t_team ta' . ' WHERE ga.t_h_team_ID = ta.t_team_ID' . ' ) UNION ALL (' . ' SELECT ' . ' t_division_ID,' . ' tb.t_team_name, ' . ' t_game_a_td h_td, ' . ' t_game_h_td a_td, ' . ' t_game_a_td-t_game_h_td td_diff,' . ' t_game_a_cas h_cas, ' . ' t_game_h_cas a_cas, ' . ' t_game_a_cas-t_game_h_cas cas_diff,' . ' (t_game_h_td<t_game_a_td) win, ' . ' (t_game_h_td=t_game_a_td) draw, ' . ' (t_game_h_td>t_game_a_td) loss,' . ' ((t_game_a_td-t_game_h_td)=0)+((t_game_a_td-t_game_h_td)>0)*3 pts' . ' FROM t_game gb, t_team tb' . ' WHERE gb.t_a_team_ID = tb.t_team_ID' . ' ))' . ' AS r_table' . ' WHERE t_division_ID = ' . $division . ' GROUP BY t_team_name' . ' ORDER BY s_pts DESC, s_td_diff DESC, s_cas_diff DESC;';
    $r_tab = mysql_query($sql) or die(b_error("View table query failed!\n", $sql));
    echo "<table summary=\"Results table\" bgcolor=#ffffff border=1 cellpadding=0 cellspacing=0>\n";
    echo "<tr><td colspan=9 align=center><b><i>Table</i></b></td></tr>\n";
    echo "<tr><th align=left>Team</th><th>Played</th><th>W</th><th>D</th><th>L</th><th>TD</th><th>TD diff</th><th>Cas.</th><th>Cas diff</th><th>Points</th></tr>\n";
    while ($n_tab = mysql_fetch_array($r_tab)) {
        echo "<tr><td>" . $n_tab[1] . "</td>\n";
        echo "<td align=center>" . $n_tab[2] . "</td>\n";
        echo "<td align=center>" . $n_tab[3] . "</td>\n";
        echo "<td align=center>" . $n_tab[4] . "</td>\n";
        echo "<td align=center>" . $n_tab[5] . "</td>\n";
        echo "<td align=center>" . $n_tab[6] . "-" . $n_tab[7] . "</td>\n";
        echo "<td align=center>" . $n_tab[8] . "</td>\n";
        echo "<td align=center>" . $n_tab[9] . "-" . $n_tab[10] . "</td>\n";
        echo "<td align=center>" . $n_tab[11] . "</td>\n";
        echo "<td align=center>" . $n_tab[12] . "</td>\n";
        echo "</tr>";
    }
    echo "</table>";
}
Example #4
0
function get_sqlresult($sql, $queryname)
{
    $result = mysql_query($sql) or die(b_error($queryname . " failed!", $sql));
    return $result;
}