YaWK  24.1
Yet another WebKit
index.php
Go to the documentation of this file.
1 <?php
2 session_start();
3 header('Cache-control: private'); // OLD IE (6+) FIX
4 error_reporting(E_ALL ^ E_STRICT); // just for development purpose!!!
5 ini_set('display_errors', 1); // DISPLAY ALL ERRORS - DEVELOPMENT ONLY!!!
6 // error_reporting(0); // no error reporting
7 $loadingTime = microtime(true); // scripting start time (var gets used for benchmark, if enabled)
8 
9 /* include controller classes */
10 require_once '../system/classes/db.php'; // database
11 require_once '../system/classes/AdminLTE.php'; // admin LTE backend
12 require_once '../system/classes/alert.php'; // custom alert and info boxes
13 require_once '../system/classes/settings.php'; // (system) settings class
14 require_once '../system/classes/language.php'; // language class
15 require_once '../system/classes/backend.php'; // backend methods and helpers
16 require_once '../system/classes/dashboard.php'; // dashboard methods
17 require_once '../system/classes/user.php'; // user class: methods to add, edit, modify users
18 require_once '../system/classes/page.php'; // pages class: methods to add edit, modify pages
19 require_once '../system/classes/menu.php'; // menu class: methods to add, edit, display menus
20 require_once '../system/classes/email.php'; // simple email helper class
21 require_once '../system/classes/plugin.php'; // plugin class: methods to handle and interact w plugins
22 require_once '../system/classes/widget.php'; // widget class: methods to handle and interact w widgets
23 require_once '../system/classes/template.php'; // template class: methods to add, edit and handle templates
24 require_once '../system/classes/controller.php'; // basic controller class
25 require_once '../system/classes/filemanager.php'; // filemanager class: methods to add, edit, upload and handle files
26 require_once '../system/classes/sys.php'; // system class: methods and helpers for overall system use
27 // PREPARE OBJECTS
28 // database object
29 if (!isset($db))
30 { // create new db obj if none exists
31  $db = new \YAWK\db();
32 }
33 // language object
34 if (!isset($lang) || (empty($lang)))
35 { // create new language obj if none exists
36  $language = new YAWK\language();
37  // init language
38  $language->init($db, "backend");
39  // convert object param to array !important
40  $lang = (array) $language->lang;
41 }
42 
43 // user object
44 if (!isset($user))
45 { // create new user obj if none exists
46  $user = new \YAWK\user($db);
47 }
48 
49 // page object
50 if (!isset($page))
51 { // create new page obj if none exists
52  $page = new \YAWK\page();
53 }
54 
55 // Admin LTE Backend
56 if (!isset($AdminLTE))
57 {
58  // create AdminLTE object
59  $AdminLTE = new \YAWK\BACKEND\AdminLTE($db);
60  // html head (html start, js includes asf...)
61  echo $AdminLTE->drawHtmlHead();
62 
63  // check if the current user is logged in
64  \YAWK\backend::checkLogin($db);
65 
66  // only show this, if session login is set and true
67  if (isset($_SESSION['logged_in']) && ($_SESSION['logged_in'] === true))
68  {
69  // check if username, session and user id are set
70  if (isset($_SESSION['username']) && (isset($_SESSION['gid']) && (isset($_SESSION['uid']))))
71  {
72  // get user properties
73  $user->loadProperties($db, $_SESSION['username']);
74 
75  // draw AdminLTE Template from top to bottom
76  // body markup
77  echo $AdminLTE->drawHtmlBody();
78  // logo markup
79  echo $AdminLTE->drawHtmlLogo($db, $lang);
80  // navbar start
81  echo $AdminLTE->drawHtmlNavbar();
82  // navbar right menu start
83  echo $AdminLTE->drawHtmlNavbarRightMenu();
84 
85  // navbar: draw preview icon
86  echo $AdminLTE->drawHtmlNavbarBackupIcon($lang);
87 
88  // navbar: draw preview icon
89  echo $AdminLTE->drawHtmlNavbarPreviewIcon($lang);
90 
91  // check if messaging is enabled
92  if (\YAWK\settings::getSetting($db, "backendMessagesMenu") == 1)
93  { // ok, draw msg icon and message navbar in upper right corner
94  echo $AdminLTE->drawHtmlNavbarMessagesMenu($db, $lang);
95  }
96 
97  // check if webmail is enabled
98  if (\YAWK\settings::getSetting($db, "webmail_active") == 1)
99  { // ok, draw msg icon and message navbar in upper right corner
100  echo $AdminLTE->drawHtmlNavbarWebmailMenu($db, $lang);
101  }
102 
103  // check, if backend notification is enabled
104  if (\YAWK\settings::getSetting($db, "backendNotificationMenu") == 1)
105  { // draw notification menu, in upper right corner
106  echo $AdminLTE->drawHtmlNavbarNotificationsMenu($db, $user, $lang);
107  }
108 
109  // user account menu
110  echo $AdminLTE->drawHtmlNavbarUserAccountMenu($db, $user);
111  // end navbar header
112  echo $AdminLTE->drawHtmlNavbarHeaderEnd();
113  // left sidebar (main menu)
114  echo $AdminLTE->drawHtmlLeftSidebar($db, $user, $lang);
115  // content header
116  echo $AdminLTE->drawHtmlContentHeader($lang);
117  // content breadcrumbs
118  echo $AdminLTE->drawHtmlContentBreadcrumbs();
119  // html content (main page)
120  echo $AdminLTE->drawHtmlContent($db, $lang, $user);
121 
122  // check, if footer should be displayed
123  if (\YAWK\settings::getSetting($db, "backendFooter") == 1)
124  { // draw footer at bottom of page
125  echo $AdminLTE->drawHtmlFooter($db);
126  }
127 
128  // right sidebar
129  echo $AdminLTE->drawHtmlRightSidebar($lang);
130  // additional js includes at the bottom
131  echo $AdminLTE->drawHtmlJSIncludes();
132  // html end
133  echo $AdminLTE->drawHtmlEnd($db);
134  }
135  else
136  {
137  // session username, gid and / or user is is not set - throw alert and draw login box
138  \YAWK\alert::draw("warning", "Warning :", "It seems that you are not logged in correctly. Please try to re-login!","","8000");
139  }
140  }
141  else
142  {
143  // user is not logged in - set a basic body markup and display login box
144  // body markup
145  echo "<body style=\"background-color: #ecf0f5\">";
146 
147  // reset password email request
148  if (isset($_POST['resetPasswordRequest']) && ($_POST['resetPasswordRequest'] == "true"))
149  { // send reset email
150  if ($user::sendResetEmail($db, $_POST['username'], $_POST['email'], $lang) == true)
151  { // email sent
152  \YAWK\alert::draw("success", "$lang[EMAIL_SENT]", "$lang[PLEASE_CHECK_YOUR_INBOX]", "", 2400);
153  }
154  else
155  { // error: sending reset email failed
156  \YAWK\alert::draw("danger", $lang['ERROR'], $lang['PASSWORD_RESET_FAILED'], "", 3800);
157  }
158  }
159 
160  // reset password requested
161  if (isset($_GET['resetPassword']) && (!empty($_GET['resetPassword']) && ($_GET['resetPassword'] === true)))
162  {
163  // check if reset token is set
164  if (isset($_GET['token']) && (!empty($_GET['token']) && (is_string($_GET['token']))))
165  {
166  // check if sent token is equal to saved token
167  if ($user::checkResetToken($db, $_GET['token']) === true)
168  {
169  // draw reset password form
170  echo $_GET['token'];
171  // echo \YAWK\backend::drawPasswordResetForm($db, $lang);
172  // end section markup
173  echo "<br><br></section></div>";
174  // output js includes at bottom of page
175  echo $AdminLTE->drawHtmlJSIncludes();
176  // html output end
177  echo $AdminLTE->drawHtmlEnd($db);
178  exit;
179  }
180  else
181  { // ERROR: token does not match with database - throw error
182  \YAWK\alert::draw("danger", $lang['ERROR'], $lang['PASSWORD_RESET_TOKEN_INVALID'], "", 3800);
183  }
184  }
185  }
186 
187  // draw login box
188  echo \YAWK\backend::drawLoginBox($db, $lang);
189  // end section markup
190  echo "<br><br></section></div>";
191 
192  // output js includes at bottom of page
193  echo $AdminLTE->drawHtmlJSIncludes();
194 
195  // html output end
196  echo $AdminLTE->drawHtmlEnd($db);
197  exit;
198  }
199 }
200 /* END /admin index controller */
print $lang['FILEMAN_UPLOAD']
$loadingTime
Definition: index.php:12
static draw($type, $title, $text, $redirect, $delay)
Definition: alert.php:30
The language class - support multilingual backend.
Definition: language.php:17
exit
This class serves methods to create backup from files.
Definition: AdminLTE.php:2
print $_GET['id']
Definition: page-edit.php:357
$page
Definition: pages.php:355