Exemplo n.º 1
0
require LIVEZILLA_PATH . "_lib/functions.global.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php";
require LIVEZILLA_PATH . "_lib/functions.index.inc.php";
languageSelect();
@set_error_handler("handleError");
$scheme = getScheme();
if (isset($_GET[GET_INDEX_SERVER_ACTION]) && $_GET[GET_INDEX_SERVER_ACTION] == "addserver") {
    $html = doReplacements(getFile(TEMPLATE_HTML_ADD_SERVER));
    $html = str_replace("<!--lz_add_url-->", getServerAddLink($scheme), $html);
    exit($html);
} else {
    $html = getFile(TEMPLATE_HTML_INDEX);
    $errorbox = null;
    $errors['write'] = getFolderPermissions();
    $errors['php_version'] = getPhpVersion();
    $errors['mysql'] = getMySQL();
    if (!empty($errors['write']) || !empty($errors['php_version']) || !empty($errors['mysql'])) {
        $errorbox = getFile(TEMPLATE_HTML_INDEX_ERRORS);
        $errorbox = str_replace("<!--write_access-->", $errors['write'], $errorbox);
        if (strlen($errors['write']) > 0 && !empty($errors['php_version'])) {
            $errors['php_version'] = "<br><br>" . $errors['php_version'];
        }
        if ((strlen($errors['write']) > 0 || !empty($errors['php_version'])) && !empty($errors['mysql'])) {
            $errors['mysql'] = "<br><br>" . $errors['mysql'];
        }
        $errorbox = str_replace("<!--mysql-->", $errors['mysql'], $errorbox);
        $errorbox = str_replace("<!--php_version-->", $errors['php_version'], $errorbox);
    }
    $html = str_replace("<!--index_errors-->", $errorbox, $html);
function listenXML($runs = 1)
{
    global $CONFIG, $RESPONSE, $INTERNAL, $QCOUNT, $QLIST;
    processActions();
    if (!SERVERSETUP && !LOGIN && $INTERNAL[CALLER_SYSTEM_ID]->Status == USER_STATUS_OFFLINE) {
        return;
    }
    $start = time();
    /*while(time() < $start + getLongPollRuntime() || $runs == 1)
    	{
    		if($runs > 1)
    			getData(true,false,true,false);*/
    $RESPONSE->XML = "<listen disabled=\"" . base64_encode(getAvailability() ? "0" : "1") . "\" h=\"<!--gl_all-->\" " . (isset($_POST[POST_INTERN_XMLCLIP_HASH_EXECUTION_TIME]) ? "ex_time=\"<!--execution_time-->\"" : "") . ">\r\n";
    $RESPONSE->Typing = "";
    if ($RESPONSE->Login != null) {
        $RESPONSE->XML .= $RESPONSE->Login;
    }
    buildSystem();
    //if($runs++ == 1)
    processPosts();
    if (($hash = substr(md5($RESPONSE->Typing), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_TYPING] && strlen($RESPONSE->Typing) > 0) {
        $RESPONSE->XML .= "<gl_typ h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Typing . "</gl_typ>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Events), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_EVENTS]) {
        $RESPONSE->XML .= "<gl_ev h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Events . "</gl_ev>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Exceptions), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_ERRORS] && strlen($RESPONSE->Exceptions) > 0) {
        $RESPONSE->XML .= "<gl_e h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Exceptions . "</gl_e>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Internals), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_INTERN] && strlen($RESPONSE->Internals) > 0) {
        $RESPONSE->XML .= "<int_r h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Internals . "</int_r>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Groups), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_GROUPS] && strlen($RESPONSE->Groups) > 0) {
        $RESPONSE->XML .= "<int_d h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Groups . "</int_d>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Actions), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_ACTIONS]) {
        $RESPONSE->XML .= "<int_ac h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Actions . "</int_ac>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->InternalVcards), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_PROFILES]) {
        $RESPONSE->XML .= "<int_v h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->InternalVcards . "</int_v>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->InternalProfilePictures), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_PICTURES_PROFILE]) {
        $RESPONSE->XML .= "<int_pp h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->InternalProfilePictures . "</int_pp>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->InternalWebcamPictures), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_PICTURES_WEBCAM]) {
        $RESPONSE->XML .= "<int_wp h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->InternalWebcamPictures . "</int_wp>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Goals), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_GOALS]) {
        $RESPONSE->XML .= "<int_t h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Goals . "</int_t>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Filter), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_FILTERS]) {
        $RESPONSE->XML .= "<ext_b h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Filter . "</ext_b>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Tracking), 0, 5)) != @$_POST[POST_INTERN_XMLCLIP_HASH_TRACKING]) {
        $RESPONSE->XML .= "<ext_u h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Tracking . "</ext_u>\r\n";
    }
    if ($RESPONSE->Archive != null) {
        $RESPONSE->XML .= "<ext_c>\r\n" . $RESPONSE->Archive . "</ext_c>\r\n";
    }
    if ($RESPONSE->Resources != null) {
        $RESPONSE->XML .= "<ext_res>\r\n" . $RESPONSE->Resources . "</ext_res>\r\n";
    }
    if ($RESPONSE->Ratings != null) {
        $RESPONSE->XML .= "<ext_r>\r\n" . $RESPONSE->Ratings . "</ext_r>\r\n";
    }
    if ($RESPONSE->Messages != null) {
        $RESPONSE->XML .= "<ext_m>\r\n" . $RESPONSE->Messages . "</ext_m>\r\n";
    }
    if (strlen($RESPONSE->Authentications) > 0) {
        $RESPONSE->XML .= "<gl_auths>\r\n" . $RESPONSE->Authentications . "\r\n</gl_auths>\r\n";
    }
    if (strlen($RESPONSE->Posts) > 0) {
        $RESPONSE->XML .= "<usr_p>\r\n" . $RESPONSE->Posts . "</usr_p>\r\n";
    }
    if (isset($_POST[POST_INTERN_ACCESSTEST])) {
        $RESPONSE->XML .= "<permission>" . base64_encode(getFolderPermissions()) . "</permission>";
    }
    if (SERVERSETUP || LOGIN || $INTERNAL[CALLER_SYSTEM_ID]->LastActive <= @filemtime(FILE_CONFIG)) {
        $RESPONSE->XML .= getConfig();
    }
    $RESPONSE->XML .= "</listen>";
    /*
    	if(substr_count($RESPONSE->XML,"<") > 4 || $INTERNAL[CALLER_SYSTEM_ID]->Status == USER_STATUS_OFFLINE || isset($_POST[POST_GLOBAL_NO_LONG_POLL]))
    	{
    		break;
    	}
    	else
    	{
    		if(isset($_POST[POST_GLOBAL_SHOUT]))
    			break;
    		$wait = max($CONFIG["poll_frequency_clients"]-3,1);
    		if(time()+$wait <= $start + getLongPollRuntime())
    		{
    			sleep($wait);
    		}
    		else
    			break;
    	}
    }
    */
}
function listenXML()
{
    global $RESPONSE, $INTERNAL;
    processActions();
    if (!SERVERSETUP && !LOGIN && $INTERNAL[CALLER_SYSTEM_ID]->Status == USER_STATUS_OFFLINE) {
        return;
    }
    $RESPONSE->XML = "<listen disabled=\"" . base64_encode(getAvailability(false) ? "0" : "1") . "\" h=\"<!--gl_all-->\" " . (isset($_POST[POST_INTERN_XMLCLIP_HASH_EXECUTION_TIME]) ? "ex_time=\"<!--execution_time-->\"" : "") . ">\r\n";
    $RESPONSE->Typing = "";
    if ($RESPONSE->Login != null) {
        $RESPONSE->XML .= $RESPONSE->Login;
    }
    buildSystem();
    processPosts();
    if (($hash = substr(md5($RESPONSE->Typing), 0, 5)) != @$_POST["p_gl_t"] && strlen($RESPONSE->Typing) > 0) {
        $RESPONSE->XML .= "<gl_typ h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Typing . "</gl_typ>\r\n";
    }
    $RESPONSE->XML .= $RESPONSE->Events . "\r\n";
    if (($hash = substr(md5($RESPONSE->Exceptions), 0, 5)) != @$_POST["p_gl_e"] && strlen($RESPONSE->Exceptions) > 0) {
        $RESPONSE->XML .= "<gl_e h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Exceptions . "</gl_e>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Internals), 0, 5)) != @$_POST["p_int_r"] && strlen($RESPONSE->Internals) > 0) {
        $RESPONSE->XML .= "<int_r h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Internals . "</int_r>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Groups), 0, 5)) != @$_POST["p_int_d"] && strlen($RESPONSE->Groups) > 0) {
        $RESPONSE->XML .= "<int_d h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Groups . "</int_d>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Actions), 0, 5)) != @$_POST["p_int_ev"]) {
        $RESPONSE->XML .= "<int_ac h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Actions . "</int_ac>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->InternalVcards), 0, 5)) != @$_POST["p_int_v"]) {
        $RESPONSE->XML .= "<int_v h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->InternalVcards . "</int_v>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->InternalWebcamPictures), 0, 5)) != @$_POST["p_int_wp"]) {
        $RESPONSE->XML .= "<int_wp h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->InternalWebcamPictures . "</int_wp>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Goals), 0, 5)) != @$_POST["p_int_t"]) {
        $RESPONSE->XML .= "<int_t h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Goals . "</int_t>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Filter), 0, 5)) != @$_POST["p_ext_b"]) {
        $RESPONSE->XML .= "<ext_b h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Filter . "</ext_b>\r\n";
    }
    if (!empty($RESPONSE->Tracking) && ($hash = substr(md5($RESPONSE->Tracking), 0, 5)) != @$_POST["p_ext_u"]) {
        $RESPONSE->XML .= "<ext_u h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Tracking . "</ext_u>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->Forwards), 0, 5)) != @$_POST["p_ext_f"]) {
        $RESPONSE->XML .= "<ext_f h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->Forwards . "</ext_f>\r\n";
    }
    if (($hash = substr(md5($RESPONSE->ChatVouchers), 0, 5)) != @$_POST["p_ext_ct"]) {
        $RESPONSE->XML .= "<ext_ct h=\"" . base64_encode($hash) . "\">\r\n" . $RESPONSE->ChatVouchers . "</ext_ct>\r\n";
    }
    if ($RESPONSE->Archive != null) {
        $RESPONSE->XML .= "<ext_c>\r\n" . $RESPONSE->Archive . "</ext_c>\r\n";
    }
    if ($RESPONSE->Resources != null) {
        $RESPONSE->XML .= "<ext_res>\r\n" . $RESPONSE->Resources . "</ext_res>\r\n";
    }
    if ($RESPONSE->Ratings != null) {
        $RESPONSE->XML .= "<ext_r>\r\n" . $RESPONSE->Ratings . "</ext_r>\r\n";
    }
    $RESPONSE->XML .= $RESPONSE->Messages . "\r\n";
    if (strlen($RESPONSE->Authentications) > 0) {
        $RESPONSE->XML .= "<gl_auths>\r\n" . $RESPONSE->Authentications . "\r\n</gl_auths>\r\n";
    }
    if (strlen($RESPONSE->Posts) > 0) {
        $RESPONSE->XML .= "<usr_p>\r\n" . $RESPONSE->Posts . "</usr_p>\r\n";
    }
    if (isset($_POST[POST_INTERN_ACCESSTEST])) {
        $RESPONSE->XML .= "<permission>" . base64_encode(getFolderPermissions()) . "</permission>";
    }
    if (SERVERSETUP || LOGIN || $INTERNAL[CALLER_SYSTEM_ID]->LastActive <= @filemtime(FILE_CONFIG)) {
        $RESPONSE->XML .= getConfig();
    }
    $RESPONSE->XML .= "</listen>";
}