Advertisement
cafreak

PHP Navigation Bar with array

Apr 20th, 2014
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.00 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. include_once('config.php');
  6. include_once('functions.php');
  7.  
  8.  
  9. //The link names (=> "LINK NAME") MUST BE UNIQUE (unless you use multiple references with the same output!)!\\
  10. //place acp links in nav_acp and normal links in $nav_normal!\\
  11. //To add links through a variable save it in the config.php\\
  12. //The navigation bar will also be shown as the following order of these array(s)\\
  13. $nav_normal = array(
  14.     $locationHome => "Home",
  15.     $locationSubscribe => "(Un)Subscribe",
  16.     $locationAbout => "About Us",
  17.     $locationLogin => "Login"
  18.     );
  19.    
  20.  
  21. $nav_acp = array(
  22.     $acpSetting => "Settings",
  23.     $acpStyle => "Style",
  24.     $acpEmailList => "Email List",
  25.     $acpSendMail => "Send Email",
  26.     $acpOperators => "Operators",
  27.     $acpLogout => "Logout"
  28. );
  29.  
  30. $last_normal = array_pop(array_keys($nav_normal));
  31. $last_acp = array_pop(array_keys($nav_acp));
  32.  
  33. foreach($nav_normal as $link => $name){
  34.  
  35.     if($name == "Login"){
  36.         if(isset($_SESSION['username']) && isset($_SESSION['password']) && isset($_SESSION['salt']) && isset($_SESSION['vsalt']) && isset($_SESSION['hashed'])){
  37.             $username = $_SESSION['username'];
  38.             $password = $_SESSION['password'];
  39.             $saltkey = $_SESSION['salt'];
  40.             $vsaltkey = $_SESSION['vsalt'];
  41.             $getHashedPassWord = $_SESSION['hashed'];
  42.             $hashedpass = hashing($password, $saltkey, $vsaltkey);
  43.             if($hashedpass == $getHashedPassWord){
  44.                 continue;
  45.             }else{
  46.                 header('location: '.$instalLocation.'/acp/index.php');
  47.                 echo('Error User Timed Out! 2');
  48.             }
  49.         }
  50.     }
  51.  
  52.     if($Nav_ID == $name){
  53.         ?><li class="Selected"><a href="<?php echo($link); ?>" class="menu"><?php echo($name); ?></a></li><?php
  54.         if($link != $last_normal){
  55.             echo("\n                    ");
  56.         }else{
  57.             echo("\n");
  58.         }
  59.     }else{
  60.         ?><li class="Unselected"><a href="<?php echo($link); ?>" class="menu"><?php echo($name); ?></a></li><?php
  61.         if($link != $last_normal){
  62.             echo("\n                    ");
  63.         }else{
  64.             echo("\n");
  65.         }
  66.     }
  67. }  
  68. ?></ul>
  69. <?php
  70. if(isset($_SESSION['username']) && isset($_SESSION['password']) && isset($_SESSION['salt']) && isset($_SESSION['vsalt']) && isset($_SESSION['hashed'])){
  71.     $username = $_SESSION['username'];
  72.     $password = $_SESSION['password'];
  73.     $saltkey = $_SESSION['salt'];
  74.     $vsaltkey = $_SESSION['vsalt'];
  75.     $getHashedPassWord = $_SESSION['hashed'];
  76.     $hashedpass = hashing($password, $saltkey, $vsaltkey);
  77.     if($hashedpass == $getHashedPassWord){
  78.         echo("\n                    <ul>\n                  <h3>AdminCP Links</h3>\n                    ");
  79.         foreach($nav_acp as $link => $name){
  80.             if($Nav_ID == $name){
  81.                 ?><li class="Selected"><a href="<?php echo($link); ?>" class="menu"><?php echo($name); ?></a></li><?php
  82.                 if($link != $last_acp){
  83.                     echo("\n                    ");
  84.                 }else{
  85.                     echo("\n");
  86.                 }
  87.             }else{
  88.                 ?><li class="Unselected"><a href="<?php echo($link); ?>" class="menu"><?php echo($name); ?></a></li><?php
  89.                 if($link != $last_acp){
  90.                     echo("\n                    ");
  91.                 }else{
  92.                     echo("\n");
  93.                 }
  94.             }
  95.         }
  96.     }else{
  97.         header('location: '.$instalLocation.'/acp/index.php');
  98.         echo('Error User Timed Out! 2');
  99.     }
  100. }
  101.  
  102. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement