Documentation is available at target.php
- <?php
- /*
- Program E related AIML knowledgebase tools
- Copyright 2004, Anne Kootstra [anne@aiml.info]
- http://www.AIML.info
- Program E is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- Program E is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Program E; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- // required files that contain functions used in this
- // page
- require_once "../admin/botloaderfuncs.php";
- require_once "include/common.inc.php";
- require_once "include/target.inc.php";
- require_once "include/add.inc.php";
- // HTTP_POST or HTTP_GET variables
- // used in this page. They are now accessible, as normal variables.
- // escape routine to make global variables from POST/GET variables.
- getRequest("cat_input", 0);
- getRequest("cat_that", 0);
- getRequest("cat_topic", 0);
- getRequest("cat_template", 0);
- getRequest("botid", 0);
- getRequest("target_id", 0);
- getRequest("act", 0);
- // routine to create the bot selection list.
- $botnames = getbotnames();
- while(list($key, $val) = each($botnames)) {
- if($botid == $key){
- $bots .= "<option value=\"$key\" selected>$val</option>";
- }else{
- $bots .= "<option value=\"$key\">$val</option>";
- }
- }
- // auto select a previously selected bot.
- if(!$botid) {
- $page['{{bots}}'] = $bots;
- echo useTemplate('botselect',$page);
- return;
- }
- //insert the new AIML category
- if($cat_input != '') {
- // check to see if fields are empty, then put a * in them
- if($cat_that == '') {
- $cat_that = "*";
- }
- if($cat_topic == '') {
- $cat_topic = "*";
- }
- // Make a string out of the received category that can be processed
- // by native Program E functions
- $mybigsentence=strtoupper($cat_input)." <that> ".strtoupper($cat_that)." <topic> ".strtoupper($cat_topic);
- // Last record of a category in the paterntable is used as an
- // ID-reference to the templates table
- $idused=insertAnnesentence($mybigsentence, $botid);
- // is used by insertmytemplate() in the ../admin/botloaderfuncs.php
- $selectbot = $botid;
- insertmytemplate($idused,$cat_template);
- deletetarget($target_id);
- } else {
- // delete the GMcache entry.
- if($act == 'delete') {
- deletetarget($target_id);
- $target_id = '';
- }
- }
- // If no Target/GMcache ID exists, find the first target/GMcache record in the table
- if(!$target_id) {
- $target_id = findFirsttarget($botid);
- }
- // retrieve the target/GMcache information from the table
- $matched = findtarget($target_id);
- $matched_pattern = explode(' : ', $matched['pattern']);
- $matched_input = explode(' : ', $matched['input']);
- // match the placeholders in the template to
- // a specific PHP variable.
- $page['{{log_input}}'] = $matched_input[0];
- $page['{{log_that}}'] = $matched_input[1];
- $page['{{log_topic}}'] = $matched_input[2];
- $page['{{match_input}}'] = $matched_pattern[0];
- $page['{{match_that}}'] = $matched_pattern[1];
- $page['{{match_topic}}'] = $matched_pattern[2];
- $page['{{target_id}}'] = $target_id;
- $page['{{bots}}'] = $bots;
- $page['{{bot_id}}'] = $botid;
- // load the template and return the page.
- echo useTemplate('target',$page);
- ?>
Documentation generated on Tue, 11 Jan 2005 18:41:11 +0100 by phpDocumentor 1.3.0RC3