File: fwphp/01mater/shop/ch24_guitar_shop/util/main.php

Recommend this page to a friend!
  Classes of Slavko Srakocic  >  B12 PHP FW  >  fwphp/01mater/shop/ch24_guitar_shop/util/main.php  >  Download  
File: fwphp/01mater/shop/ch24_guitar_shop/util/main.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change:
Date: 1 month ago
Size: 1,011 bytes
 

Contents

Class file image Download
<?php
// Get the document root
$doc_root = filter_input(INPUT_SERVER, 'DOCUMENT_ROOT', FILTER_SANITIZE_STRING);

// Get the application path http://dev1:8083/fwphp/01mater/shop/ch24_guitar_shop/account
$uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING);
$dirs = explode('/', $uri);
$app_path = '/' . $dirs[1] . '/' . $dirs[2] . '/'
  
. basename(dirname(dirname(__DIR__))) . '/' . basename(dirname(__DIR__)) . '/'
;

// Set the include path
set_include_path($doc_root . $app_path);

// Get common code
require_once('util/tags.php');
require_once(
'model/database.php');

// Define some common functions
function display_db_error($error_message) {
    global
$app_path;
    include
'errors/db_error.php';
    exit;
}

function
display_error($error_message) {
    global
$app_path;
    include
'errors/error.php';
    exit;
}

function
redirect($url) {
   
session_write_close();
   
header("Location: " . $url);
    exit;
}

// Start session to store user and cart data
session_start();
?>

For more information send a message to info at phpclasses dot org.