-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
132 lines (127 loc) · 3.38 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
session_start();
require_once "app/config/autoload.php";
require_once "app/config/db.php";
use App\Controllers\ColorController;
use App\Controllers\UserController;
use App\Controllers\LoginController;
use App\Controllers\BrandController;
use App\Controllers\CategoryController;
use App\Controllers\ProductController;
use App\Controllers\CartController;
use App\Controllers\ViewController;
$url = $_SERVER['REQUEST_URI'];
$url = str_replace("/php2sajt1", "", $url);
$url = str_replace("/index.php", "/", $url);
//var_dump($url);
$ss = explode("/", $url);
$route_id = 0;
if(count($ss) >= 3){
$route_id = intval($ss[count($ss)-1]);
if($route_id){
$pozicija_kose_crte = strrpos($url, '/', 1);
$url = substr($url, 0, $pozicija_kose_crte);
}
}
switch($url){
case "/colors" :
$boje = new ColorController();
$boje->getAll();
break;
case "/register" :
$user = new UserController();
$user->register($_POST);
break;
case "/users" :
$users = new UserController();
$users->getAll();
break;
case "/user" :
$users = new UserController();
$users->getOne($route_id);
break;
case "/edituser" :
$users = new UserController();
$users->editUser($_POST);
break;
case "/login" :
$login = new LoginController();
$login->login($_POST);
break;
case "/logout" :
$logout = new LoginController();
$logout->logout();
break;
case "/brands" :
$brands = new BrandController();
$brands->getAll();
break;
case "/products" :
$products = new ProductController();
$products->getAll($_POST);
break;
case "/insertproduct" :
$products = new ProductController();
$products->insertProduct($_POST, $_FILES);
break;
case "/editproduct" :
$products = new ProductController();
$products->editProduct($_POST, $_FILES);
break;
case "/deleteproduct" :
$products = new ProductController();
$products->deleteProduct($_POST);
break;
case "/proizvod" :
$product = new ProductController();
$product->getOne($route_id);
break;
case "/categories" :
$categories = new CategoryController();
$categories->getAll();
break;
case "/addtocart" :
$cart = new CartController();
$cart->addToCart($_POST);
break;
case "/insertcategory" :
$cart = new CategoryController();
$cart->insert($_POST);
break;
case "/insertbrand" :
$cart = new BrandController();
$cart->insert($_POST);
break;
case "/product" :
$view = new ViewController();
$view->product($route_id);
break;
case "/cart" :
$view = new ViewController();
$view->cart();
break;
case "/contact" :
$view = new ViewController();
$view->contact();
break;
case "/author" :
$view = new ViewController();
$view->author();
break;
case "/pageregister" :
$view = new ViewController();
$view->register();
break;
case "/pagelogin" :
$view = new ViewController();
$view->login();
break;
case "/adminpanel" :
$view = new ViewController();
$view->adminpanel();
break;
default :
$view = new ViewController();
$view->home();
break;
}