コード例 #1
0
ファイル: phpenv.php プロジェクト: quartemer/xoopserver
function ss_timing_start($name = 'default')
{
    global $ss_timing_start_times;
    $ss_timing_start_times[$name] = explode(' ', microtime());
}
function ss_timing_stop($name = 'default')
{
    global $ss_timing_stop_times;
    $ss_timing_stop_times[$name] = explode(' ', microtime());
}
function ss_timing_current($name = 'default')
{
    global $ss_timing_start_times, $ss_timing_stop_times;
    if (!isset($ss_timing_start_times[$name])) {
        return 0;
    }
    if (!isset($ss_timing_stop_times[$name])) {
        $stop_time = explode(' ', microtime());
    } else {
        $stop_time = $ss_timing_stop_times[$name];
    }
    // do the big numbers first so the small ones aren't lost
    $current = $stop_time[1] - $ss_timing_start_times[$name][1];
    $current += $stop_time[0] - $ss_timing_start_times[$name][0];
    return $current;
}
ss_timing_start();
phpinfo();
ss_timing_stop();
echo "<hr><br>\r\n      <div class=\"confirm\">The page was executed in : " . ss_timing_current() . " seconds.</div>";
include_once "http://localhost/a/plugins/themefooter.html";
コード例 #2
0
/**
* Main container function in creating the bot's reply.
*
* This function is the 'manager' of all the sub-funtions that do the real processing. It creates a class
* called Response that is used throughout the application.
*
* @uses addinputs()
* @uses addthats()
* @uses bget()
* @uses cleanup()
* @uses getthat()
* @uses loadcustomtags()
* @uses logconversation()
* @uses normalsentences()
* @uses respond()
* @uses ss_timing_current()
* @uses ss_timing_start()
* @uses ss_timing_stop()
*
* @global string that                   The conversation's previous bot output
* @global string topic                  The contents of the AIML tag 'Topic'
* @global integer uid                   The session ID of the user (previously $uniqueid)
* @global integer loopcounter           Counts the number of time a particular category is used in the same match trace.
* @global array patternmatched          The pattern's that matched the
*
* @param string $userinput              The user's input.
* @param integer $uniqueid              The user's session ID.
* @param integer $bot                   The bot's ID.
*
* @return object                        A class link to 'Response'.
*/
function reply($userinput, $uniqueid, $bot)
{
    if (strstr($userinput, "There is no such a bot loaded")) {
        $myresponse->response = $userinput;
    } else {
        global $that, $topic, $uid, $loopcounter, $patternmatched, $inputmatched, $selectbot;
        cleanup();
        ss_timing_start("all");
        $patternmatched = array();
        $inputmatched = array();
        $myresponse = new Response();
        $myresponse->errors = "";
        $uid = $uniqueid;
        $selectbot = $bot;
        // Load the custom plugin tags
        loadcustomtags();
        // Get the "that" and the "topic"
        $that = getthat(1, 1);
        $topic = bget("TOPIC");
        // Normalize the input
        $allinputs = normalsentences($userinput);
        // If nothing said then use INACTIVITY special input
        if (sizeof($allinputs) == 0) {
            $allinputs[] = "INACTIVITY";
        }
        // Put all the inputs into the <input> stack.
        addinputs($allinputs);
        $finalanswer = "";
        // Build our response to all of the inputs.
        for ($x = 0; $x < sizeof($allinputs); $x++) {
            $finalanswer .= respond($allinputs[$x]);
        }
        if ($loopcounter > LOOPINGLIMIT && LOOPINGLIMIT != -1) {
            $finalanswer = LOOPINGERRORMSG;
            $myresponse->errors = "LOOPINGLIMIT";
        }
        // Put the final answers into the <that> stack.
        addthats(normalsentences($finalanswer));
        // Log the conversation
        logconversation($userinput, $finalanswer);
        $myresponse->response = $finalanswer;
        $myresponse->patternsmatched = $patternmatched;
        $myresponse->inputs = $inputmatched;
        ss_timing_stop("all");
        $myresponse->timer = ss_timing_current("all");
    }
    return $myresponse;
}
コード例 #3
0
$patternsinserted = 0;
$depth = array();
$whaton = "";
$pattern = "";
$topic = "";
$that = "";
$template = "";
$startupwhich = "";
$splitterarray = array();
$inputarray = array();
$genderarray = array();
$personarray = array();
$person2array = array();
loadstartup();
makesubscode();
print "<font size='3' color='RED'><b>DONE LOADING</B><br /></font>\n";
print "<font size='3' color='BLUE'>Inserted {$templatesinserted} categories into database</font><br />\n";
print "<font size='3' color='BLUE'>Inserted {$patternsinserted} sentences into database</font><br /><br />\n";
print "<font size='3' color='RED'><b>WARNING!</b> You should either delete or rename the botloader.php and botloaderinc.php scripts, otherwise people may be able to abuse your server.</b></font>\n";
print "<p><font size='3' color='BLACK'><a href='talk.php'>Click here to talk to the bot</a></p></font>\n";
print "<br />";
ss_timing_stop("all");
print "<br /><br /><font size='3' color='BLACK'>execution time: " . ss_timing_current("all");
$avgts = round($templatesinserted / ss_timing_current("all"));
$avgtm = round($templatesinserted / (ss_timing_current("all") / 60));
print "<br /><font size='3' color='BLACK'>Templates per second={$avgts}<br />";
print "<font size='3' color='BLACK'>Templates per minute={$avgtm}<br />";
$avgps = round($patternsinserted / ss_timing_current("all"));
$avgpm = round($patternsinserted / (ss_timing_current("all") / 60));
print "<font size='3' color='BLACK'>Patterns per second={$avgps}<br />";
print "<font size='3' color='BLACK'>Patterns per minute={$avgpm}<br />";