Jump to content
MakeWebGames

Recommended Posts

Posted

I found one more bit of old code floating around my files.

This is a bank replacement, where you can store money and crystals. Money has interest rates associated (that can be unique for every single player), and a limited amount of daily deposits. I made this this way, thinking on points that could be exchanged to increase interest, yet those bits, you will need to add yourself on other files.

This is intended to be applied as a "stand alone" bank system (meaning that with minor edits this ought to work on any other engine), depending on its own table, meaning that regular "bankmoney" on users table won't be needed. Also, you don't need to generate entries for every single player as it will generate the needed row upon first use by the player itself.

You are more than welcome to expand this further more, there are a few mods to this system i would like to see floating around. And enough is enough, let's dump the damn code, cause that is what you want. ;)

Table dump

[mysql]

DROP TABLE IF EXISTS `uBANK`;

CREATE TABLE `uBANK` (

`bID` int(11) NOT NULL AUTO_INCREMENT,

`bUID` int(11) NOT NULL,

`bMONEY` int(11) NOT NULL,

`bCRYSTAL` int(11) NOT NULL,

`bINTEREST` int(11) NOT NULL,

`bDEPOSIT` int(11) NOT NULL,

`bMAXCASH` int(11) NOT NULL,

`bMAXDEP` int(11) NOT NULL,

`bMAXCRYS` int(11) NOT NULL,

PRIMARY KEY (`bID`),

UNIQUE KEY `bID` (`bID`)

) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

[/mysql]

The code

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Crons

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Have phun!

Posted

I like your style of coding.

But a few things in this script don't quite add up, I've no idea why you are using str_replace() for the numbers when there are functions specifically designed to ensure it's actually a number.

$_SERVER['php_self'] has been known to be prone to manipulation, so I'd suggest cleaning that, there is a thread on it somewhere but really htmlentities() can suffice.

Also you could receive a number of errors if you're reporting errors on your site when using this script...

Just minor little things I'd look into, your other script looks nice as well.

Good work

Posted
$_SERVER['PHP_SELF'] << insecurity right there ;)

quite true if you rely on the $var alone. the funny thing is... i don't care much about it, as i rely on my own ways to secure those "insecurity" issues you pointed so fast, also, i am not reponsable for other users security, that is not my problem ;)

@ Equinox, you are right, yet those functions assume that a negative number is actually a number, so just in case, cleaning that is not much of a big deal, as of the rest, i believe my answer to Danny would meet yours as well.

Posted

Some functions turn a negative integer in a 0

Some functions will accept negative integers while still assuming it's an integer.

Various functions do various things, but all in all, nice idea.

Posted

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Minus numbers, clean.

You could simply use a ternary operator method to assign a new value to 'input' if it has got a minus number or is not set. Just an example.

Posted

You said that a lot of functions take a negative number as an actual number. I pointed out one that does not ;) Just a better way than round() and str_replace() IMO. And still, yes it's not your priority to ensure that a site is safe of the person using this script, but a lot of people don't understand the security side of things and could cause some issues, not too hard to just protect from script kiddies (who are the greatest majority of attackers to text based games)

Not taking a hit at you, just have your own way I guess and listening to other people isn't a bad thing :P

Keep it up

Posted

No hit taken, i rarely do actually, and discussions as this pointing out the the visible flaws, are nothing but a way for those who want to learn to have a better look when reusing code.

and playing around with your suggestions why not "clone" is_pos() from perl, which is easyly achieved with a ternary condition? ;)

Posted

Well, building a function like that would be easy also using preg_match/replace() and regular expressions (regex) - But for what's being done here, there's really no need, no?

I'm not to sure on what is_pos is in Perl, I assume it is "is positive" ?

Posted

Then there we go :D

I tried finding it and reading up, but all I could find was pos , no is_pos.

But anyway, we've strayed off topic now, I will leave you again with nice work and now I will go off to bed :thumbup:

Posted

It's not as if it would take long to fix the php_slef issue - $_SERVER['PHP_SELF'] alternative/vulnerability

looks good nice to see people posting mods who are not stuck in the “mccodes style”.

there are a few mods to this system i would like to see floating around

Post what you're thinking, this system looks like something worth expanding.

Just a quick scan over I did notice stuff like

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

will give a notice, isset could fix that. I think everything else has been by Equinox O_o

Anyway nice mod. :)

@ danny -perl syntax is very close to php so is often a good thing to link into it.

Posted
Can i ask why your linking to a perl script?

i was replying to Equinox misfortune on not finding is_pos() (which is a perl function to check if the number is positive. ;)

@Dominion: well... the sky is the limit... and my ideas are just that... mine! i would like to see where people could drive with the base ;)

  • 2 weeks later...
Posted

This looks great! :) Sorry (this may be the most stupid thing you've ever heard ;)) Where am I supposed to out the cron bit? Because it is PHP, but I don't know where to put it :P

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...