Esempio n. 1
0
/**
 * Adds a new chatbot to the database
 *
 *
 * @return string
 */
function addBot()
{
    //db globals
    global $dbConn, $msg, $post_vars;
    foreach ($post_vars as $key => $value) {
        ${$key} = trim($value);
    }
    /** @noinspection PhpUndefinedVariableInspection */
    $sql = <<<endSQL
INSERT INTO `bots`(`bot_id`, `bot_name`, `bot_desc`, `bot_active`, `bot_parent_id`, `format`, `save_state`, `conversation_lines`, `remember_up_to`, `debugemail`, `debugshow`, `debugmode`, `default_aiml_pattern`, `error_response`)
VALUES (NULL,'{$bot_name}','{$bot_desc}','{$bot_active}','{$bot_parent_id}','{$format}','{$save_state}','{$conversation_lines}','{$remember_up_to}','{$debugemail}','{$debugshow}','{$debugmode}','{$aiml_pattern}','{$error_response}');
endSQL;
    $sth = $dbConn->prepare($sql);
    $sth->execute();
    $affectedRows = $sth->rowCount();
    if ($affectedRows > 0) {
        $msg = "{$bot_name} Bot details added, please dont forget to create the bot personality and add the aiml.";
    } else {
        $msg = "{$bot_name} Bot details could not be added.";
    }
    $_SESSION['poadmin']['bot_id'] = $dbConn->lastInsertId();
    $bot_id = $_SESSION['poadmin']['bot_id'];
    $_SESSION['poadmin']['bot_name'] = $post_vars['bot_name'];
    $bot_name = $_SESSION['poadmin']['bot_name'];
    $msg .= make_bot_predicates($bot_id);
    return $msg;
}
Esempio n. 2
0
/**
 * Adds a new chatbot to the database
 *
 *
 * @return string
 */
function addBot()
{
    //db globals
    global $dbConn, $msg, $post_vars;
    foreach ($post_vars as $key => $value) {
        ${$key} = trim($value);
    }
    /** @noinspection PhpUndefinedVariableInspection */
    $sql = 'INSERT INTO `bots`(`bot_id`, `bot_name`, `bot_desc`, `bot_active`, `bot_parent_id`, `format`, `save_state`, `conversation_lines`, `remember_up_to`, `debugemail`, `debugshow`, `debugmode`, `default_aiml_pattern`, `error_response`)
VALUES (NULL,:bot_name,:bot_desc,:bot_active,:bot_parent_id,:format,:save_state,:conversation_lines,:remember_up_to,:debugemail,:debugshow,:debugmode,:aiml_pattern,:error_response);';
    $params = array(':bot_name' => $bot_name, ':bot_desc' => $bot_desc, ':bot_desc' => $bot_desc, ':bot_active' => $bot_active, ':bot_parent_id' => $bot_parent_id, ':format' => $format, ':save_state' => $save_state, ':conversation_lines' => $conversation_lines, ':remember_up_to' => $remember_up_to, ':debugemail' => $debugemail, ':debugshow' => $debugshow, ':debugmode' => $debugmode, ':aiml_pattern' => $default_aiml_pattern, ':error_response' => $error_response);
    $affectedRows = db_write($sql, $params, false, __FILE__, __FUNCTION__, __LINE__);
    if ($affectedRows > 0) {
        $msg = "{$bot_name} Bot details added, please dont forget to create the bot personality and add the aiml.";
    } else {
        $msg = "{$bot_name} Bot details could not be added.";
    }
    $_SESSION['poadmin']['bot_id'] = $dbConn->lastInsertId();
    $bot_id = $_SESSION['poadmin']['bot_id'];
    $_SESSION['poadmin']['bot_name'] = $post_vars['bot_name'];
    $bot_name = $_SESSION['poadmin']['bot_name'];
    $msg .= make_bot_predicates($bot_id);
    return $msg;
}