Пример #1
0
	public function handle($params)
	{
		// check flooding using SysCache before handle Controller
		if (SysCache::$floodingChecked == false && SysCache::getFloodLimit() > 0) {
			$ip = $_SERVER['REMOTE_ADDR'];
			if (isFlooding( SysCache::$c->get('reqtime'.$ip) )) die('flooding!');
			SysCache::$c->set('reqtime'.$ip, microtime(true), 15);
			SysCache::$floodingChecked = true; // check only once per visitor
		}
		
		// call Controller
		$this->params = $params;
		$this->view();
	}
Пример #2
0
/**
 * laceListener()
 *
 * Checks POST variables for incoming messages or
 * update requests.
 */
function laceListener($fromListener = true)
{
    $cookie_name = cookieVar(LACE_NAME_COOKIE, false);
    $post_name = postVar('name', false);
    // name
    $post_text = postVar('text', false);
    // text
    if ($post_name !== false && $post_text !== false) {
        if (validateSession() === false) {
            return '"chat":{"nodata":"1"}';
        }
        if (isFlooding() === true) {
            return '"chat":{"nodata":"1"}';
        }
        $message = prepareMessage($post_name, $post_text);
        if ($message !== false) {
            if ($cookie_name && $cookie_name != $post_name) {
                addNameChange($cookie_name, $post_name);
            } else {
                global $A;
                // Activity object
                joinMessage($post_name);
                $A->update($post_name);
            }
            // Reset $name just in case it has been changed
            global $name;
            $name = $post_name;
            setcookie(LACE_NAME_COOKIE, $post_name, time() + 259200, LACE_URL_REL);
            addMessage($message);
        }
    }
    if ($fromListener) {
        $chatHash = postVar('chatHash', false);
        if ($chatHash) {
            $hash = getMessageHash();
            if (validateSession() === false || $chatHash == $hash) {
                return '"chat":{"nodata":""}';
            }
            $json = '"chat":{"hash":"' . $hash . '","data":"';
            $json .= addslashes(str_replace("\n", "", printFileContentsHTML())) . '"}';
            return $json;
        }
        return '"chat":{"nodata":""}';
    }
    return '"chat":{"nodata":""}';
}