Location: PHPKode > projects > Program E > docs/developer/__filesource/fsource_Loader__adminbotloaderfuncs.php.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos  -->
			<title>File Source for botloaderfuncs.php</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
											</head>
		<body>
						
<h1>Source for file botloaderfuncs.php</h1>
<p>Documentation is available at <a href="../Loader/_admin_botloaderfuncs_php.html">botloaderfuncs.php</a></p>
<div class="src-code">
<pre><ol><li><a name="a1"></a><span class="src-php">&lt;?</span></li>
<li><a name="a2"></a>&nbsp;</li>
<li><a name="a3"></a><span class="src-comm">/*</span></li>
<li><a name="a4"></a><span class="src-comm">    Program E</span></li>
<li><a name="a5"></a><span class="src-comm">    Copyright 2002, Paul Rydell</span></li>
<li><a name="a6"></a><span class="src-comm">    Portions by Jay Myers</span></li>
<li><a name="a7"></a>    </li>
<li><a name="a8"></a><span class="src-comm">    This file is part of Program E.</span></li>
<li><a name="a9"></a>    </li>
<li><a name="a10"></a><span class="src-comm">    Program E is free software; you can redistribute it and/or modify</span></li>
<li><a name="a11"></a><span class="src-comm">    it under the terms of the GNU General Public License as published by</span></li>
<li><a name="a12"></a><span class="src-comm">    the Free Software Foundation; either version 2 of the License, or</span></li>
<li><a name="a13"></a><span class="src-comm">    (at your option) any later version.</span></li>
<li><a name="a14"></a>&nbsp;</li>
<li><a name="a15"></a><span class="src-comm">    Program E is distributed in the hope that it will be useful,</span></li>
<li><a name="a16"></a><span class="src-comm">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span></li>
<li><a name="a17"></a><span class="src-comm">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></li>
<li><a name="a18"></a><span class="src-comm">    GNU General Public License for more details.</span></li>
<li><a name="a19"></a>&nbsp;</li>
<li><a name="a20"></a><span class="src-comm">    You should have received a copy of the GNU General Public License</span></li>
<li><a name="a21"></a><span class="src-comm">    along with Program E; if not, write to the Free Software</span></li>
<li><a name="a22"></a><span class="src-comm">    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span></li>
<li><a name="a23"></a><span class="src-comm">*/</span></li>
<li><a name="a24"></a>&nbsp;</li>
<li><a name="a25"></a><span class="src-doc">/**</span></li>
<li><a name="a26"></a><span class="src-doc"> * AIML loading functions</span></li>
<li><a name="a27"></a><span class="src-doc"> * </span></li>
<li><a name="a28"></a><span class="src-doc"> * Contains contains the functions for the actual loading of AIML.</span></li>
<li><a name="a29"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@author</span><span class="src-doc"> Paul Rydell</span></li>
<li><a name="a30"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@copyright</span><span class="src-doc"> 2002</span></li>
<li><a name="a31"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@version</span><span class="src-doc"> 0.0.8</span></li>
<li><a name="a32"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@package</span><span class="src-doc"> Loader</span></li>
<li><a name="a33"></a><span class="src-doc"> */</span></li>
<li><a name="a34"></a>&nbsp;</li>
<li><a name="a35"></a>&nbsp;</li>
<li><a name="a36"></a><span class="src-doc">/**</span></li>
<li><a name="a37"></a><span class="src-doc">* The general preferences and database details.</span></li>
<li><a name="a38"></a><span class="src-doc">*/</span></li>
<li><a name="a39"></a><span class="src-inc">require_once </span><span class="src-str">&quot;dbprefs.php&quot;</span><span class="src-sym">;</span></li>
<li><a name="a40"></a>&nbsp;</li>
<li><a name="a41"></a><span class="src-key">global </span><span class="src-var">$selectbot</span><span class="src-sym">, </span><span class="src-var">$annesID</span><span class="src-sym">;            </span></li>
<li><a name="a42"></a>&nbsp;</li>
<li><a name="a43"></a>&nbsp;</li>
<li><a name="a44"></a><span class="src-doc">/**</span></li>
<li><a name="a45"></a><span class="src-doc">* Deletes everything about a bot.</span></li>
<li><a name="a46"></a><span class="src-doc">*</span></li>
<li><a name="a47"></a><span class="src-doc">* Empties the tables, bot, patterns, templates, bots and gmcache</span></li>
<li><a name="a48"></a><span class="src-doc">*</span></li>
<li><a name="a49"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$bot </span><span class="src-doc">            The bot's ID</span></li>
<li><a name="a50"></a><span class="src-doc">*</span></li>
<li><a name="a51"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a52"></a><span class="src-doc">*/</span></li>
<li><a name="a53"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functiondeletebot">deletebot</a><span class="src-sym">(</span><span class="src-var">$bot</span><span class="src-sym">)        </span></li>
<li><a name="a54"></a><span class="src-sym">{</span></li>
<li><a name="a55"></a>    </li>
<li><a name="a56"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">delete</span> <span class="src-id">from</span> <span class="src-id">bot</span> <span class="src-id">where</span> <span class="src-id">bot</span>=<span class="src-var">$bot</span></span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a57"></a>    <span class="src-var">$e </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a58"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a59"></a>    <span class="src-sym">}</span></li>
<li><a name="a60"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">delete</span> <span class="src-id">from</span> <span class="src-id">patterns</span> <span class="src-id">where</span> <span class="src-id">bot</span>=<span class="src-var">$bot</span></span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a61"></a>    <span class="src-var">$e </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a62"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a63"></a>    <span class="src-sym">}</span></li>
<li><a name="a64"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">delete</span> <span class="src-id">from</span> <span class="src-id">templates</span> <span class="src-id">where</span> <span class="src-id">bot</span>=<span class="src-var">$bot</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a65"></a>    <span class="src-var">$e </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a66"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a67"></a>    <span class="src-sym">}</span></li>
<li><a name="a68"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">delete</span> <span class="src-id">from</span> <span class="src-id">bots</span> <span class="src-id">where</span> <span class="src-id">id</span>=<span class="src-var">$bot</span></span><span class="src-str">&quot;</span><span class="src-sym">; </span></li>
<li><a name="a69"></a>    <span class="src-var">$e </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a70"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a71"></a>    <span class="src-sym">}</span></li>
<li><a name="a72"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;delete from gmcache&quot;</span><span class="src-sym">;            </span></li>
<li><a name="a73"></a>    <span class="src-var">$e </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a74"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a75"></a>    <span class="src-sym">}</span></li>
<li><a name="a76"></a>&nbsp;</li>
<li><a name="a77"></a>&nbsp;</li>
<li><a name="a78"></a><span class="src-sym">}</span></li>
<li><a name="a79"></a>&nbsp;</li>
<li><a name="a80"></a><span class="src-doc">/**</span></li>
<li><a name="a81"></a><span class="src-doc">* Deletes information about a bot in the cache and bot tables.</span></li>
<li><a name="a82"></a><span class="src-doc">*</span></li>
<li><a name="a83"></a><span class="src-doc">* Used by the incremental bot loader program so it doesn't wipe out the whole</span></li>
<li><a name="a84"></a><span class="src-doc">* bot on each aiml file load. Deletes everything in bot, bots and gmcache tables.</span></li>
<li><a name="a85"></a><span class="src-doc">* </span></li>
<li><a name="a86"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$bot </span><span class="src-doc">            The bot's ID.</span></li>
<li><a name="a87"></a><span class="src-doc">*</span></li>
<li><a name="a88"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a89"></a><span class="src-doc">*/</span></li>
<li><a name="a90"></a>&nbsp;</li>
<li><a name="a91"></a><span class="src-comm">// </span></li>
<li><a name="a92"></a><span class="src-comm">// </span></li>
<li><a name="a92"></a>&nbsp;</li>
<li><a name="a93"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functiondeletejustbot">deletejustbot</a><span class="src-sym">(</span><span class="src-var">$bot</span><span class="src-sym">)</span><span class="src-sym">{            </span></li>
<li><a name="a94"></a>&nbsp;</li>
<li><a name="a95"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">delete</span> <span class="src-id">from</span> <span class="src-id">bots</span> <span class="src-id">where</span> <span class="src-id">id</span>=<span class="src-var">$bot</span></span><span class="src-str">&quot;</span><span class="src-sym">; </span></li>
<li><a name="a96"></a>    <span class="src-var">$e </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a97"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a98"></a>    <span class="src-sym">}</span></li>
<li><a name="a99"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">delete</span> <span class="src-id">from</span> <span class="src-id">bot</span> <span class="src-id">where</span> <span class="src-id">bot</span>=<span class="src-var">$bot</span></span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a100"></a>    <span class="src-var">$e </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a101"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a102"></a>    <span class="src-sym">}</span></li>
<li><a name="a103"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;delete from gmcache&quot;</span><span class="src-sym">;            </span></li>
<li><a name="a104"></a>    <span class="src-var">$e </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a105"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a106"></a>    <span class="src-sym">}</span></li>
<li><a name="a107"></a>&nbsp;</li>
<li><a name="a108"></a><span class="src-sym">}</span></li>
<li><a name="a109"></a>&nbsp;</li>
<li><a name="a110"></a><span class="src-doc">/** </span></li>
<li><a name="a111"></a><span class="src-doc">* Deletes the gmcache table.</span></li>
<li><a name="a112"></a><span class="src-doc">*</span></li>
<li><a name="a113"></a><span class="src-doc">* This needs to be called whenever the patterns or templates table is updated.</span></li>
<li><a name="a114"></a><span class="src-doc">*</span></li>
<li><a name="a115"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a116"></a><span class="src-doc">*/</span></li>
<li><a name="a117"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionflushcache">flushcache</a><span class="src-sym">(</span><span class="src-sym">)</span></li>
<li><a name="a118"></a><span class="src-sym">{</span></li>
<li><a name="a119"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;delete from gmcache&quot;</span><span class="src-sym">;            </span></li>
<li><a name="a120"></a>    <span class="src-var">$e </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a121"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$e</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a122"></a>    <span class="src-sym">}</span></li>
<li><a name="a123"></a><span class="src-sym">}</span></li>
<li><a name="a124"></a>&nbsp;</li>
<li><a name="a125"></a><span class="src-doc">/**</span></li>
<li><a name="a126"></a><span class="src-doc">* Makes the keys of an array uppercase.</span></li>
<li><a name="a127"></a><span class="src-doc">*</span></li>
<li><a name="a128"></a><span class="src-doc">* Makes the keys of an array uppercase.</span></li>
<li><a name="a129"></a><span class="src-doc">*</span></li>
<li><a name="a130"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$testa </span><span class="src-doc">          The array where the keys need to be changed into uppercase.</span></li>
<li><a name="a131"></a><span class="src-doc">*</span></li>
<li><a name="a132"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">array </span><span class="src-doc">                An array with only uppercase keys.</span></li>
<li><a name="a133"></a><span class="src-doc">*/</span></li>
<li><a name="a134"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionupperkeysarray">upperkeysarray</a><span class="src-sym">(</span><span class="src-var">$testa</span><span class="src-sym">)</span></li>
<li><a name="a135"></a><span class="src-sym">{</span></li>
<li><a name="a136"></a>    <span class="src-var">$newtesta</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a137"></a>    <span class="src-var">$newkeys</span>=<a href="http://www.php.net/array_keys">array_keys</a><span class="src-sym">(</span><span class="src-var">$testa</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a138"></a>    <span class="src-key">for </span><span class="src-sym">(</span><span class="src-var">$x</span>=<span class="src-num">0</span><span class="src-sym">;</span><span class="src-var">$x</span>&lt;<a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$newkeys</span><span class="src-sym">)</span><span class="src-sym">;</span><span class="src-var">$x</span>++<span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a139"></a>        <span class="src-var">$newtesta</span><span class="src-sym">[</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$newkeys</span><span class="src-sym">[</span><span class="src-var">$x</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">]</span>=<span class="src-var">$testa</span><span class="src-sym">[</span><span class="src-var">$newkeys</span><span class="src-sym">[</span><span class="src-var">$x</span><span class="src-sym">]]</span><span class="src-sym">;</span></li>
<li><a name="a140"></a>    <span class="src-sym">}</span></li>
<li><a name="a141"></a>    <span class="src-key">return </span><span class="src-var">$newtesta</span><span class="src-sym">;</span></li>
<li><a name="a142"></a><span class="src-sym">}</span></li>
<li><a name="a143"></a>&nbsp;</li>
<li><a name="a144"></a><span class="src-doc">/**</span></li>
<li><a name="a145"></a><span class="src-doc">* Write the substitution include file</span></li>
<li><a name="a146"></a><span class="src-doc">*</span></li>
<li><a name="a147"></a><span class="src-doc">* Write the substitution arrays back into the subs.inc</span></li>
<li><a name="a148"></a><span class="src-doc">*</span></li>
<li><a name="a149"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">object </span><span class="src-doc">                </span><span class="src-doc-type">The </span><span class="src-doc">opened subs.inc file, ready to write to.</span></li>
<li><a name="a150"></a><span class="src-doc">*</span></li>
<li><a name="a151"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$string </span><span class="src-doc">         most likely an array or all arrays turned into a big file.</span></li>
<li><a name="a152"></a><span class="src-doc">*</span></li>
<li><a name="a153"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a154"></a><span class="src-doc">*/</span></li>
<li><a name="a155"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionaddtosubs">addtosubs</a><span class="src-sym">(</span><span class="src-var">$string</span><span class="src-sym">)</span></li>
<li><a name="a156"></a><span class="src-sym">{</span></li>
<li><a name="a157"></a>&nbsp;</li>
<li><a name="a158"></a>    <span class="src-key">global </span><span class="src-var">$fp</span><span class="src-sym">;</span></li>
<li><a name="a159"></a>&nbsp;</li>
<li><a name="a160"></a>    <a href="http://www.php.net/fwrite">fwrite</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">,</span><span class="src-var">$string</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a161"></a>&nbsp;</li>
<li><a name="a162"></a><span class="src-sym">}</span></li>
<li><a name="a163"></a>&nbsp;</li>
<li><a name="a164"></a><span class="src-doc">/** </span></li>
<li><a name="a165"></a><span class="src-doc">* Create the object for writing the substitution include file</span></li>
<li><a name="a166"></a><span class="src-doc">*</span></li>
<li><a name="a167"></a><span class="src-doc">* Creates the object, which is then used by addtosubs() to write to</span></li>
<li><a name="a168"></a><span class="src-doc">*</span></li>
<li><a name="a169"></a><span class="src-doc">* </span><span class="src-doc-coretag">@see</span><span class="src-doc"> addtosubs()</span></li>
<li><a name="a170"></a><span class="src-doc">* </span><span class="src-doc-coretag">@see</span><span class="src-doc"> makesubscode()</span></li>
<li><a name="a171"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">object </span></li>
<li><a name="a172"></a><span class="src-doc">*</span></li>
<li><a name="a173"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a174"></a><span class="src-doc">*/</span></li>
<li><a name="a175"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functioncreatesubfile">createsubfile</a><span class="src-sym">(</span><span class="src-sym">)</span></li>
<li><a name="a176"></a><span class="src-sym">{</span></li>
<li><a name="a177"></a>&nbsp;</li>
<li><a name="a178"></a>    <span class="src-key">global </span><span class="src-var">$fp</span><span class="src-sym">;</span></li>
<li><a name="a179"></a>&nbsp;</li>
<li><a name="a180"></a>    <span class="src-var">$fp </span>= <a href="http://www.php.net/fopen">fopen</a> <span class="src-sym">(</span><span class="src-str">&quot;subs.inc&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;w+&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a181"></a>&nbsp;</li>
<li><a name="a182"></a><span class="src-sym">}</span></li>
<li><a name="a183"></a>&nbsp;</li>
<li><a name="a184"></a><span class="src-doc">/**</span></li>
<li><a name="a185"></a><span class="src-doc">* Find a word in the patterns table given the word and the parent.</span></li>
<li><a name="a186"></a><span class="src-doc">*</span></li>
<li><a name="a187"></a><span class="src-doc">* The AIML patterns are stored in the MySQL table in a binary tree format.</span></li>
<li><a name="a188"></a><span class="src-doc">* This function retrieves the next word details based upon the previous' word's ID.</span></li>
<li><a name="a189"></a><span class="src-doc">* If this word doesn't exist it returns 0, else it returns it's details.</span></li>
<li><a name="a190"></a><span class="src-doc">*</span></li>
<li><a name="a191"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> setnotend()</span></li>
<li><a name="a192"></a><span class="src-doc">*</span></li>
<li><a name="a193"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$word </span><span class="src-doc">            The word that is to be searched</span></li>
<li><a name="a194"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$parent </span><span class="src-doc">         The ID of the parent word</span></li>
<li><a name="a195"></a><span class="src-doc">* </span></li>
<li><a name="a196"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">integer </span><span class="src-doc">                The ID of the word that was searched</span></li>
<li><a name="a197"></a><span class="src-doc">*/</span></li>
<li><a name="a198"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionfindwordid">findwordid</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">,</span><span class="src-var">$parent</span><span class="src-sym">)</span></li>
<li><a name="a199"></a><span class="src-sym">{</span></li>
<li><a name="a200"></a>&nbsp;</li>
<li><a name="a201"></a>    <span class="src-var">$word</span>=<a href="http://www.php.net/addslashes">addslashes</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a202"></a>    <span class="src-var">$query</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">select</span> <span class="src-id">id</span>,<span class="src-id">isend</span> <span class="src-id">from</span> <span class="src-id">patterns</span> <span class="src-id">where</span> <span class="src-id">word</span>='<span class="src-var">$word</span>' <span class="src-id">and</span> <span class="src-id">parent</span>=<span class="src-var">$parent</span></span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a203"></a>&nbsp;</li>
<li><a name="a204"></a>    <span class="src-var">$selectcode </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$query</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a205"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a206"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/mysql_numrows">mysql_numrows</a><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a207"></a>            <span class="src-key">return </span><span class="src-num">0</span><span class="src-sym">;</span></li>
<li><a name="a208"></a>        <span class="src-sym">}</span></li>
<li><a name="a209"></a>        <span class="src-key">else</span><span class="src-sym">{</span></li>
<li><a name="a210"></a>            <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$q </span>= <a href="http://www.php.net/mysql_fetch_array">mysql_fetch_array</a><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a211"></a>                </li>
<li><a name="a212"></a>                <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span>==<span class="src-num">1</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a213"></a>                    <a href="../Loader/_admin_botloaderfuncs_php.html#functionsetnotend">setnotend</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a214"></a>                <span class="src-sym">}</span></li>
<li><a name="a215"></a>&nbsp;</li>
<li><a name="a216"></a>                <span class="src-key">return </span><span class="src-var">$q</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a217"></a>            <span class="src-sym">}</span></li>
<li><a name="a218"></a>        <span class="src-sym">}</span></li>
<li><a name="a219"></a>    <span class="src-sym">}</span></li>
<li><a name="a220"></a><span class="src-sym">}</span></li>
<li><a name="a221"></a>&nbsp;</li>
<li><a name="a222"></a><span class="src-doc">/**</span></li>
<li><a name="a223"></a><span class="src-doc">* Find a wildcard in the patterns table given the word and the parent.</span></li>
<li><a name="a224"></a><span class="src-doc">*</span></li>
<li><a name="a225"></a><span class="src-doc">* Similar as findwordid() but this will retrieve the ID if there is a wildcard that fits.</span></li>
<li><a name="a226"></a><span class="src-doc">*</span></li>
<li><a name="a227"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> setnotend()</span></li>
<li><a name="a228"></a><span class="src-doc">*</span></li>
<li><a name="a229"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$word </span><span class="src-doc">            The word that is to be searched, either _ or *</span></li>
<li><a name="a230"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$parent </span><span class="src-doc">         The ID of the parent word</span></li>
<li><a name="a231"></a><span class="src-doc">* </span></li>
<li><a name="a232"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">integer </span><span class="src-doc">                The ID of the word that was searched</span></li>
<li><a name="a233"></a><span class="src-doc">*/</span></li>
<li><a name="a234"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionfindwordidstar">findwordidstar</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">,</span><span class="src-var">$parent</span><span class="src-sym">)</span></li>
<li><a name="a235"></a><span class="src-sym">{</span></li>
<li><a name="a236"></a>&nbsp;</li>
<li><a name="a237"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$word</span>==<span class="src-str">&quot;*&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a238"></a>        <span class="src-var">$val</span>=<span class="src-num">3</span><span class="src-sym">;</span></li>
<li><a name="a239"></a>    <span class="src-sym">}</span></li>
<li><a name="a240"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><span class="src-var">$word</span>==<span class="src-str">&quot;_&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a241"></a>        <span class="src-var">$val</span>=<span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a242"></a>    <span class="src-sym">}</span></li>
<li><a name="a243"></a>    <span class="src-var">$query</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">select</span> <span class="src-id">id</span>,<span class="src-id">isend</span> <span class="src-id">from</span> <span class="src-id">patterns</span> <span class="src-id">where</span> <span class="src-id">parent</span>=<span class="src-var">$parent</span> <span class="src-id">and</span> <span class="src-id">word</span> <span class="src-id">is</span> <span class="src-id">null</span> <span class="src-id">and</span> <span class="src-id">ordera</span>=<span class="src-var">$val</span></span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a244"></a>    </li>
<li><a name="a245"></a>    <span class="src-var">$selectcode </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$query</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a246"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a247"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/mysql_numrows">mysql_numrows</a><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a248"></a>            <span class="src-key">return </span><span class="src-num">0</span><span class="src-sym">;</span></li>
<li><a name="a249"></a>        <span class="src-sym">}</span></li>
<li><a name="a250"></a>        <span class="src-key">else</span><span class="src-sym">{</span></li>
<li><a name="a251"></a>            <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$q </span>= <a href="http://www.php.net/mysql_fetch_array">mysql_fetch_array</a><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a252"></a>                </li>
<li><a name="a253"></a>                <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span>==<span class="src-num">1</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a254"></a>                    <a href="../Loader/_admin_botloaderfuncs_php.html#functionsetnotend">setnotend</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a255"></a>                <span class="src-sym">}</span></li>
<li><a name="a256"></a>                </li>
<li><a name="a257"></a>                <span class="src-key">return </span><span class="src-var">$q</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a258"></a>            <span class="src-sym">}</span></li>
<li><a name="a259"></a>        <span class="src-sym">}</span></li>
<li><a name="a260"></a>    <span class="src-sym">}</span></li>
<li><a name="a261"></a><span class="src-sym">}</span></li>
<li><a name="a262"></a>&nbsp;</li>
<li><a name="a263"></a>&nbsp;</li>
<li><a name="a264"></a><span class="src-doc">/**</span></li>
<li><a name="a265"></a><span class="src-doc">* Set an entry in the patterns table to not be flagged as the last word in its context.</span></li>
<li><a name="a266"></a><span class="src-doc">*</span></li>
<li><a name="a267"></a><span class="src-doc">* Update a record in the patterns table, change isend column from 1 to 0. Given a particular word ID.</span></li>
<li><a name="a268"></a><span class="src-doc">* </span></li>
<li><a name="a269"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$wordid </span></li>
<li><a name="a270"></a><span class="src-doc">*</span></li>
<li><a name="a271"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a272"></a><span class="src-doc">*/</span></li>
<li><a name="a273"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionsetnotend">setnotend</a><span class="src-sym">(</span><span class="src-var">$wordid</span><span class="src-sym">)</span></li>
<li><a name="a274"></a><span class="src-sym">{</span></li>
<li><a name="a275"></a>&nbsp;</li>
<li><a name="a276"></a>    <span class="src-var">$query</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">update</span> <span class="src-id">patterns</span> <span class="src-id">set</span> <span class="src-id">isend</span>=0 <span class="src-id">where</span> <span class="src-id">id</span>=<span class="src-var">$wordid</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a277"></a>    <span class="src-var">$q</span>=<a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$query</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a278"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a279"></a>&nbsp;</li>
<li><a name="a280"></a>    <span class="src-sym">}</span></li>
<li><a name="a281"></a>&nbsp;</li>
<li><a name="a282"></a><span class="src-sym">}</span></li>
<li><a name="a283"></a>&nbsp;</li>
<li><a name="a284"></a><span class="src-doc">/**</span></li>
<li><a name="a285"></a><span class="src-doc">* Inserts the pattern into the patterns table.</span></li>
<li><a name="a286"></a><span class="src-doc">*</span></li>
<li><a name="a287"></a><span class="src-doc">* inserts the pattern, that and topic as individual words in binary tree format into the patterns table</span></li>
<li><a name="a288"></a><span class="src-doc">* </span></li>
<li><a name="a289"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> findwordid()</span></li>
<li><a name="a290"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> insertwordpattern()</span></li>
<li><a name="a291"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> findwordidstar()</span></li>
<li><a name="a292"></a><span class="src-doc">*</span></li>
<li><a name="a293"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a294"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span></li>
<li><a name="a295"></a><span class="src-doc">*</span></li>
<li><a name="a296"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$mybigsentence </span><span class="src-doc">         Contains the pattern, that and topic in the following format &lt;input&gt;word word&lt;that&gt;word word&lt;topic&gt;word word.</span></li>
<li><a name="a297"></a><span class="src-doc">*/</span></li>
<li><a name="a298"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functioninsertmysentence">insertmysentence</a><span class="src-sym">(</span><span class="src-var">$mybigsentence</span><span class="src-sym">)</span></li>
<li><a name="a299"></a><span class="src-sym">{</span></li>
<li><a name="a300"></a>    <span class="src-key">global </span><span class="src-var">$selectbot</span><span class="src-sym">, </span><span class="src-var">$annesID</span><span class="src-sym">;        </span></li>
<li><a name="a301"></a>&nbsp;</li>
<li><a name="a302"></a>    <span class="src-var">$sentencepart</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a303"></a>&nbsp;</li>
<li><a name="a304"></a>    <span class="src-var">$newstarted</span>=<span class="src-num">0</span><span class="src-sym">;</span></li>
<li><a name="a305"></a>    <span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$annesID </span>!= <span class="src-str">&quot;&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a306"></a>    <span class="src-var">$parent </span>= <span class="src-var">$annesID</span><span class="src-sym">;</span></li>
<li><a name="a307"></a>    <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a308"></a>    <span class="src-var">$parent</span>=-<span class="src-var">$selectbot</span><span class="src-sym">;</span></li>
<li><a name="a309"></a>    <span class="src-sym">}</span></li>
<li><a name="a310"></a>&nbsp;</li>
<li><a name="a311"></a>    <span class="src-comm">//Parse into invidividual words</span></li>
<li><a name="a312"></a>    <span class="src-comm">//Use split</span></li>
<li><a name="a313"></a>    <span class="src-var">$allwords</span>=<a href="http://www.php.net/split">split</a><span class="src-sym">(</span><span class="src-str">&quot; &quot;</span><span class="src-sym">,</span><span class="src-var">$mybigsentence</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a314"></a>    <span class="src-var">$qadd</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a315"></a>    <span class="src-key">for </span><span class="src-sym">(</span><span class="src-var">$x</span>=<span class="src-num">0</span><span class="src-sym">;</span><span class="src-var">$x</span>&lt;<a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$allwords</span><span class="src-sym">)</span>+<span class="src-num">1</span><span class="src-sym">;</span><span class="src-var">$x</span>++<span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a316"></a>&nbsp;</li>
<li><a name="a317"></a>        <span class="src-comm">// Last word in context</span></li>
<li><a name="a318"></a>        <span class="src-var">$lwic</span>=<span class="src-num">0</span><span class="src-sym">;</span></li>
<li><a name="a319"></a>&nbsp;</li>
<li><a name="a320"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$x</span>==<a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$allwords</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a321"></a>            <span class="src-var">$word</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a322"></a>        <span class="src-sym">}</span></li>
<li><a name="a323"></a>        <span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a324"></a>            <span class="src-var">$word</span>=<span class="src-var">$allwords</span><span class="src-sym">[</span><span class="src-var">$x</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a325"></a>        <span class="src-sym">}</span></li>
<li><a name="a326"></a>        </li>
<li><a name="a327"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">)</span>==<span class="src-str">&quot;&lt;INPUT&gt;&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a328"></a>            <span class="src-var">$sentencepart</span>=<span class="src-str">&quot;INPUT&quot;</span><span class="src-sym">;</span></li>
<li><a name="a329"></a>        <span class="src-sym">} </span><span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">)</span>==<span class="src-str">&quot;&lt;THAT&gt;&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a330"></a>            <span class="src-var">$sentencepart</span>=<span class="src-str">&quot;THAT&quot;</span><span class="src-sym">;</span></li>
<li><a name="a331"></a>        <span class="src-sym">} </span><span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">)</span>==<span class="src-str">&quot;&lt;TOPIC&gt;&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a332"></a>            <span class="src-var">$sentencepart</span>=<span class="src-str">&quot;TOPIC&quot;</span><span class="src-sym">;</span></li>
<li><a name="a333"></a>        <span class="src-sym">}</span></li>
<li><a name="a334"></a>        </li>
<li><a name="a335"></a>        <span class="src-comm">// Find out if it is the last word in its context</span></li>
<li><a name="a336"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$x</span>==<span class="src-sym">(</span><a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$allwords</span><span class="src-sym">)</span>-<span class="src-num">1</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a337"></a>            <span class="src-var">$lwic</span>=<span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a338"></a>        <span class="src-sym">}</span></li>
<li><a name="a339"></a>        <span class="src-comm">// Prevent some warnings by checking this first.</span></li>
<li><a name="a340"></a>        <span class="src-key">elseif </span><span class="src-sym">((</span><span class="src-var">$x</span>+<span class="src-num">1</span><span class="src-sym">) </span>&gt;= <span class="src-sym">(</span><a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$allwords</span><span class="src-sym">)))</span><span class="src-sym">{</span></li>
<li><a name="a341"></a>        </li>
<li><a name="a342"></a>        <span class="src-sym">}</span></li>
<li><a name="a343"></a>        <span class="src-key">elseif </span><span class="src-sym">((</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$allwords</span><span class="src-sym">[</span><span class="src-var">$x</span>+<span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">)</span>==<span class="src-str">&quot;&lt;THAT&gt;&quot;</span><span class="src-sym">) </span>|| <span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$allwords</span><span class="src-sym">[</span><span class="src-var">$x</span>+<span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">)</span>==<span class="src-str">&quot;&lt;TOPIC&gt;&quot;</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a344"></a>            <span class="src-var">$lwic</span>=<span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a345"></a>        <span class="src-sym">}</span></li>
<li><a name="a346"></a>        </li>
<li><a name="a347"></a>        <span class="src-key">if </span><span class="src-sym">((</span><span class="src-var">$word</span>!=<span class="src-str">&quot;*&quot;</span><span class="src-sym">)</span>&amp;&amp;<span class="src-sym">(</span><span class="src-var">$word</span>!=<span class="src-str">&quot;_&quot;</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a348"></a>&nbsp;</li>
<li><a name="a349"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$newstarted</span>!=<span class="src-num">1</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a350"></a>                <span class="src-var">$wordid</span>=<a href="../Loader/_admin_botloaderfuncs_php.html#functionfindwordid">findwordid</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">,</span><span class="src-var">$parent</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a351"></a>            <span class="src-sym">}</span></li>
<li><a name="a352"></a>            </li>
<li><a name="a353"></a>            <span class="src-key">if </span><span class="src-sym">((</span><span class="src-var">$wordid</span>!=<span class="src-num">0</span><span class="src-sym">) </span>&amp;&amp; <span class="src-sym">(</span><span class="src-var">$newstarted</span>!=<span class="src-num">1</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a354"></a>                <span class="src-var">$parent</span>=<span class="src-var">$wordid</span><span class="src-sym">;</span></li>
<li><a name="a355"></a>            <span class="src-sym">}</span></li>
<li><a name="a356"></a>            <span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a357"></a>                </li>
<li><a name="a358"></a>                <span class="src-var">$newstarted</span>=<span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a359"></a>&nbsp;</li>
<li><a name="a360"></a>                <span class="src-var">$sword</span>=<a href="http://www.php.net/addslashes">addslashes</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a361"></a>                <span class="src-var">$qadd</span>=<span class="src-str">&quot;</span><span class="src-str">(<span class="src-var">$selectbot</span>, <span class="src-id">null</span>,'<span class="src-var">$sword</span>',2,<span class="src-var">$parent</span>,<span class="src-var">$lwic</span>)</span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a362"></a>&nbsp;</li>
<li><a name="a363"></a>                <span class="src-var">$parent </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functioninsertwordpattern">insertwordpattern</a><span class="src-sym">(</span><span class="src-var">$qadd</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a364"></a>        </li>
<li><a name="a365"></a>&nbsp;</li>
<li><a name="a366"></a>&nbsp;</li>
<li><a name="a367"></a>            <span class="src-sym">}</span></li>
<li><a name="a368"></a>        <span class="src-sym">}</span></li>
<li><a name="a369"></a>        <span class="src-key">elseif </span><span class="src-sym">((</span><span class="src-var">$word</span>==<span class="src-str">&quot;*&quot;</span><span class="src-sym">)</span>||<span class="src-sym">(</span><span class="src-var">$word</span>==<span class="src-str">&quot;_&quot;</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a370"></a>&nbsp;</li>
<li><a name="a371"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$newstarted</span>!=<span class="src-num">1</span><span class="src-sym">)</span><span class="src-sym">{            </span></li>
<li><a name="a372"></a>                <span class="src-var">$wordid</span>=<a href="../Loader/_admin_botloaderfuncs_php.html#functionfindwordidstar">findwordidstar</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">,</span><span class="src-var">$parent</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a373"></a>            <span class="src-sym">}</span></li>
<li><a name="a374"></a>            </li>
<li><a name="a375"></a>            <span class="src-key">if </span><span class="src-sym">((</span><span class="src-var">$wordid</span>!=<span class="src-num">0</span><span class="src-sym">) </span>&amp;&amp; <span class="src-sym">(</span><span class="src-var">$newstarted</span>!=<span class="src-num">1</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a376"></a>                <span class="src-var">$parent</span>=<span class="src-var">$wordid</span><span class="src-sym">;</span></li>
<li><a name="a377"></a>            <span class="src-sym">}</span></li>
<li><a name="a378"></a>            <span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a379"></a>                </li>
<li><a name="a380"></a>                <span class="src-var">$newstarted</span>=<span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a381"></a>&nbsp;</li>
<li><a name="a382"></a>                <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$word</span>==<span class="src-str">&quot;*&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a383"></a>                    <span class="src-var">$val</span>=<span class="src-num">3</span><span class="src-sym">;</span></li>
<li><a name="a384"></a>                <span class="src-sym">}</span></li>
<li><a name="a385"></a>                <span class="src-key">elseif </span><span class="src-sym">(</span><span class="src-var">$word</span>==<span class="src-str">&quot;_&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a386"></a>                    <span class="src-var">$val</span>=<span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a387"></a>                <span class="src-sym">}</span></li>
<li><a name="a388"></a>&nbsp;</li>
<li><a name="a389"></a>                <span class="src-var">$qadd</span>=<span class="src-str">&quot;</span><span class="src-str">(<span class="src-var">$selectbot</span>, <span class="src-id">null</span>,<span class="src-id">null</span>,<span class="src-var">$val</span>,<span class="src-var">$parent</span>,<span class="src-var">$lwic</span>)</span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a390"></a>&nbsp;</li>
<li><a name="a391"></a>                <span class="src-var">$parent </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functioninsertwordpattern">insertwordpattern</a><span class="src-sym">(</span><span class="src-var">$qadd</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a392"></a>&nbsp;</li>
<li><a name="a393"></a>&nbsp;</li>
<li><a name="a394"></a>                </li>
<li><a name="a395"></a>            <span class="src-sym">}</span></li>
<li><a name="a396"></a>        <span class="src-sym">}</span></li>
<li><a name="a397"></a>    <span class="src-sym">}</span></li>
<li><a name="a398"></a>&nbsp;</li>
<li><a name="a399"></a>    <span class="src-key">return </span><span class="src-var">$parent</span><span class="src-sym">;</span></li>
<li><a name="a400"></a>&nbsp;</li>
<li><a name="a401"></a><span class="src-sym">}</span></li>
<li><a name="a402"></a>&nbsp;</li>
<li><a name="a403"></a><span class="src-doc">/**</span></li>
<li><a name="a404"></a><span class="src-doc">* Inserts an entry into the patterns table. Returns the ID of the new row inserted.</span></li>
<li><a name="a405"></a><span class="src-doc">*</span></li>
<li><a name="a406"></a><span class="src-doc">* insert a word into the patterns table, returns the id of the record so it can be</span></li>
<li><a name="a407"></a><span class="src-doc">* used as the parent ID of the next word that's to be inserted.</span></li>
<li><a name="a408"></a><span class="src-doc">*</span></li>
<li><a name="a409"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$qadd </span><span class="src-doc">                The word of the pattern to be inserted</span></li>
<li><a name="a410"></a><span class="src-doc">*</span></li>
<li><a name="a411"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">integer </span><span class="src-doc">                    The record ID of the inserted word.</span></li>
<li><a name="a412"></a><span class="src-doc">*/</span></li>
<li><a name="a413"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functioninsertwordpattern">insertwordpattern</a><span class="src-sym">(</span><span class="src-var">$qadd</span><span class="src-sym">)</span></li>
<li><a name="a414"></a><span class="src-sym">{</span></li>
<li><a name="a415"></a>&nbsp;</li>
<li><a name="a416"></a>    <span class="src-var">$qcode</span>=<a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str"><span class="src-id">insert</span> <span class="src-id">into</span> <span class="src-id">patterns</span>(<span class="src-id">bot</span>,<span class="src-id">id</span>,<span class="src-id">word</span>,<span class="src-id">ordera</span>,<span class="src-id">parent</span>,<span class="src-id">isend</span>) <span class="src-id">values</span> <span class="src-var">$qadd</span></span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a417"></a>&nbsp;</li>
<li><a name="a418"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$qcode</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a419"></a>&nbsp;</li>
<li><a name="a420"></a>        <span class="src-key">return </span><a href="http://www.php.net/mysql_insert_id">mysql_insert_id</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a421"></a>    <span class="src-sym">}</span></li>
<li><a name="a422"></a>    </li>
<li><a name="a423"></a><span class="src-sym">}</span></li>
<li><a name="a424"></a>&nbsp;</li>
<li><a name="a425"></a><span class="src-doc">/**</span></li>
<li><a name="a426"></a><span class="src-doc">* Inserts a template into the template table.</span></li>
<li><a name="a427"></a><span class="src-doc">*</span></li>
<li><a name="a428"></a><span class="src-doc">* Insert the template into the template database. &lt;br/&gt;</span></li>
<li><a name="a429"></a><span class="src-doc">* This version has been adapted to also insert the pattern, that and topic into the additionally added columns</span></li>
<li><a name="a430"></a><span class="src-doc">*</span></li>
<li><a name="a431"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> templateexists()</span></li>
<li><a name="a432"></a><span class="src-doc">*</span></li>
<li><a name="a433"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span></li>
<li><a name="a434"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span><span class="src-doc">             The ID of the record in the patterns table that links to this table</span></li>
<li><a name="a435"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">              The pattern, including variables like _ and *.</span></li>
<li><a name="a436"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">              the topic, including variable like _ and *</span></li>
<li><a name="a437"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">              the that, including variables like _ and *</span></li>
<li><a name="a438"></a><span class="src-doc">*</span></li>
<li><a name="a439"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$idused </span><span class="src-doc">      The ID of the record in the patterns table that links to the template table.</span></li>
<li><a name="a440"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$template </span><span class="src-doc">     The contents inbetween &lt;template/&gt; tags.</span></li>
<li><a name="a441"></a><span class="src-doc">*</span></li>
<li><a name="a442"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a443"></a><span class="src-doc">*/</span></li>
<li><a name="a444"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functioninsertmytemplate">insertmytemplate</a><span class="src-sym">(</span><span class="src-var">$idused</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span></li>
<li><a name="a445"></a><span class="src-sym">{</span></li>
<li><a name="a446"></a>    </li>
<li><a name="a447"></a>    <span class="src-key">global </span><span class="src-var">$selectbot</span><span class="src-sym">,</span><span class="src-var">$templatesinserted</span><span class="src-sym">, </span><span class="src-var">$pattern</span><span class="src-sym">, </span><span class="src-var">$topic</span><span class="src-sym">, </span><span class="src-var">$that</span><span class="src-sym">;</span></li>
<li><a name="a448"></a>    </li>
<li><a name="a449"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><a href="../Loader/_admin_botloaderfuncs_php.html#functiontemplateexists">templateexists</a><span class="src-sym">(</span><span class="src-var">$idused</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a450"></a>        <span class="src-var">$templatesinserted</span>++<span class="src-sym">;</span></li>
<li><a name="a451"></a>&nbsp;</li>
<li><a name="a452"></a>        <span class="src-var">$template</span>=<a href="http://www.php.net/addslashes">addslashes</a><span class="src-sym">(</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a453"></a>        <span class="src-var">$query</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">insert</span> <span class="src-id">into</span> <span class="src-id">templates</span> (<span class="src-id">bot</span>,<span class="src-id">id</span>,<span class="src-id">template</span>,<span class="src-id">pattern</span>,<span class="src-id">that</span>,<span class="src-id">topic</span>) <span class="src-id">values</span> (<span class="src-var">$selectbot</span>, <span class="src-var">$idused</span>,'<span class="src-var">$template</span>','<span class="src-var">$pattern</span>','<span class="src-var">$that</span>','<span class="src-var">$topic</span>')</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a454"></a>&nbsp;</li>
<li><a name="a455"></a>        <span class="src-var">$qcode</span>=<a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$query</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a456"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$qcode</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a457"></a>        <span class="src-sym">}</span></li>
<li><a name="a458"></a>    <span class="src-sym">}</span></li>
<li><a name="a459"></a>&nbsp;</li>
<li><a name="a460"></a><span class="src-sym">}</span></li>
<li><a name="a461"></a>&nbsp;</li>
<li><a name="a462"></a><span class="src-doc">/**</span></li>
<li><a name="a463"></a><span class="src-doc">* Checks if a template exists for a given pattern</span></li>
<li><a name="a464"></a><span class="src-doc">*</span></li>
<li><a name="a465"></a><span class="src-doc">* Does a query on the database to see if an ID is used by a template in the templates table.</span></li>
<li><a name="a466"></a><span class="src-doc">*</span></li>
<li><a name="a467"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$idused </span><span class="src-doc">        The ID number that corresponds to the number in the ID column, if it exists.</span></li>
<li><a name="a468"></a><span class="src-doc">*</span></li>
<li><a name="a469"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">boolean </span><span class="src-doc">               true/false</span></li>
<li><a name="a470"></a><span class="src-doc">*/</span></li>
<li><a name="a471"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functiontemplateexists">templateexists</a><span class="src-sym">(</span><span class="src-var">$idused</span><span class="src-sym">)</span></li>
<li><a name="a472"></a><span class="src-sym">{</span></li>
<li><a name="a473"></a>    <span class="src-var">$query</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">select</span> <span class="src-id">id</span> <span class="src-id">from</span> <span class="src-id">templates</span> <span class="src-id">where</span> <span class="src-id">id</span>=<span class="src-var">$idused</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a474"></a>&nbsp;</li>
<li><a name="a475"></a>    <span class="src-var">$qcode</span>=<a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$query</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a476"></a>&nbsp;</li>
<li><a name="a477"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$qcode</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a478"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/mysql_numrows">mysql_numrows</a><span class="src-sym">(</span><span class="src-var">$qcode</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a479"></a>            <span class="src-key">return </span><span class="src-id">false</span><span class="src-sym">;</span></li>
<li><a name="a480"></a>        <span class="src-sym">}</span></li>
<li><a name="a481"></a>    <span class="src-sym">}</span></li>
<li><a name="a482"></a>&nbsp;</li>
<li><a name="a483"></a>    <span class="src-key">return </span><span class="src-id">true</span><span class="src-sym">;</span></li>
<li><a name="a484"></a>&nbsp;</li>
<li><a name="a485"></a><span class="src-sym">}</span></li>
<li><a name="a486"></a>&nbsp;</li>
<li><a name="a487"></a><span class="src-doc">/**</span></li>
<li><a name="a488"></a><span class="src-doc">* Called by the XML parser that is parsing the startup.xml file.</span></li>
<li><a name="a489"></a><span class="src-doc">*</span></li>
<li><a name="a490"></a><span class="src-doc">* startS and endS are two functions that cooperate. startS looks for the start of an XML tag, endS for the end tag.</span></li>
<li><a name="a491"></a><span class="src-doc">* It fills the global variabls with info to be processed further on. Inserts the bots into the bots table, inserts the bot predicates into its respective table.</span></li>
<li><a name="a492"></a><span class="src-doc">*</span></li>
<li><a name="a493"></a><span class="src-doc">* </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> Find out what Global $areinc does</span></li>
<li><a name="a494"></a><span class="src-doc">*</span></li>
<li><a name="a495"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> upperkeysarray()</span></li>
<li><a name="a496"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> botexists()</span></li>
<li><a name="a497"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> getbotid()</span></li>
<li><a name="a498"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> deletebot()</span></li>
<li><a name="a499"></a><span class="src-doc">*</span></li>
<li><a name="a500"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span></li>
<li><a name="a501"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a502"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span></li>
<li><a name="a503"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">                 contains the splitter characters which are used to split the sentences. For example period, comma, semi-colon, exclamation mark, question mark.</span></li>
<li><a name="a504"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">                 contains the input, split into sentences</span></li>
<li><a name="a505"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">                 contains the gender words or phrases.</span></li>
<li><a name="a506"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">                 contains the person words or phrases</span></li>
<li><a name="a507"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">                 contains the person2 words or phrases</span></li>
<li><a name="a508"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">                 contains the names of all the bots, or their ID's</span></li>
<li><a name="a509"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">                 contains something unknown</span></li>
<li><a name="a510"></a><span class="src-doc">*</span></li>
<li><a name="a511"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">resource </span><span class="src-doc-var">$parser </span><span class="src-doc">       SAX XML resource handler</span></li>
<li><a name="a512"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">           name of the encountered tag.</span></li>
<li><a name="a513"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$attrs </span><span class="src-doc">           contains the additional attribues of a tag, like value, id, find.</span></li>
<li><a name="a514"></a><span class="src-doc">* </span></li>
<li><a name="a515"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a516"></a><span class="src-doc">*/</span></li>
<li><a name="a517"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionstartS">startS</a><span class="src-sym">(</span><span class="src-var">$parser</span><span class="src-sym">,</span><span class="src-var">$name</span><span class="src-sym">,</span><span class="src-var">$attrs</span><span class="src-sym">)</span></li>
<li><a name="a518"></a><span class="src-sym">{</span></li>
<li><a name="a519"></a>&nbsp;</li>
<li><a name="a520"></a>    <span class="src-key">global </span><span class="src-var">$selectbot</span><span class="src-sym">, </span><span class="src-var">$whaton</span><span class="src-sym">, </span><span class="src-var">$startupwhich</span><span class="src-sym">, </span><span class="src-var">$splitterarray</span><span class="src-sym">, </span></li>
<li><a name="a521"></a>    <span class="src-var">$inputarray</span><span class="src-sym">, </span><span class="src-var">$genderarray</span><span class="src-sym">, </span><span class="src-var">$personarray</span><span class="src-sym">, </span><span class="src-var">$person2array</span><span class="src-sym">, </span><span class="src-var">$allbots</span><span class="src-sym">, </span><span class="src-var">$areinc</span><span class="src-sym">;</span></li>
<li><a name="a522"></a>    </li>
<li><a name="a523"></a>    <span class="src-var">$attrs</span>=<a href="../Loader/_admin_botloaderfuncs_php.html#functionupperkeysarray">upperkeysarray</a><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a524"></a>&nbsp;</li>
<li><a name="a525"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">'LEARN'</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a526"></a>        <span class="src-var">$whaton </span>= <span class="src-str">'LEARN'</span><span class="src-sym">;</span></li>
<li><a name="a527"></a>    <span class="src-sym">}</span></li>
<li><a name="a528"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;GENDER&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a529"></a>        <span class="src-var">$startupwhich</span>=<span class="src-str">&quot;GENDER&quot;</span><span class="src-sym">;</span></li>
<li><a name="a530"></a>    <span class="src-sym">}</span></li>
<li><a name="a531"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;INPUT&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a532"></a>        <span class="src-var">$startupwhich</span>=<span class="src-str">&quot;INPUT&quot;</span><span class="src-sym">;</span></li>
<li><a name="a533"></a>    <span class="src-sym">}</span></li>
<li><a name="a534"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;PERSON&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a535"></a>        <span class="src-var">$startupwhich</span>=<span class="src-str">&quot;PERSON&quot;</span><span class="src-sym">;</span></li>
<li><a name="a536"></a>    <span class="src-sym">}</span></li>
<li><a name="a537"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;PERSON2&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a538"></a>        <span class="src-var">$startupwhich</span>=<span class="src-str">&quot;PERSON2&quot;</span><span class="src-sym">;</span></li>
<li><a name="a539"></a>    <span class="src-sym">}</span></li>
<li><a name="a540"></a>&nbsp;</li>
<li><a name="a541"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;PROPERTY&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a542"></a>        <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">insert</span> <span class="src-id">into</span> <span class="src-id">bot</span> (<span class="src-id">bot</span>,<span class="src-id">name</span>,<span class="src-id">value</span>) <span class="src-id">values</span> (<span class="src-var">$selectbot</span>,'</span><span class="src-str">&quot; </span>. <a href="http://www.php.net/addslashes">addslashes</a><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;NAME&quot;</span><span class="src-sym">]</span><span class="src-sym">) </span>. <span class="src-str">&quot;','&quot; </span>. <a href="http://www.php.net/addslashes">addslashes</a><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;VALUE&quot;</span><span class="src-sym">]</span><span class="src-sym">) </span>. <span class="src-str">&quot;')&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a543"></a>&nbsp;</li>
<li><a name="a544"></a>        <span class="src-var">$qcode</span>=<a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a545"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$qcode</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a546"></a>        <span class="src-sym">}</span></li>
<li><a name="a547"></a>&nbsp;</li>
<li><a name="a548"></a>    <span class="src-sym">}</span></li>
<li><a name="a549"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;BOT&quot;</span><span class="src-sym">) </span><span class="src-sym">{                    </span></li>
<li><a name="a550"></a>        <span class="src-var">$bot </span>= <span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;ID&quot;</span><span class="src-sym">]</span><span class="src-sym">;                    </span></li>
<li><a name="a551"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="../Loader/_admin_botloaderfuncs_php.html#functionbotexists">botexists</a><span class="src-sym">(</span><span class="src-var">$bot</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a552"></a>            <span class="src-var">$existbotid </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functiongetbotid">getbotid</a><span class="src-sym">(</span><span class="src-var">$bot</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a553"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$areinc</span>==<span class="src-num">1</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a554"></a>                <a href="../Loader/_admin_botloaderfuncs_php.html#functiondeletebot">deletebot</a><span class="src-sym">(</span><span class="src-var">$existbotid</span><span class="src-sym">)</span><span class="src-sym">;    </span></li>
<li><a name="a555"></a>            <span class="src-sym">}</span></li>
<li><a name="a556"></a>        <span class="src-sym">}</span></li>
<li><a name="a557"></a>&nbsp;</li>
<li><a name="a558"></a>        <span class="src-var">$asbot</span>=<a href="http://www.php.net/addslashes">addslashes</a><span class="src-sym">(</span><span class="src-var">$bot</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a559"></a>        <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">insert</span> <span class="src-id">into</span> <span class="src-id">bots</span> (<span class="src-id">id</span>,<span class="src-id">botname</span>) <span class="src-id">values</span> (<span class="src-id">null</span>,'<span class="src-var">$asbot</span>')</span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a560"></a>        <span class="src-var">$qcode</span>=<a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a561"></a>        </li>
<li><a name="a562"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$areinc</span>==<span class="src-num">1</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a563"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$qcode</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a564"></a>            <span class="src-sym">}</span></li>
<li><a name="a565"></a>            <span class="src-var">$newbotid</span>=<a href="http://www.php.net/mysql_insert_id">mysql_insert_id</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a566"></a>        <span class="src-sym">}</span></li>
<li><a name="a567"></a>        <span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a568"></a>            <span class="src-var">$newbotid</span>=<span class="src-var">$existbotid</span><span class="src-sym">;</span></li>
<li><a name="a569"></a>        <span class="src-sym">}</span></li>
<li><a name="a570"></a>&nbsp;</li>
<li><a name="a571"></a>        <span class="src-var">$selectbot</span>=<span class="src-var">$newbotid</span><span class="src-sym">;</span></li>
<li><a name="a572"></a>        <span class="src-var">$allbots</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-var">$selectbot</span><span class="src-sym">;</span></li>
<li><a name="a573"></a>&nbsp;</li>
<li><a name="a574"></a>        <span class="src-comm">#print &quot;&lt;font size='3'&gt;&lt;b&gt;Loading bot: $bot ($selectbot)&lt;BR&gt;&lt;/b&gt;&lt;/font&gt;\n&quot;;    </span></li>
<li><a name="a575"></a>        <a href="http://www.php.net/flush">flush</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;                            </span></li>
<li><a name="a576"></a>    <span class="src-sym">}</span></li>
<li><a name="a577"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;SPLITTER&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a578"></a>        <span class="src-var">$splitterarray</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;VALUE&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a579"></a>    <span class="src-sym">}</span></li>
<li><a name="a580"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;SUBSTITUTE&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a581"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;FIND&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span>!=<span class="src-str">&quot;&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a582"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$startupwhich</span>==<span class="src-str">&quot;INPUT&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a583"></a>                <span class="src-var">$inputarray</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;FIND&quot;</span><span class="src-sym">]</span><span class="src-sym">,</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;REPLACE&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a584"></a>            <span class="src-sym">}</span></li>
<li><a name="a585"></a>            <span class="src-key">elseif </span><span class="src-sym">(</span><span class="src-var">$startupwhich</span>==<span class="src-str">&quot;GENDER&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a586"></a>                <span class="src-var">$genderarray</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;FIND&quot;</span><span class="src-sym">]</span><span class="src-sym">,</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;REPLACE&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a587"></a>            <span class="src-sym">}</span></li>
<li><a name="a588"></a>            <span class="src-key">elseif </span><span class="src-sym">(</span><span class="src-var">$startupwhich</span>==<span class="src-str">&quot;PERSON&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a589"></a>                <span class="src-var">$personarray</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;FIND&quot;</span><span class="src-sym">]</span><span class="src-sym">,</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;REPLACE&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a590"></a>            <span class="src-sym">}</span></li>
<li><a name="a591"></a>            <span class="src-key">elseif </span><span class="src-sym">(</span><span class="src-var">$startupwhich</span>==<span class="src-str">&quot;PERSON2&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a592"></a>                <span class="src-var">$person2array</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;FIND&quot;</span><span class="src-sym">]</span><span class="src-sym">,</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;REPLACE&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a593"></a>            <span class="src-sym">}</span></li>
<li><a name="a594"></a>        <span class="src-sym">}</span></li>
<li><a name="a595"></a>    <span class="src-sym">}</span></li>
<li><a name="a596"></a><span class="src-sym">}</span></li>
<li><a name="a597"></a>&nbsp;</li>
<li><a name="a598"></a><span class="src-doc">/** </span></li>
<li><a name="a599"></a><span class="src-doc">* Called by the XML parser that is parsing the startup.xml file.</span></li>
<li><a name="a600"></a><span class="src-doc">*</span></li>
<li><a name="a601"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">                Which start tag was processed last</span></li>
<li><a name="a602"></a><span class="src-doc">* </span></li>
<li><a name="a603"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">resource </span><span class="src-doc-var">$parser </span><span class="src-doc">       SAX XML resource handler</span></li>
<li><a name="a604"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">           name of the encountered tag.</span></li>
<li><a name="a605"></a><span class="src-doc">*</span></li>
<li><a name="a606"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a607"></a><span class="src-doc">*/</span></li>
<li><a name="a608"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionendS">endS</a><span class="src-sym">(</span><span class="src-var">$parser</span><span class="src-sym">,</span><span class="src-var">$name</span><span class="src-sym">)</span></li>
<li><a name="a609"></a><span class="src-sym">{</span></li>
<li><a name="a610"></a>    <span class="src-key">global </span><span class="src-var">$whaton</span><span class="src-sym">;</span></li>
<li><a name="a611"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">'LEARN'</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a612"></a>        <span class="src-var">$whaton </span>= <span class="src-str">''</span><span class="src-sym">;</span></li>
<li><a name="a613"></a>    <span class="src-sym">}</span></li>
<li><a name="a614"></a><span class="src-sym">}</span></li>
<li><a name="a615"></a>&nbsp;</li>
<li><a name="a616"></a><span class="src-doc">/** </span></li>
<li><a name="a617"></a><span class="src-doc">* Process contents &lt;learn&gt; tag in startup.xml</span></li>
<li><a name="a618"></a><span class="src-doc">*</span></li>
<li><a name="a619"></a><span class="src-doc">* Called by the XML parser that is parsing the startup.xml file. * -&gt; all files in directory, or single file.</span></li>
<li><a name="a620"></a><span class="src-doc">* </span></li>
<li><a name="a621"></a><span class="src-doc">* </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> When using * it should process AIML in subdirectories too. This is currently only supported by using multiple &lt;learn&gt; tag entries for every folder containing AIML files.</span></li>
<li><a name="a622"></a><span class="src-doc">*</span></li>
<li><a name="a623"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> learnallfiles()</span></li>
<li><a name="a624"></a><span class="src-doc">*</span></li>
<li><a name="a625"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a626"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">      contains the AIML files to learn.</span></li>
<li><a name="a627"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span></li>
<li><a name="a628"></a><span class="src-doc">*</span></li>
<li><a name="a629"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">resource </span><span class="src-doc-var">$parser </span><span class="src-doc">       SAX XML resource handler</span></li>
<li><a name="a630"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$data </span><span class="src-doc">           assuming it contains the path to the file.</span></li>
<li><a name="a631"></a><span class="src-doc">*/</span></li>
<li><a name="a632"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionhandlemeS">handlemeS</a><span class="src-sym">(</span><span class="src-var">$parser</span><span class="src-sym">, </span><span class="src-var">$data</span><span class="src-sym">)</span></li>
<li><a name="a633"></a><span class="src-sym">{</span></li>
<li><a name="a634"></a>    <span class="src-key">global </span><span class="src-var">$whaton</span><span class="src-sym">, </span><span class="src-var">$learnfiles</span><span class="src-sym">, </span><span class="src-var">$selectbot</span><span class="src-sym">;</span></li>
<li><a name="a635"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;LEARN&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a636"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$data</span><span class="src-sym">)</span>==<span class="src-str">&quot;*&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a637"></a>            <a href="../Loader/_admin_botloaderfuncs_php.html#functionlearnallfiles">learnallfiles</a><span class="src-sym">(</span><span class="src-var">$selectbot</span><span class="src-sym">)</span><span class="src-sym">;        </span></li>
<li><a name="a638"></a>        <span class="src-sym">}</span></li>
<li><a name="a639"></a>        <span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a640"></a>            <span class="src-var">$learnfiles</span><span class="src-sym">[</span><span class="src-var">$selectbot</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-sym">]</span>=<a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$data</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a641"></a>        <span class="src-sym">}</span></li>
<li><a name="a642"></a>    </li>
<li><a name="a643"></a>    <span class="src-sym">}</span></li>
<li><a name="a644"></a><span class="src-sym">}</span></li>
<li><a name="a645"></a>&nbsp;</li>
<li><a name="a646"></a><span class="src-doc">/**</span></li>
<li><a name="a647"></a><span class="src-doc">* Checks if a bot already exists.</span></li>
<li><a name="a648"></a><span class="src-doc">*</span></li>
<li><a name="a649"></a><span class="src-doc">* Does a check to see if a bot with a particular name already exists. The reliance on unique names if crucial for the bot to work.</span></li>
<li><a name="a650"></a><span class="src-doc">*</span></li>
<li><a name="a651"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">           the name of the bot that is checked.</span></li>
<li><a name="a652"></a><span class="src-doc">*</span></li>
<li><a name="a653"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">boolean </span><span class="src-doc">               true/false</span></li>
<li><a name="a654"></a><span class="src-doc">*/</span></li>
<li><a name="a655"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionbotexists">botexists</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a656"></a>&nbsp;</li>
<li><a name="a657"></a>    <span class="src-comm">// search to get existing id</span></li>
<li><a name="a658"></a>    <span class="src-var">$name</span>=<a href="http://www.php.net/addslashes">addslashes</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a659"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">select</span> <span class="src-id">id</span> <span class="src-id">from</span> <span class="src-id">bots</span> <span class="src-id">where</span> <span class="src-id">botname</span>='<span class="src-var">$name</span>'</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a660"></a>    <span class="src-var">$selectcode </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a661"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a662"></a>        <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$q </span>= <a href="http://www.php.net/mysql_fetch_array">mysql_fetch_array</a><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a663"></a>            <span class="src-key">return </span><span class="src-id">true</span><span class="src-sym">;</span></li>
<li><a name="a664"></a>        <span class="src-sym">}</span></li>
<li><a name="a665"></a>    <span class="src-sym">}</span></li>
<li><a name="a666"></a>&nbsp;</li>
<li><a name="a667"></a>    <span class="src-key">return </span><span class="src-id">false</span><span class="src-sym">;</span></li>
<li><a name="a668"></a>&nbsp;</li>
<li><a name="a669"></a><span class="src-sym">}</span></li>
<li><a name="a670"></a>&nbsp;</li>
<li><a name="a671"></a><span class="src-doc">/**</span></li>
<li><a name="a672"></a><span class="src-doc">* Gets a bot's property value.</span></li>
<li><a name="a673"></a><span class="src-doc">*</span></li>
<li><a name="a674"></a><span class="src-doc">* Retrieves the value of a particular bot predicate. If the predicate isn't set, then it will return the value 'default'. This has been hardcoded</span></li>
<li><a name="a675"></a><span class="src-doc">* </span></li>
<li><a name="a676"></a><span class="src-doc">* </span></li>
<li><a name="a677"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span></li>
<li><a name="a678"></a><span class="src-doc">* </span></li>
<li><a name="a679"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">       the name of the bot predicate to be retrieved.</span></li>
<li><a name="a680"></a><span class="src-doc">*</span></li>
<li><a name="a681"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">            the value of the bot predicate.</span></li>
<li><a name="a682"></a><span class="src-doc">*/</span></li>
<li><a name="a683"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functiongetbotvalue">getbotvalue</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span></li>
<li><a name="a684"></a><span class="src-sym">{</span></li>
<li><a name="a685"></a>    <span class="src-key">global </span><span class="src-var">$selectbot</span><span class="src-sym">;    </span></li>
<li><a name="a686"></a>&nbsp;</li>
<li><a name="a687"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;select value from bot where name=&quot; </span>. <a href="http://www.php.net/addslashes">addslashes</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">) </span>. <span class="src-str">&quot;</span><span class="src-str"> <span class="src-id">and</span> <span class="src-id">bot</span>=<span class="src-var">$selectbot</span></span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a688"></a>&nbsp;</li>
<li><a name="a689"></a>    <span class="src-var">$selectcode </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a690"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a691"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/mysql_numrows">mysql_numrows</a><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a692"></a>                <span class="src-key">return </span><span class="src-id"><a href="../Settings/_admin_dbprefs_php.html#defineDEFAULTPREDICATEVALUE">DEFAULTPREDICATEVALUE</a></span><span class="src-sym">;</span></li>
<li><a name="a693"></a>        <span class="src-sym">}</span></li>
<li><a name="a694"></a>        <span class="src-key">else</span><span class="src-sym">{</span></li>
<li><a name="a695"></a>            <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$q </span>= <a href="http://www.php.net/mysql_fetch_array">mysql_fetch_array</a><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a696"></a>                <span class="src-key">return </span><span class="src-var">$q</span><span class="src-sym">[</span><span class="src-str">&quot;value&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a697"></a>            <span class="src-sym">}</span></li>
<li><a name="a698"></a>        <span class="src-sym">}</span></li>
<li><a name="a699"></a>    <span class="src-sym">}</span></li>
<li><a name="a700"></a><span class="src-sym">}</span></li>
<li><a name="a701"></a>&nbsp;</li>
<li><a name="a702"></a><span class="src-doc">/**</span></li>
<li><a name="a703"></a><span class="src-doc">* Gets the ID of a bot given its name.</span></li>
<li><a name="a704"></a><span class="src-doc">*</span></li>
<li><a name="a705"></a><span class="src-doc">* Gets the ID of a bot given its name</span></li>
<li><a name="a706"></a><span class="src-doc">*</span></li>
<li><a name="a707"></a><span class="src-doc">* </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> move this function to a common include file shared by both the Loader and the Interpreter.</span></li>
<li><a name="a708"></a><span class="src-doc">* </span></li>
<li><a name="a709"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">             The name of the bot</span></li>
<li><a name="a710"></a><span class="src-doc">*</span></li>
<li><a name="a711"></a><span class="src-doc">*  @ return integer                 The bot's ID.</span></li>
<li><a name="a712"></a><span class="src-doc">*/</span></li>
<li><a name="a713"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functiongetbotid">getbotid</a> <span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span></li>
<li><a name="a714"></a><span class="src-sym">{</span></li>
<li><a name="a715"></a>    <span class="src-comm">// search to get existing id</span></li>
<li><a name="a716"></a>    <span class="src-var">$name</span>=<a href="http://www.php.net/addslashes">addslashes</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a717"></a>    <span class="src-var">$q</span>=<span class="src-str">&quot;</span><span class="src-str"><span class="src-id">select</span> <span class="src-id">id</span> <span class="src-id">from</span> <span class="src-id">bots</span> <span class="src-id">where</span> <span class="src-id">botname</span>='<span class="src-var">$name</span>'</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a718"></a>    <span class="src-var">$selectcode </span>= <a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$q</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a719"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a720"></a>        <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$q </span>= <a href="http://www.php.net/mysql_fetch_array">mysql_fetch_array</a><span class="src-sym">(</span><span class="src-var">$selectcode</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a721"></a>                <span class="src-key">return </span><span class="src-var">$q</span><span class="src-sym">[</span><span class="src-str">&quot;id&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a722"></a>        <span class="src-sym">}</span></li>
<li><a name="a723"></a>    <span class="src-sym">}</span></li>
<li><a name="a724"></a>&nbsp;</li>
<li><a name="a725"></a><span class="src-sym">}</span></li>
<li><a name="a726"></a>&nbsp;</li>
<li><a name="a727"></a><span class="src-doc">/**</span></li>
<li><a name="a728"></a><span class="src-doc">* Used by the AIML XML parser</span></li>
<li><a name="a729"></a><span class="src-doc">*</span></li>
<li><a name="a730"></a><span class="src-doc">* Looks for the start tag used in AIML files for category, template, that, topic.</span></li>
<li><a name="a731"></a><span class="src-doc">*</span></li>
<li><a name="a732"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> upperkeysarray()</span></li>
<li><a name="a733"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> getbotvalue()</span></li>
<li><a name="a734"></a><span class="src-doc">*</span></li>
<li><a name="a735"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">                 which tag is being processed</span></li>
<li><a name="a736"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a737"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a738"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span><span class="src-doc">                to indicate if recursion is allowed</span></li>
<li><a name="a739"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">                 the topic at hand in the AIML file</span></li>
<li><a name="a740"></a><span class="src-doc">*</span></li>
<li><a name="a741"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">resource </span><span class="src-doc-var">$parser </span><span class="src-doc">       SAX XML resource handler</span></li>
<li><a name="a742"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">           name of the encountered tag.</span></li>
<li><a name="a743"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$attrs </span><span class="src-doc">           contains the additional attribues of a tag, like value, id, find.</span></li>
<li><a name="a744"></a><span class="src-doc">*</span></li>
<li><a name="a745"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a746"></a><span class="src-doc">*/</span></li>
<li><a name="a747"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionstartElement">startElement</a><span class="src-sym">(</span><span class="src-var">$parser</span><span class="src-sym">, </span><span class="src-var">$name</span><span class="src-sym">, </span><span class="src-var">$attrs</span><span class="src-sym">) </span></li>
<li><a name="a748"></a><span class="src-sym">{</span></li>
<li><a name="a749"></a>    <span class="src-key">global </span><span class="src-var">$whaton</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">,</span><span class="src-var">$pattern</span><span class="src-sym">,</span><span class="src-var">$recursive</span><span class="src-sym">,</span><span class="src-var">$topic</span><span class="src-sym">;</span></li>
<li><a name="a750"></a>&nbsp;</li>
<li><a name="a751"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;CATEGORY&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a752"></a>        <span class="src-var">$whaton</span>=<span class="src-str">&quot;CATEGORY&quot;</span><span class="src-sym">;</span></li>
<li><a name="a753"></a>    <span class="src-sym">}</span></li>
<li><a name="a754"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;TEMPLATE&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a755"></a>        <span class="src-var">$whaton</span>=<span class="src-str">&quot;TEMPLATE&quot;</span><span class="src-sym">;</span></li>
<li><a name="a756"></a>        <span class="src-var">$template</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a757"></a>        <span class="src-var">$recursive</span>=<span class="src-num">0</span><span class="src-sym">;</span></li>
<li><a name="a758"></a>    <span class="src-sym">}</span></li>
<li><a name="a759"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;PATTERN&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a760"></a>        <span class="src-var">$whaton</span>=<span class="src-str">&quot;PATTERN&quot;</span><span class="src-sym">;</span></li>
<li><a name="a761"></a>    <span class="src-sym">}</span></li>
<li><a name="a762"></a>    <span class="src-key">elseif </span><span class="src-sym">((</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;THAT&quot;</span><span class="src-sym">)</span>&amp;&amp;<span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>!=<span class="src-str">&quot;TEMPLATE&quot;</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a763"></a>        <span class="src-var">$whaton</span>=<span class="src-str">&quot;THAT&quot;</span><span class="src-sym">;</span></li>
<li><a name="a764"></a>    <span class="src-sym">}</span></li>
<li><a name="a765"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;TOPIC&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a766"></a>        <span class="src-var">$whaton</span>=<span class="src-str">&quot;TOPIC&quot;</span><span class="src-sym">;</span></li>
<li><a name="a767"></a>    <span class="src-sym">}</span></li>
<li><a name="a768"></a>&nbsp;</li>
<li><a name="a769"></a>    <span class="src-key">if </span><span class="src-sym">((</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;PATTERN&quot;</span><span class="src-sym">)</span>&amp;&amp;<span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>!=<span class="src-str">&quot;PATTERN&quot;</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a770"></a>&nbsp;</li>
<li><a name="a771"></a>&nbsp;</li>
<li><a name="a772"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;BOT&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a773"></a>&nbsp;</li>
<li><a name="a774"></a>            <span class="src-var">$attrs </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functionupperkeysarray">upperkeysarray</a><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a775"></a>            <span class="src-var">$pattern </span>.= <a href="../Loader/_admin_botloaderfuncs_php.html#functiongetbotvalue">getbotvalue</a><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;NAME&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a776"></a>&nbsp;</li>
<li><a name="a777"></a>        <span class="src-sym">}</span></li>
<li><a name="a778"></a>        <span class="src-key">else</span><span class="src-sym">{</span></li>
<li><a name="a779"></a>            <span class="src-var">$pattern </span>.= <span class="src-str">&quot;</span><span class="src-str">&lt;<span class="src-var">$name</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a780"></a>&nbsp;</li>
<li><a name="a781"></a>            <span class="src-key">while </span><span class="src-sym">(</span>list <span class="src-sym">(</span><span class="src-var">$key</span><span class="src-sym">, </span><span class="src-var">$val</span><span class="src-sym">) </span>= <a href="http://www.php.net/each">each</a> <span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a782"></a>                <span class="src-var">$pattern </span>.= <span class="src-str">&quot;</span><span class="src-str"> <span class="src-var">$key</span>=\&quot;<span class="src-var">$val</span>\&quot; </span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a783"></a>            <span class="src-sym">}</span></li>
<li><a name="a784"></a>&nbsp;</li>
<li><a name="a785"></a>            <span class="src-var">$pattern </span>.= <span class="src-str">&quot;&gt;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a786"></a>        <span class="src-sym">}</span></li>
<li><a name="a787"></a>&nbsp;</li>
<li><a name="a788"></a>    <span class="src-sym">}</span></li>
<li><a name="a789"></a>    <span class="src-key">elseif </span><span class="src-sym">((</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;TEMPLATE&quot;</span><span class="src-sym">)</span>&amp;&amp;<span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>!=<span class="src-str">&quot;TEMPLATE&quot;</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a790"></a>        </li>
<li><a name="a791"></a>        <span class="src-var">$template </span>.=<span class="src-str">&quot;</span><span class="src-str">&lt;<span class="src-var">$name</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a792"></a>&nbsp;</li>
<li><a name="a793"></a>        <span class="src-key">while </span><span class="src-sym">(</span>list <span class="src-sym">(</span><span class="src-var">$key</span><span class="src-sym">, </span><span class="src-var">$val</span><span class="src-sym">) </span>= <a href="http://www.php.net/each">each</a> <span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a794"></a>            <span class="src-var">$template </span>.= <span class="src-str">&quot;</span><span class="src-str"> <span class="src-var">$key</span>=\&quot;<span class="src-var">$val</span>\&quot; </span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a795"></a>        <span class="src-sym">}        </span></li>
<li><a name="a796"></a>&nbsp;</li>
<li><a name="a797"></a>        <span class="src-var">$template </span>.=<span class="src-str">&quot;&gt;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a798"></a>    <span class="src-sym">}</span></li>
<li><a name="a799"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;TOPIC&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a800"></a>&nbsp;</li>
<li><a name="a801"></a>        <span class="src-var">$attrs </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functionupperkeysarray">upperkeysarray</a><span class="src-sym">(</span><span class="src-var">$attrs</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a802"></a>        <span class="src-var">$topic</span>=<span class="src-var">$attrs</span><span class="src-sym">[</span><span class="src-str">&quot;NAME&quot;</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a803"></a>&nbsp;</li>
<li><a name="a804"></a>    <span class="src-sym">}</span></li>
<li><a name="a805"></a><span class="src-sym">}</span></li>
<li><a name="a806"></a>&nbsp;</li>
<li><a name="a807"></a><span class="src-doc">/**</span></li>
<li><a name="a808"></a><span class="src-doc">* Used by the AIML XML parser</span></li>
<li><a name="a809"></a><span class="src-doc">* </span></li>
<li><a name="a810"></a><span class="src-doc">* Looks for the end tags of 'topic' and 'category'.</span></li>
<li><a name="a811"></a><span class="src-doc">*</span></li>
<li><a name="a812"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> insertmysentence()</span></li>
<li><a name="a813"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> insertmytemplate()</span></li>
<li><a name="a814"></a><span class="src-doc">* </span></li>
<li><a name="a815"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">                 which tag is being processed</span></li>
<li><a name="a816"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a817"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a818"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span><span class="src-doc">                to indicate if recursion is allowed</span></li>
<li><a name="a819"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">                 the topic at hand in the AIML file</span></li>
<li><a name="a820"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">                 the that of the category.</span></li>
<li><a name="a821"></a><span class="src-doc">*</span></li>
<li><a name="a822"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">resource </span><span class="src-doc-var">$parser </span><span class="src-doc">       SAX XML resource handler</span></li>
<li><a name="a823"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">           name of the encountered tag.</span></li>
<li><a name="a824"></a><span class="src-doc">*</span></li>
<li><a name="a825"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a826"></a><span class="src-doc">*/</span></li>
<li><a name="a827"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionendElement">endElement</a><span class="src-sym">(</span><span class="src-var">$parser</span><span class="src-sym">, </span><span class="src-var">$name</span><span class="src-sym">) </span></li>
<li><a name="a828"></a><span class="src-sym">{</span></li>
<li><a name="a829"></a>&nbsp;</li>
<li><a name="a830"></a>    <span class="src-key">global </span><span class="src-var">$whaton</span><span class="src-sym">,</span><span class="src-var">$pattern</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">,</span><span class="src-var">$recursive</span><span class="src-sym">,</span><span class="src-var">$topic</span><span class="src-sym">,</span><span class="src-var">$that</span><span class="src-sym">;</span></li>
<li><a name="a831"></a>    </li>
<li><a name="a832"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;TOPIC&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a833"></a>        <span class="src-var">$topic</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a834"></a>    <span class="src-sym">}</span></li>
<li><a name="a835"></a>&nbsp;</li>
<li><a name="a836"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>==<span class="src-str">&quot;CATEGORY&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a837"></a>        <span class="src-var">$template</span>=<a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a838"></a>        <span class="src-var">$topic</span>=<a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$topic</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a839"></a>        <span class="src-var">$that</span>=<a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$that</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a840"></a>        <span class="src-var">$pattern</span>=<a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$pattern</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a841"></a>&nbsp;</li>
<li><a name="a842"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$that</span>==<span class="src-str">&quot;&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a843"></a>            <span class="src-var">$that</span>=<span class="src-str">&quot;*&quot;</span><span class="src-sym">;</span></li>
<li><a name="a844"></a>        <span class="src-sym">}</span></li>
<li><a name="a845"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$topic</span>==<span class="src-str">&quot;&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a846"></a>            <span class="src-var">$topic</span>=<span class="src-str">&quot;*&quot;</span><span class="src-sym">;</span></li>
<li><a name="a847"></a>        <span class="src-sym">}</span></li>
<li><a name="a848"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$pattern</span>==<span class="src-str">&quot;&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a849"></a>            <span class="src-var">$pattern</span>=<span class="src-str">&quot;*&quot;</span><span class="src-sym">;</span></li>
<li><a name="a850"></a>        <span class="src-sym">}</span></li>
<li><a name="a851"></a>&nbsp;</li>
<li><a name="a852"></a>    </li>
<li><a name="a853"></a>        <span class="src-var">$mybigsentence</span>=<span class="src-str">&quot;</span><span class="src-str">&lt;<span class="src-id">input</span>&gt; <span class="src-var">$pattern</span> &lt;<span class="src-id">that</span>&gt; <span class="src-var">$that</span> &lt;<span class="src-id">topic</span>&gt; <span class="src-var">$topic</span></span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a854"></a>&nbsp;</li>
<li><a name="a855"></a><span class="src-comm">//echo $mybigsentence;</span></li>
<li><a name="a856"></a>     </li>
<li><a name="a857"></a>     <span class="src-var">$idused</span>=<a href="../Loader/_admin_botloaderfuncs_php.html#functioninsertmysentence">insertmysentence</a><span class="src-sym">(</span><span class="src-var">$mybigsentence</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a858"></a>            </li>
<li><a name="a859"></a>        <a href="../Loader/_admin_botloaderfuncs_php.html#functioninsertmytemplate">insertmytemplate</a><span class="src-sym">(</span><span class="src-var">$idused</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a860"></a>&nbsp;</li>
<li><a name="a861"></a>        <span class="src-comm">// IIS doesn't flush properly unless it has a bunch of characters in it. This fills it with spaces.</span></li>
<li><a name="a862"></a>        print <span class="src-str">&quot;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             &quot;</span><span class="src-sym">;</span></li>
<li><a name="a863"></a>        <a href="http://www.php.net/flush">flush</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a864"></a>&nbsp;</li>
<li><a name="a865"></a>        <span class="src-var">$pattern</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a866"></a>        <span class="src-var">$template</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a867"></a>        <span class="src-var">$that</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a868"></a>&nbsp;</li>
<li><a name="a869"></a>    <span class="src-sym">}</span></li>
<li><a name="a870"></a>    <span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a871"></a>        <span class="src-key">if </span><span class="src-sym">((</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;PATTERN&quot;</span><span class="src-sym">)</span>&amp;&amp;<span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>!=<span class="src-str">&quot;PATTERN&quot;</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a872"></a>            <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>!=<span class="src-str">&quot;BOT&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a873"></a>                <span class="src-var">$pattern </span>.=<span class="src-str">&quot;</span><span class="src-str">&lt;/<span class="src-var">$name</span>&gt;</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a874"></a>            <span class="src-sym">}</span></li>
<li><a name="a875"></a>        <span class="src-sym">}</span></li>
<li><a name="a876"></a>        <span class="src-key">elseif </span><span class="src-sym">((</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;TEMPLATE&quot;</span><span class="src-sym">)</span>&amp;&amp;<span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$name</span><span class="src-sym">)</span>!=<span class="src-str">&quot;TEMPLATE&quot;</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a877"></a>            <span class="src-var">$template </span>.=<span class="src-str">&quot;</span><span class="src-str">&lt;/<span class="src-var">$name</span>&gt;</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a878"></a>        <span class="src-sym">}    </span></li>
<li><a name="a879"></a>    <span class="src-sym">}</span></li>
<li><a name="a880"></a>&nbsp;</li>
<li><a name="a881"></a><span class="src-sym">}</span></li>
<li><a name="a882"></a>&nbsp;</li>
<li><a name="a883"></a>&nbsp;</li>
<li><a name="a884"></a><span class="src-doc">/**</span></li>
<li><a name="a885"></a><span class="src-doc">* Part of the AIML XML parser.</span></li>
<li><a name="a886"></a><span class="src-doc">* </span></li>
<li><a name="a887"></a><span class="src-doc">* Checks for start tags of pattern, topic, that, template and CDATA</span></li>
<li><a name="a888"></a><span class="src-doc">*</span></li>
<li><a name="a889"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a890"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a891"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a892"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a893"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span></li>
<li><a name="a894"></a><span class="src-doc">*</span></li>
<li><a name="a895"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">resource </span><span class="src-doc-var">$parser </span><span class="src-doc">       SAX XML resource handler</span></li>
<li><a name="a896"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$data </span><span class="src-doc">           containing what needs to be parsed, I guess.</span></li>
<li><a name="a897"></a><span class="src-doc">*</span></li>
<li><a name="a898"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a899"></a><span class="src-doc">*/</span></li>
<li><a name="a900"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionhandleme">handleme</a><span class="src-sym">(</span><span class="src-var">$parser</span><span class="src-sym">, </span><span class="src-var">$data</span><span class="src-sym">)</span></li>
<li><a name="a901"></a><span class="src-sym">{</span></li>
<li><a name="a902"></a>    <span class="src-key">global </span><span class="src-var">$whaton</span><span class="src-sym">,</span><span class="src-var">$pattern</span><span class="src-sym">,</span><span class="src-var">$template</span><span class="src-sym">,</span><span class="src-var">$topic</span><span class="src-sym">,</span><span class="src-var">$that</span><span class="src-sym">;</span></li>
<li><a name="a903"></a>    </li>
<li><a name="a904"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;PATTERN&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a905"></a>        <span class="src-var">$pattern </span>.= <span class="src-var">$data</span><span class="src-sym">;</span></li>
<li><a name="a906"></a>    <span class="src-sym">}</span></li>
<li><a name="a907"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;TOPIC&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a908"></a>        <span class="src-var">$topic </span>.= <span class="src-var">$data</span><span class="src-sym">;</span></li>
<li><a name="a909"></a>    <span class="src-sym">}</span></li>
<li><a name="a910"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;THAT&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a911"></a>        <span class="src-var">$that </span>.= <span class="src-var">$data</span><span class="src-sym">;</span></li>
<li><a name="a912"></a>    <span class="src-sym">}</span></li>
<li><a name="a913"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;TEMPLATE&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a914"></a>        <span class="src-var">$template </span>.= <span class="src-var">$data</span><span class="src-sym">;</span></li>
<li><a name="a915"></a>    <span class="src-sym">}</span></li>
<li><a name="a916"></a>    <span class="src-key">elseif </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$whaton</span><span class="src-sym">)</span>==<span class="src-str">&quot;TEMPLATE&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a917"></a>        <span class="src-var">$template </span>.= <span class="src-str">&quot;</span><span class="src-str">&lt;!<span class="src-sym">[</span><span class="src-id">CDATA</span><span class="src-sym">[</span><span class="src-var">$data</span><span class="src-sym">]]</span>&gt;</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a918"></a>    <span class="src-sym">}</span></li>
<li><a name="a919"></a><span class="src-sym">}</span></li>
<li><a name="a920"></a>&nbsp;</li>
<li><a name="a921"></a>&nbsp;</li>
<li><a name="a922"></a><span class="src-doc">/**</span></li>
<li><a name="a923"></a><span class="src-doc">* Parses startup.xml if the bot is loaded incrementally - one file at a time.</span></li>
<li><a name="a924"></a><span class="src-doc">*</span></li>
<li><a name="a925"></a><span class="src-doc">* Parses the startup.xml if the bot id loaded incrementally. One file at a time. This is very hacky and may not work properly.</span></li>
<li><a name="a926"></a><span class="src-doc">*</span></li>
<li><a name="a927"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> learn()</span></li>
<li><a name="a928"></a><span class="src-doc">* </span></li>
<li><a name="a929"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">                The root directory of the AIML files?</span></li>
<li><a name="a930"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">                 This array will hold the files to LEARN</span></li>
<li><a name="a931"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">boolean </span></li>
<li><a name="a932"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">                 Contains all the botnames.</span></li>
<li><a name="a933"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span><span class="src-doc">               contains the selected bot ID.</span></li>
<li><a name="a934"></a><span class="src-doc">*</span></li>
<li><a name="a935"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$fileid </span><span class="src-doc">        the ID of the file to be processed.</span></li>
<li><a name="a936"></a><span class="src-doc">*/</span></li>
<li><a name="a937"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionloadstartupinc">loadstartupinc</a><span class="src-sym">(</span><span class="src-var">$fileid</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a938"></a>&nbsp;</li>
<li><a name="a939"></a>    <span class="src-key">global </span><span class="src-var">$rootdir</span><span class="src-sym">,</span><span class="src-var">$learnfiles</span><span class="src-sym">,</span><span class="src-var">$areinc</span><span class="src-sym">,</span><span class="src-var">$allbots</span><span class="src-sym">,</span><span class="src-var">$selectbot</span><span class="src-sym">;</span></li>
<li><a name="a940"></a>    </li>
<li><a name="a941"></a>    <span class="src-var">$areinc</span>=<span class="src-num">0</span><span class="src-sym">;</span></li>
<li><a name="a942"></a>&nbsp;</li>
<li><a name="a943"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$fileid</span>==<span class="src-num">1</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a944"></a>        <span class="src-var">$areinc</span>=<span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a945"></a>    <span class="src-sym">}</span></li>
<li><a name="a946"></a>&nbsp;</li>
<li><a name="a947"></a>    print <span class="src-str">&quot;&lt;font size='3'&gt;Loading startup.xml&lt;BR&gt;&lt;/font&gt;\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a948"></a>    <span class="src-var">$learnfiles </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">; </span><span class="src-comm"># This array will hold the files to LEARN</span></li>
<li><a name="a949"></a>&nbsp;</li>
<li><a name="a950"></a>    <span class="src-var">$file </span>= <span class="src-var">$rootdir </span>. <span class="src-str">&quot;startup.xml&quot;</span><span class="src-sym">;</span></li>
<li><a name="a951"></a>    <span class="src-var">$xml_parser </span>= <a href="http://www.php.net/xml_parser_create">xml_parser_create</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a952"></a>    <a href="http://www.php.net/xml_parser_set_option">xml_parser_set_option</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">,</span><span class="src-id">XML_OPTION_CASE_FOLDING</span><span class="src-sym">,</span><span class="src-num">0</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a953"></a>    <a href="http://www.php.net/xml_set_element_handler">xml_set_element_handler</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-str">&quot;startS&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;endS&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a954"></a>    <a href="http://www.php.net/xml_set_character_data_handler">xml_set_character_data_handler</a> <span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-str">&quot;handlemeS&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a955"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-sym">(</span><span class="src-var">$fp </span>= <a href="http://www.php.net/fopen">fopen</a><span class="src-sym">(</span><span class="src-var">$file</span><span class="src-sym">, </span><span class="src-str">&quot;r&quot;</span><span class="src-sym">))) </span><span class="src-sym">{</span></li>
<li><a name="a956"></a>        <span class="src-key">die</span><span class="src-sym">(</span><span class="src-str">&quot;could not open XML input&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a957"></a>    <span class="src-sym">}</span></li>
<li><a name="a958"></a>    <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$data </span>= <a href="http://www.php.net/fread">fread</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">, </span><span class="src-num">4096</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a959"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/xml_parse">xml_parse</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-var">$data</span><span class="src-sym">, </span><a href="http://www.php.net/feof">feof</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">))) </span><span class="src-sym">{</span></li>
<li><a name="a960"></a>            <span class="src-key">die</span><span class="src-sym">(</span><a href="http://www.php.net/sprintf">sprintf</a><span class="src-sym">(</span><span class="src-str">&quot;XML error: %s at line %d&quot;</span><span class="src-sym">,</span></li>
<li><a name="a961"></a>                        <a href="http://www.php.net/xml_error_string">xml_error_string</a><span class="src-sym">(</span><a href="http://www.php.net/xml_get_error_code">xml_get_error_code</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">))</span><span class="src-sym">,</span></li>
<li><a name="a962"></a>                        <a href="http://www.php.net/xml_get_current_line_number">xml_get_current_line_number</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">)))</span><span class="src-sym">;</span></li>
<li><a name="a963"></a>        <span class="src-sym">}</span></li>
<li><a name="a964"></a>    <span class="src-sym">}</span></li>
<li><a name="a965"></a>    <a href="http://www.php.net/xml_parser_free">xml_parser_free</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a966"></a>&nbsp;</li>
<li><a name="a967"></a>    <span class="src-comm"># For each of the bots learn all of the files</span></li>
<li><a name="a968"></a>&nbsp;</li>
<li><a name="a969"></a>    <span class="src-var">$totalcounter</span>=<span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a970"></a>&nbsp;</li>
<li><a name="a971"></a>    <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$allbots </span><span class="src-key">as </span><span class="src-var">$bot</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a972"></a>&nbsp;</li>
<li><a name="a973"></a>        <span class="src-comm"># print &quot;&lt;font size='3'&gt;&lt;b&gt;Loading bot: $bot&lt;BR&gt;&lt;/b&gt;&lt;/font&gt;\n&quot;;    </span></li>
<li><a name="a974"></a>&nbsp;</li>
<li><a name="a975"></a>        <span class="src-var">$single_learnfiles </span>= <span class="src-var">$learnfiles</span><span class="src-sym">[</span><span class="src-var">$bot</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a976"></a>        <span class="src-var">$single_learnfiles </span>= <a href="http://www.php.net/array_unique">array_unique</a><span class="src-sym">(</span><span class="src-var">$single_learnfiles</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a977"></a>&nbsp;</li>
<li><a name="a978"></a>        <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$single_learnfiles </span><span class="src-key">as </span><span class="src-var">$file</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a979"></a>            </li>
<li><a name="a980"></a>            <span class="src-var">$selectbot</span>=<span class="src-var">$bot</span><span class="src-sym">;</span></li>
<li><a name="a981"></a>            </li>
<li><a name="a982"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$totalcounter</span>==<span class="src-var">$fileid</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a983"></a>                <a href="../Loader/_admin_botloaderfuncs_php.html#functionlearn">learn</a><span class="src-sym">(</span><span class="src-var">$file</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a984"></a>                <span class="src-key">return </span><span class="src-num">0</span><span class="src-sym">;</span></li>
<li><a name="a985"></a>            <span class="src-sym">}</span></li>
<li><a name="a986"></a>&nbsp;</li>
<li><a name="a987"></a>            <span class="src-var">$totalcounter</span>++<span class="src-sym">;</span></li>
<li><a name="a988"></a>&nbsp;</li>
<li><a name="a989"></a>        <span class="src-sym">}</span></li>
<li><a name="a990"></a>    <span class="src-sym">}</span></li>
<li><a name="a991"></a>&nbsp;</li>
<li><a name="a992"></a>    <span class="src-key">return </span><span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a993"></a>&nbsp;</li>
<li><a name="a994"></a>&nbsp;</li>
<li><a name="a995"></a><span class="src-sym">}</span></li>
<li><a name="a996"></a>&nbsp;</li>
<li><a name="a997"></a><span class="src-doc">/**</span></li>
<li><a name="a998"></a><span class="src-doc">* Parses startup.xml</span></li>
<li><a name="a999"></a><span class="src-doc">*</span></li>
<li><a name="a1000"></a><span class="src-doc">* Loads the startup.xml in the botloading process.</span></li>
<li><a name="a1001"></a><span class="src-doc">* XML parses the startup.xml file.</span></li>
<li><a name="a1002"></a><span class="src-doc">*</span></li>
<li><a name="a1003"></a><span class="src-doc">* </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> Seperate the XML reading from the processing code. Perhaps making a seperate class for this.</span></li>
<li><a name="a1004"></a><span class="src-doc">*</span></li>
<li><a name="a1005"></a><span class="src-doc">* </span><span class="src-doc-coretag">@see</span><span class="src-doc"> botloader.php</span></li>
<li><a name="a1006"></a><span class="src-doc">* </span><span class="src-doc-coretag">@see</span><span class="src-doc"> botloaderinc.php</span></li>
<li><a name="a1007"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> learn()</span></li>
<li><a name="a1008"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> startS()</span></li>
<li><a name="a1009"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> endS()</span></li>
<li><a name="a1010"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> handlemeS()</span></li>
<li><a name="a1011"></a><span class="src-doc">*</span></li>
<li><a name="a1012"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">              the rootdirectory</span></li>
<li><a name="a1013"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">               Files to be learned</span></li>
<li><a name="a1014"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">               All the different bots in the startup.xml file</span></li>
<li><a name="a1015"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span><span class="src-doc">             ID of the selected bot</span></li>
<li><a name="a1016"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">boolean </span><span class="src-doc">             ????</span></li>
<li><a name="a1017"></a><span class="src-doc">*</span></li>
<li><a name="a1018"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span><span class="src-doc">                prints HTML</span></li>
<li><a name="a1019"></a><span class="src-doc">*/</span></li>
<li><a name="a1020"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionloadstartup">loadstartup</a><span class="src-sym">(</span><span class="src-sym">)</span></li>
<li><a name="a1021"></a><span class="src-sym">{</span></li>
<li><a name="a1022"></a>&nbsp;</li>
<li><a name="a1023"></a>    <span class="src-key">global </span><span class="src-var">$rootdir</span><span class="src-sym">,</span><span class="src-var">$learnfiles</span><span class="src-sym">,</span><span class="src-var">$allbots</span><span class="src-sym">,</span><span class="src-var">$selectbot</span><span class="src-sym">,</span><span class="src-var">$areinc</span><span class="src-sym">;</span></li>
<li><a name="a1024"></a>    </li>
<li><a name="a1025"></a>    <span class="src-var">$areinc</span>=<span class="src-num">1</span><span class="src-sym">;</span></li>
<li><a name="a1026"></a>&nbsp;</li>
<li><a name="a1027"></a>    print <span class="src-str">&quot;&lt;font size='3'&gt;Loading startup.xml&lt;BR&gt;&lt;/font&gt;\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1028"></a>    <span class="src-var">$learnfiles </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">; </span><span class="src-comm">// This array will hold the files to LEARN</span></li>
<li><a name="a1029"></a>&nbsp;</li>
<li><a name="a1030"></a>&nbsp;</li>
<li><a name="a1031"></a>    <span class="src-var">$file </span>= <span class="src-var">$rootdir </span>. <span class="src-str">&quot;startup.xml&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1032"></a>    <span class="src-var">$xml_parser </span>= <a href="http://www.php.net/xml_parser_create">xml_parser_create</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1033"></a>    <a href="http://www.php.net/xml_parser_set_option">xml_parser_set_option</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">,</span><span class="src-id">XML_OPTION_CASE_FOLDING</span><span class="src-sym">,</span><span class="src-num">0</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1034"></a>    <a href="http://www.php.net/xml_set_element_handler">xml_set_element_handler</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-str">&quot;startS&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;endS&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1035"></a>    <a href="http://www.php.net/xml_set_character_data_handler">xml_set_character_data_handler</a> <span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-str">&quot;handlemeS&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1036"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-sym">(</span><span class="src-var">$fp </span>= <a href="http://www.php.net/fopen">fopen</a><span class="src-sym">(</span><span class="src-var">$file</span><span class="src-sym">, </span><span class="src-str">&quot;r&quot;</span><span class="src-sym">))) </span><span class="src-sym">{</span></li>
<li><a name="a1037"></a>        <span class="src-key">die</span><span class="src-sym">(</span><span class="src-str">&quot;could not open XML input&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1038"></a>    <span class="src-sym">}</span></li>
<li><a name="a1039"></a>    <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$data </span>= <a href="http://www.php.net/fread">fread</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">, </span><span class="src-num">4096</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a1040"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/xml_parse">xml_parse</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-var">$data</span><span class="src-sym">, </span><a href="http://www.php.net/feof">feof</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">))) </span><span class="src-sym">{</span></li>
<li><a name="a1041"></a>            <span class="src-key">die</span><span class="src-sym">(</span><a href="http://www.php.net/sprintf">sprintf</a><span class="src-sym">(</span><span class="src-str">&quot;XML error: %s at line %d&quot;</span><span class="src-sym">,</span></li>
<li><a name="a1042"></a>                        <a href="http://www.php.net/xml_error_string">xml_error_string</a><span class="src-sym">(</span><a href="http://www.php.net/xml_get_error_code">xml_get_error_code</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">))</span><span class="src-sym">,</span></li>
<li><a name="a1043"></a>                        <a href="http://www.php.net/xml_get_current_line_number">xml_get_current_line_number</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">)))</span><span class="src-sym">;</span></li>
<li><a name="a1044"></a>        <span class="src-sym">}</span></li>
<li><a name="a1045"></a>    <span class="src-sym">}</span></li>
<li><a name="a1046"></a>    <a href="http://www.php.net/xml_parser_free">xml_parser_free</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1047"></a>&nbsp;</li>
<li><a name="a1048"></a>    <span class="src-comm"># For each of the bots learn all of the files</span></li>
<li><a name="a1049"></a>    <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$allbots </span><span class="src-key">as </span><span class="src-var">$bot</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a1050"></a>        print <span class="src-str">&quot;</span><span class="src-str">&lt;<span class="src-id">font</span> <span class="src-id">size</span>='3'&gt;&lt;<span class="src-id">b</span>&gt;<span class="src-id">Loading</span> <span class="src-id">bot</span>: <span class="src-var">$bot</span>&lt;<span class="src-id">BR</span>&gt;&lt;/<span class="src-id">b</span>&gt;&lt;/<span class="src-id">font</span>&gt;\n</span><span class="src-str">&quot;</span><span class="src-sym">;    </span></li>
<li><a name="a1051"></a>        <span class="src-var">$single_learnfiles </span>= <span class="src-var">$learnfiles</span><span class="src-sym">[</span><span class="src-var">$bot</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a1052"></a>        <span class="src-var">$single_learnfiles </span>= <a href="http://www.php.net/array_unique">array_unique</a><span class="src-sym">(</span><span class="src-var">$single_learnfiles</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1053"></a>        <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$single_learnfiles </span><span class="src-key">as </span><span class="src-var">$file</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a1054"></a>            <span class="src-var">$selectbot</span>=<span class="src-var">$bot</span><span class="src-sym">;</span></li>
<li><a name="a1055"></a>            <a href="../Loader/_admin_botloaderfuncs_php.html#functionlearn">learn</a><span class="src-sym">(</span><span class="src-var">$file</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1056"></a>        <span class="src-sym">}</span></li>
<li><a name="a1057"></a>    <span class="src-sym">}</span></li>
<li><a name="a1058"></a>&nbsp;</li>
<li><a name="a1059"></a><span class="src-sym">}</span></li>
<li><a name="a1060"></a>&nbsp;</li>
<li><a name="a1061"></a><span class="src-doc">/**</span></li>
<li><a name="a1062"></a><span class="src-doc">* Learn all the files in a directory ending with &quot;.aiml&quot;</span></li>
<li><a name="a1063"></a><span class="src-doc">*</span></li>
<li><a name="a1064"></a><span class="src-doc">* Read all the AIML filenames into the $learnfile Array. This array is then later on used by </span><span class="src-doc-inlinetag">{@link learn()}</span><span class="src-doc"> in </span><span class="src-doc-inlinetag">{@link handlemeS()}</span></li>
<li><a name="a1065"></a><span class="src-doc">*</span></li>
<li><a name="a1066"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">          the rootdirectory</span></li>
<li><a name="a1067"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">           contains all the filenames that need to be loaded into the bot.</span></li>
<li><a name="a1068"></a><span class="src-doc">*</span></li>
<li><a name="a1069"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$curbot </span><span class="src-doc">  ID of the current bot.</span></li>
<li><a name="a1070"></a><span class="src-doc">*</span></li>
<li><a name="a1071"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a1072"></a><span class="src-doc">*/</span></li>
<li><a name="a1073"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionlearnallfiles">learnallfiles</a><span class="src-sym">(</span><span class="src-var">$curbot</span><span class="src-sym">)</span></li>
<li><a name="a1074"></a><span class="src-sym">{</span></li>
<li><a name="a1075"></a>    <span class="src-key">global </span><span class="src-var">$rootdir</span><span class="src-sym">,</span><span class="src-var">$learnfiles</span><span class="src-sym">;</span></li>
<li><a name="a1076"></a>&nbsp;</li>
<li><a name="a1077"></a>    <span class="src-var">$dir</span>=<a href="http://www.php.net/opendir">opendir</a> <span class="src-sym">(</span><span class="src-var">$rootdir</span><span class="src-sym">)</span><span class="src-sym">; </span></li>
<li><a name="a1078"></a>    <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$file </span>= <a href="http://www.php.net/readdir">readdir</a><span class="src-sym">(</span><span class="src-var">$dir</span><span class="src-sym">)) </span><span class="src-sym">{ </span></li>
<li><a name="a1079"></a>        </li>
<li><a name="a1080"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$file</span><span class="src-sym">,</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$file</span><span class="src-sym">,</span><span class="src-str">&quot;.&quot;</span><span class="src-sym">))</span>==<span class="src-str">&quot;.aiml&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a1081"></a>&nbsp;</li>
<li><a name="a1082"></a>            <span class="src-var">$learnfiles</span><span class="src-sym">[</span><span class="src-var">$curbot</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-var">$file</span><span class="src-sym">;</span></li>
<li><a name="a1083"></a>        <span class="src-sym">}</span></li>
<li><a name="a1084"></a>    <span class="src-sym">}</span></li>
<li><a name="a1085"></a>&nbsp;</li>
<li><a name="a1086"></a>    <a href="http://www.php.net/closedir">closedir</a><span class="src-sym">(</span><span class="src-var">$dir</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1087"></a><span class="src-sym">}</span></li>
<li><a name="a1088"></a>&nbsp;</li>
<li><a name="a1089"></a>&nbsp;</li>
<li><a name="a1090"></a><span class="src-doc">/**</span></li>
<li><a name="a1091"></a><span class="src-doc">* Learn the AIML string.</span></li>
<li><a name="a1092"></a><span class="src-doc">*</span></li>
<li><a name="a1093"></a><span class="src-doc">* XML parse the AIML string. It seems to have a hardcoded time limit of 600, presume seconds.</span></li>
<li><a name="a1094"></a><span class="src-doc">* </span></li>
<li><a name="a1095"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> startElement()</span></li>
<li><a name="a1096"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> endElement()</span></li>
<li><a name="a1097"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> handleme()</span></li>
<li><a name="a1098"></a><span class="src-doc">*</span></li>
<li><a name="a1099"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$xmlstring </span><span class="src-doc">              the AIML category XML string</span></li>
<li><a name="a1100"></a><span class="src-doc">*</span></li>
<li><a name="a1101"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a1102"></a><span class="src-doc">*/</span></li>
<li><a name="a1103"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionlearnstring">learnstring</a><span class="src-sym">(</span><span class="src-var">$xmlstring</span><span class="src-sym">)</span></li>
<li><a name="a1104"></a><span class="src-sym">{</span></li>
<li><a name="a1105"></a>&nbsp;</li>
<li><a name="a1106"></a>    <a href="http://www.php.net/set_time_limit">set_time_limit</a><span class="src-sym">(</span><span class="src-num">600</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1107"></a>    <span class="src-var">$xml_parser </span>= <a href="http://www.php.net/xml_parser_create">xml_parser_create</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1108"></a>    <a href="http://www.php.net/xml_parser_set_option">xml_parser_set_option</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">,</span><span class="src-id">XML_OPTION_CASE_FOLDING</span><span class="src-sym">,</span><span class="src-num">0</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1109"></a>    <a href="http://www.php.net/xml_set_element_handler">xml_set_element_handler</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-str">&quot;startElement&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;endElement&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1110"></a>    <a href="http://www.php.net/xml_set_character_data_handler">xml_set_character_data_handler</a> <span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-str">&quot;handleme&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1111"></a>&nbsp;</li>
<li><a name="a1112"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/xml_parse">xml_parse</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-var">$xmlstring</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a1113"></a>        <span class="src-key">die</span><span class="src-sym">(</span><a href="http://www.php.net/sprintf">sprintf</a><span class="src-sym">(</span><span class="src-str">&quot;XML error: %s at line %d&quot;</span><span class="src-sym">,</span></li>
<li><a name="a1114"></a>                    <a href="http://www.php.net/xml_error_string">xml_error_string</a><span class="src-sym">(</span><a href="http://www.php.net/xml_get_error_code">xml_get_error_code</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">))</span><span class="src-sym">,</span></li>
<li><a name="a1115"></a>                    <a href="http://www.php.net/xml_get_current_line_number">xml_get_current_line_number</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">)))</span><span class="src-sym">;</span></li>
<li><a name="a1116"></a>    <span class="src-sym">}</span></li>
<li><a name="a1117"></a>&nbsp;</li>
<li><a name="a1118"></a>    <a href="http://www.php.net/xml_parser_free">xml_parser_free</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1119"></a><span class="src-sym">}</span></li>
<li><a name="a1120"></a>&nbsp;</li>
<li><a name="a1121"></a>&nbsp;</li>
<li><a name="a1122"></a><span class="src-doc">/**</span></li>
<li><a name="a1123"></a><span class="src-doc">* Learn an AIML file.</span></li>
<li><a name="a1124"></a><span class="src-doc">*</span></li>
<li><a name="a1125"></a><span class="src-doc">* Learn a single AIML XML file. Again, the hardcoded time limit is set to 600, presumably seconds.</span></li>
<li><a name="a1126"></a><span class="src-doc">*</span></li>
<li><a name="a1127"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> startElement()</span></li>
<li><a name="a1128"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> endElement()</span></li>
<li><a name="a1129"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> handleme()</span></li>
<li><a name="a1130"></a><span class="src-doc">*</span></li>
<li><a name="a1131"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">string </span><span class="src-doc">              The root directory</span></li>
<li><a name="a1132"></a><span class="src-doc">*</span></li>
<li><a name="a1133"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$file </span><span class="src-doc">         The AIML file name.</span></li>
<li><a name="a1134"></a><span class="src-doc">*/</span></li>
<li><a name="a1135"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionlearn">learn</a><span class="src-sym">(</span><span class="src-var">$file</span><span class="src-sym">)</span></li>
<li><a name="a1136"></a><span class="src-sym">{</span></li>
<li><a name="a1137"></a>&nbsp;</li>
<li><a name="a1138"></a>    <span class="src-key">global </span><span class="src-var">$rootdir</span><span class="src-sym">;</span></li>
<li><a name="a1139"></a>    <a href="http://www.php.net/set_time_limit">set_time_limit</a><span class="src-sym">(</span><span class="src-num">600</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1140"></a>    <span class="src-var">$xml_parser </span>= <a href="http://www.php.net/xml_parser_create">xml_parser_create</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1141"></a>    <a href="http://www.php.net/xml_parser_set_option">xml_parser_set_option</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">,</span><span class="src-id">XML_OPTION_CASE_FOLDING</span><span class="src-sym">,</span><span class="src-num">0</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1142"></a>    <a href="http://www.php.net/xml_set_element_handler">xml_set_element_handler</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-str">&quot;startElement&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;endElement&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1143"></a>    <a href="http://www.php.net/xml_set_character_data_handler">xml_set_character_data_handler</a> <span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-str">&quot;handleme&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1144"></a>    print <span class="src-str">&quot;</span><span class="src-str">&lt;<span class="src-id">font</span> <span class="src-id">size</span>='3'&gt;<span class="src-id">Loading</span> <span class="src-id">data</span> <span class="src-id">aiml</span> <span class="src-id">file</span>: <span class="src-var">$file</span>&lt;<span class="src-id">BR</span>&gt;&lt;/<span class="src-id">font</span>&gt;\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1145"></a>    <a href="http://www.php.net/flush">flush</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1146"></a>&nbsp;</li>
<li><a name="a1147"></a>    <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$file</span><span class="src-sym">,</span><span class="src-num">0</span><span class="src-sym">,</span><span class="src-num">7</span><span class="src-sym">))</span>==<span class="src-str">&quot;HTTP://&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a1148"></a>        <span class="src-var">$file</span>=<span class="src-var">$file</span><span class="src-sym">;</span></li>
<li><a name="a1149"></a>    <span class="src-sym">}</span></li>
<li><a name="a1150"></a>    <span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a1151"></a>        <span class="src-var">$file</span>=<span class="src-var">$rootdir </span>. <span class="src-var">$file</span><span class="src-sym">;</span></li>
<li><a name="a1152"></a>    <span class="src-sym">}</span></li>
<li><a name="a1153"></a>    </li>
<li><a name="a1154"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-sym">(</span><span class="src-var">$fp </span>= <a href="http://www.php.net/fopen">fopen</a><span class="src-sym">(</span><span class="src-var">$file</span><span class="src-sym">, </span><span class="src-str">&quot;r&quot;</span><span class="src-sym">))) </span><span class="src-sym">{</span></li>
<li><a name="a1155"></a>        <span class="src-key">die</span><span class="src-sym">(</span><span class="src-str">&quot;could not open XML input&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1156"></a>    <span class="src-sym">}</span></li>
<li><a name="a1157"></a>&nbsp;</li>
<li><a name="a1158"></a>    <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$data </span>= <a href="http://www.php.net/fread">fread</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">, </span><span class="src-num">4096</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a1159"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/xml_parse">xml_parse</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">, </span><span class="src-var">$data</span><span class="src-sym">, </span><a href="http://www.php.net/feof">feof</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">))) </span><span class="src-sym">{</span></li>
<li><a name="a1160"></a>            <span class="src-key">die</span><span class="src-sym">(</span><a href="http://www.php.net/sprintf">sprintf</a><span class="src-sym">(</span><span class="src-str">&quot;XML error: %s at line %d&quot;</span><span class="src-sym">,</span></li>
<li><a name="a1161"></a>                        <a href="http://www.php.net/xml_error_string">xml_error_string</a><span class="src-sym">(</span><a href="http://www.php.net/xml_get_error_code">xml_get_error_code</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">))</span><span class="src-sym">,</span></li>
<li><a name="a1162"></a>                        <a href="http://www.php.net/xml_get_current_line_number">xml_get_current_line_number</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">)))</span><span class="src-sym">;</span></li>
<li><a name="a1163"></a>        <span class="src-sym">}</span></li>
<li><a name="a1164"></a>    <span class="src-sym">} </span></li>
<li><a name="a1165"></a>    <a href="http://www.php.net/fclose">fclose</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1166"></a>    <a href="http://www.php.net/xml_parser_free">xml_parser_free</a><span class="src-sym">(</span><span class="src-var">$xml_parser</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1167"></a><span class="src-sym">}</span></li>
<li><a name="a1168"></a>&nbsp;</li>
<li><a name="a1169"></a><span class="src-doc">/**</span></li>
<li><a name="a1170"></a><span class="src-doc">* Start a timer</span></li>
<li><a name="a1171"></a><span class="src-doc">*</span></li>
<li><a name="a1172"></a><span class="src-doc">* Save the start time of the to be timed script</span></li>
<li><a name="a1173"></a><span class="src-doc">* </span></li>
<li><a name="a1174"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">ss_timing_start_times          contains the start moments of the script</span></li>
<li><a name="a1175"></a><span class="src-doc">*</span></li>
<li><a name="a1176"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">                         default value is 'default' Makes it possibe to time more than</span></li>
<li><a name="a1177"></a><span class="src-doc">*                                               event in one script.</span></li>
<li><a name="a1178"></a><span class="src-doc">*</span></li>
<li><a name="a1179"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span><span class="src-doc">                                nothing</span></li>
<li><a name="a1180"></a><span class="src-doc">*/</span></li>
<li><a name="a1181"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionss_timing_start">ss_timing_start</a> <span class="src-sym">(</span><span class="src-var">$name </span>= <span class="src-str">'default'</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a1182"></a>    <span class="src-key">global </span><span class="src-var">$ss_timing_start_times</span><span class="src-sym">;</span></li>
<li><a name="a1183"></a>    <span class="src-var">$ss_timing_start_times</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">] </span>= <a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">' '</span><span class="src-sym">, </span><a href="http://www.php.net/microtime">microtime</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a1184"></a><span class="src-sym">}</span></li>
<li><a name="a1185"></a>&nbsp;</li>
<li><a name="a1186"></a><span class="src-doc">/**</span></li>
<li><a name="a1187"></a><span class="src-doc">* Stop a timer</span></li>
<li><a name="a1188"></a><span class="src-doc">*</span></li>
<li><a name="a1189"></a><span class="src-doc">* Save the stop time of the to be timed script</span></li>
<li><a name="a1190"></a><span class="src-doc">* </span></li>
<li><a name="a1191"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">ss_timing_stop_times          contains the stop moments of a script</span></li>
<li><a name="a1192"></a><span class="src-doc">*</span></li>
<li><a name="a1193"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">                         default value is 'default' Makes it possibe to time more than</span></li>
<li><a name="a1194"></a><span class="src-doc">*                                               event in one script.</span></li>
<li><a name="a1195"></a><span class="src-doc">*</span></li>
<li><a name="a1196"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span><span class="src-doc">                                nothing</span></li>
<li><a name="a1197"></a><span class="src-doc">*/</span></li>
<li><a name="a1198"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionss_timing_stop">ss_timing_stop</a> <span class="src-sym">(</span><span class="src-var">$name </span>= <span class="src-str">'default'</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a1199"></a>    <span class="src-key">global </span><span class="src-var">$ss_timing_stop_times</span><span class="src-sym">;</span></li>
<li><a name="a1200"></a>    <span class="src-var">$ss_timing_stop_times</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">] </span>= <a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">' '</span><span class="src-sym">, </span><a href="http://www.php.net/microtime">microtime</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a1201"></a><span class="src-sym">}</span></li>
<li><a name="a1202"></a>&nbsp;</li>
<li><a name="a1203"></a><span class="src-doc">/**</span></li>
<li><a name="a1204"></a><span class="src-doc">* Retrieve timer data</span></li>
<li><a name="a1205"></a><span class="src-doc">*</span></li>
<li><a name="a1206"></a><span class="src-doc">* Get the running time the timed script</span></li>
<li><a name="a1207"></a><span class="src-doc">* </span></li>
<li><a name="a1208"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">ss_timing_start_times          contains the start and finish moments of the script</span></li>
<li><a name="a1209"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">ss_timing_stop_times          contains the stop moments of a script</span></li>
<li><a name="a1210"></a><span class="src-doc">*</span></li>
<li><a name="a1211"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$name </span><span class="src-doc">                         default value is 'default' Makes it possibe to time more than</span></li>
<li><a name="a1212"></a><span class="src-doc">*                                               event in one script.</span></li>
<li><a name="a1213"></a><span class="src-doc">*</span></li>
<li><a name="a1214"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">                               the formated running time of the timed stript.</span></li>
<li><a name="a1215"></a><span class="src-doc">*/</span></li>
<li><a name="a1216"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionss_timing_current">ss_timing_current</a> <span class="src-sym">(</span><span class="src-var">$name </span>= <span class="src-str">'default'</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a1217"></a>    <span class="src-key">global </span><span class="src-var">$ss_timing_start_times</span><span class="src-sym">, </span><span class="src-var">$ss_timing_stop_times</span><span class="src-sym">;</span></li>
<li><a name="a1218"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span>isset<span class="src-sym">(</span><span class="src-var">$ss_timing_start_times</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a1219"></a>        <span class="src-key">return </span><span class="src-num">0</span><span class="src-sym">;</span></li>
<li><a name="a1220"></a>    <span class="src-sym">}</span></li>
<li><a name="a1221"></a>    <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span>isset<span class="src-sym">(</span><span class="src-var">$ss_timing_stop_times</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a1222"></a>        <span class="src-var">$stop_time </span>= <a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">' '</span><span class="src-sym">, </span><a href="http://www.php.net/microtime">microtime</a><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a1223"></a>    <span class="src-sym">}</span></li>
<li><a name="a1224"></a>    <span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a1225"></a>        <span class="src-var">$stop_time </span>= <span class="src-var">$ss_timing_stop_times</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a1226"></a>    <span class="src-sym">}</span></li>
<li><a name="a1227"></a>    <span class="src-comm">// do the big numbers first so the small ones aren't lost</span></li>
<li><a name="a1228"></a>    <span class="src-var">$current </span>= <span class="src-var">$stop_time</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">] </span>- <span class="src-var">$ss_timing_start_times</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a1229"></a>    <span class="src-var">$current </span>+= <span class="src-var">$stop_time</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">] </span>- <span class="src-var">$ss_timing_start_times</span><span class="src-sym">[</span><span class="src-var">$name</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a1230"></a>    <span class="src-key">return </span><span class="src-var">$current</span><span class="src-sym">;</span></li>
<li><a name="a1231"></a><span class="src-sym">}</span></li>
<li><a name="a1232"></a>&nbsp;</li>
<li><a name="a1233"></a>&nbsp;</li>
<li><a name="a1234"></a><span class="src-doc">/**</span></li>
<li><a name="a1235"></a><span class="src-doc">* Creates the PHP array code for subs.inc.</span></li>
<li><a name="a1236"></a><span class="src-doc">*</span></li>
<li><a name="a1237"></a><span class="src-doc">* Subs.inc contains PHP code written during the bot load process. This function creates the array PHP code and returns the code as a string.</span></li>
<li><a name="a1238"></a><span class="src-doc">*</span></li>
<li><a name="a1239"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> cleanforsearch()</span></li>
<li><a name="a1240"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> cleanforreplace()</span></li>
<li><a name="a1241"></a><span class="src-doc">* </span></li>
<li><a name="a1242"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc">         is an array with either gender, person(2), input and splitter details</span></li>
<li><a name="a1243"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc">        which array is being processed, is also the array namein subs.inc.</span></li>
<li><a name="a1244"></a><span class="src-doc">* </span></li>
<li><a name="a1245"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">       the array PHP code</span></li>
<li><a name="a1246"></a><span class="src-doc">*/</span></li>
<li><a name="a1247"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionmakesrphp">makesrphp</a><span class="src-sym">(</span><span class="src-var">$inarray</span><span class="src-sym">,</span><span class="src-var">$sname</span><span class="src-sym">)</span></li>
<li><a name="a1248"></a><span class="src-sym">{</span></li>
<li><a name="a1249"></a>&nbsp;</li>
<li><a name="a1250"></a>    <span class="src-var">$myphp</span>=<span class="src-str">&quot;\$&quot; </span>. <span class="src-var">$sname </span>. <span class="src-str">&quot;search=array(\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1251"></a>&nbsp;</li>
<li><a name="a1252"></a>    <span class="src-key">for </span><span class="src-sym">(</span><span class="src-var">$x</span>=<span class="src-num">0</span><span class="src-sym">;</span><span class="src-var">$x</span>&lt;<a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$inarray</span><span class="src-sym">)</span><span class="src-sym">;</span><span class="src-var">$x</span>++<span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a1253"></a>&nbsp;</li>
<li><a name="a1254"></a>        <span class="src-var">$searchvar</span>=<a href="../Loader/_admin_botloaderfuncs_php.html#functioncleanforsearch">cleanforsearch</a><span class="src-sym">(</span><span class="src-var">$inarray</span><span class="src-sym">[</span><span class="src-var">$x</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1255"></a>&nbsp;</li>
<li><a name="a1256"></a>        <span class="src-var">$beginsearch</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1257"></a>        <span class="src-var">$endsearch</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1258"></a>&nbsp;</li>
<li><a name="a1259"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$searchvar</span><span class="src-sym">,</span><span class="src-num">0</span><span class="src-sym">,</span><span class="src-num">1</span><span class="src-sym">)</span>==<span class="src-str">&quot; &quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a1260"></a>            <span class="src-var">$beginsearch</span>=<span class="src-str">&quot;\\b&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1261"></a>        <span class="src-sym">}</span></li>
<li><a name="a1262"></a>        <span class="src-key">if </span><span class="src-sym">((</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$searchvar</span><span class="src-sym">,</span><a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$searchvar</span><span class="src-sym">)</span>-<span class="src-num">1</span><span class="src-sym">,</span><span class="src-num">1</span><span class="src-sym">))</span>==<span class="src-str">&quot; &quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a1263"></a>            <span class="src-var">$endsearch</span>=<span class="src-str">&quot;\\b&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1264"></a>        <span class="src-sym">}</span></li>
<li><a name="a1265"></a>        <span class="src-var">$myphp</span>.=<span class="src-str">&quot;</span><span class="src-str">\&quot;/<span class="src-var">$beginsearch</span></span><span class="src-str">&quot; </span>. <a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$searchvar</span><span class="src-sym">) </span>. <span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$endsearch</span>/<span class="src-id">ie</span>\&quot;,\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1266"></a>&nbsp;</li>
<li><a name="a1267"></a>    <span class="src-sym">}</span></li>
<li><a name="a1268"></a>&nbsp;</li>
<li><a name="a1269"></a>    <span class="src-var">$myphp</span>.=<span class="src-str">&quot;);\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1270"></a>&nbsp;</li>
<li><a name="a1271"></a>    <span class="src-var">$myphp</span>.=<span class="src-str">&quot;\$&quot; </span>. <span class="src-var">$sname </span>. <span class="src-str">&quot;replace=array(\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1272"></a>&nbsp;</li>
<li><a name="a1273"></a>    <span class="src-key">for </span><span class="src-sym">(</span><span class="src-var">$x</span>=<span class="src-num">0</span><span class="src-sym">;</span><span class="src-var">$x</span>&lt;<a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$inarray</span><span class="src-sym">)</span><span class="src-sym">;</span><span class="src-var">$x</span>++<span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a1274"></a>        <span class="src-var">$myphp</span>.=<span class="src-str">&quot;\&quot;myfunc('&quot; </span>. <a href="../Loader/_admin_botloaderfuncs_php.html#functioncleanforreplace">cleanforreplace</a><span class="src-sym">(</span><span class="src-var">$inarray</span><span class="src-sym">[</span><span class="src-var">$x</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">) </span>. <span class="src-str">&quot;')\&quot;,\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1275"></a>    <span class="src-sym">}</span></li>
<li><a name="a1276"></a>&nbsp;</li>
<li><a name="a1277"></a>    <span class="src-var">$myphp</span>.=<span class="src-str">&quot;);\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1278"></a>    <span class="src-key">return </span><span class="src-var">$myphp</span><span class="src-sym">;</span></li>
<li><a name="a1279"></a>&nbsp;</li>
<li><a name="a1280"></a><span class="src-sym">}</span></li>
<li><a name="a1281"></a>&nbsp;</li>
<li><a name="a1282"></a>&nbsp;</li>
<li><a name="a1283"></a><span class="src-doc">/**</span></li>
<li><a name="a1284"></a><span class="src-doc">* Load an AIML string. String must be valid XML.</span></li>
<li><a name="a1285"></a><span class="src-doc">*</span></li>
<li><a name="a1286"></a><span class="src-doc">* This is going to need to take bot as a parameter</span></li>
<li><a name="a1287"></a><span class="src-doc">*</span></li>
<li><a name="a1288"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> flushcache()</span></li>
<li><a name="a1289"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> learnstring()</span></li>
<li><a name="a1290"></a><span class="src-doc">*</span></li>
<li><a name="a1291"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span><span class="src-doc">          bot ID.</span></li>
<li><a name="a1292"></a><span class="src-doc">* </span></li>
<li><a name="a1293"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$aimlstring </span><span class="src-doc">   The AIML string to be loaded.</span></li>
<li><a name="a1294"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$botid </span><span class="src-doc">       The bot's ID.</span></li>
<li><a name="a1295"></a><span class="src-doc">*</span></li>
<li><a name="a1296"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a1297"></a><span class="src-doc">*/</span></li>
<li><a name="a1298"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionloadaimlstring">loadaimlstring</a><span class="src-sym">(</span><span class="src-var">$aimlstring</span><span class="src-sym">,</span><span class="src-var">$botid</span><span class="src-sym">)</span></li>
<li><a name="a1299"></a><span class="src-sym">{</span></li>
<li><a name="a1300"></a>&nbsp;</li>
<li><a name="a1301"></a>    <span class="src-key">global </span><span class="src-var">$selectbot</span><span class="src-sym">;</span></li>
<li><a name="a1302"></a>&nbsp;</li>
<li><a name="a1303"></a>    <span class="src-var">$selectbot</span>=<span class="src-var">$botid</span><span class="src-sym">;</span></li>
<li><a name="a1304"></a>&nbsp;</li>
<li><a name="a1305"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionflushcache">flushcache</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1306"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionlearnstring">learnstring</a><span class="src-sym">(</span><span class="src-var">$aimlstring</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1307"></a>&nbsp;</li>
<li><a name="a1308"></a><span class="src-sym">}</span></li>
<li><a name="a1309"></a>&nbsp;</li>
<li><a name="a1310"></a>&nbsp;</li>
<li><a name="a1311"></a><span class="src-doc">/**</span></li>
<li><a name="a1312"></a><span class="src-doc">* Load an AIML string that is just a category.</span></li>
<li><a name="a1313"></a><span class="src-doc">*</span></li>
<li><a name="a1314"></a><span class="src-doc">* This is going to need to take bot as a parameter</span></li>
<li><a name="a1315"></a><span class="src-doc">*</span></li>
<li><a name="a1316"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> flushcache()</span></li>
<li><a name="a1317"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> learnstring()</span></li>
<li><a name="a1318"></a><span class="src-doc">*</span></li>
<li><a name="a1319"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">integer </span><span class="src-doc">          bot ID.</span></li>
<li><a name="a1320"></a><span class="src-doc">* </span></li>
<li><a name="a1321"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$aimlstring </span><span class="src-doc">   The AIML string to be loaded.</span></li>
<li><a name="a1322"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$botid </span><span class="src-doc">       The bot's ID.</span></li>
<li><a name="a1323"></a><span class="src-doc">*</span></li>
<li><a name="a1324"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a1325"></a><span class="src-doc">*/</span></li>
<li><a name="a1326"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionloadaimlcategory">loadaimlcategory</a><span class="src-sym">(</span><span class="src-var">$aimlstring</span><span class="src-sym">,</span><span class="src-var">$botid</span><span class="src-sym">)</span></li>
<li><a name="a1327"></a><span class="src-sym">{</span></li>
<li><a name="a1328"></a>&nbsp;</li>
<li><a name="a1329"></a>    <span class="src-key">global </span><span class="src-var">$selectbot</span><span class="src-sym">;</span></li>
<li><a name="a1330"></a>&nbsp;</li>
<li><a name="a1331"></a>    <span class="src-var">$selectbot</span>=<span class="src-var">$botid</span><span class="src-sym">;</span></li>
<li><a name="a1332"></a>    </li>
<li><a name="a1333"></a>    <span class="src-var">$aimlstring</span>=<span class="src-str">&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;ISO-8859-1\&quot;&quot; </span>. <span class="src-str">&quot;?&quot; </span>. <span class="src-str">&quot;&gt;&lt;aiml version=\&quot;1.0\&quot;&gt;&quot; </span>. <span class="src-var">$aimlstring </span>. <span class="src-str">&quot;&lt;/aiml&gt;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1334"></a>&nbsp;</li>
<li><a name="a1335"></a>&nbsp;</li>
<li><a name="a1336"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionflushcache">flushcache</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1337"></a>&nbsp;</li>
<li><a name="a1338"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionlearnstring">learnstring</a><span class="src-sym">(</span><span class="src-var">$aimlstring</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1339"></a>&nbsp;</li>
<li><a name="a1340"></a><span class="src-sym">}</span></li>
<li><a name="a1341"></a>&nbsp;</li>
<li><a name="a1342"></a>&nbsp;</li>
<li><a name="a1343"></a><span class="src-doc">/**</span></li>
<li><a name="a1344"></a><span class="src-doc">* Create the array PHP code for the sentence splitters</span></li>
<li><a name="a1345"></a><span class="src-doc">*</span></li>
<li><a name="a1346"></a><span class="src-doc">* In AIML it is custom to return a reply for every sentence the user inputs.</span></li>
<li><a name="a1347"></a><span class="src-doc">* This means the sentence input needs to be split into individual sentences.</span></li>
<li><a name="a1348"></a><span class="src-doc">* However, some people find that the semi-colon should also be added, while</span></li>
<li><a name="a1349"></a><span class="src-doc">* others think it should. The user will define the sentence splitters in</span></li>
<li><a name="a1350"></a><span class="src-doc">* startup.xml and these will then be stored in a PHP file included by the</span></li>
<li><a name="a1351"></a><span class="src-doc">* application.</span></li>
<li><a name="a1352"></a><span class="src-doc">*</span></li>
<li><a name="a1353"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$splitterarray </span><span class="src-doc">      containing the sentence splitters found in startup.xml</span></li>
<li><a name="a1354"></a><span class="src-doc">* </span></li>
<li><a name="a1355"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">                   PHP array code for storing the sentence splitters</span></li>
<li><a name="a1356"></a><span class="src-doc">*/</span></li>
<li><a name="a1357"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionmakesplitterphp">makesplitterphp</a><span class="src-sym">(</span><span class="src-var">$splitterarray</span><span class="src-sym">)</span></li>
<li><a name="a1358"></a><span class="src-sym">{</span></li>
<li><a name="a1359"></a>    <span class="src-var">$splitterphp</span>=<span class="src-str">&quot;\$likeperiodsearch=array(\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1360"></a>    <span class="src-key">for </span><span class="src-sym">(</span><span class="src-var">$x</span>=<span class="src-num">0</span><span class="src-sym">;</span><span class="src-var">$x</span>&lt;<a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$splitterarray</span><span class="src-sym">)</span><span class="src-sym">;</span><span class="src-var">$x</span>++<span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a1361"></a>        </li>
<li><a name="a1362"></a>        <span class="src-var">$splitterphp</span>.=<span class="src-str">&quot;\&quot;&quot; </span>. <span class="src-var">$splitterarray</span><span class="src-sym">[</span><span class="src-var">$x</span><span class="src-sym">] </span>. <span class="src-str">&quot;\&quot;,\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1363"></a>&nbsp;</li>
<li><a name="a1364"></a>    <span class="src-sym">}</span></li>
<li><a name="a1365"></a>    <span class="src-var">$splitterphp</span>.=<span class="src-str">&quot;);\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1366"></a>&nbsp;</li>
<li><a name="a1367"></a>    <span class="src-var">$splitterphp</span>.=<span class="src-str">&quot;\$likeperiodreplace=array(\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1368"></a>    <span class="src-key">for </span><span class="src-sym">(</span><span class="src-var">$x</span>=<span class="src-num">0</span><span class="src-sym">;</span><span class="src-var">$x</span>&lt;<a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$splitterarray</span><span class="src-sym">)</span><span class="src-sym">;</span><span class="src-var">$x</span>++<span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a1369"></a>        </li>
<li><a name="a1370"></a>        <span class="src-var">$splitterphp</span>.=<span class="src-str">&quot;\&quot;&quot; </span>. <span class="src-str">&quot;.&quot; </span>. <span class="src-str">&quot;\&quot;,\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1371"></a>&nbsp;</li>
<li><a name="a1372"></a>    <span class="src-sym">}</span></li>
<li><a name="a1373"></a>    <span class="src-var">$splitterphp</span>.=<span class="src-str">&quot;);\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a1374"></a>    </li>
<li><a name="a1375"></a>    <span class="src-key">return </span><span class="src-var">$splitterphp</span><span class="src-sym">;</span></li>
<li><a name="a1376"></a><span class="src-sym">}</span></li>
<li><a name="a1377"></a>&nbsp;</li>
<li><a name="a1378"></a>&nbsp;</li>
<li><a name="a1379"></a>&nbsp;</li>
<li><a name="a1380"></a><span class="src-doc">/**</span></li>
<li><a name="a1381"></a><span class="src-doc">* Add slashes for replacement purposes</span></li>
<li><a name="a1382"></a><span class="src-doc">*</span></li>
<li><a name="a1383"></a><span class="src-doc">* Making a string safe to preform a replacement function on.</span></li>
<li><a name="a1384"></a><span class="src-doc">* </span></li>
<li><a name="a1385"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$input </span><span class="src-doc">          string to be cleaned.</span></li>
<li><a name="a1386"></a><span class="src-doc">* </span></li>
<li><a name="a1387"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">                cleaned string.</span></li>
<li><a name="a1388"></a><span class="src-doc">*/</span></li>
<li><a name="a1389"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functioncleanforreplace">cleanforreplace</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span></li>
<li><a name="a1390"></a><span class="src-sym">{</span></li>
<li><a name="a1391"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;\\&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\\\\&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1392"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;\&quot;&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\\\&quot;&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1393"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;'&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\'&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1394"></a>    <span class="src-key">return </span><a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1395"></a><span class="src-sym">}</span></li>
<li><a name="a1396"></a>&nbsp;</li>
<li><a name="a1397"></a>&nbsp;</li>
<li><a name="a1398"></a>&nbsp;</li>
<li><a name="a1399"></a><span class="src-doc">/**</span></li>
<li><a name="a1400"></a><span class="src-doc">* Add slashes for database query purpose</span></li>
<li><a name="a1401"></a><span class="src-doc">*</span></li>
<li><a name="a1402"></a><span class="src-doc">* Making a string safe to put the text in an SQL query.</span></li>
<li><a name="a1403"></a><span class="src-doc">* </span></li>
<li><a name="a1404"></a><span class="src-doc">* </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$input </span><span class="src-doc">          string to be cleaned.</span></li>
<li><a name="a1405"></a><span class="src-doc">* </span></li>
<li><a name="a1406"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">                cleaned string.</span></li>
<li><a name="a1407"></a><span class="src-doc">*/</span></li>
<li><a name="a1408"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functioncleanforsearch">cleanforsearch</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span></li>
<li><a name="a1409"></a><span class="src-sym">{</span></li>
<li><a name="a1410"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;\\&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\\\\\\\\&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1411"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;\&quot;&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\\\&quot;&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1412"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;'&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\'&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1413"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;/&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\/&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1414"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;(&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\(&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1415"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;)&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\)&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1416"></a>    <span class="src-var">$input </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;.&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;\.&quot;</span><span class="src-sym">, </span><span class="src-var">$input</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1417"></a>    <span class="src-key">return </span><span class="src-var">$input</span><span class="src-sym">;</span></li>
<li><a name="a1418"></a><span class="src-sym">}</span></li>
<li><a name="a1419"></a>&nbsp;</li>
<li><a name="a1420"></a>&nbsp;</li>
<li><a name="a1421"></a><span class="src-doc">/**</span></li>
<li><a name="a1422"></a><span class="src-doc">* Creates the subs.inc file.</span></li>
<li><a name="a1423"></a><span class="src-doc">*</span></li>
<li><a name="a1424"></a><span class="src-doc">* Creates the subs.inc file and fills it with 5 arrays that correspond to the 4 substitution sections and sentence splitters.</span></li>
<li><a name="a1425"></a><span class="src-doc">*</span></li>
<li><a name="a1426"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> makesrphp()</span></li>
<li><a name="a1427"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> makesplitterphp()</span></li>
<li><a name="a1428"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> createsubfile()</span></li>
<li><a name="a1429"></a><span class="src-doc">* </span><span class="src-doc-coretag">@uses</span><span class="src-doc"> addtosubs()</span></li>
<li><a name="a1430"></a><span class="src-doc">*</span></li>
<li><a name="a1431"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">             contains the gender substitutions</span></li>
<li><a name="a1432"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">             contains the person substitutions</span></li>
<li><a name="a1433"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">             contains the person2 substitutions</span></li>
<li><a name="a1434"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">             ?????</span></li>
<li><a name="a1435"></a><span class="src-doc">* </span><span class="src-doc-coretag">@global </span><span class="src-doc-type">array </span><span class="src-doc">             contains the sentence splitters</span></li>
<li><a name="a1436"></a><span class="src-doc">*</span></li>
<li><a name="a1437"></a><span class="src-doc">* </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span><span class="src-doc">              Writes a file.</span></li>
<li><a name="a1438"></a><span class="src-doc">*/</span></li>
<li><a name="a1439"></a>&nbsp;</li>
<li><a name="a1440"></a><span class="src-key">function </span><a href="../Loader/_admin_botloaderfuncs_php.html#functionmakesubscode">makesubscode</a><span class="src-sym">(</span><span class="src-sym">)</span></li>
<li><a name="a1441"></a><span class="src-sym">{</span></li>
<li><a name="a1442"></a>&nbsp;</li>
<li><a name="a1443"></a>    <span class="src-key">global </span><span class="src-var">$genderarray</span><span class="src-sym">,</span><span class="src-var">$personarray</span><span class="src-sym">,</span><span class="src-var">$person2array</span><span class="src-sym">,</span><span class="src-var">$inputarray</span><span class="src-sym">,</span><span class="src-var">$splitterarray</span><span class="src-sym">;</span></li>
<li><a name="a1444"></a>&nbsp;</li>
<li><a name="a1445"></a>    <span class="src-var">$genderphp </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functionmakesrphp">makesrphp</a><span class="src-sym">(</span><span class="src-var">$genderarray</span><span class="src-sym">, </span><span class="src-str">&quot;gender&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1446"></a>    <span class="src-var">$personphp </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functionmakesrphp">makesrphp</a><span class="src-sym">(</span><span class="src-var">$personarray</span><span class="src-sym">, </span><span class="src-str">&quot;firstthird&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1447"></a>    <span class="src-var">$person2php </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functionmakesrphp">makesrphp</a><span class="src-sym">(</span><span class="src-var">$person2array</span><span class="src-sym">, </span><span class="src-str">&quot;firstsecond&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1448"></a>    <span class="src-var">$inputphp </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functionmakesrphp">makesrphp</a><span class="src-sym">(</span><span class="src-var">$inputarray</span><span class="src-sym">, </span><span class="src-str">&quot;contract&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1449"></a>    <span class="src-var">$splitterphp </span>= <a href="../Loader/_admin_botloaderfuncs_php.html#functionmakesplitterphp">makesplitterphp</a><span class="src-sym">(</span><span class="src-var">$splitterarray</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1450"></a>&nbsp;</li>
<li><a name="a1451"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functioncreatesubfile">createsubfile</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1452"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionaddtosubs">addtosubs</a><span class="src-sym">(</span><span class="src-str">&quot;&lt;?\n&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1453"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionaddtosubs">addtosubs</a><span class="src-sym">(</span><span class="src-var">$genderphp</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1454"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionaddtosubs">addtosubs</a><span class="src-sym">(</span><span class="src-var">$personphp</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1455"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionaddtosubs">addtosubs</a><span class="src-sym">(</span><span class="src-var">$person2php</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1456"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionaddtosubs">addtosubs</a><span class="src-sym">(</span><span class="src-var">$inputphp</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1457"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionaddtosubs">addtosubs</a><span class="src-sym">(</span><span class="src-var">$splitterphp</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1458"></a>    <a href="../Loader/_admin_botloaderfuncs_php.html#functionaddtosubs">addtosubs</a><span class="src-sym">(</span><span class="src-str">&quot;\n?&gt;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a1459"></a>&nbsp;</li>
<li><a name="a1460"></a><span class="src-sym">}</span></li>
<li><a name="a1461"></a>&nbsp;</li>
<li><a name="a1462"></a><span class="src-php">?&gt;</span></li>
</ol></pre>
</div>
	<p class="notes" id="credit">
		Documentation generated on Wed, 12 Jan 2005 12:24:44 +0100 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
	</p>
	</body>
</html>
Return current item: Program E