DrMath Posted May 5, 2014 Share Posted May 5, 2014 (edited) Hello everyone! I am here to ask for some help with a certain script I have concocted. I run a moderately sized gaming community (using vBulletin 4.2.2) that supports multiple games, and as such we needed an automated roster to keep track of who plays what games. The code displays a list of games on the left, and the actual roster to the right. The default page is a "leadership roster" listing all the leaders. Game Roster pages include several things. Username, User Rank, IGN/Game Account Name, Join Date, and Last Active Date. You can sort by Join and Last Active Dates. There are also two types of members on the roster. Those who play the game as their "main game" and those who play it occasionally as an "other game". It is easy to get the main game members, since you can only have one, vBulletin saves it as text, so you can match it. The other games selector is saved bitwise, so we have to run a check for the game's location in the list against the user's saved bitwise in their profile to see if they play it. To do this, instead of manually coding the bit number, since everything is alphabetical, we simply assign each game a number, and do a a bitshift (1<<x) to get the proper bit (I've been told bitshift is much faster than using pow(2,x)). However, because it's specific too us, I have hard coded a lot of stuff, including mixing presentation code with functional code. The code works just fine for us, but I want to make it much easier so that other staff members besides me can update it easily and so the code is easier to manage. I hope I have given a good explanation of what the code does! To see the code in action, click http://www.zealotgaming.com/forum/pages.php?pageid=15 To see the code with syntax highlighted, here is the pastebin: http://pastebin.com/Nuanj4Ci I thank you all in advance for any help and advice you can give me. I am a novice and have been learning as I go to do this for my community. Edited May 5, 2014 by DrMath Quote Link to comment https://forums.phpfreaks.com/topic/288243-roster-script/ Share on other sites More sharing options...
Ansego Posted May 5, 2014 Share Posted May 5, 2014 You may want to add this to Job offering section: http://forums.phpfreaks.com/forum/77-job-offerings/ Quote Link to comment https://forums.phpfreaks.com/topic/288243-roster-script/#findComment-1478229 Share on other sites More sharing options...
DrMath Posted May 5, 2014 Author Share Posted May 5, 2014 The thing is, I'm not quite looking to pay anyone to redo this because that's costly and the code we have already works. Why pay a lot of money to redo a working script? I'm just looking for advice on how to improve. Quote Link to comment https://forums.phpfreaks.com/topic/288243-roster-script/#findComment-1478251 Share on other sites More sharing options...
gizmola Posted May 5, 2014 Share Posted May 5, 2014 You might have more luck pinpointing specific classes/functions etc. that you think might have an issue or could be improved.Speaking generally, it would be easier to maintain if you put the presentation code into "template" files that you include, or use a template engine for.I'm not going to suggest any of the sophisticated compilation template engines like smarty or twig, due to the fact that you are integrating with bulletin, but take a look at these:Blog post that shows a simple effective way could pull this off: http://chadminick.com/articles/simple-php-template-engine.htmlSome simple template classes that can be used with a simple include of their template class: http://phpsavant.com/docs/ http://www.tinybutstrong.com http://www.raintpl.com http://gabordemooij.com/se/ You might also look at breaking up a lot of the logic sections into functions, named appropriately to represent the specific purpose they fulfill. That way if you decide to move things around or add or remove sections, it will be much easier for someone to understand the code and make changes. Quote Link to comment https://forums.phpfreaks.com/topic/288243-roster-script/#findComment-1478256 Share on other sites More sharing options...
DrMath Posted May 5, 2014 Author Share Posted May 5, 2014 The template files are a good idea, I hadn't considered. I'm not much into programming function in php, but I'm sure I can find a tutorial and try to do it that way. ^^ Quote Link to comment https://forums.phpfreaks.com/topic/288243-roster-script/#findComment-1478259 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.