forked from AfraHussaindeen/Tertiary-Care-Service-Unit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
52 lines (40 loc) · 1.86 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
define ("DS",DIRECTORY_SEPARATOR);
define ("ROOT",dirname(__FILE__)); // Give the location of the file.
//load configuration and helper functions
require_once(ROOT.DS.'config'.DS.'config.php');
require_once(ROOT.DS.'app'.DS.'lib'.DS.'helpers'.DS.'functions.php');
//Autoload classes
// Using this function the relevant php file is being acccessed.
function autoload($className){
if (file_exists(ROOT.DS.'core'.DS . $className . '.php')){
require_once(ROOT.DS.'core'.DS . $className . '.php');
}
elseif(file_exists(ROOT.DS.'app'.DS.'controllers'.DS. $className . '.php')){
require_once(ROOT.DS.'app'.DS.'controllers'.DS. $className . '.php');
}
elseif(file_exists(ROOT.DS.'app'.DS.'models'.DS. $className . '.php')){
require_once(ROOT.DS.'app'.DS.'models'.DS. $className . '.php');
}
}
//spl-standard php library
spl_autoload_register('autoload');
session_start();
//$_SERVER gives the part of the location except the root.
//die("message") and exit("message") => Output a message and terminate the script
//die and exit are alliases (Diferent name but same meaning).
//explode("character",$str,limit(optional)) => used to split a string into array with a specified character
//isset() => Check whether a variable is set or not
//require() => if file not found produce an error and stop the program
//include() => if file not found produce an error , but script will continue
//() ? : ; Similar to if else statements
//(condition) ? if yes exexute this : else execute this ;
$url =isset($_SERVER["PATH_INFO"]) ? explode ('/',ltrim($_SERVER['PATH_INFO'],'/')) : [];
//var_dump($name) => print the elements of the array
if(!Session::exists(CURRENT_USER_SESSION_NAME) && COOKIE::exists(REMEMBER_ME_COOKIE_NAME)){
Users::loginUserFromCookie();
}
//Route the Request.
//Router is the class
// route() is a defined method in the Router class .
Router:: route($url);