Advertisement
Crecket

Untitled

Apr 2nd, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.80 KB | None | 0 0
  1. <?php      
  2.     try {
  3.         $conn = new PDO("mysql:host=$servername:3307;dbname=$dbname", $username, $password);
  4.         $conn->setAttribute(PDO::ATTR_ERRMODE,  PDO::ERRMODE_EXCEPTION);
  5.     }catch(PDOException $e){
  6.     }
  7.    
  8.     if (!Isset($_SESSION['crecketgaming_usergroup'])){
  9.         $_SESSION['crecketgaming_usergroup'] = "Guest";
  10.     }
  11.    
  12.     if (Isset($_SESSION['crecketgaming_username'])){
  13.         $usernametest = $_SESSION['crecketgaming_username'];
  14.         $sql2 = "SELECT Usergroup, user_ID FROM users WHERE Username = :username";
  15.         $sth = $conn->prepare($sql2);
  16.         $sth->bindParam(':username', $usernametest, PDO::PARAM_STR);
  17.         $sth->execute();
  18.         $rowcount = $sth->rowCount();
  19.         $row = $sth->fetch();      
  20.  
  21.         if ($rowcount > 0) {
  22.             $_SESSION['crecketgaming_usergroup'] = $row['Usergroup'];
  23.             $_SESSION['crecketgaming_userid'] = $row['user_ID'];
  24.         }
  25.         //if the user is logged in it will show the username + usergroup
  26.         $_SESSION['crecketgaming_loginmessage'] = "
  27.             <form class='s-12 l-12 shadow profbox' method='post' action='logout.php' >
  28.                 <div class='line'>
  29.                     <div class='margin-bottom'>
  30.                         <div  align='center' class='s-12 l-12'>
  31.                             <a>You're currently logged in as: <br><strong>" . $_SESSION['crecketgaming_username'] . "</strong> " . $_SESSION['crecketgaming_usergroup'] . "  </a>
  32.                             <br>
  33.                         </div>
  34.                     </div>
  35.                 </div>
  36.             </form>
  37.         ";
  38.         //if the usergroup is set to admin the menu will show a extra submenu with links to admin pages
  39.         if($_SESSION['crecketgaming_usergroup'] == "Admin"){
  40.             $_SESSION['crecketgaming_menuadmin'] = '   
  41.                 <li>
  42.                     <a>Adminpanel</a>
  43.                     <ul>
  44.                         <li><a href="/phpadmin/adminpanel">Main panel</a></li>
  45.                         <li><a href="/phpadmin/checkusers">Users</a></li>
  46.                         <li><a href="/phpadmin/checkreloads">Page loads</a></li>
  47.                         <li><a href="/phpadmin/checklocked">Locked accounts</a></li>
  48.                         <li><a href="/phpadmin/checksessions">Sessions</a></li>
  49.                         <li><a href="/phpadmin/checkfailed">Failed logins</a></li>
  50.                         <li><a href="/phpadmin/checkactivation">Activate accounts</a></li>
  51.                         <li><a href="/blogpost">New blog post</a></li>
  52.                     </ul>
  53.                 </li>
  54.                 ';
  55.         }else{
  56.             $_SESSION['crecketgaming_menuadmin'] = '';
  57.         }
  58.         //displays a icon which links to the profile page
  59.         $_SESSION['crecketgaming_profileicon'] = 'class="icon-user_male icon2x right padding"';
  60.         //if the user is logged in a link to the profile and logout page is shown
  61.         $_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>';
  62.         //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
  63.         $_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>";
  64.     }elseif (!Isset($_SESSION['crecketgaming_username']) || $_SESSION['crecketgaming_username'] = "" ) {
  65.         $_SESSION['crecketgaming_webshopmessage'] = "<li><a href='index.php'>Market</a></li>";
  66.         //if the user is not logged in this is shown at the top right of the page in the header
  67.         $_SESSION['crecketgaming_loginmessage'] = "
  68.         <a href='login.php'>
  69.             <div class='s-12 l-12 shadow profbox'>
  70.                 <div class='line'>
  71.                     <div class='margin-bottom'>
  72.                         <p align='center'>You are currently not logged in.</p>
  73.                     </div>
  74.                 </div>
  75.             </div>
  76.         </a>
  77.         ";
  78.         $_SESSION['crecketgaming_profileicon'] = "";
  79.         $_SESSION['crecketgaming_menuadmin'] = "";
  80.         $_SESSION['crecketgaming_menuaccount'] =  '<li><a>Account</a><ul><li><a href="/login">Login</a></li> <li><a href="/register">Register</a></li></ul></li>';
  81.         $_SESSION['crecketgaming_usergroup'] = "Guest";
  82.         $_SESSION['crecketgaming_userid'] = "";
  83.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement