Ejemplo n.º 1
0
function leaveRun()
{
    // Access the globals.
    global $DB;
    global $TIMEMARK;
    global $MySelf;
    $runid = $_GET[id];
    $userid = $MySelf->getID();
    // Are we actually still in this run?
    if (userInRun($userid, $runid) == "none") {
        makeNotice("You can not leave a run you are currently not a part of.", "warning", "Not you run.", "index.php?action=show&id={$runid}", "[cancel]");
    }
    // Is $runid truly an integer?
    numericCheck($runid);
    // Oh yeah?
    if (runIsLocked($runid)) {
        confirm("Do you really want to leave mining operation #{$runid} ?<br><br>Careful: This operation has been locked by " . runSupervisor($runid, true) . ". You can not rejoin the operation unless its unlocked again.");
    } else {
        confirm("Do you really want to leave mining operation #{$runid} ?");
    }
    // Did the run start yet? If not, delete the request.
    $runStart = $DB->getCol("SELECT starttime FROM runs WHERE id='{$runid}' LIMIT 1");
    if ($TIMEMARK < $runStart[0]) {
        // Event not started yet. Delete.
        $DB->query("DELETE FROM joinups WHERE run='{$runid}' AND userid='{$userid}'");
    } else {
        // Event started, just mark inactive.
        $DB->query("update joinups set parted = '{$TIMEMARK}' where run = '{$runid}' and userid = '{$userid}' and parted IS NULL");
    }
    makeNotice("You have left the run.", "notice", "You left the Op.", "index.php?action=show&id={$runid}", "[OK]");
}
Ejemplo n.º 2
0
function joinRun()
{
    // Access the globals.
    global $DB;
    global $TIMEMARK;
    global $MySelf;
    $runid = (int) $_GET[id];
    $userid = $MySelf->GetID();
    // Are we allowed to join runs?
    if (!$MySelf->canJoinRun()) {
        makeNotice("You are not allowed to join mining operations. Please ask your CEO to unblock your account.", "error", "Forbidden");
    }
    // Is $runid truly an integer?
    numericCheck($runid);
    // Is the run still open?
    if (!miningRunOpen($runid)) {
        makeNotice("This mining operation has been closed!", "warning", "Can not join", "index.php?action=show&id={$runid}");
    }
    // Are we banned from the run?
    $State = $DB->getCol("SELECT status FROM joinups WHERE run='{$runid}' and userid='" . $MySelf->getID() . "'ORDER BY id DESC LIMIT 1");
    $State = $State[0];
    switch ($State) {
        case "2":
            // We have been kicked.
            $kicked = true;
            break;
        case "3":
            // We have been banned!
            if (runSupervisor($runid) == $MySelf->getUsername() || $MySelf->isOfficial()) {
                $banned = "You have been banned from this operation but your rank overrides this block.";
            } else {
                makeNotice("You have been banned from this operation. You can not rejoin it.", "warning", "You are banned.", "index.php?action=list", "[cancel]");
            }
            break;
    }
    // Is the run locked?
    if (runIsLocked($runid)) {
        makeNotice("You can not join this run as this run has been locked by " . runSupervisor($runid) . ".", "notice", "Mining operation locked", "index.php?action=show&id={$runid}", "[Cancel]");
    }
    // Join with shiptype.
    if (!$_GET['confirmed-ship']) {
        $table = new table(1, true);
        $table->addHeader(">> Join an Operation");
        // If we have been kicked, inform the user.
        if ($kicked) {
            $table->addRow("#880000");
            $table->addCol("Warning: You have been recently kicked. Please check if you are allowed to rejoin to avoid a ban.");
        }
        // If we are banned by an official, inform the user.
        if ($banned) {
            $table->addRow("#880000");
            $table->addCol($banned);
        }
        $table->addRow();
        $table->addCol($form . "Join the Operation in " . ucfirst(getLocationOfRun($runid)) . ".");
        $table->addRow();
        $table->addCol("You have requested to join mining operation #{$runid}. Please choose the shipclass " . "you are going to join up with.");
        $table->addRow();
        $table->addCol("Shiptype: " . $hiddenstuff . joinAs(), array("align" => "center"));
        $table->addRow("#444455");
        $table->addCol("<input type=\"submit\" name=\"submit\" value=\"Join mining operation\">" . $form_end, array("align" => "center"));
        $page = "<h2>Join an Operation.</h2>";
        $page .= "<form action=\"index.php\" method=\"GET\">";
        $page .= "<input type=\"hidden\" name=\"id\" value=\"{$runid}\">";
        $page .= "<input type=\"hidden\" name=\"confirmed-ship\" value=\"true\">";
        $page .= "<input type=\"hidden\" name=\"confirmed\" value=\"true\">";
        $page .= "<input type=\"hidden\" name=\"multiple\" value=\"true\">";
        $page .= "<input type=\"hidden\" name=\"action\" value=\"joinrun\">";
        $page .= $table->flush();
        $page .= "</form>";
        return $page;
    }
    // Sanitize the Shiptype.
    global $SHIPTYPES;
    $ShiptypesCount = count($SHIPTYPES);
    if (!numericCheck($_GET[shiptype], 0, $ShiptypesCount)) {
        makeNotice("The shiptype you tried to join up with is invalid, please go back, and try again.", "warning", "Shiptype invalid!", "index.php?action=show&id={$_GET['id']}");
    } else {
        $shiptype = $_GET[shiptype];
    }
    // Warn the user if he is already in another run.
    $joinedothers = $DB->query("select run from joinups where userid='{$userid}' and parted IS NULL order by run");
    // And check for that just now.
    if ($joinedothers->numRows() > 0) {
        confirm("You joined another mining operation already!<br>Are you sure you want to join multiple runs at the same time?");
    }
    // Get the correct time to join (in case event hasnt started yet)
    $startOfRun = $DB->getCol("SELECT starttime FROM runs WHERE id='{$runid}' LIMIT 1");
    if ($startOfRun[0] > $TIMEMARK) {
        $time = $startOfRun[0];
    } else {
        $time = $TIMEMARK;
    }
    // Dont allow him to join the same mining run twice.
    if (userInRun($MySelf->getID(), "{$runid}") == "none") {
        // Mark user as joined.
        $DB->query("insert into joinups (userid, run, joined, shiptype) values (?,?,?,?)", array("{$userid}", "{$runid}", "{$time}", "{$shiptype}"));
        // Forward user to his joined run.
        makeNotice("You have joined the Mining Operation.", "notice", "Joining confirmed", "index.php?action=show&id={$id}");
    } else {
        // Hes already in that run.
        makeNotice("You are already in that mining run!", "notice", "Joinup not confirmed", "index.php?action=show&id={$id}");
    }
}
Ejemplo n.º 3
0
             $join = "You are not allowed to join operations.";
         }
     } else {
         $join = ucfirst(runSupervisor($ID)) . " has locked this run.";
     }
 } else {
     // User IS in this run.
     // Are we allowed to haul?
     if ($row['endtime'] == "" && $MySelf->canAddHaul()) {
         $addHaul .= " [<a href=\"index.php?action=addhaul&id={$ID}\">Haul</a>] ";
     } else {
         $addHaul .= false;
     }
     // Run-Owner: Lock/Unlock run (to dissallow people joining)
     if (runSupervisor($row['id']) == $MySelf->getUsername()) {
         if (runIsLocked($row['id'])) {
             $lock .= " [<a href=\"index.php?action=lockrun&id={$row['id']}&state=unlock\">Unlock Run</a>] ";
         } else {
             $lock .= " [<a href=\"index.php?action=lockrun&id={$row['id']}&state=lock\">Lock Run</a>] ";
         }
     }
     // IS in the run, give option to leave.
     $add .= " [<a href=\"index.php?action=partrun&id={$ID}\">Leave Op</a>] [<a href=\"index.php?action=cans\">Manage Cans</a>]";
     //$add .= " [Leave Op Disabled] [<a href=\"index.php?action=cans\">Manage Cans</a>]";
     // Make the charity button.
     $charityFlag = $DB->getCol("SELECT charity FROM joinups WHERE run='{$ID}' AND userid='" . $MySelf->getID() . "' AND parted IS NULL LIMIT 1");
     if ($charityFlag[0]) {
         $charity = " [<a href=\"index.php?action=toggleCharity&id={$ID}\">Unset Charity Flag</a>]";
     } else {
         $charity = " [<a href=\"index.php?action=toggleCharity&id={$ID}\">Set Charity Flag</a>]";
     }