Documentation is available at backup.inc.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
- */
- /**
- * Creating the AIML categories.
- *
- * Creating the actual AIML categories from the Topic, Pattern, That and
- * Template. At first this was done using DOM XML. However, it treated the
- * AIML in the template as text and thus converted all the <srai> etc to their
- * 'safe' characters
- *
- * @param string $cat_topic the contents of <topic name=''>
- * @param string $cat_that contents of <that>..</that>
- * @param string $cat_pattern contents of <pattern>..</pattern>
- * @param string $cat_template contents of the <template> including all
- * of the AIML code.
- *
- * @return string a very long string
- *
- */
- function makeCategory($cat_topic, $cat_that, $cat_pattern, $cat_template) {
- $cat = "";
- // if Topic is a * then leave it out.
- if(trim($cat_topic) != '*') {
- $cat .="<topic name=\"".trim($cat_topic)."\">\n";
- }
- $cat .=" <category>\n";
- $cat .=" <pattern>".trim($cat_pattern)."</pattern>\n";
- // if That is a * then leave it out
- if(trim($cat_that) != '*') {
- $cat .=" <that>".trim($cat_that)."</that>\n";
- }
- $cat .=" <template>".trim($cat_template)."</template>\n";
- $cat .=" </category>\n";
- // if Topic is a * then leave it out.
- if(trim($cat_topic) != '*') {
- $cat .="</topic>\n";
- }
- return $cat;
- }
- /**
- * Count categories
- *
- * Count the number of categories by counting the number of templates in the
- * template table of the database
- *
- * @todo Use a different error scheme.
- *
- * @param integer $botid the bot's ID, in case there are more
- * than one bot.
- *
- * @return integer number of categories.
- *
- */
- function count_IDs($botid) {
- $query = "select count(id) as id from templates where bot='".$botid."'";
- $selectcode = mysql_query($query);
- if ($selectcode){
- if(!mysql_numrows($selectcode)){
- }
- else{
- while ($row = mysql_fetch_array($selectcode)){
- $count_ids = $row['id'];
- }
- return $count_ids;
- }
- } else {
- echo "count database does something odd";
- }
- }
- /**
- * Retrieve a predetermined number of templates
- *
- * Retrieve a predetermined number of templates and their corresponding ID's
- * from the templates table.
- *
- * @param integer $botid The bot's ID, in case there are more than one bot.
- * @param integer $templatesToProcess Number of templates to process in a single processing cycle.
- * @param integer $pid Process ID, the process cycle (number of templates/templates to process) that
- * is to be retrieved for processing
- *
- * @return array key being the template ID and the value being the contents of the <template> tag.
- *
- */
- function getTemplateIDs($botid, $pid, $templatesToProcess) {
- // At start the pid may be zero.
- if($pid != 0) {
- $temp_start = $pid * $templatesToProcess;
- } else {
- $temp_start = $pid;
- }
- $query = "select id, template from templates where bot='".$botid."' order by id asc limit ".$temp_start.",".$templatesToProcess;
- $selectcode = mysql_query($query);
- if ($selectcode){
- if(!mysql_numrows($selectcode)){
- }
- else{
- while ($row = mysql_fetch_array($selectcode)){
- $templates[$row['id']] = $row['template'];
- }
- return $templates;
- }
- } else {
- echo "template database does something odd";
- }
- }
- ?>
Documentation generated on Tue, 11 Jan 2005 18:40:57 +0100 by phpDocumentor 1.3.0RC3