Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/README_3.0.txt
GolfstatsPHP 3.0
=================

I had some complaints that the readme wasn’t so helpful for the last version. Since I didn’t make a lot of changes to warrant a version 3.0, I guess a more respectable manual could be useful.

I added some graphics here but they are all elementary stuff, I just use the freehand pen tool to illustrate. Hey as long as you understand, I can not bother trying to learn how to use Photoshop and stick to my alt-Printscreen-draw-arrow-draw-circle super illustration.

Maybe version 4 will have better manual graphics.

Note: For users upgrading from version 2.0 to 3.0, Appendix 1 at the bottom gives you a runthrough to migrate the stuff. I like Appendices. They sound important.

INSTALLATION
============

Database Installation
=====================
I use PHPmyadmin to administer my database. Create your database with username/password. I won’t go through how to set up mysql and apache. I’m afraid this version is not packaged with that, so you still need to have a little tech head to sort that out. Most service providers should have some GUI or something to easily set up a database.

Anyhoos, once done with the database, either using PHPMyadmin or CLI or any of the GUI management provided, run the SQL found in sqltables_3.0.txt.



Click GO and hopefully everything runs dandy and out comes



Note that clubs and stableford are populated. Please check it and edit it if you want to.

You’re set and ready!


Files Installation
===================
Unzip/untar the file to the directory you want. I suggest like http://<yoursite>/golf/ or something but its up to you.

There are a few steps to complete first before you are good to go.


Step 1: Env.php
===============
Modify env.php

$tourleaderid="root"; 

Your tourleader is the dude in charge of the tour. Duh. Usually the same guy as root but sometimes you want to give him as someone else. He’s actually a normal user, the only thing is he gets to have his face under Ramblings of the Tourleader. So he’s got no special powers. Management is still out of reach for this guy. He obviously needs to be a created user. You can even do away with this and modify your front page completely.

$rootid="root";

$rootid is the guy in charge of everything. Sorry, I haven’t figured out having multiple roots. Maybe next version? You can obviously rename the rootid to your name or whatever.

$guestid="guest";

$guestid is an idea to give a read only access to users to have a look at stats but don’t screw things up. Again, next version. 

$measure="Meters";
if ($measure=="Yards") {
$measureshort="y";
} else {
$measureshort="m";
}

$measure is whether Meters or Yards. Basically it’s just whether in the stats you see y or m. There’s no auto conversion and I haven’t really figured out how to have courses with yards and meters together. I simply convert to metric system with a hand calculator. Haha. Yeah, maybe next version.



Step 2: Create your dbase connection
====================================
Modify the dbasecon.inc.php.

<?
$db=@mysql_connect("localhost", "username", "password") or header("Location:login.php?xc=3112");
mysql_select_db("database",$db);
?>

This is the password to your DATABASE.

Step 3: Create your root!
=========================
Head over to http://<yoursite>/signup.php and you can start creating your root user (as set in env.php).

Go ahead and create your tourleader as well if you want.

Might be a good time to put their images as well under the images directory. The name convention here is mug_<userid>.jpg.

By default, there are two ugly mugs there, one of it is mine.

The tourleader is featured on the front page.



Step 4: Your Images
===================
Aside from that the title image is named title.jpg (wow!). You can modify it if you want.

Another thing is the style.css file. You likely want to change that for your site looks. I’m colour blind by the way so the default colours can look like puke and I wouldn’t know.

Also, I developed the table borders using css statements like border-top:3px solid black etc.

For some reason, I.E doesn’t recognize it. I.E sucks. Not my fault =). You can change it if you wish. The code or the browser that is….

Step 5: Your directories and Clean Up
=====================================

While you’re at it, why don’t you change the directory permissions of tempcharts to full read-write. You need this directory for users to create temporary graphs and charts when you query hole statistics. If you’re uncomfortable with that, you can edit the holecharts/holestats file and choose another directory.

You also want to make sure you know where your sessions are written to. Usually it could be /tmp. Or you can find out by using http://<sitename>/phpinfo.php. You can see it under session.save_path. You need to make sure you can write to it.

While you’re at it, make sure register_globals = On for variables to be able to pass properly. If you prefer to be more secure, then I'm afraid there would be a lot of coding changes in terms of variable calling. I just run golf statistics, not really classified national security information :)

Also, auth.inc.php and sesion.inc.php deals with the cookies and sessions. Please ensure that your broswer accepts cookies for the app to work.

For this app to work, PLEASE ENABLE COOKIES. For I.E. users: Tools --> Internet Options --> Privacy Tab --> Low
For Firefox, Tools --> Options --> Privacy --> Cookies -->Allow sites to set cookies


GET STARTED!
============

OK! If all is done, you are going to see this.



Area A and Area B are stated in login.php. So go ahead and modify it. Or leave it. It’s up to you!

If you have signed up, you can login now with the root id.

You can put a html link to link users to signup.php if you want. Actually users can signup anytime if they know the name of the signup page. I haven’t put a mechanism for the root to allow/disallow signups not invited. I know….next version?!


If everthing is ok so far, you will get the following page




This is the main menu. Now, you can CHANGE how the main menu is. Really you can.

But I’d advise against changing too much unless you know what you’re doing. My hacking sucks (hey I’m a golfer after all), but I’ve separated the main menu to five PARTS, which I’ve attempted to identify in the code. You can modify each part but you might want to back up the file first, because my if { } are all over the place.

The top menu is always there. If you want to alter it, you need to head over to header.php and sort it out.

Tourleader’s Ramble
The articles are numbered like so

leadramble.php?article=009

where 009 pertains to leadramble009.txt in the files directory


The money leaders section is also optional. This only pertains to tournaments. 


Here are a few steps for a quick start!

1. Add A Course
===============

Click Add/Edit Course-->Add New Course. The courses listed here are the ones added by you. Each course has an ‘owner’ so only the ‘owner’ can edit the courses. You’d think root should have ownership of all, but I again didn’t code it in. So it might be user A puts in a stupid course and root can’t modify the course. At this point root has 2 options:
a) Remove the course and all its games
b) Go to the database itself and change the ownership in the course table then modify it via the GUI
c) The third is to hit the offending User A with a 7 iron on the skull

Adding a course is pretty straightforward. I won’t be adding unnecessary screenshots to pretty up this manual, since it occurred to me it could be like 10 mb in size at the end of the day!

Short note: In NOTES, it’s actually a text box that doesn’t recognize your carriage returns and stuff. So if you’re thinking of chucking in a table or something, you’ll need to code it in HTML with all the tags like <td> and <p> and stuff. Sorry, this is really basic.

Slope rating/Course rating is optional. If you don’t have it, just put 0 in there. You can’t leave it empty, there’s a check for it.

I’ll probably use it for an auto handicap calculator for…you guess it…the next VERSION!

!!Some Notes on course naming convention!!

My advice on the Course name would be

<name>-<tees>

Such as 

My First Course – Blue Tee

Because it could be other people wants to play off the white so it becomes

My First Course – White Tee

Which would be a different course altogether since the yardage to the hole is now different.

The same way for an ID, I’d advice on a convention like

MFC01 – My First Course – Blue Tee
MFC02 – My First Course – White Tee

And so on.

Some courses have a chance to play either two of 4 available nines, so it works the same way. For instance, in my home course, there are 36 holes so I have two courses:

KRPM1 – Course 1 and 2
KRPM2 -  Course 3 and 4

Obviously it gets worse if you have Blue tees and white tees and so on. It’s up to you to decide.

Frankly for me, I put all the courses at Blue Tees Distance. I have a girl in the group that tees it up at the Red Tees, but we include her into the Blue Tee course because her tee off comex up to the same as us, so there’s the implicit handicap already given by the course itself.

As I’ve said, simplify it and do what you like.



2. Add your score card
======================

Click scorecard.

You can change your default handicap. Useful for System 36 games here. Unfortunately, you’ll need to manually count your handicap on your own first before inputting the scores. If there’s enough request, I might put in a auto handicap calculator.

You can check the tournament box to see if this is tournament. Once you mark it, the date and course id becomes marked as Tournament. So everyone else that puts in same date and same course can have an option to join the tournament. 

All it takes is one user to mark a tournament. The tournament is not CREATED yet per se (that comes later in management) but now you have games marked as tournaments. I’ll add a non tournament game now.



OK. I’ll need to break down the score card. There are a couple of columns for you to fill up.

The only mandatory column is Gr.Score. Please tell me you know what a gross score is. =)

If you’ve taken stats for your fairways hit, first click on the box next to ‘Fairway’. This means to include it in your calculation.

Then check the boxes on each hole you hit the fairway.

If you leave a putt empty, it will default to ‘na’ that means it doesn’t take it into account. If you chipped in put 0 instead. You can have mixture if you only tracked a few holes and gave up after that.

Bunker is tricky. What constitutes a save? For my group, a save is when you get out of sand and sink the damn putt. So I can score a 10 and still get a save as long as I one putt.

By default, I’ve made the program to calculate sand save as par or better. If you want it easier, just remove the && ($$gross_score<=$parhole_current) line from scorecard.php.

Next one is everyone’s favourite. Drive Distance. It takes into account all drives made on holes NOT PAR3s. So if you put a drive in Par 3, it’s ignored in calculations.

For my group, I tend to put in drives only for fairway hits. But non fairway hit drives are calculated as well, so its up to you to decide.

The last column is for future feature. As of now, a drive is a drive whether you use a pitching wedge or driver. I wanted to track individual distances with each club but didn’t get down to it.

OK, go ahead and CONFIRM.

Your scores should now appear in SCORES.

Your stats should also be in STATS.

Go back to the first page and you should be the money leader (bug) and see an empty overall ranking. Don’t worry. We’ll figure that one out later.

If you’re not happy with your score:

There is no edit function. TO edit a scorecard, just create a new one with the same date. It will write it over.

I did attempt to do a score card edit function but its a WIP. Feel free to hack scorecardedit.php if you want.

If you card is so ugly and you want to banish it from the face of this earth, try to resist and remember golf is a game of up and downs. Shooting 130 isn’t the end of the world. Its good to keep the bad scores to remind us when we improve how far we have come.

If you think what I just said is all bullshit, just click on Delete. Shame on you.

Once deleted, the stats in the front menu is still the same. You will need the management to refresh your points etc.

Note: Ranking points only appears when player has 2 or more games. This can be changed in the line if ($roundcheckexist>1) { in menu.php.

Notice also, without a scorecard, you won’t see anybody’s card or stats. So get a scorecard!!!!

Congratulations! You’ve finished the basic tutorial.


ADVANCED OPTIONS
================
Management
==========
OK, here’s where all the stuff happens.



Let’s start from the bottom.

Add ramble
==========
This is just an option to put in funny statements from players. It’s random. It uses a sequential algo. It’s very dumb. Can someone smarten it? Right now you can’t delete a ramble. Silly isn’t it?

Delete Player
=============
Just as the site says, all scorecards are GONE!

Delete Course
=============
This deletes all scorecards tied to the course. It checks if there is a tournament tied to it and refuses to delete it so BE CAREFUL about this.

The next 3 deals with Tournaments, so let’s jump in later.

Update Hole Ranks
=================
This is important to click. Once all the stats are in, the hole by hole stats will not be calculated by default so you need to click on this to get a hole by hole statistics of each course. So don’t complain if you don’t see hole statistics when you forget to click on this.

Update Player Stats
===================
Player stats are usually updated once scorecards are submitted but at times you might want to manually update their stats

Update Player Points
====================
Player points can be updated each time you place a card in. Points by default are set in updateplayerpoints.php. 

Sorry I don’t have a GUI for this. Maybe next version? (this is becoming old…)

Generally, you want to click on Update Stats first before Updating points….or not. Up to you!

See Appendix 3 for default calculation values.




TOURNAMENTS
===========
OK, lets create another player, or a few other players, using signup.php.

And lets create scorecards for all players, using same date and same course and check the tournament.


Under Create Tournament go ahead and create the tournament Name.

Select the tournament Game.

Select tournament type. I only so far put in Gross, Net and System 36. I’ll add in more I guess in….the next version!!

Put in your tournament purse. (Total prize money, fake or real)

Go ahead and create it.

Once created, you need to reclick Management so that the tourney can be found under Process Tournament. It’s a known Bug.


Under process tournament, simply select the winnings and Process tournament!

Another Known Bug

When you process tournament, you get the string

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/core.com.my/httpdocs/stats30/tourneycount.php on line 133

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/core.com.my/httpdocs/stats30/tourneycount.php on line 134

Etc etc

This means that your mysql doesn’t understand the cast function which is only introduced in Mysql 4 I think.

This sucks, but basically we need to compare string to string but need to change it to numeric first, hence the cast.

There’s no work around for this at the moment until mysql can be upgraded.



Don’t worry, the tournament has been created only without the GIR, Sandsave a  few more stats, they will be projected as NA.

Check the tournament page. You should see some stuff there. You can put in the picture image if you want.

It is under

images/<date><courseid>a.jpg

Also, you can put in a text report if you want

Files/<date><courseid>a.txt


You should be getting something like this




Oops. Looks like Phil and Vijay tied. I haven’t really figured out a good way to solve that one yet aside from manually inputting their scores. 

Next version?

 
CONCLUSION
==========
Let me know what other features or bugs or if someone wants to hack this for me. You can mail me at either 

hide@address.com
hide@address.com

I respond faster if you become a friend in myspace at www.myspace.com/stevheong. My email to be friends is hide@address.com I am new to myspace and don’t really have lots of friends....so request!!!





APPENDIX 1
==========
It just sounds cooler to have appendices at the end of a document, something my company likes to do.

MIGRATION FROM VERSION 2.0 TO VERSION 3.0
==========================================
The best way is of course to install the new version. However, you might already have users so its everyone’s interest that the migration is as painless as possible so we can start playing golf instead of sitting in front of the confounded PC.

DATABASE MIGRATION
==================
This is the most crucial part since the database is the engine.

Tables

Clubs – No change

Courses – No Change

Gameorg – No Change

Games – No Change

Hole1 – hole18

There’s a patch on all these tables to make the default of bunker to be 0 instead of 1.

ALTER TABLE `hole1` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole2` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole3` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole4` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole5` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole6` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole7` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole8` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole9` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole10` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole11` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole12` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole13` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole14` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole15` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole16` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole17` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';
ALTER TABLE `hole18` CHANGE `bunker` `bunker` CHAR( 2 ) DEFAULT '0';


UPDATE `hole1` SET `bunker` = '0';
UPDATE `hole2` SET `bunker` = '0';
UPDATE `hole3` SET `bunker` = '0';
UPDATE `hole4` SET `bunker` = '0';
UPDATE `hole5` SET `bunker` = '0';
UPDATE `hole6` SET `bunker` = '0';
UPDATE `hole7` SET `bunker` = '0';
UPDATE `hole8` SET `bunker` = '0';
UPDATE `hole9` SET `bunker` = '0';
UPDATE `hole10` SET `bunker` = '0';
UPDATE `hole11` SET `bunker` = '0';
UPDATE `hole12` SET `bunker` = '0';
UPDATE `hole13` SET `bunker` = '0';
UPDATE `hole14` SET `bunker` = '0';
UPDATE `hole15` SET `bunker` = '0';
UPDATE `hole16` SET `bunker` = '0';
UPDATE `hole17` SET `bunker` = '0';
UPDATE `hole18` SET `bunker` = '0';


Holerank – No change

Msgboard- No change

Ranking – Documented change to add double eagle and hole in one


ALTER TABLE `ranking` ADD `totaldoubleeagles` INT(4)  NOT NULL AFTER `totaleagles`;
ALTER TABLE `ranking` ADD `totalholeinone` INT(4)  NOT NULL AFTER `totaleagles`;
ALTER TABLE `ranking` ADD `net_totaldoubleeagles` INT(4)  NOT NULL AFTER `net_totaleagles`;
ALTER TABLE `ranking` ADD `net_totalholeinone` INT(4)  NOT NULL AFTER `net_totaleagles`;



Stableford- No change

Substats – No change

Tips – No change

Tourney – No Change

Tourney_board – No Change

Tourney_stat – No change

Users_clubs – No change

Users_tour – No change

Database migrated!



FILES MIGRATION
===============
Copy all to the directory (make sure you back up first) and make sure you change your dbasecon.inc.php accordingly.

Env.php also should remain the same.

Login.php also should remain the same since it’s your first page.

Your images and files directory should remain the same as well.

There has been changes in menu.php, so if you’ve changed the structure, I’m afraid, you’ll need to remodify it to suit your needs.

Keep your fingers crossed!

I recommend you to rename the current folder to <foldername>-old, Recreate an empty <foldername> and unzip  all the files in there.




APPENDIX 2
==========
From the previous version’s readme, a short note on some tables

Games
=====
Additional four fields for tournament (1,0), tourney placing, money won and points won (points are not calculated yet, maybe useful for future). Also, field types have changed in fairway hit, gir to accomodate 'na'. Remember, if this is changed to char type, we have to CAST to numeric during the sql query to find top record!

Hole
====
Changes only to the type, again to char and again, remember to CAST during query!


Holerank
========
This is the table that gets updated to reflect hole statistics


Msgboard
========
The ramble (quote) and normal messages piggy back on this table. Quotes would have a rambleid > 1. Normal messages (appearing in the yellow box at the front page) has rambleid=0. One thing to note about the random ramble is that it takes a sequential formula according to the rambleid. I.e if you have ramble 1-10, there's no problem. But say you deleted ramble 3, now you have a break, 1-2, 4-10. The formula still takes into account the formula for 1-10, so  it might generate a random 3, in which in this case, its empty, hence, a random empty quote pops up. Might work on this in next version.


Ranking
=======
This is where all the player ranks are kept and calculated.


Stableford
==========
Probably in the next version, I'll come up with a simple interface to edit this table. As of now, you'll have to manually change the stableford point system.


Substats
========
These are actually the stats used to count the ranking stats.


Tourney_Board
=============
Here is where the tournament report is kept


Tourney_stat
============
And here's where all the tourney stats dumped by 'Processing Tournament' in management module are kept.


users_clubs
===========
New table to store club information for players

users_tour
==========
This is the new user database, entirely up to you, but make sure you change the queries in all files to query the new field name as opposed to users_tour.



APPENDIX 3
==========
Values for point calculations are

Optional to calculate Tournament Points 
=======================================
Tournament points optional
==========================
Tournament Wins=x * 5
Top 3=x * 3
Top 5=x * 1

Stat Points
===========
Hardest
=======
Double Eagles=x * 8
Hole In one=x * 5
Eagles=x * 2

Pretty tough
==============
Net Double Eagles=x * 2
Gross Birdie=x * 2
Gross Parbreaker=x
sandsave=x/5

Hard
====
GIR=x/10
Average gross score=500/x
Net Hole in One=x/(no of games/2)
Net Eagles=x/(no of games/2)

Medium
======
Average Net score=300/x
Scrambling=x/10
Putting Average=5/x
Gross Par=x
Net Parbreakers=x/10
Net Birdie=x

Easy
====
Net Scrambling=x/20
Net Par=x/2
Drive Distance=x/200
Driving Accuracy=x/20

Return current item: GolfstatsPHP