Beispiel #1
1
function addEvent()
{
    // Arr, we need some globals!
    global $MySelf;
    global $TIMEMARK;
    global $DB;
    // is the events module active?
    if (!getConfig("events")) {
        makeNotice("The admin has deactivated the events module.", "warning", "Module not active");
    }
    // Are we allowed to add an Event?
    if (!$MySelf->canEditEvents()) {
        makeNotice("You are not allowed to add events.", "error", "Forbidden");
    }
    // Create new tables, define standard mode.
    $table = new table(2, true);
    $mode = array("align" => "right", "valign" => "top");
    // Table header
    $table->addHeader(">> Announce an event");
    // Row: Short Description
    $table->addRow();
    $table->addCol("Short description:", $mode);
    $table->addCol("<input type=\"text\" name=\"sdescr\" size=\"50\" maxlength=\"50\">");
    // Row: Flag Officer
    $table->addRow();
    $table->addCol("Flag officer:", $mode);
    // Fetch all senior officers from the database
    $allSeniors = $DB->query("SELECT DISTINCT username, id FROM users WHERE isOfficial='1' AND deleted='0' ORDER BY username");
    // Loop through them.
    while ($senior = $allSeniors->fetchRow()) {
        // Pre-select ourselves.
        if ($senior[id] == $MySelf->getID()) {
            // Ourselves.
            $pdm .= "<option value=\"" . $senior[id] . "\" SELECTED>" . ucfirst($senior[username]) . "</option>";
        } else {
            // Some other senior officer.
            $pdm .= "<option value=\"" . $senior[id] . "\">" . ucfirst($senior[username]) . "</option>";
        }
    }
    // We dont need to check if we had any user matches at all: At least the user
    // Viewing this page is eligible.
    $pdm = "<select name=\"officer\">" . $pdm . "</select>";
    $table->addCol($pdm . " -or- <input type=\"text\" name=\"officer2\" maxlength=\"50\">");
    // We need $pdm soon enough again, clear it.
    unset($pdm);
    // Row: Location
    $table->addRow();
    $table->addCol("Location:", $mode);
    // Query all recent locations.
    $allLocations = $DB->query("SELECT DISTINCT system FROM events ORDER BY system");
    // Loop through them.
    while ($loc = $allLocations->fetchRow()) {
        // Add to dropdown.
        $pdm .= "<option>" . ucfirst($loc[system]) . "</option>";
        $haveLocations = true;
    }
    // If we never had an event, we wont show the recent locations dropdown menu.
    if ($haveLocations) {
        // Have recent locations
        $pdm = "<select name=\"system\">" . $pdm . "</select>";
        $table->addCol($pdm . " -or- <input type=\"text\" name=\"system2\" maxlength=\"50\">");
    } else {
        // No recent locations.
        $table->addCol("<input type=\"text\" name=\"system\" maxlength=\"50\">");
    }
    // We need $pdm soon enough again, clear it.
    unset($pdm);
    // Row: Security
    $table->addRow();
    $table->addCol("Security:", $mode);
    for ($i = 10; $i >= 0; $i--) {
        $security = number_format($i / 10, 1);
        $pdm .= "<option value=\"" . $security . "\">" . $security . "</option>";
    }
    $table->addCol("<select name=\"security\">" . $pdm . "</select>");
    // Row: Mission Type
    $table->addRow();
    $table->addCol("Mission Type:", $mode);
    $table->addCol("<select name=\"type\">" . "<option value=\"Mining\">Mining</option>" . "<option value=\"Mission\">Missions</option>" . "<option value=\"Kill\">Killing</option>" . "<option value=\"Transport\">Transporting</option>" . "<option value=\"PK\">Player Killing</option>" . "</select>");
    // Row: Starttime
    $table->addRow();
    $table->addCol("Starttime:", $mode);
    // Get a time-array and do the human friendly part.
    // Funnies: We always want to use "00" as the minute, and always at the start of the
    // NEXT hour.
    $times = humanTime("toHuman", $TIMEMARK + 3600);
    $happy_starting_time .= "<input type=\"text\" name=\"ST_day\"    size=\"4\" maxlength=\"20\" value=\"" . $times[day] . "\">.";
    $happy_starting_time .= "<input type=\"text\" name=\"ST_month\"  size=\"4\" maxlength=\"2\" value=\"" . $times[month] . "\">.";
    $happy_starting_time .= "<input type=\"text\" name=\"ST_year\"   size=\"6\" maxlength=\"4\" value=\"" . $times[year] . "\">";
    $happy_starting_time .= "&nbsp;&nbsp;";
    $happy_starting_time .= "<input type=\"text\" name=\"ST_hour\"   size=\"4\" maxlength=\"2\" value=\"" . date("H", $TIMEMARK + 3600) . "\">:";
    $happy_starting_time .= "<input type=\"text\" name=\"ST_minute\" size=\"4\" maxlength=\"2\" value=\"00\">";
    $table->addCol($happy_starting_time);
    // Info for the startime
    $table->addRow();
    $table->addCol("");
    $table->addCol("(day.month.year hour:minute)");
    // Row: Expected Duration
    $table->addRow();
    $table->addCol("Expected Duration:", $mode);
    $table->addCol("<input type=\"text\" name=\"dur\" maxlength=\"20\" value=\"2 hours\">");
    // Row: Difficulty
    $table->addRow();
    $table->addCol("Difficulty:", $mode);
    $difficulty = "<option value=\"0\">No risk involved</option>";
    $difficulty .= "<option value=\"1\">Minimal risk</option>";
    $difficulty .= "<option value=\"2\">moderate risk</option>";
    $difficulty .= "<option value=\"3\">above average risk</option>";
    $difficulty .= "<option value=\"4\">extreme risk</option>";
    $difficulty .= "<option value=\"5\">No survivors expected</option>";
    $table->addCol("<select name=\"difficulty\">" . $difficulty . "</select>");
    // Row: Payment
    $table->addRow();
    $table->addCol("Payment:", $mode);
    $table->addCol("<input type=\"text\" name=\"payment\" maxlength=\"20\" value=\"0\">");
    // Row: Collateral
    $table->addRow();
    $table->addCol("Collateral:", $mode);
    $table->addCol("<input type=\"text\" name=\"collateral\" value=\"0\">");
    // Row: Notes
    $table->addRow();
    $table->addCol("Notes:", $mode);
    $table->addCol("<textarea name=\"notes\" rows=\"10\" cols=\"50\"></textarea>");
    // Row: Shipt types needed
    $table->addRow();
    $table->addCol("Ship types needed", array("colspan" => 2));
    $table->addRow();
    $table->addCol("Shuttles");
    $table->addCol("<input type=\"checkbox\" name=\"shuttles\">");
    $table->addRow();
    $table->addCol("Frigates");
    $table->addCol("<input type=\"checkbox\" name=\"frigates\">");
    $table->addRow();
    $table->addCol("Destroyers");
    $table->addCol("<input type=\"checkbox\" name=\"destroyers\">");
    $table->addRow();
    $table->addCol("Cruisers");
    $table->addCol("<input type=\"checkbox\" name=\"cruisers\">");
    $table->addRow();
    $table->addCol("Battlecruisers");
    $table->addCol("<input type=\"checkbox\" name=\"bcruiser\">");
    $table->addRow();
    $table->addCol("Strategic Cruisers");
    $table->addCol("<input type=\"checkbox\" name=\"scruiser\">");
    $table->addRow();
    $table->addCol("Battleships");
    $table->addCol("<input type=\"checkbox\" name=\"bship\">");
    $table->addRow();
    $table->addCol("Dreadnoughts");
    $table->addCol("<input type=\"checkbox\" name=\"dread\">");
    $table->addRow();
    $table->addCol("Carriers");
    $table->addCol("<input type=\"checkbox\" name=\"carrier\">");
    $table->addRow();
    $table->addCol("Titans");
    $table->addCol("<input type=\"checkbox\" name=\"titan\">");
    $table->addRow();
    $table->addCol("Mining Barges");
    $table->addCol("<input type=\"checkbox\" name=\"barges\">");
    $table->addRow();
    $table->addCol("Industrial Ships");
    $table->addCol("<input type=\"checkbox\" name=\"indies\">");
    $table->addRow();
    $table->addCol("Freighters");
    $table->addCol("<input type=\"checkbox\" name=\"freighter\">");
    $table->addRow();
    $table->addCol("Jump Freighters");
    $table->addCol("<input type=\"checkbox\" name=\"jfreighter\">");
    $table->addRow();
    $table->addCol("Exhumers");
    $table->addCol("<input type=\"checkbox\" name=\"exhumer\">");
    // Submit button
    $form_end .= "<input type=\"submit\" name=\"submit\" value=\"Announce this event\">";
    $form_end .= "<input type=\"hidden\" name=\"action\" value=\"addevent\">";
    $form_end .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $table->addHeaderCentered($form_end, array("align" => "center", "colspan" => 2));
    return "<h2>Add event</h2><form action=\"index.php\" method=\"post\">" . $table->flush() . "</form>";
}
Beispiel #2
1
function makeLoginPage($user = false)
{
    // We need global Variables.
    global $VERSION;
    global $SITENAME;
    global $IGB;
    global $IS_DEMO;
    global $IS_BETA;
    global $DB;
    global $IGB_VISUAL;
    if ($IGB && $IGB_VISUAL) {
        $login = new table(3, true);
    } else {
        $login = new table(3, true, "width=\"400\"", "align=\"center\"");
    }
    $peeps = $DB->getCol("SELECT COUNT(id) FROM users");
    if ($peeps[0] == 0) {
        header("Location: index.php?auth=requestaccount&admin=true");
    }
    $login->addHeader(">> Welcome to {$VERSION}.");
    $login->addRow("#060622");
    $login->addCol($SITENAME, array("colspan" => 3, "align" => "center", "bold" => true));
    if ($user) {
        if ($user == "__invalidchar") {
            $login->addRow("redish");
            $login->addCol("Only characters a-z, A-Z and 0-9 are allowed. " . array("bold" => "true", "colspan" => 3));
        } else {
            if (isset($_SESSION['testauth'])) {
                $login->addRow();
                $login->addCol("Please select the character you wish to login as.", array("colspan" => 3));
            } else {
                $login->addRow("redish");
                $login->addCol("Your supplied credentials are invalid, please check and try again. " . "If you cannot remember your password use the Password Recovery link below.", array("bold" => "true", "colspan" => 3));
            }
        }
    }
    // Show login info for demo.
    if ($IS_DEMO) {
        $login->addRow("#006600");
        $login->addCol("This installation of MiningBuddy runs in demo mode. Login with username demo, password demo. If you get kicked out, someone else logged in with the same account.", array("colspan" => 3, "align" => "center", "bold" => true));
    }
    global $BLESSED;
    if ($BLESSED == true) {
        $login->addRow("#330000");
        $login->addCol("Using a superior hosted slot.", array("colspan" => 3, "align" => "center", "bold" => true));
    }
    // Beta Warning
    if ($IS_BETA) {
        $login->addRow("#904000");
        $login->addCol("-beta version-", array("colspan" => 3, "align" => "center", "bold" => true));
    }
    // User has logged in, but we need a character name.
    if (!isset($_SESSION[testauth])) {
        $login->addRow();
        $login->addCol("Username:"******"<input type=\"text\" name=\"username\" value=\"{$EVE_Charname}\" maxlength=\"30\">");
        } else {
            $login->addCol("<input type=\"text\" name=\"username\" value=\"" . stripcslashes($user) . "\" maxlength=\"30\">");
        }
        $login->addCol("<img src=\"./images/keys.png\">", array("rowspan" => "2"));
        $login->addRow();
        $login->addCol("Password:"******"<input type=\"password\" name=\"password\" maxlength=\"80\">", array("colspan" => "2"));
        $login->addRow("#060622");
        $login->addCol("Please login with your credentials. If you are in need of an account, request an account below and ask your CEO to activate it for you.", array("colspan" => "3", "align" => "center"));
    } else {
        $login->addRow();
        $login->addCol("Character:");
        global $TEST_AUTH;
        $eveApiProxyUrl = "https://auth.pleaseignore.com/api/1.0/eveapi/?apikey={$TEST_AUTH}&userid=" . $_SESSION[testauth][id];
        $return = file_get_contents($eveApiProxyUrl);
        $obj = json_decode($return, TRUE);
        $count = 0;
        $select = "<select name=\"username\" >";
        $array = array();
        foreach ($obj[keys] as $key) {
            $eveApiProxyUrl = "https://auth.pleaseignore.com/api/1.0/eveapi/account/Characters.xml.aspx?apikey={$TEST_AUTH}&userid=" . $key[api_user_id];
            $return = file_get_contents($eveApiProxyUrl);
            try {
                $chars = new SimpleXMLElement($return);
            } catch (Exception $ex) {
                continue;
            }
            foreach ($chars->result[0]->rowset[0] as $row) {
                $character = (string) $row[name];
                if ($row['corporationName'] != "B0rthole" || in_array($character, $array)) {
                    continue;
                }
                if ($character == $user) {
                    $selected = "selected";
                }
                $select .= "<option {$selected} value='{$character}'>{$character}</option>";
                $array[] = $character;
                $count++;
            }
        }
        //var_dump($array);
        $select .= "</select>";
        $login->addCol($select, array("colspan" => "2"));
        if ($count == 0) {
            session_destroy();
            makenotice("You do not belong here. Leave at once!", "warning", "ACCESS DENIED");
            die;
        }
        //file_put_contents($_SESSION[testauth][id].".xml",print_r($list,true));
    }
    if ($IGB && $IGB_VISUAL) {
        $login->addHeaderCentered("<input type=\"submit\" name=\"login\" value=\"login\">");
    } else {
        $login->addHeaderCentered("<input type=\"image\" name=\"login\" value=\"login\" src=\"./images/login.png\">");
    }
    $login->addRow("#060622");
    $login->addCol("<a href=\"index.php?auth=lostpass\">lost password</a>");
    /*
    $login->addCol("<a href=\"index.php?auth=requestaccount\">request account</a>", array (
    	"align" => "right",
    	"colspan" => "2"
    ));
    */
    $login->addCol("", array("colspan" => "2"));
    $page = "<br><br><br>";
    if (strstr($_SERVER[QUERY_STRING], "switch")) {
        $page .= "<form action=\"index.php?\" method=\"post\">";
    } else {
        $page .= "<form action=\"index.php?{$_SERVER['QUERY_STRING']}\" method=\"post\">";
    }
    // Add special hidden forms for stupid browsers.
    $browserinfo = new BrowserInfo();
    if (ereg("MSIE", $_SERVER[HTTP_USER_AGENT]) or $browserinfo->getBrowser() == BrowserInfo::BROWSER_FIREFOX && $browserinfo->getVersion() >= 4) {
        $page .= "<input type=\"hidden\" name=\"login\" value=\"login\">";
    }
    $page .= $login->flush();
    //$page .= "<input type='hidden' name='redirect' value='$_SERVER[QUERY_STRING]'";
    $page .= "</form><br><br><br>";
    $html = new html();
    $html->addBody($page);
    die($html->flush());
}
function makeRequestAccountPage($failedFastLogin = false)
{
    // We need global Variables.
    global $VERSION;
    global $SITENAME;
    global $IGB;
    global $IGB_VISUAL;
    if ($IGB && $IGB_VISUAL) {
        $table = new table(2, true);
    } else {
        $table = new table(2, true, "width=\"500\"", "align=\"center\"");
    }
    if ($_GET[admin] == true) {
        $table->addHeader(">> Create initial Superadmin account");
    } else {
        $table->addHeader(">> Request an account");
    }
    // Trust, INC.
    if ($failedFastLogin) {
        // This happens when someone allowed fast logins(!) and the user does not exist.
        global $EVE_Charname;
        $table->addRow("#660000");
        $table->addCol("Fast login failed; Username \"" . ucfirst($EVE_Charname) . "\" does not exist.", array("colspan" => 2, "align" => "center"));
    }
    $table->addRow("#060622");
    if ($_GET[admin] == true) {
        $table->addCol("Fill out the form below to create the initial superadmin account. " . "This account will have all priviledges - so keep the login credentials safe! " . "Your password will be randomly generated and revealed to you just once, " . "so write it down or copy it elsewhere. You will have the option to " . "change your password on your first login.", array("colspan" => 2));
    } else {
        $table->addCol("Fill out the form below to apply for a new account. After you requested " . "an account you will receive an email with an activation link. Finally, your " . "CEO has to approve of your account, after which you will receive your initial password.", array("colspan" => 2));
    }
    $table->addRow();
    $table->addCol("Character Name:");
    // Trust, INC.
    global $EVE_Charname;
    if ($EVE_Charname) {
        $table->addCol("<input type=\"text\" name=\"username\" value=\"{$EVE_Charname}\" maxlength=\"30\">");
    } else {
        $table->addCol("<input type=\"text\" name=\"username\" maxlength=\"30\">");
    }
    $table->addRow();
    $table->addCol("Your valid eMail:");
    $table->addCol("<input type=\"text\" name=\"email\" maxlength=\"70\">");
    if ($_GET[admin] == false) {
        $table->addHeaderCentered("<input type=\"submit\" name=\"login\" value=\"request account\">");
        $table->addRow("#060622");
        $table->addCol("[<a href=\"index.php\">Cancel request</a>]", array("colspan" => 2));
    } else {
        $table->addHeaderCentered("<input type=\"submit\" name=\"login\" value=\"Create Superadmin\">");
    }
    $page = "<br><br>";
    $page .= "<form action=\"index.php\" method=\"post\">";
    $page .= "<input type=\"hidden\" name=\"action\" value=\"requestaccount\">";
    $page .= $table->flush();
    $page .= "</form><br><br>";
    // Print it, and die (special case: login does not get beautified.)
    $html = new html();
    $html->addBody($page);
    die($html->flush());
}
Beispiel #4
0
function makeAddUserForm()
{
    // Are we allowed to?
    global $MySelf;
    if (!$MySelf->canAddUser()) {
        makeNotice("You are not authorized to do that!", "error", "Forbidden");
    }
    // Suggest a user password.
    $suggestedPassword = crypt(base64_encode(rand(11111, 99999)), "8ewf7tg2k,leduj");
    $table = new table(2, true);
    $table->addHeader(">> Add a new user");
    $table->addRow("#060622");
    $table->addCol("You can manually add a new user with this form. But use this only " . "as a last resort, for example, if your server can not send eMails. " . "Always let the user request an account. This form was supposed to be " . "removed, but complains from the users kept it alive.", array("colspan" => 2));
    $table->addRow();
    $table->addCol("Username:"******"<input type=\"text\" name=\"username\" maxlength=\"20\">");
    $table->addRow();
    $table->addCol("eMail:");
    $table->addCol("<input type=\"text\" name=\"email\">");
    $table->addRow();
    $table->addCol("Password:"******"<input type=\"password\" name=\"pass1\" value=\"{$suggestedPassword}\"> (Suggested: {$suggestedPassword})");
    $table->addRow();
    $table->addCol("Verify Password:"******"<input type=\"password\" name=\"pass2\" value=\"{$suggestedPassword}\">");
    $table->addHeaderCentered("<input type=\"submit\" name=\"create\" value=\"Add user to database\">");
    $page = "<h2>Add a new User</h2>";
    $page .= "<form action=\"index.php\" method=\"post\">";
    $page .= $table->flush();
    $page .= "<input type=\"hidden\" name=\"action\" value=\"newuser\">";
    $page .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $page .= "</form>";
    return $page;
}
Beispiel #5
0
function lotto_editLottery()
{
    // We need some globals
    global $MySelf;
    global $DB;
    $formDisable = "";
    if (lotto_getOpenDrawing()) {
        $formDisable = "disabled";
    }
    // is Lotto enabled at all?
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Deny access to non-lotto-officials.
    if (!$MySelf->isLottoOfficial()) {
        makeNotice("You are not allowed to do this!", "error", "Permission denied");
    }
    $table = new table(2, true);
    $table->addHeader(">> Open new drawing");
    $table->addRow();
    $table->addCol("Number of tickets in draw:");
    $table->addCol("<input type=\"text\" name=\"count\" " . $formDisable . " value=\"30\">");
    //	$newLotto = new table (2);
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" " . $formDisable . " value=\"open new drawing\">", array("bold" => true, "colspan" => 2));
    $html = "<h2>Lotto Administration</h2>";
    $html .= "<form action=\"index.php\" method=\"POST\">";
    $html .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $html .= "<input type=\"hidden\" name=\"action\" value=\"createDrawing\">";
    $html .= $table->flush();
    $html .= "</form>";
    if (lotto_getOpenDrawing()) {
        $html .= "[<a href=\"index.php?action=drawLotto\">Draw Winner</a>]";
    }
    return $html;
}
Beispiel #6
0
function editTemplate()
{
    global $DB;
    global $MySelf;
    // Are we allowed to?
    if (!$MySelf->isAdmin()) {
        makeNotice("Only an Administator can edit the sites templates.", "warning", "Access denied");
    }
    // No Identifier, no service
    if ($_POST[check]) {
        // We got the returning form, edit it.
        numericCheck($_POST[id], 0);
        $ID = $_POST[id];
        // Fetch the current template, see that its there.
        $test = $DB->query("SELECT identifier FROM templates WHERE id='{$ID}' LIMIT 1");
        if ($test->numRows() == 1) {
            // We got the template
            $template = sanitize($_POST[template]);
            $DB->query("UPDATE templates SET template='" . $template . "' WHERE id='{$ID}' LIMIT 1");
            // Check for success
            if ($DB->affectedRows() == 1) {
                // Success!
                header("Location: index.php?action=edittemplate&id={$ID}");
            } else {
                // Fail!
                makeNotice("There was a problem updating the template in the database!", "error", "Internal Error", "index.php?action=edittemplate&id={$ID}", "Cancel");
            }
        } else {
            // There is no such template
            makeNotice("There is no such template in the database!", "error", "Invalid Template!", "index.php?action=edittemplate&id={$ID}", "Cancel");
        }
    } elseif (empty($_GET[id])) {
        // No returning form, no identifier.
        header("Location: index.php?action=configuration");
    } else {
        $ID = $_GET[id];
    }
    // numericheck!
    numericCheck($ID, 0);
    $temp = $DB->getCol("SELECT template FROM templates WHERE id='{$ID}' LIMIT 1");
    $table = new table(1, true);
    $table->addHeader(">> Edit template");
    $table->addRow();
    $table->addCol("<center><textarea name=\"template\" rows=\"30\" cols=\"60\">" . $temp[0] . "</textarea></center>");
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Edit Template\">");
    $form1 = "<form action=\"index.php\" method=\"POST\">";
    $form2 = "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $form2 .= "<input type=\"hidden\" name=\"action\" value=\"editTemplate\">";
    $form2 .= "<input type=\"hidden\" name=\"id\" value=\"" . $ID . "\">";
    $form2 .= "</form>";
    $backlink = "<br><a href=\"index.php?action=configuration\">Back to configuration</a>";
    return "<h2>Edit the template</h2>" . $form1 . $table->flush() . $form2 . $backlink;
}
Beispiel #7
0
function makeLostPassForm()
{
    // We need some global vars again.
    global $IGB;
    global $SITENAME;
    global $IGB_VISUAL;
    if ($IGB && $IGB_VISUAL) {
        $table = new table(2, true);
    } else {
        $table = new table(2, true, "width=\"500\"", "align=\"center\"");
    }
    $table->addHeader(">> Request a new password");
    $table->addRow("#060622");
    $table->addCol("Fill out the form below to have a new password generated and sent to you registered eMail address.", array("colspan" => 2));
    $table->addRow();
    $table->addCol("Character Name:");
    // Trust, INC.
    global $EVE_Charname;
    if ($EVE_Charname) {
        $table->addCol("<input type=\"text\" name=\"username\" value=\"{$EVE_Charname}\" maxlength=\"30\">");
    } else {
        $table->addCol("<input type=\"text\" name=\"username\" maxlength=\"30\">");
    }
    $table->addRow();
    $table->addCol("Your valid eMail:");
    $table->addCol("<input type=\"text\" name=\"email\" maxlength=\"70\">");
    $table->addHeaderCentered("<input type=\"submit\" name=\"change\" value=\"Get Password\">");
    $table->addRow("#060622");
    $table->addCol("[<a href=\"index.php\">Cancel request</a>]", array("colspan" => 2));
    //	$page = "<h2>Lost password</h2>";
    $page = "<br><br>";
    $page .= "<form action=\"index.php\" method=\"post\">";
    $page .= "<input type=\"hidden\" name=\"action\" value=\"lostpass\">";
    $page .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $page .= $table->flush();
    $page .= "</form><br><br>";
    // Print it, and die (special case: login does not get beautified.)
    $html = new html();
    $html->addBody($page);
    die($html->flush());
}
Beispiel #8
0
 public function makeInfoTable()
 {
     $systemTable = new table(2, true);
     $systemTable->addHeader("System Information");
     if ($this->valid()) {
         $systemTable->addRow();
         $systemTable->addCol("System Name:");
         $systemTable->addCol("<a href=\"index.php?action=browse&mode=0&id=" . $this->solarSystemID . "\">" . $this->getName() . "</a> (<a target=\"_blank\" href=\"http://www.staticmapper.com/index.php?system=" . $this->getName() . "\">static mapper</a>) (<a target=\"_blank\" href=\"http://evemaps.dotlan.net/system/" . $this->getName() . "\">dotlan</a>)");
         $systemTable->addRow();
         $systemTable->addCol("Constellation:");
         $systemTable->addCol($this->getConstellation());
         $systemTable->addRow();
         $systemTable->addCol("Region:");
         $systemTable->addCol($this->getRegion());
         $systemTable->addRow();
         $systemTable->addCol("Security Status:");
         $systemTable->addCol($this->getSecurity());
     } else {
         $systemTable = new table(2, true);
         $systemTable->addHeader("System Information");
         $systemTable->addRow();
         $systemTable->addCol("System Name:");
         $systemTable->addCol(ucfirst($this->solarSystemName));
         $systemTable->addHeaderCentered("No EVE data has been found for this system in the database.");
     }
     return $systemTable->flush();
 }
Beispiel #9
0
function addhaulpage()
{
    // Needed globals
    global $DB;
    global $ORENAMES;
    global $DBORE;
    global $MySelf;
    // Some needed variables
    $USER = $MySelf->getID();
    $ORESETTINGS = getOreSettings();
    // Get the run the user is on.
    if (!empty($_GET[id])) {
        // We supplied our own ID.
        $ID = sanitize((int) $_GET[id]);
        numericCheck($_GET[id], 0);
    } else {
        // No idd supplied, get our own :P
        $ID = userInRun($MySelf->getID());
    }
    //   No ID found.
    if (!$ID) {
        makeNotice("Either you have selected an invalid run, you have not joined that run or it is no longer open.", "warning", "Unable to register your haul");
    }
    $OPTYPE = $DB->getCol("select optype from runs where id = {$ID}");
    $OPTYPE = $OPTYPE[0];
    // Create the table!
    $haulpage = new table(2, true);
    $mode = array("bold" => true, "align" => "right");
    $haulpage->addHeader(">> Register new Hauling");
    $haulpage->addRow();
    if ($OPTYPE == "Shopping") {
        $haulpage->addCol("Shopping for Op: #<a href=\"index.php?action=show&id={$ID}\">" . str_pad($ID, 5, "0", STR_PAD_LEFT) . "</a> Add *positive* values for purchases", array("align" => "left"));
    } else {
        $haulpage->addCol("Hauling for Op: #<a href=\"index.php?action=show&id={$ID}\">" . str_pad($ID, 5, "0", STR_PAD_LEFT) . "</a>", array("align" => "left"));
    }
    // fetch the system the haul is taking place in..
    //	$location = $DB->getCol("select location from runs where endtime is NULL and id='$ID' order by id desc limit 1");
    //	$runLocation = $location[0];
    $runLocation = getLocationOfRun($ID);
    // make the targeted system click-able.
    $sytem = new solarSystem($runLocation);
    // Assemble a PDM with all the destinations for the current run.
    $locations = $DB->query("SELECT location FROM hauled WHERE miningrun='{$ID}' ORDER BY location ASC");
    if ($locations->numRows()) {
        while ($loc = $locations->fetchRow()) {
            if ($loc[location] != "") {
                $pdmSystems[] = $loc[location];
            }
        }
    }
    // Get the location the last haul was brought to at.
    $lastHaulLocation = $DB->getCol("SELECT location FROM hauled WHERE miningrun='{$ID}' AND hauler='" . $MySelf->getID() . "' ORDER BY time DESC LIMIT 1");
    $lastHaulLocation = $lastHaulLocation[0];
    // Get a list of neighbouring systems.
    $neighbouringSystems = $sytem->getNeighbouringSystems();
    // Lets pick the right system.
    if ($lastHaulLocation) {
        // Use the last system stuff was hauled to.
        $location = $lastHaulLocation;
    } else {
        // Or, if thats empty, the system the op is in.
        $location = $runLocation;
    }
    if (is_array($pdmSystems)) {
        $Systems = array_merge($neighbouringSystems, $pdmSystems);
    } else {
        $Systems = $neighbouringSystems;
    }
    sort($Systems);
    //	unset($pdmSystems);
    //	unset($neighbouringSystems);
    //	unset($loc);
    //	unset($locations);
    foreach ($Systems as $s) {
        if ($s == $location) {
            $pdm .= "<option value=\"" . strtolower($s) . "\" SELECTED>" . ucfirst($s) . "</option>";
        } else {
            $pdm .= "<option value=\"" . strtolower($s) . "\">" . ucfirst($s) . "</option>";
        }
    }
    $pdm = "<select name=\"location\">" . $pdm . "</select>";
    $haulpage->addCol("System hauling to: " . $pdm . " -or- <input type=\"text\" name=\"location2\" value=\"\">", array("align" => "right"));
    $haulpage->addRow();
    $haulpage->addCol("<hr>", array("colspan" => "2"));
    // Now we need the sum of all ores.
    $totalOres = count($ORENAMES);
    /*
    // And the sum of all ENABLED ores.
    $totalEnabledOres = $DB->getCol("select count(name) as active from config where name LIKE '%Enabled' AND value='1'");
    $totalEnabledOres = $totalEnabledOres[0];
    */
    /*
     * This is evil. We have to create an array that we fill up sorted.
     * It aint cheap. First, we loop through all the ore values.
     */
    for ($p = 0; $p < $totalOres; $p++) {
        // Then we check each ore if it is enabled.
        $ORE = $DBORE[$ORENAMES[$p]];
        if (getOreSettings($ORE, $OPTYPE)) {
            // If the ore is enabled, add it to the array.
            $left[] = $ORE;
        } else {
            // add to disabled-array.
            $disabledOres[] = $ORE;
        }
    }
    $totalEnabledOres = count($left);
    // No ores enabled?
    if ($totalEnabledOres == 0 && $OPTYPE != "Shopping") {
        makeNotice("Your CEO has disabled *all* the Oretypes. Please ask your CEO to reactivate at leat one Oretype.", "error", "No valid Oretypes!");
    }
    $ajaxHaul = isset($_GET[ajaxHaul]);
    if ($ajaxHaul || $OPTYPE == "Shopping") {
        $haulpage->addRow();
        $script = "<script>\nvar selectedItems = \"\";\nvar currentQuery;\nvar int;\nfunction lookForItem(txt){\n\tcurrentQuery = txt;\n\tclearInterval(int);\n\tif(txt.value.length>2){\n\t\tvar int=self.setInterval('execQuery()',2000);\n\t}\n}";
        $script .= "\nfunction execQuery(){\n\tclearInterval(int);\n\tvar txt = currentQuery;\n\t\$.ajax({\n\t\turl: 'index.php?action=getItemList&ajax&q=' + txt.value,\n\t\tsuccess: function(data){\$('#ajaxItemList').html(data);}\n\t});\n\t\n}";
        $script .= "\nfunction addItem(selection){\n\t//\$(selection).animate({background-color:yellow;});\n\tvar item = selection.innerHTML;\n\tvar dbore = selection.name;\n\t//\$(selection).animate({background-color:none;});\n\tif(selectedItems.split(',').indexOf(item) == -1 ){\n\t\tvar print = \$('#selectedItemList').html() + '<div>Add <input type=\"text\" size=\"5\" name=\"' + dbore + '\" value=\"0\">' + item + '</div>';\n\t\t\$('#selectedItemList').html(print);\n\t\tif(selectedItems.length == 0){\n\t\t\tselectedItems = item;\n\t\t} else {\n\t\t\tselectedItems += ',' + item;\n\t\t}\n\t}\n}\n</script> ";
        $haulpage->addCol("Search for an item:<input name='itemSearch' onkeyup='lookForItem(this)' />, then click the item name below.", array("colspan" => 2));
        $haulpage->addRow();
        $haulpage->addCol("<div id='selectedItemList'></div>", array("colspan" => 2));
        $haulpage->addRow();
        $haulpage->addCol("<div id='ajaxItemList'></div>", array("colspan" => 2));
    } else {
        // The table is, rounded up, exactly half the size of all enabled ores.
        $tableLength = ceil($totalEnabledOres / 2);
        // Now, copy the lower second half into a new array.
        $right = array_slice($left, $tableLength);
        /*
         * So now we have an array of all the enabled ores. All we
         * need to do now, is create a nice, handsome table of it.
         * Loop through this array.
         */
        for ($i = 0; $i < $tableLength; $i++) {
            // Fetch the right image for the ore.
            $ri_words = str_word_count(array_search($left[$i], $DBORE), 1);
            $ri_max = count($ri_words);
            $ri = strtolower($ri_words[$ri_max - 1]);
            // Add a row.
            $haulpage->addRow();
            // left side.
            $haulpage->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . array_search($left[$i], $DBORE) . ".png\">" . "Add <input type=\"text\" size=\"5\" name=\"{$left[$i]}\" value=\"0\"> " . array_search($left[$i], $DBORE));
            // We need an ore type (just in case of odd ore numbers)
            if ($right[$i] != "") {
                // right side.
                // Fetch the right image for the ore.
                $ri_words = str_word_count(array_search($right[$i], $DBORE), 1);
                $ri_max = count($ri_words);
                $ri = strtolower($ri_words[$ri_max - 1]);
                // Add the column.
                $haulpage->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . array_search($right[$i], $DBORE) . ".png\">" . "Add <input type=\"text\" size=\"5\" name=\"" . $right[$i] . "\" value=\"0\"> " . array_search($right[$i], $DBORE));
            } else {
                // We have an odd number of ores: add empty cell.
                $haulpage->addCol("");
            }
        }
    }
    /*
    // Print out all disabled ore types:
    $disabledOreCount = count($disabledOres);
    
    // add the "," between words, but not before the first one, and an "and" between the last one.
    for ($i = 0; $i < $disabledOreCount; $i++) {
    	if ($disabledOreCount == $i +1) {
    		$disabledOresText .= " and " . array_search($disabledOres[$i], $DBORE);
    	} else
    		if (empty ($disabledOresText)) {
    			$disabledOresText = array_search($disabledOres[$i], $DBORE);
    		} else {
    			$disabledOresText .= ", " . array_search($disabledOres[$i], $DBORE);
    		}
    }
    
    // Display the ore-disables-disclaimer. (Only if there are disabled oretypes.)
    if (!empty ($disabledOresText)) {
    	$disabledOresText = "The following Oretypes has been disabled by the CEO: $disabledOresText.";
    }
    */
    $haulpage->addRow();
    $haulpage->addCol("<hr>", array("colspan" => "2"));
    $haulpage->addHeaderCentered("<input type=\"submit\" name=\"haul\" value=\"Commit haul to database\">");
    // Render the page...
    $form_stuff .= "<input type=\"hidden\" value=\"check\" name=\"check\">";
    $form_stuff .= "<input type=\"hidden\" value=\"addhaul\" name=\"action\">";
    $form_stuff .= "<input type=\"hidden\" value=\"" . $ID . "\" name=\"id\">";
    $form_stuff .= "</form>";
    $html = "<h2>Submit new transport manifest (<a href='?" . $_SERVER['QUERY_STRING'] . "&ajaxHaul'>ajax</a>)</h2><form action=\"index.php\" method=\"post\">" . $haulpage->flush() . $form_stuff;
    /*
    	// print out all the disabled oretypes.
    	if (!empty ($disabledOresText)) {
    		$page .= "<br><i>" . $disabledOresText . "</i>";
    	}*/
    // Return the page
    return $script . $html . $page;
}
Beispiel #10
0
function profile()
{
    // The usual suspects.
    global $MySelf;
    global $DB;
    // Set the ID.
    $ID = sanitize($_GET[id]);
    numericCheck($_GET[id], 0);
    // Load the profile.
    $profile = new profile($ID);
    $username = ucfirst(idToUsername($ID));
    // Cache our permissions.
    $canSeeUsers = $MySelf->canSeeUsers();
    // Need the api.
    $api = new api($ID);
    // Create table header.
    $table = new table(2, true);
    $table->addHeader(">> About " . $username);
    $table->addRow();
    $table->addCol("Current rank:");
    $table->addCol(getRank($ID));
    $table->addRow();
    $table->addCol("Last login:"******"SELECT lastlogin FROM users WHERE id='" . $ID . "' AND deleted='0' LIMIT 1");
    $table->addCol(date("d.m.y. H:i:s", $lastLog[0]));
    $table->addRow();
    $table->addCol("Total logins:");
    $lastLog = $DB->getCol("SELECT COUNT(authkey) FROM auth WHERE user='******' LIMIT 1");
    $table->addCol(number_format($lastLog[0], 0));
    $table->addRow();
    $table->addCol("Valid api-key on file:");
    $table->addCol(yesno($api->valid(), true));
    $table->addRow();
    $table->addCol("Is available for mining:");
    if ($profile->isOwn()) {
        if ($profile->MinerFlag()) {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&mining=false\">set not available</a>]";
        } else {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&mining=true\">set available</a>]";
        }
    }
    $table->addCol(yesno($profile->MinerFlag(), true) . $temp);
    $table->addRow();
    $table->addCol("Is available for hauling:");
    if ($profile->isOwn()) {
        if ($profile->HaulerFlag()) {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&hauling=false\">set not available</a>]";
        } else {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&hauling=true\">set available</a>]";
        }
    }
    $table->addCol(yesno($profile->HaulerFlag(), true) . $temp);
    $table->addRow();
    $table->addCol("Is available for fighting:");
    if ($profile->isOwn()) {
        if ($profile->FighterFlag()) {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&fighting=false\">set not available</a>]";
        } else {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&fighting=true\">set available</a>]";
        }
    }
    $table->addCol(yesno($profile->FighterFlag(), true) . $temp);
    if ($profile->emailVisible() || $profile->isOwn()) {
        if ($profile->isOwn()) {
            if ($profile->emailVisible()) {
                $temp = " (public) [<a href=\"index.php?action=modprofile&id=" . $ID . "&email=hide\">hide from public</a>]";
            } else {
                $temp = " (hidden) [<a href=\"index.php?action=modprofile&id=" . $ID . "&email=show\">make public</a>]";
            }
        }
        $table->addRow();
        $table->addCol("Email address:");
        $email = $DB->getCol("SELECT email FROM users WHERE id='" . $ID . "' LIMIT 1");
        $table->addCol($email[0] . $temp);
    }
    // Statistics.
    $stats = new table(2, true);
    $stats->addHeader(">> Statistical breakdown");
    $miningRunsJoined = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "'");
    $miningRunsJoined = $miningRunsJoined[0];
    $OpjoinUps = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "'");
    $OpjoinUps = $OpjoinUps[0];
    $joinUps = $DB->getCol("SELECT COUNT(id) FROM (SELECT * from joinups WHERE userid='" . $ID . "' GROUP BY run) as uJoinups");
    $joinUps = $joinUps[0];
    $haulingRuns = $DB->getCol("SELECT COUNT(id) FROM hauled WHERE hauler='" . $ID . "'");
    $haulingRuns = $haulingRuns[0];
    $timeMining = $DB->getCol("SELECT SUM(parted - joined) FROM joinups WHERE userid='" . $ID . "' AND parted >1");
    $timeMining = $timeMining[0];
    $timesKicked = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "' AND status='1'");
    $timesKicked = $timesKicked[0];
    $timesRemoved = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "' AND status='2'");
    $timesRemoved = $timesRemoved[0];
    $timesBanned = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "' AND status='3'");
    $timesBanned = $timesBanned[0];
    $timesCharity = $DB->getCol("SELECT COUNT(id) FROM (SELECT * from joinups WHERE userid='" . $ID . "' GROUP BY run) as uJoinups WHERE userid='" . $ID . "' AND charity='1'");
    $timesCharity = $timesCharity[0];
    $tmec = $DB->getCol("SELECT AVG(tmec) FROM runs WHERE isOfficial = 1");
    $tmecJoined = $DB->getCol("SELECT AVG(runs.tmec) FROM joinups, runs WHERE joinups.userid='" . $ID . "' AND joinups.run = runs.id AND runs.endtime > 0 AND runs.isOfficial = 1");
    $tmecNotJoined = $DB->getCol("SELECT AVG(runs.tmec) FROM joinups, runs WHERE joinups.userid='" . $ID . "' AND joinups.run <> runs.id AND runs.endtime > 0 AND runs.isOfficial = 1");
    $tmecDiff = $tmecJoined[0] - $tmecNotJoined[0];
    $stats->addRow();
    $stats->addCol("Mining operations joined:");
    if ($miningRunsJoined > 0) {
        $stats->addCol(number_format($joinUps, 0));
    } else {
        $stats->addCol("never joined.");
    }
    $stats->addRow();
    $stats->addCol("Total operations joinups:");
    if ($OpjoinUps > 0) {
        $stats->addCol(number_format($OpjoinUps, 0));
    } else {
        $stats->addCol("never joined.");
    }
    $stats->addRow();
    $stats->addCol("Hauling runs:");
    if ($haulingRuns > 0) {
        $stats->addCol(number_format($haulingRuns, 0));
    } else {
        $stats->addCol("never hauled.");
    }
    $stats->addRow();
    $stats->addCol("Time spent mining:");
    if ($timeMining > 0) {
        $stats->addCol(numberToString($timeMining));
    } else {
        $stats->addCol("never mined.");
    }
    $stats->addRow();
    $stats->addCol("Average TMEC:");
    $stats->addCol(number_format($tmec[0], 3));
    $stats->addRow();
    $stats->addCol("Average TMEC on Ops <b>with</b> " . $username . ":");
    $stats->addCol(number_format($tmecJoined[0], 3));
    $stats->addRow();
    $stats->addCol("Average TMEC on Ops <b>without</b> " . $username . ":");
    $stats->addCol(number_format($tmecNotJoined[0], 3));
    $stats->addRow();
    $stats->addCol("TMEC difference:");
    if ($tmecDiff >= 0) {
        $stats->addCol("<font color=\"#00ff00\">" . number_format($tmecDiff, 3), true . "</font>");
    } else {
        $stats->addCol("<font color=\"#ff0000\">" . number_format($tmecDiff, 3), true . "</font>");
    }
    $stats->addRow();
    $stats->addCol("Times removed from OP:");
    $stats->addCol(number_format($timesRemoved, 0));
    $stats->addRow();
    $stats->addCol("Times kicked from OP:");
    $stats->addCol(number_format($timesKicked, 0));
    $stats->addRow();
    $stats->addCol("Times banned from OP:");
    $stats->addCol(number_format($timesBanned, 0));
    $stats->addRow();
    $stats->addCol("Times declared charity:");
    $stats->addCol(number_format($timesCharity, 0));
    /*
     * Assemble the heavy-duty SQL query.
     * It is dynamic because this way we can easily add ores from 
     * config-system.php to the system without code rewrite.
     */
    /*
    	global $DBORE;
    	global $ORENAMES;
    	foreach ($DBORE as $ORE) {
    		$new = $ORE;
    		if ($last) {
    			$SQLADD .= "SUM(" . $last . ") AS total" . $last . ", ";
    		}
    		$last = $new;
    	}
    	$SQLADD .= "SUM(" . $last . ") AS total" . $last . " ";
    	$SQL = "SELECT " . $SQLADD . " FROM hauled WHERE hauler='" . $ID . "'";
    
    	// Now query it.
    	$totalOREDB = $DB->query("$SQL");
    	
    
    if (DB::isError($totalOREDB)) {
        *
         * This is not what you would really want to do in
         * your program.  It merely demonstrates what kinds
         * of data you can get back from error objects.
         *
        echo 'Standard Message: ' . $totalOREDB->getMessage() . "\n";
        echo '\n ';
        echo 'Standard Code: ' . $totalOREDB->getCode() . "\n";
        echo '\n ';
        echo 'DBMS/User Message: ' . $totalOREDB->getUserInfo() . "\n";
        echo '\n ';
        echo 'DBMS/Debug Message: ' . $totalOREDB->getDebugInfo() . "\n";
        echo '\n ';
        exit;
    }
    
    	// Create table.
    	$totalOre_table = new table(2, true);
    	$totalOre_table->addHeader(">> Total ore hauled");
    
    	// Loop through the result (single result!)
    	if ($totalOREDB->numRows() > 0) {
    		while ($totalORE = $totalOREDB->fetchRow()) {
    			// Now check each ore type.
    			foreach ($ORENAMES as $ORE) {
    				// And ignore never-hauled ore
    				if ($totalORE[total . $ORE] > 0) {
    					// We got some ore!
    					$totalOre_table->addRow();
    					$totalOre_table->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . $ORE . ".png\">Total " . $ORE . " hauled:");
    					$totalOre_table->addCol(number_format($totalORE[total . $ORE]));
    					$gotOre = true;
    				}
    			}
    		}
    		if ($gotOre) {
    			$oretable_r = "<br>" . $totalOre_table->flush();
    		}
    	}
    */
    // Image thingy.
    // We serve small images IGB.
    global $IGB;
    global $IGB_VISUAL;
    if ($IGB && $IGB_VISUAL) {
        $image = "<img src=\"portrait:" . $api->getCharacterID() . "\" SIZE=\"128\">";
    } else {
        $image = $profile->getImage("large");
    }
    $picTable = new table(true, 1);
    $picTable->addHeader(">> Picture of " . $username);
    $picTable->addRow();
    $picTable->addCol($image);
    $imageTable = $picTable->flush();
    // About
    if ($profile->GetAbout() && !$profile->isOwn()) {
        $aboutTable = new table(1, true);
        $aboutTable->addHeader(">> " . $username . " says...");
        $aboutTable->addRow();
        $aboutTable->addCol(nl2br($profile->GetAbout()));
        $aboutTable = "<br>" . $aboutTable->flush();
    }
    if ($profile->isOwn()) {
        $aboutTable = new table(1, true);
        $aboutTable->addHeader(">> Enter a public viewable text here");
        $aboutTable->addRow();
        $form = "<form action=\"index.php\" method=\"POST\">";
        $form .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
        $form .= "<input type=\"hidden\" name=\"action\" value=\"modprofile\">";
        $form .= "<input type=\"hidden\" name=\"id\" value=\"" . $ID . "\">";
        $aboutTable->addCol("<textarea rows=\"18\" cols=\"80\" name=\"about\">" . $profile->GetAbout() . "</textarea>");
        $aboutTable->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Update about\">");
        $aboutTable = "<br>" . $form . $aboutTable->flush() . "</form>";
    }
    // quick "jump to" -thingy.
    $peeps = $DB->query("SELECT DISTINCT username,id FROM users WHERE deleted = 0 AND canLogin = 1 ORDER BY username ASC");
    if ($peeps->numRows() > 0) {
        while ($p = $peeps->fetchRow()) {
            if ($ID == $p[id]) {
                $pdm .= "<option SELECTED value=\"" . $p[id] . "\">" . ucfirst($p[username]) . " (current)</option>";
            } else {
                $pdm .= "<option value=\"" . $p[id] . "\">" . ucfirst($p[username]) . "</option>";
            }
        }
        $pdm = "<select name=\"id\">" . $pdm . "</select></form>";
        $quickChooser = new table(1, true);
        $quickChooser->addHeader(">> Quick jump to profile");
        $quickChooser->addRow();
        $quickChooser->addCol($pdm);
        $quickChooser->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Switch\">");
        $quickChooser = "<form action=\"index.php\" method=\"GET\"><input type=\"hidden\" name=\"action\" value=\"profile\">" . $quickChooser->flush() . "</form>";
    }
    $page = "<h2>View profile</h2>" . $quickChooser . $imageTable . "<br>" . $table->flush() . "<br>" . $stats->flush() . $oretable_r . $aboutTable;
    return $page;
}
Beispiel #11
0
function lotto_buyTickets()
{
    // Set some needed variables.
    global $DB;
    global $MySelf;
    $ID = $MySelf->getID();
    $myMoney = getCredits($ID);
    $affordable = floor($myMoney / 1000000);
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Get my credits
    $MyStuff = $DB->getRow("SELECT lottoCredit, lottoCreditsSpent FROM users WHERE id='" . $MySelf->getID() . "'");
    $Credits = $MyStuff[lottoCredit];
    $CreditsSpent = $MyStuff[lottoCreditsSpent];
    // User submited this form already!
    if ($_POST[check]) {
        numericCheck($_POST[amount], 0, $affordable);
        if ($_POST[amount] == 0) {
            makeNotice("You cannot buy zero tickets.", "warning", "Too few tickets.", "index.php?action=lotto", "[whoops]");
        }
        confirm("Please authorize the transaction of " . number_format($_POST[amount] * 1000000, 2) . " ISK in order to buy {$_POST['amount']} lotto credits.");
        // Get the old ticket count, and add the new tickets on top of those.
        $oldCount = $DB->getCol("SELECT lottoCredit FROM users WHERE id='{$ID}' LIMIT 1");
        $newcount = $oldCount[0] + $_POST[amount];
        // Update the database to reflect the new ticket count.
        $check = $DB->query("UPDATE users SET lottoCredit='{$newcount}' WHERE id='{$ID}' LIMIT 1");
        // Check that we were successful.
        if ($DB->affectedRows() != 1) {
            makeNotice("I was unable to add {$newcount} tickets to {$user} stack of {$count} tickets! Danger will robonson, danger!", "error", "Unable to comply.");
        }
        // Make him pay!
        global $TIMEMARK;
        $transaction = new transaction($ID, 1, $_POST[amount] * 1000000);
        $transaction->setReason("lotto credits bought");
        if ($transaction->commit()) {
            // all worked out!
            makeNotice("Your account has been charged the amount of " . number_format($_POST[amount] * 1000000, 2) . " ISK.", "notice", "Credits bought", "index.php?action=lotto", "[OK]");
        } else {
            // We were not successfull
            makeNotice("I was unable to add {$newcount} tickets to {$user} stack of {$count} tickets! Danger will robonson, danger!", "error", "Unable to comply.");
        }
    }
    // Prepare the drop-down menu.
    if ($affordable >= 1) {
        $ddm = "<select name=\"amount\">";
        for ($i = 1; $i <= $affordable; $i++) {
            if ($i == 1) {
                $ddm .= "<option value=\"{$i}\">Buy {$i} tickets</option>";
            } else {
                $ddm .= "<option value=\"{$i}\">Buy {$i} tickets</option>";
            }
        }
        $ddm .= "</select>";
    } else {
        // Poor user.
        $ddm = "You can not afford any credits.";
    }
    // Create the table.
    $table = new table(2, true);
    $table->addHeader(">> Buy lotto credits");
    $table->addRow();
    $table->addCol("Here you can buy lotto tickets for 1.000.000,00 ISK each. " . "Your account currently holds " . number_format($myMoney, 2) . " ISK, so " . "you can afford {$affordable} tickets. Please choose the amount of credits you wish " . "to buy.", array("colspan" => 2));
    $table->addRow();
    $table->addCol("Your credits:");
    $table->addCol($Credits);
    $table->addRow();
    $table->addCol("Total spent credits:");
    $table->addCol($CreditsSpent);
    $table->addRow();
    $table->addCol("Purchase this many credits:");
    $table->addCol($ddm);
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Buy credits\">");
    $table->addRow("#060622");
    $table->addCol("[<a href=\"index.php?action=lotto\">Cancel request</a>]", array("colspan" => 2));
    // Add some more html form stuff.
    $html = "<h2>Buy Lotto credits</h2>";
    $html .= "<form action=\"index.php\" method=\"POST\">";
    $html .= $table->flush();
    $html .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $html .= "<input type=\"hidden\" name=\"action\" value=\"lottoBuyCredits\">";
    $html .= "</form>";
    // Return the mess we made.
    return $html;
}
Beispiel #12
0
function makeShipValue()
{
    // Get the globals.
    global $TIMEMARK;
    global $SHIPTYPES;
    global $DBSHIP;
    global $DB;
    // load the values.
    $shipvaluesDS = $DB->query("select * from shipvalues order by id DESC limit 1");
    $shipvalues = $shipvaluesDS->fetchRow();
    // Create the table.
    $table = new table(6, true);
    //(8, true)
    $table->addHeader(">> Manage ship values (Values may be as little as 0.01% and as high as 999.99%)", array("bold" => true, "colspan" => 6));
    $table->addRow();
    $table->addCol("Ship Type", array("colspan" => 2, "bold" => true));
    //	$table->addCol("Enabled", array (
    //		"bold" => true
    //	));
    $table->addCol("Value", array("bold" => true));
    $table->addCol("Ship Type", array("colspan" => 2, "bold" => true));
    //	$table->addCol("Enabled", array (
    //		"bold" => true
    //	));
    $table->addCol("Value", array("bold" => true));
    // How many Ships are there in total? Ie, how long has the table to be?
    $tableLength = ceil(count($SHIPTYPES) / 2) - 2;
    for ($i = 0; $i <= $tableLength; $i++) {
        $table->addRow();
        $SHIP = $SHIPTYPES[$i];
        // Ship columns for LEFT side.
        $table->addCol("<img width=\"32\" height=\"32\" src=\"./images/ships/ship.png\">");
        $table->addCol($SHIP);
        //		if (getShipSettings($DBSHIP[$SHIP])) {
        //			$table->addCol("<input name=\"" . $DBSHIP[$SHIP] . "Enabled\" value=\"true\" type=\"checkbox\" checked=\"checked\">");
        //		} else {
        //			$table->addCol("<input name=\"" . $DBSHIP[$SHIP] . "Enabled\" value=\"true\" type=\"checkbox\">");
        //		}
        $table->addCol("<input type=\"text\" name=\"{$DBSHIP[$SHIP]}\"" . "size=\"6\" value=\"" . number_format($shipvalues[$DBSHIP[$SHIP] . Value] * 100, 2) . "\">" . " %");
        // Ship columns for RIGHT side.
        $SHIP = $SHIPTYPES[$i + $tableLength + 1];
        if ($SHIP != "") {
            $table->addCol("<img width=\"32\" height=\"32\" src=\"./images/ships/ship.png\">");
            $table->addCol($SHIP);
            //			if (getShipSettings($DBSHIP[$SHIP])) {
            //				$table->addCol("<input name=\"" . $DBSHIP[$SHIP] . "Enabled\" value=\"true\" type=\"checkbox\" checked=\"checked\">");
            //			} else {
            //				$table->addCol("<input name=\"" . $DBSHIP[$SHIP] . "Enabled\" value=\"true\" type=\"checkbox\">");
            //			}
            $table->addCol("<input type=\"text\" name=\"{$DBSHIP[$SHIP]}\"" . "size=\"6\" value=\"" . number_format($shipvalues[$DBSHIP[$SHIP] . Value] * 100, 2) . "\">" . " %");
        } else {
            $table->addCol("");
            $table->addCol("");
            $table->addCol("");
            //			$table->addCol("");
        }
    }
    $form .= "<input type=\"hidden\" name=\"action\" value=\"changeship\">";
    $form .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $form .= "<input type=\"submit\" name=\"change\" value=\"Modify ship settings\">";
    $table->addHeaderCentered($form, array("colspan" => 6, "align" => "center"));
    // return the page
    return "<h2>Modify ship settings</h2><form action=\"index.php\"method=\"post\">" . $table->flush();
}
Beispiel #13
0
function listUser()
{
    global $DB;
    global $MySelf;
    global $IGB;
    global $TIMEMARK;
    global $IGB_VISUAL;
    // Are we allowed to peek into peoples files?
    if (!$MySelf->canSeeUsers()) {
        makeNotice("You are not allowed to do this!", "error", "forbidden");
    }
    // Is the supplied ID truly numeric?
    if (!is_numeric($_GET[id])) {
        makeNotice("Why would you do such a thing? Are you evil at heart? Lets assume its a \"mistake\" for now..", "warning", "*cough*", "index.php?action=editusers", "I'm sorry...");
    } else {
        $id = (int) $_GET[id];
    }
    // Query the database.
    $users = $DB->query("select * from users where id='{$id}' AND deleted='0' limit 1");
    // Build the tables.
    while ($row = $users->fetchRow()) {
        $table = new table(2, true);
        $table->addHeader(">> Managing user " . ucfirst($row[username]));
        $username = ucfirst($row[username]);
        $table->addRow();
        $table->addCol("ID:");
        $table->addCol(str_pad("{$row['id']}", 5, "0", STR_RIGHT_PAD));
        $table->addRow();
        $table->addCol("Username:"******"<input type=\"text\" name=\"username\" value=\"" . $uname_temp . "\">";
            $confi_temp = "<input type=\"checkbox\" name=\"username_check\" value=\"true\">";
            $table->addCol($field_temp . " (changing username tick here also: " . $confi_temp . ")");
        } else {
            $table->addCol(ucfirst($row[username]));
        }
        $table->addRow();
        $table->addCol("eMail:");
        $table->addCol("<input type=\"text\" size=\"40\" name=\"email\" value=\"" . ($row[email] == "" ? 'no email supplied' : $row[email]) . "\">");
        $table->addRow();
        $table->addCol("Password:"******"<input type=\"password\" size=\"40\" name=\"password\">");
        // Ranks System
        $RanksDS = $DB->query("SELECT * FROM ranks ORDER BY rankOrder ASC");
        $rankCount = $RanksDS->numRows();
        if ($rankCount >= 1) {
            // We have at least 1 rank.
            while ($rank = $RanksDS->fetchRow()) {
                if ($rank[rankid] == $row[rank]) {
                    // The current rank is selected.
                    $rank_pdm .= "<option SELECTED value=\"{$rank['rankid']}\">{$rank['name']}</option>";
                } else {
                    // The others of course, are not.
                    $rank_pdm .= "<option value=\"{$rank['rankid']}\">{$rank['name']}</option>";
                }
            }
            $rankColumn = "<select name=\"rank\">" . $rank_pdm . "</select>";
        } else {
            // No rank has been set yet.
            $rankColumn = "There are no ranks. Go create some!";
        }
        $table->addRow();
        $table->addCol("Rank:");
        $table->addCol($rankColumn);
        $table->addRow();
        $table->addCol("Last login:"******"{$row['lastlogin']}" < 10) {
            $table->addCol("never");
        } else {
            $table->addCol(date("d.m.y H:i:s", $row[lastlogin]));
        }
        $table->addRow();
        $table->addCol("Credits:");
        $table->addCol(number_format(getCredits($row[id]), 2) . " ISK");
        // Is the account confirmed?
        if ("{$row['confirmed']}" == "0") {
            $table->addRow();
            $table->addCol("Account confirmed:");
            $table->addCol("This account has <b>not</b> been confirmed yet.");
            $table->addRow();
            $table->addCol("Confirm account:");
            $table->addCol("<input type=\"checkbox\" name=\"confirm\" value=\"true\"> Tick box to confirm account. <br><br>This is a one-way action only. Once an account" . " has been confirmed you can not unconfirm it. Tho you can block or delete it." . " Be careful not to confirm an account by accident - you could allow a non-authorized third party to access your MiningBuddy!");
            $table->addRow();
            $table->addCol("Account confirmed:");
            // Give a red light if user has not even verified himself.
            if ("{$row['emailvalid']}" == "0") {
                $table->addCol("<b>WARNING!</b><br> The User has not yet verified this email yet! If you choose to enable" . " this account at this time, be very sure that you know the person requesting the account!", array("bgcolor" => "#662222"));
            } else {
                $table->addCol("<br><br><b>The user validated the email address.</b><br>");
            }
        } else {
            $table->addRow();
            $table->addCol("This account has been confirmed.");
            if ("{$row['emailvalid']}" == "0") {
                $table->addCol("<font color=\"#ff0000\">WARNING!</b></font><br> The User has not verified this email but the account has been confirmed!");
                // Add a "confirm email" checkbox.
                $table->addRow();
                $table->addCol("Mark users email as valid:");
                $table->addCol("<input type=\"checkbox\" name=\"SetEmailValid\" value=\"true\">");
            } else {
                $table->addCol("The user validated the supplied email address.");
            }
        }
        /*
         * API Goodness
         */
        $api = new api($row[id], true);
        $apit = new table(2, true);
        $apit->addHeader(">> Api information for " . ucfirst($row[username]));
        $apit->addRow();
        $apit->addCol("API Key in database:");
        if ($api->getApiID() && $api->getApiKey()) {
            $apit->addCol(yesno(1, true));
            $apit->addRow();
            $apit->addCol("API valid:");
            $apit->addCol(yesno($api->valid(), true));
            if ($api->valid()) {
                $apit->addRow();
                $apit->addCol("Character ID:");
                $apit->addCol($api->getCharacterID());
                $apit->addRow();
                $apit->addCol("Validated on:");
                $apit->addCol(date("d.m.Y H:i:s", $api->validatedOn()));
            }
            $apit->addRow();
            $apit->addCol("Remove API key from database:");
            $apit->addCol("[<a href=\"index.php?action=delapi&id={$id}\">delete api key</a>]");
        } else {
            $apit->addCol(yesno(0));
        }
        // Permissions matrix
        $perms = array("canLogin" => "log in", "canJoinRun" => "join mining Ops", "canCreateRun" => "create new mining Ops", "canCloseRun" => "close mining Ops", "canDeleteRun" => "delete mining Ops", "canAddHaul" => "haul from/to mining Ops", "canSeeEvents" => "view scheduled events", "canDeleteEvents" => "can delete events", "canEditEvents" => "add and delete scheduled events", "canChangePwd" => "change his own password", "canChangeEmail" => "change his own email", "canChangeOre" => "manage ore prices and enable/disable them.", "canAddUser" => "add new accounts", "canSeeUsers" => "see other accounts", "canDeleteUser" => "delete other accounts.", "canEditRank" => "edit other peoples ranks.", "canManageUser" => "grant and take permissions.", "isOfficial" => "create official mining runs (with payout).", "isAdmin" => "edit site settings.", "isLottoOfficial" => "administrate the lottery", "canPlayLotto" => "play Lotto!", "isAccountant" => "edit other users credits.", "optIn" => "User has opt-in to eMails.");
        // Create a seperate permissions table.
        $perm_table = new table(2, true);
        $perm_table->addHeader(">> " . ucfirst($row[username]) . " has permission to... ");
        $perm_keys = array_keys($perms);
        $LoR = 1;
        foreach ($perm_keys as $key) {
            if ($LoR) {
                $perm_table->addRow();
            }
            if ($row[$key]) {
                $perm_table->addCol("<input type=\"checkbox\" name=\"{$key}\" checked> " . $perms[$key]);
            } else {
                $perm_table->addCol("<input type=\"checkbox\" name=\"{$key}\"> " . $perms[$key]);
            }
            $LoR = 1 - $LoR;
        }
        if (!$LoR) {
            $perm_table->addCol();
        }
        // Delete User
        $perm_table->addRow();
        $perm_table->addCol("<hr>", array("colspan" => 2));
        $perm_table->addRow();
        $perm_table->addCol("Delete user:"******"<input type=\"checkbox\" name=\"delete\" value=\"true\"> Tick box to delete the user permanently.");
        $perm_table->addRow();
        $perm_table->addCol("<hr>", array("colspan" => 2));
        // Commit changes button.
        $perm_table->addHeaderCentered("<input type=\"submit\" name=\"send\" value=\"Commit changes\">", array("colspan" => 2, "align" => "center"));
    }
    $form .= "<form action=\"index.php\" method=\"POST\">";
    $form .= "<input type=\"hidden\" name=\"id\" value=\"" . $_GET[id] . "\">";
    $form .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $form .= "<input type=\"hidden\" name=\"action\" value=\"edituser\">";
    // Show all logins.
    $logins = getLogins($id);
    // Show failed logins.
    $failed_logins = showFailedLogins("15", idToUsername($id));
    /*
     * Transactions.
     */
    if ($MySelf->isAccountant()) {
        $acc = new table(2, true);
        $acc->addHeader(">> Create transaction to user " . ucfirst(idToUsername($id)));
        $acc->addRow();
        $acc->addCol("Credit to:");
        $acc->addCol($username);
        $acc->addRow();
        $acc->addCol("Authorization by:");
        $acc->addCol(ucfirst($MySelf->getUsername()));
        $acc->addRow();
        $acc->addCol("Time of Transaction:");
        $acc->addCol(date("r", $TIMEMARK));
        $acc->addRow();
        $acc->addCol("Withdrawal or deposit:");
        $pdm = "<select name=\"wod\">";
        $pdm .= "<option value=\"0\">Deposit (give money)</option>";
        $pdm .= "<option SELECTED value=\"1\">Withdrawal (take money)</option>";
        $pdm .= "</select>";
        $acc->addCol($pdm);
        $acc->addRow();
        $acc->addCol("Amount:");
        $acc->addCol("<input size=\"8\" type=\"text\" name=\"amount\"> ISK");
        $acc->addRow();
        $acc->addCol("Reason:");
        $pdm = "<select name=\"reason1\">";
        $pdm .= "<option>requested payout</option>";
        $pdm .= "<option SELECTED>normal payout</option>";
        $pdm .= "<option>payout of loan</option>";
        $pdm .= "<option>manual deposit</option>";
        $pdm .= "<option>cash recived</option>";
        $pdm .= "</select>";
        $acc->addCol($pdm . " -or- <input type=\"text\" name=\"reason2\">");
        $acc->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Authorize transaction\">");
        $transBox = "<form action=\"index.php\" method=\"POST\">";
        $transBox .= $acc->flush();
        $transBox .= "<input type=\"hidden\" name=\"id\" value=\"" . $_GET[id] . "\">";
        $transBox .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
        $transBox .= "<input type=\"hidden\" name=\"action\" value=\"transaction\">";
        $transBox .= "</form>";
    }
    $page = "<h2>Managing user details</h2>" . $form . $table->flush() . "<br>" . $apit->flush() . "<br>" . $perm_table->flush() . "</form>" . $transBox;
    $transactions = getTransactions($id);
    if ($transactions) {
        $page .= $transactions;
    }
    // Add login table if we have more than 0 logins.
    if ($logins) {
        if ($transactions) {
            $page .= "<br>";
        }
        $page .= $logins;
    }
    $page .= $failed_logins;
    // Return the page.
    return $page;
}
Beispiel #14
0
function showFailedLogins($limit, $user = false)
{
    global $DB;
    $user = sanitize(stripslashes($user));
    // Specify a user, if given.
    if ($user) {
        $addQuery = "WHERE username = '******'";
    } else {
        $addQuery = "";
    }
    // Set the default results (10)
    if ($limit < 1) {
        $limit = 10;
    }
    // Ask the oracle.
    $FailedDB = $DB->query("SELECT * FROM failed_logins {$addQuery} order by incident desc LIMIT {$limit} ");
    // Check for results.
    if ($FailedDB->numRows() > 0) {
        // We have failed logins.
        $table = new table(5, true);
        // Add a table header accordingly.
        if ($user) {
            $table->addHeader("Failed logins for user " . ucfirst(stripslashes($user)) . ".");
        } else {
            $table->addHeader("Failed logins");
        }
        // Add Table Description
        $table->addRow();
        $table->addCol("Incident");
        $table->addCol("Occurance");
        $table->addCol("IP");
        $table->addCol("Username");
        $table->addCol("Valid Username");
        // 		$table->addCol("Agent");
        // Add the data-rows.
        while ($log = $FailedDB->fetchRow()) {
            $table->addRow();
            $table->addCol(str_pad($log['incident'], 4, "0", STR_PAD_LEFT));
            $table->addCol(date("d.m.y h:i:s", $log['time']));
            $table->addCol($log['ip']);
            if ($log['username_valid']) {
                $userID = usernameToID(stripslashes(sanitize($log['username'])), "Failed_Login");
                if ($userID == -1) {
                    $link = ucfirst(stripslashes(sanitize($log['username'])));
                } else {
                    $link = "<a href=\"index.php?action=edituser&id={$userID}\">" . ucfirst(stripslashes(sanitize($log['username']))) . "</a>";
                }
                $table->addCol($link);
            } else {
                $table->addCol(ucfirst(sanitize($log['username'])));
            }
            $table->addCol(yesno($log['username_valid']));
            // 			$table->addCol($log['agent']);
        }
        $table->addHeaderCentered("Securing your system is your responsibility!");
        return "<br>" . $table->flush();
    } else {
        // No failed logins.
        return false;
    }
}
Beispiel #15
0
function makePreferences()
{
    // I kid you not. All needed.
    global $PREFS;
    global $VERSION;
    global $SITENAME;
    global $TIMEMARK;
    global $DB;
    global $MySelf;
    /*
     * Cantimer Settings
     */
    $cantimer_table = new table(2, true);
    $cantimer_table->addHeader(">> Preferences for Cantimer");
    // Can see my own cans.
    $cantimer_table->addRow();
    if ($PREFS->getPref("CanMyCans")) {
        $cantimer_table->addCol("<input type=\"checkbox\" CHECKED name=\"CanMyCans\" value=\"true\">");
    } else {
        $cantimer_table->addCol("<input type=\"checkbox\" name=\"CanMyCans\" value=\"true\">");
    }
    $cantimer_table->addCol("Tick box to see your own cans.");
    // Can see the add cans form.
    $cantimer_table->addRow();
    if ($PREFS->getPref("CanAddCans")) {
        $cantimer_table->addCol("<input type=\"checkbox\" CHECKED name=\"CanAddCans\" value=\"true\">");
    } else {
        $cantimer_table->addCol("<input type=\"checkbox\" name=\"CanAddCans\" value=\"true\">");
    }
    $cantimer_table->addCol("Tick the add can form.");
    // Can See cans beloning to same run.
    $cantimer_table->addRow();
    if ($PREFS->getPref("CanRunCans")) {
        $cantimer_table->addCol("<input type=\"checkbox\" CHECKED name=\"CanRunCans\" value=\"true\">");
    } else {
        $cantimer_table->addCol("<input type=\"checkbox\" name=\"CanRunCans\" value=\"true\">");
    }
    $cantimer_table->addCol("Tick to see cans beloning to your MiningOp.");
    // Can see all cans.
    $cantimer_table->addRow();
    if ($PREFS->getPref("CanAllCans")) {
        $cantimer_table->addCol("<input type=\"checkbox\" CHECKED name=\"CanAllCans\" value=\"true\">");
    } else {
        $cantimer_table->addCol("<input type=\"checkbox\" name=\"CanAllCans\" value=\"true\">");
    }
    $cantimer_table->addCol("Tick if you want to see all cans.");
    $cantimer_table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Update Can Timer settings\">");
    /*
     * Opt In/Out of emails Setting
     */
    $opt_table = new table(2, true);
    $opt_table->addHeader(">> Your eMail settings");
    $opt_table->addRow();
    if ($MySelf->optInState()) {
        $opt_table->addCol("<input type=\"checkbox\" CHECKED name=\"optIn\" value=\"true\">");
    } else {
        $opt_table->addCol("<input type=\"checkbox\" name=\"optIn\" value=\"true\">");
    }
    $opt_table->addCol("Tick this to recive eMails from MiningBuddy. You will get eMails that will inform you about new events entered into the system, Mining Run reciepts and the occasional CEO email.");
    $opt_table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Update your eMail preferences\">");
    /*
     * Show/hide inofficial runs
     */
    $sir_table = new table(2, true);
    $sir_table->addHeader(">> Show/Hide inofficial runs");
    $sir_table->addRow();
    if ($PREFS->getPref("sirstate")) {
        $sir_table->addCol("<input type=\"checkbox\" CHECKED name=\"sir\" value=\"true\">");
    } else {
        $sir_table->addCol("<input type=\"checkbox\" name=\"sir\" value=\"true\">");
    }
    $sir_table->addCol("Tick the box to show non-official mining operations. Your own inofficial mining runs are still shown, however.");
    $sir_table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Update your settings\">");
    /*
     * Update eMail address.
     */
    if ($MySelf->canChangeEmail()) {
        $email_table = new table(2, true);
        $email_table->addHeader(">> Update your eMail address");
        $email_table->addRow("#060622");
        $email_table->addCol("Your email is needed to send password hints and event news.", array("colspan" => 2));
        // Query the oracle.
        $email_table->addRow();
        $email = $DB->getCol("select email from users where username = '******' AND deleted='0' limit 1");
        $email_table->addCol("Current eMail:");
        $email_table->addCol("<input type=\"text\" readonly value=\"" . $email[0] . "\">");
        $email_table->addRow();
        $email_table->addCol("New eMail:");
        $email_table->addCol("<input type=\"text\" name=\"email\" maxlength=\"100\">");
        $email_table->addHeaderCentered("<input type=\"submit\" name=\"change\" value=\"Update your eMail\">");
    }
    /*
     * Change password.
     */
    if ($MySelf->canChangePwd()) {
        $password_table = new table(2, true);
        $password_table->addHeader(">> Change your password");
        $password_table->addRow("#060622");
        $password_table->addCol("Its always a good idea to change your password frequently. Your password is " . "stored in an encrypted form; no one will ever be able to read it.", array("colspan" => "2"));
        $password_table->addRow();
        $password_table->addCol("Changing password for:");
        $password_table->addCol(ucfirst($MySelf->getUsername()));
        $password_table->addRow();
        $password_table->addCol("Your current password:"******"<input type=\"password\" name=\"password\" maxlength=\"20\">");
        $password_table->addRow();
        $password_table->addCol("Set a new password:"******"<input type=\"password\" name=\"password1\" maxlength=\"20\">");
        $password_table->addRow();
        $password_table->addCol("Verify your new password:"******"<input type=\"password\" name=\"password2\" maxlength=\"20\">");
        $password_table->addHeaderCentered("<input type=\"submit\" name=\"change\" value=\"Update your password\">");
    }
    // Assemble the html.
    $page = "<h2>Your Preferences</h2>";
    $page .= "<form action=\"index.php\" method=\"POST\">";
    $page .= $cantimer_table->flush();
    $page .= "<input type=\"hidden\" name=\"action\" value=\"changecanpage\">";
    $page .= "<input type=\"hidden\" name=\"check\" value=\"check\"></form>";
    $page .= "<form action=\"index.php\" method=\"POST\">";
    $page .= $opt_table->flush();
    $page .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $page .= "<input type=\"hidden\" name=\"action\" value=\"optIn\"></form>";
    $page .= "<form action=\"index.php\" method=\"POST\">";
    $page .= $sir_table->flush();
    $page .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $page .= "<input type=\"hidden\" name=\"action\" value=\"sirchange\"></form>";
    if ($MySelf->canChangeEmail()) {
        $page .= "<form action=\"index.php\" method=\"post\">";
        $page .= $email_table->flush();
        $page .= "<input type=\"hidden\" name=\"action\" value=\"changeemail\">";
        $page .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
        $page .= "</form>";
    }
    if ($MySelf->canChangePwd()) {
        $page .= "<form action=\"index.php\" method=\"post\">";
        $page .= $password_table->flush();
        $page .= "<input type=\"hidden\" name=\"action\" value=\"changepw\">";
        $page .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
        $page .= "<input type=\"hidden\" name=\"username\" value=\"%%USERNAME%%\">";
        $page .= "</form>";
    }
    // Api Keys
    // Load possible current keys.
    $api = new api($MySelf->getID());
    $api_key = $api->getApiKey();
    $api_id = $api->getApiID();
    if (!$api->valid()) {
        $api->authorizeApi();
    }
    // Do the api table.
    $api_table = new table(2, true);
    $api_table->addHeader(">> Api key management");
    $api_table->addRow();
    $api_table->addCol("Here you can supply your limited-access API-Key. Its used for quick-login for now.", array("colspan" => 2));
    if ($api_id && $api->valid()) {
        $s1 = "<input type =\"hidden\" name=\"apiID\" value=\"{$api_id}\">{$api_id}";
    } else {
        $s1 = "<input type=\"text\" name=\"apiID\" value=\"{$api_id}\">";
        $doApiLink = true;
    }
    if ($api_key && $api->valid()) {
        $s2 = "<input type =\"hidden\" name=\"apiKey\" value=\"{$api_key}\">{$api_key}";
    } else {
        $s2 = "<input type=\"text\" size=\"80\" name=\"apiKey\" value=\"{$api_key}\">";
        $doApiLink = true;
    }
    $api_table->addRow();
    $api_table->addCol("API ID:");
    $api_table->addCol($s1);
    $api_table->addRow();
    $api_table->addCol("Verification Code:");
    $api_table->addCol($s2);
    // Add the API link to eve online.
    global $IGB;
    global $IGB_VISUAL;
    if ($doApiLink && (!$IGB || $IGB && $IGB_VISUAL)) {
        $api_table->addRow();
        $api_table->addCol("Get your API key here:");
        $api_table->addCol("<a href=\"http://support.eveonline.com/api/default.asp\">http://support.eveonline.com/api/default.asp</a>");
    }
    if ($api_key) {
        $api_table->addRow();
        $api_table->addCol("API Key validated:");
        if (!$api->valid()) {
            $hint = " (If your key is not validated, hit update API key button.)";
        }
        $api_table->addCol(yesno($api->valid(), yes) . $hint);
        if ($api->valid()) {
            $api_table->addRow();
            $api_table->addCol("Validated on:");
            $api_table->addCol(date("d.m.Y H:i:s", $api->validatedOn()));
            $api_table->addRow();
            $api_table->addCol("Next verification at:");
            $api_table->addCol(date("d.m.Y H:i:s", $api->nextValidation()));
            $api_table->addRow();
            $api_table->addCol("API keys are valid for:");
            $days = getConfig("api_keys_valid");
            if ($days <= 1) {
                $days = "1 day.";
            } else {
                $days = $days . " days.";
            }
            $api_table->addCol($days);
            $api_table->addRow();
            $api_table->addCol("Character ID:");
            $api_table->addCol($api->getCharacterID());
        }
        $api_table->addRow();
        $api_table->addCol("Remove Key:");
        $api_table->addCol("<input type=\"checkbox\" name=\"deleteKey\" value=\"true\"> Tick box to remove the API key from the Database.");
    }
    $api_table->addHeaderCentered("<input type=\"submit\" name=\"update_api\" value=\"Update API Key\">");
    $api_form .= "<form action=\"index.php\" method=\"POST\">";
    $api_form .= $api_table->flush();
    $api_form .= "<input type=\"hidden\" name=\"action\" value=\"update_api\">";
    $api_form .= "<input type=\"hidden\" name=\"check\" value=\"check\"></form>";
    $page .= $api_form;
    // We are done here.
    return $page;
}
Beispiel #16
0
function makeCanPage()
{
    // Defining some globals.
    global $DB;
    global $TIMEMARK;
    global $MySelf;
    global $PREFS;
    $USERNAME = $MySelf->getUsername();
    $USERID = $MySelf->getID();
    $TTL = getConfig("canLifeTime") * 60;
    // is the cargo module active?
    if (!getConfig("cargocontainer")) {
        makeNotice("The admin has deactivated the events module.", "warning", "Module not active");
    }
    // Get all current locations.
    $locations = $DB->getCol("SELECT DISTINCT location FROM runs ORDER BY location");
    // Get all current cans.
    $cans = $DB->getAssoc("SELECT * from cans");
    // Get last can-nr.
    $canNaming = $PREFS->getPref("CanNaming");
    // Query the database accordingly.
    if ($canNaming == 1) {
        $maxCan = $DB->getCol("SELECT MAX(name) as max FROM cans WHERE pilot = '{$USERID}'");
    } else {
        $maxCan = $DB->getCol("SELECT MAX(name) as max FROM cans");
    }
    // For can-naming: Increment the number.
    if ($maxCan[0] == "") {
        // No can jettisoned yet.
        $canname = "001";
    } else {
        if (is_numeric($maxCan[0])) {
            // Can ejected, and it is numeric, we can increase that number.
            $canname = str_pad($maxCan[0] + 1, "3", "0", STR_PAD_LEFT);
        } else {
            // User entered some non-numerical stuff, can not increase.
            unset($canname);
        }
    }
    // Get the system the users mining operation takes place in, if any.
    $myRun = userInRun($USERNAME);
    if ($myRun != false) {
        $myLocation = $DB->getCol("SELECT location FROM runs WHERE id='{$myRun}'");
        $myLocation = $myLocation[0];
    }
    // Assemble the locations dropdown menu.
    if (!empty($locations)) {
        // Loop through all the locations.
        foreach ($locations as $location) {
            // And preselect the location the users miningrun takes place, if any.
            if ("{$location}" == "{$myLocation}") {
                $ddm .= "<option selected value=\"{$location}\">{$location}</option>";
            } else {
                $ddm .= "<option value=\"{$location}\">{$location}</option>";
            }
        }
    }
    // Select all current cans owned by the pilot.
    $CansDS = $DB->query("SELECT location, droptime, name, id, isFull, miningrun FROM cans WHERE pilot = '{$USERID}' ORDER BY droptime ASC");
    if ($CansDS->numRows() > 0) {
        // We have at least one can out there, lets do this.
        $myCans = new table(7, true);
        $myCans->addHeader(">> My cargo containers in space");
        $mode = array("bold" => true);
        $myCans->addRow("#060622");
        $myCans->addCol("Name", $mode);
        $myCans->addCol("Location", $mode);
        $myCans->addCol("Self or Run", $mode);
        $myCans->addCol("Droptime", $mode);
        $myCans->addCol("est. Poptime", $mode);
        $myCans->addCol("Time Left", $mode);
        $myCans->addCol("Can is full", $mode);
        while ($can = $CansDS->fetchRow()) {
            $candroptime = $can[droptime];
            // Time of can drop.
            $poptime = $candroptime + $TTL;
            // Extimated pop time (droptime + 1h)
            $timeleft = $candroptime + $TTL - $TIMEMARK;
            // Time left (poptime - current time)
            $minsleft = str_pad(number_format(($timeleft - 60) / 60, 0), "2", "0", STR_PAD_LEFT);
            $secsleft = str_pad($timeleft % 60, "2", "0", STR_PAD_LEFT);
            if ($secsleft < 1) {
                // We want all negative amounts to read "00".
                $secsleft = "00";
            }
            // Colorize the remaining time
            if ($minsleft >= 30) {
                // More or equal 30 mins: Green. We are cool.
                $color = "#88ff88";
            } elseif ($minsleft <= 29 && $minsleft >= 15) {
                // Less or equal 29 mins: Yellow, keep an eye out.
                $color = "#FFFF00";
            } elseif ($minsleft < 15) {
                // Less than 15 minutes: Ayee! RED! Refresh!s
                $color = "#FF0000";
            }
            $myCans->addRow();
            $myCans->addCol("<a href=\"index.php?action=popcan&id={$can['id']}\"><b>{$can['name']}</b></a>");
            $system = new solarSystem($can[location]);
            $myCans->addCol($system->makeFancyLink());
            // Can for self or mining run?
            if ($can[miningrun] >= 0) {
                $myCans->addCol("<a href=\"index.php?action=show&id={$can['miningrun']}\">" . str_pad($can[miningrun], "5", "0", STR_PAD_LEFT) . "</a>");
            } else {
                $myCans->addCol("(for self)");
            }
            $myCans->addCol(date("H:i:s", $can[droptime]));
            $myCans->addCol(date("H:i:s", $poptime));
            // Can popped already?
            if ($minsleft > 0) {
                $myCans->addCol("<font color=\"{$color}\">" . numberToString($timeleft) . "</font>");
            } else {
                $myCans->addCol("<font color=\"{$color}\">POPPED</font>");
            }
            // Can full?
            if ($can[isFull]) {
                $myCans->addCol("<a href=\"index.php?action=togglecan&canid={$can['id']}\"><font color=\"#00ff00\">YES</font></a>");
            } else {
                $myCans->addCol("<a href=\"index.php?action=togglecan&canid={$can['id']}\">No</a>");
            }
        }
        // The delete all button.
        $myCans->addHeaderCentered("[<a href=\"index.php?action=popcan&id=all\">pop all cans</a>]");
        $MyCansExist = true;
    }
    // Select all current cans, belonging to the mining run.
    $MiningRun = userInRun($MySelf->getUsername());
    if ($MiningRun) {
        $CansDS = $DB->query("SELECT location, droptime, name, pilot, isFull, miningrun FROM cans WHERE miningrun='{$MiningRun}' ORDER BY droptime ASC");
        if ($CansDS->numRows() > 0) {
            // We got one or more can floating around that belong to our mining run.
            $runCans = new table(7, true);
            $runCans->addHeader(">> My operations's cargo containers in space");
            $runCans->addRow("#060622");
            $runCans->addCol("Name", $mode);
            $runCans->addCol("Owner", $mode);
            $runCans->addCol("Location", $mode);
            $runCans->addCol("Droptime", $mode);
            $runCans->addCol("est. Poptime", $mode);
            $runCans->addCol("time remaining", $mode);
            $runCans->addCol("is full", $mode);
            while ($can = $CansDS->fetchRow()) {
                // Same as above.
                $candroptime = $can[droptime];
                $timeleft = $candroptime + $TTL - $TIMEMARK;
                $minsleft = str_pad(number_format(($timeleft - 60) / 60, 0), "2", "0", STR_PAD_LEFT);
                $secsleft = str_pad($timeleft % 60, "2", "0", STR_PAD_LEFT);
                $poptime = $candroptime + $TTL;
                // No negative minutes..
                if ($secsleft < 1) {
                    $secsleft = "00";
                }
                // Colorize..
                if ($minsleft >= 30) {
                    $color = "#88ff88";
                } elseif ($minsleft < 29 && $minsleft >= 15) {
                    $color = "#FFFF00";
                } elseif ($minsleft < 15) {
                    $color = "#FF0000";
                }
                // Build table..
                $runCans->addRow();
                $runCans->addCol($can[name]);
                $runCans->addCol(idToUsername($can[pilot]));
                $system = new solarSystem($can[location]);
                $runCans->addCol($system->makeFancyLink());
                $runCans->addCol(date("H:i:s", $can[droptime]));
                $runCans->addCol(date("H:i:s", $poptime));
                // Can popped already?
                if ($minsleft > 0) {
                    $runCans->addCol("<font color=\"{$color}\">" . numberToString($timeleft) . "</font>");
                } else {
                    $runCans->addCol("<font color=\"{$color}\">POPPED</font>");
                }
                // Can full?
                if ($can[isFull]) {
                    $runCans->addCol("<font color=\"#00ff00\">YES</font>");
                } else {
                    $runCans->addCol("No");
                }
            }
            $runCansExists = true;
        }
    }
    // Select all current cans, regardless
    $CansDS = $DB->query("SELECT location, droptime, name, pilot, isFull FROM cans WHERE pilot <> '{$USERID}' ORDER BY droptime ASC");
    if ($CansDS->numRows() > 0) {
        // There is at least.. yeah..
        $allCans = new table(7, true);
        $allCans->addHeader(">> All containers floating in space");
        $allCans->addRow("#060622");
        $allCans->addCol("Name", $mode);
        $allCans->addCol("Owner", $mode);
        $allCans->addCol("Location", $mode);
        $allCans->addCol("Droptime", $mode);
        $allCans->addCol("est. Poptime", $mode);
        $allCans->addCol("time remaining", $mode);
        $allCans->addCol("is full", $mode);
        while ($can = $CansDS->fetchRow()) {
            // Time-stuff, yet again.
            $candroptime = $can[droptime];
            $timeleft = $candroptime + $TTL - $TIMEMARK;
            $minsleft = str_pad(number_format(($timeleft - 60) / 60, 0), "2", "0", STR_PAD_LEFT);
            $secsleft = str_pad($timeleft % 60, "2", "0", STR_PAD_LEFT);
            $poptime = $candroptime + $TTL;
            // no neg mins..
            if ($secsleft < 1) {
                $secsleft = "00";
            }
            // color..
            if ($minsleft >= 30) {
                $color = "#88ff88";
            } elseif ($minsleft < 29 && $minsleft >= 15) {
                $color = "#FFFF00";
            } elseif ($minsleft < 15) {
                $color = "#FF0000";
            }
            $allCans->addRow();
            $allCans->addCol($can[name]);
            $allCans->addCol(idToUsername($can[pilot]));
            $system = new solarSystem($can[location]);
            $allCans->addCol($system->makeFancyLink());
            $allCans->addCol(date("H:i:s", $can[droptime]));
            $allCans->addCol(date("H:i:s", $poptime));
            // Can popped already?
            if ($minsleft > 0) {
                $allCans->addCol("<font color=\"{$color}\">" . numberToString($timeleft) . "</font>");
            } else {
                $allCans->addCol("<font color=\"{$color}\">POPPED</font>");
            }
            // Can full?
            if ($can[isFull]) {
                $allCans->addCol("<font color=\"#00ff00\">YES</font>");
            } else {
                $CANS_other .= "<td align=\"center\">No</td>";
                $allCans->addCol("No");
            }
        }
        $allCansExists = true;
    }
    // Lets get down to html buisiness.
    // Show only what the man wants. Eh, Tony?
    global $PREFS;
    if ($PREFS->getPref("CanAddCans")) {
        // Create a new add-can table.
        $addFormTable = new table(2, true);
        $addFormTable->addHeader(">> Register a new cargo container");
        // Row: Name
        $addFormTable->addRow();
        $addFormTable->addCol("Container name:", $mode);
        $addFormTable->addCol("<input type=\"text\" name=\"cantag\" value=\"" . $canname . "\" maxlength=\"100\" size=\"20\">");
        // Row: Naming preferences
        $addFormTable->addRow();
        $addFormTable->addCol("Naming&nbsp;preferences:", $mode);
        // Pre-select the current preferences.
        switch ($canNaming) {
            case "0":
                $c1 = "selected";
                break;
            case "1":
                $c2 = "selected";
                break;
            case "2":
                $c3 = "selected";
                break;
        }
        $canNamingPDM = "<select name=\"canprefs\">" . "<option " . $c1 . " value=\"0\">Do not suggest names</option>" . "<option " . $c2 . " value=\"1\">Numbers - select your highest can-number</option>" . "<option " . $c3 . " value=\"2\">Numbers - select overall highest can-number</option>" . "</select>";
        $addFormTable->addCol($canNamingPDM);
        // Row: Location
        $addFormTable->addRow();
        $addFormTable->addCol("Location:", $mode);
        $addFormTable->addCol("<select name=\"location\">" . $ddm . "</select>");
        // Row: System
        $addFormTable->addRow();
        $addFormTable->addCol("<b>-or-</b> System name:", $mode);
        $addFormTable->addCol("<input type=\"text\" name=\"location2\">");
        // Row: Time of Launch
        $addFormTable->addRow();
        $addFormTable->addCol("Time of launch:", $mode);
        // Get a time-array and do the human friendly part.
        // Funnies: We always want to use "00" as the minute, and always at the start of the
        // NEXT hour.
        $times = humanTime("toHuman", $TIMEMARK);
        $timefield = "<input type=\"text\" name=\"ST_day\"    size=\"2\" maxlength=\"4\" value=\"" . $times[day] . "\">." . "<input type=\"text\" name=\"ST_month\"  size=\"2\" maxlength=\"4\" value=\"" . $times[month] . "\">." . "<input type=\"text\" name=\"ST_year\"   size=\"4\" maxlength=\"6\" value=\"" . $times[year] . "\">" . "&nbsp;&nbsp;" . "<input type=\"text\" name=\"ST_hour\"   size=\"2\" maxlength=\"4\" value=\"" . $times[hour] . "\">:" . "<input type=\"text\" name=\"ST_minute\" size=\"2\" maxlength=\"4\" value=\"" . $times[minute] . "\">";
        $addFormTable->addCol($timefield . " <i>(d:m:y, h:m)</i>");
        // Row: Belongs to run
        $addFormTable->addRow();
        $addFormTable->addCol("For mining op:", $mode);
        if ($PREFS->getPref("CanForRun")) {
            $addFormTable->addCol("<input type=\"checkbox\" CHECKED name=\"forRun\" value=\"true\"> Tick this if the can(s) you are dropping are part of your mining run, if any.");
        } else {
            $addFormTable->addCol("<input type=\"checkbox\" CHECKED name=\"forRun\" value=\"true\"> Tick this if the can(s) you are dropping are part of your mining run, if any.");
        }
        // Row: Submit button.
        $addFormTable->addHeaderCentered("<input type=\"submit\" name=\"create\" value=\"Register can in Database\">" . "<input type=\"hidden\" name=\"action\" value=\"addcan\">" . "<input type=\"hidden\" name=\"check\" value=\"true\">");
    }
    $html = "<h2>Cargo container chronograph</h2>";
    if ($PREFS->getPref("CanAddCans")) {
        $html .= "<form action=\"index.php\" method=\"post\">" . $addFormTable->flush();
    }
    if ($PREFS->getPref("CanMyCans") && $MyCansExist) {
        $html .= "<br>" . $myCans->flush();
    }
    if ($PREFS->getPref("CanRunCans") && $runCansExists) {
        $html .= "<br>" . $runCans->flush();
    }
    if ($PREFS->getPref("CanAllCans") && $allCansExists) {
        $html .= "<br>" . $allCans->flush();
    }
    return $html . "</form>";
}
Beispiel #17
0
function makeNewOreRunPage()
{
    // Load the globals.
    global $VERSION;
    global $SITENAME;
    global $TIMEMARK;
    global $ORENAMES;
    global $DBORE;
    global $DB;
    global $MySelf;
    $locationPDM = "";
    // We need a list of all the previous run locations.
    $locations = $DB->query("SELECT DISTINCT location FROM runs ORDER BY location");
    if ($locations->numRows() > 0) {
        while ($location = $locations->fetchRow()) {
            $locationPDM .= "<option value=\"" . $location['location'] . "\">" . $location['location'] . "</option>";
        }
        $locationPDM = "<select name=\"locations\">" . $locationPDM . "</select>";
    }
    // Table
    $table = new table(2, true);
    $table->addHeader(">> Create a new operation");
    $table->addRow();
    // Field: Location.
    $table->addCol("Location of Operation:");
    if ($locationPDM) {
        // We have at least one possible System we hauled before.
        $table->addCol($locationPDM . " -or- <input type=\"text\" name=\"location\">");
    } else {
        // There are not target systems in the database.
        if (getConfig("trustSetting") > 0) {
            $table->addCol("<input type=\"text\" value=\"" . $_SERVER['HTTP_EVE_SOLARSYSTEMNAME'] . "\" name=\"location\">");
        } else {
            $table->addCol("<input type=\"text\" name=\"location\">");
        }
    }
    $pdm = "";
    // Field: Officer in Charge
    if ($MySelf->isOfficial()) {
        $SeniorUsers = $DB->getCol("SELECT DISTINCT username FROM users WHERE canCreateRun = 1 AND deleted='0' ORDER BY username");
        foreach ($SeniorUsers as $senior) {
            if ($MySelf->getUsername() == "{$senior}") {
                $pdm .= "<option value=\"{$senior}\" selected>" . ucwords($senior) . "</option>";
            } else {
                $pdm .= "<option value=\"{$senior}\">" . ucwords($senior) . "</option>";
            }
            $seniorUsersPDM = "<select name=\"supervisor\">" . $pdm . "</select>";
        }
    } else {
        // In case the user is not a senior member he can not change the officer in charge.
        $seniorUsersPDM = ucfirst($MySelf->getUsername());
        $seniorUsersPDM .= "<input type=\"hidden\" name=\"supervisor\" value=\"" . $MySelf->getUsername() . "\">";
    }
    // We have no senior member (aka: people who may start runs)
    if (!$seniorUsersPDM) {
        makeNotice("No one from your current users may create or lead a mining operation. Please give out appropiate permissions.", "warning", "Insufficient Rights");
    } else {
        $table->addRow();
        $table->addCol("Executing Officer:");
        $table->addCol($seniorUsersPDM);
    }
    $table->addRow();
    $table->addCol("Op Type:");
    $OPTYPE = isset($_REQUEST['optype']) ? $_REQUEST['optype'] : "";
    $ops = $DB->getAll("select opName from opTypes;");
    if ($DB->isError($ops)) {
        die($ops->getMessage());
    }
    $opSelect = "<select name='optype' onChange='window.location = \"?action=newrun&optype=\"+this.value'>\n";
    $opSelect .= "<option value=''>Standard</option>\n";
    foreach ($ops as $op) {
        $default = $op['opName'] == $OPTYPE ? "selected" : "";
        $opSelect .= "<option {$default} value='" . $op['opName'] . "'>" . $op['opName'] . "</option>\n";
    }
    $opSelect .= "</select>";
    $table->addCol($opSelect);
    // Field: Corporation keeps.
    $table->addRow();
    $table->addCol("Corporation keeps:");
    // Get the average amount.
    if ($MySelf->isOfficial()) {
        if (!getConfig("defaultTax")) {
            // No default tax has been defined in the config file, generate our own.
            $tax = $DB->getCol("SELECT AVG(corpKeeps) AS tax FROM runs;");
            $tax = round($tax[0]);
            // in case there are no taxes yet AND no default has been set.
            if (!$tax) {
                $tax = "15";
            }
        } else {
            if ($OPTYPE == "Shopping") {
                $tax = "0";
            } else {
                // Set the default tax, according to config.
                $tax = getConfig("defaultTax");
            }
        }
        $table->addCol("<input readonly=\"readonly\" type=\"text\" maxlength=\"3\" value=\"{$tax}\" size=\"4\" name=\"corpkeeps\">% of gross value.");
    } else {
        $table->addCol("As this is not an official Op, no tax is deducted.");
    }
    // Give option to make this run official.
    if ($MySelf->isOfficial()) {
        $table->addRow();
        $table->addCol("Official Run:");
        $table->addCol("<input type=\"checkbox\" name=\"isOfficial\" checked=\"checked\" >Tick box if this is an official mining run.");
    }
    // Field: Starttime.
    $table->addRow();
    $table->addCol("Starttime:");
    // Get a time-array and do the human friendly part.
    // Funnies: We always want to use "00" as the minute, and always at the start of the
    // NEXT hour.
    $times = humanTime("toHuman", $TIMEMARK + 3600);
    $timefield = "<input type=\"text\" name=\"ST_day\"    size=\"4\" maxlength=\"2\" value=\"" . $times['day'] . "\">." . "<input type=\"text\" name=\"ST_month\"  size=\"4\" maxlength=\"2\" value=\"" . $times['month'] . "\">." . "<input type=\"text\" name=\"ST_year\"   size=\"6\" maxlength=\"4\" value=\"" . $times['year'] . "\">" . "&nbsp;&nbsp;" . "<input type=\"text\" name=\"ST_hour\"   size=\"4\" maxlength=\"2\" value=\"" . $times['hour'] . "\">:" . "<input type=\"text\" name=\"ST_minute\" size=\"4\" maxlength=\"2\" value=\"00\">";
    $orNow = "<input type=\"checkbox\" name=\"startnow\" value=\"true\" checked=\"checked\" > start now";
    $or = " - or - ";
    $table->addCol($orNow . $or . $timefield);
    $table->addRow();
    $table->addCol("format: day.month.year hour:minute", array("align" => "right", "colspan" => "2"));
    // Now we need the sum of all ores.
    //$totalOres = count($ORENAMES);
    /*
    // And the sum of all ENABLED ores.
    $totalEnabledOres = $DB->getCol("select count(name) as active from config where name LIKE '%".$OPTYPE."Enabled' AND value='1'");
    $totalEnabledOres = $totalEnabledOres[0];
    */
    /*
     * This is evil. We have to create an array that we fill up sorted.
     * It aint cheap. First, we loop through all the ore values.
     */
    /*
    for ($p = 0; $p < $totalOres; $p++) {
    	// Then we check each ore if it is enabled.
    	$ORE = $DBORE[$ORENAMES[$p]];
    	if (getOreSettings($ORE,$OPTYPE)) {
    		// If the ore is enabled, add it to the array.
    		$left[] = $ORE;
    	} else {
    		// add to disabled-array.
    		$disabledOres[] = $ORE;
    	}
    }
    
    $totalEnabledOres = count($left);
    
    // No ores enabled?
    if ($totalEnabledOres == 0) {
    	makeNotice("Your CEO has disabled *all* the Oretypes. Please ask your CEO to reactivate at leat one Oretype.", "error", "No valid Oretypes!");
    }
    
    // The table is, rounded up, exactly half the size of all enabled ores.
    $tableLength = ceil($totalEnabledOres / 2);
    // Now, copy the lower second half into a new array.
    $right = array_slice($left, $tableLength);
    */
    /*
     * So now we have an array of all the enabled ores. All we
     * need to do now, is create a nice, handsome table of it.
     * Loop through this array.
     */
    /*
    for ($i = 0; $i < $tableLength; $i++) {
    
    	// Fetch the right image for the ore.
    	$ri_words = str_word_count(array_search($left[$i], $DBORE), 1);
    	$ri_max = count($ri_words);
    	$ri = strtolower($ri_words[$ri_max -1]);
    
    	// Add a row.
    	$table->addRow();
    
    	// left side.
    	$table->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . array_search($left[$i], $DBORE) . ".png\"> <input type=\"text\" name=\"$left[$i]\" size=\"10\" value=\"0\"> " . array_search($left[$i], $DBORE) . " wanted. ");
    
    	// We need an ore type (just in case of odd ore numbers)
    	if ($right[$i] != "") {
    		// right side.
    
    		// Fetch the right image for the ore.
    		$ri_words = str_word_count(array_search($right[$i], $DBORE), 1);
    		$ri_max = count($ri_words);
    		$ri = strtolower($ri_words[$ri_max -1]);
    
    		// Add the column.
    		$table->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . array_search($right[$i], $DBORE) . ".png\"> <input type=\"text\" name=\"$right[$i]\" size=\"10\" value=\"0\"> " . array_search($right[$i], $DBORE) . " wanted. ");
    
    	} else {
    		// We have an odd number of ores: add empty cell.
    		$table->addCol("");
    	}
    
    }
    
    // Display the ore-disables-disclaimer. (Only if there are disabled oretypes.)
    if (!empty ($disabled)) {
    	$disabledText = "The following Oretypes has been disabled by the CEO: $disabled";
    }
    */
    $submitbutton = "<input type=\"hidden\" name=\"check\" value=\"true\">" . "<input type=\"hidden\" value=\"addrun\" name=\"action\">" . "<input type=\"submit\" value=\"Create new Operation\" name=\"submit\">";
    // El grande submit button!
    $table->addHeaderCentered($submitbutton);
    /*
    	// Show, if any, disabled ore-types.
    	if ($disabledText) {
    		$table->addRow();
    		$table->addCol("<br><br>" . $disabledText . ".", array (
    			"colspan" => "2"
    		));
    	}*/
    // Render the table, and return it.
    return "<h2>Create a new Operation</h2><form action=\"index.php\" method=\"POST\">" . $table->flush() . "</form>";
}
Beispiel #18
0
function manageWallet()
{
    // Globals
    global $MySelf;
    global $DB;
    $MyCredits = getCredits($MySelf->getID());
    // Get (recent?) transactions
    $html = getTransactions($MySelf->getID());
    if ($MyCredits > 0) {
        // Create the dropdown menu with all pilots.
        $NamesDS = $DB->query("SELECT DISTINCT username, id FROM users WHERE deleted='0' ORDER BY username");
        $ddm = "<select name=\"to\">";
        while ($name = $NamesDS->fetchRow()) {
            // Lets not allow transfers to self.
            if ($name[id] != $MySelf->getID()) {
                $ddm .= "<option value=\"" . $name[id] . "\">" . ucfirst($name[username]) . "</option>";
            }
        }
        $ddm .= "</select>";
        $tt = new table(2, true);
        $tt->addHeader(">> Transfer ISK");
        $tt->addRow("#060622");
        $tt->addCol("You can transfer ISK into another Pilots wallet by using this form.", array("colspan" => 2));
        $tt->addRow();
        $tt->addCol("Transfer from:");
        $tt->addCol(ucfirst($MySelf->getUsername()));
        $tt->addRow();
        $tt->addCol("Transfer to:");
        $tt->addCol($ddm);
        $tt->addRow();
        $tt->addCol("Amount:");
        $tt->addCol("<input type=\"text\" name=\"amount\">");
        $tt->addRow();
        $tt->addCol("Reason:");
        $tt->addCol("<input type=\"text\" name=\"reason\">");
        $tt->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Transfer money\">");
        // Create form stuff, and embed the table within.
        $transfer = "<form action=\"index.php\" method=\"POST\">";
        $transfer .= $tt->flush();
        $transfer .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
        $transfer .= "<input type=\"hidden\" name=\"action\" value=\"transferMoney\">";
        $transfer .= "</form>";
        // Create the payout form.
        $payout = new table(2, true);
        $payout->addHeader(">> Request payout");
        $payout->addRow("#060622");
        $payout->addCol("Fill out this form to request payout of ISK. An accountant will honor your request soon.", array("colspan" => 2));
        $payout->addRow();
        $payout->addCol("Payout amount:");
        $payout->addCol("<input type=\"text\" name=\"amount\" value=\"" . $MyCredits . "\"> ISK");
        $payout->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"request payout\">");
        // Create form stuff, and embed the table within.
        $requestPayout = "<form action=\"index.php\" method=\"POST\">";
        $requestPayout .= $payout->flush();
        $requestPayout .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
        $requestPayout .= "<input type=\"hidden\" name=\"action\" value=\"requestPayout\">";
        $requestPayout .= "</form>";
    }
    /*
     * Show current requests
     */
    $requests = $DB->query("SELECT * FROM payoutRequests WHERE payoutTime IS NULL AND applicant='" . $MySelf->getID() . "' ORDER BY time");
    $table = new table(4, true);
    $table->addHeader(">> Pending payout requests");
    $table->addRow("#060622");
    $table->addCol("request");
    $table->addCol("time");
    $table->addCol("amount");
    $table->addCol("Cancel");
    while ($request = $requests->fetchRow()) {
        $table->addRow();
        $table->addCol("#" . str_pad($request[request], "5", "0", STR_PAD_LEFT));
        $table->addCol(date("d.m.y H:i:s", $request[time]));
        $table->addCol(number_format($request[amount], 2) . " ISK");
        $table->addCol("<input type=\"checkbox\" name=\"" . $request[request] . "\" value=\"true\">");
        $haveRequest = true;
    }
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"cancel marked requests\">");
    $takeBack = "<form action=\"index.php\" method=\"POST\">";
    $takeBack .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $takeBack .= "<input type=\"hidden\" name=\"action\" value=\"deleteRequest\">";
    $takeBack .= $table->flush();
    $rakeBack .= "</form>";
    /*
     * Show fulfilled requests
     */
    $requests = $DB->query("SELECT * FROM payoutRequests WHERE payoutTime IS NOT NULL AND applicant='" . $MySelf->getID() . "' ORDER BY time");
    $table_done = new table(5, true);
    $table_done->addHeader(">> Fulfilled payout requests");
    $table_done->addRow("#060622");
    $table_done->addCol("request");
    $table_done->addCol("time");
    $table_done->addCol("amount");
    $table_done->addCol("Payout time");
    $table_done->addCol("Paid by");
    while ($request = $requests->fetchRow()) {
        $table_done->addRow();
        $table_done->addCol("#" . str_pad($request[request], "5", "0", STR_PAD_LEFT));
        $table_done->addCol(date("d.m.y H:i:s", $request[time]));
        $table_done->addCol(number_format($request[amount], 2) . " ISK");
        $table_done->addCol(date("d.m.y H:i:s", $request[payoutTime]));
        $table_done->addCol(ucfirst(idToUsername($request[banker])));
        $haveOldRequests = true;
    }
    if ($html) {
        $html = "<h2>Your Wallet</h2>" . $html . "<br>" . $requestPayout . $transfer;
        if ($haveRequest) {
            $html .= $takeBack . "<br>";
        }
        if ($haveOldRequests) {
            $html .= $table_done->flush();
        }
    } else {
        $html = "<h2>Your Wallet</h2>Once your wallet has any transactions you can view the details here. And once you obtained a positive balance you can transfer money and request payouts.<br>";
    }
    return $html;
}
Beispiel #19
0
function showRanks()
{
    // We needeth the databaseth!
    global $DB;
    global $MySelf;
    // Is sire alloweth to logineth?
    if (!$MySelf->canEditRank()) {
        makeNotice("You do not have sufficient rights to access this page.", "warning", "Access denied");
    }
    // Get all current ranks.
    $ranks_ds = $DB->query("SELECT * FROM ranks ORDER BY rankOrder ASC");
    $currentRanks = $ranks_ds->numRows();
    // Are there any ranks defined yet?
    if ($currentRanks > 0) {
        // Yuh. Create table.
        $headerConfig = array("bold" => true, "align" => "center");
        $table = new table(4, true);
        $table->addHeader(">> Edit current ranks");
        $table->addRow();
        $table->addCol("Rank Order", $headerConfig);
        $table->addCol("Rank Name", $headerConfig);
        $table->addCol("Nr. of times Issued", $headerConfig);
        $table->addCol("Delete Rank", $headerConfig);
        // Create a nice, fancy row for every rank.
        while ($rank = $ranks_ds->fetchRow()) {
            $table->addRow();
            for ($i = 1; $i <= $currentRanks; $i++) {
                $ro = str_pad($i, 3, "0", STR_PAD_LEFT);
                if ($rank[rankOrder] == $i) {
                    $pdm .= "<option SELECTED value=\"{$ro}\">{$i}</option>";
                } else {
                    $pdm .= "<option value=\"{$ro}\">{$i}</option>";
                }
            }
            $ddm = "<select name=\"order_" . $rank[rankid] . "\">" . $pdm . "</select>";
            $table->addCol($ddm, $headerConfig);
            $table->addCol("<input type=\"text\" name=\"title_" . $rank[rankid] . "_name\" value=\"" . $rank[name] . "\">", $headerConfig);
            // how many times has the rank been issue?
            $count = $DB->getCol("SELECT COUNT(id) FROM users WHERE rank='{$rank['rankid']}' AND deleted='0'");
            $count = $count[0];
            if ($count < 1) {
                $table->addCol("<i>Rank not used</i>");
            } else {
                $table->addCol($count);
            }
            $table->addCol("<a href=\"index.php?action=deleterank&id={$rank['rankid']}\">delete</a>", $headerConfig);
            unset($pdm);
            unset($ddm);
        }
        // Submit button & stuff.
        $hidden = "<input type=\"hidden\" name=\"check\"  value=\"true\">" . "<input type=\"hidden\" name=\"action\"  value=\"editranks\">";
        $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Update Ranks\">");
        $rankTable = "<form action=\"index.php\" method=\"POST\">" . $table->flush() . $hidden . "</form>";
        unset($table);
        unset($currentRanks);
    }
    // Create the new-rank-form-jiggamajig.
    $table = new table(2, true);
    $table->addHeader(">> Add a new rank");
    $table->addRow();
    $table->addCol("Rank name:");
    $table->addCol("<input type=\"text\" name=\"rankname\">");
    $hidden = "<input type=\"hidden\" name=\"check\"  value=\"true\">" . "<input type=\"hidden\" name=\"action\"  value=\"addnewrank\">";
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Add Rank\">");
    $addRankTable = "<form action=\"index.php\" method=\"POST\">" . $table->flush() . $hidden . "</form>";
    // Flush the page!
    return "<h2>Edit the ranks</h2>" . $rankTable . $addRankTable;
}
Beispiel #20
0
function onlineTime()
{
    // We need funky globals!
    global $DB;
    global $MySelf;
    global $TIMEMARK;
    /*
     * The change form.
     */
    $MySetting = $DB->query("SELECT * FROM onlinetime WHERE userid='" . $MySelf->getID() . "'");
    $MySetting = $MySetting->numRows();
    if ($MySetting == 0 || $_GET[edit]) {
        $setTable = new table(3, true);
        $setTable->addHeader(">> Set your online time");
        // Fetch el grande saved array. Ole!
        $myOnlineTime = $DB->getAssoc("SELECT * FROM onlinetime WHERE userid='" . $MySelf->getID() . "' LIMIT 1");
        $myOnlineTime = $myOnlineTime[$MySelf->getID()];
        // Loop through the hours.
        $j = 0;
        for ($i = 0; $i <= 23; $i++) {
            // Add a new row every 3rd time we are here, startign with first.
            if ($j == 0) {
                $setTable->addRow();
                $j = 3;
            }
            // 01-02, 02-03.. etc
            $p = str_pad($i, 2, "0", STR_PAD_LEFT) . "-" . str_pad($i + 1, 2, "0", STR_PAD_LEFT);
            // Wow this is ugly. Pre-select all values that are stored in the db.
            $ppdv0 = "<option value=\"0\">0</option>";
            $ppdv1 = "<option value=\"1\">1</option>";
            $ppdv2 = "<option value=\"2\">2</option>";
            $ppdv3 = "<option value=\"3\">3</option>";
            $column = "h" . str_pad($i, 2, "0", STR_PAD_LEFT);
            switch ($myOnlineTime[$column]) {
                case "0":
                    $ppdv0 = "<option selected value=\"0\">0</option>";
                    break;
                case "01":
                    $ppdv1 = "<option selected value=\"1\">1</option>";
                    break;
                case "2":
                    $ppdv2 = "<option selected value=\"2\">2</option>";
                    break;
                case "3":
                    $ppdv3 = "<option selected value=\"3\">3</option>";
                    break;
            }
            $ppd = $ppdv0 . $ppdv1 . $ppdv2 . $ppdv3;
            $s = "<select name=\"{$i}\">";
            $setTable->addCol($p . $s . $ppd . "</select>");
            // Substract one.
            $j--;
        }
        // explain:
        $setTable->addRow();
        $setTable->addCol("Code 0: You cant play at all. (sleep, work)", array("colspan" => 3));
        $setTable->addRow();
        $setTable->addCol("Code 1: You could, but normaly wouldnt, except for extreme cases.", array("colspan" => 3));
        $setTable->addRow();
        $setTable->addCol("Code 2: You can easily be online, but normaly are not.", array("colspan" => 3));
        $setTable->addRow();
        $setTable->addCol("Code 3: Your preffered online time.", array("colspan" => 3));
        $submitbutton = "<input type=\"hidden\" name=\"check\" value=\"true\">" . "<input type=\"hidden\" value=\"modonlinetime\" name=\"action\">" . "<input type=\"submit\" value=\"Update your OnlineTime\" name=\"submit\">";
        $setTable->addHeaderCentered("All times are EvE time!");
        $setTable->addHeaderCentered($submitbutton);
        $form .= "<form action=\"index.php\" method=\"POST\">";
        $form .= $setTable->flush();
        $form .= "</form>";
    } else {
        $editLink = "<br>[<a href=\"index.php?action=onlinetime&edit=true\">Edit your times</a>]";
    }
    $page = "<h2>Online Time</h2>" . $form;
    /*
     * Okay pheew. That was the table to set your own time. Now lets create
     * a table to show everyones online time.
     */
    $onlineTime = new table(25, true);
    $onlineTime->addHeader(">> Online Time of your corporation");
    $onlineTime->addRow("#060622");
    $onlineTime->addCol("Member");
    $onlineTime->addCol("00");
    $onlineTime->addCol("01");
    $onlineTime->addCol("02");
    $onlineTime->addCol("03");
    $onlineTime->addCol("04");
    $onlineTime->addCol("05");
    $onlineTime->addCol("06");
    $onlineTime->addCol("07");
    $onlineTime->addCol("08");
    $onlineTime->addCol("09");
    $onlineTime->addCol("10");
    $onlineTime->addCol("11");
    $onlineTime->addCol("12");
    $onlineTime->addCol("13");
    $onlineTime->addCol("14");
    $onlineTime->addCol("15");
    $onlineTime->addCol("16");
    $onlineTime->addCol("17");
    $onlineTime->addCol("18");
    $onlineTime->addCol("19");
    $onlineTime->addCol("20");
    $onlineTime->addCol("21");
    $onlineTime->addCol("22");
    $onlineTime->addCol("23");
    // Ask the oracle.
    $cutOff = $TIMEMARK - 2592000;
    // 30 days.
    $OT = $DB->getCol("select distinct id from users where canLogin='******' and lastlogin >= '{$cutOff}'  AND deleted='0'");
    // Pilots names are not store in the onlinetable. So we have to translate.
    foreach ($OT as $pilotID) {
        $pilots[] = idToUsername($pilotID);
    }
    // Anyone published his online time yet?
    if (count($pilots) >= 1) {
        $haveOnlineTime = true;
    }
    // Sort the pilots by name.
    asort($pilots);
    // Create a row for each pilot.
    foreach ($pilots as $pilot) {
        // Get the pilots online times.
        $id = usernameToID($pilot);
        $ot = $DB->query("SELECT * FROM onlinetime WHERE userid='" . $id . "'");
        // break off here if the user has not publishes his online time yet.
        if ($ot->numRows() == 0) {
            continue;
        }
        $ot = $ot->fetchRow();
        $onlineTime->addRow();
        // Pilot name
        $onlineTime->addCol(ucfirst($pilot));
        // And go through each hour, creating a nice coloured box.
        for ($i = 0; $i <= 23; $i++) {
            $column = "h" . str_pad($i, 2, "0", STR_PAD_LEFT);
            // #222733  |  #4f646e  |  #c2c957  |  #e6f137
            switch ($ot[$column]) {
                case "0":
                    $onlineTime->addCol(" ", array("bgcolor" => "#222733"));
                    break;
                case "01":
                    $onlineTime->addCol(" ", array("bgcolor" => "#4f646e"));
                    break;
                case "2":
                    $onlineTime->addCol(" ", array("bgcolor" => "#c2c957"));
                    break;
                case "3":
                    $onlineTime->addCol(" ", array("bgcolor" => "#e6f137"));
                    break;
            }
        }
    }
    // Return the hard labor.
    /* Return the Online Table, or, If no one published his online time yet,
     * print a message saying just that. */
    if ($haveOnlineTime) {
        // We have at least one person who sent in his times.
        return $page . $onlineTime->flush() . $editLink;
    } else {
        // No one ever sent in his times.
        return $page . "<b>No one sent in his/her onlinetimes yet. But you can be the first! :)</b><br>" . $editLink;
    }
}
Beispiel #21
0
function configuration()
{
    /*
     * Checks, Setups ETC
     */
    // You guessed right.
    global $MySelf;
    global $DB;
    $config = array("align" => "right");
    // Are we an admin here?
    if (!$MySelf->isAdmin()) {
        makeNotice("You are not an admin, and are forbidden to be here.", "warning", "What are you sneaking 'round here?");
    }
    /*
     * Main Site Configuration
     */
    $table = new table(2, true);
    $table->addHeader(">> Edit configuration");
    // SiteName.
    $table->addRow();
    $table->addCol("Sitename:", $config);
    $table->addCol("<input type=\"text\" name=\"sitename\" size=\"70\" value=\"" . getConfig("sitename", true) . "\">");
    // Session Lifetime
    $table->addRow();
    $table->addCol("Session expiration in minutes:", $config);
    $table->addCol("<input type=\"text\" name=\"TTL\" value=\"" . getConfig("TTL", true) . "\">");
    // Time Offset.
    $currentOffset = getConfig("timeOffset", true);
    // Make the options.
    for ($i = -12; $i <= 12; $i++) {
        // Calculate offset for eve time.
        $eve = date("l, H:i", date("U") - $i * 60 * 60);
        if ("{$i}" == "{$currentOffset}") {
            $pdm .= "<option value=\"{$i}\" selected>EvE: {$eve} (offset: {$i} hours) (current)</option>";
        } else {
            $pdm .= "<option value=\"{$i}\">EvE: {$eve} (offset: {$i} hours)</option>";
        }
    }
    $table->addRow();
    $table->addCol("Server time offset:", $config);
    $table->addCol("<select name=\"timeOffset\">" . $pdm . "</select>");
    unset($pdm);
    // Ban goodness
    $table->addRow();
    $table->addCol("Autoban: Kicks in after ", $config);
    $table->addCol("<input type=\"text\" name=\"banAttempts\" value=\"" . getConfig("banAttempts", true) . "\"> attempts made within 15 minutes.");
    $table->addRow();
    $table->addCol("Autoban: ban holds", $config);
    $table->addCol("<input type=\"text\" name=\"banAttempts\" value=\"" . getConfig("banTime", true) . "\"> minutes.");
    // Can lifetime.
    if (getConfig("cargocontainer", true)) {
        $table->addRow();
        $table->addCol("Can lifetime in minutes:", $config);
        $table->addCol("<input type=\"text\" name=\"canLifeTime\" value=\"" . getConfig("canLifeTime", true) . "\">");
    }
    // Max Lotto tickets %
    if (getConfig("Lotto", true)) {
        $table->addRow();
        $table->addCol("Max Lotto tickets (%):", $config);
        $table->addCol("<input type=\"text\" name=\"LottoPercent\" value=\"" . getConfig("LottoPercent", true) . "\">");
    }
    // Default Tax.
    $table->addRow();
    $table->addCol("Default Corp tax (set to zero for dynamic):", $config);
    $table->addCol("<input type=\"text\" name=\"defaultTax\" value=\"" . getConfig("defaultTax", true) . "\">");
    // Trust, IGB.
    $table->addRow();
    $table->addCol("IGB Trust setting:", $config);
    unset($pdm);
    $trustSetting = getConfig("trustSetting", true);
    // Preselect the entry.
    if ($trustSetting == 0) {
        $pdm .= "<option selected value=\"0\">Do not trust IGB at all. (disable)</option>";
    } else {
        $pdm .= "<option value=\"0\">Do not trust IGB at all. (disable)</option>";
    }
    if ($trustSetting == 1) {
        $pdm .= "<option selected value=\"1\">Use IGB to prefill forms (enable, safe)</option>";
    } else {
        $pdm .= "<option value=\"1\">Use IGB to prefill forms (enable, safe)</option>";
    }
    if ($trustSetting == 2) {
        $pdm .= "<option selected value=\"2\">Allow fast login using API keys and IGB Trust (enable, somewhat safe)</option>";
    } else {
        $pdm .= "<option value=\"2\">Allow fast login using API keys and IGB Trust (enable, somewhat safe)</option>";
    }
    // Add the pull down menu to the form.
    $table->addCol("<select name=\"trustSetting\">" . $pdm . "</select>");
    // How long should API keys be valid?
    $table->addRow();
    $table->addCol("API keys are valid for:", $config);
    $apiKeysValid = getConfig("api_keys_valid");
    unset($pdm);
    $pdm = "<select name=\"api_keys\" >";
    for ($i = 1; $i <= 30; $i++) {
        if ($i == 1) {
            // Singular
            if ($i == $apiKeysValid) {
                $pdm .= "<option value=\"{$i}\" SELECTED >{$i} day</option>";
            } else {
                $pdm .= "<option value=\"{$i}\">{$i} day</option>";
            }
        } else {
            // Plural
            if ($i == $apiKeysValid) {
                $pdm .= "<option value=\"{$i}\" SELECTED >{$i} days</option>";
            } else {
                $pdm .= "<option value=\"{$i}\">{$i} days</option>";
            }
        }
    }
    $pdm .= "</select>";
    $table->addCol($pdm);
    //$table->addRow();
    //$table->addCol("Advanced Settings:", $config);
    //$advancedOptions = getConfig("advancedOptions", true);
    //if ($advancedOptions) {
    //	$pdm = "<option selected value=\"true\">Online</option>";
    //	$pdm .= "<option value=\"false\">Offline</option>";
    //} else {
    //	$pdm = "<option value=\"true\">Online</option>";
    //	$pdm .= "<option selected value=\"false\">Offline</option>";
    //}
    //$table->addCol("<select name=\"advancedOptions\">" . $pdm . "</select>");
    unset($pdm);
    // Use Market Values when loading Manage Ore Values
    $table->addRow();
    $table->addCol("Use Market for Ore Default Values:", $config);
    $useMarket = getConfig("useMarket", true);
    if ($useMarket == 1) {
        $table->addCol("<input name=\"useMarket\" value=\"true\" type=\"checkbox\" checked=\"checked\">");
    } else {
        $table->addCol("<input name=\"useMarket\" value=\"true\" type=\"checkbox\">");
    }
    if ($useMarket == 1) {
        // Select Region to get prices from
        $regionDS = $DB->query("SELECT * FROM `{$STATIC_DB}.mapRegions` ORDER BY regionName ASC");
        $regionCount = $regionDS->numRows();
        $useRegion = getConfig("useRegion", true);
        if ($regionCount >= 1) {
            // We have at least 1 region.
            while ($region = $regionDS->fetchRow()) {
                if ($region[regionID] == $useRegion) {
                    // The current region is selected.
                    $region_pdm .= "<option SELECTED value=\"{$region['regionID']}\">{$region['regionName']}</option>";
                } else {
                    // The others of course, are not.
                    $region_pdm .= "<option value=\"{$region['regionID']}\">{$region['regionName']}</option>";
                }
            }
            $regionColumn = "<select name=\"useRegion\">" . $region_pdm . "</select>";
        } else {
            // No regions are in tables.
            $regionColumn = "There are no regions. Region table is empty!";
        }
        $table->addRow();
        $table->addCol("Market Region to use:", $config);
        $table->addCol($regionColumn);
        // Select order type to use
        $table->addRow();
        $table->addCol("Order type to use:", $config);
        $orderType = getConfig("orderType", true);
        if ($orderType == 0) {
            $pdm .= "<option selected value=\"0\">Buy</option>";
        } else {
            $pdm .= "<option value=\"0\">Buy</option>";
        }
        if ($orderType == 1) {
            $pdm .= "<option selected value=\"1\">Sell</option>";
        } else {
            $pdm .= "<option value=\"1\">Sell</option>";
        }
        // Add the pull down menu to the form.
        $table->addCol("<select name=\"orderType\">" . $pdm . "</select>");
        unset($pdm);
        // Select Price Criteria
        $table->addRow();
        $table->addCol("Price Criteria to use:", $config);
        $priceCriteria = getConfig("priceCriteria", true);
        if ($priceCriteria == 0) {
            $pdm .= "<option selected value=\"0\">Min</option>";
        } else {
            $pdm .= "<option value=\"0\">Min</option>";
        }
        if ($priceCriteria == 1) {
            $pdm .= "<option selected value=\"1\">Max</option>";
        } else {
            $pdm .= "<option value=\"1\">Max</option>";
        }
        if ($priceCriteria == 2) {
            $pdm .= "<option selected value=\"2\">Median</option>";
        } else {
            $pdm .= "<option value=\"2\">Median</option>";
        }
        // Add the pull down menu to the form.
        $table->addCol("<select name=\"priceCriteria\">" . $pdm . "</select>");
        unset($pdm);
    }
    // End of table.
    $table->addRow("#060622");
    $table->addCol("All new settings require a relogin to take effect.", array("colspan" => "2"));
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Update configuration\">");
    /*
     * MODULES
     */
    $modules_table = new table(2, true);
    $modules_table->addHeader(">> Enable or disable modules");
    // Events enable.
    $modules_table->addRow();
    $modules_table->addCol("Events Module:", $config);
    $eventsState = getConfig("events", true);
    if ($eventsState) {
        $pdm = "<option selected value=\"true\">Online</option>";
        $pdm .= "<option value=\"false\">Offline</option>";
    } else {
        $pdm = "<option value=\"true\">Online</option>";
        $pdm .= "<option selected value=\"false\">Offline</option>";
    }
    $modules_table->addCol("<select name=\"events\">" . $pdm . "</select>");
    unset($pdm);
    // Cargo Container Module enable.
    $modules_table->addRow();
    $modules_table->addCol("Cargo container Module:", $config);
    $cargocontainer = getConfig("cargocontainer", true);
    if ($cargocontainer) {
        $pdm = "<option selected value=\"true\">Online</option>";
        $pdm .= "<option value=\"false\">Offline</option>";
    } else {
        $pdm = "<option value=\"true\">Online</option>";
        $pdm .= "<option selected value=\"false\">Offline</option>";
    }
    $modules_table->addCol("<select name=\"cargocontainer\">" . $pdm . "</select>");
    unset($pdm);
    // Lotto Module enable.
    $modules_table->addRow();
    $modules_table->addCol("Lotto Module:", $config);
    $lotto = getConfig("Lotto", true);
    if ($lotto) {
        $pdm = "<option selected value=\"true\">Online</option>";
        $pdm .= "<option value=\"false\">Offline</option>";
    } else {
        $pdm = "<option value=\"true\">Online</option>";
        $pdm .= "<option selected value=\"false\">Offline</option>";
    }
    $modules_table->addCol("<select name=\"Lotto\">" . $pdm . "</select>");
    unset($pdm);
    // Advanced settings Module Enable.
    $modules_table->addRow();
    $modules_table->addCol("Advanced Settings:", $config);
    $advancedOptions = getConfig("advancedOptions", true);
    if ($advancedOptions) {
        $pdm = "<option selected value=\"true\">Online</option>";
        $pdm .= "<option value=\"false\">Offline</option>";
    } else {
        $pdm = "<option value=\"true\">Online</option>";
        $pdm .= "<option selected value=\"false\">Offline</option>";
    }
    $modules_table->addCol("<select name=\"advancedOptions\">" . $pdm . "</select>");
    unset($pdm);
    // Assemble form stuff.
    $form = "<form action=\"index.php\" method=\"POST\">";
    $form .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $form .= "<input type=\"hidden\" name=\"action\" value=\"configuration\">";
    /*
     * Templates
     */
    if (getConfig("advancedOptions")) {
        // Load all templates identifiers (but not the templates to save RAM)
        $templates_DS = $DB->query("SELECT id, identifier, type, descr FROM templates ORDER BY type ASC, identifier");
        // Check if we have some
        if ($templates_DS->numRows() > 0) {
            // Create the table
            $template_table = new table(3, true);
            $template_table->addHeader(">> Edit templates");
            $template_table->addRow("#060622");
            $template_table->addCol("Type");
            $template_table->addCol("Identifier");
            $template_table->addCol("Description");
            // Create a row for every template
            while ($template = $templates_DS->fetchRow()) {
                $template_table->addRow();
                $template_table->addCol($template[type]);
                $template_table->addCol("<a href=\"index.php?action=edittemplate&id=" . $template[id] . "\">" . $template[identifier] . "</a>");
                $template_table->addCol($template[descr]);
            }
            $templates = $template_table->flush();
        }
    }
    // Create the html page.
    $html = "<h2>Edit site configuration</h2>" . $form . $modules_table->flush() . "<br>" . $table->flush() . "<br>" . $templates;
    // We done here, return it!
    return $html;
}
Beispiel #22
0
function browser()
{
    // Wash the incoming.
    numericCheck(sanitize($_GET[mode]));
    numericCheck(sanitize($_GET[id]));
    $id = $_GET[id];
    $mode = $_GET[mode];
    global $DB;
    // We differ between 0 = system (detailed), 1 = constellation and 2 = region.
    switch ($_GET[mode]) {
        case "0":
            $solar = new solarSystem($id);
            $table = $solar->makeInfoTable();
            //Current Runs in System
            $openRuns = $DB->query("SELECT * FROM runs WHERE location = '" . $solar->getName() . "' AND endtime IS NULL ORDER BY id");
            if ($openRuns->numRows() > 0) {
                $openRunsTable = new table(2, true);
                $openRunsTable->addHeader(">> Current runs in " . $solar->getName());
                // We need this for a new table line.
                $newline = true;
                // Loop through all solarsystems.
                while ($openRun = $openRuns->fetchRow()) {
                    // If this is a new table row, add one.
                    if ($newline) {
                        $openRunsTable->addRow();
                        $newline = false;
                    } else {
                        $newline = true;
                    }
                    // Add the information.
                    $openRunsTable->addCol("<a href=\"index.php?action=show&id=" . $openRun[id] . "\">#" . str_pad($openRun[id], 4, "0", STR_PAD_LEFT . "</a>"));
                }
                if (!$newline) {
                    $openRunsTable->addCol();
                }
                $openRunsStuff = $openRunsTable->flush();
            }
            //Past Runs in System
            $Runs = $DB->query("SELECT * FROM runs WHERE location = '" . $solar->getName() . "' AND endtime > 0 ORDER BY id");
            if ($Runs->numRows() > 0) {
                $RunsTable = new table(2, true);
                $RunsTable->addHeader(">> Past runs in " . $solar->getName());
                // We need this for a new table line.
                $newline = true;
                // Loop through all solarsystems.
                while ($Run = $Runs->fetchRow()) {
                    // If this is a new table row, add one.
                    if ($newline) {
                        $RunsTable->addRow();
                        $newline = false;
                    } else {
                        $newline = true;
                    }
                    // Add the information.
                    $RunsTable->addCol("<a href=\"index.php?action=show&id=" . $Run[id] . "\">#" . str_pad($Run[id], 4, "0", STR_PAD_LEFT . "</a>"));
                }
                if (!$newline) {
                    $RunsTable->addCol();
                }
                // Get the total time spent in this System.
                $time = $DB->getCol("SELECT SUM(endtime - starttime) FROM runs WHERE location='" . $solar->getName() . "'");
                $time = numberToString($time[0]);
                $RunsTable->addHeaderCentered("Time spent in " . $solar->makeFancyLink() . ": " . $time);
                $RunsStuff = $RunsTable->flush();
            }
            $solarStuff = $solar->makeConstellationTable();
            break;
    }
    return "<h2>Solar System Information</h2>" . $table . "<br>" . $solarStuff . "<br>" . $openRunsStuff . "<br>" . $RunsStuff;
}
Beispiel #23
0
function payout()
{
    // Some globals needed.
    global $DB;
    global $TIMEMARK;
    global $MySelf;
    global $IGB;
    global $IGB_VISUAL;
    // Are we allowed to do this?
    if (!$MySelf->isAccountant()) {
        makeNotice("You are not an accountant to your corporation. Access denied.", "error", "Access denied");
    }
    /*
     * Amount of ISK owned.
     */
    $iskOwned = new table(2, true);
    $iskOwned->addHeader(">> Outstanding ISK");
    // Load all unique members from the database.
    $uniqeMembers = $DB->query("SELECT DISTINCT id FROM users WHERE deleted='0' ORDER BY username ASC");
    // Create a row for each member.
    while ($id = $uniqeMembers->fetchRow()) {
        $playerCreds = getCredits($id['id']);
        // We need this later on...
        $allPeeps[$id['id']] = ucfirst(idToUsername($id['id']));
        // if the member has more or less than zero isk, list him.
        if ($playerCreds != 0) {
            $iskOwned->addRow();
            $iskOwned->addCol("<a href=\"index.php?action=showTransactions&id=" . $id['id'] . "\">" . $allPeeps[$id['id']] . "</a>");
            $iskOwned->addCol(number_format($playerCreds, 2) . " ISK");
        }
    }
    // Show the total isk owned.
    $outstanding = totalIskOwned();
    $iskOwned->addRow("#060622");
    $iskOwned->addCol(">> Total Outstanding ISK:");
    $iskOwned->addCol(totalIskOwned() . " ISK");
    /*
     * Show a drop down menu to create a menu to see everyones transaction log.
     */
    $freeSelect = new table(2, true);
    $freeSelect->addHeader(">> Lookup specific transaction log");
    // Create a PDM for all the peoples.
    foreach ($allPeeps as $peep) {
        $pdm .= "<option value=\"" . array_search($peep, $allPeeps) . "\">{$peep}</option>";
    }
    $freeSelect->addRow();
    $freeSelect->addCol("Show log of ", array("align" => "right"));
    $freeSelect->addCol("<select name=\"id\">{$pdm}</select>");
    $freeSelect->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Lookup log in Database\">");
    unset($pdm);
    /*
     * Show current requests
     */
    $requests = $DB->query("SELECT * FROM payoutRequests WHERE payoutTime IS NULL ORDER BY time DESC");
    if ($IGB && $IGB_VISUAL) {
        $table = new table(6, true);
    } else {
        $table = new table(5, true);
    }
    $table->addHeader(">> Pending payout requests");
    $table->addRow("#060622");
    $table->addCol("request");
    $table->addCol("applicant");
    if ($IGB && $IGB_VISUAL) {
        $table->addCol("right click menu");
    }
    $table->addCol("time");
    $table->addCol("amount");
    $table->addCol("Payout");
    while ($request = $requests->fetchRow()) {
        if ($IGB && $IGB_VISUAL) {
            $api = new api($request['applicant']);
            //			$profile = new profile($request['applicant']);
            if ($api->valid() && ($IGB && $IGB_VISUAL)) {
                $rcm = " [<a href=\"showinfo:1378//" . $api->getCharacterID() . "\">RCM</a>]";
            }
        }
        $table->addRow();
        $table->addCol("#" . str_pad($request['request'], "5", "0", STR_PAD_LEFT));
        $table->addCol("<a href=\"index.php?action=showTransactions&id={$request['applicant']}\">" . ucfirst(idToUsername($request['applicant'])) . "</a>");
        if ($IGB && $IGB_VISUAL) {
            $table->addCol($rcm);
        }
        $table->addCol(date("d.m.y H:i:s", $request['time']));
        if (getCredits($request['applicant']) < $request['amount']) {
            $class .= "red";
        }
        if ($IGB && $IGB_VISUAL) {
            $table->addCol("<input type=\"text\" class=\"{$class}\" name=\"dumb\" readonly value=\"" . number_format($request['amount'], 2) . "\"> ISK");
        } else {
            $table->addCol(number_format($request['amount'], 2) . " ISK", array("class" => $class));
        }
        // Can the user still cover his request with cash?
        $table->addCol("<input type=\"checkbox\" name=\"" . $request['request'] . "\" value=\"true\">");
        $haveRequest = true;
        //} else {
        //	$table->addCol("<i>not enough ISK</i>");
        //}
    }
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Mark as paid\">");
    $funnyForm = "<form action=\"index.php\" method=\"POST\">";
    $funnyForm .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $funnyForm .= "<input type=\"hidden\" name=\"action\" value=\"payout\">";
    $funnyForm .= $table->flush();
    $funnyForm .= "</form>";
    /*
     * Show fulfilled requests
     */
    if (is_numeric($_GET['page']) && $_GET['page'] > 0) {
        $page = "LIMIT " . $_GET['page'] * 20 . ", 20";
    } elseif ($_GET['page'] == "all") {
        $page = "";
    } else {
        $page = "LIMIT 20";
    }
    $requests = $DB->query("SELECT * FROM payoutRequests WHERE payoutTime IS NOT NULL ORDER BY time DESC {$page}");
    $table_done = new table(6, true);
    $table_done->addHeader(">> Fulfilled payout requests");
    $table_done->addRow("#060622");
    $table_done->addCol("request");
    $table_done->addCol("applicant");
    $table_done->addCol("time");
    $table_done->addCol("amount");
    $table_done->addCol("Payout time");
    $table_done->addCol("Authorized by");
    while ($request = $requests->fetchRow()) {
        $table_done->addRow();
        $table_done->addCol("#" . str_pad($request['request'], "5", "0", STR_PAD_LEFT));
        $table_done->addCol("<a href=\"index.php?action=showTransactions&id={$request['applicant']}\">" . ucfirst(idToUsername($request['applicant'])) . "</a>");
        $table_done->addCol(date("d.m.y H:i:s", $request['time']));
        $table_done->addCol(number_format($request['amount'], 2) . " ISK");
        $table_done->addCol(date("d.m.y H:i:s", $request['payoutTime']));
        $table_done->addCol(ucfirst(idToUsername($request['banker'])));
        $haveOldRequests = true;
    }
    // The "show this many payouts"-part.
    $count = $DB->getCol("SELECT COUNT(request) FROM payoutRequests WHERE payoutTime IS NOT NULL");
    $countSteps = floor($count[0] / 20);
    $showMore = "Switch to page >> ";
    for ($i = 1; $i <= $countSteps; $i++) {
        $thisStep = str_pad($i, 2, "0", STR_PAD_LEFT);
        $showMore .= "[<a href=\"index.php?action=payout&page=" . $thisStep . "\">" . $thisStep . "</a>] ";
    }
    $showMore .= "[<a href=\"index.php?action=payout&page=all\">All</a>] ";
    $table_done->addHeader($showMore);
    $html = "<h2>Manage Payouts</h2>" . $iskOwned->flush() . "<br><br>";
    $html .= "<form action=\"index.php\" method=\"GET\">" . $freeSelect->flush() . "<input type=\"hidden\" name=\"action\" value=\"showTransactions\"></form><br>";
    if ($haveRequest) {
        $html .= $funnyForm . "<br>";
    } else {
        $html .= "<i>No open requests.</i><br><br>";
    }
    if ($haveOldRequests) {
        $html .= $table_done->flush();
    } else {
        $html .= "<br><i>No payouts at all.</i>";
    }
    return $html;
}
Beispiel #24
0
function makeOreWorth()
{
    // Get the globals.
    global $TIMEMARK;
    global $ORENAMES;
    global $DBORE;
    global $DB;
    global $OTYPENAME;
    global $PRICECRITERIA;
    // Where do I get Ore Values?
    $Market = getConfig("useMarket");
    if ($Market) {
        // Update prices from Eve-Central and store.
        if ($Market == "eve-central") {
            $CURRENTTIME = date(U) - getConfig("timeOffset") * 60 * 60;
            $itemListDB = $DB->query("SELECT * FROM `itemList` ORDER BY `itemName` DESC");
            $orderType = $OTYPENAME[getConfig("orderType")];
            $priceCrit = $PRICECRITERIA[getConfig("priceCriteria")];
            for ($i = 0; $i <= $itemListDB->numRows(); $i++) {
                $itemInfo = $itemListDB->fetchRow();
                $quoteAge = $CURRENTTIME - $itemInfo['updateTime'];
                if ($quoteAge >= 3600) {
                    $currentPrice = getMarketPrice($itemInfo['itemID'], $orderType, $priceCrit);
                    $DB->query("UPDATE itemList SET `updateTime` = {$CURRENTTIME}, `value` = {$currentPrice} WHERE `itemID` = " . $itemInfo['itemID']);
                }
            }
        } else {
            if ($Market == "eve-marketdata") {
            } else {
                if ($Market == "eve-marketeer") {
                    $regionID = getConfig("useRegion");
                    $url = "http://www.evemarketeer.com/api/info/{$itemID}/xml/{$regionID}/buy_highest5";
                    $xml = getXMLobj($url);
                    echo $xml[row][buy_highest5];
                }
            }
        }
    } else {
        // load the values.
        $orevaluesDS = $DB->query("select a.item, a.Worth, a.time, a.modifier from orevalues a where time = (select max(time) from orevalues b where a.item = b.item) group by item ORDER BY time DESC");
        while ($row = $orevaluesDS->fetchRow()) {
            $orevalues[$row[item]] = $row;
        }
    }
    if ($Market) {
        $headerText = ">> Manage ore values<br><font color=\"#ff0000\"><b>Ore values are current market values.</b></font>";
    } else {
        $headerText = ">> Manage ore values";
    }
    // Create the table.
    $table = new table(8, true);
    $table->addHeader($headerText, array("bold" => true, "colspan" => 8));
    $OPTYPE = isset($_REQUEST[optype]) ? $_REQUEST[optype] : "";
    $table->addRow();
    $table->addCol("Op Type:");
    $ops = $DB->getAll("select opName from opTypes;");
    if ($DB->isError($ops)) {
        die($ops->getMessage());
    }
    $opSelect = "<select name='optype' onChange='window.location = \"?action=changeow&optype=\"+this.value'>\n";
    $opSelect .= "<option value=''>Standard</option>\n";
    foreach ($ops as $op) {
        $default = $op[opName] == $OPTYPE ? "selected" : "";
        $opSelect .= "<option {$default} value='" . $op[opName] . "'>" . $op[opName] . "</option>\n";
    }
    $opSelect .= "</select>";
    $table->addCol($opSelect, array("colspan" => 7));
    $table->addRow();
    $table->addCol("Ore Name", array("colspan" => 2, "bold" => true));
    $table->addCol("Enabled", array("bold" => true));
    $table->addCol("Value", array("bold" => true));
    $table->addCol("Ore Name", array("colspan" => 2, "bold" => true));
    $table->addCol("Enabled", array("bold" => true));
    $table->addCol("Value", array("bold" => true));
    // How many ores are there in total? Ie, how long has the table to be?
    $tableLength = ceil(count($ORENAMES) / 2) - 1;
    for ($i = 0; $i <= $tableLength; $i++) {
        $right = 0;
        $table->addRow();
        for ($side = 0; $side <= 1; $side++) {
            $ORE = $ORENAMES[$i + ($tableLength + 1) * $side];
            // Fetch the right image for the ore.
            $ri_words = str_word_count($ORE, 1);
            $ri_max = count($ri_words);
            $ri = strtolower($ri_words[$ri_max - 1]);
            if ($ORE != "") {
                $table->addCol("<img width=\"32\" height=\"32\" src=\"./images/ores/" . $ORE . ".png\">");
                $table->addCol($ORE);
                if (getOreSettings($DBORE[$ORE], $OPTYPE)) {
                    $table->addCol("<input name=\"" . $DBORE[$ORE] . "Enabled\" value=\"true\" type=\"checkbox\" checked=\"checked\">");
                } else {
                    $table->addCol("<input name=\"" . $DBORE[$ORE] . "Enabled\" value=\"true\" type=\"checkbox\">");
                }
                if ($Market == 1) {
                    $thisPrice = getPriceCache($ORE);
                    $table->addCol("<input type=\"text\" style=\"text-align: right\" name=\"{$DBORE[$ORE]}\"" . "size=\"10\" value=\"" . $thisPrice . "\">");
                } else {
                    $table->addCol("<input type=\"text\" style=\"text-align: right\" name=\"{$DBORE[$ORE]}\"" . "size=\"10\" value=\"" . $orevalues[$DBORE[$ORE]][Worth] . "\">");
                }
            } else {
                $table->addCol("");
                $table->addCol("");
                $table->addCol("");
                $table->addCol("");
            }
        }
    }
    $form .= "<input type=\"hidden\" name=\"action\" value=\"changeore\">";
    $form .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $form .= "<input type=\"hidden\" name=\"optype\" value=\"{$OPTYPE}\">";
    $form .= "<input type=\"submit\" name=\"change\" value=\"Modify ore settings\">";
    $table->addHeaderCentered($form, array("colspan" => 8, "align" => "center"));
    // return the page
    return "<h2>Modify ore settings</h2><form action=\"index.php\"method=\"post\">" . $table->flush();
}
Beispiel #25
0
function showEvent()
{
    // Lets import some globals, shall we?
    global $MySelf;
    global $DB;
    global $TIMEMARK;
    $ID = $MySelf->getID();
    // is the events module active?
    if (!getConfig("events")) {
        makeNotice("The admin has deactivated the events module.", "warning", "Module not active");
    }
    // Are we allowed to be here?
    if (!$MySelf->canSeeEvents()) {
        makeNotice("You are not allowed to do this!", "error", "Forbidden");
    }
    // Is the ID safe?
    if (!is_numeric($_GET[id]) || $_GET[id] < 0) {
        makeNotice("Invalid ID given!", "error", "Invalid Data");
    }
    // Load the event.
    $EVENTS = $DB->getRow("SELECT * FROM events WHERE id='{$_GET['id']}'");
    $mission = new table(2, true);
    $mission->addHeader(">> Mission information");
    $mission->addRow();
    $mission->addCol("Mission ID:");
    $mission->addCol(str_pad("{$EVENTS['id']}", 5, "0", STR_RIGHT_PAD));
    $mission->addRow();
    $mission->addCol("Mission Type:");
    $mission->addCol($EVENTS[type]);
    $mission->addRow();
    $mission->addCol("Executing Officer:");
    // In case of a numeric value we have to translate that into plain english.
    if (is_numeric($EVENTS[officer])) {
        $officer = idToUsername($EVENTS[officer]);
    } else {
        $officer = $EVENTS[officer];
    }
    $mission->addCol(ucfirst($officer));
    $mission->addRow();
    $mission->addCol("System:");
    $mission->addCol(ucfirst($EVENTS[system]));
    $mission->addRow();
    $mission->addCol("Security:");
    $mission->addCol($EVENTS[security]);
    // Has the event started yet?
    $delta = $TIMEMARK - $EVENTS[starttime];
    if ($delta > 0) {
        // Yep!
        $mission->addRow();
        $mission->addCol("Mission underway for:");
        $mission->addCol(numberToString($delta));
    } else {
        // Nope!
        $delta = $delta * -1;
        $mission->addRow();
        $mission->addCol("Mission will start in:");
        $mission->addCol(numberToString($delta));
    }
    $mission->addRow();
    $mission->addCol("Est. Duration:");
    $mission->addCol($EVENTS[duration]);
    // How difficult is it?
    $mission->addRow();
    $mission->addCol("Difficulty:");
    switch ($EVENTS[difficulty]) {
        case 0:
            $mission->addCol("No risk involved");
            break;
        case 1:
            $mission->addCol("Inferior forces");
            break;
        case 2:
            $mission->addCol("Adequate forces");
            break;
        case 3:
            $mission->addCol("Major forces expected");
            break;
        case 4:
            $mission->addCol("Superior forces expected");
            break;
        case 5:
            $mission->addCol("Suicide Mission");
            break;
    }
    $mission->addRow();
    $mission->addCol("Payment:");
    $mission->addCol($EVENTS[payment]);
    $mission->addRow();
    $mission->addCol("Collateral:");
    $mission->addCol(number_format($EVENTS[collateral]));
    $mission->addRow();
    $mission->addCol("Notes:");
    $mission->addCol(nl2br($EVENTS[notes]));
    $shipsTable = new table(3, true);
    $shipsTable->addHeader(">> Shiptypes and Joinups");
    // Compute the wanted Ships.
    $ships = unserialize($EVENTS[ships]);
    $SHIPTYPES = array("shuttles", "frigates", "destroyers", "cruisers", "bcruiser", "scruiser", "bship", "dread", "carrier", "titan", "barges", "indies", "freighter", "jfreighter", "exhumer");
    $TRANSLATE = array("shuttles" => "Shuttle", "frigates" => "Frigate", "destroyers" => "Destroyer", "cruisers" => "Cruiser", "bcruiser" => "Battlecruiser", "scruiser" => "Strategic Cruiser", "bship" => "Battleship", "dread" => "Dreadnought", "carrier" => "Carrier", "titan" => "Titan", "barges" => "Mining Barge", "indies" => "Industrial Ship", "freighter" => "Freighter", "jfreighter" => "Jump Freighter", "exhumer" => "Exhumer");
    $shipsTable->addRow("#060622");
    $shipsTable->addCol("Ship class");
    $shipsTable->addCol("Signed up");
    $shipsTable->addCol("Join up");
    // Ugh. ugly hack. Easier way?
    $JOINUPS_DS = $DB->getCol("SELECT signups FROM events WHERE id = '{$_GET['id']}'");
    $JOINUPS = unserialize($JOINUPS_DS[0]);
    unset($JOINUPS_DS);
    $JOINUPS_SHIPS = array_count_values($JOINUPS);
    // Translate the ships.
    foreach ($SHIPTYPES as $type) {
        if (in_array($type, $ships)) {
            $shipsTable->addRow();
            $shipsTable->addCol($TRANSLATE[$type] . "s");
            // Print how many ships are coming.
            if ($JOINUPS_SHIPS[$type] != "") {
                $shipsTable->addCol("{$JOINUPS_SHIPS[$type]}");
            } else {
                $shipsTable->addCol("none");
            }
            // Okay this is fun. First lets see if the user is already in this event.
            if ($JOINUPS[$ID] != "") {
                // User in Event. Lets see if the current shiptype is the shiptype hes joined up with.
                if ($JOINUPS[$ID] != $type) {
                    // Its not. Offer to switch.
                    $shipsTable->addCol("<a href=\"index.php?action=joinevent&id={$EVENTS['id']}&type={$type}\">Switch to " . $TRANSLATE[$type] . " class</a>");
                } else {
                    // It is. Renember him.
                    $shipsTable->addCol("You are signed up as " . $TRANSLATE[$type]);
                }
            } else {
                // User is not in event, offer to joinup.
                $shipsTable->addCol("<a href=\"index.php?action=joinevent&id={$EVENTS['id']}&type={$type}\">Join as " . $TRANSLATE[$type] . "</a>");
            }
        }
    }
    // Offer to quit Event.
    if ($JOINUPS[$ID] != "") {
        $shipsTable->addHeaderCentered("<a href=\"index.php?action=joinevent&id={$EVENTS['id']}&type=quit\">Cancel my signup for this event.</a>");
    }
    // Pilot overview.
    $pilotTable = new table(1, true);
    $pilotTable->addHeader(">> Current event roster");
    $keys = array_keys($JOINUPS);
    foreach ($keys as $key) {
        $pilotTable->addRow();
        $pilotTable->addCol(ucfirst(idToUsername($key)) . " has joined as a " . $TRANSLATE[$JOINUPS[$key]]);
    }
    // Return what we got.
    $html = "<h2>Detailed Mission Information</h2>" . $mission->flush();
    $html .= "<br>[<a href=\"index.php?action=showevents\">Back to overview</a>]<br>";
    $html .= "<br>" . $shipsTable->flush();
    $html .= "<br>" . $pilotTable->flush();
    return $html;
}