Exemple #1
0
 function go_page_list()
 {
     // Update the shopsetting to indicate this step is complete
     global $ROW, $TEMPLATE;
     LOG_MSG('INFO', "go_page_list(): START ");
     // Do we have a search string?
     // Get all the args from $_GET
     $name = get_arg($_GET, "name");
     $title = get_arg($_GET, "title");
     $type = get_arg($_GET, "type");
     LOG_MSG('DEBUG', "go_page_list(): Got args");
     // Validate parameters as normal strings
     LOG_MSG('DEBUG', "go_page_list(): Validated args");
     // Rebuild search string for future pages
     $search_str = "name={$name}&title={$title}&type={$type}";
     $ROW = $this->admin_model->db_page_select("", $name, $title, '', $type);
     if ($ROW[0]['STATUS'] != "OK") {
         add_msg("ERROR", "There was an error loading the Pages. Please try again later. ");
         return;
     }
     $this->data['rows'] = $ROW;
     $this->load->view('theme1/nav/header', $this->data, '');
     $this->load->view('theme1/nav/topbar', $this->data, '');
     $this->load->view('theme1/index', $this->data);
     $this->load->view('theme1/nav/footer', $this->data);
     LOG_MSG('INFO', "go_page_list(): END");
 }
Exemple #2
0
function do_login($auto_login = 0)
{
    global $GO;
    global $ROW;
    // Are we already logged in?
    do_logout();
    // Everybody goes home after login
    $GO = "Home";
    // Auto login?
    if ($auto_login) {
        // Happens after registration
        session_regenerate_id(true);
        $_SESSION['logged_in'] = 1;
        $_SESSION['user_id'] = $auto_login;
        $_SESSION['fname'] = $ROW["fname"];
        // This is the row used for registration
        $_SESSION['email_id'] = $ROW["email_id"];
    } else {
        if (get_arg($_POST, "lemail_id") && get_arg($_POST, "lpassword")) {
            // Get parameters
            $_email_id = get_arg($_POST, "lemail_id");
            $_password = get_arg($_POST, "lpassword");
            // Validate ALL parameters
            if (!validate("Email ID", $_email_id, 5, 100, "EMAIL") || !validate("Password", $_password, 5, 100, "PASSWORD")) {
                add_msg('ERROR', "The email ID or password you entered is incorrect</br>");
                return;
            }
            ##################################################
            #                  DB LOGIN                      #
            ##################################################
            $ROW = db_do_login($_email_id, $_password);
            if ($ROW[0]['STATUS'] == "OK" && $ROW[0]["NROWS"] == 1) {
                session_regenerate_id(true);
                $_SESSION['email_id'] = $_email_id;
                $_SESSION['logged_in'] = 1;
                $_SESSION['user_id'] = $ROW[0]["user_id"];
                $_SESSION['fname'] = $ROW[0]["fname"];
                add_msg('SUCCESS', "Welcome " . $ROW[0]["fname"] . "! </br>");
                if ($ROW[0]["type"] == "E") {
                    $_SESSION['employee'] = 1;
                    // For employees store a backup of their details since they
                    // switch roles often
                    $_SESSION['e_user_id'] = $ROW[0]["user_id"];
                    $_SESSION['e_fname'] = $ROW[0]["fname"];
                    $_SESSION['e_email_id'] = $_email_id;
                }
            }
        }
    }
    // logged_in will not be set if we failed anywhere above
    if (!isset($_SESSION['logged_in']) || !$_SESSION['logged_in']) {
        add_msg('ERROR', "1The email ID or password you entered is incorrect</br>");
    }
}
Exemple #3
0
function do_check_rooms()
{
    global $ROW, $TEMPLATE;
    LOG_MSG('INFO', "do_check_rooms(): START GET=" . print_r($_GET, true));
    // Get all the args from $_GET
    $room_name = get_arg($_GET, "room_name");
    $room_id = get_arg($_GET, "room_id");
    $ROW = db_room_select($room_id, $room_name);
    if ($ROW[0]['STATUS'] != "OK") {
        add_msg("ERROR", "There was an error loading the wallet. Please try again later. <br/>");
        return;
    }
    LOG_MSG('INFO', "do_check_rooms() : END");
}
Exemple #4
0
function modulesetting_init()
{
    global $MODULE_SETTINGS;
    $MODULE_SETTINGS = array();
    LOG_MSG('INFO', "modulesetting_init(): START");
    $resp = execSQL("SELECT \n\t\t\t\t\t\tname,value\n\t\t\t\t\tFROM \n\t\t\t\t\t\ttSetting \n\t\t\t\t\tWHERE\n\t\t\t\t\t\tis_hidden=1 AND \n\t\t\t\t\t\tTRAVEL_ID=" . TRAVEL_ID, array(), false);
    if ($resp[0]['STATUS'] != 'OK') {
        add_msg("ERROR", "There was an error loading your module settings. Please contact customer care");
        return false;
    }
    LOG_MSG('INFO', "modulesetting_init(): Loaded " . $resp[0]['NROWS'] . " settings");
    for ($i = 0; $i < $resp[0]['NROWS']; $i++) {
        $name = $resp[$i]['name'];
        $value = $resp[$i]['value'];
        $MODULE_SETTINGS[$name] = $value;
    }
    LOG_ARR("INFO", "SHOP SETTINGS", $MODULE_SETTINGS);
    LOG_MSG('INFO', "modulesetting_init(): END");
    return true;
}
Exemple #5
0
function db_get_list($TYPE = 'LIST', $fields, $table, $where_clause = "")
{
    LOG_MSG("INFO", "####### db_get_list(): TYPE={$TYPE}, fields={$fields},table={$table},where_clause={$where_clause} ");
    // Only allow single fields for LIST
    if ($TYPE == 'LIST' && preg_match('/,/', $fields)) {
        add_msg('ERROR', 'Internal error. Pease contact customer service.');
        LOG_MSG('ERROR', 'db_get_list(): Type LIST should have only one SELECT field');
        return false;
    }
    if ($where_clause) {
        $where_clause = " WHERE " . $where_clause;
    }
    $row = execSQL("\tSELECT \n\t\t\t\t\t\t{$fields} \n\t\t\t\t\tFROM \n\t\t\t\t\t\t{$table} \n\t\t\t\t\t\t{$where_clause}\n\t\t\t\t\tORDER \n\t\t\t\t\t\tBY 1", array(), false);
    if ($row[0]['STATUS'] != 'OK') {
        add_msg('ERROR', 'Internal error. Pease contact customer service.');
        LOG_ARR('INFO', 'row', $row);
        return false;
    }
    if ($TYPE == 'LIST') {
        $values = "";
        $seperator = "";
        //LOG_MSG('INFO',"=======================".print_r($row,true));
        for ($i = 0; $i < $row[0]['NROWS']; $i++) {
            $values = $values . $seperator . $row[$i][$fields];
            $seperator = ",";
            //LOG_MSG('INFO',"=========[$values]");
        }
        return $values;
    } else {
        return $row;
    }
}
Exemple #6
0
function upload_image($html_img_name, $dest_img_file, $req_width = '', $req_height = '', $autocrop = 0)
{
    LOG_MSG("INFO", "upload_image():START html_img_name = [{$html_img_name}],\n\t\t\t\t\t\t\t\t\t\tdest_img_file = [{$dest_img_file}],\n\t\t\t\t\t\t\t\t\t\treq_width = [{$req_width}],\n\t\t\t\t\t\t\t\t\t\treq_height = [{$req_height}],\n\t\t\t\t\t\t\t\t\t\tautocrop = [{$autocrop}]");
    if (isset($_FILES[$html_img_name]) && validate_file($_FILES[$html_img_name])) {
        if ($_FILES[$html_img_name]['type'] != 'image/jpeg' && $_FILES[$html_img_name]['type'] != 'image/pjpeg' && $_FILES[$html_img_name]['type'] != 'image/png') {
            add_msg('ERROR', 'Sorry, you can only upload a jpg, jpeg or png image. Please try again.');
            LOG_MSG('ERROR', "upload_image(): Got file type=[" . $_FILES[$html_img_name]['type'] . "]");
            return false;
        }
        LOG_ARR('INFO', 'upload_image(): FILES', $_FILES);
        //Crop/Resize the image
        if ($req_width !== '' && $req_height !== '') {
            if (!image_resize(get_arg($_FILES[$html_img_name], 'tmp_name'), $req_width, $req_height, $autocrop)) {
                add_msg('ERROR', 'There was an error uploading the image. Please try later');
                LOG_MSG('ERROR', "upload_image(); Error resizing the file");
                return false;
            }
        }
        // Copy the file to the uploaded directory
        if (!copy(get_arg($_FILES[$html_img_name], 'tmp_name'), $dest_img_file)) {
            add_msg('ERROR', 'There was an error uploading the image. Please try later');
            LOG_ARR('INFO', 'upload_image(): FILES', $_FILES);
            LOG_MSG('ERROR', "upload_image(); Error copying file to the directory: [{$dest_img_file}]");
            return false;
        }
        LOG_MSG('INFO', "upload_image(): New File: is [{$dest_img_file}]");
        return true;
    }
    LOG_MSG("INFO", "upload_image():END");
    return false;
}
Exemple #7
0
			<!-- CENTER CONTENT -->
			<div class="span-24 center-content">
					<?php 
show_msgs();
if (is_loggedin() && is_admin() || is_viewer()) {
    if (file_exists("modules/{$MOD}/{$ENTITY}/controller.php")) {
        include "modules/" . $MOD . "/" . $ENTITY . "/controller.php";
    }
} else {
    if (is_loggedin() && is_supervisor()) {
        include "modules/admin/vehicle/controller.php";
    } else {
        if (is_loggedin() && is_superuser()) {
            include "modules/admin/travel/controller.php";
        } else {
            add_msg('SUCCESS', "Welcome to {$DOMAIN}. Please login to start using your account");
            show_msgs();
        }
    }
}
?>
			</div>
			<!-- END CENTER CONTENT -->

			<!-- FOOTER -->
			<?php 
include "static/html/footer.html";
?>

		</div> 	<!-- END CONTAINER -->
Exemple #8
0
function has_user_permission($function, $mode = "")
{
    return true;
    $return = true;
    $user_id = get_arg($_SESSION, 'user_id');
    $user_permission_row = db_permission_select($user_id, $function, $mode);
    if ($user_permission_row[0]['STATUS'] != 'OK' || $user_permission_row[0]['NROWS'] != 1) {
        add_msg("ERROR", "Sorry! You do not have the permission to perform this action.<br />");
        $return = false;
    }
    LOG_MSG("INFO", "has_user_permission(): user_id=[{$user_id}] function=[{$function}] mode=[{$mode}] has_premission=[{$return}]");
    return $return;
}
Exemple #9
0
function app_sync($table_name, $primary_id, $status, $travel_id)
{
    LOG_MSG('INFO', "app_sync(): START");
    $ROW = db_appsync_insert($table_name, $primary_id, $status, $travel_id);
    if ($ROW['STATUS'] !== 'OK') {
        LOG_MSG('ERROR', "app_sync(): Error inserting app_sync or no row found");
        add_msg("ERROR", "There was an error adding to appsync");
        return false;
    }
    $supervisor_row = db_is_sync_supervisor_update(0);
    if ($ROW['STATUS'] != "OK") {
        add_msg("ERROR", "There was an error updating the supervisor .");
        return false;
    }
    LOG_MSG('INFO', "app_sync(): END");
    return true;
}
Exemple #10
0
 function go_page_view($mode = "EDIT")
 {
     global $ROW, $TEMPLATE;
     LOG_MSG('INFO', "go_page_view(): START mode=[{$mode}]");
     // Don't load for add mode or when reloading the form
     if ($mode != "ADD" && (!isset($ROW[0]) || get_arg($ROW[0], 'STATUS') !== 'RELOAD')) {
         // Get the Page ID
         $page_id = $this->data['id'];
         // Get from DB
         $ROW = $this->admin_model->db_page_select($page_id);
         if ($ROW[0]['STATUS'] != "OK") {
             add_msg("ERROR", "There was an error loading the Page. Please try again later. ");
             return;
         }
         // No rows found
         if ($ROW[0]['NROWS'] == 0) {
             add_msg("ERROR", "No Pages found! <br />Click on <strong>Add Page</strong> to create a one.");
             return;
         }
     }
     $disabled = "";
     // Setup display parameters
     switch ($mode) {
         case "ADD":
             $_do = "add";
             break;
         case "EDIT":
             $_do = "save";
             break;
         case "DELETE":
             $_do = "remove";
             $disabled = "disabled";
             break;
         case "VIEW":
         default:
             $disabled = "disabled";
             break;
     }
     $this->data['rows'] = $ROW;
     $this->load->view('admin/html/header', $this->data);
     $this->load->view('admin/html/topbar', $this->data);
     $this->load->view('admin/html/leftnav', $this->data);
     $this->load->view('admin/page/record', $this->data);
     $this->load->view('admin/html/footer', $this->data);
     LOG_MSG('INFO', "go_page_view(): END");
 }