protected function side_menu() { //Check if the user can see this if (!(AuthenticationUtil::is_logged_in() && AuthenticationUtil::check_privilege($this->user, AuthenticationUtil::PRIVILEGE_VIEW_ADMIN_PAGE))) { return; } $menu = new AdminMenu(); echo $menu; }
protected function body() { AuthenticationUtil::logout(); ?> <div class="main-wrapper"> <div class="login-wrapper"> <h3>You are now logged out.</h3> </div> </div> <?php }
private function add_user() { $user = new \stdClass(); $user->userName = param('txtName'); $user->emailAddress = param('txtEmail'); $user->company = param('txtCompany'); $user->salt = AuthenticationUtil::salt(); $user->password = AuthenticationUtil::hash(param('txtPassword'), $user->salt); $user->privs = array_sum(param('cbxPrivs')); //Make connection if (!($dbConnection = DatabaseUtil::db_connect(DatabaseUtil::DATABASE_USER))) { return 'Error with database connection. Contact DB admin. '; } if (!($error = DatabaseUtil::insert($dbConnection, 'users', $user))) { return 'User Added'; } else { return $error; } }
/** * Renders the Page with the Template */ private function render_html_template() { ?> <!DOCTYPE HTML> <html> <head> <!-- meta data--> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!-- CSS--> <link rel="stylesheet" type="text/css" href="/stylesheets/base.css"> <?php $this->render_css(); ?> <!-- JS--> <script src="/javascript/jquery-2.1.3.min.js"></script> <?php $this->render_js(); ?> <title><?php echo $this->title; ?> </title> </head> <body> <header> <div class="template-header-wrapper"> <div class="template-logo-wrapper"> <a href="<?php echo 'http://' . $_SERVER['SERVER_NAME']; ?> "><img src="/images/QdinkaFull25.png" /></a> </div> <div class="template-search-bar-wrapper"> <form action="" method="post"> <input type="text" name="txtSearch" placeholder="Search <?php echo $this->title; ?> ..."/> <input type="image" name="btnSubmit" src="/images/icons/search.png" /> </form> </div> <div class="template-header-menu"> <ul> <li class="template-header-menu-right"><a href="/index.php"><img class="template-header-menu-right" src="/images/icons/Shopping-Cart.png" alt="shopping cart" title="Shopping Cart"/></a></li> <?php //Print the admin page if they have access to it if (!is_null($this->user) && AuthenticationUtil::check_privilege($this->user, AuthenticationUtil::PRIVILEGE_VIEW_ADMIN_PAGE)) { echo '<li class="template-header-menu-right"><a href="/pages/admin/admin.php"> | Admin</a></li>'; } //Print the merchant page if they have access to it. if (!is_null($this->user) && AuthenticationUtil::check_privilege($this->user, AuthenticationUtil::PRIVILEGE_VIEW_MERCHANT_PAGE)) { echo '<li class="template-header-menu-right"><a href="/index.php"> | Sell</a></li>'; } //Check to see if the person is logged in an display the correct link if (AuthenticationUtil::is_logged_in()) { echo '<li><a href="/pages/users/logout.php"> | Logout</a></li>'; } else { echo '<li><a href="/pages/users/login.php"> | Login</a></li>'; } ?> </ul> </div> </div> </header> <section> <div class="template-wrapper"> <div class="template-side-menu-wrapper"> <?php $this->side_bar(); ?> </div> <div class="template-content-wrapper"> <?php $this->body(); ?> </div> </div> </section> <footer> <div class="template-footer-wrapper"> <div class="template-footer-menu-wrapper"> <div class="menu-item"><a href="#">About Qdinka</a></div> <div class="menu-item"><a href="#">Community</a></div> <div class="menu-item"><a href="#">Seller Information Center</a></div> <div class="menu-item"><a href="#">Policies</a></div> <div class="menu-item"><a href="#">Affiliates and Partners</a></div> <div class="menu-item"><a href="#">Help/Contact</a></div> <br> <hr /> </div> <div class="template-footer-content-wrapper"> <div class="footer-image-wrapper"> <a href="<?php echo 'http://' . $_SERVER['SERVER_NAME']; ?> "><img class="footer-image" src="/images/QdinkaFull25.png" /> </a> </div> <div class="footer-content"> A Note from the founders:<br /> Created in order to bring a balance to the Online Marketplace industry, we want our users to actually enjoy selling on the internet, and not have to worry about hundreds of hidden fees, unnavigable seller profiles, and unreliable customer service. Our users are guaranteed a more than satisfactory experience with the most comprehensive seller platform available; post products, track sales, integrate QuickBooks, market and promote your business and products. </div> <div class="footer-social-wrapper"> <img class="social-image" src="/images/social_media/facebook-icon.png" /> <img class="social-image" src="/images/social_media/twitter-icon.png" /> <img class="social-image" src="/images/social_media/google-icon.png" /> </div> </div> </div> </footer> </body> </html> <?php }
private function post() { //Check to see what button was pressed if (param('btnLogin')) { //Check to make sure that everything is filled out if (param('txtEmail') && param('txtPassword')) { $result = AuthenticationUtil::login(param('txtEmail'), param('txtPassword')); //Check to see if the login succeeded if ($result) { return '<h3>Login Failed: ' . $result . '</h3>'; } else { header('Location: /index.php'); exit; } } else { return '<h3>Login Failed: Missing fields.</h3>'; } } elseif (param('btnRegister')) { header('Location: /pages/users/login.php?page=register'); } return false; }