Documentation is available at menu.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
- */
- $settings['menuItems'] = '5';
- function getFirstWords($strFirstChar, $botid, $pid) {
- global $settings;
- $strSQLfirsWords = "
- SELECT
- DISTINCT SUBSTRING_INDEX(pattern, ' ', 1) AS firstWords
- FROM templates
- WHERE
- bot = ".$botid." AND
- pattern REGEXP '^".$strFirstChar."'
- ORDER BY
- firstWords ASC
- LIMIT ".$pid * $settings['menuItems'].",".(($pid + 1) * $settings['menuItems']).";";
- debugger($strSQLfirsWords,2);
- $selectcode = mysql_query($strSQLfirsWords);
- if ($selectcode){
- if(!mysql_numrows($selectcode)){
- return "";
- }
- else{
- while ($q = mysql_fetch_row($selectcode)){
- $result[] = $q[0];
- }
- return $result;
- }
- }
- return "";
- }
- function getNode($strPattern, $botid, $pid) {
- global $settings;
- $pid = $pid - 1;
- $quer = "set @strPat = '1';";
- $que2 = "select botname from bots where id = @strPat;";
- $strSQLsetVar = "
- SET
- @strPattern = TRIM(UCASE('".$strPattern."')),
- @intWords = LENGTH(@strPattern) - LENGTH(REPLACE(@strPattern, ' ', '')) + 1;";
- $strSQLnodes = "
- SELECT
- SUBSTRING_INDEX(
- SUBSTRING_INDEX(
- pattern,
- ' ',
- @intWords +1
- ),
- ' ',
- -1
- ) AS word,
- IF(
- LENGTH(pattern) - LENGTH(REPLACE(pattern, ' ', '')) = @intWords,
- 1,
- 0
- ) AS isend,
- COUNT(pattern) AS no_nodes,
- IF(
- LENGTH(pattern) - LENGTH(REPLACE(pattern, ' ', '')) = @intWords || COUNT(pattern) = 1,
- id,
- null
- ) AS template_id,
- MAX(LENGTH(pattern) - LENGTH(REPLACE(pattern, ' ', ''))) + 1 AS max_words
- FROM
- templates
- WHERE
- SUBSTRING_INDEX(pattern, ' ', @intWords) like @strPattern AND
- pattern != @strPattern AND
- bot = ".$botid."
- GROUP BY
- word
- ORDER BY
- word ASC
- LIMIT ".$pid * $settings['menuItems'].",".(($pid + 1) * $settings['menuItems']).";";
- //echo "$strSQLsetVar $strSQLnodes";
- debugger($strSQLnodes,2);
- $selectcode = mysql_query($strSQLsetVar);
- $selectcode = mysql_query($strSQLnodes);
- if ($selectcode){
- if(!mysql_numrows($selectcode)){
- //die('<br/><br/><br/>Invalid query: ' . mysql_error());
- return "";
- }
- else{
- $x = 0;
- while ($q = mysql_fetch_array($selectcode)){
- $result[$x]['word'] = $q['word'];
- $result[$x]['isend'] = $q['isend'];
- $result[$x]['no_nodes'] = $q['no_nodes'];
- $result[$x]['template_id'] = $q['template_id'];
- $result[$x]['max_words'] = $q['max_words'];
- $x++;
- }
- return $result;
- }
- }
- return "";
- }
- function getBotName($botid){
- $query = "select botname from bots where id=".$botid."";
- debugger($query,2);
- $selectcode = mysql_query($query);
- if ($selectcode){
- if(!mysql_numrows($selectcode)){
- return "";
- }
- else{
- while ($q = mysql_fetch_array($selectcode)){
- return $q[0];
- }
- }
- }
- return "";
- }
- ?>
Documentation generated on Tue, 11 Jan 2005 18:41:07 +0100 by phpDocumentor 1.3.0RC3