Source for file target.php

Documentation is available at target.php

  1. <?php
  2.  
  3. /*
  4. Program E related AIML knowledgebase tools
  5. Copyright 2004, Anne Kootstra [anne@aiml.info]
  6. http://www.AIML.info
  7. Program E is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. Program E is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Program E; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21.  
  22. // required files that contain functions used in this
  23. // page
  24.  
  25. require_once "../admin/botloaderfuncs.php";
  26. require_once "include/common.inc.php";
  27. require_once "include/target.inc.php";
  28. require_once "include/add.inc.php";
  29.  
  30.  
  31. // HTTP_POST or HTTP_GET variables
  32. // used in this page. They are now accessible, as normal variables.
  33. // escape routine to make global variables from POST/GET variables.
  34.  
  35. getRequest("cat_input", 0);
  36. getRequest("cat_that", 0);
  37. getRequest("cat_topic", 0);
  38. getRequest("cat_template", 0);
  39. getRequest("botid", 0);
  40. getRequest("target_id", 0);
  41. getRequest("act", 0);
  42.  
  43.  
  44.  
  45. // routine to create the bot selection list.
  46. $botnames = getbotnames();
  47.  
  48. while(list($key, $val) = each($botnames)) {
  49. if($botid == $key){
  50. $bots .= "<option value=\"$key\" selected>$val</option>";
  51. }else{
  52. $bots .= "<option value=\"$key\">$val</option>";
  53. }
  54. }
  55.  
  56.  
  57. // auto select a previously selected bot.
  58. if(!$botid) {
  59.  
  60. $page['{{bots}}'] = $bots;
  61. echo useTemplate('botselect',$page);
  62.  
  63. return;
  64.  
  65. }
  66.  
  67.  
  68. //insert the new AIML category
  69. if($cat_input != '') {
  70.  
  71. // check to see if fields are empty, then put a * in them
  72. if($cat_that == '') {
  73.  
  74. $cat_that = "*";
  75. }
  76.  
  77. if($cat_topic == '') {
  78.  
  79. $cat_topic = "*";
  80. }
  81.  
  82. // Make a string out of the received category that can be processed
  83. // by native Program E functions
  84. $mybigsentence=strtoupper($cat_input)." <that> ".strtoupper($cat_that)." <topic> ".strtoupper($cat_topic);
  85.  
  86. // Last record of a category in the paterntable is used as an
  87. // ID-reference to the templates table
  88. $idused=insertAnnesentence($mybigsentence, $botid);
  89.  
  90. // is used by insertmytemplate() in the ../admin/botloaderfuncs.php
  91. $selectbot = $botid;
  92. insertmytemplate($idused,$cat_template);
  93.  
  94. deletetarget($target_id);
  95. } else {
  96.  
  97. // delete the GMcache entry.
  98. if($act == 'delete') {
  99.  
  100. deletetarget($target_id);
  101. $target_id = '';
  102. }
  103.  
  104. }
  105.  
  106.  
  107. // If no Target/GMcache ID exists, find the first target/GMcache record in the table
  108. if(!$target_id) {
  109. $target_id = findFirsttarget($botid);
  110. }
  111.  
  112. // retrieve the target/GMcache information from the table
  113. $matched = findtarget($target_id);
  114.  
  115.  
  116. $matched_pattern = explode(' : ', $matched['pattern']);
  117. $matched_input = explode(' : ', $matched['input']);
  118.  
  119.  
  120.  
  121.  
  122.  
  123. // match the placeholders in the template to
  124. // a specific PHP variable.
  125.  
  126. $page['{{log_input}}'] = $matched_input[0];
  127. $page['{{log_that}}'] = $matched_input[1];
  128. $page['{{log_topic}}'] = $matched_input[2];
  129.  
  130. $page['{{match_input}}'] = $matched_pattern[0];
  131. $page['{{match_that}}'] = $matched_pattern[1];
  132. $page['{{match_topic}}'] = $matched_pattern[2];
  133.  
  134. $page['{{target_id}}'] = $target_id;
  135. $page['{{bots}}'] = $bots;
  136. $page['{{bot_id}}'] = $botid;
  137.  
  138.  
  139. // load the template and return the page.
  140. echo useTemplate('target',$page);
  141.  
  142. ?>

Documentation generated on Tue, 11 Jan 2005 18:41:11 +0100 by phpDocumentor 1.3.0RC3