-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
43 lines (33 loc) · 935 Bytes
/
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
<?php
header("Content-Type: text/html; charset=utf-8");
require_once ('./includes/initialize.php');
function __autoload($class_name) {
if ($class_name != 'DbSimple_Mysqli' && $class_name != 'Smarty') {
require_once CLASS_PATH . '/class.' . $class_name . '.php';
}
}
if (request_is_post()) {
if ( isset($_POST['cancel'] )) {
redirect_to('index.php');
}
$ad = new Ad(AdsStorage::sanitizeFormData($_POST));
$ad->save();
redirect_to('index.php');
}
$edit_id = '';
if (isset($_GET['id']) && isset($_GET['mode'])) {
$id = (int) $_GET['id'];
$mode = strip_tags($_GET['mode']);
if ($mode == "show") {
$edit_id = $id;
} elseif ($mode == "delete") {
Ad::delete($id);
exit(); //AJAX. Output isn't needed
}
}
//could be chained methods -> -> ->
$storage = AdsStorage::getInstance();
$storage->fillStorage();
$storage->prepareFieldsOfAd($edit_id);
$storage->prepareTableOfAds();
$storage->display();