Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- try {
- $conn = new PDO("mysql:host=$servername:3307;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }catch(PDOException $e){
- }
- if (!Isset($_SESSION['crecketgaming_usergroup'])){
- $_SESSION['crecketgaming_usergroup'] = "Guest";
- }
- if (Isset($_SESSION['crecketgaming_username'])){
- $usernametest = $_SESSION['crecketgaming_username'];
- $sql2 = "SELECT Usergroup, user_ID FROM users WHERE Username = :username";
- $sth = $conn->prepare($sql2);
- $sth->bindParam(':username', $usernametest, PDO::PARAM_STR);
- $sth->execute();
- $rowcount = $sth->rowCount();
- $row = $sth->fetch();
- if ($rowcount > 0) {
- $_SESSION['crecketgaming_usergroup'] = $row['Usergroup'];
- $_SESSION['crecketgaming_userid'] = $row['user_ID'];
- }
- //if the user is logged in it will show the username + usergroup
- $_SESSION['crecketgaming_loginmessage'] = "
- <form class='s-12 l-12 shadow profbox' method='post' action='logout.php' >
- <div class='line'>
- <div class='margin-bottom'>
- <div align='center' class='s-12 l-12'>
- <a>You're currently logged in as: <br><strong>" . $_SESSION['crecketgaming_username'] . "</strong> " . $_SESSION['crecketgaming_usergroup'] . " </a>
- <br>
- </div>
- </div>
- </div>
- </form>
- ";
- //if the usergroup is set to admin the menu will show a extra submenu with links to admin pages
- if($_SESSION['crecketgaming_usergroup'] == "Admin"){
- $_SESSION['crecketgaming_menuadmin'] = '
- <li>
- <a>Adminpanel</a>
- <ul>
- <li><a href="/phpadmin/adminpanel">Main panel</a></li>
- <li><a href="/phpadmin/checkusers">Users</a></li>
- <li><a href="/phpadmin/checkreloads">Page loads</a></li>
- <li><a href="/phpadmin/checklocked">Locked accounts</a></li>
- <li><a href="/phpadmin/checksessions">Sessions</a></li>
- <li><a href="/phpadmin/checkfailed">Failed logins</a></li>
- <li><a href="/phpadmin/checkactivation">Activate accounts</a></li>
- <li><a href="/blogpost">New blog post</a></li>
- </ul>
- </li>
- ';
- }else{
- $_SESSION['crecketgaming_menuadmin'] = '';
- }
- //displays a icon which links to the profile page
- $_SESSION['crecketgaming_profileicon'] = 'class="icon-user_male icon2x right padding"';
- //if the user is logged in a link to the profile and logout page is shown
- $_SESSION['crecketgaming_menuaccount'] = '<li><a>Account</a><ul><li><a href="/profile">My profile</a></li><li><a href="/logout">Logout</a></li></ul></li>';
- //on the webshop if the user is not logged in it will only show a link to the main page, else it will add 2 extra links
- $_SESSION['crecketgaming_webshopmessage'] = "<li><a>Market</a><ul><li><a href='index.php'>Market</a></li><li><a href='profile?userid=" . $_SESSION['crecketgaming_userid'] . "'>My profile</a></li><li><a href='newsale'>New/Change sale</a></li></ul></li>";
- }elseif (!Isset($_SESSION['crecketgaming_username']) || $_SESSION['crecketgaming_username'] = "" ) {
- $_SESSION['crecketgaming_webshopmessage'] = "<li><a href='index.php'>Market</a></li>";
- //if the user is not logged in this is shown at the top right of the page in the header
- $_SESSION['crecketgaming_loginmessage'] = "
- <a href='login.php'>
- <div class='s-12 l-12 shadow profbox'>
- <div class='line'>
- <div class='margin-bottom'>
- <p align='center'>You are currently not logged in.</p>
- </div>
- </div>
- </div>
- </a>
- ";
- $_SESSION['crecketgaming_profileicon'] = "";
- $_SESSION['crecketgaming_menuadmin'] = "";
- $_SESSION['crecketgaming_menuaccount'] = '<li><a>Account</a><ul><li><a href="/login">Login</a></li> <li><a href="/register">Register</a></li></ul></li>';
- $_SESSION['crecketgaming_usergroup'] = "Guest";
- $_SESSION['crecketgaming_userid'] = "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement