Example #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>";
}
Example #2
0
function ticketExpiration($DATA, &$expVal = NULL)
{
    if ($DATA["expire_dln"] || $DATA["last_time"]) {
        if ($DATA["last_stamp"] && $DATA["last_time"]) {
            $expVal = $DATA["last_stamp"] + $DATA["last_time"] - time();
            return sprintf(T_("About %s"), humanTime($expVal));
        } elseif ($DATA["expire_dln"] && $DATA["downloads"]) {
            $expVal = $DATA["expire_dln"] - $DATA["downloads"];
            return sprintf(T_("About %d downloads"), $expVal);
        } elseif ($DATA["expire"]) {
            $expVal = $DATA["expire"] - time();
            return sprintf(T_("About %s"), humanTime($expVal));
        } elseif ($DATA["expire_dln"]) {
            $expVal = $DATA["expire_dln"];
            return sprintf(T_("After %d downloads"), $expVal);
        } else {
            $expVal = $DATA["last_time"];
            return sprintf(T_("%s after next download"), humanTime($expVal));
        }
    } elseif ($DATA["expire"]) {
        $expVal = $DATA["expire"] - time();
        return sprintf(T_("In %s"), humanTime($expVal));
    }
    $expVal = 4294967295;
    return "<strong>" . T_("Never") . "</strong>";
}
Example #3
0
function grantExpiration($DATA, &$expVal = NULL)
{
    if ($DATA["grant_expire"]) {
        $expVal = $DATA["grant_expire"] - time();
        return sprintf(T_("In %s"), humanTime($expVal));
    }
    $expVal = 4294967295;
    return "<strong>" . T_("Never") . "</strong>";
}
Example #4
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>";
}
Example #5
0
function addRun()
{
    // We need some more globals.
    global $DB;
    global $ORENAMES;
    global $DBORE;
    global $ORENAMES_STR;
    global $MySelf;
    global $TIMEMARK;
    // Set the userID
    $userID = $MySelf->getID();
    // Are we permitted to create a new run?
    if (!$MySelf->canCreateRun()) {
        makeNotice("You are not allowed to create a mining op!", "error", "forbidden");
    }
    if ($_POST[startnow]) {
        $starttime = $TIMEMARK;
    } else {
        // Startting time goodness.
        $myTime = array("day" => "{$_POST['ST_day']}", "month" => "{$_POST['ST_month']}", "year" => "{$_POST['ST_year']}", "hour" => "{$_POST['ST_hour']}", "minute" => "{$_POST['ST_minute']}");
        $starttime = humanTime("toUnix", $myTime);
    }
    // Having fun with checkboxes, yet again.
    if ($_POST[isOfficial] == "on") {
        $official = true;
    } else {
        $official = false;
    }
    // We using either predefined locations.
    if (empty($_POST[location])) {
        $location = $_POST[locations];
    } else {
        $location = $_POST[location];
    }
    if (empty($location)) {
        makeNotice("You need to specify the location of the Mining Operation!", "notice", "Where again?", "index.php?action=newrun", "[Cancel]");
    }
    // Supervisor
    if ($MySelf->isOfficial()) {
        if (empty($_POST[supervisor])) {
            // Is official, but no one named!
            makeNotice("You need to name someone as the supervisor for this run!", "warning", "Missing Information", "index.php?action=newrun", "[Cancel]");
        } else {
            // Grab ID of named supervisor.
            $supervisor = usernameToID(sanitize($_POST[supervisor]));
        }
    } else {
        // Non official, use own ID
        $supervisor = $MySelf->getID();
    }
    // Corp tax
    if ($MySelf->isOfficial()) {
        if ($_POST[corpkeeps] > 100 || $_POST[corpkeeps] < 0 || !numericCheckBool($_POST[corpkeeps])) {
            makeNotice("The corporation can not keep more than 100% and most certainly wont pay out more than the gross worth (values below 0%). A value of " . $_POST[corpkeeps] . " is really not valid.", "warning", "Out of range", "index.php?action=newrun", "[Cancel]");
        } else {
            $tax = $_POST[corpkeeps];
        }
    } else {
        $tax = "0";
    }
    /*
    // Get the current ore-values.
    $oreValue = $DB->getCol("SELECT max(time) FROM orevalues");
    $oreValue = $oreValue[0];
    */
    //Edit Starts Here
    $shipValue = $DB->getCol("SELECT max(id) FROM shipvalues");
    $shipValue = $shipValue[0];
    $optype = $_REQUEST[optype];
    //Edit Ends Here
    $DB->query("insert into runs (location, starttime, supervisor, corpkeeps, isOfficial, oreGlue, shipGlue,optype) " . "values (?,?,?,?,?,?,?,?)", array("{$location}", "{$starttime}", "{$supervisor}", $tax, $official, "{$TIMEMARK}", $shipValue, "{$optype}"));
    // Check for success.
    if ($DB->affectedRows() != 1) {
        makeNotice("DB Error: Could not add run to database!", "error", "DB Error");
    }
    // Now update the "required" ore values.
    foreach ($DBORE as $ORE) {
        // But the ore needs to be set, valid (numeric) and must be activated.
        if (isset($_POST[$ORE]) && is_numeric($_POST[$ORE]) && getOreSettings($ORE) == true && $_POST[$ORE] > 0) {
            $DB->query("UPDATE runs SET " . $ORE . "Wanted='" . $_POST[$ORE] . "' WHERE {$starttime}='{$starttime}'");
        }
    }
    // And return the user to the run-list overview page.
    makeNotice("The new Mining Operation has been created in the database.", "notice", "Mining Operation created", "index.php?action=list", "[OK]");
}
Example #6
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>";
}
Example #7
0
<?php

$pageTitle = "News";
include_once 'includes/header.php';
include_once 'includes/lastRSS.php';
if (true) {
    include_once 'includes/functions_twitter.php';
    $tweetblob = '<span class="follow"><a href="//twitter.com/intent/follow?screen_name=SteamLUG&amp;tw_p=followbutton"><i class="fa-twitter"></i><span id="l" class="follow-label">Follow <b>@SteamLUG</b></span></a></span>' . "\n";
    $tweetblob .= '<ol>' . "\n";
    foreach (getRecentTweets(3) as $tweet) {
        $time = humanTime($tweet['created_at']);
        $user = $tweet['user'];
        if (array_key_exists('retweeted_status', $tweet)) {
            $user = $tweet['retweeted_status']['user'];
            $tweet = $tweet['retweeted_status'];
        }
        $msg = populateTweet($tweet);
        $tweetblob .= "<li\n\tclass=\"tweet\">";
        $tweetblob .= "<div\n\t\tclass=\"header\"><a class=\"permalink\" href=\"//twitter.com/{$user['screen_name']}/status/{$tweet['id']}\">{$time}</a><div class=\"h-card p-author\"><a class=\"profile\" href=\"//twitter.com/{$user['screen_name']}\"><img class=\"avatar\" alt=\"\" src=\"{$user['profile_image_url_https']}\"><span class=\"full-name\"><span class=\"p-name\">{$user['name']}</span></span><span class=\"p-nickname\">@<b>{$user['screen_name']}</b></span></a></div></div>";
        $tweetblob .= "<div\n\t\tclass=\"content\"><p class=\"e-entry-title\" lang=\"en\">{$msg}</p></div>";
        $tweetblob .= "<div\n\t\tclass=\"footer\"><ul class=\"tweets\" role=\"menu\"><li><a href=\"//twitter.com/intent/tweet?in_reply_to={$tweet['id']}\" class=\"reply\" title=\"Reply\"><i class=\"fa-reply\"></i><b>Reply</b></a></li><li><a href=\"//twitter.com/intent/retweet?tweet_id={$tweet['id']}\" class=\"retweet\" title=\"Retweet\"><i class=\"fa-retweet\"></i><b>Retweet</b></a></li><li><a href=\"//twitter.com/intent/favorite?tweet_id={$tweet['id']}\" class=\"favourite\" title=\"Favorite\"><i class=\"fa-star\"></i><b>Favorite</b></a></li></ul></div>";
        $tweetblob .= "</li>";
    }
    $tweetblob .= '</ol>';
    echo <<<TWITTERWIDGET
\t\t<h1 class="text-center">News</h1>
\t\t<article class="panel panel-default tweets col-md-4 col-md-push-8">
\t\t\t<header class="panel-heading">
\t\t\t\t<h3 class="panel-title">Tweets</h3>
\t\t\t</header>
\t\t\t<div class="panel-body" id="twitter-here">
Example #8
0
function addCanToDatabase()
{
    // We need some more globals.
    global $DB;
    global $TIMEMARK;
    global $MySelf;
    global $PREFS;
    // Change of prefs?
    switch ($_POST[canprefs]) {
        case "0":
            $PREFS->setPref("CanNaming", "0");
            break;
        case "1":
            $PREFS->setPref("CanNaming", "1");
            break;
        case "2":
            $PREFS->setPref("CanNaming", "2");
            break;
    }
    if ($_POST[forRun]) {
        $PREFS->setPref("CanForRun", "1");
    } else {
        $PREFS->setPref("CanForRun", "0");
    }
    // Save the modified Preferences.
    $PREFS->storePrefs();
    // Wash the incoming stuff.
    $cantag = sanitize("{$_POST['cantag']}");
    $location = sanitize("{$_POST['location']}");
    $location2 = sanitize("{$_POST['location2']}");
    $droptime = date("U", strtotime(sanitize("{$_POST['droptime']}")));
    $id = $MySelf->getID();
    // If user entered special location, use that.
    if ($location2 != "") {
        $location = $location2;
    }
    // Startting time goodness.
    $myTime = array("day" => "{$_POST['ST_day']}", "month" => "{$_POST['ST_month']}", "year" => "{$_POST['ST_year']}", "hour" => "{$_POST['ST_hour']}", "minute" => "{$_POST['ST_minute']}");
    $droptime = humanTime("toUnix", $myTime);
    // is the time valid?
    if (!$droptime) {
        makeNotice("Invalid time supplied!", "error", "Invalid Time!");
    }
    // We got a name?
    if (empty($cantag)) {
        makeNotice("You need to supply a name for your can!", "error", "Can not added", "index.php?action=cans", "[cancel]");
    }
    // We got a location?
    if (empty($location)) {
        makeNotice("You need to supply the location of your can!", "error", "Can not added", "index.php?action=cans", "[cancel]");
    }
    // Can for mining operation?
    $myRun = userInRun($MySelf->getID());
    if ($_POST[forRun] && $myRun) {
        $forrun = $myRun;
    } else {
        $forrun = -1;
    }
    // Insert the can into the database.
    $P = $DB->query("INSERT INTO cans (pilot, location, droptime, name, miningrun) VALUES (?,?,?,?,?)", array("{$id}", "{$location}", "{$droptime}", "{$cantag}", $forrun));
    // Did we encounter an error?
    if ($DB->affectedRows() == 1) {
        $to_old = $TIMEMARK - 7200;
        $DB->query("DELETE FROM cans WHERE droptime < {$to_old}");
        if ($DB->affectedRows() > 0) {
            makeNotice("Mining can added. I also popped " . $DB->affectedRows() . " Cans, " . "which were older than 2 hours.", "notice", "Old cans popped", "index.php?action=cans", "[ok]");
        }
        header("Location: index.php?action=cans");
    } else {
        makeNotice("Unable to create can in database:<br>" . $P->getMessage(), "error", "Internal error");
    }
}
Example #9
0
function addEventToDB()
{
    global $MySelf;
    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 Events?
    if (!$MySelf->canEditEvents()) {
        makeNotice("You are not allowed to add events!", "error", "Forbidden!");
    }
    // Do we have a short description?
    if (empty($_POST[sdescr])) {
        makeNotice("You need to supply a short description!", "error", "Important field missing!");
    }
    // Do we have an officer?
    if (empty($_POST[officer])) {
        makeNotice("You need to supply who is in command!", "error", "Important field missing!");
    }
    // Choose which supplied officer we use.
    if (!empty($_POST[officer2])) {
        sanitize($officer = sanitize($_POST[officer2]));
    } else {
        sanitize($officer = sanitize($_POST[officer]));
    }
    // Choose which system we use.
    if (!empty($_POST[system2])) {
        $system = strtolower($_POST[system2]);
    } else {
        $system = strtolower($_POST[system]);
    }
    // Check that we still have a valid systemname.
    if (empty($system)) {
        makeNotice("No valid Systemname found! Please go back, and try again.", "warning", "No system name", "index.php?action=addevent", "[cancel]");
    }
    // Do we have an ETD?
    if (empty($_POST[dur])) {
        makeNotice("You need to tell me the guessed runtime!", "error", "Important field missing!");
    }
    // Collateral?
    if (!is_numeric($_POST[collateral]) && $_POST[collateral] < 0) {
        makeNotice("You need to supply a valid collateral!", "error", "Important field missing!");
    }
    // Do we have an ETD?
    if ($_POST[payment] < 0) {
        makeNotice("You need to give the folks some money!", "error", "Important field missing!");
    }
    // Startting time goodness.
    $myTime = array("day" => "{$_POST['ST_day']}", "month" => "{$_POST['ST_month']}", "year" => "{$_POST['ST_year']}", "hour" => "{$_POST['ST_hour']}", "minute" => "{$_POST['ST_minute']}");
    $starttime = humanTime("toUnix", $myTime);
    // is the time valid?
    if (!$starttime) {
        makeNotice("Invalid time supplied!", "error", "Invalid Time!");
    }
    // Lets see what ships are required.
    $SHIPTYPES = array("shuttles", "frigates", "destroyers", "cruisers", "bcruiser", "scruiser", "bship", "dread", "carrier", "titan", "barges", "indies", "freighter", "jfreighter", "exhumer");
    foreach ($SHIPTYPES as $ship) {
        if ($_POST[$ship] == "on") {
            $wantedships[] = $ship;
        }
    }
    $ships = serialize($wantedships);
    $p = $DB->query("INSERT INTO events (sdesc, officer, system, security, type, starttime, " . "duration, difficulty, payment, collateral, notes, ships)\r\n\t               values (?,?,?,?,?,?,?,?,?,?,?,?)", array(sanitize($_POST[sdescr]), $officer, $system, sanitize($_POST[security]), sanitize($_POST[type]), sanitize($starttime), sanitize($_POST[dur]), sanitize($_POST[difficulty]), sanitize($_POST[payment]), sanitize($_POST[collateral]), sanitize($_POST[notes]), "{$ships}"));
    if ($DB->affectedRows() == 1) {
        // Prepare the announcement email.
        global $SITENAME;
        global $VERSION;
        global $URL;
        // Bloody hack to get latest ID. No one will ever know. ;)
        $lastID = $DB->getCol("SELECT max(ID) from events;");
        $risks = array("No risk involved.", "Only inferior forces suspected.", "Somewhat risky.", "Moderate risk.", "Extreme risks are involved.", "No survivors expected.");
        $risk_index = $_POST[difficulty];
        // Fix the template up.
        $email = str_replace("{{ID}}", str_pad("{$lastID['0']}", "5", "0", STR_PAD_LEFT), getTemplate("newevent", "email"));
        $email = str_replace("{{SDESCR}}", $_POST[sdescr], $email);
        $email = str_replace("{{TYPE}}", $_POST[type], $email);
        // In case of a numeric value we have to translate that into plain english.
        if (is_numeric($_POST[officer])) {
            $officer = idToUsername($_POST[officer]);
        } else {
            $officer = sanitze($_POST[officer]);
        }
        $email = str_replace("{{FLAGOFFICER}}", ucfirst($officer), $email);
        $email = str_replace("{{SYSTEM}}", $_POST[system], $email);
        $email = str_replace("{{SECURITY}}", $_POST[security], $email);
        $email = str_replace("{{STARTTIME}}", date("d.m.y H:i:s", $starttime), $email);
        $email = str_replace("{{DURATION}}", $_POST[dur], $email);
        $email = str_replace("{{RISK}}", $risks[$risk_index], $email);
        $email = str_replace("{{PAYMENT}}", $_POST[payment], $email);
        $email = str_replace("{{COLLATERAL}}", number_format($_POST[collateral], 2), $email);
        $email = str_replace("{{NOTES}}", $_POST[notes], $email);
        $email = str_replace("{{SITENAME}}", $SITENAME, $email);
        $email = str_replace("{{URL}}", $URL, $email);
        $email = str_replace("{{VERSION}}", $VERSION, $email);
        // mail the user.
        mailUser($email, "New event added!");
        // Tell the admin what we did.
        makeNotice("Event added to the database and users who are opt-in got an email.", "notice", "New Event added.", "index.php?action=showevents", "[OK]");
    } else {
        makeNotice("Something went horribly wrong! AIEE!!", "error", "Mummy!");
    }
}
Example #10
0
    if ($t < 3600) {
        return sprintf("%d мин. %d сек.", $t / 60, $t % 60);
    } else {
        return sprintf("%d час. %d мин.", $t / 3660, $t / 60 % 60);
    }
}
$ini = Yii::app()->user->ini;
if (count($hot) == 0) {
    echo "<p class='alert alert-box alert-warning'>В данный момент никто ничего не переводит ";
    echo Yii::app()->langs->from_to($ini["hot.s_lang"], $ini["hot.t_lang"]);
    echo ". Хотите посмотреть, что переводят <a href='#' data-toggle='modal' data-target='#f-hot-ini'>на других языках</a>?</p>";
} else {
    echo "<ul" . ($ini["hot.img"] ? " class='imged'" : "") . ">";
    foreach ($hot as $book) {
        echo "<li>";
        $t = humanTime(time() - strtotime($book->last_tr));
        if ($ini["hot.img"]) {
            echo "<div class='bimg'";
            if ($book->img->exists) {
                echo " style=\"background-image:url('" . $book->img->getUrl("5050") . "')\"";
            }
            echo "></div>";
            echo "<p class='title'>";
            echo "<a href='{$book->url}' title='{$t}'>{$book->fullTitle}</a>";
            echo "</p><p class='info'>";
            echo Yii::app()->params["book_types"][$book->typ] . " ";
            echo Yii::app()->langs->from_to($book->s_lang, $book->t_lang) . " ";
            echo "<span class='r'>{$book->ready}</span>";
            echo "</p>";
        } else {
            echo Yii::app()->langs->from_to($book->s_lang, $book->t_lang, Langs::FORMAT_ABBR) . " ";