Author |
Message |
rebelt
Worker


Joined: May 07, 2006
Posts: 172
|
Posted:
Sun Jun 06, 2010 1:26 pm |
|
I would like to change two scripts that were written back in 2005 into modules.
One adds teams and players while the other adds results
Don't know how simple or difficult it would be.
Results can be seen Only registered users can see links on this board! Get registered or login!
Teams can be seen Only registered users can see links on this board! Get registered or login!
Or could I do it myself?
Any more info needed please let me know. |
|
|
|
 |
Palbin
Site Admin

Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Sun Jun 06, 2010 3:24 pm |
|
Just from looking at the pages it looks like it wouldn't be to bad, but no one is going to have much of an idea until they see the code. |
_________________ "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:
Sun Jun 06, 2010 5:07 pm |
|
That's a good point.
Results Script
Code:<?PHP
if (!isset($mainfile)) { include("mainfile.php"); }
###
### Main Page (would this be index.php)
###
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 (would this be datelist.php)
###
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>";
}
// The below line referring to commentary and SMS needs to be removed but When I tried I got a blank page.
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 (would this be scoresbydate.php)
###
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 (would this be resultform.php)
###
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://rebelt.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 this 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://rebelt.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://rebelt.westonpoolleague.org.uk/leagueresult.php?op=makelive&id=$this_match&validate=$email2\">click here</a>
To delete this result please <a href=\"http://rebelt.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@rebelt.westonpoolleague.org.uk");
####
}
else
{
###Normal email
mail("$email", "Weston Pool League Result Verification", "The following information was submitted to http://rebelt.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://rebelt.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://rebelt.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: 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: $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@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 RebelT
mail("webmaster@rebelt.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@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
###
### Would this now be index.php in modulename/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
###
### admin file 2?
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@rebelt.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@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 ( anotherfile.php in modules/modulename
###
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 Leave in first index.php
###
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;
}
?>
|
|
|
|
|
 |
rebelt

|
Posted:
Sun Jun 06, 2010 5:14 pm |
|
Sorry must be a limit
The teams script
Code:<?PHP
// includes the mainfile functions and the header junk
if (!isset($mainfile)) { include("mainfile.php"); }
### Main Page
### Main Page (would now be index.php)
### 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 (would now be teams.php)
### 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 (would now be showmyteam.php)
### 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://rebelt.westonpoolleague.org.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 (would now be venues.php)
### 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 (would now be showteam.php)
### 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://rebelt.westonpoolleague.org.uk/maintenance.php?op=CreateTeam&step=AddPlayers&teamid=$teamid&teamname=$teamname\">add players</a> | <a href=\"http://rebelt.westonpoolleague.org.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname\">add authors</a> | <a href=\"http://rebelt.westonpoolleague.org.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 (would now be showvenue.php)
### 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 (would now be venselect.php)
### 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 "<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 (would now be vensubmit.php)
### 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://rebelt.westonpoolleague.org.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 (would now be venselected.php)
### 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 (would now be teamname.php)
### 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://rebelt.westonpoolleague.org.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 (would now be addplayers.php)
### 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 (would now be subplayers.php)
### 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://rebelt.westonpoolleague.org.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 (would now be authors.php)
### 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 nuke_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 (would now be subauthor.php)
### 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://rebelt.westonpoolleague.org.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 (would now be finished.php)
### Finished
function finished($teamid) {
include ('header.php');
maintheader();
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=ShowTeam&teamid=$teamid";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
###
### List All Records In Admin (would now be admin/index.php)
###
function listrecords($user)
{
include ('header.php');
global $admin;
maintheader();
# teams
$result = mysql_query("select team_id, team_venue_id, team_name, team_email, team_telephone, team_alternate_telephone, team_name_old, division, division_old from team_names2 order by team_id");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
echo "<font size=4><B>Teams</b></font size=4><BR><BR>";
echo "<table>";
while (list($teamid, $teamvenueid, $teamname, $teamemail, $teamtelephone, $teamalternatetelephone, $teamnameold, $division, $divisionold) = mysql_fetch_row($result))
{
echo "<tr><td colspan=1 align=center><font size=4>$teamid</td><td>$teamvenueid</td><td>$teamname</td><td>$teamemail</td><td>$teamtelephone</td><td>$teamalternatetelephone</td><td>$teamnameold</td><td>$division</td><td>$divisionold</td><TD><a href=\"?op=Admin&step=AdminDelete&id=$teamid\">delete</a></font size=4></td></tr>";
}
echo "</table><BR><BR>";
mysql_free_result($result);
# authority
$result = mysql_query("select authorisation_teamid, authorisation_user from team_authorisation order by authorisation_teamid");
echo "<font size=4><B>Authorities</b></font size=4>";
echo "<table>";
while (list($authorisationteamid, $authorisationuser) = mysql_fetch_row($result))
{
echo "<tr><td colspan=1 align=center><font size=4>$authorisationteamid</td><td>$authorisationuser</font size=4></td></tr>";
}
echo "</table><BR><BR>";
mysql_free_result($result);
# players
$result = mysql_query("select players_playerid, players_teamid, players_playername, players_playerstartdate from team_players order by players_teamid, players_playerid");
echo "<font size=4><B>Players</b></font size=4>";
echo "<table>";
while (list($playersplayerid, $playersteamid, $playersplayername, $playersplayerstartdate) = mysql_fetch_row($result))
{
echo "<tr><td colspan=1 align=center><font size=4>$playersteamid</td><td>$playersplayerid</td><td>$playersplayername</td><td>$playersplayerstartdate</font size=4></td><TD> <a href=\"?op=Admin&step=RemovePlayer&playerid=$playersplayerid&teamid=$playersteamid\"> delete</a></font size=4></td></tr>";
}
echo "</table><BR><BR>";
mysql_free_result($result);
# venues
$result = mysql_query("select venue_id, venue_name, venue_oldname, venue_address, venue_town, venue_postcode, venue_telephone from team_venues order by venue_id");
echo "<font size=4><B>Venues</b></font size=4>";
echo "<table>";
while (list($venueid, $venuename, $venueoldname, $venueaddress, $venuetown, $venuepostcode, $venuetelephone) = mysql_fetch_row($result))
{
echo "<tr><td colspan=1 align=center><font size=4>$venueid</td><td>$venuename</td><td>$venueoldname</td><td>$venueaddress</td><td>$venuetown</td><td>$venuepostcode</td><td>$venuetelephone</td><TD><a href=\"?op=Admin&step=RemoveVenue&venueid=$venueid\">delete</a></font size=4></td></tr>";
}
echo "</table><BR><BR>";
mysql_free_result($result);
include ("footer.php");
}
###
### Admin Delete (would now be admin/delete.php)
###
function admin_delete_team($id)
{
mysql_query("delete from team_names2 where team_id='$id'");
mysql_query("delete from team_players where players_teamid='$id'");
mysql_query("delete from team_authorisation where authorisation_teamid='$id'");
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin&step=List";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
###
### Delete Authors
###
function removeauthor($teamid, $teamname, $user, $authorid)
{
### registered user or email address
$username=getusername($user);
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
if ($authorid==$username){echo "You cannot remove yourself from the team."; exit;}
mysql_query("delete from team_authorisation where authorisation_teamid='$teamid' AND authorisation_user='$authorid'");
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
###
### Delete Venues
###
function removevenue($venueid, $user)
{
### registered user or email address
$username=getusername($user);
if ($username=="LeeJS" | $username=="RebelT")
{
mysql_query("delete from team_venues where venue_id='$venueid'");
}
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin&step=List";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
###
### Delete Player
###
function removeplayer($playerid, $teamid, $user)
{
### registered user or email address
$username=getusername($user);
if ($username=="2wheels" | $username=="RebelT")
{
mysql_query("delete from team_players where players_playerid='$playerid' and players_teamid='$teamid'");
# echo "delete from team_players where players_playerid='$playerid' and players_teamid='$teamid'<BR>";
## Now sort through whole team and ensure IDs are contiguous
##
##read in number of players
$playerresult = mysql_query("select COUNT(*) from team_players where players_teamid='$teamid'");
$playercount=mysql_fetch_array($playerresult);
$y= $playercount[0];
$thisplayerid=1;
# Read in all players details
$result = mysql_query("select players_playerid from team_players where players_teamid=$teamid order by players_playerid");
# for loop reading each one in turn
while (list($playersplayerid) = mysql_fetch_row($result))
{
# Compare player number against loop number
#if different update with loop value
#echo "playersplayerid=$playersplayerid | thisplayerid=$thisplayerid<BR>";
if ($playersplayerid!=$thisplayerid)
{
mysql_query("update team_players set players_playerid='$thisplayerid' where players_playerid='$playersplayerid' and players_teamid='$teamid'");
## echo "update team_players set players_playerid='$thisplayerid' where players_playerid='$playersplayerid' and players_teamid='$teamid'<BR>";
}
##else{ echo "No update<BR>"; }
$thisplayerid=$thisplayerid+1;
##end if
}
}
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin&step=List";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
### Submitted Team Allocations
### Submitted Team Allocations
### Submitted Team Allocations
function submittedteamallocations($user, $allchanges)
{
$username=getusername($user);
if ($username=="LeeJS" | $username=="RebelT")
{
$pieces = explode("|", $allchanges);
$ii = count($pieces)-1;
for($i=0;$i<$ii;$i++)
{
$thisvalue = explode("=", $pieces[$i]);
mysql_query("update team_names2 set division='$thisvalue[1]' where team_id='$thisvalue[0]'");
# echo "update team_names2 set division='$thisvalue[1]' where team_id='$thisvalue[0]'<BR>";
}
# echo urlforward("http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin");
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
}
###
### Summarise Team Members (would now be admin/summary.php)
###
function summarise($user)
{
include ('header.php');
global $admin;
maintheader();
# player summary
$result = mysql_query("select team_id, team_venue_id, team_name, players_teamid, players_playername from team_names2, team_players where team_id=players_teamid order by team_name, players_playername");
if (!$result) {
die('Could not read record: ' . mysql_error());
}
echo "<h3><B>Player Summary data</b></h3>";
echo "<table>";
while (list($teamid, $teamvenueid, $teamname, $teamid2, $playername) = mysql_fetch_row($result))
{
if ($teamname!=$oldteamname)
{
if ($teamcount) echo "<tr><td>Total</td><td><B>$teamcount</B></td></tr><tr><td> </td><td> </td></tr>";
echo "<tr><td><B>$teamname</b></td>";
$teamcount=0;
}
else
{
echo "<tr><td> </td>";
}
echo "<td>$playername</td></tr>";
$oldteamname=$teamname;
$teamcount=$teamcount+1;
$playercount=$playercount+1;
}
echo "<tr><td>Total</td><td><B>$teamcount</B></td></tr><tr><td> </td><td> </td></tr>";
echo "<tr><td><B>Total Number Of Players:</b></td><td><B>$playercount</b></td>";
echo "</table><BR><BR>";
mysql_free_result($result);
include ("footer.php");
}
### Admin Options
### Admin Options (would now be admin/options.php)
### Admin Options
function adminoptions($user) {
include ('header.php');
maintheader();
$username=getusername($user);
if ($username=="LeeJS" | $username=="RebelT")
{
echo "<center><H3><B>Pool Team Maintenance Administration Options</b></h3></center>";
//echo "<center><B>This is a beta service for adding and updating Weston Pool League team names and members. You are now in the Administration section.</center>";
echo "<BR><table width=100%>";
// These links will obviously need changing
echo "<a href=\"?op=Admin&step=List\">List All Team Data</a><BR><BR>
<a href=\"?op=Admin&step=Allocate\">Allocate Divisions</a><BR><BR>
<a href=\"?op=Admin&step=Summarise\">Summarise Team Members By Team</a><BR><BR>";
echo "</table>";
}
else
{
echo urlforward("http://rebelt.westonpoolleague.org.uk/maintenance.php");
# echo ("nope");
}
maintfooter();
include ('footer.php');
}
### Allocate
### Allocate (would now be admin/allocate.php)
### Allocate
function allocate($user) {
include ('header.php');
maintheader();
$result = mysql_query("select team_id, team_name, division, division_old from team_names2 order by division_old, team_name");
echo "<SCRIPT LANGUAGE=\"JavaScript\">\n
function Validate(thisForm)\n
{\n
var result = \"\";
var thisvar = \"\";
var formElements = thisForm.elements; \n
for (i=0; i<formElements.length; i++) { \n
thisvar=formElements[i].name; \n
if (thisvar.substring(0,4)==\"team\")\n
{\n
result += thisvar.substring(4,thisvar.length)+\"=\"+formElements[i].value+\"|\";\n
}\n
}\n
thisForm.allchanges.value=result;
return true;
}\n
</SCRIPT>";
$lastdivision="A";
echo "<h3><B>Team Allocation Page</b></h3><BR><FORM ONSUBMIT=\"return Validate(this)\" ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"Allocate\"><table>";
while (list($teamid, $teamname, $division, $divisionold) = mysql_fetch_row($result))
{
if ($divisionold!=$lastdivision)
{
if ($divisionold=='0')
{
echo "<tr><td colspan=2><B>New Teams</b></td></tr>";
}
else
{
echo "<tr><td colspan=2><B>Old Division $divisionold Teams</b></td></tr>";
}
}
echo "<tr><td><a href=\"http://rebelt.westonpoolleague.org.uk/maintenance.php?op=ShowTeam&teamid=$teamid\" target=\"_blank\">$teamname</a></td><td><input type=text NAME=\"team$teamid\" size=1 value=\"$division\"></td></tr>";
$lastdivision=$divisionold;
}
echo "</table>";
echo "<input type=hidden name=\"allchanges\"><input type=hidden name=\"op\" value=\"Admin\">
<input type=hidden name=\"step\" value=\"SubmittedTeamAllocations\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Allocate Team Divisions\"></form>";
maintfooter();
mysql_free_result($result);
include ('footer.php');
}
// A bit lost from here on.
###
### 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://rebelt.westonpoolleague.org.uk/maintenance.php\">Home</a></td><td align=center><a href=\"http://rebelt.westonpoolleague.org.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;
}
?>
|
|
|
|
|
 |
rebelt

|
Posted:
Sun Jun 13, 2010 3:46 pm |
|
Gonna have a go at this but would like to ask a couple of questions first.
As I understand it, I will need an index.php file in modules/Leagueresult for the public part and leagueresult.php, in admin/modules for the admin part.
Would links change from
Code:<a href=\"leagueresult.php?op=showdate&date=$matchdate\">
|
to
Code:<a href=\"modules.php?name=Leagueresult?op=showdate&date=$matchdate\">
|
Obviously I would like the simplest way of splitting the two files above into public and admin.  |
|
|
|
 |
rebelt

|
Posted:
Wed Jun 23, 2010 4:08 pm |
|
Bump.
 |
|
|
|
 |
Palbin

|
Posted:
Wed Jun 23, 2010 4:22 pm |
|
Yes on the links. If there is a separate admin for both modules I would put them in modules/*modulename*/admin. If the admin is for both modules then you are stuck doing the /admin/modules/ as you suggest. |
|
|
|
 |
rebelt

|
Posted:
Sun Jun 27, 2010 5:45 am |
|
Thanks. Yes the admin is separate. Haven't worked out how to access modules/*modulename*/admin yet though I'll have a look at the howto once the public part is done
Changed all the mysql_query to $db->sql_query and mysql_fetch_row to $db->sql_fetchrow.
Most things seem to work but am getting the "Sorry, that module file was not found." error on this link. Code:modules.php?name=Leagueresult?op=showdate&date=$matchdate
|
Get it clicking the links on the main page
http://rebelt.westonpoolleague.org.uk/modules.php?name=Leagueresult
Tried Code:$ACCEPT_FILE['modules.php?name=Leagueresult?op=showdate&date=$matchdate'] = 'modules.php?name=Leagueresult?op=showdate&date=$matchdate';
|
Tried searching too but haven't found any other answers.
Ideas, pointers please. |
|
|
|
 |
spasticdonkey
RavenNuke(tm) Development Team

Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA
|
Posted:
Sun Jun 27, 2010 6:47 am |
|
Looks like it's not inserting the value for $matchdate, try:
Code:$ACCEPT_FILE['modules.php?name=Leagueresult?op=showdate&date='.$matchdate.''] = 'modules.php?name=Leagueresult?op=showdate&date='.$matchdate.'';
|
|
|
|
|
 |
rebelt

|
Posted:
Sun Jun 27, 2010 4:50 pm |
|
|
|
 |
Palbin

|
Posted:
Sun Jun 27, 2010 5:52 pm |
|
Code:$ACCEPT_FILE['modules.php?name=Leagueresult&op=showdate&date=$matchdate'] = 'modules.php?name=Leagueresult&op=showdate&date=$matchdate';
|
In your links you can only have one ? all the ones after have to be &. |
|
|
|
 |
rebelt

|
Posted:
Mon Jun 28, 2010 1:56 am |
|
Had an idea it was something simple.
Thank you.
Now for the admin side. |
|
|
|
 |
rebelt

|
Posted:
Mon Jul 19, 2010 3:03 am |
|
rebelt wrote: |
The teams script
Code:<?PHP
// includes the mainfile functions and the header junk
if (!isset($mainfile)) { include("mainfile.php"); }
### 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://rebelt.westonpoolleague.org.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://rebelt.westonpoolleague.org.uk/maintenance.php?op=CreateTeam&step=AddPlayers&teamid=$teamid&teamname=$teamname\">add players</a> | <a href=\"http://rebelt.westonpoolleague.org.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname\">add authors</a> | <a href=\"http://rebelt.westonpoolleague.org.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 "<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://rebelt.westonpoolleague.org.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://rebelt.westonpoolleague.org.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://rebelt.westonpoolleague.org.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 nuke_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://rebelt.westonpoolleague.org.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://rebelt.westonpoolleague.org.uk/maintenance.php?op=ShowTeam&teamid=$teamid";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
maintfooter();
include ('footer.php');
}
###
### List All Records In Admin
###
function listrecords($user)
{
include ('header.php');
global $admin;
maintheader();
# teams
$result = mysql_query("select team_id, team_venue_id, team_name, team_email, team_telephone, team_alternate_telephone, team_name_old, division, division_old from team_names2 order by team_id");
if (!$result) {
die('Could not write record: ' . mysql_error());
}
echo "<font size=4><B>Teams</b></font size=4><BR><BR>";
echo "<table>";
while (list($teamid, $teamvenueid, $teamname, $teamemail, $teamtelephone, $teamalternatetelephone, $teamnameold, $division, $divisionold) = mysql_fetch_row($result))
{
echo "<tr><td colspan=1 align=center><font size=4>$teamid</td><td>$teamvenueid</td><td>$teamname</td><td>$teamemail</td><td>$teamtelephone</td><td>$teamalternatetelephone</td><td>$teamnameold</td><td>$division</td><td>$divisionold</td><TD><a href=\"?op=Admin&step=AdminDelete&id=$teamid\">delete</a></font size=4></td></tr>";
}
echo "</table><BR><BR>";
mysql_free_result($result);
# authority
$result = mysql_query("select authorisation_teamid, authorisation_user from team_authorisation order by authorisation_teamid");
echo "<font size=4><B>Authorities</b></font size=4>";
echo "<table>";
while (list($authorisationteamid, $authorisationuser) = mysql_fetch_row($result))
{
echo "<tr><td colspan=1 align=center><font size=4>$authorisationteamid</td><td>$authorisationuser</font size=4></td></tr>";
}
echo "</table><BR><BR>";
mysql_free_result($result);
# players
$result = mysql_query("select players_playerid, players_teamid, players_playername, players_playerstartdate from team_players order by players_teamid, players_playerid");
echo "<font size=4><B>Players</b></font size=4>";
echo "<table>";
while (list($playersplayerid, $playersteamid, $playersplayername, $playersplayerstartdate) = mysql_fetch_row($result))
{
echo "<tr><td colspan=1 align=center><font size=4>$playersteamid</td><td>$playersplayerid</td><td>$playersplayername</td><td>$playersplayerstartdate</font size=4></td><TD> <a href=\"?op=Admin&step=RemovePlayer&playerid=$playersplayerid&teamid=$playersteamid\"> delete</a></font size=4></td></tr>";
}
echo "</table><BR><BR>";
mysql_free_result($result);
# venues
$result = mysql_query("select venue_id, venue_name, venue_oldname, venue_address, venue_town, venue_postcode, venue_telephone from team_venues order by venue_id");
echo "<font size=4><B>Venues</b></font size=4>";
echo "<table>";
while (list($venueid, $venuename, $venueoldname, $venueaddress, $venuetown, $venuepostcode, $venuetelephone) = mysql_fetch_row($result))
{
echo "<tr><td colspan=1 align=center><font size=4>$venueid</td><td>$venuename</td><td>$venueoldname</td><td>$venueaddress</td><td>$venuetown</td><td>$venuepostcode</td><td>$venuetelephone</td><TD><a href=\"?op=Admin&step=RemoveVenue&venueid=$venueid\">delete</a></font size=4></td></tr>";
}
echo "</table><BR><BR>";
mysql_free_result($result);
include ("footer.php");
}
###
### Admin Delete
###
function admin_delete_team($id)
{
mysql_query("delete from team_names2 where team_id='$id'");
mysql_query("delete from team_players where players_teamid='$id'");
mysql_query("delete from team_authorisation where authorisation_teamid='$id'");
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin&step=List";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
###
### Delete Authors
###
function removeauthor($teamid, $teamname, $user, $authorid)
{
### registered user or email address
$username=getusername($user);
if (!(isauthorised($teamid, $username))){echo "Not authorised."; exit;}
if ($authorid==$username){echo "You cannot remove yourself from the team."; exit;}
mysql_query("delete from team_authorisation where authorisation_teamid='$teamid' AND authorisation_user='$authorid'");
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=CreateTeam&step=AddAuthors&teamid=$teamid&teamname=$teamname";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
###
### Delete Venues
###
function removevenue($venueid, $user)
{
### registered user or email address
$username=getusername($user);
if ($username=="LeeJS" | $username=="RebelT")
{
mysql_query("delete from team_venues where venue_id='$venueid'");
}
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin&step=List";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
###
### Delete Player
###
function removeplayer($playerid, $teamid, $user)
{
### registered user or email address
$username=getusername($user);
if ($username=="2wheels" | $username=="RebelT")
{
mysql_query("delete from team_players where players_playerid='$playerid' and players_teamid='$teamid'");
# echo "delete from team_players where players_playerid='$playerid' and players_teamid='$teamid'<BR>";
## Now sort through whole team and ensure IDs are contiguous
##
##read in number of players
$playerresult = mysql_query("select COUNT(*) from team_players where players_teamid='$teamid'");
$playercount=mysql_fetch_array($playerresult);
$y= $playercount[0];
$thisplayerid=1;
# Read in all players details
$result = mysql_query("select players_playerid from team_players where players_teamid=$teamid order by players_playerid");
# for loop reading each one in turn
while (list($playersplayerid) = mysql_fetch_row($result))
{
# Compare player number against loop number
#if different update with loop value
#echo "playersplayerid=$playersplayerid | thisplayerid=$thisplayerid<BR>";
if ($playersplayerid!=$thisplayerid)
{
mysql_query("update team_players set players_playerid='$thisplayerid' where players_playerid='$playersplayerid' and players_teamid='$teamid'");
## echo "update team_players set players_playerid='$thisplayerid' where players_playerid='$playersplayerid' and players_teamid='$teamid'<BR>";
}
##else{ echo "No update<BR>"; }
$thisplayerid=$thisplayerid+1;
##end if
}
}
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin&step=List";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
### Submitted Team Allocations
### Submitted Team Allocations
### Submitted Team Allocations
function submittedteamallocations($user, $allchanges)
{
$username=getusername($user);
if ($username=="LeeJS" | $username=="RebelT")
{
$pieces = explode("|", $allchanges);
$ii = count($pieces)-1;
for($i=0;$i<$ii;$i++)
{
$thisvalue = explode("=", $pieces[$i]);
mysql_query("update team_names2 set division='$thisvalue[1]' where team_id='$thisvalue[0]'");
# echo "update team_names2 set division='$thisvalue[1]' where team_id='$thisvalue[0]'<BR>";
}
# echo urlforward("http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin");
$url = "http://rebelt.westonpoolleague.org.uk/maintenance.php?op=Admin";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
}
###
### Summarise Team Members
###
function summarise($user)
{
include ('header.php');
global $admin;
maintheader();
# player summary
$result = mysql_query("select team_id, team_venue_id, team_name, players_teamid, players_playername from team_names2, team_players where team_id=players_teamid order by team_name, players_playername");
if (!$result) {
die('Could not read record: ' . mysql_error());
}
echo "<h3><B>Player Summary data</b></h3>";
echo "<table>";
while (list($teamid, $teamvenueid, $teamname, $teamid2, $playername) = mysql_fetch_row($result))
{
if ($teamname!=$oldteamname)
{
if ($teamcount) echo "<tr><td>Total</td><td><B>$teamcount</B></td></tr><tr><td> </td><td> </td></tr>";
echo "<tr><td><B>$teamname</b></td>";
$teamcount=0;
}
else
{
echo "<tr><td> </td>";
}
echo "<td>$playername</td></tr>";
$oldteamname=$teamname;
$teamcount=$teamcount+1;
$playercount=$playercount+1;
}
echo "<tr><td>Total</td><td><B>$teamcount</B></td></tr><tr><td> </td><td> </td></tr>";
echo "<tr><td><B>Total Number Of Players:</b></td><td><B>$playercount</b></td>";
echo "</table><BR><BR>";
mysql_free_result($result);
include ("footer.php");
}
### Admin Options
### Admin Options
### Admin Options
function adminoptions($user) {
include ('header.php');
maintheader();
$username=getusername($user);
if ($username=="LeeJS" | $username=="RebelT")
{
echo "<center><H3><B>Pool Team Maintenance Administration Options</b></h3></center>";
//echo "<center><B>This is a beta service for adding and updating Weston Pool League team names and members. You are now in the Administration section.</center>";
echo "<BR><table width=100%>";
// These links will obviously need changing
echo "<a href=\"?op=Admin&step=List\">List All Team Data</a><BR><BR>
<a href=\"?op=Admin&step=Allocate\">Allocate Divisions</a><BR><BR>
<a href=\"?op=Admin&step=Summarise\">Summarise Team Members By Team</a><BR><BR>";
echo "</table>";
}
else
{
echo urlforward("http://rebelt.westonpoolleague.org.uk/maintenance.php");
# echo ("nope");
}
maintfooter();
include ('footer.php');
}
### Allocate
### Allocate
### Allocate
function allocate($user) {
include ('header.php');
maintheader();
$result = mysql_query("select team_id, team_name, division, division_old from team_names2 order by division_old, team_name");
echo "<SCRIPT LANGUAGE=\"JavaScript\">\n
function Validate(thisForm)\n
{\n
var result = \"\";
var thisvar = \"\";
var formElements = thisForm.elements; \n
for (i=0; i<formElements.length; i++) { \n
thisvar=formElements[i].name; \n
if (thisvar.substring(0,4)==\"team\")\n
{\n
result += thisvar.substring(4,thisvar.length)+\"=\"+formElements[i].value+\"|\";\n
}\n
}\n
thisForm.allchanges.value=result;
return true;
}\n
</SCRIPT>";
$lastdivision="A";
echo "<h3><B>Team Allocation Page</b></h3><BR><FORM ONSUBMIT=\"return Validate(this)\" ACTION=\"maintenance.php\" METHOD=\"POST\" NAME=\"Allocate\"><table>";
while (list($teamid, $teamname, $division, $divisionold) = mysql_fetch_row($result))
{
if ($divisionold!=$lastdivision)
{
if ($divisionold=='0')
{
echo "<tr><td colspan=2><B>New Teams</b></td></tr>";
}
else
{
echo "<tr><td colspan=2><B>Old Division $divisionold Teams</b></td></tr>";
}
}
echo "<tr><td><a href=\"http://rebelt.westonpoolleague.org.uk/maintenance.php?op=ShowTeam&teamid=$teamid\" target=\"_blank\">$teamname</a></td><td><input type=text NAME=\"team$teamid\" size=1 value=\"$division\"></td></tr>";
$lastdivision=$divisionold;
}
echo "</table>";
echo "<input type=hidden name=\"allchanges\"><input type=hidden name=\"op\" value=\"Admin\">
<input type=hidden name=\"step\" value=\"SubmittedTeamAllocations\">
<BR clear=all><INPUT TYPE=\"submit\" value=\"Allocate Team Divisions\"></form>";
maintfooter();
mysql_free_result($result);
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://rebelt.westonpoolleague.org.uk/maintenance.php\">Home</a></td><td align=center><a href=\"http://rebelt.westonpoolleague.org.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;
}
?>
| |
Is there anyone who could please take this on.  |
|
|
|
 |
rebelt

|
Posted:
Tue Jul 27, 2010 3:29 am |
|
Last bump  |
|
|
|
 |
rebelt

|
Posted:
Sun Aug 08, 2010 8:02 am |
|
Just got round to looking at this again.
Public side of this seems to be working fine.
Really stuck on the admin side. can't get around.
Quote: | Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server. |
modules/Leagueresult/admin
index.php
Code:<?php
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
$querystr = "SELECT radminsuper, admlanguage FROM "
.$prefix."_authors where aid='$aid'";
$result = $db->sql_query($querystr) or die ("invalied query");
list($radminsuper) = $db->sql_fetchrow($result);
if ($radminsuper==1) {
} else {
echo "Access Denied";
}
###
### List Results In Admin
###
function listresults()
{
include ('header.php');
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>";
mysql_free_result($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>";
mysql_free_result($result);
include ("footer.php");
}
###
### Admin Delete
###
function admin_delete_result($id, $validate)
{
$email = str_replace(',', '.', $validate);
$db->sql_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)
{
$db->sql_query("update team_scores set status='1' where match_id='$id'");
if (mysql_affected_rows()==0)
{
dispmessage('nosuchmatchID', $id);
}
else
{
dispmessage('authorised', $id);
}
}
*/
switch($_REQUEST['op']) {
// case "adminmakelive":
// admin_makelive_result($_REQUEST['id']);
// break;
case "admindelete":
admin_delete_result($_REQUEST['id'], $_REQUEST['validate']);
break;
}
die();
?>
|
case.php
Code:<?php
if (!defined('ADMIN_FILE')) die ('Access Denied');
$module_name = 'Leagueresult';
switch($_REQUEST['op']) {
case 'adminmakelive':
case 'admindelete':
include 'modules/'.$module_name.'/admin/index.php';
break;
}
?>
|
links.php
Code:<?php
if ( !defined('ADMIN_FILE') ) die('Illegal File Access');
global $admin_file;
adminmenu($admin_file.'.php?op=adminmakelive', 'Live Results', 'results.gif');
?>
|
Could someone please take a look and point out where it's going wrong[/img] |
|
|
|
 |
nuken
RavenNuke(tm) Development Team

Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina
|
Posted:
Sun Aug 08, 2010 8:37 am |
|
Have you checked the permissions of the folder and files inside it? I don't see any thing in the script that would give you that warning. |
_________________ Only registered users can see links on this board! Get registered or login! |
|
|
 |
rebelt

|
Posted:
Sun Aug 08, 2010 11:49 am |
|
That error is on localhost
On a test site I get
Quote: | You do not have permission to access the requested file
Hint: The server understood the request, but is refusing to fulfill it |
Permissions were 755 so I changed them to 777 but still no change.
Doesn't happen on any other module. |
|
|
|
 |
Palbin

|
Posted:
Sun Aug 08, 2010 12:02 pm |
|
You checked the permissions on all files and folders? This is not a coding problem, but a problem with accessing a file on the server. |
|
|
|
 |
rebelt

|
Posted:
Sun Aug 08, 2010 2:52 pm |
|
Yes.
Index, case and links in the modulename/admin folder are 777.
As is the folder. |
|
|
|
 |
nuken

|
Posted:
Sun Aug 08, 2010 3:46 pm |
|
the files should be files 644 and folders 744. If that does not work, change the folders to 755 but leave the files at 644 |
|
|
|
 |
rebelt

|
Posted:
Sun Aug 08, 2010 3:57 pm |
|
No Change.
I don't understand why I get this error on localhost though? Didn't think a local setup needed permissions. |
|
|
|
 |
nuken

|
Posted:
Sun Aug 08, 2010 4:08 pm |
|
Is it a localhost on windows or linux? |
|
|
|
 |
rebelt

|
Posted:
Sun Aug 08, 2010 4:10 pm |
|
|
|
 |
nuken

|
Posted:
Sun Aug 08, 2010 5:04 pm |
|
see if the files are read only by right clicking it and selecting properties. If read only is checked, un check it and that should fix you up. |
|
|
|
 |
rebelt

|
Posted:
Sun Aug 08, 2010 5:11 pm |
|
All unchecked in windows localhost.
Permissions fine in Linux server.
Nothing in the script to cause the error.
Confusion reigns. |
|
|
|
 |
|