-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfront-controller.php
More file actions
117 lines (102 loc) · 5.92 KB
/
front-controller.php
File metadata and controls
117 lines (102 loc) · 5.92 KB
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
<?php
ob_start();
session_start();
$q = $_GET['q'];
$isLanding = !preg_match('#^app|^landlord|^admin#', $q);
$isApp = preg_match('#^app#', $q);
$isAppIndex = preg_match('#^app/?$#', $q);
$isResendValidationEmail = preg_match('#^app\/resend-validation-email/?$#', $q);
$isVerifyAccount = preg_match('#^app\/verify-account/?$#', $q);
$isResetPassword = preg_match('#^app\/reset-password/?$#', $q);
$isProfile = preg_match('#^app\/profile/?$#', $q);
$isProperties = preg_match('#^app\/properties/?$#', $q);
$isActivity = preg_match('#^app\/activity/?$#', $q);
$isProperty = preg_match('#^app\/property\/\d+/?$#', $q);
$isGallery = preg_match('#^app\/property\/\d+/gallery/?$#', $q);
$isInstall = preg_match('#^app\/install/?$#', $q);
$isAbout = preg_match('#^app\/about/?$#', $q);
$isPrivacy = preg_match('#^app\/privacy-policy/?$#', $q);
$isLogout = preg_match('#^app\/logout/?$#', $q);
$isLandlord = preg_match('#^landlord#', $q);
$isLandlordIndex = preg_match('#^landlord/?$#', $q);
$isLandlordResendValidationEmail = preg_match('#^landlord\/resend-validation-email/?$#', $q);
$isLandlordVerifyAccount = preg_match('#^landlord\/verify-account/?$#', $q);
$isLandlordResetPassword = preg_match('#^landlord\/reset-password/?$#', $q);
$isLandlordActivity = preg_match('#^landlord\/activity/?$#', $q);
$isLandlordAllProperties = preg_match('#^landlord\/all-properties/?$#', $q);
$isLandlordNewProperty = preg_match('#^landlord\/new-property/?$#', $q);
$isLandlordPayment = preg_match('#^landlord\/payment/?$#', $q);
$isLandlordUpdateRoomAvailability = preg_match('#^landlord\/update-room-availability/?$#', $q);
$isLandlordRemoveProperty = preg_match('#^landlord\/remove-property/?$#', $q);
$isAdmin = preg_match('#^admin#', $q);
$isAdminIndex = preg_match('#^admin/?$#', $q);
$isAdminActivity = preg_match('#^admin\/activity/?$#', $q);
$isAdminAllProperties = preg_match('#^admin\/all-properties/?$#', $q);
$isAdminNewProperty = preg_match('#^admin\/new-property/?$#', $q);
$isAdminUpdateRoomAvailability = preg_match('#^admin\/update-room-availability/?$#', $q);
$isAdminDeleteProperty = preg_match('#^admin\/delete-property/?$#', $q);
$path = preg_replace('/\/$|.php/', '', $q);
if($isLanding) {
if(empty($path)) { // HOME
$file = 'index';
} elseif(file_exists("views/$path.php")) {
$file = $path; // LANDING SITE
} elseif($path === 'app') {
header('location: /app/'); // REDIRECT TO APP
} else {
$file = '404'; // LANDING SITE 404 NOT FOUND
}
}
if($isApp) {
if($isAppIndex) {
$file = 'app/index'; // APP HOME
} elseif($isResendValidationEmail || $isVerifyAccount || $isResetPassword || $isPrivacy) {
$file = $path; // ALLOW WITHOUT LOGGING IN
} elseif(!isset($_SESSION['s_userId'])) {
header('location: /app/'); // NOT LOGGED IN
} elseif(file_exists("views/$path.php")) {
$file = $path; // APP
} else {
$file = 'app/404'; // APP 404 NOT FOUND
}
}
if($isLandlord) {
if($isLandlordIndex) {
$file = 'landlord/index';
} elseif($isLandlordResendValidationEmail || $isLandlordVerifyAccount || $isLandlordResetPassword) {
$file = $path; // ALLOW WITHOUT LOGGING IN
} else {
if(!isset($_SESSION['s_landlordId'])) {
header("location: /landlord?r=" . urlencode(str_replace('/landlord/', '', $_SERVER['REQUEST_URI'])));
} else {
$file = $path; // LANDLORD PAGE
}
}
}
if($isAdmin) {
if($isAdminIndex) {
$file = 'admin/index';
} else {
if(!isset($_SESSION['s_admin'])) {
header("location: /admin?r=" . urlencode(str_replace('/admin/', '', $_SERVER['REQUEST_URI'])));
} else {
$file = $path; // ADMIN PAGE
}
}
}
if($isAppIndex) { require_once('models/model-index.php'); }
if($isProfile) { require_once('models/model-profile.php'); }
if($isProperties) { require_once('models/model-properties.php'); }
if($isActivity) { require_once('models/model-activity.php'); }
if($isProperty) { require_once('models/model-property.php'); }
if($isGallery) { require_once('models/model-gallery.php'); }
if($isLandlordActivity) { require_once('models/model-landlord-activity.php'); }
if($isLandlordAllProperties) { require_once('models/model-landlord-all-properties.php'); }
if($isLandlordNewProperty) { require_once('models/model-landlord-new-property.php'); }
if($isLandlordPayment) { require_once('models/model-landlord-payment.php'); }
if($isLandlordUpdateRoomAvailability) { require_once('models/model-landlord-update-room-availability.php'); }
if($isAdminActivity) { require_once('models/model-admin-activity.php'); }
if($isAdminAllProperties) { require_once('models/model-admin-all-properties.php'); }
if($isAdminUpdateRoomAvailability) { require_once('models/model-admin-update-room-availability.php'); }
if($isAdminDeleteProperty) { require_once('models/model-admin-delete-property.php'); }
require_once('front-view.php');