public static function birthday() { $birthday = JxBotConfig::bot('birthday'); if ($birthday == '') { return ''; } $birthtime = strtotime(trim($birthday)); return date('F j, Y', $birthtime); }
protected function walk($in_parent_id, $in_term_index) { /* check search depth to prevent infinite recursion */ $this->search_depth++; if ($this->search_depth > JxBotEngine::MAX_SEARCH_DEPTH) { throw new Exception('Too much recursion (in pattern search)'); } /* look in this branch for all possible matching sub-branches; ie. an exact match with the input term, or, a wildcard or complex pattern term such as a bot property or AIML 2 'set' */ $stmt = JxBotDB::$db->prepare("SELECT id,expression,is_terminal FROM pattern_node \n\t\t\tWHERE parent=? AND ( (expression = ? AND sort_key IN (0,5)) OR (sort_key NOT IN (0,5)) ) \n\t\t\tORDER BY sort_key"); $current_term = $this->get_term($in_term_index); $stmt->execute(array($in_parent_id, $current_term)); $possible_branches = $stmt->fetchAll(PDO::FETCH_NUM); //print "Walk parent=$in_parent_id, term_index=$in_term_index, term=$current_term<br>"; //print '<pre>'; //var_dump($possible_branches); //print '</pre>'; foreach ($possible_branches as $possibility) { /* decode the possibility and prepare to match */ list($br_parent, $br_expr, $br_terminal) = $possibility; // in future, for speed, this information could be assessed at pattern registration // and stored & accessed, possibly using the sort key integer ? $is_wildcard = JxBotEngine::is_wildcard($br_expr); $set_ref = JxBotEngine::is_set_ref($br_expr); $bot_ref = JxBotEngine::is_bot_ref($br_expr); //print $br_expr; //print "Considering possible branch=$br_parent, expr=$br_expr, term=$br_terminal, wild=$is_wildcard :<br>"; // pattern side sets & bot tags will have to be handled similarly, since they may have multi-word values // basically, like wildcards, except all words must match /* branch to appropriate match handler depending on type of branch */ if ($bot_ref !== false || $set_ref !== false) { /* match: bot predicate or set reference: */ if ($bot_ref !== false) { $values = array(JxBotNL::normalise(JxBotConfig::bot($bot_ref))); $match = $this->try_match_values($br_parent, $values, false, $in_term_index, $br_terminal); } else { $values = JxBotNLData::set_values($set_ref); $match = $this->try_match_values($br_parent, $values, true, $in_term_index, $br_terminal); } } else { if (!$is_wildcard) { /* match: normal word or pattern clause separator: */ $match = $this->try_match_word($br_parent, $br_expr, $in_term_index, $br_terminal); } else { /* match: wildcard */ $match = $this->try_match_wildcard($br_parent, $br_expr, $in_term_index, $br_terminal); } } /* if matching was successful, return the matching pattern, otherwise, continue looking at sub-branches at this level */ if ($match !== false) { return $match; } } /* no possible subbranches; no match this branch */ $this->search_depth--; return false; }