Source for file voice_command.php

Documentation is available at voice_command.php

  1. <?php
  2. /**
  3. * Command menu of the voice application
  4. *
  5. * Executes a command selected by the user and confirms it if successful
  6. * @package Phone2Dev
  7. * @author Stanislav Miroshnikov
  8. */
  9.  
  10. // start the session
  11. session_start();
  12.  
  13. print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
  14.  
  15. /**
  16. * Requires a custom error handler
  17. */
  18. require_once("voice_error.php");
  19. //trigger_error('This is an information log message.', E_USER_NOTICE);
  20. //NOTE: default values are for debuging purposes only
  21. /*
  22. if(!isset($_SESSION['intUserId'])) {
  23. $_SESSION['intUserId'] = 1;
  24. }
  25. if(!isset($_SESSION['intMainMenuId'])) {
  26. $_SESSION['intMainMenuId'] = 1;
  27. }
  28. if(!isset($_GET['commandId'])) {
  29. $_GET['commandId'] = 1;
  30. }
  31. if(!isset($_GET['menuId'])) {
  32. $_GET['menuId'] = 1;
  33. }
  34. if(!isset($_GET['deviceId'])) {
  35. $_GET['deviceId'] = 1;
  36. }
  37. */
  38.  
  39. /**
  40. * Requires PHP Voice library to generate the VoiceXML
  41. */
  42. require_once ("phpvoice/vxml.class.php");
  43.  
  44. // check that the required parameters are set
  45. if(
  46. isset($_SESSION['intUserId']) &&
  47. isset($_SESSION['intMainMenuId']) &&
  48. isset($_GET['commandId']) &&
  49. isset($_GET['menuId']) &&
  50. isset($_GET['deviceId'])) {
  51.  
  52. /**
  53. * Requires the Phone2Dev class to access the database
  54. */
  55. require_once ("phone2dev.php");
  56. $objP2D =& new Phone2Dev();
  57.  
  58. // connect to the database
  59. $objP2D->dbConnect();
  60.  
  61. // activate the command
  62. $intStatus = $objP2D->executeCommand($_GET['commandId'],
  63. $_GET['deviceId'],
  64. $_SESSION['intUserId']);
  65.  
  66. $app =& new gonx_vxml();
  67. $app->start_vxml("", "", "", "", "", "2.0"); {
  68. // catch the disconnect event
  69. $app->start_catch("connection.disconnect"); {
  70. $app->start_exit_c();
  71. }$app->end_catch();
  72. // show the menu
  73. $app->start_menu("command_menu"); {
  74. $app->start_prompt(); {
  75. if($intStatus == 200) {
  76. $app->write("Command was send successfully.");
  77. } else {
  78. $app->write("Command send failed with error code: ".$intStatus.".");
  79. }
  80. $app->write("Select one of the following menu choices");
  81. $app->start_enumerate_c();
  82. }$app->end_prompt();
  83. $app->start_choice("", "", "",
  84. "voice_menu.php?menuId="
  85. .$_SESSION['intMainMenuId']);{
  86. $app->write("Return to main menu.");
  87. }$app->end_choice();
  88. if($_GET['menuId'] != $_SESSION['intMainMenuId']) {
  89. // this command has a parent menu if it is not located
  90. // in the main menu
  91. $app->start_choice("", "", "",
  92. "voice_menu.php?menuId="
  93. .$_GET['menuId']);{
  94. $app->write("Return to previous menu.");
  95. }$app->end_choice();
  96. }
  97. }$app->end_menu();
  98. }$app->end_vxml();
  99. // generate the document
  100. $app->generate();
  101. // disconnect from the database
  102. $objP2D->dbDisconnect();
  103. } else {
  104. // user is not logged in correctly
  105. $app =& new gonx_vxml();
  106. $app->start_vxml("", "", "", "", "", "2.0"); {
  107. // catch the disconnect event
  108. $app->start_catch("connection.disconnect"); {
  109. $app->start_exit_c();
  110. }$app->end_catch();
  111. $app->start_form("login_failure",""); {
  112. $app->start_block(); {
  113. $app->start_prompt(); {
  114. $app->write("Error. Your session have expired or");
  115. $app->write("you have not logged in.");
  116. }$app->end_prompt();
  117. }$app->end_block();
  118. $app->start_exit_c();
  119. }$app->end_form();
  120. // end of the vxml document
  121. }$app->end_vxml();
  122.  
  123. // generate the document
  124. $app->generate();
  125. }
  126.  
  127. ?>

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