Zettieee Posted April 15, 2016 Share Posted April 15, 2016 Hello. after speaking with Adam he has allowed me to recode and release a custom version of GRPG. What would you, the people who use GRPG like in this version? Somethings I've already started: Converted to mysqli, securing inputs, thinking of removing the weird class system is has in favor of a more array styled system (like the one in mccodes). So any ideas you guys have post below. Quote Link to comment Share on other sites More sharing options...
AdamHull Posted April 15, 2016 Share Posted April 15, 2016 CSRF tokens? just to make it that bit secure as it never was was :) Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 15, 2016 Share Posted April 15, 2016 Keep the class system but just make it better. He'll just use eloquent Quote Link to comment Share on other sites More sharing options...
Dominion Posted April 15, 2016 Share Posted April 15, 2016 It's important to add in the missing security checks as the system is old, and I have to admit I have only seen parts of it. I would say Kyle was right on the class system. It probably needs work, but I imagine going OO is better then just dumping everything into arrays. What I would suggest is making sure the database is optimized. People far to often jump straight into the files, and forget a slow database can be just as big of an issue. Quote Link to comment Share on other sites More sharing options...
Zettieee Posted April 15, 2016 Author Share Posted April 15, 2016 Would converting an array into a class object be better in the long run? Quote Link to comment Share on other sites More sharing options...
Dominion Posted April 15, 2016 Share Posted April 15, 2016 Would converting an array into a class object be better in the long run? Not necessarily. I don't really know anything about Grpg so I couldn't comment on the engine, but I've seen people go overboard both ways. If the only thing you do in a class is define a bunch of $vars it's all but pointless. For example I once saw someone set a class up to define the price of travel in mccodes monorail file. If it's something like a character class then it makes sense So I guess the question is what are the arrays/class files used for in Grpg? Quote Link to comment Share on other sites More sharing options...
AdamHull Posted April 15, 2016 Share Posted April 15, 2016 You could use the mysqli objects as this would keep with current theme to a extent, would make it easier for people to convert mods to it, the classes are used to declare all user information from the database meaning installing a new user mod that requires a new field entered into the user table means you have to update the class which makes it totally useless and harder to install mods. Quote Link to comment Share on other sites More sharing options...
Zettieee Posted April 15, 2016 Author Share Posted April 15, 2016 Here is the current user class: http://pastebin.com/pbaT7WKp Its rather slow and clunky The way I'm going to d it just array to object. It'll save me time on development and hopefully make it a little cleaner on the eyes. //edit here's what I was thinking of using. <?php class Z_User { function Z_User($id) { $run = mysqli_query("SELECT * FROM `grpgusers` WHERE `id`='$id'"); $users = mysqli_fetch_assoc($run); foreach ($users as $obj => $value) { $this->$obj = $value; } } } ?> It's not perfect but it works. Example use age for people who currently use GRPG: $zuser_class = new Z_User($_SESSION['id']); <?= $zuser_class->username; ?> Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 16, 2016 Share Posted April 16, 2016 Go more OO. It'll be more maintainable and scalable in the long run. You can also cut down the amount you rewrite code. Quote Link to comment Share on other sites More sharing options...
Zettieee Posted April 16, 2016 Author Share Posted April 16, 2016 Not sure if a whole rewrite isn't needed. So much code is so badly written it's hard for me to do anything without breaking something else. Quote Link to comment Share on other sites More sharing options...
Dominion Posted April 16, 2016 Share Posted April 16, 2016 Go more OO. It'll be more maintainable and scalable in the long run. You can also cut down the amount you rewrite code. I said this, but as it stands how it's using it is ridiculous. It needs a rework. Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 17, 2016 Share Posted April 17, 2016 I said this, but as it stands how it's using it is ridiculous. It needs a rework. I was hoping the reiteration would help the issue of making it OO more noticeable. 1 Quote Link to comment Share on other sites More sharing options...
Dominion Posted April 17, 2016 Share Posted April 17, 2016 (edited) I was hoping the reiteration would help the issue of making it OO more noticeable. Fair enough. When I said it I hadn't realised how badly Grpg uses it. If it's redone it should be done with an OO setup in mind(as you said). :-) Edited April 17, 2016 by Dominion Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 17, 2016 Share Posted April 17, 2016 An OO Modular code structure could work very well for this. I always had plans to do something similar to that. The idea would be that a developer could zip a mod for the game, and a game owner could install the mods through the admin panel by uploading the zip Quote Link to comment Share on other sites More sharing options...
Dominion Posted April 18, 2016 Share Posted April 18, 2016 An OO Modular code structure could work very well for this. I always had plans to do something similar to that. The idea would be that a developer could zip a mod for the game, and a game owner could install the mods through the admin panel by uploading the zip This can be done without OO within PHP. For example NWE does it this way. I'd still say go OO if it's a full recode, but the biggest advantage is logic/design separation, and (in theory) easier maintenance for when new people pick up the code. Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 18, 2016 Share Posted April 18, 2016 This can be done without OO within PHP. For example NWE does it this way. I'd still say go OO if it's a full recode, but the biggest advantage is logic/design separation, and (in theory) easier maintenance for when new people pick up the code. I know it can be done without, but it would be better with. The zip would contain the logic file(s), the controller (if part of the code structure), and the view file. In my own ideal scenario, it would also contain a links.txt file. This would have a structure like: link : title : location Where the link is the url to a certain part of the mod, title is the link text and location would be town or main menu When the zip is uploaded the code would scan for this file, and on finding it would read the location and link and store them into a db. Then the mainmenu and the town links etc would be retrieved from the db. The admin panel could have a wysiwyg editor to allow the owner to change the order of the links or their titles. Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 18, 2016 Share Posted April 18, 2016 This would be good in Laravel if you have time for the learning curve. If you don't really want to spend time learning something like Laravel you can use let the bashing begin Code Igniter. Or Laravel 4.2 is much easier than 5.* Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 19, 2016 Share Posted April 19, 2016 This would be good in Laravel if you have time for the learning curve. If you don't really want to spend time learning something like Laravel you can use let the bashing begin Code Igniter. Or Laravel 4.2 is much easier than 5.* I use CodeIgniter, I like it a lot actually /: so I'll prepare myself for the bashing Quote Link to comment Share on other sites More sharing options...
Zettieee Posted April 20, 2016 Author Share Posted April 20, 2016 To me frameworks never made sense. Relearning basic functions just to start a project is a little rough for me. You're all welcome to help btw. Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 20, 2016 Share Posted April 20, 2016 To me frameworks never made sense. Relearning basic functions just to start a project is a little rough for me. You're all welcome to help btw. Frameworks never made sense... That's a great start. Um.. They help keep your code maintainable. They provide a range of functions, libraries and helpers to help speed up the process of development. They generally provide an OO environment out of the box. A lot of them allow you to split the logic and design parts of your code. They provide extensions or plugins to handle things like rendering, bbcode parsers etc. They provide a good code structure. A lot of them have some sort of cache system built in. I'm not sure about Laravel but CodeIgniter has built in CSRF and XSS protection. CodeIgniter also has Query Builder which can help make your database queries more maintainable and readable. Don't knock them until you try it Quote Link to comment Share on other sites More sharing options...
Dominion Posted April 20, 2016 Share Posted April 20, 2016 To me frameworks never made sense. Relearning basic functions just to start a project is a little rough for me. You're all welcome to help btw. You learn one Framework so you can continue using it for other projects. The larger the application the more sense it makes to use them. It keeps you from having to rewrite the same basic things again, and allows others to pick up a project much easier. In truth I wouldn't say it's needed here, but I would recommend learning a framework if you work with PHP enough. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted May 15, 2016 Share Posted May 15, 2016 Here is the current user class: http://pastebin.com/pbaT7WKp [...] Plzn, plzno, kthx 1 Quote Link to comment Share on other sites More sharing options...
Coly010 Posted May 16, 2016 Share Posted May 16, 2016 First time I looked at that class. It's disgusting. One of the many things I see wrong is that it doesn't check whether the user it's trying to pull information on even exists. Next up, all it does is create a bunch of variables in a class, and doesn't do it nicely, or efficiently (foreach( $worked as $k=>$v){ $this->$k = $v; } ??? ). There's no need for this class. A user class should have both variables and functions. Even functions as simple as addMoney($amt), removeMoney($amt). It makes the logic code a lot better. If this approach was taken for a lot of the code you setup for say buying an item could be as simple as: if(!$this->Items->itemExists($itmid)){ //handle error } $item = $this->Items->getItem($itmid); if($this->User->get("money") < $item['cost']){ // handle error } $this->User->removeMoney($item['cost']); $this->User->giveItem($itmid); It cuts down a lot of code and makes life easy and makes the code very readable and easy to understand 1 Quote Link to comment Share on other sites More sharing options...
IllegalPigeon Posted May 16, 2016 Share Posted May 16, 2016 A user class should have both variables and functions. His user class had both variables and functions, albeit the class was bad but both those points were there. Not sure what you're getting at? if(!$this->Items->itemExists($itmid)){ //handle error } $item = $this->Items->getItem($itmid); if($this->User->get("money") < $item['cost']){ // handle error } $this->User->removeMoney($item['cost']); $this->User->giveItem($itmid); I don't think you understand object referencing. 1 Quote Link to comment Share on other sites More sharing options...
Coly010 Posted May 16, 2016 Share Posted May 16, 2016 His user class had both variables and functions, albeit the class was bad but both those points were there. Not sure what you're getting at? I don't think you understand object referencing. More than a constructor function I should say. And explain my object referencing issue? Quote Link to comment 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.