|
| 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