function next_photo()
{
    // Find the ID of the next photo to use
    $query = "SELECT id FROM photo_of_the_week ORDER BY last_date_used,id LIMIT 1";
    $result = mydb::cxn()->query($query);
    $row = $result->fetch_assoc();
    $next_photo_id = $row['id'];
    $query = "UPDATE photo_of_the_week SET last_date_used = curdate() where id = " . $next_photo_id;
    $result = mydb::cxn()->query($query);
}
 public function exists($id = false)
 {
     if (is_numeric($id)) {
         mydb::cxn()->query('SELECT count(*) FROM scheduled_courses WHERE id = ' . $id);
         if (mydb::cxn()->affected_rows >= 1) {
             return 1;
         }
     } else {
         return 0;
     }
 }
function get_chuck_norris_fact()
{
    //require_once("scripts/connect.php");
    //$dbh = connect();
    $query = "SELECT MAX(id) as max, MIN(id) as min from chuck_norris_facts";
    $result = mydb::cxn()->query($query);
    $row = $result->fetch_assoc();
    $min_id = $row['min'];
    $max_id = $row['max'];
    $id = rand($min_id, $max_id);
    $query = "SELECT fact FROM chuck_norris_facts WHERE id LIKE '" . $id . "'";
    $result = mydb::cxn()->query($query);
    $row = $result->fetch_assoc();
    echo $row['fact'];
}
function check_hrap($hrap_id)
{
    // This function will accept an INTEGER and check for a corresponding HRAP ID in the database (hraps.id).
    // If the requested hrap exists, the function returns the rappeller's full name (as a string).
    // If the requested hrap does not exist, or a non-integer value is passed, return 0
    if (is_numeric($hrap_id) && intval($hrap_id) == floatval($hrap_id)) {
        //Match an integer value
        $query = "SELECT firstname, lastname FROM hraps WHERE id = " . $hrap_id;
        $result = mydb::cxn()->query($query);
        if (mydb::cxn()->affected_rows > 0) {
            $row = $result->fetch_assoc();
            return $row['firstname'] . " " . $row['lastname'];
        }
    }
    return 0;
}
示例#5
0
function is_valid($year)
{
    //Check to see if a given year is present in the database
    // Return 1 if given year is valid
    // Return 0 otherwise
    $result = mydb::cxn()->query("SELECT DISTINCT year FROM roster");
    if (mydb::cxn()->error != '') {
        die("Retrieving valid YEARs failed: " . mydb::cxn()->error . "<br>\n" . $query);
    }
    while ($row = $result->fetch_assoc()) {
        if ($row['year'] == $year) {
            return 1;
        }
    }
    return 0;
    //Year is NOT valid or else function would have returned 1 by now
}
function build_auth_info_array()
{
    global $auth_info;
    $query = "SELECT id, username, real_name, access_level FROM authentication WHERE 1 ORDER BY username";
    $result = mydb::cxn()->query($query) or die("Error retrieving usernames for edit_user list: " . mydb::cxn()->error);
    //Build a local array of access privileges for each user
    $access_levels = array('account_management', 'backup_restore', 'roster', 'edit_phonelist', 'inventory', 'edit_incidents', 'budget_helper', 'budget_helper_admin', 'flight_hours', 'crew_status', 'photos', 'update_jobs', 'order_apparel', 'manage_apparel');
    while ($row = $result->fetch_assoc()) {
        $auth_info[$row['id']] = array('username' => $row['username'], 'real_name' => $row['real_name'], 'id' => $row['id']);
        foreach ($access_levels as $area) {
            if (strpos($row['access_level'], $area) !== false) {
                $auth_info[$row['id']][$area] = 1;
            } else {
                $auth_info[$row['id']][$area] = 0;
            }
        }
    }
}
function update_rss_feed()
{
    $description_length = 300;
    $title_length = 40;
    $num_entries = 4;
    // The number of blog entries to include in the RSS feed
    $query = "SELECT name, unix_timestamp(date) as date, status FROM current_sticky WHERE 1";
    $result = mydb::cxn()->query($query);
    $sticky = $result->fetch_assoc();
    $query = "SELECT name, unix_timestamp(date) as date, status FROM current ORDER BY date DESC LIMIT " . $num_entries;
    $result = mydb::cxn()->query($query);
    $rss = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n" . "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n" . "<channel>\n\n" . "<title>SRC - Crew Status</title>\n" . "<link>http://www.siskiyourappellers.com/current.php</link>\n" . "<description>\n" . "\tThe Crew Status Page provides information on the whereabouts of crewmembers\n" . "\tand the various projects that we're currently working on.\n" . "</description>\n\n" . "<atom:link href=\"http://www.siskiyourappellers.com/rss.php\" rel=\"self\" type=\"application/rss+xml\" />\n" . "<lastBuildDate>" . date("r") . "</lastBuildDate>\n" . "<language>en-us</language>\n\n";
    //Post the "sticky" content at the top of the RSS Feed
    if (strlen($sticky['status']) > 0) {
        if (strlen($sticky['status']) > $title_length) {
            $content_title = substr($sticky['status'], 0, $title_length) . "...";
        } else {
            $content_title = $sticky['status'];
        }
        $timestamp_sticky = date("r", $sticky['date']);
        $timestamp_title = date("M jS", $sticky['date']);
        $rss .= "<item>\n" . "<title>[!] " . $content_title . "</title>\n" . "<link>http://www.siskiyourappellers.com/current.php</link>\n" . "<guid>http://www.siskiyourappellers.com/current.php?id=" . $sticky['date'] . "</guid>\n" . "<pubDate>" . $timestamp_sticky . "</pubDate>\n" . "<description>" . $sticky['status'] . "</description>\n" . "</item>\n\n";
    }
    //Add the most recent updates to the RSS feed
    while ($row = $result->fetch_assoc()) {
        //Replace <br> with a single space - " "
        $status = str_replace(array("<br>", "<br />", "<BR>", "<BR />"), " ", $row['status']);
        //Generate a Title for this update
        if (strlen($status) > $title_length) {
            $content_title = substr($status, 0, $title_length) . "...";
        } else {
            $content_title = $status;
        }
        //Format the date strings
        $timestamp_status = date("r", $row['date']);
        $timestamp_title = date("M jS", $row['date']);
        $rss .= "<item>\n" . "<title>[" . $timestamp_title . "] " . $content_title . "</title>\n" . "<link>http://www.siskiyourappellers.com/current.php</link>\n" . "<guid>http://www.siskiyourappellers.com/current.php?id=" . $row['date'] . "</guid>\n" . "<pubDate>" . $timestamp_status . "</pubDate>\n" . "<description>" . $status . "</description>\n" . "</item>\n\n";
    }
    // END WHILE
    $rss .= "</channel>\n" . "</rss>\n";
    //Open the rss.xml file for writing
    $rss_file = fopen("../rss.xml", "w");
    fwrite($rss_file, $rss);
}
示例#8
0
 function set($var, $value)
 {
     // This function handles a SPECIAL CASE where the use_offset is queried for a ROPE object.  This is special because a ROPE has a different use_offset
     // for each end (end 'a' and end 'b'), which are serialized into a single STRING value for database storage.
     // If this set function is called and the special case does not apply, the 'set' function in the parent class will be invoked.
     $value = strtolower(mydb::cxn()->real_escape_string($value));
     switch ($var) {
         case 'use_offset':
             if ($value == "") {
                 $this->use_offset = 'a0,b0';
             } elseif (preg_match('/\\ba\\d{1,3},b\\d{1,3}\\b/', $value) != 1) {
                 throw new Exception('The USE OFFSET for a rope must include both the \'A\' end and the \'B\' end.');
             } else {
                 $this->use_offset = $value;
             }
         case 'use_offset_a':
             if ($value == "") {
                 $this->use_offset = 'a0,b0';
             }
             if ($this->var_is_int($value) && $value >= 0) {
                 $this->use_offset = 'a' . $value . ',b' . $this->get_use_offset('b');
             } else {
                 throw new Exception('The use-offset for end \'A\' must be a number greater than or equal to zero.');
             }
             break;
         case 'use_offset_b':
             if ($this->var_is_int($value) && $value >= 0) {
                 $this->use_offset = 'a' . $this->get_use_offset('a') . ',b' . $value;
             } else {
                 throw new Exception('The use-offset for end \'B\' must be a number greater than or equal to zero.');
             }
             break;
         default:
             parent::set($var, $value);
     }
     // End: switch()
 }
function update_or_insert_paycheck($year, $payperiod, $person_id, $status)
{
    //This function will change the STATUS of a specific paycheck.
    //Sanitize inputs
    $year = mydb::cxn()->real_escape_string($year);
    $payperiod = mydb::cxn()->real_escape_string($payperiod);
    $person_id = mydb::cxn()->real_escape_string($person_id);
    $status = mydb::cxn()->real_escape_string($status);
    //Check to see if this paycheck is already in the database
    $query = "\tSELECT id FROM paychecks\n\t\t\t\t\tWHERE \tpaychecks.year = " . $year . "\n\t\t\t\t\tAND\t\tpaychecks.payperiod = " . $payperiod . "\n\t\t\t\t\tAND\t\tpaychecks.crewmember_id = " . $person_id;
    $result = mydb::cxn()->query($query);
    $row = $result->fetch_assoc();
    echo $query . "<br /><br />\n\n";
    if ($result->num_rows > 0) {
        // This paycheck is already in the database.  UPDATE the status.
        $query = "UPDATE paychecks SET status = " . $status . " WHERE id = " . $row['id'];
        $result = mydb::cxn()->query($query);
    } else {
        // This paycheck is NOT in the database.  INSERT it with the requested status.
        $query = "\tINSERT INTO paychecks (year,payperiod,crewmember_id,status)\n\t\t\t\t\t\tvalues(" . $year . "," . $payperiod . "," . $person_id . "," . $status . ")";
        $result = mydb::cxn()->query($query);
    }
    echo $query . "\n\n" . mydb::cxn()->error;
}
function show_add_eq_form($eq_type, $msg = "")
{
    $field1 = "";
    $field2 = "";
    $field3 = "";
    $field4 = $_SESSION['current_view']['crew']->get('id');
    if ($msg != "" && $msg != "Your equipment has been added.") {
        //If an error was thrown, repopulate the form with the POST'ed values
        $field1 = $_POST['eq_num1'];
        $field2 = $_POST['eq_num2'];
        $field3 = $_POST['in_service_date'];
        $field4 = $_POST['crew_affiliation_id'];
    }
    // Build Crew selection menu AND
    // Build a hidden list of Crew Abbreviations.
    // This list is used to update the equipment # field in the modify_equipment_form when the Ownership is changed
    echo "<form action=\"\" method=\"GET\" id=\"abbrev_list\">\n";
    $query = "SELECT DISTINCT id, name, abbrev FROM crews ORDER BY name";
    $result = mydb::cxn()->query($query);
    $crew_menu = "";
    while ($row = $result->fetch_assoc()) {
        if ($field4 == $row['id']) {
            $crew_menu .= "<option value=\"" . $row['id'] . "\" selected=\"selected\">" . $row['name'] . "</option>\n";
            $abbrev = $row['abbrev'];
        } elseif ($_SESSION['current_user']->get('account_type') == 'admin' || $row['id'] == get_academy_id($_SESSION['current_user']->get('region'))) {
            $crew_menu .= "<option value=\"" . $row['id'] . "\">" . $row['name'] . "</option>\n";
        }
        echo "<input type=\"hidden\" name=\"crew_" . $row['id'] . "_abbrev\" id=\"crew_" . $row['id'] . "_abbrev\" value=\"" . $row['abbrev'] . "\">\n";
    }
    echo "</form>\n\n";
    echo "<br><div class=\"error_msg\">" . $msg . "</div>\n";
    echo "<form id=\"modify_equipment_form\" method=\"post\" action=\"add_new_equipment.php?crew=" . $_GET['crew'] . "&eq_type=" . $eq_type . "\" style=\"text-align:center;\">\n\t\t\t\t\t<input type=\"hidden\" name=\"eq_type\" value=\"" . $eq_type . "\">\n\t\t\t\t\t<table width=\"500\" style=\"border:2px solid #555555; background-color:#bbbbbb;margin:25px auto 0 auto;\">\n\t\t\t\t\t\t<tr><td colspan=\"2\" style=\"text-align:left; font-size:15px; font-weight:bold;\">Add a New " . ucwords(str_replace("_", " ", $eq_type)) . "</td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style=\"width:150px;\">" . ucwords(str_replace("_", " ", $eq_type)) . " #:</td>\n\t\t\t\t\t\t\t<td style=\"width:auto;text-align:left;\">\n\t\t\t\t\t\t\t\t<input type=\"text\" name=\"eq_num1\" id=\"eq_abbrev\" value=\"" . $abbrev . "\" style=\"width:2.5em; background-color:#bbbbbb; border:none; text-transform:uppercase; text-align:right;\" readonly=\"readonly\"/> -\n\t\t\t\t\t\t\t\t<span id=\"eq_num2_spry\">\n\t\t\t\t\t\t\t\t<input type=\"text\" name=\"eq_num2\" id=\"eq_num2\" value=\"" . $field2 . "\" style=\"width:4.5em\"/>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldRequiredMsg\">Required</span>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldInvalidFormatMsg\">Must be a 3-7 digit number.</span>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldMinCharsMsg\">Must be 3 digits.</span>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldMaxCharsMsg\">Must be 7 digits.</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>";
    if ($eq_type == 'rope') {
        echo "<tr><td>Unrecorded uses<br />on End 'A':</td><td style=\"text-align:left\"><input type=\"text\" name=\"use_offset_a\" style=\"width:2.5em\"></td></tr>\n" . "<tr><td>Unrecorded uses<br />on End 'B':</td><td style=\"text-align:left\"><input type=\"text\" name=\"use_offset_b\" style=\"width:2.5em\"></td></tr>\n";
    } else {
        echo "<tr><td>Unrecorded uses:</td><td style=\"text-align:left\"><input type=\"text\" name=\"use_offset\" style=\"width:2.5em\"></td></tr>\n";
    }
    echo "\t\t<tr>\n\t\t\t\t\t\t\t<td>Manufacture Date:</td>\n\t\t\t\t\t\t\t<td style=\"text-align:left\">\n\t\t\t\t\t\t\t\t<span id=\"in_service_date_spry\">\n\t\t\t\t\t\t\t\t\t<input type=\"text\" name=\"in_service_date\" id=\"in_service_date\" style=\"width:5em\" value=\"" . $field3 . "\" onFocus=\"showCal('equipment_in_service_date')\" />\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldRequiredMsg\">Required</span>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldInvalidFormatMsg\">Date must be: mm/dd/yyyy</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Ownership:</td>\n\t\t\t\t\t\t\t<td style=\"text-align:left\"><select name=\"crew_affiliation_id\" id=\"crew_affiliation_id\" onchange=\"updateAbbrev()\">" . $crew_menu . "</select></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan=\"2\" style=\"text-align:center\"><input name=\"submit\" type=\"submit\" class=\"form_button\" style=\"width:150px\" value=\"Save\" /></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</form>";
}
function populate_requisition_by_id($id)
{
    /* Check id validity here */
    $requisition_id = mydb::cxn()->real_escape_string($_GET['id']);
    $query = "SELECT count(*) as num FROM requisitions WHERE id = " . $requisition_id;
    $result = mydb::cxn()->query($query);
    $row = $result->fetch_assoc();
    if ($row['num'] == 0) {
        throw new Exception('The requested requisition does not exist (Requisition #' . $requisition_id . ').');
    }
    $query = "SELECT\n\t\t\t  requisitions.id,\n                          requisitions.added_by,\n\t\t\t  requisitions.vendor_info,\n\t\t\t  requisitions.description,\n\t\t\t  requisitions.attachment1, \n\t\t\t  requisitions.attachment2,\n\t\t\t  requisitions.attachment3,\n\t\t\t  round(requisitions.amount,2) as order_total,\n\t\t\t  requisitions.card_used,\n\t\t\t  date_format(requisitions.date,'%m/%d/%Y') as date,\n\t\t\t  requisitions_split.id as split_id,\n\t\t\t  requisitions_split.comments as split_comments,\n\t\t\t  requisitions_split.s_number,\n\t\t\t  requisitions_split.charge_code,\n\t\t\t  requisitions_split.override,\n\t\t\t  round(requisitions_split.amount,2) as amount,\n\t\t\t  requisitions_split.received as split_received,\n\t\t\t  requisitions_split.reconciled as split_reconciled\n\t\t\t  FROM requisitions LEFT OUTER JOIN requisitions_split \n\t\t\t  ON requisitions.id = requisitions_split.requisition_id\n\t\t\t  WHERE requisitions.id = " . $id . "\n\t\t\t  ORDER BY split_id";
    $result = mydb::cxn()->query($query);
    if (!$result) {
        throw new Exception('Database error: ' . mydb::cxn()->error);
    }
    $_SESSION['form_memory']['requisition'] = array();
    while ($row = $result->fetch_assoc()) {
        $_SESSION['form_memory']['requisition'][] = $row;
    }
    return;
}
	}
	else {
		// Access Denied.
		header('location: http://www.siskiyourappellers.com/admin/index.php');
	}
*/
try {
    $req_id = mydb::cxn()->real_escape_string($_GET['req_id']);
    $attachment_num = mydb::cxn()->real_escape_string($_GET['attachment_num']);
    $query = "SELECT attachment" . $attachment_num . " FROM requisitions WHERE id = " . $req_id;
    $result = mydb::cxn()->query($query);
    if (mydb::cxn()->affected_rows > 0) {
        $row = $result->fetch_assoc();
        $attachment_path = $row['attachment' . $attachment_num];
    } else {
        throw new Exception('Requisition #' . $req_id . ' doesn\'t appear to have an Attachment #' . $attachment_num . '!');
        exit;
    }
    if (!unlink($_SERVER['DOCUMENT_ROOT'] . "/admin/" . $attachment_path)) {
        throw new Exception('Attachment #' . $attachment_num . ' could not be deleted.');
    } else {
        $query = "UPDATE requisitions SET attachment" . $attachment_num . " = NULL WHERE id = " . $req_id;
        $result = mydb::cxn()->query($query);
        if (mydb::cxn()->error != '') {
            throw new Exception('Attachment #' . $attachment_num . ' was deleted, but the database entry still exists: ' . mydb::cxn()->error);
        }
    }
} catch (Exception $e) {
    echo $e->getMessage();
}
return true;
    $query = "SELECT query, unix_timestamp(creation_date) as creation_date, (days_until_expiration * 24 * 3600) as exp_interval FROM confirmation WHERE code = '" . mydb::cxn()->real_escape_string($_GET['verification']) . "'";
    $result = mydb::cxn()->query($query);
    $row = $result->fetch_assoc();
    if ($row['query'] == "") {
        echo "That confirmation code is invalid<br>\n";
    } elseif ($row['creation_date'] + $row['exp_interval'] < time()) {
        echo "<div class=\"error_msg\" style=\"margin:0 auto 0 auto;\">That confirmation code has expired!</div>\n";
        $query = "DELETE from confirmation WHERE code = '" . mydb::cxn()->real_escape_string($_GET['verification']) . "'";
        $result = mydb::cxn()->query($query);
    } else {
        if (!mydb::cxn()->multi_query($row['query'])) {
            echo "<div class=\"error_msg\" style=\"margin:0 auto 0 auto;\">There was a problem confirming your request.</div>\n";
        } else {
            while (mydb::cxn()->next_result()) {
                mydb::cxn()->store_result();
            }
            //Clear the buffer from the dB multi_query
            echo "<div class=\"error_msg\" style=\"margin:0 auto 0 auto;\">Your request has been confirmed.</div>";
            $query = "DELETE from confirmation WHERE code = '" . mydb::cxn()->real_escape_string($_GET['verification']) . "'";
            $result = mydb::cxn()->query($query);
            echo mydb::cxn()->error;
        }
    }
}
?>
    </div> <!-- End 'content' -->
   	
<div style="clear:both; display:block; visibility:hidden;"></div>
</body>
</html>
示例#14
0
 static function exists($hrap_id = false)
 {
     // Returns TRUE if $hrap_id is found in the 'hraps' database table
     // Returns FALSE otherwise.
     // This function will take any data type as input.
     if (!$hrap_id) {
         return false;
     }
     $query = "SELECT id FROM hraps WHERE id = " . mydb::cxn()->real_escape_string($hrap_id);
     $result = mydb::cxn()->query($query);
     if (mydb::cxn()->affected_rows > 0) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
示例#15
0
 function item_id_exists($item_id = '')
 {
     // This function checks the database to see if an item exists with the ID specified by $item_id
     // Return TRUE if an item exists
     // Return FALSE otherwise
     if ($item_id != '') {
         $query = "SELECT * FROM items WHERE id = '" . mydb::cxn()->real_escape_string($item_id) . "'";
         $result = mydb::cxn()->query($query);
         return $result->num_rows > 0 ? TRUE : FALSE;
     } else {
         return FALSE;
     }
 }
示例#16
0
function aircraft($id, $action, $year)
{
    switch ($action) {
        case "operations":
            $query = "SELECT ";
            break;
        case "rappels":
            $query = "SELECT ";
            break;
        default:
            throw new Exception();
            //Non-existent action was requested
            break;
    }
    $result = mydb::cxn()->query($query);
    $object = array();
    while ($row = $result->fetch_assoc()) {
        $object[] = $row;
    }
    echo json_encode($object, JSON_FORCE_OBJECT);
}
<?php

include '../php_doc_root.php';
require_once "../../classes/mydb_class.php";
require_once "../../classes/hrap_class.php";
require_once "../../classes/crew_class.php";
require_once "includes/charts/chart_error_msg.php";
session_name('raprec');
session_start();
// Determine the 3 other HRAPS who have rappelled with THIS HRAP the most
$query = "SELECT hrap_name FROM view_rappels " . "WHERE (operation_id IN (SELECT operation_id FROM rappels WHERE hrap_id = " . $_SESSION['current_view']['hrap']->get('id') . ")) " . "&& (hrap_id <> " . $_SESSION['current_view']['hrap']->get('id') . ")";
$result = mydb::cxn()->query($query);
$fav = array(1 => array('name' => '', 'raps' => 0), 2 => array('name' => '', 'raps' => 0), 3 => array('name' => '', 'raps' => 0));
$tally = array();
while ($row = $result->fetch_assoc()) {
    if (array_key_exists($row['hrap_name'], $tally)) {
        $tally[$row['hrap_name']]++;
    } else {
        $tally[$row['hrap_name']] = 1;
    }
}
arsort($tally);
$tally_keys = array_keys($tally);
if (isset($tally_keys[0])) {
    $fav[1] = array('name' => $tally_keys[0], 'raps' => $tally[$tally_keys[0]]);
}
if (isset($tally_keys[1])) {
    $fav[2] = array('name' => $tally_keys[1], 'raps' => $tally[$tally_keys[1]]);
}
if (isset($tally_keys[2])) {
    $fav[3] = array('name' => $tally_keys[2], 'raps' => $tally[$tally_keys[2]]);
function commit_letdown_line()
{
    // Load letdown_line details into the form memory
    $_SESSION['form_memory']['letdown_line'][0] = mydb::cxn()->real_escape_string($_POST['id']);
    $_SESSION['form_memory']['letdown_line'][1] = mydb::cxn()->real_escape_string($_POST['letdown_line_num1']) . "-" . mydb::cxn()->real_escape_string($_POST['letdown_line_num2']);
    $_SESSION['form_memory']['letdown_line'][2] = mydb::cxn()->real_escape_string($_POST['crew_affiliation_id']);
    $_SESSION['form_memory']['letdown_line'][3] = mydb::cxn()->real_escape_string($_POST['crew_affiliation_name']);
    $_SESSION['form_memory']['letdown_line'][4] = mydb::cxn()->real_escape_string($_POST['in_service_date']);
    $_SESSION['form_memory']['letdown_line'][5] = mydb::cxn()->real_escape_string($_POST['retired_date']);
    $_SESSION['form_memory']['letdown_line'][6] = mydb::cxn()->real_escape_string($_POST['retired_reason']);
    $_SESSION['form_memory']['letdown_line'][7] = mydb::cxn()->real_escape_string($_POST['retired_category']);
    $_SESSION['form_memory']['letdown_line'][8] = mydb::cxn()->real_escape_string($_POST['status']);
    // This function is called within a try/catch block - let any exceptions thrown by the letdown_line class return to the caller
    $eq = new letdown_line();
    $eq->load($_SESSION['form_memory']['letdown_line'][0]);
    $eq->set('serial_num', $_SESSION['form_memory']['letdown_line'][1]);
    $eq->set('crew_affiliation_id', $_SESSION['form_memory']['letdown_line'][2]);
    $eq->set('in_service_date', $_SESSION['form_memory']['letdown_line'][4]);
    $eq->set('retired_date', $_SESSION['form_memory']['letdown_line'][5]);
    $eq->set('retired_reason', $_SESSION['form_memory']['letdown_line'][6]);
    $eq->set('retired_category', $_SESSION['form_memory']['letdown_line'][7]);
    $eq->set('status', $_SESSION['form_memory']['letdown_line'][8]);
    $eq->save();
    return true;
    // Success
}
示例#19
0
 function get_name($crew_id)
 {
     $query = "SELECT name FROM crews WHERE id = " . $crew_id;
     $result = mydb::cxn()->query($query);
     if (mydb::cxn()->affected_rows > 0) {
         $row = $result->fetch_assoc();
         return $row['name'];
     } else {
         return FALSE;
     }
 }
function crew_has_max_admins($crew_id)
{
    $query = "SELECT count(id) as admins FROM authentication WHERE crew_affiliation_id = " . mydb::cxn()->real_escape_string($crew_id) . " AND account_type = 'crew_admin'";
    $result = mydb::cxn()->query($query);
    $row = $result->fetch_assoc();
    if ($row['admins'] >= $_SESSION['max_crew_admins_per_crew']) {
        return true;
    } else {
        return false;
    }
}
if (isset($_POST['function'])) {
    switch ($_POST['function']) {
        case 'restore_from_user_file':
            $fh = fopen($_FILES['userfile']['tmp_name'], 'r');
            while ($line = fgets($fh)) {
                $query .= $line;
            }
            mydb::cxn()->query($query);
            break;
        case 'restore_from_auto_backup':
            $query = "";
            $fh = fopen("../" . $_POST['filename'], 'r');
            while ($line = fgets($fh)) {
                $query .= $line;
            }
            mydb::cxn()->query($query);
            break;
    }
}
//****************************************************************************************
function display_download_menu($backup_file_list)
{
    echo "<div style=\"margin-left:10px;\">\n";
    foreach ($backup_file_list as $key => $row) {
        echo "\t\t\t<a href=\"" . $row['filename'] . "\">" . $row['date'] . "</a><br>\n";
    }
    echo "\t\t\t</div>\n";
    return;
}
// END display_download_menu()
$backup_root_folder = "../db_backups";
 public function id_exists($id = false)
 {
     if (is_numeric($id)) {
         $result = mydb::cxn()->query("SELECT id FROM enrollment WHERE id = " . $id);
         if (mydb::cxn()->error == '') {
             return 1;
         }
     } else {
         return 0;
     }
 }
示例#23
0
    if ($status['success']) {
        if (!move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
            //if(!is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) {
            //if(!resize($_FILES['uploadedfile']['tmp_name'], $target_path)) {
            $status['success'] = 0;
            $status['desc'] = "Unable to accept file, try again later.<br>\n";
        } elseif (!resize($target_path, $target_path, $size)) {
            //file was successfully moved onto the server
            $status['success'] = 0;
            $status['desc'] = "Unable to resize file.<br>\n";
        } elseif (!create_thumbnail($target_path, "photos/thumbs/" . $targets['filename'])) {
            $status['success'] = 0;
            $status['desc'] = "Unable to create thumbnail.<br>\n";
        } else {
            // Photo successfully uploaded, now add an entry in the database
            $result = mydb::cxn()->query("insert into photo_of_the_week(path,thumbpath,photographer,location,description,height,width)\n\t\t\t\t\t\t\t\t\t\tvalues(\t\"photo_of_the_week/photos/" . $targets['filename'] . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"photo_of_the_week/photos/thumbs/" . $targets['filename'] . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"" . mydb::cxn()->real_escape_string($_POST['photographer']) . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"" . mydb::cxn()->real_escape_string($_POST['location']) . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"" . mydb::cxn()->real_escape_string($_POST['description']) . "\",\n\t\t\t\t\t\t\t\t\t\t\t\t" . $size['height'] . "," . $size['width'] . ")") or die("Failed while adding photo entry to dB: " . mydb::cxn()->error());
        }
    }
    // end 'if($status['success'])'
}
// end 'if(isset($_POST['MAX_FILE_SIZE']))'
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Upload Photo of the Week :: Siskiyou Rappel Crew</title>
    $current_sticky = nl2br(htmlentities($_POST['sticky_text'], ENT_QUOTES));
    $current_text = filter_var($current_text, FILTER_SANITIZE_STRING);
    $current_sticky = filter_var($current_sticky, FILTER_SANITIZE_STRING);
    $query = "INSERT INTO current (name, date, status) VALUES('" . $_POST['name'] . "', NOW(), '" . $current_text . "')";
    mydb::cxn()->query($query);
    $query = "UPDATE current_sticky SET name='" . $_POST['name'] . "', date=NOW(), status='" . $current_sticky . "' WHERE 1";
    mydb::cxn()->query($query);
    //update_rss_feed($current_sticky, $current_text, time());
    update_rss_feed();
    header('location: http://www.siskiyourappellers.com/current.php');
    //header('location: http://www.siskiyourappellers.com/admin/update_facebook_wall.php');
    exit;
}
$query_read_sticky = "SELECT name, unix_timestamp(date) as date, status FROM current_sticky WHERE 1";
if (!($result = mydb::cxn()->query($query_read_sticky))) {
    $sticky_text = "Error retrieving sticky post: " . mydb::cxn()->error;
} else {
    $row = $result->fetch_assoc();
    $sticky_text = str_replace("<br />", "", $row['status']);
    $sticky_name = $row['name'];
    $sticky_date = date('d-M-Y H:i', $row['date']);
}
//---------------------------------------------------------------------------------------------------
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
示例#25
0
 private function rappel_id_exists($rappel_id = false)
 {
     // Check for the requested rappel_id in the database
     // Return values:	true	:	The specified rappel_id is NOT found in the database
     //					false	:	The specified rappel_id was found (already exists)
     if (!$rappel_id) {
         return false;
     }
     $query = "SELECT id FROM rappels WHERE id = " . $rappel_id;
     $result = mydb::cxn()->query($query);
     if (mydb::cxn()->affected_rows > 0) {
         return true;
     } else {
         return false;
     }
 }
function show_confirm_existing_hrap_menu()
{
    //Check that the requested HRAP is valid
    $name = check_hrap($_GET['hrap_id']);
    $crew = check_crew($_GET['crew']);
    //Check that the requested HRAP is not already on a roster for the requested year
    $query = "SELECT crews.name as crew_name FROM rosters INNER JOIN crews ON crews.id = rosters.crew_id WHERE rosters.hrap_id = " . $_GET['hrap_id'] . " AND rosters.year = '" . $_SESSION['current_view']['year'] . "'";
    $result = mydb::cxn()->query($query);
    $msg = "";
    if ($name === 0) {
        $msg = "The rappeller you requested does not appear to exist!";
    } elseif ($crew == false) {
        $msg = "The crew you requested does not appear to exist!";
    } elseif (mydb::cxn()->affected_rows > 0) {
        $row = $result->fetch_assoc();
        $msg = $name . " is already a member of " . $row['crew_name'] . " in " . $_SESSION['current_view']['year'] . "!";
    } else {
        $msg = "Are you sure you want to add " . $name . " to your " . $_SESSION['current_view']['year'] . " roster?<br><br>\n\n" . "<form action=\"\" method=\"post\">\n <input type=\"hidden\" name=\"hrap_id\" value=\"" . $_GET['hrap_id'] . "\">\n " . "<input type=\"submit\" value=\"Add\"> <input type=\"button\" value=\"Cancel\" onClick=\"window.location.href='" . $_SERVER['PHP_SELF'] . "?crew=" . $_GET['crew'] . "&function=add_existing_hrap'\">\n " . "</form>";
    }
    show_header();
    echo "<div style=\"border:2px solid #666666;padding:10px;text-align:center;\">" . $msg . "</div><br>\n\n";
    echo "</div>\n";
}
示例#27
0
function get_incidents($crewmember_id = -1)
{
    // Build a database query based on a user-specified sort field
    // Run display_inv to step through each row and display the inventory data
    $query = "\tSELECT\tincidents.idx,\n\t\t\t\t\tunix_timestamp(incidents.date) as date,\n\t\t\t\t\tincidents.event_type,\n\t\t\t\t\tincidents.number,\n\t\t\t\t\tincidents.name,\n\t\t\t\t\tincidents.code,\n\t\t\t\t\tincidents.override,\n\t\t\t\t\tincidents.size,\n\t\t\t\t\tincidents.type,\n\t\t\t\t\tincidents.fuel_models,\n\t\t\t\t\tincidents.description,\n\t\t\t\t\tincidents.latitude_degrees,\n\t\t\t\t\tincidents.latitude_minutes,\n\t\t\t\t\tincidents.longitude_degrees,\n\t\t\t\t\tincidents.longitude_minutes\n\t\t\tFROM incidents\n\t\t\tWHERE year(date) = '" . $_SESSION['incident_year'] . "'";
    $sort_by = $_SESSION['sort_view_by'];
    switch ($sort_by) {
        case "number":
            $query .= " ORDER BY number, date";
            break;
        case "name":
            $query .= " ORDER BY name, number, date";
            break;
        case "override":
            $query .= " ORDER BY override, number, date";
            break;
        case "event_type":
            $query .= " ORDER BY event_type, number, date";
            break;
        case "date":
        default:
            $query .= " ORDER BY date, number";
            $_SESSION['sort_view_by'] = "date";
            break;
    }
    $result = mydb::cxn()->query($query) or die("dB query failed (Retrieving incidents): " . mydb::cxn()->error);
    $incident_array = array();
    $i = 0;
    while ($row = $result->fetch_assoc()) {
        $query2 = "\tSELECT CONCAT(crewmembers.firstname,' ',crewmembers.lastname) AS name, crewmembers.id\n\t\t\t\t\tFROM crewmembers\tINNER JOIN incident_roster\tON crewmembers.id = incident_roster.crewmember_id\n\t\t\t\t\t\t\t\t\t\tINNER JOIN incidents\t\tON incident_roster.idx = incidents.idx\n\t\t\t\t\tWHERE incident_roster.idx LIKE '" . $row['idx'] . "' ORDER BY name";
        $result2 = mydb::cxn()->query($query2) or die("dB query failed (Retrieving incident_roster): " . mydb::cxn()->error);
        //If a specific crewmember has been specified, only return incidents where that crewmember was present
        if ($crewmember_id != -1) {
            $searching = 1;
        } else {
            $searching = 0;
        }
        $found = 0;
        while ($roster_row = $result2->fetch_assoc()) {
            $one_incident_roster[] = $roster_row['name'];
            if ($crewmember_id == $roster_row['id']) {
                $found = 1;
            }
        }
        if (!$searching || $searching && $found) {
            $incident_array[$i] = $row;
            $incident_array[$i]['roster'] = $one_incident_roster;
            $i++;
        }
        $one_incident_roster = array();
    }
    return $incident_array;
}
function delete_attached_file($file_id)
{
    $query = "SELECT file_path from incident_files where id = " . $file_id;
    $result = mydb::cxn()->query($query);
    if ($row = $result->fetch_assoc()) {
        $query = "DELETE from incident_files WHERE id = " . mydb::cxn()->real_escape_string($file_id);
        $result = mydb::cxn()->query($query);
        //Delete the file
        if (!@unlink("../" . $row['file_path'])) {
            $error = 1;
            $error_msg = "Unable to delete " . $row['path'];
        }
    }
}
示例#29
0
<body>
<div id="wrapper" style="height:170px; min-height:170px; width:900px;">
	<div id="banner">
        <a href="http://www.siskiyourappellers.com/training" style="display:block; width:900px; height:75px; padding:0;"><img src="images/banner_index2.jpg" style="border:none" alt="Scroll down..." /></a>
    </div>
</div>

<div id="wrapper" style="width:95%;">
	<div id="content" style="text-align:center">
    
    <?php 
echo "<br /><h2 style=\"font-size:1.7em;\">Upcoming Courses</h2>\n" . "<table style=\"font-size:1.5em; margin:0 auto 0 auto;\">\n" . "<tr><th>Start Date</th><th>Course</th><th>Student</th><th>Status</th></tr>\n";
$query = "SELECT\n\t\t\t  scheduled_courses.id,\n\t\t\t  scheduled_courses.name as course_name,\n\t\t\t  scheduled_courses.date_start,\n\t\t\t  scheduled_courses.date_end,\n\t\t\t  CONCAT(people.firstname,' ',people.lastname) as student,\n\t\t\t  enrollment.status\n\t\t\t  \n\t\t\t  FROM\n\t\t\t  scheduled_courses INNER JOIN enrollment\n\t\t\t  ON enrollment.scheduled_course_id = scheduled_courses.id\n\t\t\t  INNER JOIN people on people.id = enrollment.student_id\n\t\t\t  \n\t\t\t  WHERE\n\t\t\t  scheduled_courses.date_end >= CURDATE()";
$result = mydb::cxn()->query($query);
if (mydb::cxn()->error != '') {
    throw new Exception('There was a problem retrieving enrolled courses for this crew');
}
$last_course_id = -1;
$row_class = 'evn';
while ($row = $result->fetch_assoc()) {
    if ($row['id'] == $last_course_id) {
        echo "<tr class=\"" . $row_class . "\"><td colspan=\"2\">&nbsp;</td>";
    } else {
        if ($row_class == 'evn') {
            $row_class = 'odd';
        } else {
            $row_class = 'evn';
        }
        echo "<tr class=\"" . $row_class . "\"><td>" . $row['date_start'] . "</td>" . "<td>" . $row['course_name'] . "</td>";
    }
示例#30
0
	0		1		2		3
	
		4				5				8	9
		
		6				7

--------------------------------------------------------*/
$seat_coords = array(array('x' => 21, 'y' => 84), array('x' => 50, 'y' => 84), array('x' => 80, 'y' => 84), array('x' => 110, 'y' => 84), array('x' => 35, 'y' => 131), array('x' => 93, 'y' => 131), array('x' => 35, 'y' => 159), array('x' => 93, 'y' => 159), array('x' => 187, 'y' => 97), array('x' => 228, 'y' => 97));
$seats = array('light' => array('bench' => array('1' => array('left' => array('raps' => 0, 'seat_num' => 8), 'right' => array('raps' => 0, 'seat_num' => 9))), 'hellhole' => array('1' => array('left' => array('raps' => 0, 'seat_num' => 8), 'right' => array('raps' => 0, 'seat_num' => 9)))), 'medium' => array('bench' => array('1' => array('left' => array('raps' => 0, 'seat_num' => 0), 'right' => array('raps' => 0, 'seat_num' => 3)), '2' => array('left' => array('raps' => 0, 'seat_num' => 1), 'right' => array('raps' => 0, 'seat_num' => 2)), '3' => array('left' => array('raps' => 0, 'seat_num' => 4), 'right' => array('raps' => 0, 'seat_num' => 5))), 'hellhole' => array('1' => array('left' => array('raps' => 0, 'seat_num' => 0), 'right' => array('raps' => 0, 'seat_num' => 3)), '2' => array('left' => array('raps' => 0, 'seat_num' => 4), 'right' => array('raps' => 0, 'seat_num' => 5)), '3' => array('left' => array('raps' => 0, 'seat_num' => 6), 'right' => array('raps' => 0, 'seat_num' => 7)))));
$heli_types = array('1' => 'heavy', '2' => 'medium', '3' => 'light');
// Match helicopter type number with their type description
$raps_by_seat = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
// This array is used to consolidate redundant entries in the $raps_by_seat array so that each seat has only one entry
$query = "\n\tSELECT rappels.door, rappels.stick, aircraft_types.type, aircraft_types.configuration, COUNT( rappels.id ) as rap_count\n\tFROM rappels\n\tINNER JOIN operations ON rappels.operation_id = operations.id\n\tINNER JOIN aircraft_types ON operations.aircraft_type_config = aircraft_types.id\n\t\n\tWHERE hrap_id = " . $_SESSION['current_view']['hrap']->get('id') . "\n\tGROUP BY TYPE , configuration, stick, door";
$result = mydb::cxn()->query($query);
if (mydb::cxn()->error != NULL) {
    bad_image("Error retrieving HRAP stats");
}
while ($row = $result->fetch_assoc()) {
    $raps_by_seat[$seats[$heli_types[$row['type']]][$row['configuration']][$row['stick']][$row['door']]['seat_num']] += $row['rap_count'];
}
// Define the font color
$fc = imagecolorallocate($helicopter, 50, 50, 50);
foreach ($raps_by_seat as $seat_num => $rap_count) {
    $x = $seat_coords[$seat_num]['x'];
    $y = $seat_coords[$seat_num]['y'];
    $x = $x - 4 * (strlen($raps_by_seat[$seat_num]) - 1);
    // Move the starting point LEFT 4 pixels for each digit in excess of 1
    imagestring($helicopter, 4, $x, $y, $raps_by_seat[$seat_num], $fc);
}
// Write finished image to browser