Author |
Message |
rebelt
Worker


Joined: May 07, 2006
Posts: 172
|
Posted:
Sun Jan 22, 2012 10:17 am |
|
These files
Code:<?PHP
// includes the mainfile functions and the header junk
if (!isset($mainfile)) { include("mainfile.php"); }
define('INDEX_FILE', true);
### Main Page
### Main Page
### Main Page
function mainpage() {
include ('header.php');
maintheader();
echo "<center><B>This online service will be used to add and update Weston Pool League team names, members and venues.<br /> By registering with Weston Pool League, you acknowledge that the league, those who run it and members, are not responsible for access to any venue. <br />If you are new to this process, get started by creating your team using the first option below.<br /><h3>Please make sure the player is ONLY registered to play for your team.</h3><br /><h3><blink><B>Important!</b></blink><br/>DO NOT enter any team detail, until the notice appears on the fromt page telling you the database is ready.</h3></center>";
echo "<BR><table width=100%>";
echo "<a href=\"?op=CreateTeam&step=Venue\">1. Create New Team</a><BR><BR>
<a href=\"?op=ListVenues\">2. List All Venues</a><BR><BR>
<a href=\"?op=ShowMyTeam\">3. Show My Team</a><BR><BR>
<a href=\"?op=ListTeams\">4. List All Teams</a><BR><BR>";
echo "</table>";
maintfooter();
mysql_free_result($result);
include ('footer.php');
}
### List Teams
### List Teams
### List Teams
function listteams() {
include ('header.php');
maintheader();
$result = mysql_query("select team_id, team_name, division from team_names2 order by division, team_name");
$lastdivision="A";
while (list($teamid, $teamname, $division) = mysql_fetch_row($result))
{
if ($division!=$lastdivision)
{
if ($division=='0')
{
echo "<BR><B>Division Unallocated Teams</b> (divisions are usually allocated towards the beginning of the season)<BR><BR>";
}
else
{
echo "<BR><B>Division $division Teams</b><BR><BR>";
}
}
echo "<a href=\"?op=ShowTeam&teamid=$teamid\">$teamname</a><BR>";
$lastdivision=$division;
}
maintfooter();
mysql_free_result($result);
include ('footer.php');
}
### Show My Team
### Show My Team
### Show My Team
function showmyteam($user) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
## Check to see if user is author on a team
$teamresult = mysql_query("select COUNT(*) from team_authorisation where authorisation_user='$username'");
$teamcount=mysql_fetch_array($teamresult);
$existsonteam= $teamcount[0];
if ($existsonteam)
{
$result = mysql_query("select authorisation_teamid from team_authorisation where authorisation_user='$username'");
while (list($authorisation_teamid) = mysql_fetch_row($result))
{
$url = "http://mysite.co.uk/maintenance.php?op=ShowTeam&teamid=$authorisation_teamid";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
}
else
{
echo "Unfortunately we cannot find your user ID attached to any existing team. You either need to create a new team or ask the person who administers your team to add your user ID to the list of authorised users.";
exit;
}
mysql_free_result($result);
include ('footer.php');
}
### List Venues
### List Venues
### List Venues
function listvenues() {
include ('header.php');
maintheader();
$result = mysql_query("select venue_name, venue_id from team_venues order by venue_name");
while (list($venuename, $venueid) = mysql_fetch_row($result))
{
echo "<a href=\"?op=ShowVenue&venueid=$venueid\">$venuename</a><BR>";
}
maintfooter();
mysql_free_result($result);
include ('footer.php');
}
### Show Team
### Show Team
### Show Team
function showteam($teamid, $user) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
echo "<h3><B>Show Team Details</b></h3>";
$result = mysql_query("select team_venue_id, team_name, team_name_old, division, division_old, team_email, team_telephone, team_alternate_telephone from team_names2 where team_id='$teamid' order by team_id limit 1");
while (list($teamvenueid, $teamname, $teamnameold, $division, $divisionold, $teamemail, $teamtelephone, $teamalternatetelephone) = mysql_fetch_row($result))
{
echo "<B>Team Name:</b> $teamname<BR>";
echo "<B>Team Email Contact:</b> $teamemail<BR>";
echo "<B>Team Telephone Contact:</b> $teamtelephone<BR>";
echo "<B>Alternate Team Telephone Contact:</b> $teamalternatetelephone<BR>";
if ($teamnameold!='') echo "<B>Old Team Name:</b> $teamnameold<BR>";
echo "<B>Division This Season:</b>";
if ($division==0) {echo " not yet allocated<BR>";}
else {echo " $division<BR>";}
if ($divisionold!=0) echo "<B>Division Last Season:</b> $divisionold<BR>";
echo "<BR><b>Plays From:</b><BR><BR>";
$result = mysql_query("select venue_name, venue_oldname, venue_address, venue_town,
venue_postcode, venue_telephone from team_venues where venue_id='$teamvenueid'");
while (list($venuename, $venueoldname, $venueaddress, $venuetown,
$venuepostcode, $venuetelephone) = mysql_fetch_row($result))
{
echo "<table><tr><TD><B>Venue Name:</b> $venuename<BR>
<B>Old Venue Name:</b> $venueoldname<BR>
<B>Venue Address:</b> $venueaddress<BR>
<B>Venue Town:</b> $venuetown<BR>
<B>Venue Postcode:</b> $venuepostcode<BR>
<B>Venue Contact Telephone:</b> $venuetelephone<BR></td><td>
<a href=\"http://uk.multimap.com/map/browse.cgi?client=public&db=pc&cidr_client=none&lang=&pc=".$venuepostcode."\" target=\"_blank\"><img src=\"/images/minimap.jpg\" border=\"0\"><BR>map it</a></td></tr></table>";
}
echo "<BR><BR>";
$x=1;
$result = mysql_query("select players_playerid, players_playername, players_playerstartdate from team_players where players_teamid='$teamid' order by players_playerid");
while (list($playersplayerid, $playersplayername, $playersplayerstartdate) = mysql_fetch_row($result))
{
$box.="<TR><td>$playersplayername</td><td>".date("Y-m-d", strtotime($playersplayerstartdate))."</td><td>";
if ($x==1){$box.=" (Captain)";}
$box.="</td></tr>";
$x++;
}
if ($box){
echo "<table border=0><tr><td><B>Player Name</b></td><td><B>Valid For games From</b></td><td></td></tr>";
echo $box;
echo "</table>";
}
else
{
echo "No registered players";
}
echo "<BR><BR><B>Current authors:</b><BR>";
# Read existing authors in
$result = mysql_query("select authorisation_user from team_authorisation where authorisation_teamid='$teamid'");
while (list($authorisation_user) = mysql_fetch_row($result))
{
echo "$authorisation_user<BR>";
if (trim($authorisation_user)==trim($username)) {$author=1;}
}
if ($author){echo "<BR><B><h3><a href=\"http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddPlayers&teamid=$teamid&teamname=$teamname\">add players</a> | <a href=\"http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname\">add authors</a> | <a href=\"http://mysite.co.uk/maintenance.php\">main menu</a></B></h3>";}
else{echo "<BR><B><h3>To edit this team you must be logged in and listed as a team author. </b></h3>";}
}
maintfooter();
include ('footer.php');
}
### Show Venue
### Show Venue
### Show Venue
function showvenue($venueid) {
include ('header.php');
maintheader();
echo "<h3><B>Venue Details</b></h3>";
$result = mysql_query("select venue_name, venue_oldname, venue_address, venue_town,
venue_postcode, venue_telephone from team_venues where venue_id='$venueid'");
while (list($venuename, $venueoldname, $venueaddress, $venuetown,
$venuepostcode, $venuetelephone) = mysql_fetch_row($result))
{
echo "<table><tr><td><B>Venue Name:</b> $venuename<BR>
<B>Old Venue Name:</b> $venueoldname<BR>
<B>Venue Address:</b> $venueaddress<BR>
<B>Venue Town:</b> $venuetown<BR>
<B>Venue Postcode:</b> $venuepostcode<BR>
<B>Venue Contact Telephone:</b> $venuetelephone<BR></td><td>
<a href=\"http://uk.multimap.com/map/browse.cgi?client=public&db=pc&cidr_client=none&lang=&pc=".$venuepostcode."\" target=\"_blank\"><img src=\"/images/minimap.jpg\" border=\"0\"><BR>map it</a></td></tr></table>";
}
maintfooter();
include ('footer.php');
}
### Select Venue
### Select Venue
### Select Venue
function selectvenue($user) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
echo "<SCRIPT LANGUAGE=\"JavaScript\">\n
function Validate(thisForm)\n
{\n";
echo "thisForm.venuename.value=thisForm.venueid.options[thisForm.venueid.selectedIndex].text;\n";
echo "if (thisForm.venuename.value==\"Other...\" || thisForm.venuename.value==\"Select One\"){return (false)};\n";
echo "return (true);\n
}\n
\n
function Validate2(thisForm)\n
{\n";
echo "if (thisForm.venuename.value==\"\" || thisForm.venueaddress.value==\"\" || thisForm.venuetown.value==\"\" || thisForm.venuepostcode.value==\"\" || thisForm.venuetelephone.value==\"\"){alert(\"It is very important that you fill all these fields in so that other site users can find your venue when playing you at home.\"); return (false) };\n";
echo "return (true);\n
}\n
\n
function unhide(thisField, thisObject)\n
{\n
if (thisField.options[thisField.selectedIndex].text==\"Other...\"){thisObject.style.display=\"\";}\n
else\n
{thisObject.style.display=\"none\"}
}\n
function websearch(placename)\n
{\n
url=\"http://www.google.co.uk/search?hl=en&q=\"+placename+\"+weston+super+mare&meta=cr%3DcountryUK%7CcountryGB\";
url2=\"http://www.yell.com/ucs/UcsSearchAction.do?searchType=classic&ooa=on&keywords=&companyName=\"+placename+\"&location=Weston-Super-Mare\"
winRef = window.open(url, \"Websearch\");\n
winRef2 = window.open(url2, \"Websearch2\");\n
}\n
\n
</SCRIPT>";
echo "<center><img src=\"/images/step1.jpg\" align=absmiddle><img src=\"/images/step2grey.jpg\" align=absmiddle><img src=\"/images/step3grey.jpg\" align=absmiddle><img src=\"/images/step4grey.jpg\" align=absmiddle></center>";
echo "<h3><B>Create New Team: Select Venue</b></h3>";
echo "<FORM ONSUBMIT=\"return Validate(this)\" ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"SelectVenue\">
<BR>
My team plays from the following venue:<select name=\"venueid\" onChange=\"unhide(venueid, hiddensection)\";><option selected>Select One</option>";
$result = mysql_query("select venue_id, venue_name from team_venues order by venue_name");
while (list($venueid, $venuename) = mysql_fetch_row($result))
{
echo "<option value=\"$venueid\">$venuename</option>";
}
echo "<option value=\"other\" default>Other...</option>";
echo "</select>";
echo "<input name=\"venuename\" type=\"hidden\">
<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"VenueSelected\">
<INPUT TYPE=\"submit\" value=\"Next Step->\">";
echo "</form>";
echo "<h3><B>Please make sure your venue is not in the above dropdown list, BEFORE you enter any details below. Venues entered more than once delays fixtures.</b></h3>";
echo "<FORM ACTION=\"maintenance.php\" ONSUBMIT=\"return Validate2(this)\" METHOD=\"POST\" NAME=\"NewVenue\">";
echo "<P ID=\"hiddensection\" STYLE=\"display:none;\">";
echo "Venue not listed? Add it here:<BR><BR><table>
<TR><td><B>Venue Name:</b> </td><td><input type=text NAME=\"venuename\" size=30></td></tr>
<TR><td><B>Old Venue Name:</b> </td><td><input type=text NAME=\"venueoldname\" size=30> (optional)</td></tr>
<TR><td><B>Venue Address:</b> </td><td><input type=text NAME=\"venueaddress\" size=30> <a href=\"javascript:websearch(NewVenue.venuename.value)\" title=\"Clicking here will open search windows to Google and Yell\">Click here to search the web for the address</a></td></tr>
<TR><td><B>Venue Town:</b> </td><td><input type=text NAME=\"venuetown\" size=30></td></tr>
<TR><td><B>Venue Postcode:</b> </td><td><input type=text NAME=\"venuepostcode\" size=30></td></tr>
<TR><td><B>Venue Contact Telephone:</b> </td><td><input type=text NAME=\"venuetelephone\" size=30></td></tr></table>";
echo "<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"SubmittedVenue\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Add Venue\">";
echo "</p>";
echo "</form>";
maintfooter();
include ('footer.php');
}
### Submitted Venue
### Submitted Venue
### Submitted Venue
function submittedvenue($venuename, $venueoldname, $venueaddress, $venuetown, $venuepostcode, $venuetelephone, $user) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if ($username!=''){$email=$username;}
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
$venuename=ucwords(strtolower($venuename));
$venueoldname=ucwords(strtolower($venueoldname));
$venueaddress=ucwords(strtolower($venueaddress));
$venuetown=ucwords(strtolower($venuetown));
$venuepostcode=strtoupper(str_replace ( "-", "", $venuepostcode));
##
## Make sure all fields are filled in
##
if ($venuename=='' or $venueaddress=='' or $venuetown=='' or $venuepostcode=='' or $venuetelephone=='')
{
echo "Somehow you have got this far without filling in all the fields on the previous form. Please return to the previous page and fill in all the fields.";
exit;
}
$result=mysql_query("insert into team_venues values (NULL, '$venuename', '$venueoldname', '$venueaddress', '$venuetown', '$venuepostcode', '$venuetelephone')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
### Read back in
$result = mysql_query("select venue_id from team_venues where venue_name='$venuename' AND venue_oldname='$venueoldname' AND venue_address='$venueaddress' AND venue_town='$venuetown' AND venue_postcode='$venuepostcode' AND venue_telephone='$venuetelephone' limit 1");
$url = "http://mysite.co.uk/maintenance.php?op=CreateTeam&step=Venue";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
### Venue Selected
### Venue Selected
### Venue Selected
function venueselected($venueid, $venuename, $user) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
###
### 'Teams already allocated' code
###
$teams_already_created.="<B>Teams already created for this venue:</b><BR>";
$result = mysql_query("select team_id, team_name, division from team_names2 where team_venue_id='$venueid' order by division, team_name");
$jarraynumber=0;
$jarray.="var existingteams = new Array()\n";
while (list($teamid, $teamname, $division) = mysql_fetch_row($result))
{
$teams_already_created.="<a href=\"?op=ShowTeam&teamid=$teamid\">$teamname</a><BR>";
$jarray.="existingteams[$jarraynumber]=\"$teamname\"\n";
$jarraynumber++;
}
##
## end
##
###
### Error checking
###
echo "<SCRIPT LANGUAGE=\"JavaScript\">\n";
echo $jarray;
echo "\n function Validate(thisForm)
{\n";
echo "for (var i=0; i<existingteams.length; i++)
{
var left=thisForm.teamname.value;
var right=existingteams[i];
if (left.toUpperCase()==right.toUpperCase())
{
alert (\"Team name already exists for this venue\");
thisForm.teamname.focus();
return (false);
}
}\n";
echo "if (thisForm.teamname.value==\"\")
{
alert (\"Team name must be filled in\");
thisForm.teamname.focus();
return (false);
}\n";
echo "if (thisForm.teamemail.value==\"\")
{
alert (\"Team email must be filled in\");
thisForm.teamemail.focus();
return (false);
}\n";
echo "if (thisForm.teamtelephone.value==\"\")
{
alert (\"Team telephone must be filled in\");
thisForm.teamtelephone.focus();
return (false);
}
}
</SCRIPT>\n";
###
### end
###
echo "<center><img src=\"/images/step1grey.jpg\" align=absmiddle><img src=\"/images/step2.jpg\" align=absmiddle><img src=\"/images/step3grey.jpg\" align=absmiddle><img src=\"/images/step4grey.jpg\" align=absmiddle></center>";
echo "<h3><B>Create New Team: Team Details</b></h3>";
echo "<FORM ONSUBMIT=\"return Validate(this)\" ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"AddTeam\">
<BR>
<b>Venue:</b> <input type=text NAME=\"venuename\" size=30 value=\"".stripslashes($venuename)."\" disabled><BR>
<input type=hidden NAME=\"venueid\" value=\"$venueid\">
<B>Created By: </b> <input type=text NAME=\"username\" size=30 value=\"".$username."\" disabled><BR>
<BR>
<table>
<TR><td><b>Team Name This Season: </b></td><TD><input type=text NAME=\"teamname\" size=30></td></tr>
<TR><td><b>Team Contact Email: </b></td><TD> <input type=text NAME=\"teamemail\" size=30></td></tr>
<TR><td><b>Team Telephone Contact:</b> </td><TD><input type=text NAME=\"teamtelephone\" size=30></td></tr>
<TR><td><b>Alternative Team Telephone Contact:</b> </td><TD><input type=text NAME=\"teamalternatetelephone\" size=30></td></tr>
<TR><td></td><TD></td></tr>
<TR><td><b>Team Name Last Season:</b> </td><TD><input type=text NAME=\"teamnameold\" size=30> (leave blank if new team)</td></tR>
<TR><td><B>Division Last Season:</b> </td><TD><input type=text NAME=\"divisionold\" size=1> (leave blank if new team)</td></tr>
</table><BR>";
echo "
<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"SubmittedTeamName\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Next Step-->\">";
echo "</form>";
echo $teams_already_created;
maintfooter();
include ('footer.php');
}
### Submitted Team Name
### Submitted Team Name
### Submitted Team Name
function submittedteamname($venueid, $teamname, $teamemail, $teamtelephone, $teamalternatetelephone, $teamnameold, $divisionold, $user) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if ($username!=''){$email=$username;}
$teamname=ucwords(strtolower($teamname));
$teamnameold=ucwords(strtolower($teamnameold));
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
##
## Make sure all fields are filled in
##
if ($teamname=='')
{
echo "Somehow you have got this far without filling in all the fields on the previous form. Please return to the previous page and fill in all the fields.";
exit;
}
### Check if team name at venue already exists, then stop from writing new record
$teamresult = mysql_query("select COUNT(*) from team_names2 where team_name='$teamname' AND team_venue_id='$venueid'");
$teamcount=mysql_fetch_array($teamresult);
$nameexists= $teamcount[0];
if ($nameexists){echo "Sorry, the team name you specified has already been allocated. Please click the back button on your browser and choose another name."; exit;}
### Write team record
$result=mysql_query("insert into team_names2 values (NULL, $venueid, '$teamname', '$teamnameold', '0', '$divisionold', '$teamemail', '$teamtelephone', '$teamalternatetelephone')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
### Read back in
$result = mysql_query("select team_id from team_names2 where team_venue_id='$venueid' AND team_name='$teamname' AND team_name_old='$teamnameold' AND division_old='$divisionold' limit 1");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
while (list($teamid2) = mysql_fetch_row($result))
{
### Add user to authority file
$teamid=$teamid2;
$result=mysql_query("insert into team_authorisation values ('$teamid', '$username')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
}
$url = "http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddPlayers&teamid=$teamid&teamname=$teamname";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
### Add Players
### Add Players
### Add Players
function addplayers($teamid, $teamname, $user) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
echo "<center><img src=\"/images/step1grey.jpg\" align=absmiddle><img src=\"/images/step2grey.jpg\" align=absmiddle><img src=\"/images/step3.jpg\" align=absmiddle><img src=\"/images/step4grey.jpg\" align=absmiddle></center>";
echo "<h3><b>Create New Team: Add Players</b></h3>";
echo "<B>Player names entered here CANNOT be changed. If you do not know the exact name of some of your team members do not enter them. You can come back to this page at any time and add more members to your team without penalty.</b><BR><BR>";
echo "<FORM ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"AddPlayers\">;
<input type=hidden NAME=\"teamid\" value=\"$teamid\">
Team Name: <input type=text NAME=\"teamname2\" value=\"$teamname\" disabled>
<input type=hidden NAME=\"teamname\" value=\"$teamname\">
<input type=hidden NAME=\"user\" value=\"$username\"><BR><BR>";
echo "<b>Players added now will only be elligible to play in games from tomorrow.<BR><BR></b>";
echo "<h4><b>Please enter First and Last names. Not just initial (e.g. John Smith not J.Smith)</b> </h4>
<BR>";
# Read existing players in
$x=1;
$result = mysql_query("select players_playerid, players_playername, players_playerstartdate from team_players where players_teamid='$teamid' order by players_playerid");
while (list($playersplayerid, $playersplayername, $playersplayerstartdate) = mysql_fetch_row($result))
{
echo "<B>Player $x: </b> <input type=text NAME=\"fixedplayer$x\" size=30 value=\"$playersplayername\" disabled>";
if ($x==1){echo " (Captain)";}
echo "<BR><BR>";
$x++;
}
while ($x<21)
{
echo "<B>Player $x: </b> <input type=text NAME=\"player$x\" size=30 value=\"\">";
if ($x==1){echo " (Captain)";}
echo "<BR><BR>";
$x++;
}
echo "
<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"SubmittedPlayers\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Next Step-->\">";
echo "</form>";
maintfooter();
include ('footer.php');
}
### Submitted Players
### Submitted Players
### Submitted Players
function submittedplayers($teamid, $teamname, $player1, $player2, $player3, $player4, $player5, $player6, $player7, $player8, $player9, $player10, $player11, $player12, $player13, $player14, $player15, $player16, $player17, $player18, $player19, $player20, $user) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if ($username!=''){$email=$username;}
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
##
## Make sure all fields are filled in
##
#if ($teamname=='')
#{
# echo "Somehow you have got this far without filling in all the fields on the previous form. Please #return to the previous page and fill in all the fields.";
#exit;
#}
# Count existing players
$playerresult = mysql_query("select COUNT(*) from team_players where players_teamid='$teamid'");
$playercount=mysql_fetch_array($playerresult);
$y= $playercount[0];
$x=$y+1;
$tomorrow = date("Y-m-d", strtotime("tomorrow"));
while($x<21)
{
#$thisplayer=str_replace ( ".", " ", ${"player".$x});
#$thisplayer=ucwords(strtolower($thisplayer));
#$thisplayer=ucwords(strtolower(${"player".$x}));
$thisplayer=ucwords(strtolower(str_replace("."," ",${"player".$x})));
### Write player records
if ($thisplayer!=''){
$y++;
$result=mysql_query("insert into team_players values ('$y', '$teamid', '$thisplayer', '$tomorrow')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
else
{
}
}
$x++;
}
### Read back in
#$result = mysql_query("select team_id from team_names2 where team_venue_id='$venueid' AND team_name='$teamname' AND teamname_old='$teamnameold' AND division_old='$divisionold' limit 1");
#while (list($teamid) = mysql_fetch_row($result))
# {
#### Add user to authority file
#$result=mysql_query("insert into team_authorisation values ('$teamid', '$username')");
# }
$url = "http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
### Add Authors
### Add Authors
### Add Authors
function addauthors($teamid, $teamname, $user) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
echo "<center><img src=\"/images/step1grey.jpg\" align=absmiddle><img src=\"/images/step2grey.jpg\" align=absmiddle><img src=\"/images/step3grey.jpg\" align=absmiddle><img src=\"/images/step4.jpg\" align=absmiddle></center>";
echo "<h3><B>Create New Team: Add Team Authors</b></h3>";
echo "<FORM ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"AddAuthors\">
Using this form you can add or delete site members as editors of your team. If you do not add any more only you will be able to amend the details about your team. If you do not wish to add them now you can add them at any time in the future.<BR><BR>
<input type=hidden NAME=\"teamid\" value=\"$teamid\">
Team Name: <input type=text NAME=\"teamname2\" value=\"$teamname\" disabled>
<input type=hidden NAME=\"teamname\" value=\"$teamname\">
<input type=hidden NAME=\"user\" value=\"$username\"><BR><BR><B>Current authors:</b><BR>";
# Read existing authors in
$x=0;
$result = mysql_query("select authorisation_user from team_authorisation where authorisation_teamid='$teamid'");
while (list($authorisation_user) = mysql_fetch_row($result))
{
echo "<input type=text NAME=\"author$x\" size=30 value=\"$authorisation_user\" disabled>";
if ($authorisation_user!=$username){ echo "<a href=\"?op=CreateTeam&step=RemoveAuthor&teamid=$teamid&authorid=$authorisation_user&teamname=$teamname\">remove</a>";}
echo "<BR><BR>";
$author{$x}=$authorisation_user;
$x++;
}
echo "<select name=\"addauthor\" size=\"10\">";
$result = mysql_query("select username from rebelt_users");
$authorexists=0;
while (list($allusers) = mysql_fetch_row($result))
{
for ($i = 0; $i <= $x; $i++)
{
if ($allusers==$author{$i}){$authorexists=1;}
}
if (!($authorexists)){echo "<option>$allusers</option>";}
$authorexists=0;
}
echo "</select>";
echo "
<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"SubmittedAuthor\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Add Author\"></form><BR><FORM ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"AddAuthors\"><input type=hidden name=\"op\" value=\"Finished\"><input type=hidden name=\"teamid\" value=\"$teamid\"><INPUT TYPE=\"submit\" value=\"Finished-->\">";
echo "</form>";
maintfooter();
include ('footer.php');
}
### Submitted Author
### Submitted Author
### Submitted Author
function submittedauthor($teamid, $teamname, $user, $addauthor) {
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if ($username!=''){$email=$username;}
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
if ($addauthor==$username){echo "Your name is already in the authors list."; exit;}
##
## Make sure all fields are filled in
##
if ($addauthor=='')
{
echo "You must select a name from the list in order to add an additional team author. If you do not have any more authors to add, just click the 'Finished' button.";
exit;
}
# Count existing players
$playerresult = mysql_query("select COUNT(*) from team_players where players_teamid='$teamid'");
$playercount=mysql_fetch_array($playerresult);
$y= $playercount[0];
$result=mysql_query("insert into team_authorisation values ('$teamid', '$addauthor')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
$url = "http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
### Finished
### Finished
### Finished
function finished($teamid) {
include ('header.php');
maintheader();
$url = "http://mysite.co.uk/league_cup_exclude.php";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
###
### Page Header
###
function maintheader(){
echo "<center><H2><B>Pool Team Maintenance</b></h2></center>";
}
###
### Page Footer
###
function maintfooter(){
echo "<BR><BR><center><table width=90% border=1><tr><td align=center width=50%><a href=\"http://mysite.co.uk/maintenance.php\">Home</a></td><td align=center><a href=\"http://mysite.co.uk/maintenance.php?op=ShowMyTeam\">Show My Team</a></td></tr></table></center><BR><BR><BR><BR>";
}
### Get Username
### Get Username
### Get Username
function getusername($user)
{
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$user2 = explode(":", $user2);
return $user2[1];
}
### URL Forward
### URL Forward
### URL Forward
function urlforward($url)
{
$delay = "0";
return "<meta http-equiv=\"refresh\" content=\"".$delay.";url=".$url."\">";
}
### Check authorisation
### Check authorisation
### Check authorisation
function isauthorised($teamid, $username)
{
$result = mysql_query("select authorisation_user from team_authorisation where authorisation_teamid='$teamid'");
while (list($authorisation_user) = mysql_fetch_row($result))
{
if ($authorisation_user==$username){ return true;}
}
return false;
}
###
### Main Entry
###
switch($op) {
case "CreateTeam":
switch($step) {
case "Venue":
selectvenue($user);
break;
case "SubmittedVenue":
submittedvenue($venuename, $venueoldname, $venueaddress, $venuetown, $venuepostcode, $venuetelephone, $user);
break;
case "VenueSelected":
venueselected($venueid, $venuename, $user);
break;
case "SubmittedTeamName":
submittedteamname($venueid, $teamname, $teamemail, $teamtelephone, $teamalternatetelephone, $teamnameold, $divisionold, $user);
break;
case "AddPlayers":
addplayers($teamid, $teamname, $user);
break;
case "SubmittedPlayers":
submittedplayers($teamid, $teamname, $player1, $player2, $player3, $player4, $player5, $player6, $player7, $player8, $player9, $player10, $player11, $player12, $player13, $player14, $player15, $player16, $player17, $player18, $player19, $player20, $user);
break;
case "AddAuthors":
addauthors($teamid, $teamname, $user);
break;
case "SubmittedAuthor":
submittedauthor($teamid, $teamname, $user, $addauthor);
break;
case "RemoveAuthor":
removeauthor($teamid, $teamname, $user, $authorid);
break;
}
case "Admin":
switch($step)
{
case "List":
listrecords($user);
break;
case "Allocate":
allocate($user);
break;
case "SubmittedTeamAllocations":
submittedteamallocations($user, $allchanges);
break;
case "AdminDelete":
admin_delete_team($id, $user);
break;
case "Summarise":
summarise($user);
break;
case "RemoveVenue":
removevenue($venueid, $user);
break;
case "RemovePlayer":
removeplayer($playerid, $teamid, $user);
break;
default:
adminoptions($user);
break;
}
case "ListTeams":
listteams();
break;
case "ShowTeam":
showteam($teamid, $user);
break;
case "ShowMyTeam":
showmyteam($user);
break;
case "ListVenues":
listvenues();
break;
case "ShowVenue":
showvenue($venueid);
break;
case "Finished":
finished($teamid);
break;
case "FAQ":
FAQ();
break;
default:
mainpage();
break;
}
?>
|
|
_________________ I wish I knew what I was doing LOL |
|
|
 |
rebelt

|
Posted:
Sun Jan 22, 2012 10:22 am |
|
Too big for one post.
And this one
Code:
<?PHP
if (!isset($mainfile)) { include("mainfile.php"); }
###
### Main Page
###
function mainpage() {
include ('header.php');
$result = mysql_query("select match_id, home_team, away_team, home_score, away_score, division, match_date from team_scores where status>0 order by match_date DESC");
echo "<center><H2><B>Live Result Listings</b></h2></center>";
echo "<center><B>All results submitted through this system should be genuine match results only.</b><BR><BR><B>New:</b> You can now see a running history of each team's matches by clicking on their team name. For and against graphs are also included.</center>";
echo "<BR><table width=100%>";
$lastmatchdate="";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $match_date) = mysql_fetch_row($result))
{
if ($match_date!=$lastmatchdate)
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
echo "<tr><td colspan=4 align=center><font size=4><b><a href=\"leagueresult.php?op=showdate&date=$matchdate\">Click here for matches played on $displaymatchdate</a></b></font size=4></td></tr>";
}
$lastmatchdate=$match_date;
}
echo "</table>";
livefooter();
mysql_free_result($result);
include ('footer.php');
}
###
### Show Date Listing
###
function showdate($matchdate) {
include ('header.php');
$result = mysql_query("select match_id, home_team, away_team, home_score, away_score, division, match_date, status, comments from team_scores where status>0 AND match_date='$matchdate' order by match_date, division");
echo "<BR><center><table width=75% border=1 valign=top>";
$lastdivision="9";
$lastmatchdate="";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $match_date, $status, $comments) = mysql_fetch_row($result))
{
if ($match_date!=$lastmatchdate)
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
echo "<tr><td colspan=4 align=center bgcolor=\"#B1CFED\"><h2><b>Games Played On $displaymatchdate</b></h2></td></tr>";
}
if ($division!=$lastdivision)
{
echo "<tr><td colspan=4 align=center bgcolor=\"#EEF4FC\"><font size=4><b>Division $division</b></font size=4></td></tr>";
}
# Look up comments
// $commentresult = mysql_query("select COUNT(*) from match_commentary where match_id='$match_id'");
// $commentcount=mysql_fetch_array($commentresult);
// $nocomments= $commentcount[0];
if ($status==1)
{
echo "<tr><td bgcolor=\"#ffffff\" align=right width=43%><font size=4><a href=\"leagueresult.php?op=teammatches&team=$home_team\">$home_team</a></font size=4></td><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$home_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$away_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=left width=43%><font size=4><a href=\"leagueresult.php?op=teammatches&team=$away_team\">$away_team</a></font size=4></td></tr>";
}
else
{
echo "<tr><td colspan=4><center><table border=0><td width=90% bgcolor=\"#ffffff\" align=middle width=90%><font size=4>$comments</font size=4></td><td><img src=\"/images/sms.gif\" title=\"This result has been submitted by SMS\"></td></tr></table></center></td><td><center><a href=\"#\" onclick=\"javascript:window.open('commentary.php?matchid=$match_id','COMMENTARY','width=380, height=400, scrollbars=yes, resizable=no, toolbar=no, location=no, status=no, menubar=no')\">Read</a>(<B>".$nocomments."</b>)</center></td></tr>";
}
$thiscount=$thiscount+1;
$lastdivision=$division;
$lastmatchdate=$match_date;
}
livefooter();
mysql_free_result($result);
include ('footer.php');
}
###
### Show All Team Match Scores By date
###
function teammatches($team) {
include ('header.php');
$result = mysql_query("select match_id, home_team, away_team, home_score, away_score, division, match_date, status, comments from team_scores where status>0 AND (home_team='$team' or away_team='$team') order by match_date");
echo "<BR><center><table width=90% border=1 valign=top>";
echo "<tr><td colspan=5 align=center bgcolor=\"#B1CFED\"><h3>Games Played By $team This Season</h3></td></tr>";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $match_date, $status, $comments) = mysql_fetch_row($result))
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
echo "<tr><td bgcolor=\"#ffffff\" align=right width=20%><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=33%><font size=4><a href=\"leagueresult.php?op=teammatches&team=$home_team\">$home_team</a></font size=4></td><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$home_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$away_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=left width=33%><font size=4><a href=\"leagueresult.php?op=teammatches&team=$away_team\">$away_team</a></font size=4></td></tr>";
}
echo "</table></center>";
### Graph Progress
$result = mysql_query("select match_id, home_team, away_team, home_score, away_score, division, match_date, status, comments from team_scores where status>0 AND (home_team='$team' or away_team='$team') order by match_date");
echo "<BR><center><table width=90% border=1 valign=top>";
echo "<tr><td colspan=3 align=center bgcolor=\"#B1CFED\"><h3>Progress This Season</h3></td></tr>";
echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>Match Date</font size=4></td><td bgcolor=\"#ffffff\" align=right width=40%><font size=4>Games Against</font size=4></td><TD bgcolor=\"#ffffff\" align=left width=40%><font size=4>Games For</font size=4></td></tr>";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $match_date, $status, $comments) = mysql_fetch_row($result))
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
$homewidth=$home_score*18;
$awaywidth=$away_score*18;
if ($team==$away_team)
{
echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=40%>$home_score<img src=\"/images/reddot.jpg\" height=20 width=$homewidth></td><TD bgcolor=\"#ffffff\" align=left width=40%><img src=\"/images/greendot.jpg\" height=20 width=$awaywidth>$away_score</td></tr>";
}
else
{
echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=40%>$away_score<img src=\"/images/reddot.jpg\" height=20 width=$awaywidth></td><TD bgcolor=\"#ffffff\" align=left width=40%><img src=\"/images/greendot.jpg\" height=20 width=$homewidth>$home_score</td></tr>";
}
}
echo "</table></center>";
livefooter();
mysql_free_result($result);
include ('footer.php');
}
###
### Result Form
###
function resultform($user) {
include ('header.php');
### registered user or email address
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$user2 = explode(":", $user2);
$username = "$user2[1]";
## load in team names
$result = mysql_query("select team_name, division from team_names2 order by division, team_name");
$result2 = mysql_query("select team_name, division from team_names2 order by division, team_name");
if (date("Y-m-d", strtotime("this Tuesday"))==date("Y-m-d", strtotime("today")))
{
$lasttuesday = date("Y-m-d", strtotime("today"));
$displaylasttuesday = date("d-m-Y", strtotime("today"));
}
else
{
$lasttuesday = date("Y-m-d", strtotime("last Tuesday"));
$displaylasttuesday = date("d-m-Y", strtotime("last Tuesday"));
}
echo "<SCRIPT LANGUAGE=\"JavaScript\">\n
var menu=new Array()\n";
$lastdivision=9;
while (list($team_name, $division) = mysql_fetch_row($result2))
{
if ($division!=$lastdivision)
{
echo "menu[".$division."]=new Array()\n";
$count=0;
}
echo "menu[".$division."][".$count."]=new Option(\"".$team_name."\")\n";
$count=$count+1;
$lastdivision=$division;
}
echo "function changeTeam(number){
for (i=document.Result.home_team.options.length-1;i>0;i--){
document.Result.home_team.options[i]=null
}
for (i=0;i<menu[number].length;i++){
document.Result.home_team.options[i]=new Option(menu[number][i].text,menu[number][i].value)
}
document.Result.home_team.selectedIndex=0
for (i=document.Result.away_team.options.length-1;i>0;i--){
document.Result.away_team.options[i]=null
}
for (i=0;i<menu[number].length;i++){
document.Result.away_team.options[i]=new Option(menu[number][i].text,menu[number][i].value)
}
document.Result.away_team.selectedIndex=0
document.Result.jdivision.value=number;
}\n";
echo "function selectmenu(startteam){
if (startteam.division.options[startteam.division.selectedIndex].value == \"null\"){}
else
{
window.top.location.href = startteam.division.options[startteam.division.selectedIndex].value;
}
}
function Validate(thisForm)
{
if (thisForm.division.options[thisForm.division.selectedIndex].value == \"null\")
{
alert(\"You must select a division.\");
thisForm.division.focus();
return (false);
}
if (thisForm.home_team.value==\"null\")
{
alert(\"You must enter a home team.\");
thisForm.home_team.focus();
return (false);
}
if (thisForm.away_team.value==\"null\")
{
alert(\"You must enter an away team.\");
thisForm.away_team.focus();
return (false);
}
if (thisForm.away_team.options[thisForm.away_team.selectedIndex].text==thisForm.home_team.options[thisForm.home_team.selectedIndex].text)
{
alert(\"Home team cannot be the same as away team.\");
thisForm.home_team.focus();
return (false);
}
if (((thisForm.home_score.options[thisForm.home_score.selectedIndex].text*1)+(thisForm.home_score.options[thisForm.away_score.selectedIndex].text*1)<13) && (thisForm.comments.value==\"\"))
{
alert(\"This score does not add up to 13. If this is the case you must give a reason in the comments box.\");
thisForm.comments.focus();
return (false);
}
if (((thisForm.home_score.options[thisForm.home_score.selectedIndex].text*1)+(thisForm.home_score.options[thisForm.away_score.selectedIndex].text*1)>13) && (thisForm.comments.value==\"\"))
{
alert(\"No more than 13 games should played as part of a match. Please correct the scores.\");
return (false);
}
";
if ($username=='')
{
echo "
if (thisForm.tickme.checked == false)
{
alert (\"You must tick to say you have read and understand the disclaimer.\");
return false;
}
if ((thisForm.email.value.indexOf(\".\") > 2) && (thisForm.email.value.indexOf(\"@\") > 0))
{
}
else
{
alert(\"Without a valid email address you will be unable to validate this result.\");
thisForm.email.focus();
return (false);
}
if (thisForm.email.value.indexOf(\"hotmail\") > 1)
{
alert(\"Hotmail seems to mark the verification emails as junk mail. Please check in your junk mail folder and see if the verification email gets put there.\");
}
if (thisForm.email.value.indexOf(\"lycos\") > 1)
{
alert(\"Lycos rejects emails from this form so we are unable to accept Lycos addresses until they fix their system. Please provide an alternative email address to validate your result. Sorry.\");
return (false);
}
if (thisForm.email.value.indexOf(\"aol\") > 1)
{
alert(\"AOL's email client does not allow links to be clickable so you will need to cut and paste the verification link from the email in to your browser manually. Sorry, AOL's fault, not ours.\");
}
";
}
echo "thisForm.hometeam.value=thisForm.home_team.options[thisForm.home_team.selectedIndex].text
thisForm.awayteam.value=thisForm.away_team.options[thisForm.away_team.selectedIndex].text
thisForm.division.options[thisForm.division.selectedIndex].value='';
return (true);
}
</SCRIPT>";
echo "<STYLE>
<!--
blink {color: red}
-->
</STYLE>
<SCRIPT>
<!--
function doBlink() {
var blink = document.all.tags(\"BLINK\")
for (var i=0; i<blink.length; i++)
blink[i].style.visibility = blink[i].style.visibility == \"\" ? \"hidden\" : \"\"
}
function startBlink() {
if (document.all)
setInterval(\"doBlink()\",500)
}
window.onload = startBlink;
// -->
</SCRIPT>";
echo "<font size=4>Submit League Match Result. If 13-0, please indicate if a no show in the comments box.</font size=4>";
if ($username=='')
{
echo "<BR><blink><B>Important!</b></blink> This result will be emailed to you for confirmation before being accepted. If you do not authorise the result by clicking on the link in the email your result <B>will not</b> be accepted.";
}
# echo "<FORM ACTION=\"leagueresult.php\" METHOD=\"POST\" NAME=\"Result\">";
echo "<FORM ONSUBMIT=\"return Validate(this)\" ACTION=\"leagueresult.php\" METHOD=\"POST\" NAME=\"Result\">
<BR>
<B>Division:</b></font><select name=\"division\" size=\"1\" onChange=\"selectmenu(this.form)\">
<OPTION selected VALUE=\"null\">Div
<OPTION VALUE=\"Javascript:changeTeam(1)\">1
<OPTION VALUE=\"Javascript:changeTeam(2)\">2
<OPTION VALUE=\"Javascript:changeTeam(3)\">3
<OPTION VALUE=\"Javascript:changeTeam(4)\">4
<OPTION VALUE=\"Javascript:changeTeam(5)\">5
<OPTION VALUE=\"Javascript:changeTeam(6)\">6
<OPTION VALUE=\"Javascript:changeTeam(7)\">7
<OPTION VALUE=\"Javascript:changeTeam(8)\">8
</select><BR>
<b>Home Team:</b><select name=\"home_team\">";
echo "<OPTION VALUE=\"null\">Select A Team</select>
<B>Home Score:</b><select name=\"home_score\" size=\"1\">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
</select><BR>
<b>Away Team:</b><select name=\"away_team\">";
echo "<OPTION VALUE=\"null\">Select A Team</select>
<B>Away Score:</b><select name=\"away_score\" size=\"1\">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
</select><BR>
<B>Date:</b> <input type=text NAME=\"matchdate\" value=\"$displaylasttuesday\" disabled><BR>
<B>Your Name:</b> <input type=text NAME=\"submitter\" size=30><BR>";
if ($username=='')
{
echo "<B>Your Email Address:</b> <input type=text NAME=\"email\" size=30><BR>*As a non-registered user your results will need to be validated before acceptance<BR>";
}
else
{
echo "<B>User ID: </b> <input type=text NAME=\"email\" size=30 value=\"".$username."\" disabled> *As a registered user your results are prevalidated<BR>";
}
echo "
<textarea name=\"comments\" cols=60 rows=5></textarea>
<input type=hidden name=\"op\" value=\"submitted\">
<input type=hidden name=\"awayteam\">
<input type=hidden NAME=\"match_date\" value=\"$lasttuesday\">
<input type=hidden NAME=\"jdivision\" value=\"\">
<input type=hidden name=\"hometeam\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Submit\">";
if ($username=='')
{
echo "
<BR clear=all><input type=checkbox name=\"tickme\">By ticking this box I understand that I will have to validate this result through an email sent to me at the address specified above. If I do not get the email, or do not bother to validate it, I understand that my result will not be processed or accepted by the league. I will not bitch and moan if this happens because I was made aware of the consequences beforehand. If I do not get an email I will read <a href=\"http://westonpoolleague.org.uk/leagueresult.php?op=FAQ\">the help page</a> to find out what to do next.";
}
echo "</form>";
livefooter();
include ('footer.php');
}
### Add Result To Database
### Add Result To Database (would now be addtodb.php)
### Add Result To Database
function submittedresult($home_team, $away_team, $home_score, $away_score, $division, $match_date, $submitter, $email, $comments, $user) {
include ('header.php');
### registered user or email address
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$user2 = explode(":", $user2);
$username = "$user2[1]";
if ($username!=''){$email=$username;}
echo "<STYLE>
<!--
blink {color: red}
-->
</STYLE>
<SCRIPT>
<!--
function doBlink() {
var blink = document.all.tags(\"BLINK\")
for (var i=0; i<blink.length; i++)
blink[i].style.visibility = blink[i].style.visibility == \"\" ? \"hidden\" : \"\"
}
function startBlink() {
if (document.all)
setInterval(\"doBlink()\",500)
}
window.onload = startBlink;
// -->
</SCRIPT>";
#$division=substr($division,22,1);
## Get date of next Tuesday
if (date("Y-m-d", strtotime("this Tuesday"))==date("Y-m-d", strtotime("today")))
{
$lasttuesday = date("Y-m-d", strtotime("today"));
}
else
{
$lasttuesday = date("Y-m-d", strtotime("last Tuesday"));
}
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
##
## Make sure all fields are filled in
##
if ($home_team=='' or $away_team=='' or $home_score=='' or $away_score=='' or $division=='' or $match_date=='' or $email=='')
{
echo "Somehow you have got this far without filling in all the fields on the previous form. Please return to the previous page and fill in all the fields.";
exit;
}
# check to see if this result has already been verified
$result = mysql_query("select COUNT(*) from team_scores where home_team='$home_team' AND away_team='$away_team' AND match_date='$match_date' AND division='$division' AND home_score='$home_score' AND away_score='$away_score' AND status='1'");
$totalcount2=mysql_fetch_array($result);
$alreadyverified= $totalcount2[0];
### If not validated
if ($alreadyverified==0){
# check to see if this result has been submitted twice
$result = mysql_query("select COUNT(*) from team_scores where home_team='$home_team' AND away_team='$away_team' AND match_date='$match_date' AND division='$division' AND home_score='$home_score' AND away_score='$away_score' AND submitter='$submitter' AND email='$email'");
$totalcount3=mysql_fetch_array($result);
$alreadylogged= $totalcount3[0];
if ($alreadylogged==0){
$result=mysql_query("insert into team_scores values (NULL, '$home_team', '$away_team', $home_score, $away_score, '$division', '$matchdate', '$submitter', 0, '$email', '$comments')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
}
### Read back in
$result = mysql_query("select match_id from team_scores where home_team='$home_team' AND away_team='$away_team' AND match_date='$matchdate' AND division='$division' AND home_score='$home_score' AND away_score='$away_score' AND submitter='$submitter' AND email='$email' limit 1");
while (list($match_id) = mysql_fetch_row($result))
{
$this_match=$match_id;
$email2 = str_replace('.', ',', $email);
}
### If not registered user, do validation
if ($email!=$username)
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
if (strstr($email,"aol"))
{
### AOL Mail
#
mail("$email", "Weston Pool League Result Verification", "The following information was submitted to http://westonpoolleague.org.uk. If you have not submitted this information please ignore this email.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $submitter
Email: $email
Comments: $comments
To accept this result please <a href=\"http://westonpoolleague.org.uk/leagueresult.php?op=makelive&id=$this_match&validate=$email2\">click here</a>
To delete this result please <a href=\"http://westonpoolleague.org.uk/leagueresult.php?op=delete&id=$this_match&validate=$email2\">click here</a>
DO NOT DELETE THIS EMAIL. This is confirmation of receipt of your result and may be needed in cases of dispute.", "From: rebelt@westonpoolleague.org.uk");
####
}
else
{
###Normal email
mail("$email", "Weston Pool League Result Verification", "The following information was submitted to http://westonpoolleague.org.uk. If you have not submitted this information please ignore this email.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $submitter
Email: $email
Comments: $comments
To validate this result click this link:
http://westonpoolleague.org.uk/leagueresult.php?op=makelive&id=$this_match&validate=$email2
IF YOU DO NOT VALIDATE, YOUR RESULT WILL NOT BE SENT TO THE LEAGUE AND THE GAME WILL BE FORFEIT
To delete this result click this link:
http://westonpoolleague.org.uk/leagueresult.php?op=delete&id=$this_match&validate=$email2
DO NOT DELETE THIS EMAIL. This is confirmation of receipt of your result and may be needed in cases of dispute.
", "From: westonpoolleague.org.uk");
}
echo "<h2>Result Submission</h2>
Division: $division<BR>
Home team: $home_team $home_score<BR>
Away team: $away_team $away_score<BR>
Match date: $displaymatchdate<BR>
Submitted By: $submitter<BR>
Email: $email<BR>
Comments: $comments
<BR><BR>";
echo "<font size=4>Your result has not been accepted. Yet. </font size=4> In order to complete the result submission process, you must now check the email address you specified and click on the link inside. This is a very simple process and will take you a matter of seconds. Hopefully you will see how this makes the system more secure and stops people submitting fake results for your match or wasting the league's time with malicious submissions.<Br><BR> Once you have clicked the link your result will appear in the Live Results table straight away. You can see it by <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">clicking here</a>.<BR><BR><Blink>Remember, if you do not verify this result it will not be accepted!</blink>";
}
else
{
### Registered user. Send email and validate.
### Look up email address
$result = mysql_query("select user_email from nuke_users where username='$email'");
while (list($useremail) = mysql_fetch_row($result))
{
mail("$useremail", "Weston Pool League Result", "The following match result has been received and pre-validated.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $email
Email: $useremail
Comments: $comments
Thank you for your submission.
DO NOT DELETE THIS EMAIL. This is confirmation of receipt of your result and may be needed in cases of dispute.
", "From: rebelt@westonpoolleague.org.uk");
}
echo "<h2>Result Submission</h2>
Division: $division<BR>
Home team: $home_team $home_score<BR>
Away team: $away_team $away_score<BR>
Match date: $displaymatchdate<BR>
Submitted By: $email<BR>
Email: $useremail<BR>
Comments: $comments
<BR><BR>";
echo "<font size=4>As a pregistered site user your result has now been pre-validated and accepted. There is no need to do anything further.</font size=4> You can see it by <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">clicking here</a>.<BR><BR>";
### Update result to live
# delete where details are the same and != match_id
mysql_query("delete from team_scores where (home_team='$home_team' AND away_team='$away_team' AND home_score='$home_score' AND away_score='$away_score' AND match_date='$match_date' AND match_id!='$this_match')");
# make validated link live
mysql_query("update team_scores set status='1' where match_id='$this_match'");
#mail result to
mail("webmaster@westonpoolleague.org.uk", "League Result $home_team v $away_team", "The following result has been verified.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $email
Email: $useremail
Comments: $comments", "From: rebelt@westonpoolleague.org.uk");
}
}
else
{
echo "<B>This result has already been submitted. Please check the <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">real time results service</a> to see if it has been verified.<BR><BR>";
}
livefooter();
include ('footer.php');
}
###
### List Results In Admin
###
###
function listresults()
{
include ('header.php');
global $admin;
$result = mysql_query("select match_id, home_team, away_team, home_score, away_score, division, email, match_date from team_scores where status=0 order by division");
$thiscount=1;
echo "<font size=4><B>Results Admin</b></font size=4>";
echo "<font size=2><center><b>Pending Results</b></center><br><BR></font>";
echo "<BR><table width=100%>";
$lastdivision="9";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $email, $match_date) = mysql_fetch_row($result))
{
if ($division!=$lastdivision)
{
echo "<tr><td colspan=4 align=center><font size=4><b>Division $division</b></font size=4></td></tr>";
}
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
$email2 = str_replace('.', ',', $email);
echo"<tr><td>$match_id $displaymatchdate $email </td><TD>$home_team $home_score</TD><TD>$away_team</td><TD>$away_score</TD><td><td><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a> <a href=leagueresult.php?op=adminmakelive&id=$match_id>Make Live</a></font></td></tr>";
$thiscount=$thiscount+1;
$lastdivision=$division;
}
echo "</table><BR>";
mysql_free_result($result);
$result = mysql_query("select match_id, home_team, away_team, home_score, away_score, division, email, match_date, status, comments from team_scores where status>0 order by division");
echo "<font size=2><center><b>Live Results</b></center><br><BR></font>";
echo "<BR><table width=100%>";
$lastdivision="9";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $email, $match_date, $status, $comments) = mysql_fetch_row($result))
{
if ($division!=$lastdivision)
{
echo "<tr><td colspan=4 align=center><font size=4><b>Division $division</b></font size=4></td></tr>";
}
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
$email2 = str_replace('.', ',', $email);
if ($status=='3')
{
echo"<tr><td>$match_id $displaymatchdate $email </td><TD></TD><TD></td><TD></TD><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a></font></td></tr>";
}
else
{
echo"<tr><td>$match_id $displaymatchdate $email</td><TD>$home_team $home_score</TD><TD>$away_team</td><TD>$away_score</TD><td><td><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a></font></td></tr>";
}
$thiscount=$thiscount+1;
$lastdivision=$division;
}
echo "</table><BR><BR><BR><a href=\"leagueresult.php\">Live results page</a>";
mysql_free_result($result);
include ("footer.php");
}
###
### Make Live
###
function makelive_result($id, $validate)
{
$email = str_replace(',', '.', $validate);
# read match in
$result = mysql_query("select home_team, away_team, home_score, away_score, match_date, email from team_scores where match_id='$id'");
while (list($home_team, $away_team, $home_score, $away_score, $match_date, $thisemail) = mysql_fetch_row($result))
{
# delete where details are the same and != match_id
if ($email==$thisemail){
mysql_query("delete from team_scores where (home_team='$home_team' AND away_team='$away_team' AND home_score='$home_score' AND away_score='$away_score' AND match_date='$match_date' AND match_id!='$id')"); }
}
# make validated link live
mysql_query("update team_scores set status='1' where match_id='$id' AND email='$email' AND status='0'");
if (mysql_affected_rows()==0)
{
$result = mysql_query("select COUNT(*) from team_scores where match_id='$id'");
$totalcount2=mysql_fetch_array($result);
$totalcount= $totalcount2[0];
# No such ID
if ($totalcount==0)
{
dispmessage('nosuchmatchID', $id);
}
else
{
$result = mysql_query("select home_team, away_team, home_score, away_score, division, match_date, submitter, email, status, comments from team_scores where match_id='$id'");
while (list($home_team, $away_team, $home_score, $away_score, $division, $match_date, $submitter, $thisemail, $status, $comments) = mysql_fetch_row($result))
{
# Already validated
if ($status=='1'){dispmessage('alreadyvalidated', $id);}
# SMS Entry
if ($status=='3'){dispmessage('smssubmission', $id);}
# Wrong email address
if ($email!=$thisemail){dispmessage('wrongemail', $id);}
}
}
}
else
{
$result = mysql_query("select home_team, away_team, home_score, away_score, division, match_date, submitter, email, comments from team_scores where match_id='$id'");
while (list($home_team, $away_team, $home_score, $away_score, $division, $match_date, $submitter, $email, $comments) = mysql_fetch_row($result))
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
mail("webmaster@westonpoolleague.org.uk", "League Result $home_team v $away_team", "The following result has been verified.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $submitter
Email: $email
Comments: $comments", "From: rebelt@westonpoolleague.org.uk");
dispmessage('authorised', $id);
}
}
}
###
### Delete
###
function delete_result($id, $validate)
{
$email = str_replace(',', '.', $validate);
mysql_query("delete from team_scores where match_id='$id' AND email='$email' AND status='0'");
if (mysql_affected_rows()==0)
{
dispmessage('notauthorisedtodelete', $id);
}
else
{
dispmessage('deleted', $id);
}
}
###
### Admin Delete
###
function admin_delete_result($id, $validate)
{
$email = str_replace(',', '.', $validate);
mysql_query("delete from team_scores where match_id='$id'");
if (mysql_affected_rows()==0)
{
dispmessage('nosuchmatchID', $id);
}
else
{
dispmessage('deleted', $id);
}
}
###
### Admin Make Live
###
function admin_makelive_result($id)
{
mysql_query("update team_scores set status='1' where match_id='$id'");
if (mysql_affected_rows()==0)
{
dispmessage('nosuchmatchID', $id);
}
else
{
dispmessage('authorised', $id);
}
}
###
### Errors and Confirmation
###
function dispmessage($messagetype, $id) {
include ('header.php');
if (date("Y-m-d", strtotime("this Tuesday"))==date("Y-m-d", strtotime("today")))
{
$lasttuesday = date("Y-m-d", strtotime("today"));
}
else
{
$lasttuesday = date("Y-m-d", strtotime("last Tuesday"));
}
if ($messagetype=="authorised")
{
echo "<h2><B>Result Validation</b></h2><BR><BR>";
echo "Thank you, your result was successfully verified and has been added to the database. You can view this result on the <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">real time results service by clicking here</a>.";
}
if ($messagetype=="wrongemail")
{
echo "<h2><B>Result Validation</b></h2><BR><BR>";
echo "That is not the correct email address used to submit this match. Only the person who submitted the result can verify it.";
}
if ($messagetype=="alreadyvalidated")
{
echo "<h2><B>Result Validation</b></h2><BR><BR>";
echo "This match has already been validated. Perhaps you clicked the validation link twice by mistake?<BR>To see your result <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">click here for the real time results service</a>.";
}
if ($messagetype=="smssubmission")
{
echo "<h2><B>Result Validation</b></h2><BR><BR>";
echo "You have attempted to validate an SMS submission. It is not possible to do this, nor is it necessary.";
}
if ($messagetype=="deleted")
{
echo "<h2><B>Result Deletion</b></h2><BR><BR>";
echo "Thank you, your result was successfully deleted from the database. Please <a href=\"leagueresult.php?op=resultform\">resubmit your result</a> and try again if necessary.";
}
if ($messagetype=="notauthorisedtoupdate")
{
echo "<h2><B>Result Deletion</b></h2><BR><BR>";
echo "You are not authorised to update that record. If you believe this to be an error, please contact <a href=\"mailto:mail@mail.co.uk\">mail@mail.co.uk</a> quoting the following code: UPDAUTH$id.";
}
if ($messagetype=="notauthorisedtodelete")
{
echo "<h2><B>Result Deletion</b></h2><BR><BR>";
echo "You are not authorised to delete that record. If you believe this to be an error, please contact <a href=\"mailto:mail@mail.co.uk\">mail@mail.co.uk</a> quoting the following code: DELAUTH$id.";
}
if ($messagetype=="nosuchmatchID")
{
echo "<h2><B>Result Deletion</b></h2><BR><BR>";
echo "The match you have tried to delete does not exist. If you believe this to be an error, please contact <a href=\"mailto:mail@mail.co.uk\">mail@mail.co.uk</a> quoting the following code: NOSUCH$id.";
}
livefooter();
include ('footer.php');
}
###
### Page Footer
###
function livefooter(){
echo "<BR><BR><center><table width=90% border=1><tr><td align=center width=50%><a href=\"leagueresult.php?op=resultform\"><B>Add Result</b></a></td></tr></table></center><BR><BR><BR><BR>";
}
###
### Main Entry
###
switch($_REQUEST['op']) {
case "resultform":
resultform($_REQUEST['user']);
break;
case "list":
listresults();
break;
case "FAQ":
FAQ();
break;
case "makelive":
makelive_result($_REQUEST['id'], $_REQUEST['validate']);
break;
case "adminmakelive":
admin_makelive_result($_REQUEST['id']);
break;
case "showdate":
showdate($_REQUEST['date']);
break;
case "teammatches":
teammatches($_REQUEST['team']);
break;
case "delete":
delete_result($_REQUEST['id'], $_REQUEST['validate']);
break;
case "admindelete":
admin_delete_result($_REQUEST['id'], $_REQUEST['validate']);
break;
case "submitted":
submittedresult($_REQUEST['hometeam'], $_REQUEST['awayteam'], $_REQUEST['home_score'], $_REQUEST['away_score'], $_REQUEST['jdivision'], $_REQUEST['match_date'], $_REQUEST['submitter'], $_REQUEST['email'], $_REQUEST['comments'], $_REQUEST['user']);
break;
default:
mainpage();
break;
}
?>
|
|
|
|
|
 |
nuken
RavenNuke(tm) Development Team

Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina
|
Posted:
Sun Jan 22, 2012 12:01 pm |
|
See if these will work
Code:
<?PHP
// includes the mainfile functions and the header junk
if (!isset($mainfile)) { include("mainfile.php"); }
define('INDEX_FILE', true);
### Main Page
### Main Page
### Main Page
function mainpage() {
global $db;
include ('header.php');
maintheader();
echo "<center><B>This online service will be used to add and update Weston Pool League team names, members and venues.<br /> By registering with Weston Pool League, you acknowledge that the league, those who run it and members, are not responsible for access to any venue. <br />If you are new to this process, get started by creating your team using the first option below.<br /><h3>Please make sure the player is ONLY registered to play for your team.</h3><br /><h3><blink><B>Important!</b></blink><br/>DO NOT enter any team detail, until the notice appears on the fromt page telling you the database is ready.</h3></center>";
echo "<BR><table width=100%>";
echo "<a href=\"?op=CreateTeam&step=Venue\">1. Create New Team</a><BR><BR>
<a href=\"?op=ListVenues\">2. List All Venues</a><BR><BR>
<a href=\"?op=ShowMyTeam\">3. Show My Team</a><BR><BR>
<a href=\"?op=ListTeams\">4. List All Teams</a><BR><BR>";
echo "</table>";
maintfooter();
$db->sql_freeresult($result);
include ('footer.php');
}
### List Teams
### List Teams
### List Teams
function listteams() {
global $db;
include ('header.php');
maintheader();
$result = $db->sql_query("select team_id, team_name, division from team_names2 order by division, team_name");
$lastdivision="A";
while (list($teamid, $teamname, $division) = $db->sql_fetchrow($result))
{
if ($division!=$lastdivision)
{
if ($division=='0')
{
echo "<BR><B>Division Unallocated Teams</b> (divisions are usually allocated towards the beginning of the season)<BR><BR>";
}
else
{
echo "<BR><B>Division $division Teams</b><BR><BR>";
}
}
echo "<a href=\"?op=ShowTeam&teamid=$teamid\">$teamname</a><BR>";
$lastdivision=$division;
}
maintfooter();
$db->sql_freeresult($result);
include ('footer.php');
}
### Show My Team
### Show My Team
### Show My Team
function showmyteam($user) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
## Check to see if user is author on a team
$teamresult = $db->sql_query("select COUNT(*) from team_authorisation where authorisation_user='$username'");
$teamcount=$db->sql_fetchrow($teamresult);
$existsonteam= $teamcount[0];
if ($existsonteam)
{
$result = $db->sql_query("select authorisation_teamid from team_authorisation where authorisation_user='$username'");
while (list($authorisation_teamid) = $db->sql_fetchrow($result))
{
$url = "http://mysite.co.uk/maintenance.php?op=ShowTeam&teamid=$authorisation_teamid";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
}
else
{
echo "Unfortunately we cannot find your user ID attached to any existing team. You either need to create a new team or ask the person who administers your team to add your user ID to the list of authorised users.";
exit;
}
$db->sql_freeresult($result);
include ('footer.php');
}
### List Venues
### List Venues
### List Venues
function listvenues() {
global $db;
include ('header.php');
maintheader();
$result = $db->sql_query("select venue_name, venue_id from team_venues order by venue_name");
while (list($venuename, $venueid) = $db->sql_fetchrow($result))
{
echo "<a href=\"?op=ShowVenue&venueid=$venueid\">$venuename</a><BR>";
}
maintfooter();
$db->sql_freeresult($result);
include ('footer.php');
}
### Show Team
### Show Team
### Show Team
function showteam($teamid, $user) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
echo "<h3><B>Show Team Details</b></h3>";
$result = $db->sql_query("select team_venue_id, team_name, team_name_old, division, division_old, team_email, team_telephone, team_alternate_telephone from team_names2 where team_id='$teamid' order by team_id limit 1");
while (list($teamvenueid, $teamname, $teamnameold, $division, $divisionold, $teamemail, $teamtelephone, $teamalternatetelephone) = $db->sql_fetchrow($result))
{
echo "<B>Team Name:</b> $teamname<BR>";
echo "<B>Team Email Contact:</b> $teamemail<BR>";
echo "<B>Team Telephone Contact:</b> $teamtelephone<BR>";
echo "<B>Alternate Team Telephone Contact:</b> $teamalternatetelephone<BR>";
if ($teamnameold!='') echo "<B>Old Team Name:</b> $teamnameold<BR>";
echo "<B>Division This Season:</b>";
if ($division==0) {echo " not yet allocated<BR>";}
else {echo " $division<BR>";}
if ($divisionold!=0) echo "<B>Division Last Season:</b> $divisionold<BR>";
echo "<BR><b>Plays From:</b><BR><BR>";
$result = $db->sql_query("select venue_name, venue_oldname, venue_address, venue_town,
venue_postcode, venue_telephone from team_venues where venue_id='$teamvenueid'");
while (list($venuename, $venueoldname, $venueaddress, $venuetown,
$venuepostcode, $venuetelephone) = $db->sql_fetchrow($result))
{
echo "<table><tr><TD><B>Venue Name:</b> $venuename<BR>
<B>Old Venue Name:</b> $venueoldname<BR>
<B>Venue Address:</b> $venueaddress<BR>
<B>Venue Town:</b> $venuetown<BR>
<B>Venue Postcode:</b> $venuepostcode<BR>
<B>Venue Contact Telephone:</b> $venuetelephone<BR></td><td>
<a href=\"http://uk.multimap.com/map/browse.cgi?client=public&db=pc&cidr_client=none&lang=&pc=".$venuepostcode."\" target=\"_blank\"><img src=\"/images/minimap.jpg\" border=\"0\"><BR>map it</a></td></tr></table>";
}
echo "<BR><BR>";
$x=1;
$result = $db->sql_query("select players_playerid, players_playername, players_playerstartdate from team_players where players_teamid='$teamid' order by players_playerid");
while (list($playersplayerid, $playersplayername, $playersplayerstartdate) = $db->sql_fetchrow($result))
{
$box.="<TR><td>$playersplayername</td><td>".date("Y-m-d", strtotime($playersplayerstartdate))."</td><td>";
if ($x==1){$box.=" (Captain)";}
$box.="</td></tr>";
$x++;
}
if ($box){
echo "<table border=0><tr><td><B>Player Name</b></td><td><B>Valid For games From</b></td><td></td></tr>";
echo $box;
echo "</table>";
}
else
{
echo "No registered players";
}
echo "<BR><BR><B>Current authors:</b><BR>";
# Read existing authors in
$result = $db->sql_query("select authorisation_user from team_authorisation where authorisation_teamid='$teamid'");
while (list($authorisation_user) = $db->sql_fetchrow($result))
{
echo "$authorisation_user<BR>";
if (trim($authorisation_user)==trim($username)) {$author=1;}
}
if ($author){echo "<BR><B><h3><a href=\"http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddPlayers&teamid=$teamid&teamname=$teamname\">add players</a> | <a href=\"http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname\">add authors</a> | <a href=\"http://mysite.co.uk/maintenance.php\">main menu</a></B></h3>";}
else{echo "<BR><B><h3>To edit this team you must be logged in and listed as a team author. </b></h3>";}
}
maintfooter();
include ('footer.php');
}
### Show Venue
### Show Venue
### Show Venue
function showvenue($venueid) {
global $db;
include ('header.php');
maintheader();
echo "<h3><B>Venue Details</b></h3>";
$result = $db->sql_query("select venue_name, venue_oldname, venue_address, venue_town,
venue_postcode, venue_telephone from team_venues where venue_id='$venueid'");
while (list($venuename, $venueoldname, $venueaddress, $venuetown,
$venuepostcode, $venuetelephone) = $db->sql_fetchrow($result))
{
echo "<table><tr><td><B>Venue Name:</b> $venuename<BR>
<B>Old Venue Name:</b> $venueoldname<BR>
<B>Venue Address:</b> $venueaddress<BR>
<B>Venue Town:</b> $venuetown<BR>
<B>Venue Postcode:</b> $venuepostcode<BR>
<B>Venue Contact Telephone:</b> $venuetelephone<BR></td><td>
<a href=\"http://uk.multimap.com/map/browse.cgi?client=public&db=pc&cidr_client=none&lang=&pc=".$venuepostcode."\" target=\"_blank\"><img src=\"/images/minimap.jpg\" border=\"0\"><BR>map it</a></td></tr></table>";
}
maintfooter();
include ('footer.php');
}
### Select Venue
### Select Venue
### Select Venue
function selectvenue($user) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
echo "<SCRIPT LANGUAGE=\"JavaScript\">\n
function Validate(thisForm)\n
{\n";
echo "thisForm.venuename.value=thisForm.venueid.options[thisForm.venueid.selectedIndex].text;\n";
echo "if (thisForm.venuename.value==\"Other...\" || thisForm.venuename.value==\"Select One\"){return (false)};\n";
echo "return (true);\n
}\n
\n
function Validate2(thisForm)\n
{\n";
echo "if (thisForm.venuename.value==\"\" || thisForm.venueaddress.value==\"\" || thisForm.venuetown.value==\"\" || thisForm.venuepostcode.value==\"\" || thisForm.venuetelephone.value==\"\"){alert(\"It is very important that you fill all these fields in so that other site users can find your venue when playing you at home.\"); return (false) };\n";
echo "return (true);\n
}\n
\n
function unhide(thisField, thisObject)\n
{\n
if (thisField.options[thisField.selectedIndex].text==\"Other...\"){thisObject.style.display=\"\";}\n
else\n
{thisObject.style.display=\"none\"}
}\n
function websearch(placename)\n
{\n
url=\"http://www.google.co.uk/search?hl=en&q=\"+placename+\"+weston+super+mare&meta=cr%3DcountryUK%7CcountryGB\";
url2=\"http://www.yell.com/ucs/UcsSearchAction.do?searchType=classic&ooa=on&keywords=&companyName=\"+placename+\"&location=Weston-Super-Mare\"
winRef = window.open(url, \"Websearch\");\n
winRef2 = window.open(url2, \"Websearch2\");\n
}\n
\n
</SCRIPT>";
echo "<center><img src=\"/images/step1.jpg\" align=absmiddle><img src=\"/images/step2grey.jpg\" align=absmiddle><img src=\"/images/step3grey.jpg\" align=absmiddle><img src=\"/images/step4grey.jpg\" align=absmiddle></center>";
echo "<h3><B>Create New Team: Select Venue</b></h3>";
echo "<FORM ONSUBMIT=\"return Validate(this)\" ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"SelectVenue\">
<BR>
My team plays from the following venue:<select name=\"venueid\" onChange=\"unhide(venueid, hiddensection)\";><option selected>Select One</option>";
$result = $db->sql_query("select venue_id, venue_name from team_venues order by venue_name");
while (list($venueid, $venuename) = $db->sql_fetchrow($result))
{
echo "<option value=\"$venueid\">$venuename</option>";
}
echo "<option value=\"other\" default>Other...</option>";
echo "</select>";
echo "<input name=\"venuename\" type=\"hidden\">
<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"VenueSelected\">
<INPUT TYPE=\"submit\" value=\"Next Step->\">";
echo "</form>";
echo "<h3><B>Please make sure your venue is not in the above dropdown list, BEFORE you enter any details below. Venues entered more than once delays fixtures.</b></h3>";
echo "<FORM ACTION=\"maintenance.php\" ONSUBMIT=\"return Validate2(this)\" METHOD=\"POST\" NAME=\"NewVenue\">";
echo "<P ID=\"hiddensection\" STYLE=\"display:none;\">";
echo "Venue not listed? Add it here:<BR><BR><table>
<TR><td><B>Venue Name:</b> </td><td><input type=text NAME=\"venuename\" size=30></td></tr>
<TR><td><B>Old Venue Name:</b> </td><td><input type=text NAME=\"venueoldname\" size=30> (optional)</td></tr>
<TR><td><B>Venue Address:</b> </td><td><input type=text NAME=\"venueaddress\" size=30> <a href=\"javascript:websearch(NewVenue.venuename.value)\" title=\"Clicking here will open search windows to Google and Yell\">Click here to search the web for the address</a></td></tr>
<TR><td><B>Venue Town:</b> </td><td><input type=text NAME=\"venuetown\" size=30></td></tr>
<TR><td><B>Venue Postcode:</b> </td><td><input type=text NAME=\"venuepostcode\" size=30></td></tr>
<TR><td><B>Venue Contact Telephone:</b> </td><td><input type=text NAME=\"venuetelephone\" size=30></td></tr></table>";
echo "<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"SubmittedVenue\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Add Venue\">";
echo "</p>";
echo "</form>";
maintfooter();
include ('footer.php');
}
### Submitted Venue
### Submitted Venue
### Submitted Venue
function submittedvenue($venuename, $venueoldname, $venueaddress, $venuetown, $venuepostcode, $venuetelephone, $user) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if ($username!=''){$email=$username;}
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
$venuename=ucwords(strtolower($venuename));
$venueoldname=ucwords(strtolower($venueoldname));
$venueaddress=ucwords(strtolower($venueaddress));
$venuetown=ucwords(strtolower($venuetown));
$venuepostcode=strtoupper(str_replace ( "-", "", $venuepostcode));
##
## Make sure all fields are filled in
##
if ($venuename=='' or $venueaddress=='' or $venuetown=='' or $venuepostcode=='' or $venuetelephone=='')
{
echo "Somehow you have got this far without filling in all the fields on the previous form. Please return to the previous page and fill in all the fields.";
exit;
}
$result=$db->sql_query("insert into team_venues values (NULL, '$venuename', '$venueoldname', '$venueaddress', '$venuetown', '$venuepostcode', '$venuetelephone')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
### Read back in
$result = $db->sql_query("select venue_id from team_venues where venue_name='$venuename' AND venue_oldname='$venueoldname' AND venue_address='$venueaddress' AND venue_town='$venuetown' AND venue_postcode='$venuepostcode' AND venue_telephone='$venuetelephone' limit 1");
$url = "http://mysite.co.uk/maintenance.php?op=CreateTeam&step=Venue";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
### Venue Selected
### Venue Selected
### Venue Selected
function venueselected($venueid, $venuename, $user) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
###
### 'Teams already allocated' code
###
$teams_already_created.="<B>Teams already created for this venue:</b><BR>";
$result = $db->sql_query("select team_id, team_name, division from team_names2 where team_venue_id='$venueid' order by division, team_name");
$jarraynumber=0;
$jarray.="var existingteams = new Array()\n";
while (list($teamid, $teamname, $division) = $db->sql_fetchrow($result))
{
$teams_already_created.="<a href=\"?op=ShowTeam&teamid=$teamid\">$teamname</a><BR>";
$jarray.="existingteams[$jarraynumber]=\"$teamname\"\n";
$jarraynumber++;
}
##
## end
##
###
### Error checking
###
echo "<SCRIPT LANGUAGE=\"JavaScript\">\n";
echo $jarray;
echo "\n function Validate(thisForm)
{\n";
echo "for (var i=0; i<existingteams.length; i++)
{
var left=thisForm.teamname.value;
var right=existingteams[i];
if (left.toUpperCase()==right.toUpperCase())
{
alert (\"Team name already exists for this venue\");
thisForm.teamname.focus();
return (false);
}
}\n";
echo "if (thisForm.teamname.value==\"\")
{
alert (\"Team name must be filled in\");
thisForm.teamname.focus();
return (false);
}\n";
echo "if (thisForm.teamemail.value==\"\")
{
alert (\"Team email must be filled in\");
thisForm.teamemail.focus();
return (false);
}\n";
echo "if (thisForm.teamtelephone.value==\"\")
{
alert (\"Team telephone must be filled in\");
thisForm.teamtelephone.focus();
return (false);
}
}
</SCRIPT>\n";
###
### end
###
echo "<center><img src=\"/images/step1grey.jpg\" align=absmiddle><img src=\"/images/step2.jpg\" align=absmiddle><img src=\"/images/step3grey.jpg\" align=absmiddle><img src=\"/images/step4grey.jpg\" align=absmiddle></center>";
echo "<h3><B>Create New Team: Team Details</b></h3>";
echo "<FORM ONSUBMIT=\"return Validate(this)\" ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"AddTeam\">
<BR>
<b>Venue:</b> <input type=text NAME=\"venuename\" size=30 value=\"".stripslashes($venuename)."\" disabled><BR>
<input type=hidden NAME=\"venueid\" value=\"$venueid\">
<B>Created By: </b> <input type=text NAME=\"username\" size=30 value=\"".$username."\" disabled><BR>
<BR>
<table>
<TR><td><b>Team Name This Season: </b></td><TD><input type=text NAME=\"teamname\" size=30></td></tr>
<TR><td><b>Team Contact Email: </b></td><TD> <input type=text NAME=\"teamemail\" size=30></td></tr>
<TR><td><b>Team Telephone Contact:</b> </td><TD><input type=text NAME=\"teamtelephone\" size=30></td></tr>
<TR><td><b>Alternative Team Telephone Contact:</b> </td><TD><input type=text NAME=\"teamalternatetelephone\" size=30></td></tr>
<TR><td></td><TD></td></tr>
<TR><td><b>Team Name Last Season:</b> </td><TD><input type=text NAME=\"teamnameold\" size=30> (leave blank if new team)</td></tR>
<TR><td><B>Division Last Season:</b> </td><TD><input type=text NAME=\"divisionold\" size=1> (leave blank if new team)</td></tr>
</table><BR>";
echo "
<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"SubmittedTeamName\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Next Step-->\">";
echo "</form>";
echo $teams_already_created;
maintfooter();
include ('footer.php');
}
### Submitted Team Name
### Submitted Team Name
### Submitted Team Name
function submittedteamname($venueid, $teamname, $teamemail, $teamtelephone, $teamalternatetelephone, $teamnameold, $divisionold, $user) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if ($username!=''){$email=$username;}
$teamname=ucwords(strtolower($teamname));
$teamnameold=ucwords(strtolower($teamnameold));
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
##
## Make sure all fields are filled in
##
if ($teamname=='')
{
echo "Somehow you have got this far without filling in all the fields on the previous form. Please return to the previous page and fill in all the fields.";
exit;
}
### Check if team name at venue already exists, then stop from writing new record
$teamresult = $db->sql_query("select COUNT(*) from team_names2 where team_name='$teamname' AND team_venue_id='$venueid'");
$teamcount=$db->sql_fetchrow($teamresult);
$nameexists= $teamcount[0];
if ($nameexists){echo "Sorry, the team name you specified has already been allocated. Please click the back button on your browser and choose another name."; exit;}
### Write team record
$result=$db->sql_query("insert into team_names2 values (NULL, $venueid, '$teamname', '$teamnameold', '0', '$divisionold', '$teamemail', '$teamtelephone', '$teamalternatetelephone')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
### Read back in
$result = $db->sql_query("select team_id from team_names2 where team_venue_id='$venueid' AND team_name='$teamname' AND team_name_old='$teamnameold' AND division_old='$divisionold' limit 1");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
while (list($teamid2) = $db->sql_fetchrow($result))
{
### Add user to authority file
$teamid=$teamid2;
$result=$db->sql_query("insert into team_authorisation values ('$teamid', '$username')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
}
$url = "http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddPlayers&teamid=$teamid&teamname=$teamname";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
### Add Players
### Add Players
### Add Players
function addplayers($teamid, $teamname, $user) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
echo "<center><img src=\"/images/step1grey.jpg\" align=absmiddle><img src=\"/images/step2grey.jpg\" align=absmiddle><img src=\"/images/step3.jpg\" align=absmiddle><img src=\"/images/step4grey.jpg\" align=absmiddle></center>";
echo "<h3><b>Create New Team: Add Players</b></h3>";
echo "<B>Player names entered here CANNOT be changed. If you do not know the exact name of some of your team members do not enter them. You can come back to this page at any time and add more members to your team without penalty.</b><BR><BR>";
echo "<FORM ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"AddPlayers\">;
<input type=hidden NAME=\"teamid\" value=\"$teamid\">
Team Name: <input type=text NAME=\"teamname2\" value=\"$teamname\" disabled>
<input type=hidden NAME=\"teamname\" value=\"$teamname\">
<input type=hidden NAME=\"user\" value=\"$username\"><BR><BR>";
echo "<b>Players added now will only be elligible to play in games from tomorrow.<BR><BR></b>";
echo "<h4><b>Please enter First and Last names. Not just initial (e.g. John Smith not J.Smith)</b> </h4>
<BR>";
# Read existing players in
$x=1;
$result = $db->sql_query("select players_playerid, players_playername, players_playerstartdate from team_players where players_teamid='$teamid' order by players_playerid");
while (list($playersplayerid, $playersplayername, $playersplayerstartdate) = $db->sql_fetchrow($result))
{
echo "<B>Player $x: </b> <input type=text NAME=\"fixedplayer$x\" size=30 value=\"$playersplayername\" disabled>";
if ($x==1){echo " (Captain)";}
echo "<BR><BR>";
$x++;
}
while ($x<21)
{
echo "<B>Player $x: </b> <input type=text NAME=\"player$x\" size=30 value=\"\">";
if ($x==1){echo " (Captain)";}
echo "<BR><BR>";
$x++;
}
echo "
<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"SubmittedPlayers\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Next Step-->\">";
echo "</form>";
maintfooter();
include ('footer.php');
}
### Submitted Players
### Submitted Players
### Submitted Players
function submittedplayers($teamid, $teamname, $player1, $player2, $player3, $player4, $player5, $player6, $player7, $player8, $player9, $player10, $player11, $player12, $player13, $player14, $player15, $player16, $player17, $player18, $player19, $player20, $user) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if ($username!=''){$email=$username;}
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
##
## Make sure all fields are filled in
##
#if ($teamname=='')
#{
# echo "Somehow you have got this far without filling in all the fields on the previous form. Please #return to the previous page and fill in all the fields.";
#exit;
#}
# Count existing players
$playerresult = $db->sql_query("select COUNT(*) from team_players where players_teamid='$teamid'");
$playercount=$db->sql_fetchrow($playerresult);
$y= $playercount[0];
$x=$y+1;
$tomorrow = date("Y-m-d", strtotime("tomorrow"));
while($x<21)
{
#$thisplayer=str_replace ( ".", " ", ${"player".$x});
#$thisplayer=ucwords(strtolower($thisplayer));
#$thisplayer=ucwords(strtolower(${"player".$x}));
$thisplayer=ucwords(strtolower(str_replace("."," ",${"player".$x})));
### Write player records
if ($thisplayer!=''){
$y++;
$result=$db->sql_query("insert into team_players values ('$y', '$teamid', '$thisplayer', '$tomorrow')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
else
{
}
}
$x++;
}
### Read back in
#$result = $db->sql_query("select team_id from team_names2 where team_venue_id='$venueid' AND team_name='$teamname' AND teamname_old='$teamnameold' AND division_old='$divisionold' limit 1");
#while (list($teamid) = $db->sql_fetchrow($result))
# {
#### Add user to authority file
#$result=$db->sql_query("insert into team_authorisation values ('$teamid', '$username')");
# }
$url = "http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
### Add Authors
### Add Authors
### Add Authors
function addauthors($teamid, $teamname, $user) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
echo "<center><img src=\"/images/step1grey.jpg\" align=absmiddle><img src=\"/images/step2grey.jpg\" align=absmiddle><img src=\"/images/step3grey.jpg\" align=absmiddle><img src=\"/images/step4.jpg\" align=absmiddle></center>";
echo "<h3><B>Create New Team: Add Team Authors</b></h3>";
echo "<FORM ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"AddAuthors\">
Using this form you can add or delete site members as editors of your team. If you do not add any more only you will be able to amend the details about your team. If you do not wish to add them now you can add them at any time in the future.<BR><BR>
<input type=hidden NAME=\"teamid\" value=\"$teamid\">
Team Name: <input type=text NAME=\"teamname2\" value=\"$teamname\" disabled>
<input type=hidden NAME=\"teamname\" value=\"$teamname\">
<input type=hidden NAME=\"user\" value=\"$username\"><BR><BR><B>Current authors:</b><BR>";
# Read existing authors in
$x=0;
$result = $db->sql_query("select authorisation_user from team_authorisation where authorisation_teamid='$teamid'");
while (list($authorisation_user) = $db->sql_fetchrow($result))
{
echo "<input type=text NAME=\"author$x\" size=30 value=\"$authorisation_user\" disabled>";
if ($authorisation_user!=$username){ echo "<a href=\"?op=CreateTeam&step=RemoveAuthor&teamid=$teamid&authorid=$authorisation_user&teamname=$teamname\">remove</a>";}
echo "<BR><BR>";
$author{$x}=$authorisation_user;
$x++;
}
echo "<select name=\"addauthor\" size=\"10\">";
$result = $db->sql_query("select username from rebelt_users");
$authorexists=0;
while (list($allusers) = $db->sql_fetchrow($result))
{
for ($i = 0; $i <= $x; $i++)
{
if ($allusers==$author{$i}){$authorexists=1;}
}
if (!($authorexists)){echo "<option>$allusers</option>";}
$authorexists=0;
}
echo "</select>";
echo "
<input type=hidden name=\"op\" value=\"CreateTeam\">
<input type=hidden name=\"step\" value=\"SubmittedAuthor\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Add Author\"></form><BR><FORM ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"AddAuthors\"><input type=hidden name=\"op\" value=\"Finished\"><input type=hidden name=\"teamid\" value=\"$teamid\"><INPUT TYPE=\"submit\" value=\"Finished-->\">";
echo "</form>";
maintfooter();
include ('footer.php');
}
### Submitted Author
### Submitted Author
### Submitted Author
function submittedauthor($teamid, $teamname, $user, $addauthor) {
global $db;
include ('header.php');
maintheader();
### registered user or email address
$username=getusername($user);
if ($username!=''){$email=$username;}
if (!($username)){echo "Sorry, you need to be a registered user to use this area of the site."; exit;}
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
if ($addauthor==$username){echo "Your name is already in the authors list."; exit;}
##
## Make sure all fields are filled in
##
if ($addauthor=='')
{
echo "You must select a name from the list in order to add an additional team author. If you do not have any more authors to add, just click the 'Finished' button.";
exit;
}
# Count existing players
$playerresult = $db->sql_query("select COUNT(*) from team_players where players_teamid='$teamid'");
$playercount=$db->sql_fetchrow($playerresult);
$y= $playercount[0];
$result=$db->sql_query("insert into team_authorisation values ('$teamid', '$addauthor')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
$url = "http://mysite.co.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
### Finished
### Finished
### Finished
function finished($teamid) {
global $db;
include ('header.php');
maintheader();
$url = "http://mysite.co.uk/league_cup_exclude.php";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
###
### Page Header
###
function maintheader(){
echo "<center><H2><B>Pool Team Maintenance</b></h2></center>";
}
###
### Page Footer
###
function maintfooter(){
echo "<BR><BR><center><table width=90% border=1><tr><td align=center width=50%><a href=\"http://mysite.co.uk/maintenance.php\">Home</a></td><td align=center><a href=\"http://mysite.co.uk/maintenance.php?op=ShowMyTeam\">Show My Team</a></td></tr></table></center><BR><BR><BR><BR>";
}
### Get Username
### Get Username
### Get Username
function getusername($user)
{
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$user2 = explode(":", $user2);
return $user2[1];
}
### URL Forward
### URL Forward
### URL Forward
function urlforward($url)
{
$delay = "0";
return "<meta http-equiv=\"refresh\" content=\"".$delay.";url=".$url."\">";
}
### Check authorisation
### Check authorisation
### Check authorisation
function isauthorised($teamid, $username)
global $db;
{
$result = $db->sql_query("select authorisation_user from team_authorisation where authorisation_teamid='$teamid'");
while (list($authorisation_user) = $db->sql_fetchrow($result))
{
if ($authorisation_user==$username){ return true;}
}
return false;
}
###
### Main Entry
###
switch($op) {
case "CreateTeam":
switch($step) {
case "Venue":
selectvenue($user);
break;
case "SubmittedVenue":
submittedvenue($venuename, $venueoldname, $venueaddress, $venuetown, $venuepostcode, $venuetelephone, $user);
break;
case "VenueSelected":
venueselected($venueid, $venuename, $user);
break;
case "SubmittedTeamName":
submittedteamname($venueid, $teamname, $teamemail, $teamtelephone, $teamalternatetelephone, $teamnameold, $divisionold, $user);
break;
case "AddPlayers":
addplayers($teamid, $teamname, $user);
break;
case "SubmittedPlayers":
submittedplayers($teamid, $teamname, $player1, $player2, $player3, $player4, $player5, $player6, $player7, $player8, $player9, $player10, $player11, $player12, $player13, $player14, $player15, $player16, $player17, $player18, $player19, $player20, $user);
break;
case "AddAuthors":
addauthors($teamid, $teamname, $user);
break;
case "SubmittedAuthor":
submittedauthor($teamid, $teamname, $user, $addauthor);
break;
case "RemoveAuthor":
removeauthor($teamid, $teamname, $user, $authorid);
break;
}
case "Admin":
switch($step)
{
case "List":
listrecords($user);
break;
case "Allocate":
allocate($user);
break;
case "SubmittedTeamAllocations":
submittedteamallocations($user, $allchanges);
break;
case "AdminDelete":
admin_delete_team($id, $user);
break;
case "Summarise":
summarise($user);
break;
case "RemoveVenue":
removevenue($venueid, $user);
break;
case "RemovePlayer":
removeplayer($playerid, $teamid, $user);
break;
default:
adminoptions($user);
break;
}
case "ListTeams":
listteams();
break;
case "ShowTeam":
showteam($teamid, $user);
break;
case "ShowMyTeam":
showmyteam($user);
break;
case "ListVenues":
listvenues();
break;
case "ShowVenue":
showvenue($venueid);
break;
case "Finished":
finished($teamid);
break;
case "FAQ":
FAQ();
break;
default:
mainpage();
break;
}
?>
|
|
_________________ Only registered users can see links on this board! Get registered or login! |
|
|
 |
nuken

|
Posted:
Sun Jan 22, 2012 12:03 pm |
|
Code:
<?PHP
if (!isset($mainfile)) { include("mainfile.php"); }
###
### Main Page
###
function mainpage() {
global $db;
include ('header.php');
$result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, division, match_date from team_scores where status>0 order by match_date DESC");
echo "<center><H2><B>Live Result Listings</b></h2></center>";
echo "<center><B>All results submitted through this system should be genuine match results only.</b><BR><BR><B>New:</b> You can now see a running history of each team's matches by clicking on their team name. For and against graphs are also included.</center>";
echo "<BR><table width=100%>";
$lastmatchdate="";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $match_date) = $db->sql_fetchrow($result))
{
if ($match_date!=$lastmatchdate)
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
echo "<tr><td colspan=4 align=center><font size=4><b><a href=\"leagueresult.php?op=showdate&date=$matchdate\">Click here for matches played on $displaymatchdate</a></b></font size=4></td></tr>";
}
$lastmatchdate=$match_date;
}
echo "</table>";
livefooter();
$db->sql_freeresult($result);
include ('footer.php');
}
###
### Show Date Listing
###
function showdate($matchdate) {
global $db;
include ('header.php');
$result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, division, match_date, status, comments from team_scores where status>0 AND match_date='$matchdate' order by match_date, division");
echo "<BR><center><table width=75% border=1 valign=top>";
$lastdivision="9";
$lastmatchdate="";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $match_date, $status, $comments) = $db->sql_fetchrow($result))
{
if ($match_date!=$lastmatchdate)
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
echo "<tr><td colspan=4 align=center bgcolor=\"#B1CFED\"><h2><b>Games Played On $displaymatchdate</b></h2></td></tr>";
}
if ($division!=$lastdivision)
{
echo "<tr><td colspan=4 align=center bgcolor=\"#EEF4FC\"><font size=4><b>Division $division</b></font size=4></td></tr>";
}
# Look up comments
// $commentresult = $db->sql_query("select COUNT(*) from match_commentary where match_id='$match_id'");
// $commentcount=$db->sql_fetchrow($commentresult);
// $nocomments= $commentcount[0];
if ($status==1)
{
echo "<tr><td bgcolor=\"#ffffff\" align=right width=43%><font size=4><a href=\"leagueresult.php?op=teammatches&team=$home_team\">$home_team</a></font size=4></td><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$home_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$away_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=left width=43%><font size=4><a href=\"leagueresult.php?op=teammatches&team=$away_team\">$away_team</a></font size=4></td></tr>";
}
else
{
echo "<tr><td colspan=4><center><table border=0><td width=90% bgcolor=\"#ffffff\" align=middle width=90%><font size=4>$comments</font size=4></td><td><img src=\"/images/sms.gif\" title=\"This result has been submitted by SMS\"></td></tr></table></center></td><td><center><a href=\"#\" onclick=\"javascript:window.open('commentary.php?matchid=$match_id','COMMENTARY','width=380, height=400, scrollbars=yes, resizable=no, toolbar=no, location=no, status=no, menubar=no')\">Read</a>(<B>".$nocomments."</b>)</center></td></tr>";
}
$thiscount=$thiscount+1;
$lastdivision=$division;
$lastmatchdate=$match_date;
}
livefooter();
$db->sql_freeresult($result);
include ('footer.php');
}
###
### Show All Team Match Scores By date
###
function teammatches($team) {
global $db;
include ('header.php');
$result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, division, match_date, status, comments from team_scores where status>0 AND (home_team='$team' or away_team='$team') order by match_date");
echo "<BR><center><table width=90% border=1 valign=top>";
echo "<tr><td colspan=5 align=center bgcolor=\"#B1CFED\"><h3>Games Played By $team This Season</h3></td></tr>";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $match_date, $status, $comments) = $db->sql_fetchrow($result))
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
echo "<tr><td bgcolor=\"#ffffff\" align=right width=20%><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=33%><font size=4><a href=\"leagueresult.php?op=teammatches&team=$home_team\">$home_team</a></font size=4></td><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$home_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$away_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=left width=33%><font size=4><a href=\"leagueresult.php?op=teammatches&team=$away_team\">$away_team</a></font size=4></td></tr>";
}
echo "</table></center>";
### Graph Progress
$result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, division, match_date, status, comments from team_scores where status>0 AND (home_team='$team' or away_team='$team') order by match_date");
echo "<BR><center><table width=90% border=1 valign=top>";
echo "<tr><td colspan=3 align=center bgcolor=\"#B1CFED\"><h3>Progress This Season</h3></td></tr>";
echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>Match Date</font size=4></td><td bgcolor=\"#ffffff\" align=right width=40%><font size=4>Games Against</font size=4></td><TD bgcolor=\"#ffffff\" align=left width=40%><font size=4>Games For</font size=4></td></tr>";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $match_date, $status, $comments) = $db->sql_fetchrow($result))
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
$homewidth=$home_score*18;
$awaywidth=$away_score*18;
if ($team==$away_team)
{
echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=40%>$home_score<img src=\"/images/reddot.jpg\" height=20 width=$homewidth></td><TD bgcolor=\"#ffffff\" align=left width=40%><img src=\"/images/greendot.jpg\" height=20 width=$awaywidth>$away_score</td></tr>";
}
else
{
echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=40%>$away_score<img src=\"/images/reddot.jpg\" height=20 width=$awaywidth></td><TD bgcolor=\"#ffffff\" align=left width=40%><img src=\"/images/greendot.jpg\" height=20 width=$homewidth>$home_score</td></tr>";
}
}
echo "</table></center>";
livefooter();
$db->sql_freeresult($result);
include ('footer.php');
}
###
### Result Form
###
function resultform($user) {
global $db;
include ('header.php');
### registered user or email address
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$user2 = explode(":", $user2);
$username = "$user2[1]";
## load in team names
$result = $db->sql_query("select team_name, division from team_names2 order by division, team_name");
$result2 = $db->sql_query("select team_name, division from team_names2 order by division, team_name");
if (date("Y-m-d", strtotime("this Tuesday"))==date("Y-m-d", strtotime("today")))
{
$lasttuesday = date("Y-m-d", strtotime("today"));
$displaylasttuesday = date("d-m-Y", strtotime("today"));
}
else
{
$lasttuesday = date("Y-m-d", strtotime("last Tuesday"));
$displaylasttuesday = date("d-m-Y", strtotime("last Tuesday"));
}
echo "<SCRIPT LANGUAGE=\"JavaScript\">\n
var menu=new Array()\n";
$lastdivision=9;
while (list($team_name, $division) = $db->sql_fetchrow($result2))
{
if ($division!=$lastdivision)
{
echo "menu[".$division."]=new Array()\n";
$count=0;
}
echo "menu[".$division."][".$count."]=new Option(\"".$team_name."\")\n";
$count=$count+1;
$lastdivision=$division;
}
echo "function changeTeam(number){
global $db;
for (i=document.Result.home_team.options.length-1;i>0;i--){
document.Result.home_team.options[i]=null
}
for (i=0;i<menu[number].length;i++){
document.Result.home_team.options[i]=new Option(menu[number][i].text,menu[number][i].value)
}
document.Result.home_team.selectedIndex=0
for (i=document.Result.away_team.options.length-1;i>0;i--){
document.Result.away_team.options[i]=null
}
for (i=0;i<menu[number].length;i++){
document.Result.away_team.options[i]=new Option(menu[number][i].text,menu[number][i].value)
}
document.Result.away_team.selectedIndex=0
document.Result.jdivision.value=number;
}\n";
echo "function selectmenu(startteam){
if (startteam.division.options[startteam.division.selectedIndex].value == \"null\"){}
else
{
window.top.location.href = startteam.division.options[startteam.division.selectedIndex].value;
}
}
function Validate(thisForm)
{
if (thisForm.division.options[thisForm.division.selectedIndex].value == \"null\")
{
alert(\"You must select a division.\");
thisForm.division.focus();
return (false);
}
if (thisForm.home_team.value==\"null\")
{
alert(\"You must enter a home team.\");
thisForm.home_team.focus();
return (false);
}
if (thisForm.away_team.value==\"null\")
{
alert(\"You must enter an away team.\");
thisForm.away_team.focus();
return (false);
}
if (thisForm.away_team.options[thisForm.away_team.selectedIndex].text==thisForm.home_team.options[thisForm.home_team.selectedIndex].text)
{
alert(\"Home team cannot be the same as away team.\");
thisForm.home_team.focus();
return (false);
}
if (((thisForm.home_score.options[thisForm.home_score.selectedIndex].text*1)+(thisForm.home_score.options[thisForm.away_score.selectedIndex].text*1)<13) && (thisForm.comments.value==\"\"))
{
alert(\"This score does not add up to 13. If this is the case you must give a reason in the comments box.\");
thisForm.comments.focus();
return (false);
}
if (((thisForm.home_score.options[thisForm.home_score.selectedIndex].text*1)+(thisForm.home_score.options[thisForm.away_score.selectedIndex].text*1)>13) && (thisForm.comments.value==\"\"))
{
alert(\"No more than 13 games should played as part of a match. Please correct the scores.\");
return (false);
}
";
if ($username=='')
{
echo "
if (thisForm.tickme.checked == false)
{
alert (\"You must tick to say you have read and understand the disclaimer.\");
return false;
}
if ((thisForm.email.value.indexOf(\".\") > 2) && (thisForm.email.value.indexOf(\"@\") > 0))
{
}
else
{
alert(\"Without a valid email address you will be unable to validate this result.\");
thisForm.email.focus();
return (false);
}
if (thisForm.email.value.indexOf(\"hotmail\") > 1)
{
alert(\"Hotmail seems to mark the verification emails as junk mail. Please check in your junk mail folder and see if the verification email gets put there.\");
}
if (thisForm.email.value.indexOf(\"lycos\") > 1)
{
alert(\"Lycos rejects emails from this form so we are unable to accept Lycos addresses until they fix their system. Please provide an alternative email address to validate your result. Sorry.\");
return (false);
}
if (thisForm.email.value.indexOf(\"aol\") > 1)
{
alert(\"AOL's email client does not allow links to be clickable so you will need to cut and paste the verification link from the email in to your browser manually. Sorry, AOL's fault, not ours.\");
}
";
}
echo "thisForm.hometeam.value=thisForm.home_team.options[thisForm.home_team.selectedIndex].text
thisForm.awayteam.value=thisForm.away_team.options[thisForm.away_team.selectedIndex].text
thisForm.division.options[thisForm.division.selectedIndex].value='';
return (true);
}
</SCRIPT>";
echo "<STYLE>
<!--
blink {color: red}
-->
</STYLE>
<SCRIPT>
<!--
function doBlink() {
var blink = document.all.tags(\"BLINK\")
for (var i=0; i<blink.length; i++)
blink[i].style.visibility = blink[i].style.visibility == \"\" ? \"hidden\" : \"\"
}
function startBlink() {
if (document.all)
setInterval(\"doBlink()\",500)
}
window.onload = startBlink;
// -->
</SCRIPT>";
echo "<font size=4>Submit League Match Result. If 13-0, please indicate if a no show in the comments box.</font size=4>";
if ($username=='')
{
echo "<BR><blink><B>Important!</b></blink> This result will be emailed to you for confirmation before being accepted. If you do not authorise the result by clicking on the link in the email your result <B>will not</b> be accepted.";
}
# echo "<FORM ACTION=\"leagueresult.php\" METHOD=\"POST\" NAME=\"Result\">";
echo "<FORM ONSUBMIT=\"return Validate(this)\" ACTION=\"leagueresult.php\" METHOD=\"POST\" NAME=\"Result\">
<BR>
<B>Division:</b></font><select name=\"division\" size=\"1\" onChange=\"selectmenu(this.form)\">
<OPTION selected VALUE=\"null\">Div
<OPTION VALUE=\"Javascript:changeTeam(1)\">1
<OPTION VALUE=\"Javascript:changeTeam(2)\">2
<OPTION VALUE=\"Javascript:changeTeam(3)\">3
<OPTION VALUE=\"Javascript:changeTeam(4)\">4
<OPTION VALUE=\"Javascript:changeTeam(5)\">5
<OPTION VALUE=\"Javascript:changeTeam(6)\">6
<OPTION VALUE=\"Javascript:changeTeam(7)\">7
<OPTION VALUE=\"Javascript:changeTeam(8)\">8
</select><BR>
<b>Home Team:</b><select name=\"home_team\">";
echo "<OPTION VALUE=\"null\">Select A Team</select>
<B>Home Score:</b><select name=\"home_score\" size=\"1\">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
</select><BR>
<b>Away Team:</b><select name=\"away_team\">";
echo "<OPTION VALUE=\"null\">Select A Team</select>
<B>Away Score:</b><select name=\"away_score\" size=\"1\">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
</select><BR>
<B>Date:</b> <input type=text NAME=\"matchdate\" value=\"$displaylasttuesday\" disabled><BR>
<B>Your Name:</b> <input type=text NAME=\"submitter\" size=30><BR>";
if ($username=='')
{
echo "<B>Your Email Address:</b> <input type=text NAME=\"email\" size=30><BR>*As a non-registered user your results will need to be validated before acceptance<BR>";
}
else
{
echo "<B>User ID: </b> <input type=text NAME=\"email\" size=30 value=\"".$username."\" disabled> *As a registered user your results are prevalidated<BR>";
}
echo "
<textarea name=\"comments\" cols=60 rows=5></textarea>
<input type=hidden name=\"op\" value=\"submitted\">
<input type=hidden name=\"awayteam\">
<input type=hidden NAME=\"match_date\" value=\"$lasttuesday\">
<input type=hidden NAME=\"jdivision\" value=\"\">
<input type=hidden name=\"hometeam\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Submit\">";
if ($username=='')
{
echo "
<BR clear=all><input type=checkbox name=\"tickme\">By ticking this box I understand that I will have to validate this result through an email sent to me at the address specified above. If I do not get the email, or do not bother to validate it, I understand that my result will not be processed or accepted by the league. I will not bitch and moan if this happens because I was made aware of the consequences beforehand. If I do not get an email I will read <a href=\"http://westonpoolleague.org.uk/leagueresult.php?op=FAQ\">the help page</a> to find out what to do next.";
}
echo "</form>";
livefooter();
include ('footer.php');
}
### Add Result To Database
### Add Result To Database (would now be addtodb.php)
### Add Result To Database
function submittedresult($home_team, $away_team, $home_score, $away_score, $division, $match_date, $submitter, $email, $comments, $user) {
global $db;
include ('header.php');
### registered user or email address
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$user2 = explode(":", $user2);
$username = "$user2[1]";
if ($username!=''){$email=$username;}
echo "<STYLE>
<!--
blink {color: red}
-->
</STYLE>
<SCRIPT>
<!--
function doBlink() {
var blink = document.all.tags(\"BLINK\")
for (var i=0; i<blink.length; i++)
blink[i].style.visibility = blink[i].style.visibility == \"\" ? \"hidden\" : \"\"
}
function startBlink() {
global $db;
if (document.all)
setInterval(\"doBlink()\",500)
}
window.onload = startBlink;
// -->
</SCRIPT>";
#$division=substr($division,22,1);
## Get date of next Tuesday
if (date("Y-m-d", strtotime("this Tuesday"))==date("Y-m-d", strtotime("today")))
{
$lasttuesday = date("Y-m-d", strtotime("today"));
}
else
{
$lasttuesday = date("Y-m-d", strtotime("last Tuesday"));
}
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
##
## Make sure all fields are filled in
##
if ($home_team=='' or $away_team=='' or $home_score=='' or $away_score=='' or $division=='' or $match_date=='' or $email=='')
{
echo "Somehow you have got this far without filling in all the fields on the previous form. Please return to the previous page and fill in all the fields.";
exit;
}
# check to see if this result has already been verified
$result = $db->sql_query("select COUNT(*) from team_scores where home_team='$home_team' AND away_team='$away_team' AND match_date='$match_date' AND division='$division' AND home_score='$home_score' AND away_score='$away_score' AND status='1'");
$totalcount2=$db->sql_fetchrow($result);
$alreadyverified= $totalcount2[0];
### If not validated
if ($alreadyverified==0){
# check to see if this result has been submitted twice
$result = $db->sql_query("select COUNT(*) from team_scores where home_team='$home_team' AND away_team='$away_team' AND match_date='$match_date' AND division='$division' AND home_score='$home_score' AND away_score='$away_score' AND submitter='$submitter' AND email='$email'");
$totalcount3=$db->sql_fetchrow($result);
$alreadylogged= $totalcount3[0];
if ($alreadylogged==0){
$result=$db->sql_query("insert into team_scores values (NULL, '$home_team', '$away_team', $home_score, $away_score, '$division', '$matchdate', '$submitter', 0, '$email', '$comments')");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
}
### Read back in
$result = $db->sql_query("select match_id from team_scores where home_team='$home_team' AND away_team='$away_team' AND match_date='$matchdate' AND division='$division' AND home_score='$home_score' AND away_score='$away_score' AND submitter='$submitter' AND email='$email' limit 1");
while (list($match_id) = $db->sql_fetchrow($result))
{
$this_match=$match_id;
$email2 = str_replace('.', ',', $email);
}
### If not registered user, do validation
if ($email!=$username)
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
if (strstr($email,"aol"))
{
### AOL Mail
#
mail("$email", "Weston Pool League Result Verification", "The following information was submitted to http://westonpoolleague.org.uk. If you have not submitted this information please ignore this email.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $submitter
Email: $email
Comments: $comments
To accept this result please <a href=\"http://westonpoolleague.org.uk/leagueresult.php?op=makelive&id=$this_match&validate=$email2\">click here</a>
To delete this result please <a href=\"http://westonpoolleague.org.uk/leagueresult.php?op=delete&id=$this_match&validate=$email2\">click here</a>
DO NOT DELETE THIS EMAIL. This is confirmation of receipt of your result and may be needed in cases of dispute.", "From: rebelt@westonpoolleague.org.uk");
####
}
else
{
###Normal email
mail("$email", "Weston Pool League Result Verification", "The following information was submitted to http://westonpoolleague.org.uk. If you have not submitted this information please ignore this email.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $submitter
Email: $email
Comments: $comments
To validate this result click this link:
http://westonpoolleague.org.uk/leagueresult.php?op=makelive&id=$this_match&validate=$email2
IF YOU DO NOT VALIDATE, YOUR RESULT WILL NOT BE SENT TO THE LEAGUE AND THE GAME WILL BE FORFEIT
To delete this result click this link:
http://westonpoolleague.org.uk/leagueresult.php?op=delete&id=$this_match&validate=$email2
DO NOT DELETE THIS EMAIL. This is confirmation of receipt of your result and may be needed in cases of dispute.
", "From: westonpoolleague.org.uk");
}
echo "<h2>Result Submission</h2>
Division: $division<BR>
Home team: $home_team $home_score<BR>
Away team: $away_team $away_score<BR>
Match date: $displaymatchdate<BR>
Submitted By: $submitter<BR>
Email: $email<BR>
Comments: $comments
<BR><BR>";
echo "<font size=4>Your result has not been accepted. Yet. </font size=4> In order to complete the result submission process, you must now check the email address you specified and click on the link inside. This is a very simple process and will take you a matter of seconds. Hopefully you will see how this makes the system more secure and stops people submitting fake results for your match or wasting the league's time with malicious submissions.<Br><BR> Once you have clicked the link your result will appear in the Live Results table straight away. You can see it by <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">clicking here</a>.<BR><BR><Blink>Remember, if you do not verify this result it will not be accepted!</blink>";
}
else
{
### Registered user. Send email and validate.
### Look up email address
$result = $db->sql_query("select user_email from nuke_users where username='$email'");
while (list($useremail) = $db->sql_fetchrow($result))
{
mail("$useremail", "Weston Pool League Result", "The following match result has been received and pre-validated.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $email
Email: $useremail
Comments: $comments
Thank you for your submission.
DO NOT DELETE THIS EMAIL. This is confirmation of receipt of your result and may be needed in cases of dispute.
", "From: rebelt@westonpoolleague.org.uk");
}
echo "<h2>Result Submission</h2>
Division: $division<BR>
Home team: $home_team $home_score<BR>
Away team: $away_team $away_score<BR>
Match date: $displaymatchdate<BR>
Submitted By: $email<BR>
Email: $useremail<BR>
Comments: $comments
<BR><BR>";
echo "<font size=4>As a pregistered site user your result has now been pre-validated and accepted. There is no need to do anything further.</font size=4> You can see it by <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">clicking here</a>.<BR><BR>";
### Update result to live
# delete where details are the same and != match_id
$db->sql_query("delete from team_scores where (home_team='$home_team' AND away_team='$away_team' AND home_score='$home_score' AND away_score='$away_score' AND match_date='$match_date' AND match_id!='$this_match')");
# make validated link live
$db->sql_query("update team_scores set status='1' where match_id='$this_match'");
#mail result to
mail("webmaster@westonpoolleague.org.uk", "League Result $home_team v $away_team", "The following result has been verified.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $email
Email: $useremail
Comments: $comments", "From: rebelt@westonpoolleague.org.uk");
}
}
else
{
echo "<B>This result has already been submitted. Please check the <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">real time results service</a> to see if it has been verified.<BR><BR>";
}
livefooter();
include ('footer.php');
}
###
### List Results In Admin
###
###
function listresults()
{
include ('header.php');
global $db;
global $admin;
$result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, division, email, match_date from team_scores where status=0 order by division");
$thiscount=1;
echo "<font size=4><B>Results Admin</b></font size=4>";
echo "<font size=2><center><b>Pending Results</b></center><br><BR></font>";
echo "<BR><table width=100%>";
$lastdivision="9";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $email, $match_date) = $db->sql_fetchrow($result))
{
if ($division!=$lastdivision)
{
echo "<tr><td colspan=4 align=center><font size=4><b>Division $division</b></font size=4></td></tr>";
}
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
$email2 = str_replace('.', ',', $email);
echo"<tr><td>$match_id $displaymatchdate $email </td><TD>$home_team $home_score</TD><TD>$away_team</td><TD>$away_score</TD><td><td><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a> <a href=leagueresult.php?op=adminmakelive&id=$match_id>Make Live</a></font></td></tr>";
$thiscount=$thiscount+1;
$lastdivision=$division;
}
echo "</table><BR>";
$db->sql_freeresult($result);
$result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, division, email, match_date, status, comments from team_scores where status>0 order by division");
echo "<font size=2><center><b>Live Results</b></center><br><BR></font>";
echo "<BR><table width=100%>";
$lastdivision="9";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $email, $match_date, $status, $comments) = $db->sql_fetchrow($result))
{
if ($division!=$lastdivision)
{
echo "<tr><td colspan=4 align=center><font size=4><b>Division $division</b></font size=4></td></tr>";
}
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
$email2 = str_replace('.', ',', $email);
if ($status=='3')
{
echo"<tr><td>$match_id $displaymatchdate $email </td><TD></TD><TD></td><TD></TD><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a></font></td></tr>";
}
else
{
echo"<tr><td>$match_id $displaymatchdate $email</td><TD>$home_team $home_score</TD><TD>$away_team</td><TD>$away_score</TD><td><td><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a></font></td></tr>";
}
$thiscount=$thiscount+1;
$lastdivision=$division;
}
echo "</table><BR><BR><BR><a href=\"leagueresult.php\">Live results page</a>";
$db->sql_freeresult($result);
include ("footer.php");
}
###
### Make Live
###
function makelive_result($id, $validate)
{
global $db;
$email = str_replace(',', '.', $validate);
# read match in
$result = $db->sql_query("select home_team, away_team, home_score, away_score, match_date, email from team_scores where match_id='$id'");
while (list($home_team, $away_team, $home_score, $away_score, $match_date, $thisemail) = $db->sql_fetchrow($result))
{
# delete where details are the same and != match_id
if ($email==$thisemail){
$db->sql_query("delete from team_scores where (home_team='$home_team' AND away_team='$away_team' AND home_score='$home_score' AND away_score='$away_score' AND match_date='$match_date' AND match_id!='$id')"); }
}
# make validated link live
$db->sql_query("update team_scores set status='1' where match_id='$id' AND email='$email' AND status='0'");
if ($db->sql_affectedrows()==0)
{
$result = $db->sql_query("select COUNT(*) from team_scores where match_id='$id'");
$totalcount2=$db->sql_fetchrow($result);
$totalcount= $totalcount2[0];
# No such ID
if ($totalcount==0)
{
dispmessage('nosuchmatchID', $id);
}
else
{
$result = $db->sql_query("select home_team, away_team, home_score, away_score, division, match_date, submitter, email, status, comments from team_scores where match_id='$id'");
while (list($home_team, $away_team, $home_score, $away_score, $division, $match_date, $submitter, $thisemail, $status, $comments) = $db->sql_fetchrow($result))
{
# Already validated
if ($status=='1'){dispmessage('alreadyvalidated', $id);}
# SMS Entry
if ($status=='3'){dispmessage('smssubmission', $id);}
# Wrong email address
if ($email!=$thisemail){dispmessage('wrongemail', $id);}
}
}
}
else
{
$result = $db->sql_query("select home_team, away_team, home_score, away_score, division, match_date, submitter, email, comments from team_scores where match_id='$id'");
while (list($home_team, $away_team, $home_score, $away_score, $division, $match_date, $submitter, $email, $comments) = $db->sql_fetchrow($result))
{
$matchdate = date("Y-m-d", strtotime($match_date));
$displaymatchdate = date("d-m-Y", strtotime($match_date));
mail("webmaster@westonpoolleague.org.uk", "League Result $home_team v $away_team", "The following result has been verified.
Division: $division
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $submitter
Email: $email
Comments: $comments", "From: rebelt@westonpoolleague.org.uk");
dispmessage('authorised', $id);
}
}
}
###
### Delete
###
function delete_result($id, $validate)
{
global $db;
$email = str_replace(',', '.', $validate);
$db->sql_query("delete from team_scores where match_id='$id' AND email='$email' AND status='0'");
if ($db->sql_affectedrows()==0)
{
dispmessage('notauthorisedtodelete', $id);
}
else
{
dispmessage('deleted', $id);
}
}
###
### Admin Delete
###
function admin_delete_result($id, $validate)
{
global $db;
$email = str_replace(',', '.', $validate);
$db->sql_query("delete from team_scores where match_id='$id'");
if ($db->sql_affectedrows()==0)
{
dispmessage('nosuchmatchID', $id);
}
else
{
dispmessage('deleted', $id);
}
}
###
### Admin Make Live
###
function admin_makelive_result($id)
{
global $db;
$db->sql_query("update team_scores set status='1' where match_id='$id'");
if ($db->sql_affectedrows()==0)
{
dispmessage('nosuchmatchID', $id);
}
else
{
dispmessage('authorised', $id);
}
}
###
### Errors and Confirmation
###
function dispmessage($messagetype, $id) {
include ('header.php');
global $db;
if (date("Y-m-d", strtotime("this Tuesday"))==date("Y-m-d", strtotime("today")))
{
$lasttuesday = date("Y-m-d", strtotime("today"));
}
else
{
$lasttuesday = date("Y-m-d", strtotime("last Tuesday"));
}
if ($messagetype=="authorised")
{
echo "<h2><B>Result Validation</b></h2><BR><BR>";
echo "Thank you, your result was successfully verified and has been added to the database. You can view this result on the <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">real time results service by clicking here</a>.";
}
if ($messagetype=="wrongemail")
{
echo "<h2><B>Result Validation</b></h2><BR><BR>";
echo "That is not the correct email address used to submit this match. Only the person who submitted the result can verify it.";
}
if ($messagetype=="alreadyvalidated")
{
echo "<h2><B>Result Validation</b></h2><BR><BR>";
echo "This match has already been validated. Perhaps you clicked the validation link twice by mistake?<BR>To see your result <a href=\"leagueresult.php?op=showdate&date=$lasttuesday\">click here for the real time results service</a>.";
}
if ($messagetype=="smssubmission")
{
echo "<h2><B>Result Validation</b></h2><BR><BR>";
echo "You have attempted to validate an SMS submission. It is not possible to do this, nor is it necessary.";
}
if ($messagetype=="deleted")
{
echo "<h2><B>Result Deletion</b></h2><BR><BR>";
echo "Thank you, your result was successfully deleted from the database. Please <a href=\"leagueresult.php?op=resultform\">resubmit your result</a> and try again if necessary.";
}
if ($messagetype=="notauthorisedtoupdate")
{
echo "<h2><B>Result Deletion</b></h2><BR><BR>";
echo "You are not authorised to update that record. If you believe this to be an error, please contact <a href=\"mailto:mail@mail.co.uk\">mail@mail.co.uk</a> quoting the following code: UPDAUTH$id.";
}
if ($messagetype=="notauthorisedtodelete")
{
echo "<h2><B>Result Deletion</b></h2><BR><BR>";
echo "You are not authorised to delete that record. If you believe this to be an error, please contact <a href=\"mailto:mail@mail.co.uk\">mail@mail.co.uk</a> quoting the following code: DELAUTH$id.";
}
if ($messagetype=="nosuchmatchID")
{
echo "<h2><B>Result Deletion</b></h2><BR><BR>";
echo "The match you have tried to delete does not exist. If you believe this to be an error, please contact <a href=\"mailto:mail@mail.co.uk\">mail@mail.co.uk</a> quoting the following code: NOSUCH$id.";
}
livefooter();
include ('footer.php');
}
###
### Page Footer
###
function livefooter(){
echo "<BR><BR><center><table width=90% border=1><tr><td align=center width=50%><a href=\"leagueresult.php?op=resultform\"><B>Add Result</b></a></td></tr></table></center><BR><BR><BR><BR>";
}
###
### Main Entry
###
switch($_REQUEST['op']) {
case "resultform":
resultform($_REQUEST['user']);
break;
case "list":
listresults();
break;
case "FAQ":
FAQ();
break;
case "makelive":
makelive_result($_REQUEST['id'], $_REQUEST['validate']);
break;
case "adminmakelive":
admin_makelive_result($_REQUEST['id']);
break;
case "showdate":
showdate($_REQUEST['date']);
break;
case "teammatches":
teammatches($_REQUEST['team']);
break;
case "delete":
delete_result($_REQUEST['id'], $_REQUEST['validate']);
break;
case "admindelete":
admin_delete_result($_REQUEST['id'], $_REQUEST['validate']);
break;
case "submitted":
submittedresult($_REQUEST['hometeam'], $_REQUEST['awayteam'], $_REQUEST['home_score'], $_REQUEST['away_score'], $_REQUEST['jdivision'], $_REQUEST['match_date'], $_REQUEST['submitter'], $_REQUEST['email'], $_REQUEST['comments'], $_REQUEST['user']);
break;
default:
mainpage();
break;
}
?>
|
|
|
|
|
 |
Guardian2003
Site Admin

Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Sun Jan 22, 2012 1:08 pm |
|
If you get stuck you can send the script to me for a FREE re-write, including updating the code so that it is standards compliant etc. |
|
|
|
 |
Dawg
RavenNuke(tm) Development Team

Joined: Nov 07, 2003
Posts: 928
|
Posted:
Sun Jan 22, 2012 1:44 pm |
|
Guardian2003 wrote: | If you get stuck you can send the script to me for a FREE re-write, including updating the code so that it is standards compliant etc. |
Now that is SERVICE!
 |
|
|
|
 |
rebelt

|
Posted:
Sun Jan 22, 2012 4:13 pm |
|
Guardian2003 wrote: | If you get stuck you can send the script to me for a FREE re-write, including updating the code so that it is standards compliant etc. |
WOW. That would be great. Could you pm me an email address so I can attach the scripts please. |
|
|
|
 |
Guardian2003

|
Posted:
Sun Jan 22, 2012 11:54 pm |
|
|
|
 |
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm

Joined: Aug 13, 2009
Posts: 1123
|
Posted:
Mon Jan 23, 2012 10:13 am |
|
That was an amazing server from nuken as always. It will be nice a pastebin option for these big files maybe to not be storage in phpmyadmin but as a file in the server so we don't get any space in between. |
|
|
|
 |
rebelt

|
Posted:
Sun May 20, 2012 12:28 pm |
|
Guardian2003 wrote: | If you get stuck you can send the script to me for a FREE re-write, including updating the code so that it is standards compliant etc. |
Guardian actually turned these into a module, but just as it was almost finished, he became swamped with other work.
As he's now "off the grid for about 8 weeks" I'm stuck.
There was an unresolved problem of players disappearing.
The most recent idea was
Quote: | When new players are added, the form gives each player name an id and I think from a quick look at the code, that this id is what is used for the pid when the data is inserted. Obviously as the pid is an auto-number field, I cannot do that; I cannot insert a record and give it a pid because the database itself assigns that number and I think that might be where the users are disappearing.
When multiple players are added at the same time, if one of the record (pid) already exists it just won't add that particular player but it will add the others, making it seem as though everything has worked (no error message).
If it is just one player being added; for arguments sake, player 3 on the list and pid 3 is already there it would generate the "could not write record" error message.
|
This is the file
Code:<?php
if(!defined('LEAGUE')) die('Direct access not allowed');
$stop = 0;
global $db, $module_name, $stop;
addCSSToHead('modules/'.$module_name.'/style.css', 'file');
include_once 'header.php';
OpenTable();
include_once 'modules/'.$module_name.'/public/menu.php';
CloseTable();
OpenTable();
// TERMINATE IF NOT REG USER
if(!is_user($user)) {
echo '<div class="error">Sorry, you need to be a registered user to use this area of the site.</div>';
CloseTable();
include_once 'footer.php';
exit;
}
if(!isset($func)) $func = '';
if($func == 'RemPlayer'){
RemPlayer($playersplayername, $tid, $teamname);
}
$username = getusername($user);
if (!(isauthorised($teamid, $username))){
echo '<div class="validation">Not authorised!</div>';
CloseTable();
include_once 'footer.php';
exit;
}
//if(isset($_POST)) print_r($_POST);
if(isset($_POST) && $_POST['submit'] == 'Add Players'){
$teamid = intval($_POST['teamid']);
$teamname = strip_tags($_POST['teamname']);
// Count existing players
$playerresult = $db->sql_query("SELECT COUNT(*) FROM ca_league_team_players
WHERE players_teamid='$teamid'");
$playercount = $db->sql_fetchrow($playerresult);
$y = $playercount[0];
$x = $y+1;
$tomorrow = date("Y-m-d", strtotime("tomorrow"));
while($x<21){
//$thisplayer=str_replace ( ".", " ", ${"player".$x});
//$thisplayer=ucwords(strtolower($thisplayer));
//$thisplayer=ucwords(strtolower(${"player".$x}));
$thisplayer = ucwords(strtolower(str_replace("."," ",${"player".$x})));
### Write player records
if ($thisplayer!=''){
$y++;
$result = $db->sql_query("INSERT INTO ca_league_team_players
VALUES ('$y', '$teamid', '$thisplayer', '$tomorrow')");
if (!$result) {
die('Could not write record: ' . mysql_error());
} else {
echo '<div class="info">Records updated: '.$thisplayer.' added</div>';
}
}
$x++;
}
CloseTable();
include_once 'footer.php';
exit;
}
// RENDER FORM
echo '<div class="info"><strong>Player names entered here CANNOT be changed.
If you do not know the exact name of some of your team members do not enter them.
You can come back to this page at any time and add more members to your team without penalty.</strong></div>';
echo '<form action="modules.php?name='.$module_name.'&op=AddPlayers" method="post">
<fieldset><legend>Add Players</legend>
<input type="hidden" name="teamid" value="'.$teamid.'" />
<label style="width:100px; display:block; float:left;" for="teamname2">Team Name: </label>
<input type="text" name="teamname2" value="'.$teamname.'" disabled />
<input type="hidden" name="teamname" value="'.$teamname.'" />
<input type="hidden" name="user" value="'.$username.'" /><br /><br />';
echo '<div class="info"><strong>Players added now will only be elligible to play in games from tomorrow.</strong><br />
Please enter First and Last names. Not just initial (e.g. John Smith not J.Smith)</div>';
# Read existing players in
$x = 1;
$result = $db->sql_query("SELECT players_playerid, players_playername, players_playerstartdate
FROM ca_league_team_players WHERE players_teamid='$teamid' ORDER BY players_playerid");
while (list($playersplayerid, $playersplayername, $playersplayerstartdate) = $db->sql_fetchrow($result)){
echo '<label style="width:75px; display:block; float:left;" for="fixedplayer'.$x.'">Player '.$x.': </label>
<input type="text" name="fixedplayer'.$x.'" size="30" value="'.$playersplayername.'" disabled />';
if ($x == 1){
echo ' (Captain)';
} else {
echo '<a href="modules.php?name='.$module_name.'&op=AddPlayers&func=RemPlayer&playersplayername='.$playersplayername.'&tid='.$teamid.'&teamname='.$teamname.'"> Remove Player</a>';
}
echo '<br /><br />';
$x++;
}
while ($x<21){
echo '<label style="width:75px; display:block; float:left;" for="player'.$x.'">Player '.$x.': </label><input type="text" name="player'.$x.'" size="30" value="">';
if ($x==1){
echo ' (Captain)';
}
echo '<br /><br />';
$x++;
}
echo '<input type="submit" class="button" name="submit" value="Add Players" />
</fieldset></form>';
echo '<div style="text-align:right;">© <a href="http://www.code-authors.com" target="_blank" title="Code Authors">Code Authors</a></div>';
CloseTable();
include_once 'footer.php';
// FUNCTIONS
### Get Username
function getusername($user){
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$user2 = explode(":", $user2);
return $user2[1];
}
function RemPlayer($playersplayername, $tid, $teamname){
global $db, $module_name, $teamname;
$query ='DELETE FROM ca_league_team_players WHERE players_teamid = \''.$tid.'\' AND players_playername = \''.$playersplayername.'\'';
$db->sql_query($query);
header('Location: modules.php?name=' . $module_name . '&op=AddPlayers&teamid='.$tid.'&teamname='.$teamname.'');
}
function isauthorised($teamid, $username){
global $db;
$result = $db->sql_query("SELECT authorisation_user
FROM ca_league_team_authorisation WHERE authorisation_teamid='$teamid'");
while (list($authorisation_user) = $db->sql_fetchrow($result)){
if ($authorisation_user == $username){
return true;
}
}
return false;
}
|
Could anyone help with this please.
If you need to see the whole module I will send it to you. |
|
|
|
 |
Palbin
Site Admin

Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Sun May 20, 2012 4:02 pm |
|
I need the entire module. I do not see how add players works at all currently.
Guardian is talking about this:
Code:
while($x<21){
//$thisplayer=str_replace ( ".", " ", ${"player".$x});
//$thisplayer=ucwords(strtolower($thisplayer));
//$thisplayer=ucwords(strtolower(${"player".$x}));
$thisplayer = ucwords(strtolower(str_replace("."," ",${"player".$x})));
### Write player records
if ($thisplayer!=''){
$y++;
$result = $db->sql_query("INSERT INTO ca_league_team_players
VALUES ('$y', '$teamid', '$thisplayer', '$tomorrow')");
if (!$result) {
die('Could not write record: ' . mysql_error());
} else {
echo '<div class="info">Records updated: '.$thisplayer.' added</div>';
}
}
$x++;
}
|
Specifically he is talking about $y. It should probably be NULL and let it auto-increment, but it is hard to tell with out the entire module. I will also need the database tables. If you have an installation script or sql file that would be fine. I just need the table structure not the data that may be in them. |
_________________ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. |
|
|
 |
rebelt

|
Posted:
Mon May 21, 2012 12:09 pm |
|
Module and tables are Only registered users can see links on this board! Get registered or login!
Thank You |
|
|
|
 |
rebelt

|
Posted:
Mon May 28, 2012 5:37 pm |
|
Well I changed it to this,
### Write player records
if ($thisplayer!=''){
$result = $db->sql_query("INSERT INTO ca_league_team_players
VALUES ('$NULL', '$teamid', '$thisplayer', '$tomorrow')"); Code:
And it looks like it did the trick.
Thanks Palbin.
|
Edit. I put the code tags around the code, even edited but they moved on their own. Weird.  |
|
|
|
 |
rebelt

|
Posted:
Mon May 28, 2012 5:43 pm |
|
Can't seem to edit the post above. |
|
|
|
 |
rebelt

|
Posted:
Mon Jun 04, 2012 6:04 am |
|
Could someone help me put users in a dropdown box instead of a list please.
Code:echo '<ul>';
$result = $db->sql_query('SELECT `username` FROM `nuke_users`'); //_users
$authorexists = 0;
while (list($allusers) = $db->sql_fetchrow($result)){
for ($i = 0; $i <= $x; $i++) {
if ($allusers == $author{$i}){$authorexists = 1;}
}
if (!($authorexists)){
echo '<li><a href="modules.php?name='.$module_name.'&op=AddAuthors&func=AddAuthor&teamid='.$teamid.'&addauthor='.$allusers.'&teamname='.$teamname.'">'.$allusers.' - Add as Team Manager</a></li>';
}
$authorexists = 0;
}
echo '</ul>';
|
Just in case, this is the whole file.
addauthore.php
Code:<?php
if(!defined('LEAGUE')) die('Direct access not allowed');
$stop = 0;
global $db, $module_name, $stop;
addCSSToHead('modules/'.$module_name.'/style.css', 'file');
include_once 'header.php';
OpenTable();
include_once 'modules/'.$module_name.'/public/menu.php';
CloseTable();
OpenTable();
// TERMINATE IF NOT REG USER
if(!is_user($user)) {
echo '<div class="error">Sorry, you need to be a registered user to use this area of the site.</div>';
CloseTable();
include_once 'footer.php';
exit;
}
$username=getusername($user);
if (!($username)){
echo '<div class="warning">Sorry, you need to be a registered user to use this area of the site.</div>';
CloseTable();
include_once 'footer.php';
exit;
}
if (!(isauthorised($teamid, $username))){
echo '<div class="warning">Not authorised.</div>';
CloseTable();
include_once 'footer.php';
exit;
}
// are we performing an add or remove function?
if(!isset($func)) $func = '';
if($func == 'AddAuthor'){
AddAuthor($teamid, $addauthor, $teamname);
}
if($func == 'RemoveAuthor'){
RemoveAuthor($teamid, $authorisation_user, $teamname);
}
echo '<div><p>Using this form you can add or delete site members as Managers of your team.
If you do not add any more, only you will be able to amend the details about your team.
If you do not wish to add them now, you can add them at any time in the future.</p></div>';
echo '<br />
<h2>Team Name: '.$teamname.' </h2>';
// Read existing authors in
echo '<strong>Existing Managers:</strong><ul>';
$x=0;
$result = $db->sql_query("SELECT authorisation_user FROM ca_league_team_authorisation WHERE authorisation_teamid='$teamid'");
while (list($authorisation_user) = $db->sql_fetchrow($result)){
echo '<li>'.$authorisation_user.'';
if ($authorisation_user!=$username){
echo '<a href="modules.php?name='.$module_name.'&op=AddAuthors&func=RemoveAuthor&teamid='.$teamid.'&authorisation_user='.$authorisation_user.'&teamname='.$teamname.'"> Remove Manager '.$authorisation_user.'</a>';
echo '</li>';
}
echo '</ul>';
$author{$x}=$authorisation_user;
$x++;
}
echo '<ul>';
$result = $db->sql_query('SELECT `username` FROM `nuke_users`'); //_users
$authorexists = 0;
while (list($allusers) = $db->sql_fetchrow($result)){
for ($i = 0; $i <= $x; $i++) {
if ($allusers == $author{$i}){$authorexists = 1;}
}
if (!($authorexists)){
echo '<li><a href="modules.php?name='.$module_name.'&op=AddAuthors&func=AddAuthor&teamid='.$teamid.'&addauthor='.$allusers.'&teamname='.$teamname.'">'.$allusers.' - Add as Team Manager</a></li>';
}
$authorexists = 0;
}
echo '</ul>';
echo '<div style="text-align:right;">© <a href="http://www.code-authors.com" target="_blank" title="Code Authors">Code Authors</a></div>';
CloseTable();
include_once 'footer.php';
//}
// FUNCTIONS
### Get Username
function getusername($user){
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$user2 = explode(":", $user2);
return $user2[1];
}
function isauthorised($teamid, $username){
global $db;
$result = $db->sql_query("SELECT authorisation_user
FROM ca_league_team_authorisation WHERE authorisation_teamid='$teamid'");
while (list($authorisation_user) = $db->sql_fetchrow($result)){
if ($authorisation_user == $username){
return true;
}
}
return false;
}
function AddAuthor($teamid, $addauthor, $teamname) {
global $db, $module_name, $teamname;
$query = "INSERT INTO ca_league_team_authorisation VALUES ('$teamid', '$addauthor')";
$db->sql_query($query);
header('Location: modules.php?name=' . $module_name . '&op=AddAuthors&teamid='.$teamid.'&teamname='.$teamname.'');
}
function RemoveAuthor($teamid, $authorisation_user, $teamname) {
global $db, $module_name, $teamname;
$query ='DELETE FROM ca_league_team_authorisation WHERE authorisation_user = \''.$authorisation_user.'\'';
$db->sql_query($query);
header('Location: modules.php?name=' . $module_name . '&op=AddAuthors&teamid='.$teamid.'&teamname='.$teamname.'');
}
|  |
|
|
|
 |
neralex
Site Admin

Joined: Aug 22, 2007
Posts: 1775
|
Posted:
Mon Jun 04, 2012 3:18 pm |
|
i have try it to install your files. i think, you have destroyed the complete module. nothing works correct. all functions comes with errors. |
|
|
|
 |
rebelt

|
Posted:
Mon Jun 04, 2012 5:45 pm |
|
rar file is Only registered users can see links on this board! Get registered or login!
Or go to the site http://test.wsmpool.co.uk
Log in as testuser testuser
CA League / Show my team/ Add managers
You'll see a long list of users. |
|
|
|
 |
Palbin

|
Posted:
Mon Jun 04, 2012 5:50 pm |
|
I did not test this, but give this a go.
Code:
echo '<form method="get" action="' . $module_name . '&op=AddAuthors&func=AddAuthor&teamid=' . $teamid . '&teamname=' . $teamname . '">'
. '<select name="addauthor">';
$result = $db->sql_query('SELECT `username` FROM `nuke_users`');
$authorexists = 0;
while (list($allusers) = $db->sql_fetchrow($result, SQL_NUM)) {
for ($i = 0; $i <= $x; $i++) {
if ($allusers == $author{$i}) {
$authorexists = 1;
}
}
if (!($authorexists)) {
echo '<option value="' . $allusers . '">' . $allusers . '</option>';
}
$authorexists = 0;
}
echo '</select>'
. '<input type="submit" name="submit" value="submit"/>'
. '</form>';
|
|
|
|
|
 |
rebelt

|
Posted:
Mon Jun 04, 2012 5:57 pm |
|
Gave it a go box with dropdown was fine
But got a 404 error object not found on submit. |
Last edited by rebelt on Tue Jun 05, 2012 1:22 am; edited 1 time in total |
|
|
 |
killing-hours
RavenNuke(tm) Development Team

Joined: Oct 01, 2010
Posts: 438
Location: Houston, Tx
|
Posted:
Mon Jun 04, 2012 6:12 pm |
|
Code:echo '<select id="YOUR_ID">'; // Begin your selectmenu
$getUID = $db->sql_query('SELECT `username` FROM `nuke_users`'); // Get the user data from the database
$authorexists = 0; // Set the author check to 0 for the for loop to check
while($user = $db->sql_fetchrow($getUID)){ // begin while loop to iterate over the results
for ($i = 0; $i <= $x; $i++) {
if ($allusers == $author{$i}){
$authorexists = 1;
}
}
if($authorexists != 0){
echo '<option id="'.$SOME_ID.'" value="'.$SOME_VALUE.'">'.$USERNAME.'</option>'; // set an option for each result using some data to distinguish them apart. ID's must
}
} // End while loop
echo '</select>'; // End select
|
Should get you somewhere close. I don't have time to install etc... just going by what you posted.
EDIT**
Whoops... sorry Palbin, you got me again.  |
_________________ Money is the measurement of time - Me
"You can all go to hell…I’m going to Texas" -Davy Crockett |
|
|
 |
rebelt

|
Posted:
Tue Jun 05, 2012 1:58 am |
|
Changed the action to
Code:action="modules.php?name='.$module_name.'&op=AddAuthors&func=AddAuthor&teamid='.$teamid.'&teamname='.$teamname.'">'
. '<select name="addauthor">';
|
and it worked.
Thanks again Palbin. |
|
|
|
 |
rebelt

|
Posted:
Thu Aug 09, 2012 3:03 am |
|
Hi guys,
This is the file for adding players. Team managers who are logged in are getting the error message. If user is also logged in as admin then players can be added.
Code:<?php
if(!defined('LEAGUE')) die('Direct access not allowed');
$stop = 0;
global $db, $module_name, $stop;
addCSSToHead('modules/'.$module_name.'/style.css', 'file');
include_once 'header.php';
OpenTable();
include_once 'modules/'.$module_name.'/public/menu.php';
CloseTable();
OpenTable();
// TERMINATE IF NOT REG USER
if(!is_user($user)|| !is_admin($admin)) {
echo '<div class="error">Sorry, you need to be a registered user to use this area of the site.</div>';
CloseTable();
include_once 'footer.php';
exit;
}
if(!isset($func)) $func = '';
if($func == 'RemPlayer'){
RemPlayer($playersplayername, $tid, $teamname);
}
$username = getusername($user);
if (!(isauthorised($teamid, $username))){
echo '<div class="validation">Not authorised!</div>';
CloseTable();
include_once 'footer.php';
exit;
}
//if(isset($_POST)) print_r($_POST);
if(isset($_POST) && $_POST['submit'] == 'Add Players'){
$teamid = intval($_POST['teamid']);
$teamname = strip_tags($_POST['teamname']);
// Count existing players
$playerresult = $db->sql_query("SELECT COUNT(*) FROM ca_league_team_players
WHERE players_teamid='$teamid'");
$playercount = $db->sql_fetchrow($playerresult);
$y = $playercount[0];
$x = $y+1;
$tomorrow = date("Y-m-d", strtotime("tomorrow"));
while($x<21){
//$thisplayer=str_replace ( ".", " ", ${"player".$x});
//$thisplayer=ucwords(strtolower($thisplayer));
//$thisplayer=ucwords(strtolower(${"player".$x}));
$thisplayer = ucwords(strtolower(str_replace("."," ",${"player".$x})));
### Write player records
if ($thisplayer!=''){
// $y++;
$result = $db->sql_query("INSERT INTO ca_league_team_players
VALUES ('$NULL', '$teamid', '$thisplayer', '$tomorrow')");
if (!$result) {
die('Could not write record: ' . mysql_error());
} else {
echo '<div class="info">Records updated: '.$thisplayer.' added</div>';
}
}
$x++;
}
CloseTable();
include_once 'footer.php';
exit;
}
// RENDER FORM
echo '<div class="info"><strong>Player names entered here CANNOT be changed.
If you do not know the exact name of some of your team members do not enter them.
You can come back to this page at any time and add more members to your team without penalty.</strong></div>';
echo '<form action="modules.php?name='.$module_name.'&op=AddPlayers" method="post">
<fieldset><legend>Add Players</legend>
<input type="hidden" name="teamid" value="'.$teamid.'" />
<label style="width:100px; display:block; float:left;" for="teamname2">Team Name: </label>
<input type="text" name="teamname2" value="'.$teamname.'" disabled />
<input type="hidden" name="teamname" value="'.$teamname.'" />
<input type="hidden" name="user" value="'.$username.'" /><br /><br />';
echo '<div class="info"><strong>Players added now will only be elligible to play in games from tomorrow.</strong><br />
Please enter First and Last names. Not just initial (e.g. John Smith not J.Smith)</div>';
# Read existing players in
$x = 1;
$result = $db->sql_query("SELECT players_playerid, players_playername, players_playerstartdate
FROM ca_league_team_players WHERE players_teamid='$teamid' ORDER BY players_playerid");
while (list($playersplayerid, $playersplayername, $playersplayerstartdate) = $db->sql_fetchrow($result)){
echo '<label style="width:75px; display:block; float:left;" for="fixedplayer'.$x.'">Player '.$x.': </label>
<input type="text" name="fixedplayer'.$x.'" size="30" value="'.$playersplayername.'" disabled />';
if ($x == 1){
echo ' (Captain)';
} else {
echo '<a href="modules.php?name='.$module_name.'&op=AddPlayers&func=RemPlayer&playersplayername='.$playersplayername.'&tid='.$teamid.'&teamname='.$teamname.'"> Remove Player</a>';
}
echo '<br /><br />';
$x++;
}
while ($x<21){
echo '<label style="width:75px; display:block; float:left;" for="player'.$x.'">Player '.$x.': </label><input type="text" name="player'.$x.'" size="30" value="">';
if ($x==1){
echo ' (Captain)';
}
echo '<br /><br />';
$x++;
}
echo '<input type="submit" class="button" name="submit" value="Add Players" />
</fieldset></form>';
echo '<div style="text-align:right;">© <a href="http://www.code-authors.com" target="_blank" title="Code Authors">Code Authors</a></div>';
CloseTable();
include_once 'footer.php';
// FUNCTIONS
### Get Username
function getusername($user){
$user2 = base64_decode($user);
$user2 = addslashes($user2);
$user2 = explode(":", $user2);
return $user2[1];
}
function RemPlayer($playersplayername, $tid, $teamname){
global $db, $module_name, $teamname;
$query ='DELETE FROM ca_league_team_players WHERE players_teamid = \''.$tid.'\' AND players_playername = \''.$playersplayername.'\'';
$db->sql_query($query);
header('Location: modules.php?name=' . $module_name . '&op=AddPlayers&teamid='.$tid.'&teamname='.$teamname.'');
}
function isauthorised($teamid, $username){
global $db;
$result = $db->sql_query("SELECT authorisation_user
FROM ca_league_team_authorisation WHERE authorisation_teamid='$teamid'");
while (list($authorisation_user) = $db->sql_fetchrow($result)){
if ($authorisation_user == $username){
return true;
}
}
return false;
}
|
Anyone see anything wrong here please? |
|
|
|
 |
rebelt

|
Posted:
Fri Aug 10, 2012 3:59 am |
|
Using trial and error I changed
Code:if(!is_user($user)|| !is_admin($admin))
|
to
and the user can add players.
How would I get both user and admin to work? |
|
|
|
 |
killing-hours

|
Posted:
Fri Aug 10, 2012 8:46 pm |
|
Code:if(!is_user($user) || !is_admin($admin))
|
see if that makes any difference. |
|
|
|
 |
nuken

|
Posted:
Sat Aug 11, 2012 6:21 am |
|
Make sure you have $admin and $user in your globals. |
|
|
|
 |
|