PDA

View Full Version : Relatively Big Project



iGoD ReLeNtLeS
20-12-10, 01:27
Im starting a couple of big projects for the clan im in. The website is hosted from my server so i have all the access i need. Its a runescape based clan, although not going to indepth with it.

Everything will be hosted from my homeserver until its done/relatively usable. Basically we have a fortnightly competition in a chosen skill as to who can gain the most xp within a week, known as Skill of the Week (sotw). Currently we are using google docs as a 'tracker', but a new one needs creating each time which is a slight pain as its quite a long process. I want to use this thread to keep a clear head, plan things and for help ect rather than creating tonnes of threads, keep it in one place. :thumb:

Home server address: http://www.igodrelentles.co.cc/sotw/ everything done in that project will be in that dir. I will eventually create a basic page where i will link everything together.

The Project Itself:

Firstly i have already created a stats parser which is currently reading the stats for a given user and echoing them to view in a table. However this needs modifying to read all names from a database and then saving the xp for each user into a separate database and an individual table for each user. This will be an independent script from anything else and will be run on a 30 minute interval (i have other uses for this as well). This can currently be viewed at www.igodrelentles.co.cc/sotw/ You can use my rsn for an example: iWader

I will keep this updated as i go, first step should be finished by tomorrow (20th Dec 2010). Would appreciate any tips, pointers ect as to methods of doing things as i go, little uncertain as to how to execute the code on an interval? perhaps setting this under the server settings as a task will do it. Will update this when i wake up :p

iGoD

Peter
20-12-10, 03:33
Parsing the stats should be very trivial if you're using the lite feed that Jagex provide (if you're not using it I suggest you switch to it):
http://hiscore.runescape.com/index_lite.ws?player=iwader

What kind of server is that running on? Is it linux? Do you have access to a cPanel?

If the answer to both of those questions is yes then you can setup a cron job to execute the script on whatever interval you'd like.

Presumably you want to keep a record of these stats as you're calculating a weekly total. In that case, you should save their username, the Unix Timestamp, and the relevant statistics. From there you can use an SQL query to select all of the data between two points, and sum it up to see who gained the most.

iGoD ReLeNtLeS
23-12-10, 23:47
hmm k, im created the script and its writing all the data i need to the database, but when i remove the html details and run it in the terminal and im getting syntax errors, is there a different way to script it to run through the terminal or something?

current error im getting is


$con = mysql_connect("localhost","","")

but that works just fine through the browser with html format.

on a side note i've pretty much finished the hardest part.

Edit:

Well i've fixed that but now i cant seem to get it to execute on the Cronbar. I've run it manually on the server through SSH and that worked and created all the tables and saved all the data. Below is my Cronbar settings

http://img143.imageshack.us/img143/8564/trackerv.png

Naphta
24-12-10, 09:33
Try changing it to the loopback without the FQDN.

Peter
24-12-10, 19:24
You probably need to prefix it with PHP like:

php /home/ts3/tracker.php
OR put a hashbang at the top of your tracker.php file, before everything else, like this:

#!/usr/bin/php
<?php...

iGoD ReLeNtLeS
27-12-10, 03:00
hmm k i've hit a bit of a problem on my vps. I done some extra editing on my script with some validation so if the field is blank or the user doesn't exist within the rs database it won't create a table or input the details of the user, but now i seem to have hit a php problem.

My VPS says that php isn't installed into the dir /usr/bin/php/... but when i type "whereis php" it returns...


php: /usr/bin/php /usr/lib/php /usr/lib64/php /usr/share/man/man1/php.1.gz

which would suggest that its installed in the dir /usr/bin/php

i have used #!/usr/bin/php on the first line of my script.

anyone got any suggestions?

Peter
27-12-10, 03:50
If you've got a VPS you may as well just directly execute it like:

php /path/to/file.phpAnd just scrap the hashbang.

You do need to make sure you have PHP CLI installed though (package php5-cli on Debian based distros I believe) for both scenarios.