function transferMoney() { // Globals global $MySelf; global $DB; global $TIMEMARK; $MyCredits = getCredits($MySelf->getID()); // Can we afford even the most basic transactions? if (!numericCheckBool($MyCredits, 0)) { makeNotice("You can not afford any transaction.", "warning", "Out of money", "index.php?action=manageWallet", "[cancel]"); } // Did we supply an isk amount at all? if ($_POST[amount] == "") { makeNotice("You did not specify an ISK amount. Please go back, and try again.", "warning", "How much?", "index.php?action=manageWallet", "[cancel]"); } if (!is_numeric($_POST[amount])) { makeNotice("The frog looks at you and your cheque with the amount of \"" . $_POST[amount] . "\". The frog is unsure how much ISK that is and instead decides to lick your face in a friendly manner, then it closes the teller and goes for lunch.", "warning", "Huh?"); } // Check for sanity. if (!numericCheckBool($_POST[to], 0)) { makeNotice("The supplied reciver is not valid.", "warning", "Invalid ID", "index.php?action=manageWallet", "[cancel]"); } if (!numericCheckBool($_POST[amount], 0)) { makeNotice("You need to specify a positive ISK value.", "error", "Invalid amount", "index.php?action=manageWallet", "[cancel]"); } if (!numericCheckBool($_POST[amount], 0, $MyCredits)) { makeNotice("You can not afford this transaction.", "warning", "Out of money", "index.php?action=manageWallet", "[cancel]"); } // Ok so now we know: The reciver is valid, the sender has enough money. $from = "<br><br>From: " . ucfirst($MySelf->getUsername()); $to = "<br>To: " . ucfirst(idToUsername($_POST[to])); $amount = "<br>Amount: " . number_format($_POST[amount], 2) . " ISK"; $reason = "<br>Reason: " . $_POST[reason]; confirm("Please authorize this transaction:" . $from . $to . $amount . $reason); // Lets do it. $transaction = new transaction($_POST[to], 0, $_POST[amount]); $transaction->setReason("Cash transfer from " . ucfirst($MySelf->getUsername()) . " to " . ucfirst(idToUsername($_POST[to])) . ": " . $_POST[reason]); $transaction->isTransfer(true); $transaction->commit(); // Send'em back. makeNotice($amount . " has been transfered from your into " . ucfirst(idToUsername($_POST[to])) . " account.", "notice", "Cash transfered", "index.php?action=manageWallet", "[OK]"); }
function toggleLock() { global $MySelf; // Check the ID for validity. if (!numericCheckBool($_GET[id], 0)) { makeNotice("That run ID is invalid.", "error", "Invalid RUN"); } else { $ID = $_GET[id]; } // Only the owner of the run can do this. if (runSupervisor($ID) != $MySelf->getUsername()) { makeNotice("Only the supervisor of a run can lock and unlock his/her run.", "warning", "Unable to comply", "index.php?action=show&id={$_GET['id']}", "[Cancel]"); } // Determine what the user wants. switch ($_GET[state]) { // User wants to lock. case "lock": confirm("You are about to lock Mining Operation #{$ID}. No one will be able to join up until you choose to unlock it. Is that what you want?"); $bool = "1"; break; // User wants to unlock. // User wants to unlock. case "unlock": confirm("You are about to unlock Mining Operation #{$ID}. Everyone will be able to join up again until you choose to relock it. Is that what you want?"); $bool = "0"; break; // User wants to screw around. // User wants to screw around. default: makeNotice("I dont know what you want off me. I only know lock and unlock. Sorry.", "warning", "Ehh?"); } // Update the database! global $DB; $DB->query("UPDATE runs SET isLocked='{$bool}' WHERE id='{$ID}' LIMIT 1"); // Success? if ($DB->affectedRows != 1) { header("Location: index.php?action=show&id={$ID}"); } else { makeNotice("Unable to set the new locked status in the database. Be sure to run the correct sql schema!", "warning", "Cannot write to database."); } }
function requestPayout() { // Globals global $MySelf; global $DB; global $TIMEMARK; // How much overdraft are we allowed? $overdraft = 100 * 1000000; // 100m $overdraftlimit = false; // How much isk we got? $MyCredits = getCredits($MySelf->getID()); // Is this a number? if (!is_numeric($_POST[amount])) { makeNotice("The frog looks at you and your cheque with the amount of \"" . $_POST[amount] . "\". The frog is unsure how much ISK that is and instead decides to lick your face in a friendly manner, then it closes the teller and goes for lunch.", "warning", "Huh?"); } // We are requesting a POSITIVE amount, right? if (!numericCheckBool($_POST[amount], 0)) { makeNotice("You can only request positive amounts of ISK. If you want money, go work for it.", "notice", "This aint no charity", "index.php?action=manageWallet", "But i got women and children to feed..."); } // So, can we afford it? if ($overdraft <= 0 && !numericCheckBool($_POST[amount], 1, $MyCredits)) { makeNotice("You can only request a payment up to " . number_format($MyCredits) . " ISK. You requested " . number_format($_POST[amount]) . " ISK. Thats " . number_format($_POST[amount] - $MyCredits, 2) . " ISK more than you can afford.", "warning", "Too big of a payout.", "index.php?action=manageWallet", "[Cancel]"); } // Allow an overdraft, but not too much if ($overdraft > 0 && $overdraftlimit && !numericCheckBool($_POST[amount], 1, $MyCredits + $overdraft)) { makeNotice("You can only request a payment up to " . number_format($MyCredits + $overdraft) . " ISK. You requested " . number_format($_POST[amount]) . " ISK. Thats " . number_format($_POST[amount] - ($MyCredits + $overdraft), 2) . " ISK more than you are allowed.", "warning", "Too big of a payout.", "index.php?action=manageWallet", "[Cancel]"); } // We sure? confirm("Please confirm your payout request of " . number_format($_POST[amount], 2) . " ISK."); // Ok, do it. $DB->query("INSERT INTO payoutRequests (time, applicant, amount) VALUES (?,?,?)", array($TIMEMARK, $MySelf->getID(), $_POST[amount])); if ($DB->affectedRows() == 1) { mailUser("We are notifying you that " . $MySelf->getUsername() . " has requested a payout of " . number_format($_POST[amount], 2) . " ISK", "WHB Payout Requested", "isAccountant"); makeNotice("You request has been logged. An accountant will soon honor your request.", "notice", "Request logged", "index.php?action=manageWallet", "[OK]"); } else { makeNotice("Internal Error! Unable to record your request into the database! Inform the admin!", "error", "Internal Error!", "index.php?action=manageWallet", "[cancel]"); } }
function addRun() { // We need some more globals. global $DB; global $ORENAMES; global $DBORE; global $ORENAMES_STR; global $MySelf; global $TIMEMARK; // Set the userID $userID = $MySelf->getID(); // Are we permitted to create a new run? if (!$MySelf->canCreateRun()) { makeNotice("You are not allowed to create a mining op!", "error", "forbidden"); } if ($_POST[startnow]) { $starttime = $TIMEMARK; } else { // Startting time goodness. $myTime = array("day" => "{$_POST['ST_day']}", "month" => "{$_POST['ST_month']}", "year" => "{$_POST['ST_year']}", "hour" => "{$_POST['ST_hour']}", "minute" => "{$_POST['ST_minute']}"); $starttime = humanTime("toUnix", $myTime); } // Having fun with checkboxes, yet again. if ($_POST[isOfficial] == "on") { $official = true; } else { $official = false; } // We using either predefined locations. if (empty($_POST[location])) { $location = $_POST[locations]; } else { $location = $_POST[location]; } if (empty($location)) { makeNotice("You need to specify the location of the Mining Operation!", "notice", "Where again?", "index.php?action=newrun", "[Cancel]"); } // Supervisor if ($MySelf->isOfficial()) { if (empty($_POST[supervisor])) { // Is official, but no one named! makeNotice("You need to name someone as the supervisor for this run!", "warning", "Missing Information", "index.php?action=newrun", "[Cancel]"); } else { // Grab ID of named supervisor. $supervisor = usernameToID(sanitize($_POST[supervisor])); } } else { // Non official, use own ID $supervisor = $MySelf->getID(); } // Corp tax if ($MySelf->isOfficial()) { if ($_POST[corpkeeps] > 100 || $_POST[corpkeeps] < 0 || !numericCheckBool($_POST[corpkeeps])) { makeNotice("The corporation can not keep more than 100% and most certainly wont pay out more than the gross worth (values below 0%). A value of " . $_POST[corpkeeps] . " is really not valid.", "warning", "Out of range", "index.php?action=newrun", "[Cancel]"); } else { $tax = $_POST[corpkeeps]; } } else { $tax = "0"; } /* // Get the current ore-values. $oreValue = $DB->getCol("SELECT max(time) FROM orevalues"); $oreValue = $oreValue[0]; */ //Edit Starts Here $shipValue = $DB->getCol("SELECT max(id) FROM shipvalues"); $shipValue = $shipValue[0]; $optype = $_REQUEST[optype]; //Edit Ends Here $DB->query("insert into runs (location, starttime, supervisor, corpkeeps, isOfficial, oreGlue, shipGlue,optype) " . "values (?,?,?,?,?,?,?,?)", array("{$location}", "{$starttime}", "{$supervisor}", $tax, $official, "{$TIMEMARK}", $shipValue, "{$optype}")); // Check for success. if ($DB->affectedRows() != 1) { makeNotice("DB Error: Could not add run to database!", "error", "DB Error"); } // Now update the "required" ore values. foreach ($DBORE as $ORE) { // But the ore needs to be set, valid (numeric) and must be activated. if (isset($_POST[$ORE]) && is_numeric($_POST[$ORE]) && getOreSettings($ORE) == true && $_POST[$ORE] > 0) { $DB->query("UPDATE runs SET " . $ORE . "Wanted='" . $_POST[$ORE] . "' WHERE {$starttime}='{$starttime}'"); } } // And return the user to the run-list overview page. makeNotice("The new Mining Operation has been created in the database.", "notice", "Mining Operation created", "index.php?action=list", "[OK]"); }