Skip to content

Commit a4a5806

Browse files
committed
Added Basic UI pages
A set of UI pages to perform basic actions
1 parent 6078241 commit a4a5806

10 files changed

+1180
-0
lines changed

pages/home.php

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
/*
4+
* The MIT License
5+
*
6+
* Copyright 2018 Ibrahim.
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
//first, load the root file
28+
require_once '../root.php';
29+
30+
//use this to show runtime errors
31+
Util::displayErrors();
32+
33+
//sets the translation
34+
PageAttributes::get()->loadTranslation(TRUE);
35+
36+
//load theme
37+
PageAttributes::get()->loadTheme();
38+
39+
$lang = LANGUAGE['pages']['home'];
40+
41+
PageAttributes::get()->setTitle($lang['title']);
42+
43+
PageAttributes::get()->setDescription($lang['description']);
44+
//end of page setup.
45+
46+
// check if user is logged in
47+
//if not, go to login page
48+
if(SessionManager::get()->validateToken() != TRUE){
49+
header('location: login');
50+
}
51+
?>
52+
<!DOCTYPE html>
53+
<html lang="<?php echo PageAttributes::get()->getLang()?>">
54+
<head>
55+
<?php echo staticHeadTag('home', PageAttributes::get()->getLang())?>
56+
</head>
57+
<body itemscope itemtype="http://schema.org/WebPage">
58+
<div class="pa-container">
59+
<div class="pa-row">
60+
<div class="pa-row">
61+
<?php echo staticAsideNav(PageAttributes::get()->getWritingDir(),1);?>
62+
<div id="pa-main-content" itemscope itemtype="http://schema.org/WebPageElement" itemprop="mainContentOfPage" dir="<?php echo PageAttributes::get()->getWritingDir()?>" class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-ten'?> show-border">
63+
<header id="header" itemscope itemtype="http://schema.org/WPHeader" class="pa-row">
64+
<h1 name="page-title" itemprop="name" id="page-title"><?php echo $lang['title']?></h1>
65+
</header>
66+
<div class="pa-row">
67+
Home Page
68+
</div>
69+
<?php echo staticFooter()?>
70+
</div>
71+
</div>
72+
</div>
73+
</div>
74+
</body>
75+
</html>
76+
77+

pages/login.php

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
/*
4+
* The MIT License
5+
*
6+
* Copyright 2018 Ibrahim.
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
//first, load the root file
28+
require_once '../root.php';
29+
30+
//use this to show runtime errors
31+
Util::displayErrors();
32+
33+
//sets the translation
34+
PageAttributes::get()->loadTranslation(TRUE);
35+
$pageLbls = LANGUAGE['pages']['login'];
36+
//load themem
37+
PageAttributes::get()->loadTheme();
38+
39+
//end of page setup.
40+
?>
41+
<!DOCTYPE html>
42+
<html lang = "<?php echo PageAttributes::get()->getLang()?>">
43+
<head>
44+
<?php echo staticHeadTag('login', PageAttributes::get()->getLang())?>
45+
<script type="text/javascript" src="res/js/js-ajax-helper-0.0.5/AJAX.js"></script>
46+
<script type="text/javascript" src="res/js/APIs.js"></script>
47+
<script type="text/javascript" src="res/js/langs/lANG_EN.js"></script>
48+
<link rel="stylesheet" href="res/css/login.css">
49+
<script type="text/javascript">
50+
function login(){
51+
document.getElementById('message').innerHTML = <?php echo '\''.LANGUAGE['general']['wait'].'\''?>;
52+
var username = document.getElementById('username-input').value;
53+
var password = document.getElementById('password-input').value;
54+
var params = 'action=login&username='+encodeURIComponent(username)+'&password='+password;
55+
var ajax = new AJAX();
56+
ajax.setURL(APIS.AuthAPI.link);
57+
ajax.setReqMethod('post');
58+
ajax.setParams(params);
59+
ajax.setOnSuccess(function(){
60+
console.log(this.response);
61+
document.getElementById('message').innerHTML = <?php echo '\''.$pageLbls['success'].'\''?>;
62+
var tok = this.jsonResponse['user']['token'];
63+
//exp after 30 min
64+
var date = new Date();
65+
date.setTime(currentTime + 1000*60*30);
66+
var currentTime = date.getTime();
67+
document.cookie = 'token='+tok+';expires ='+date.toUTCString();
68+
window.location.href = 'pages/home';
69+
});
70+
ajax.setOnClientError(function(){
71+
console.log(this.response);
72+
document.getElementById('message').innerHTML = <?php echo '\''.$pageLbls['errors']['incorrect-login-params'].'\''?>;
73+
});
74+
ajax.send();
75+
}
76+
</script>
77+
</head>
78+
<body itemscope itemtype="http://schema.org/WebPage">
79+
<div class="pa-container">
80+
<div class="pa-row">
81+
<div class="pa-row">
82+
<form dir="<?php echo PageAttributes::get()->getWritingDir()?>" onsubmit="login()" dir="rtl" method="POST" id="login_form" class="pa-row">
83+
<div style="margin-bottom: 18%;text-align: center;" class="pa-row">
84+
<!--<img id="login_logo" src="res/images/favicon.png" alt="Website Logo">-->
85+
<label style="font-weight: bold; display: block; margin:auto; text-align: center; width: 100%;"><?php echo $pageLbls['labels']['main']?></label>
86+
</div>
87+
<div class="pa-row" style="background-color: #2d8659">
88+
<label for="username"><?php echo $pageLbls['labels']['username']?></label><br/>
89+
<input id="username-input" spellcheck="off" form="login_form" required placeholder="<?php echo $pageLbls['placeholders']['username']?>" type="text" name="username"/>
90+
</div>
91+
<div class="pa-row" style="background-color: #2d8659">
92+
<label for="password"><?php echo $pageLbls['labels']['password']?></label><br/>
93+
<input autocomplete="off" id="password-input" spellcheck="off" form="login_form" required placeholder="<?php echo $pageLbls['placeholders']['password']?>" type="password" name="password"/>
94+
</div>
95+
<div class="pa-row" style="background-color: #2d8659">
96+
<label id="message"></label>
97+
</div>
98+
<div class="pa-row" style="background-color: #2d8659">
99+
<input id="login_button" value="<?php echo $pageLbls['actions']['login']?>" type="button" onclick="login()"/>
100+
<!--<button id="cancel_button"><?php //echo DISP_LANG_LOGIN['cancel-label']?></button>-->
101+
</div>
102+
</form>
103+
</div>
104+
</div>
105+
</div>
106+
</body>
107+
</html>
108+
109+
110+

pages/logout.php

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
require_once '../root.php';
3+
SessionManager::get()->kill();
4+
header('location: login');

pages/profile.php

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?php
2+
3+
/*
4+
* The MIT License
5+
*
6+
* Copyright 2018 Ibrahim.
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
//first, load the root file
28+
require_once '../root.php';
29+
30+
//use this to show runtime errors
31+
Util::displayErrors();
32+
33+
//sets the translation
34+
PageAttributes::get()->loadTranslation(TRUE);
35+
36+
//load theme
37+
PageAttributes::get()->loadTheme();
38+
39+
$lang = LANGUAGE['pages']['profile'];
40+
41+
PageAttributes::get()->setTitle($lang['title']);
42+
43+
PageAttributes::get()->setDescription($lang['description']);
44+
//end of page setup.
45+
46+
// check if user is logged in
47+
//if not, go to login page
48+
if(SessionManager::get()->validateToken() != TRUE){
49+
header('location: login');
50+
}
51+
52+
//check user type
53+
$userId = filter_input(INPUT_GET, 'user-id');
54+
55+
?>
56+
<!DOCTYPE html>
57+
<html lang="<?php echo PageAttributes::get()->getLang()?>">
58+
<head>
59+
<?php echo staticHeadTag('pages/profile', PageAttributes::get()->getLang())?>
60+
</head>
61+
<body itemscope itemtype="http://schema.org/WebPage">
62+
<div class="pa-container">
63+
<div class="pa-row">
64+
<div class="pa-row">
65+
<?php echo staticAsideNav(PageAttributes::get()->getWritingDir(),2);?>
66+
<div id="pa-main-content" itemscope itemtype="http://schema.org/WebPageElement" itemprop="mainContentOfPage" dir="<?php echo PageAttributes::get()->getWritingDir()?>" class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-ten'?> show-border">
67+
<header id="header" itemscope itemtype="http://schema.org/WPHeader" class="pa-row">
68+
<h1 name="page-title" itemprop="name" id="page-title"><?php echo $lang['title']?></h1>
69+
</header>
70+
<div class="pa-row">
71+
<?php
72+
if($userId != NULL && $userId != FALSE){
73+
if($userId != SessionManager::get()->getUser()->getID()){
74+
if(SessionManager::get()->getUser()->getAccessLevel() != 0){
75+
$profile = new User();
76+
$profile->setAccessLevel('<b style="color:red">NOT AUTHORIZED</b>');
77+
$profile->setDisplayName('<b style="color:red">NOT AUTHORIZED</b>');
78+
$profile->setEmail('<b style="color:red">NOT AUTHORIZED</b>');
79+
$profile->setStatus('<b style="color:red">NOT AUTHORIZED</b>');
80+
$profile->setActivationTok('<b style="color:red">NOT AUTHORIZED</b>');
81+
$profile->setUserName('<b style="color:red">NOT AUTHORIZED</b>');
82+
}
83+
else{
84+
$profile = UserFunctions::get()->getUserByID($userId);
85+
if($profile == UserFunctions::NO_SUCH_USER){
86+
$profile = new User();
87+
$profile->setAccessLevel(UserFunctions::NO_SUCH_USER);
88+
$profile->setDisplayName(UserFunctions::NO_SUCH_USER);
89+
$profile->setEmail(UserFunctions::NO_SUCH_USER);
90+
$profile->setStatus(UserFunctions::NO_SUCH_USER);
91+
$profile->setActivationTok(UserFunctions::NO_SUCH_USER);
92+
$profile->setUserName(UserFunctions::NO_SUCH_USER);
93+
}
94+
}
95+
}
96+
else{
97+
$profile = SessionManager::get()->getUser();
98+
}
99+
}
100+
else{
101+
header('location: home');
102+
}
103+
?>
104+
<div style="border: 1px solid" class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-twelve'?>">
105+
<p><b><?php echo $lang['labels']['actions']?></b></p>
106+
<ul>
107+
<li><a href="pages/update-pass?user-id=<?php echo $userId?>"><?php echo $lang['labels']['update-password']?></a></li>
108+
<li><a href="pages/update-email?user-id=<?php echo $userId?>"><?php echo $lang['labels']['update-email']?></a></li>
109+
<li><a href="pages/update-disp-name?user-id=<?php echo $userId?>"><?php echo $lang['labels']['update-disp-name']?></a></li>
110+
</ul>
111+
</div>
112+
<div class="pa-row">
113+
<div class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-twelve'?>">
114+
<p><b><?php echo $lang['labels']['username']?></b><?php echo $profile->getUserName()?></p>
115+
</div>
116+
<div class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-twelve'?>">
117+
<p><b><?php echo $lang['labels']['display-name']?></b><?php echo $profile->getDisplayName()?></p>
118+
</div>
119+
<div class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-twelve'?>">
120+
<p><b><?php echo $lang['labels']['email']?></b><?php echo $profile->getEmail()?></p>
121+
</div>
122+
<div class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-twelve'?>">
123+
<p><b><?php echo $lang['labels']['status']?></b><?php echo $profile->getStatus()?></p>
124+
</div>
125+
<div class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-twelve'?>">
126+
<p><b><?php echo $lang['labels']['reg-date']?></b><?php echo $profile->getRegDate()?></p>
127+
</div>
128+
<div class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-twelve'?>">
129+
<p><b><?php echo $lang['labels']['last-login']?></b><?php echo $profile->getLastLogin()?></p>
130+
</div>
131+
<div class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-twelve'?>">
132+
<p><b><?php echo $lang['labels']['access-level']?></b><?php echo $profile->getAccessLevel()?></p>
133+
</div>
134+
<div class="<?php echo 'pa-'.PageAttributes::get()->getWritingDir().'-col-twelve'?>">
135+
<p><b><?php echo $lang['labels']['activation-token']?></b><a href="pages/login?ac-tok=<?php echo $profile->getActivationTok()?>"><?php echo $profile->getActivationTok()?></a></p>
136+
</div>
137+
</div>
138+
</div>
139+
<?php echo staticFooter()?>
140+
</div>
141+
</div>
142+
</div>
143+
</div>
144+
</body>
145+
</html>
146+
147+

0 commit comments

Comments
 (0)