コード例 #1
0
ファイル: graphnew.php プロジェクト: erico-deh/ocPortal
/**
* Check to see if exact input-that-topic exists in cache
*
* GmCache is a log that contains all unique entries. If the exact same input-that-topic is requested that is found in GmCache, then it's template reference is used instead of traversing the binary AIML tree. Saving response time.
*
* @param string $combined                  the complete input in <input>word word<that>word word<topic>word word format. 
* @param array &$inputstarvals   contents of the *'s when they are part of the matching pattern input string
* @param array &$thatstarvals    contents of the *'s when they are part of the matching pattern that string
* @param array &$topicstarvals   contents of the *'s when they are part of the matching pattern topic string
* @param array &$patternmatched  all the patterns that match input, i.e. multiple sentences are kept seperate.
* @param array &$inputmatched    all the matched input.
*
* @return boolean                true/false Note, info is also transfere through the call-by-reference variables.
*/
function checkcache($combined, &$template, &$inputstarvals, &$thatstarvals, &$topicstarvals, &$patternmatched, &$inputmatched)
{
    $ccquery = "select template,inputstarvals,thatstarvals,topicstarvals,patternmatched,inputmatched from gmcache where combined='" . addslashes($combined) . "' and " . whichbots();
    $selectcode = mysql_query($ccquery);
    if ($selectcode) {
        if (!mysql_numrows($selectcode)) {
            return false;
        } else {
            while ($q = mysql_fetch_array($selectcode)) {
                $template = findtemplate($q[0]);
                $inputstarvals = explode(",", $q[1]);
                $thatstarvals = explode(",", $q[2]);
                $topicstarvals = explode(",", $q[3]);
                $patternmatched = $q[4];
                $inputmatched = $q[5];
                return true;
            }
        }
    }
    return false;
}
コード例 #2
0
ファイル: util.php プロジェクト: erico-deh/ocPortal
/**
* Gets the numer of AIML categories stored in the database
*
* The size of the AIML knowledgebase is counted in categories. This function
* will count the number of categories based upon the number of records in the
* templates table.
*
* @uses whichbots()
*
* @return integer         the number of templates in the template database. 
*/
function getsize()
{
    $query = "select count(*) from templates where " . whichbots();
    $selectcode = mysql_query($query);
    if ($selectcode) {
        if (!mysql_numrows($selectcode)) {
            return 0;
        } else {
            while ($q = mysql_fetch_array($selectcode)) {
                return $q[0];
            }
        }
    }
    return "";
}