Source for file talk.php

Documentation is available at talk.php

  1. <?php
  2.  
  3. /*
  4. Program E
  5. Copyright 2002, Paul Rydell
  6.  
  7. This file is part of Program E.
  8. Program E is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. Program E is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with Program E; if not, write to the Free Software
  20. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22.  
  23. /**
  24. * HTML chat interface
  25. *
  26. * Contains the script that outputs the HTML interface for chatting
  27. * @author Paul Rydell
  28. * @copyright 2002
  29. * @version 0.0.8
  30. * @package Interpreter
  31. * @subpackage Responder
  32. */
  33.  
  34.  
  35. /**
  36. * Include the guts of the program.
  37. */
  38. include "respond.php";
  39.  
  40. if (isset($HTTP_POST_VARS['input'])){
  41.  
  42. $numselects=0;
  43.  
  44. // Start the session or get the existing session.
  45. session_start();
  46. $myuniqueid=session_id();
  47.  
  48. // Here is where we get the reply.
  49. $botresponse=replybotname($HTTP_POST_VARS['input'],$myuniqueid,$HTTP_POST_VARS['botname']);
  50.  
  51. // Print the results.
  52. print "<B>RESPONSE: " . $botresponse->response . "<BR></b>";
  53. print "<BR><BR>execution time: " . $botresponse->timer;
  54. print "<BR>numselects= $numselects";
  55.  
  56. //print_r($botresponse->inputs);
  57. //print_r($botresponse->patternsmatched);
  58.  
  59. // Include a form so they can say more. Note the hidden part for people that do not have trans sid on but want non-cookie users to be able to use the system.
  60.  
  61.  
  62. ?>
  63.  
  64. <html>
  65. <head>
  66. <title>Sample talk to Program E page</title>
  67. </head>
  68. <body>
  69. <form name="form1" method="post" action="talk.php">
  70. <input type="hidden" name="<?=session_name()?>" value="<?=$uid?>">
  71. <input type="hidden" name="botname" value="<?=$HTTP_POST_VARS['botname']?>">
  72. Input: <input type="text" name="input" size="55">
  73.  
  74. <input type="submit" name="Submit" value="Submit">
  75. </form>
  76. </body>
  77. </html>
  78.  
  79. <?
  80. }
  81. else {
  82.  
  83. $availbots=array();
  84.  
  85. // Get all the names of our bots.
  86. $query="select botname from bots";
  87.  
  88. $selectcode = mysql_query($query);
  89.  
  90. if ($selectcode){
  91. if(!mysql_numrows($selectcode)){
  92. }
  93. else{
  94. while ($q = mysql_fetch_array($selectcode)){
  95. $availbots[]=$q[0];
  96. }
  97. }
  98. }
  99.  
  100. ?>
  101.  
  102. <html>
  103. <head>
  104. <title>Program E Tester</title>
  105. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  106. </head>
  107.  
  108. <body bgcolor="#FFFFFF" text="#000000">
  109. <form name="form1" method="post" action="talk.php">
  110.  
  111. Talk to: <select name="botname">
  112. <?
  113. foreach ($availbots as $onebot){
  114. print "<option value=\"$onebot\">$onebot</option>";
  115. }
  116. ?>
  117. </select><BR>
  118.  
  119. Input: <input type="text" name="input" size="55">
  120.  
  121. <input type="submit" name="Submit" value="Submit">
  122. </form>
  123. </body>
  124. </html>
  125.  
  126. <?
  127.  
  128. }
  129.  
  130. ?>

Documentation generated on Wed, 12 Jan 2005 12:24:49 +0100 by phpDocumentor 1.3.0RC3