game_day/arrow.php 0000664 0000764 0000764 00000002426 10411127057 014741 0 ustar ganzhorn ganzhorn * * This file is part of Game Day. * * Game Day is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Game Day 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 Game Day; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * $Id: arrow.php,v 1.2 2005/07/20 03:17:00 ganzhorn Exp $ */ header("Content-type: image/png"); include("./graphics.php"); function def($var,$def) { if( null== $var ) { return $def; } else { return $var; } } $y = def($_GET['h'],16); $x = def($_GET['w'],$y/1.2); $color = def($_GET['color'],"000000"); $r = def($_GET['r'],0); $g = def($_GET['g'],0); $b = def($_GET['b'],0); $dir = def($_GET['d'],"l"); $img = d_arrow($x,$y,$dir,$r,$g,$b); imagepng($img); imagedestroy($img); ?> game_day/chat_definition.php 0000664 0000764 0000764 00000002250 10411127057 016731 0 ustar ganzhorn ganzhorn * * This file is part of Game Day. * * Game Day is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Game Day 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 Game Day; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * $Id: chat_definition.php,v 1.3 2005/07/20 03:29:06 ganzhorn Exp $ */ require('../chat/chat.php'); class GameDayChat extends Chat { function MChat($channel="default") { parent::Chat($channel); } // reimplimented db login function user() { return USER; } function password() { return PASSWD; } function database() { return CHAT_DATABASE; } }; ?> game_day/chat_message.php 0000664 0000764 0000764 00000002561 10411127057 016232 0 ustar ganzhorn ganzhorn * * This file is part of Game Day. * * Game Day is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Game Day 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 Game Day; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * $Id: chat_message.php,v 1.4 2005/07/20 03:29:06 ganzhorn Exp $ */ require_once("./config.php"); require("./db.php"); require("./chat_definition.php"); if( !$user_api->is_active() ) { error_text("Cannot post without being logged in!"); } else if( null == $_POST['channel'] ) { error_text("Internal error."); } else { $channel = $_POST['channel']; $chat = new GameDayChat($channel); $chat->message($user_api->name(),$_POST['message']); if( null == $_POST['load_uri'] ) { $uri = HOME_URI; } else { $uri = $_POST['load_uri']; } header("Location: $uri"); } ?> game_day/config.template.php 0000664 0000764 0000764 00000002211 10275016330 016655 0 ustar ganzhorn ganzhorn * * This file is part of Game Day. * * Game Day is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Game Day 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 Game Day; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * $Id: config.template.php,v 1.1 2005/08/06 02:13:44 ganzhorn Exp $ */ // Database access variables define(USER,"sql user name"); define(PASSWD,"sql password"); define(GAME_DATABASE,"sql database"); // Chat configuration define(CHAT_DATABASE,"chat database"); // Change this to the root url directory of your project define(HOME_URI,"home uri"); ?> game_day/corner.php 0000664 0000764 0000764 00000002344 10411127057 015076 0 ustar ganzhorn ganzhorn * * This file is part of Game Day. * * Game Day is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Game Day 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 Game Day; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * $Id: corner.php,v 1.4 2005/07/20 03:17:00 ganzhorn Exp $ */ header("Content-type: image/png"); include("./graphics.php"); include("./util.php"); $y = def($_GET['h'],16); $x = def($_GET['w'],16); $color = def($_GET['color'],"000000"); $r = def($_GET['r'],0); $g = def($_GET['g'],0); $b = def($_GET['b'],0); $f = def($_GET['f'],1); $dir = def($_GET['d'],"ul"); $img = d_corner($x,$y,$dir,$r,$g,$b,$f); imagepng($img); imagedestroy($img); ?> game_day/db.php 0000664 0000764 0000764 00000022242 10411127057 014172 0 ustar ganzhorn ganzhorn * * This file is part of Game Day. * * Game Day is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Game Day 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 Game Day; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * $Id: db.php,v 1.19 2005/08/06 02:09:55 ganzhorn Exp $ */ require_once("./config.php"); require("./session.php"); require("./util.php"); // // "norf" -> noon or five // if( $db_loaded ) { return; } $db_loaded=1; $gd_connection=0; $user_api = new UserAPI(); // User API class UserAPI { function name() { if( UserAPI::is_active() ) { return $_SESSION['ActiveUser']; } else { return null; } } function email() { if( UserAPI::is_active() ) { return get_user_email($this->name()); } else { return null; } } function is_active() { return (null != $_SESSION['ActiveUser'] ); } function is_admin() { if( !UserAPI::is_active() ) { return 0; } gd_db_open(); $user = $_SESSION['ActiveUser']; $query=sprintf("SELECT is_admin FROM users WHERE name='%s'", mysql_real_escape_string($user)); $result = mysql_query($query); if( $result && mysql_numrows($result) ) { return mysql_result($result,0,"is_admin"); } return 0; } function logout() { unset($_SESSION['ActiveUser']); } function login($email,$pass) { gd_db_open(); $email=trim($email); $pass=trim($pass); $query=sprintf("SELECT name FROM users WHERE email='%s' && password='%s'", mysql_real_escape_string($email), mysql_real_escape_string($pass)); $result = mysql_query($query); if( $result && mysql_numrows($result) ) { $_SESSION['ActiveUser'] = mysql_result($result,0,"name"); return 1; } else { return 0; } } }; function field_exists($table,$field,$value) { gd_db_open(); $field = mysql_real_escape_string($field); $table = mysql_real_escape_string($table); $value = mysql_real_escape_string($value); $query = "SELECT COUNT($field) FROM $table WHERE $field='$value'"; $result = mysql_query($query); if( NULL == $result ) { $num = 0; } else { $num = mysql_result($result,0); } return $num; } function get_user_email($user) { global $user_api; if( !$user_api->is_active() ) { die("Must be logged in to call this fn."); } gd_db_open(); $query = "SELECT email FROM users WHERE name='$user'"; $result = mysql_query($query); if( $result ) { return mysql_result($result,0,"email"); } return null; } function get_all_email_addrs() { global $user_api; if( !$user_api->is_active() ) { die("Must be logged in to call this fn."); } $email_pattern = '/^[A-Z0-9._-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i'; gd_db_open(); $query = "SELECT email FROM users"; $result = mysql_query($query); while( $row = mysql_fetch_object($result) ) { if( preg_match($email_pattern,$row->email) ) { $addrs[] = $row->email; } } return $addrs; } function get_locations() { gd_db_open(); $query = "SELECT * FROM locations"; $result = mysql_query($query); $stop = mysql_numrows($result); $i = 0; $return; while( $i < $stop ) { $name = mysql_result($result,$i,"name"); $return[$name] = array("street"=>mysql_result($result,$i,"street"), "zip"=>mysql_result($result,$i,"zip")); ++$i; } return $return; } function add_user($user,$email,$password) { gd_db_open(); $user=mysql_real_escape_string(trim($user)); $email=mysql_real_escape_string(trim($email)); $password=mysql_real_escape_string(trim($password)); $query = "INSERT INTO users (name,email,password) VALUES " . "('$user','$email','$password')"; $result = mysql_query($query); $error = 0; if( !$result ) { error_text(mysql_error()); $error = 1; } return !$error; } function gd_db_open() { $gd_connection = mysql_connect(localhost,USER,PASSWD); mysql_select_db(GAME_DATABASE) or die( "Unable to select database" ); } function game_exists($court,$day,$norf="noon") { $court_id = location_to_id($court); $day = mysql_real_escape_string($day); $norf = mysql_real_escape_string($norf); $court = mysql_real_escape_string($court); $query = "SELECT name FROM games_$norf WHERE day='$day' AND location='$court'"; $result = mysql_result($query); if( !$result ) { db_error(); } return mysql_numrows($result); } function opt_in($time,$user,$norf="noon") { $user_id = user_to_id($user); $day_id = time_to_day($time); $query = "DELETE FROM game_off_$norf WHERE date='$day_id' AND user='$user_id'"; $result = mysql_query($query); if( !$result ) { db_error(); } } function opt_out($time,$user,$norf="noon") { remove_player($time,$user,$norf); $user_id = user_to_id($user); $day_id = time_to_day($time); $query = "SELECT COUNT(user) FROM game_off_$norf WHERE user='$user_id' AND date='$day_id'"; $result = mysql_query($query); $num = mysql_result($result,0); if( !$num ) { $query = "INSERT INTO game_off_$norf (date,user) VALUES ('$day_id','$user_id')"; $result = mysql_query($query); if( !$result ) { db_error(); } } } function remove_player($day,$user,$norf="noon") { $user_id = user_to_id($user); $day_id = time_to_day($day); $query = "DELETE FROM games_$norf WHERE name='$user_id' AND day='$day_id'"; $result = mysql_query($query); if( !$result ) { db_error(); } } function play($user,$court,$day,$norf="noon") { opt_in($day,$user,$norf); $user_id = user_to_id($user); $loc_id = location_to_id($court); $day_id = time_to_day($day); // remove player from other courts remove_player($day,$user,$norf); // add player to new court $query = "INSERT INTO games_$norf (day,location,name) VALUES " . "('$day_id','$loc_id','$user_id')"; $result = mysql_query($query); if( !$result ) { db_error(); } } function time_to_day($day) { return date("Y-m-d",$day); } function get_players($court,$day,$norf="noon") { gd_db_open(); $day = time_to_day($day); if( "out" == $court ) { $query="SELECT user FROM game_off_$norf WHERE date='$day'"; $field = "user"; } else { $loc_id = location_to_id($court); $query="SELECT name FROM games_$norf WHERE day='$day' AND location='$loc_id'"; $field = "name"; } $result = mysql_query($query); if( !$result ) { db_error($query); } $return; $stop = mysql_numrows($result); $i = 0; while( $i < $stop ) { $return[] = id_to_user(mysql_result($result,$i,$field)); ++$i; } return $return; } function string_to_id($table,$name) { gd_db_open(); $table = mysql_real_escape_string($table); $name = mysql_real_escape_string($name); $query = "SELECT id FROM $table WHERE name='$name'"; $result = mysql_query($query); if( !$result ) { die(mysql_error()); } if( !mysql_numrows($result) ) { error_text("No id for '$name' in '$table'"); die(); } return mysql_result($result,0); } function id_to_string($table,$id) { gd_db_open(); $query = "SELECT name FROM $table WHERE id='$id'"; $result = mysql_query($query); if( !$result ) { die(mysql_error()); } return mysql_result($result,0,"name"); } function location_to_id($loc_name) { return string_to_id("locations",$loc_name); } function id_to_location($id) { return id_to_string("location",$id); } function user_to_id($user) { return string_to_id("users",$user); } function id_to_user($id) { return id_to_string("users",$id); } function db_error($msg) { die("Database error: " . mysql_error()."\n".$msg); } function email_password($email) { gd_db_open(); $query=sprintf("SELECT password FROM users WHERE email='%s'", mysql_escape_string($email)); $result = mysql_query($query); if( !$result ) { db_error(); } $password = mysql_result($result,0); $subject = "Game Day - Password"; $body = "Password: " . $password; $body .= "\nhttp://rtphoops.com\n"; mail($email,$subject,$body,'From: eyekode@yahoo.com'); } function delete_user($email) { $email = mysql_real_escape_string($email); $query = "SELECT id FROM users WHERE email='$email'"; $result = mysql_query($query); $id = mysql_result($result,0); $query = "DELETE FROM games_noon WHERE name='$id'"; mysql_query($query); $query = "DELETE FROM games_five WHERE name='$id'"; mysql_query($query); $query = "DELETE FROM game_off_noon WHERE user='$id'"; mysql_query($query); $query = "DELETE FROM game_off_five WHERE user='$id'"; mysql_query($query); $query = "DELETE FROM users WHERE id='$id'"; mysql_query($query); } if( 0 ) { if( $_GET['adders'] == "secret" ) { echo '
'; $all_emails = get_all_email_addrs(); $i = 0; foreach($all_emails as $email) { echo "$i\t$email'; if( $user_api->is_active() ) { echo 'User: '.$user_api->name().'
'. ''; } else { echo 'Login'. ''; } } function display_email($action,$method="get") { echo '