Exemple #1
0
    if (!isnull(getCookieValue("userid"))) {
        define("CALLER_BROWSER_ID", getId(USER_ID_LENGTH));
        define("CALLER_USER_ID", getCookieValue("userid"));
    }
}
if (!defined("CALLER_USER_ID")) {
    if (!JAVASCRIPT) {
        define("CALLER_USER_ID", substr(md5(getIP()), 0, USER_ID_LENGTH));
        define("CALLER_BROWSER_ID", substr(strrev(md5(getIP())), 0, USER_ID_LENGTH));
    } else {
        define("CALLER_USER_ID", getId(USER_ID_LENGTH));
        define("CALLER_BROWSER_ID", getId(USER_ID_LENGTH));
    }
}
$EXTERNALUSER = new Visitor(CALLER_USER_ID);
$EXTERNALUSER->Load();
if (isset($_GET[GET_TRACK_OUTPUT_TYPE]) && ($_GET[GET_TRACK_OUTPUT_TYPE] == "jscript" || $_GET[GET_TRACK_OUTPUT_TYPE] == "jcrpt")) {
    $fullname = getParam(GET_EXTERN_USER_NAME);
    $email = getParam(GET_EXTERN_USER_EMAIL);
    $company = getParam(GET_EXTERN_USER_COMPANY);
    $customs = array();
    if (empty($_GET[GET_TRACK_NO_SEARCH_ENGINE])) {
        exit(getFile(TEMPLATE_HTML_SUPPORT));
    }
    $row = $EXTERNALUSER->CreateSignature();
    if (is_array($row) && $row["id"] != CALLER_USER_ID) {
        $EXTERNALUSER->UserId = $row["id"];
        $fullname = empty($fullname) ? base64UrlEncode($row["fullname"]) : "";
        $email = empty($email) ? base64UrlEncode($row["email"]) : "";
        $company = empty($company) ? base64UrlEncode($row["company"]) : "";
        $customs = @unserialize($row["customs"]);
if (!defined("LIVEZILLA_PATH")) {
    define("LIVEZILLA_PATH", "./");
}
require LIVEZILLA_PATH . "_definitions/definitions.inc.php";
require LIVEZILLA_PATH . "_lib/functions.global.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php";
@set_error_handler("handleError");
if (!empty($_REQUEST["cid"]) && Server::InitDataProvider()) {
    $chat = VisitorChat::GetByChatId(Communication::ReadParameter("cid", 0));
    if ($chat != null) {
        if ($chat->Closed) {
            exit("lz_chat_file_stop();");
        } else {
            $visitor = new Visitor($chat->UserId);
            $visitor->Load();
            if (isset($_FILES["form_userfile"])) {
                if (StoreFile($visitor, $chat->BrowserId, $chat->DesiredChatPartner, $chat->UserData->Fullname, $chat->ChatId)) {
                    exit("lz_chat_file_ready();");
                } else {
                    exit("lz_chat_file_error(2);");
                }
            } else {
                if (Communication::GetIP() == $visitor->IP) {
                    if (!empty($_POST["p_fu_a"])) {
                        exit(AbortFileUpload($chat, $_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]));
                    }
                    if (!empty($_POST["p_iu"])) {
                        exit(RequestFileUpload($visitor, $chat, $_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME]));
                    } else {
                        $html = IOStruct::GetFile(PATH_TEMPLATES . "upload.tpl");
* All rights reserved.
* LiveZilla is a registered trademark.
* 
* Improper changes to this file may cause critical errors.
***************************************************************************************/
if (!defined("IN_LIVEZILLA")) {
    die;
}
require LIVEZILLA_PATH . "_lib/objects.external.inc.php";
require LIVEZILLA_PATH . "_lib/functions.external.inc.php";
if (isset($_POST[POST_EXTERN_SERVER_ACTION])) {
    languageSelect();
    initData(array("GROUPS", "FILTERS"));
    $externalUser = new Visitor(base64UrlDecode($_POST[POST_EXTERN_USER_USERID]));
    $externalUser->ExtendSession = true;
    $externalUser->Load();
    array_push($externalUser->Browsers, new VisitorChat($externalUser->UserId, base64UrlDecode($_POST[POST_EXTERN_USER_BROWSERID])));
    define("IS_FILTERED", $FILTERS->Match(getIP(), formLanguages(!empty($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : ""), base64UrlDecode($_POST[POST_EXTERN_USER_USERID]), true));
    define("IS_FLOOD", $externalUser->Browsers[0]->FirstCall && isFlood(getIP(), @$_POST[POST_EXTERN_USER_USERID], true));
    $externalUser->Browsers[0]->Load();
    if ($_POST[POST_EXTERN_SERVER_ACTION] == EXTERN_ACTION_LISTEN) {
        $externalUser = listen($externalUser);
    } else {
        if ($_POST[POST_EXTERN_SERVER_ACTION] == EXTERN_ACTION_MAIL) {
            initData(array("GROUPS"));
            $phone = isset($_POST["p_phone"]) ? base64UrlDecode($_POST["p_phone"]) : "";
            if (($ticket = $externalUser->SaveTicket(base64UrlDecode($_POST[POST_EXTERN_USER_GROUP]), base64UrlDecode($_POST[POST_EXTERN_USER_NAME]), base64UrlDecode($_POST[POST_EXTERN_USER_EMAIL]), base64UrlDecode($_POST[POST_EXTERN_USER_COMPANY]), $externalUser->GeoCountryISO2, $phone, isset($_GET["cmb"]), base64UrlDecode($_POST[POST_EXTERN_USER_MAIL]), true, getOParam("p_url", "", $nu, FILTER_SANITIZE_URL))) !== false && ($CONFIG["gl_scom"] != null || $CONFIG["gl_sgom"] != null)) {
                Visitor::SendTicketAutoresponder($ticket, $externalUser->Language);
            }
            $externalUser->Browsers[0]->SaveLoginData();
        } else {
 static function FromCache($_id)
 {
     global $CM, $VISITOR;
     if (!empty($CM)) {
         initData(array("VISITOR"));
         if (isset($VISITOR[$_id])) {
             return $VISITOR[$_id];
         }
     }
     $v = new Visitor(CALLER_USER_ID);
     $v->Load();
     return $v;
 }
@ini_set('session.use_cookies', '0');
@error_reporting(E_ALL);
$content_frames = array("lz_chat_frame.3.2.lgin.1.0", "lz_chat_frame.3.2.mail.1.0", "lz_chat_frame.3.2.chat.1.0", "lz_chat_frame.3.2.chat.0.0", "lz_chat_frame.3.2.chat.2.0");
require LIVEZILLA_PATH . "_lib/functions.external.inc.php";
require LIVEZILLA_PATH . "_lib/objects.external.inc.php";
@set_time_limit($CONFIG["timeout_chats"]);
if (!isset($_GET["file"])) {
    @set_error_handler("handleError");
}
if (!isset($_GET["browid"])) {
    exit;
}
languageSelect();
initData(array("INTERNAL", "GROUPS", "FILTERS", "INPUTS"));
$USER = new Visitor(base64UrlDecode(getParam(GET_TRACK_USERID)));
$USER->Load();
array_push($USER->Browsers, new VisitorChat($USER->UserId, $USER->UserId . "_OVL"));
array_push($USER->Browsers, $BROWSER);
$GroupBuilder = new GroupBuilder($INTERNAL, $GROUPS, $CONFIG, $USER->Browsers[0]->DesiredChatGroup, $USER->Browsers[0]->DesiredChatPartner, false);
$GroupBuilder->Generate(null, true);
$USER->Browsers[0]->Overlay = true;
$USER->Browsers[0]->Load();
if ($USER->Browsers[0]->FirstCall) {
    $USER->AddFunctionCall("lz_chat_init_data_change(null,null);", false);
}
if (IS_FILTERED) {
    $USER->Browsers[0]->CloseChat();
    $USER->Browsers[0]->Destroy();
    $USER->AddFunctionCall("lz_tracking_remove_overlay_chat();", true);
}
$USER->Browsers[0]->LoadForward(false);
 static function Build($_fullList = false, $_sqlwhere = "", $_limit = "")
 {
     global $VISITOR, $CONFIG, $COUNTRIES, $CM;
     if (!$_fullList && !empty($CM) && $CM->GetData(111, $VISITOR)) {
         return;
     }
     $VISITOR = $tvisitors = $tbrowsers = array();
     if (!$_fullList) {
         $_sqlwhere = " WHERE `last_active`>" . DBManager::RealEscape(time() - $CONFIG["timeout_track"]);
     }
     $result = queryDB(true, "SELECT *,`t1`.`id` AS `id` FROM `" . DB_PREFIX . DATABASE_VISITORS . "` AS `t1` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_BROWSERS . "` AS `t2` ON `t1`.`browser`=`t2`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_CITIES . "` AS `t3` ON `t1`.`city`=`t3`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_REGIONS . "` AS `t4` ON `t1`.`region`=`t4`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_ISPS . "` AS `t5` ON `t1`.`isp`=`t5`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_SYSTEMS . "` AS `t6` ON `t1`.`system`=`t6`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_RESOLUTIONS . "` AS `t8` ON `t1`.`resolution`=`t8`.`id`" . $_sqlwhere . " ORDER BY `entrance` ASC" . $_limit . ";");
     if ($result) {
         initData(array("COUNTRIES"));
         while ($row = DBManager::FetchArray($result)) {
             $fa = $row["entrance"];
             if (isset($tvisitors[$row["id"]])) {
                 $fa = min($tvisitors[$row["id"]]->FirstActive, $fa);
             }
             if (!empty($COUNTRIES[$row["country"]])) {
                 $row["countryname"] = $COUNTRIES[$row["country"]];
             }
             if (!isset($vcount[$row["id"]])) {
                 $vcount[$row["id"]] = 0;
             }
             $vcount[$row["id"]]++;
             $row["dcount"] = $vcount[$row["id"]];
             $visitor = new Visitor($row["id"]);
             $visitor->Load($row);
             $visitor->FirstActive = $fa;
             $tvisitors[$row["id"]] = $visitor;
             $tvisitors[$row["id"]]->FirstActive = min($tvisitors[$row["id"]]->FirstActive, $row["entrance"]);
         }
         $minEntrance = time();
         $limiter = !$_fullList ? " WHERE `last_active` > " . (time() - $CONFIG["timeout_track"]) . " " : "";
         $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "`" . $limiter . "ORDER BY `created` ASC;");
         if ($result) {
             while ($row = DBManager::FetchArray($result)) {
                 if (isset($tvisitors[$row["visitor_id"]]) && ($tvisitors[$row["visitor_id"]]->VisitId == $row["visit_id"] || $_fullList)) {
                     $browser = $tvisitors[$row["visitor_id"]]->CreateBrowser($row);
                     $tbrowsers[$browser->BrowserId] = $browser;
                     $minEntrance = min($minEntrance, $row["created"]);
                 }
             }
         }
         if ($_fullList) {
             if ($result = queryDB(true, "SELECT `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted`.`browser_id`,`" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted`.`title` as `url_title`,`treftitle`.`title` as `ref_title`,`turldom`.`domain` as `url_dom`,`turlpath`.`path` as `url_path`,`trefdom`.`domain` as `ref_dom`,`trefpath`.`path` as `ref_path`,`entrance`,`params`,`untouched`,`ref_untouched` FROM (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "` ORDER BY `entrance` ASC) AS `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_PAGES . "` AS `turl` ON `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted`.`url`=`turl`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_PAGES . "` AS `tref` ON `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted`.`referrer`=`tref`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_DOMAINS . "` AS `trefdom` ON `tref`.`domain`=`trefdom`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_DOMAINS . "` AS `turldom` ON `turl`.`domain`=`turldom`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_PATHS . "` AS `trefpath` ON `tref`.`path`=`trefpath`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_PATHS . "` AS `turlpath` ON `turl`.`path`=`turlpath`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_TITLES . "` AS `treftitle` ON `tref`.`title`=`treftitle`.`id`;")) {
                 while ($row = DBManager::FetchArray($result)) {
                     if (isset($tbrowsers[$row["browser_id"]])) {
                         $tbrowsers[$row["browser_id"]]->History[] = new HistoryURL($row);
                     }
                 }
             }
         } else {
             if ($result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "` WHERE `entrance` >= " . $minEntrance . ";")) {
                 while ($row = DBManager::FetchArray($result)) {
                     if (isset($tbrowsers[$row["browser_id"]])) {
                         $tbrowsers[$row["browser_id"]]->History[] = new HistoryURL($row, true);
                     }
                 }
             }
         }
         foreach ($tbrowsers as $i => $browser) {
             $tbrowsers[$i]->SetFirstCall(count($browser->History) == 0);
             if (isset($tvisitors[$browser->UserId])) {
                 $tvisitors[$browser->UserId]->Browsers[count($tvisitors[$browser->UserId]->Browsers)] = $browser;
             }
         }
         foreach ($tvisitors as $vid => $visitor) {
             if ($_fullList || count($visitor->Browsers) > 0) {
                 $VISITOR[$vid] = $visitor;
             }
         }
         if (!$_fullList && !empty($CM)) {
             $CM->SetData(111, $VISITOR, true);
         }
     }
 }
 static function Build($_fullList = false, $_sqlwhere = "", $_limit = "", $_created = 0)
 {
     Server::InitDataBlock(array("COUNTRIES"));
     if (!$_fullList && !empty(CacheManager::$ActiveManager) && CacheManager::$ActiveManager->GetData(DATA_CACHE_KEY_VISITORS, Server::$Visitors)) {
         return count(Server::$Visitors);
     }
     Server::$Visitors = $tvisitors = $tbrowsers = array();
     if (!$_fullList) {
         $_sqlwhere = " WHERE `last_active`>" . DBManager::RealEscape(time() - Server::$Configuration->File["timeout_track"]);
     }
     $result = DBManager::Execute(true, "SELECT *,`t1`.`id` AS `id` FROM `" . DB_PREFIX . DATABASE_VISITORS . "` AS `t1` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_BROWSERS . "` AS `t2` ON `t1`.`browser`=`t2`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_CITIES . "` AS `t3` ON `t1`.`city`=`t3`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_REGIONS . "` AS `t4` ON `t1`.`region`=`t4`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_ISPS . "` AS `t5` ON `t1`.`isp`=`t5`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_SYSTEMS . "` AS `t6` ON `t1`.`system`=`t6`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_RESOLUTIONS . "` AS `t8` ON `t1`.`resolution`=`t8`.`id`" . $_sqlwhere . " ORDER BY `entrance` ASC" . $_limit . ";");
     if ($result) {
         while ($row = DBManager::FetchArray($result)) {
             $fa = $row["entrance"];
             if (isset($tvisitors[$row["id"]])) {
                 $fa = min($tvisitors[$row["id"]]->FirstActive, $fa);
             }
             if (!empty(Server::$Countries[$row["country"]])) {
                 $row["countryname"] = Server::$Countries[$row["country"]];
             }
             if (!isset($vcount[$row["id"]])) {
                 $vcount[$row["id"]] = 0;
             }
             $vcount[$row["id"]]++;
             $row["dcount"] = $vcount[$row["id"]];
             $visitor = new Visitor($row["id"]);
             $visitor->Load($row);
             $visitor->FirstActive = $fa;
             $tvisitors[$row["id"]] = $visitor;
             $tvisitors[$row["id"]]->FirstActive = min($tvisitors[$row["id"]]->FirstActive, $row["entrance"]);
         }
         $minEntrance = time();
         if ($_fullList) {
             $result = DBManager::Execute(true, $d = "SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` WHERE `created` > " . intval($_created) . " ORDER BY `created` ASC;");
         } else {
             $result = DBManager::Execute(true, $d = "SELECT `t1`.*,`t2`.`h_fullname`,`t2`.`h_email`,`t2`.`h_company`,`t2`.`h_phone`,`t2`.`h_customs`,`t2`.`h_text` FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` AS `t1` INNER JOIN `" . DB_PREFIX . DATABASE_USER_DATA . "` AS `t2` ON `t1`.`data_id`=`t2`.`id` WHERE `last_active` > " . intval(time() - Server::$Configuration->File["timeout_track"]) . " ORDER BY `created` ASC;");
         }
         if ($result) {
             while ($row = DBManager::FetchArray($result)) {
                 if (isset($tvisitors[$row["visitor_id"]]) && ($tvisitors[$row["visitor_id"]]->VisitId == $row["visit_id"] || $_fullList)) {
                     $browser = $tvisitors[$row["visitor_id"]]->CreateBrowser($row, false, false);
                     $tbrowsers[$browser->BrowserId] = $browser;
                     $minEntrance = min($minEntrance, $row["created"]);
                 }
             }
         }
         if ($_fullList) {
             if ($result = DBManager::Execute(true, "SELECT `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted`.`browser_id`,`" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted`.`title` as `url_title`,`treftitle`.`title` as `ref_title`,`turldom`.`domain` as `url_dom`,`turlpath`.`path` as `url_path`,`trefdom`.`domain` as `ref_dom`,`trefpath`.`path` as `ref_path`,`entrance`,`params`,`untouched`,`ref_untouched` FROM (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "` ORDER BY `entrance` ASC) AS `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_PAGES . "` AS `turl` ON `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted`.`url`=`turl`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_PAGES . "` AS `tref` ON `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "_sorted`.`referrer`=`tref`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_DOMAINS . "` AS `trefdom` ON `tref`.`domain`=`trefdom`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_DOMAINS . "` AS `turldom` ON `turl`.`domain`=`turldom`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_PATHS . "` AS `trefpath` ON `tref`.`path`=`trefpath`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_PATHS . "` AS `turlpath` ON `turl`.`path`=`turlpath`.`id` INNER JOIN `" . DB_PREFIX . DATABASE_VISITOR_DATA_TITLES . "` AS `treftitle` ON `tref`.`title`=`treftitle`.`id`;")) {
                 while ($row = DBManager::FetchArray($result)) {
                     if (isset($tbrowsers[$row["browser_id"]])) {
                         $tbrowsers[$row["browser_id"]]->History[] = new HistoryURL($row);
                     }
                 }
             }
         } else {
             if ($result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_CHATS . "` WHERE (`status`>0 OR `waiting`=1) ORDER BY `first_active` ASC;")) {
                 while ($row = DBManager::FetchArray($result)) {
                     if (isset($tbrowsers[$row["browser_id"]]) && get_class($tbrowsers[$row["browser_id"]]) == "VisitorChat") {
                         $tbrowsers[$row["browser_id"]]->Status = CHAT_STATUS_OPEN;
                         $tbrowsers[$row["browser_id"]]->LastActive = time();
                         $tbrowsers[$row["browser_id"]]->Members = array();
                         if (empty($row["external_close"])) {
                             $tbrowsers[$row["browser_id"]]->FirstCall = !empty($row["exit"]);
                             $tbrowsers[$row["browser_id"]]->SetValues($row, false);
                         } else {
                             $tbrowsers[$row["browser_id"]]->SetValues($row, true);
                         }
                         if ($tbrowsers[$row["browser_id"]]->Status > CHAT_STATUS_OPEN) {
                             $tbrowsers[$row["browser_id"]]->LoadMembers();
                         }
                     }
                 }
             }
             if ($result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "` WHERE `entrance` >= " . intval($minEntrance) . " ORDER BY `entrance` ASC;")) {
                 while ($row = DBManager::FetchArray($result)) {
                     if (isset($tbrowsers[$row["browser_id"]])) {
                         $tbrowsers[$row["browser_id"]]->History[] = new HistoryURL($row, true);
                     }
                 }
             }
         }
         foreach ($tbrowsers as $i => $browser) {
             $tbrowsers[$i]->SetFirstCall(count($browser->History) == 0);
             if (isset($tvisitors[$browser->UserId])) {
                 if ($_fullList && count($browser->History) == 0) {
                     continue;
                 }
                 $tvisitors[$browser->UserId]->Browsers[count($tvisitors[$browser->UserId]->Browsers)] = $browser;
             }
         }
         foreach ($tvisitors as $vid => $visitor) {
             if (count($visitor->Browsers) > 0) {
                 Server::$Visitors[$vid] = $visitor;
             }
         }
         if (!$_fullList && !empty(CacheManager::$ActiveManager)) {
             CacheManager::$ActiveManager->SetData(DATA_CACHE_KEY_VISITORS, Server::$Visitors, true);
         }
     }
     return count($tvisitors);
 }