Source for file menu.php

Documentation is available at menu.php

  1. <?php
  2. /**
  3. * Main menu of the web interface
  4. *
  5. * Allows user to navigate between menus and choose commands.
  6. * @package Phone2Dev
  7. * @author Stanislav Miroshnikov
  8. * @todo add template support
  9. */
  10. //start a session
  11. session_start();
  12. ?>
  13.  
  14. <html>
  15. <head>
  16. <title>Phone2Dev: Main Menu</title>
  17. </head>
  18. <body>
  19. <?php
  20. // check if the required session variables are set
  21. if(isset($_SESSION['intUserId']) && isset($_SESSION['intMainMenuId'])) {
  22.  
  23. //if the menuId is not supplied display the user's main menu
  24. $intMenuId = -1;
  25. if(!isset($_GET['menuId'])) {
  26. $intMenuId = $_SESSION['intMainMenuId'];
  27. } else {
  28. $intMenuId = $_GET['menuId'];
  29. }
  30.  
  31. /**
  32. * Requires Phone2Dev class for database access.
  33. */
  34. require_once 'phone2dev.php';
  35. $objP2D =& new Phone2Dev();
  36. // connect to the database
  37. $objP2D->dbConnect();
  38. // output the page header
  39. print "<h1>Phone2Dev: Main Menu</h1>";
  40. print "<p>You are logged in as: ".$_SESSION['strUsername']."</p>";
  41.  
  42. // display sub menus for the menu
  43. $arrSubMenus = &$objP2D->getSubMenus($intMenuId, $_SESSION['intUserId']);
  44. reset($arrSubMenus);
  45. while (list($intSubMenuId, $strSubMenuName) = each($arrSubMenus)) {
  46. if($intSubMenuId != $intMenuId) {
  47. print "<p><a href=\"menu.php?menuId=".$intSubMenuId
  48. ."\">Go to: ".$strSubMenuName."<a\></p>";
  49. }
  50. }
  51.  
  52. // display commands for the menu
  53. $arrCommands =& $objP2D->getCommands($intMenuId, $_SESSION['intUserId']);
  54. while (list($intComId, $arrComInfo) = each($arrCommands)) {
  55. print "<p><a href=\"command.php?menuId=".$intMenuId
  56. ."&commandId=".$intComId
  57. ."&deviceId=".$arrComInfo['intDeviceId']."\">"
  58. .$arrComInfo['strDeviceName'].": ".$arrComInfo['strComName']."<a\></p>";
  59. }
  60.  
  61. // if this is not the main menu give option to return to main menu
  62. if($intMenuId != $_SESSION['intMainMenuId']) {
  63. print "<p>Return to <a href=\"menu.php?menuId="
  64. .$_SESSION['intMainMenuId']."\">Main Menu<a\></p>";
  65. }
  66. // give option to log out
  67. print "<p>Click here to <a href=\"logout.php\">logout</a>.</p>";
  68.  
  69. // disconnect from the database
  70. $objP2D->dbDisconnect();
  71. } else {
  72. print "<h1>Phone2Dev Error</h1>";
  73. print "<p>You are not properly logged in.</p>";
  74. print "<p>You can login <a href=\"login.html\">here</a>.</p>";
  75. }
  76. ?>
  77. </body>
  78. </html>

Documentation generated on Tue, 4 Jan 2005 13:48:00 -0500 by phpDocumentor 1.3.0RC3