예제 #1
0
function auth()
{
    $id = mysql_escape_string($_POST['login']);
    $password = mysql_escape_string($_POST['password']);
    $query = mysql_query("SELECT * FROM tbl_auth WHERE id = '{$id}' and password ='******' limit 1");
    if (mysql_num_rows($query) == 1) {
        $_SESSION['auth'] = "1";
        $_SESSION['id'] = $id;
        $_SESSION['name'] = get_agency_name($id);
        //this is the first time we use this function to pull the agency name.
        $_SESSION['ses_start'] = date('Y-m-d-h-i-s');
        $_SESSION['log_ip'] = $_SERVER['REMOTE_ADDR'];
        log_activity('login');
        load_index();
    } else {
        $error_message = 'Sorry, try again! (your ip address has been recorded)';
        // This is an example of a generic log entry
        $_SESSION['extra'] = $id;
        //we set the extra var to the attemped user id
        $_SESSION['log_ip'] = $_SERVER['REMOTE_ADDR'];
        //we record the ip address
        log_activity('failed login');
        //we use a string to id the activity and write the log
        //  end of logging
        show_login($error_message);
    }
    //echo $query;
}
*
*
*/
ini_set('display_errors', 'On');
include '../config.php';
include '../includes/globalinc.php';
## This is the testing Agency
//$agency = "H12";  //Comment out once everything is ready
##
$agency = $_GET['id'];
$tmpfname = tempnam("../downloads", $agency) . ".csv";
$handle = fopen($tmpfname, "w");
$query = "SELECT * FROM tbl_idc WHERE agency = '{$agency}'";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
    $agency = get_agency_name($row['agency']);
    $idc_number = $row['idc_id_internal'];
    $scope_of_contract = $row['scope_of_work'];
    $contractor = mysql_escape_string($row['contractor']);
    $commencement = $row['commencement'];
    $expiration = $row['expiration'];
    $idc_id = $row['id'];
    #IDC
    ## Build Header
    fwrite($handle, "\"Agency Name\",\"{$agency}\"\n");
    fwrite($handle, "\"IDC Number\",\"{$idc_number}\"\n");
    fwrite($handle, "\"IDC Project Name\",\"{$scope_of_contract}\"\n");
    fwrite($handle, "\"IDC Contractor\",\"{$contractor}\"\n");
    fwrite($handle, "\"Effective Date\",\"{$commencement}\"\n");
    fwrite($handle, "\"Termination Date\",\"{$expiration}\"\n");
    fwrite($handle, "\n");