Exemple #1
0
/**
 * Returns an HTML form, filled with the current chatbot's configuration data
 *
 *
 * @return string
 */
function getSelectedBot()
{
    global $dbConn, $template, $pattern, $remember_up_to, $conversation_lines, $error_response, $curBot, $unknown_user;
    $bot_conversation_lines = $conversation_lines;
    $bot_default_aiml_pattern = $pattern;
    $bot_error_response = $error_response;
    $bot_unknown_user = $unknown_user;
    $inputs = '';
    $form = $template->getSection('SelectBotForm');
    $sel_session = '';
    $sel_db = '';
    $sel_html = '';
    $sel_xml = '';
    $sel_json = '';
    $sel_yes = '';
    $sel_no = '';
    $sel_fyes = '';
    $sel_fno = '';
    $sel_fuyes = '';
    $sel_funo = '';
    $ds_ = '';
    $ds_i = '';
    $ds_ii = '';
    $ds_iii = '';
    $ds_iv = '';
    $dm_ = '';
    $dm_i = '';
    $dm_ii = '';
    $dm_iii = '';
    $dm_iv = '';
    $bot_id = isset($_SESSION['poadmin']['bot_id']) ? $_SESSION['poadmin']['bot_id'] : 'new';
    if ($bot_id != "new") {
        $sql = "SELECT * FROM `bots` where bot_id = :bot_id;";
        $sth = $dbConn->prepare($sql);
        $sth->bindValue(':bot_id', $bot_id);
        $sth->execute();
        $row = $sth->fetch();
        $curBot = $row;
        foreach ($row as $key => $value) {
            if (strstr($key, 'bot_') != false) {
                $tmp = '';
                ${$key} = $value;
            } else {
                $tmp = "bot_{$key}";
                ${$tmp} = $value;
            }
        }
        if ($bot_active == "1") {
            $sel_yes = ' selected="selected"';
        } else {
            $sel_no = ' selected="selected"';
        }
        if ($bot_save_state == "database") {
            $sel_db = ' selected="selected"';
        } else {
            $sel_session = ' selected="selected"';
        }
        if ($bot_format == "html") {
            $sel_html = ' selected="selected"';
        } elseif ($bot_format == "xml") {
            $sel_xml = ' selected="selected"';
        } elseif ($bot_format == "json") {
            $sel_json = ' selected="selected"';
        }
        if ($bot_debugshow == "0") {
            $ds_ = ' selected="selected"';
        } elseif ($bot_debugshow == "1") {
            $ds_i = ' selected="selected"';
        } elseif ($bot_debugshow == "2") {
            $ds_ii = ' selected="selected"';
        } elseif ($bot_debugshow == "3") {
            $ds_iii = ' selected="selected"';
        } elseif ($bot_debugshow == "4") {
            $ds_iv = ' selected="selected"';
        }
        /** @noinspection PhpUndefinedVariableInspection */
        if ($bot_debugmode == "0") {
            $dm_ = ' selected="selected"';
        } elseif ($bot_debugmode == "1") {
            $dm_i = ' selected="selected"';
        } elseif ($bot_debugmode == "2") {
            $dm_ii = ' selected="selected"';
        } elseif ($bot_debugmode == "3") {
            $dm_iii = ' selected="selected"';
        } elseif ($bot_debugmode == "4") {
            $dm_iv = ' selected="selected"';
        }
        $action = "update";
    } else {
        $bot_id = '';
        $bot_parent_id = 0;
        $bot_name = '';
        $bot_desc = '';
        $bot_active = '';
        $action = "add";
        $bot_format = '';
        $bot_conversation_lines = $conversation_lines;
        //$remember_up_to = $remember_up_to;
        $bot_default_aiml_pattern = $pattern;
        $bot_error_response = $error_response;
        $bot_debugemail = '';
        $debugemail = '';
        $bot_debugshow = '';
        $bot_debugmode = '';
    }
    $parent_options = getBotParentList($bot_parent_id);
    $searches = array('[bot_id]', '[bot_name]', '[bot_desc]', '[parent_options]', '[sel_yes]', '[sel_no]', '[sel_html]', '[sel_xml]', '[sel_json]', '[sel_session]', '[sel_db]', '[sel_fyes]', '[sel_fno]', '[sel_fuyes]', '[sel_funo]', '[bot_conversation_lines]', '[remember_up_to]', '[bot_debugemail]', '[dm_]', '[dm_i]', '[dm_ii]', '[dm_iii]', '[ds_]', '[ds_i]', '[ds_ii]', '[ds_iii]', '[ds_iv]', '[action]', '[bot_default_aiml_pattern]', '[bot_error_response]', '[bot_unknown_user]', '[unknown_user]');
    foreach ($searches as $search) {
        $replace = str_replace('[', '', $search);
        $replace = str_replace(']', '', $replace);
        $form = str_replace($search, ${$replace}, $form);
    }
    return $form;
}
Exemple #2
0
function getSelectedBot()
{
    global $template, $default_pattern, $default_remember_up_to, $default_conversation_lines, $default_error_response;
    $bot_conversation_lines = $default_conversation_lines;
    $bot_remember_up_to = $default_remember_up_to;
    $bot_default_aiml_pattern = $default_pattern;
    $bot_error_response = $default_error_response;
    $dbconn = db_open();
    $inputs = "";
    $form = $template->getSection('SelectBotForm');
    $sel_session = "";
    $sel_db = "";
    $sel_html = "";
    $sel_xml = "";
    $sel_json = "";
    $sel_yes = "";
    $sel_no = "";
    $sel_fyes = "";
    $sel_fno = "";
    $sel_fuyes = "";
    $sel_funo = "";
    $ds_ = "";
    $ds_i = "";
    $ds_ii = "";
    $ds_iii = "";
    $ds_iv = "";
    $dm_ = "";
    $dm_i = "";
    $dm_ii = "";
    $dm_iii = "";
    $dm_iv = "";
    if ($_SESSION['poadmin']['bot_id'] != "new") {
        $bot_id = $_SESSION['poadmin']['bot_id'];
        //get data for all of the bots from the db
        $sql = "SELECT * FROM `bots` where bot_id = '{$bot_id}';";
        $result = mysql_query($sql, $dbconn) or die('You have a SQL error on line ' . __LINE__ . ' of ' . __FILE__ . '. Error message is: ' . mysql_error() . '.');
        while ($row = mysql_fetch_assoc($result)) {
            foreach ($row as $key => $value) {
                if (strstr($key, 'bot_') != false) {
                    $tmp = '';
                    ${$key} = $value;
                } else {
                    $tmp = "bot_{$key}";
                    ${$tmp} = $value;
                }
            }
            if ($bot_active == "1") {
                $sel_yes = ' selected="selected"';
            } else {
                $sel_no = ' selected="selected"';
            }
            if ($bot_save_state == "database") {
                $sel_db = ' selected="selected"';
            } else {
                $sel_session = ' selected="selected"';
            }
            if ($bot_format == "html") {
                $sel_html = ' selected="selected"';
            } elseif ($bot_format == "xml") {
                $sel_xml = ' selected="selected"';
            } elseif ($bot_format == "json") {
                $sel_json = ' selected="selected"';
            }
            if ($bot_use_aiml_code == "1") {
                $sel_fuyes = ' selected="selected"';
            } elseif ($bot_use_aiml_code == "0") {
                $sel_funo = ' selected="selected"';
            }
            if ($bot_update_aiml_code == "1") {
                $sel_fyes = ' selected="selected"';
            } elseif ($bot_update_aiml_code == "0") {
                $sel_fno = ' selected="selected"';
            }
            if ($bot_debugshow == "0") {
                $ds_ = ' selected="selected"';
            } elseif ($bot_debugshow == "1") {
                $ds_i = ' selected="selected"';
            } elseif ($bot_debugshow == "2") {
                $ds_ii = ' selected="selected"';
            } elseif ($bot_debugshow == "3") {
                $ds_iii = ' selected="selected"';
            } elseif ($bot_debugshow == "4") {
                $ds_iv = ' selected="selected"';
            }
            if ($bot_debugmode == "0") {
                $dm_ = ' selected="selected"';
            } elseif ($bot_debugmode == "1") {
                $dm_i = ' selected="selected"';
            } elseif ($bot_debugmode == "2") {
                $dm_ii = ' selected="selected"';
            } elseif ($bot_debugmode == "3") {
                $dm_iii = ' selected="selected"';
            } elseif ($bot_debugmode == "4") {
                $dm_iv = ' selected="selected"';
            }
            $action = "update";
        }
        mysql_close($dbconn);
    } else {
        $bot_id = "";
        $bot_parent_id = 0;
        $bot_name = "";
        $bot_desc = "";
        $bot_active = "";
        $action = "add";
        $bot_format = "";
        $bot_use_aiml_code = "";
        $bot_update_aiml_code = "";
        $bot_conversation_lines = $default_conversation_lines;
        $bot_remember_up_to = $default_remember_up_to;
        $bot_default_aiml_pattern = $default_pattern;
        $bot_error_response = $default_error_response;
        $bot_debugemail = "";
        $debugemail = "";
        $bot_debugshow = "";
        $bot_debugmode = "";
    }
    $parent_options = getBotParentList($bot_parent_id, $dbconn);
    $searches = array('[bot_id]', '[bot_name]', '[bot_desc]', '[parent_options]', '[sel_yes]', '[sel_no]', '[sel_html]', '[sel_xml]', '[sel_json]', '[sel_session]', '[sel_db]', '[sel_fyes]', '[sel_fno]', '[sel_fuyes]', '[sel_funo]', '[bot_conversation_lines]', '[bot_remember_up_to]', '[bot_debugemail]', '[dm_]', '[dm_i]', '[dm_ii]', '[dm_iii]', '[ds_]', '[ds_i]', '[ds_ii]', '[ds_iii]', '[ds_iv]', '[action]', '[bot_default_aiml_pattern]', '[bot_error_response]');
    foreach ($searches as $search) {
        $replace = str_replace('[', '', $search);
        $replace = str_replace(']', '', $replace);
        $form = str_replace($search, ${$replace}, $form);
    }
    return $form;
}