
BlueDevil23
Members-
Posts
328 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by BlueDevil23
-
I'm sneaky. I like to surprise ya.
-
Good to see a lot of old names still around!
-
Haha, it definitely is.
-
It doesn't directly add security, just another way of calling the same file. It's more or less a preference thing :)
-
I believe this is a gym I secured and threw together for someone back in the day, or maybe just something I did for fun. I don't remember anymore haha. It's nothing special, a little more aesthetically pleasing and secure to my knowledge. Thought I'd release it for the hell of it, it's just sitting around. Thanks to Lilith and dominion for testing it out for me on their test servers, to make sure it wasn't bugged :) <?php $macropage = "gym.php"; require_once "globals.php"; ($ir['hospital'] ? die("This page cannot be accessed while in hospital.") : FALSE); $statnames = array ( 'Strength' => 'strength', 'Agility' => 'agility', 'Guard' => 'guard', 'Labour' => 'labour' ); $_POST['amnt'] = (!empty($_POST['amnt']) && ctype_digit($_POST['amnt']) && isset($_POST['amnt']) ? abs(@intval($_POST['amnt'])) : ""); $_POST['stat'] = (!empty($_POST['stat']) && ctype_alpha($_POST['stat']) && isset($_POST['amnt']) ? htmlentities(trim($_POST['stat'])) : ""); $gymname = ($ir['jail'] ? "Jail Gym" : "Gym"); echo "<h1> {$gymname} </h1>"; if($_POST['stat'] && $_POST['amnt']) { $stat = $statnames[$_POST['stat']]; (!$stat ? die("This stat cannot be trained or it does not exist") : FALSE); if($_POST['amnt'] > $ir['energy']) { echo "You do not have enough energy to train that much"; } else { $gain = 0; for($i=0; $i<$_POST['amnt']; $i++) { $gain += mt_rand(1,3) / mt_rand(800,1000) * mt_rand(800,1000) * (($ir['will'] + 20) / 150); $ir['will'] -= mt_rand(1,3); ($ir['will'] < 0 ? $ir['will'] = 0 : $ir['will'] = $ir['will']); } ($ir['jail'] ? $gain /= 2 : FALSE); $statUp = sprintf("UPDATE `userstats` SET `%s` = `%s` + %d WHERE (`userid` = %u)", $stat, $stat, abs(@intval($gain)), abs(@intval($userid))); $do_statUp = mysql_query($statUp); if($do_statUp === FALSE) { echo "".mysql_error().""; } $adjUser = sprintf("UPDATE `users` SET `will` = %d, `energy` = `energy` - %d WHERE (`userid` = %u)", abs(@intval($ir['will'])), $_POST['amnt'], abs(@intval($userid))); $do_adjUser = mysql_query($adjUser); if($do_adjUser === FALSE) { echo "".mysql_error().""; } $inc = abs(@intval($ir[$stat] + $gain)); $inc2 = abs(@intval($ir['energy'] - $_POST['amnt'])); if($stat == "strength") { printf(" You begin lifting some weights. You have gained %d strength, by doing %d sets of weights. You now have %d strength and %d energy left. </p>", abs(@intval($gain)), $_POST['amnt'], $inc, $inc2); $_SESSION['checked'] = 1; } elseif($stat == "agility") { printf(" You begin running on a treadmill. You have gained %d agility, by doing %d minutes of running. You now have %d agility and %d energy left. </p>", abs(@intval($gain)), $_POST['amnt'], $inc, $inc2); $_SESSION['checked'] = 2; } elseif($stat == "guard") { printf(" You jump into the pool, and begin swimming. You have gained %d guard, by doing %d minutes of swimming. You now have %d guard and %d energy left. </p>", abs(@intval($gain)), $_POST['amnt'], $inc, $inc2); $_SESSION['checked'] = 3; } elseif($stat == "labour") { printf(" You walk over to some boxes filled with gym equipment and start moving them. You have gained %d labour, by moving %d boxes. You now have %d labour and %d energy left. </p>", abs(@intval($gain)), $_POST['amnt'], $inc, $inc2); $_SESSION['checked'] = 4; } $ir['energy'] -= $_POST['amnt']; $ir[$stat] += $gain; } } $checked1 = (($_SESSION['checked'] == 1) ? "checked='checked' />" : "/>"); $checked2 = (($_SESSION['checked'] == 2) ? "checked='checked' />" : "/>"); $checked3 = (($_SESSION['checked'] == 3) ? "checked='checked' />" : "/>"); $checked4 = (($_SESSION['checked'] == 4) ? "checked='checked' />" : "/>"); $ir['strank'] = get_rank($ir['strength'],'strength'); $ir['agirank'] = get_rank($ir['agility'],'agility'); $ir['guarank'] = get_rank($ir['guard'],'guard'); $ir['labrank'] = get_rank($ir['labour'],'labour'); echo <<<EOF2 <style type="text/css"> legend { margin-left: 1em; color: #FFF; font-weight: bold; } fieldset ol { padding: 1em 1em 0 1em; list-style: none; } fieldset ol li { float: left; clear: left; width: 100%; padding-bottom: 0.5em; } label { float: left; width: 10em; margin-right: 1em; font-weight: bold; } fieldset.submit { float: none; width: auto; border-style: none; padding-left: 12em; background-color: transparent; background-image: none; } .padder { padding: 0 5px 15px 5px; } dl { width: 500px; } dt { float: left; width: 300px; } dd { float: right; width: 200px; margin-top: -11px; } </style> <h3> Choose the stat you want to train and the times you would like to train it</h3> <h3> You can train up to {$ir['energy']} times </h3> <div class="padder"> <fieldset> <legend> Gym </legend> <form action="gym.php" method="POST"> [list=1] [*] <label for="strength"> Strength (Have {$ir['strength']}, Ranked {$ir['strank']}) </label> <input type="radio" name="stat" value="Strength" $checked1 [*] <label for="agility"> Agility (Have {$ir['agility']}, Ranked {$ir['agirank']}) </label> <input type="radio" name="stat" value="Agility" $checked2 [*] <label for="guard"> Guard (Have {$ir['guard']}, Ranked {$ir['guarank']}) </label> <input type="radio" name="stat" value="Guard" $checked3 [*] <label for="labour"> Labour (Have {$ir['labour']}, Ranked {$ir['labrank']}) </label> <input type="radio" name="stat" value="Labour" $checked4 [*] <label for="amnt"> Times to Train </label> <input type="text" name="amnt" value="{$ir['energy']}" /> [*] <input type="submit" class="submit" value=" Train " /> [/list] </form> </fieldset> EOF2; $h->endpage(); ?>
-
I had a raw, functioning one, I worked on back in the day. I'll try and see if I can find the code somewhere on my computer. I unfortunately couldn't find my old AJAX gym, must have left it on the server, which is down now. Sorry.
-
I had a raw, functioning one, I worked on back in the day. I'll try and see if I can find the code somewhere on my computer.
-
Haha thanks, but I thought I'd repost it for everyone for free, because it's probably not even efficient code anymore with the way things change in the programming world, but who knows.
-
Thanks Danny 696. And thanks Jordan Palmer, glad to hear it's still running smoothly. :)
-
Haha, I was hoping no one got too bothered about a dollar.. hah And thanks, it's good to be back! :) Oh, and could you let me know if it still is working?
-
Old paid mod. I don't programm anymore, so I will not provide any support for this anymore, sorry hah. I'm not even sure if it works anymore, because Yahoo might have changed their Weather API on me, but I don't know. Someone let me know.
-
Ha, well it's good to see some people I remember, and thanks for all the welcome backs. I'm not exactly sure I'll be around more, again, but I'll probably check in more often. I don't really programm anymore, but glad to see you guys are still at it! :)
-
I might :P ... PM with more info, and exacts, or preferrably add me on IM MSN: [email protected] Yahoo: [email protected]
-
I am now taking(Actively seeking... more like it) mod requests for paid work. So if you have something on your mind, you'd like in your game, give me a holler :)
-
PHP Development: Rapid PHP 2008 Pretty much everything else: Aptana Studio
-
Good luck, but I have to agree with the other forewarnings, as you may need to come up with something out of the box to make money. Heck, even Twitter hasn't found a way to monetize itself yet. But hopefully you will, good luck :)
-
I have not personally ventured into Java... but I'm pretty sure Gx works with it(Not sure if he's on the forums, be he is in chat sometimes, and I know you also frequent it). parelem is sick with Java, I'm pretty sure she knows more about Java than she does PHP, but don't quote me on that. Hope that helps you out, or at least gives you some people to contact. :)
-
Not the same ID *and* name on different objects, but say you have a form... you give the form the an ID of foo... but then end up naming one of the input foo... it's going to create problems.
-
IE 8 doesn't (I believe). IE 6 and 7 search for both ID *and* the name attribute when using getElementById(). The easy way to get around that is not using the same ID and the same name on different elements.... but that's not always the case.
-
@Floydian Thanks for the tips. Javascript is really an area I would like to improve in. @Alain Internet Explorer has problems with getElementById(). And on the event... meh either of your proposed choices would be fine. I have no real reason I did it, just for completeness.
-
mdshare was kind enough to lend me some server space, and I set up an example: http://www.browsergames.be/counter_example.html
-
Post the login.php here, and I'll help you out.
-
Here a few little functions I made to use with a form, to tell the user how many characters they have left. Obviously, they can bypass this without JS turned off, so make sure to check the length of the submitted string, server-side also! [js] /** * xBrowser_getID returns the supplied elements ID * * This is basically a cross-browser version of get.ElementById() * * @param string supplied_ID This is the element you want to get the ID of. * @return The ID of the supplied element. * @type string * */ function xBrowser_getID(supplied_ID) { var ID = null; if(document.layers) { ID = document.layers[supplied_ID]; } else if(document.all) { ID = document.all[supplied_ID]; } else if(document.getElementById) { ID = document.getElementById(supplied_ID); } return ID; } /** * fillCounter is meant to be used in conjunction with characterCounter, to prefill. * * fillCounter finds the element provided, and counts the number of characters * in it. It then finds the element with the counterID and fills it with the * correct number depending on the maximum allowed characters. This function is * meant to be used after document execution and without any user interaction -- * to simply prefill the element, for better presentation. * * @requires xBrowser_getID() Requires this function to get the ID of the supplied element. * * @param string elementID Element that you are counting the characters in. * @param string counterID Element that is updated with the characters left. * @param integer max_allowed_chars The maximum amount of characters allowed in the elementID. * */ function fillCounter(elementID, counterID, max_allowed_chars) { var element = xBrowser_getID(elementID); var counterElement = xBrowser_getID(counterID); counterElement.innerHTML = max_allowed_chars - element.value.length; } // Example: fillCounter('profileSig', 'lettersLeft', 300); /** * characterCounter sets a value to be counted up and down. * * characterCounter finds the element provided, and sets the max characters allowed * in it. It is meant to be used with the onkeyup and onkeydown event handlers * When the user either keys up or down, it will decrease the character count * by the amount of character written. If the characters exceed the maximum * allowed, it will subtract them from the input, and bring them back down to * the allowed amount. * * @requires xBrowser_getID() Requires this function to get the ID of the supplied element. * * @param string elementID Element that you are counting the characters in. * @param string counterID Element that is updated with the characters left. * @param integer max_allowed_chars The maximum amount of characters allowed in the elementID. * */ function characterCounter(elementID, counterID, max_allowed_chars) { var element = xBrowser_getID(elementID); var counterElement = xBrowser_getID(counterID); if(element.value.length > max_allowed_chars) { element.value = element.value.substring(0, max_allowed_chars); } else { counterElement.innerHTML = max_allowed_chars - element.value.length; } } [/js] Usage: <form action="#" method="POST" id="dummy_form"> <textarea row="5" cols="60" id="dummy_text" onkeyup="characterCounter('dummy_text', 'counter', 300);" onkeydown="characterCounter('dummy_text', 'counter', 300);"> Heya MakeWebGames </textarea> <input type="submit" id="submit" name="submit" value="Submit" /> </form> <span id="counter"></span> <script type="text/javascript"> fillCounter('dummy_text', 'counter', 300); </script>