Source for file backup.inc.php

Documentation is available at backup.inc.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.  
  23. /**
  24. * Creating the AIML categories.
  25. *
  26. * Creating the actual AIML categories from the Topic, Pattern, That and
  27. * Template. At first this was done using DOM XML. However, it treated the
  28. * AIML in the template as text and thus converted all the <srai> etc to their
  29. * 'safe' characters
  30. *
  31. * @param string $cat_topic the contents of <topic name=''>
  32. * @param string $cat_that contents of <that>..</that>
  33. * @param string $cat_pattern contents of <pattern>..</pattern>
  34. * @param string $cat_template contents of the <template> including all
  35. * of the AIML code.
  36. *
  37. * @return string a very long string
  38. *
  39. */
  40. function makeCategory($cat_topic, $cat_that, $cat_pattern, $cat_template) {
  41.  
  42. $cat = "";
  43.  
  44. // if Topic is a * then leave it out.
  45. if(trim($cat_topic) != '*') {
  46. $cat .="<topic name=\"".trim($cat_topic)."\">\n";
  47. }
  48. $cat .=" <category>\n";
  49. $cat .=" <pattern>".trim($cat_pattern)."</pattern>\n";
  50.  
  51. // if That is a * then leave it out
  52. if(trim($cat_that) != '*') {
  53. $cat .=" <that>".trim($cat_that)."</that>\n";
  54. }
  55. $cat .=" <template>".trim($cat_template)."</template>\n";
  56. $cat .=" </category>\n";
  57.  
  58. // if Topic is a * then leave it out.
  59. if(trim($cat_topic) != '*') {
  60. $cat .="</topic>\n";
  61. }
  62.  
  63. return $cat;
  64. }
  65.  
  66.  
  67. /**
  68. * Count categories
  69. *
  70. * Count the number of categories by counting the number of templates in the
  71. * template table of the database
  72. *
  73. * @todo Use a different error scheme.
  74. *
  75. * @param integer $botid the bot's ID, in case there are more
  76. * than one bot.
  77. *
  78. * @return integer number of categories.
  79. *
  80. */
  81. function count_IDs($botid) {
  82.  
  83. $query = "select count(id) as id from templates where bot='".$botid."'";
  84. $selectcode = mysql_query($query);
  85. if ($selectcode){
  86. if(!mysql_numrows($selectcode)){
  87. }
  88. else{
  89. while ($row = mysql_fetch_array($selectcode)){
  90.  
  91. $count_ids = $row['id'];
  92. }
  93. return $count_ids;
  94. }
  95. } else {
  96. echo "count database does something odd";
  97. }
  98.  
  99. }
  100.  
  101.  
  102.  
  103. /**
  104. * Retrieve a predetermined number of templates
  105. *
  106. * Retrieve a predetermined number of templates and their corresponding ID's
  107. * from the templates table.
  108. *
  109. * @param integer $botid The bot's ID, in case there are more than one bot.
  110. * @param integer $templatesToProcess Number of templates to process in a single processing cycle.
  111. * @param integer $pid Process ID, the process cycle (number of templates/templates to process) that
  112. * is to be retrieved for processing
  113. *
  114. * @return array key being the template ID and the value being the contents of the <template> tag.
  115. *
  116. */
  117. function getTemplateIDs($botid, $pid, $templatesToProcess) {
  118.  
  119. // At start the pid may be zero.
  120. if($pid != 0) {
  121. $temp_start = $pid * $templatesToProcess;
  122.  
  123. } else {
  124. $temp_start = $pid;
  125. }
  126. $query = "select id, template from templates where bot='".$botid."' order by id asc limit ".$temp_start.",".$templatesToProcess;
  127. $selectcode = mysql_query($query);
  128. if ($selectcode){
  129. if(!mysql_numrows($selectcode)){
  130. }
  131. else{
  132. while ($row = mysql_fetch_array($selectcode)){
  133.  
  134. $templates[$row['id']] = $row['template'];
  135. }
  136. return $templates;
  137. }
  138. } else {
  139. echo "template database does something odd";
  140. }
  141.  
  142. }
  143.  
  144. ?>

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