boionfire81 Posted May 13, 2016 Share Posted May 13, 2016 Anyone care to add their 2 cents on this. <?php require "globals.php"; $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? $_GET['action'] : null; switch ($_GET['action']) { case 'pray': prayer(); break; default: index(); break; } function index() { global $db,$h,$ir,$userid; print "<h3>You are currently at the church</h3><br><br> <form action='?action=pray' method='post'> Do you have a request of our Lord?<br> <select id='state' name='pray'> <option value='will'></option> <option value='hp'>Health Issues</option> <option value='energy'>I'd like to be more energetic</option> <option value='money'>I'd like help with a financial burden</option> <option value='friend'>I'd like to pray for my friend</option> </select><br><br> Please select your friend you would like to pray for<br>"; $q = $db->query( "SELECT `cl_ADDED` FROM `contactlist` WHERE `cl_ADDER` = {$userid}"); if ($db->num_rows($q) == 0) { echo "You have no contacts!"; } else { echo "<select id='foo' name='user1' type='dropdown'><option value=''><select a contact...></option>"; while ($r = $db->fetch_row($q)) { $esc_part = addslashes($r['username']); echo "<option value='{$esc_part}'>{$r['username']}</option>"; } echo "</select>"; } $db->free_result($q); echo" <input type='submit' value='Pray'>"; $h->endpage(); } function prayer() { global $db, $ir, $userid, $h; $_POST['pray'] = isset($_POST['pray']) && ctype_alpha($_POST['pray']) ? $_POST['pray'] : null; $_POST['user1'] = isset($_POST['user1']) && ctype_digit($_POST['user1']) ? $_POST['user1'] : null; $friend = $_POST['user1']; if($_POST['user1'] != $userid) { if($_POST['pray'] === 'hp') { $gain = ($ir['karma'] * 5); $total = ($ir['hp'] + $gain); echo "You prayed for a healing and you were blessed with + " . $total . "% of your health"; $db->query("UPDATE `users` SET `hp` = LEAST($total, maxhp) WHERE `userid` = $userid"); } elseif($_POST['pray'] === 'energy') { $grand = rand(1,3); $brand = rand(5,10); $ggain = $ir['maxenergy'] / $rand; $bgain = $ir['maxenergy'] / $brand; if($ir['karma'] > 39) { echo "You prayed for energy and you were blessed with $ggain energy"; $db->query("UPDATE `users` SET `energy` = LEAST(`energy` + $ggain, `maxhenergy`) WHERE `userid` = $userid"); } elseif($ir['karma'] < 40) { echo "You prayed for energy and you were blessed with $bgain energy"; $db->query("UPDATE `users` SET `energy` = LEAST(`energy` + $bgain, `maxhenergy`) WHERE `userid` = $userid"); } } elseif($_POST['pray'] === 'money') { $money = rand (10,50); echo "You prayed for money and you were blessed with " . money_formatter($money) . ""; $db->query("UPDATE `users` SET `money` = `money` + $money WHERE `userid` = $userid"); } } elseif(!empty($_POST['user1'])) { $a = $db->query("SELECT `karma` FROM `users` WHERE `userid` = $friend"); $b = $db->fetch_row($a); if($_POST['pray'] === 'hp') { $hpgain = $b['karma'] * 5; echo "You prayed for a healing and you were blessed with + " . $total . "% of your health"; $db->query("UPDATE `users` SET `hp` = LEAST(`hp` + $hpgain, `maxhp`) WHERE `userid` = $friend"); } elseif($_POST['pray'] === 'energy') { $grand = rand(1,3); $brand = rand(5,10); $ggain = $ir['maxenergy'] / $rand; $bgain = $ir['maxenergy'] / $brand; if($b['karma'] > 39) { echo "You prayed for energy and you were blessed with $ggain energy"; $db->query("UPDATE `users` SET `energy` = LEAST(`energy` + $ggain, `maxhenergy`) WHERE `userid` = $friend"); } if($b['karma'] < 40) { echo "You prayed for energy and you were blessed with $bgain energy"; $db->query("UPDATE `users` SET `energy` = LEAST(`energy` + $bgain, `maxhenergy`) WHERE `userid` = $friend"); } } elseif($_POST['pray'] === 'money') { $money = rand (10,50); echo "You prayed for money and you were blessed with " . money_formatter($money) . ""; $db->query("UPDATE `users` SET `money` = `money` + $money WHERE `userid` = $friend"); } $h->endpage(); } } And in header.php <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'></script> <script> $(document).ready(function (){ $('state').change(function() { if ($(this).val() != 'notinoz') { $('#foo').show(); }else{ $('#foo').hide(); } }); }); </script> First the java isn't hiding the contact list. Second, hp is going negative?????? Doesn't make sense because hp ++++++ ANYTHING equals a GAIN >.< Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted May 13, 2016 Share Posted May 13, 2016 Not the greatest at JS, so can't really help there. However, as a dirty trick with the HP, you could just multiply added health by negative one. If its just an arithmetic error, it should end up going positive. Just my quick two-cents. :D Quote Link to comment Share on other sites More sharing options...
boionfire81 Posted May 13, 2016 Author Share Posted May 13, 2016 it printed up as - 167 Quote Link to comment Share on other sites More sharing options...
sniko Posted May 14, 2016 Share Posted May 14, 2016 First the java isn't hiding the contact list. Second, hp is going negative?????? Doesn't make sense because hp ++++++ ANYTHING equals a GAIN >.< 1) You mean JavaScript (Java and JavaScript are totally different) 2) The implementation is terrible To fix 1) Create a div around the contact list section. Name it something meaningful (foo isn't contextually meaningful). Then hide it with CSS for the initial page load. 2) Add JavaScript to detect the option change, and show the contact list div https://jsfiddle.net/ot9ec2LL/ 1 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.