Location: PHPKode > scripts > phpMyAccess > phpmyaccess-1.5.3/phpmyaccess/index.php
<?php

// db access data
include 'dbaccess.php';
include 'pma-debuginc.php';

/*
  tables:
  menuitems
  $items = 'menuitems';
  Menus
  $menus = 'user_menu';
  items in menus
  $umenus = 'umenu_items';
*/
// setup auth (>0) or not (0)
$auth = 1;

// connect to database
$dbl = mysql_connect($opt['hn'],$opt['un'],$opt['pw'])
  or pma_errpage ("Could not connect to MySQL");
if (!isset($opt['db'])) {
   pma_errpage("No Database defined");
}

// header output
function MyHeader ($menutitle) {
echo("<?xml version=\"1.0\"?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
  <title>$menutitle </title>

</head>
<body bgcolor=\"#ffeb10\">
  <div class=\"main\">
  <h3>$menutitle</h3>
  <P></p>
  <hr  width=\"30%\"  align=\"left\">
  <P></p>
");
}

// authenticated level = 0 to start with
$auth_level = 0;
// is authentication required ?
if ($auth >= 1) {
   include 'auth.inc.php';
   if ((!$auth_level) || ($auth_level < $auth)) {
      // this can be a function to display something nicer, of course
      die("Access Denied");
   }
} else {
   // select default user for menus
   $auth_user = "Default";
}

$debug=0;

// default to main page
if (!$_GET['page']) {
   $page="main";
} else {
	$page=$_GET['page'];
}

// query to get needed page display data from tables
$qry="select menu_items.menu_value, menu_items.menu_name, menu_pages.menu_page_long from umenu_items, menu_items, umenu_pages, menu_pages " .
       "where (umenu_pages.user_logname='$auth_user') and (umenu_pages.menu_page_name='$page') and (umenu_items.user_logname='$auth_user')" .
       " and  (umenu_items.menu_item_ID=menu_items.menu_item_ID) and (menu_pages.menu_page_name=umenu_pages.menu_page_name)" .
       " and (umenu_items.umenu_ID=umenu_pages.umenu_ID) order by umenu_items.umenu_item_order";

pma_debug ("Page menu query : " . $qry );

// find page info for user
$res = mysql_db_query($opt['db'],$qry);
// database error, so we quit
if (!$res) {
   pma_errpage ("Error ! Menu Pages result : " . mysql_errno().": ".mysql_error());
} else { // this should mean we're ok
   list($menu_value, $menu_name, $page_title ) =  mysql_fetch_row($res);
   MyHeader($page_title);
   echo "   <a href='$menu_value'>$menu_name</a><br>\n";
   while(list($menu_value, $menu_name, $page_title) =  mysql_fetch_row($res)) {
     // this is a hack, needs a nicer fix
     if ($menu_name=="break") {
        echo $menu_value . "\n";
     } else {
        echo "   <a href='$menu_value'>$menu_name</a><br>\n";
     }
   }
}

echo "  <P></p>\n";
echo "  <hr  width=\"30%\"  align=\"left\">\n";
echo "  <P></p>\n";
echo "<br><b> User : $auth_user</b><br>\n";
echo "</body>\n";
echo "</html>\n";
?>
Return current item: phpMyAccess