function GroupBuilder($_internalUsers, $_internalGroups, $_config)
 {
     $this->InternalUsers = $_internalUsers;
     $this->InternalGroups = $_internalGroups;
     $this->Config = $_config;
     $this->GroupValues["groups_online"] = array();
     $this->GroupValues["groups_offline"] = array();
     $this->GroupValues["groups_online_amounts"] = array();
     $this->GroupValues["groups_output"] = array();
     $this->GroupValues["groups_hidden"] = array();
     $this->GroupValues["set_by_get_user"] = null;
     $this->GroupValues["set_by_get_group"] = null;
     $this->GroupValues["set_by_cookie"] = null;
     $this->GroupValues["set_by_standard"] = null;
     $this->GroupValues["set_by_online"] = null;
     $this->GroupValues["req_for_user"] = isset($_GET[GET_EXTERN_INTERN_USER_ID]);
     $this->GroupValues["req_for_group"] = isset($_GET[GET_EXTERN_GROUP]);
     $parameters = getTargetParameters();
     if ($parameters["include_group"] != null) {
         foreach ($_internalGroups as $gid => $group) {
             if (!in_array($gid, $parameters["include_group"])) {
                 $this->GroupValues["groups_hidden"][] = $gid;
             }
         }
     } else {
         if ($parameters["include_user"] != null) {
             foreach ($_internalGroups as $gid => $group) {
                 if (!in_array($gid, $_internalUsers[getInternalSystemIdByUserId($parameters["include_user"])]->Groups)) {
                     $this->GroupValues["groups_hidden"][] = $gid;
                 }
             }
         } else {
             if ($parameters["exclude"] != null) {
                 $this->GroupValues["groups_hidden"] = $parameters["exclude"];
             }
         }
     }
 }
function getInternal($desired = "", $util = 0, $fromCookie = null)
{
    global $CONFIG, $INTERNAL, $GROUPS, $USER, $INTLIST, $INTBUSY;
    $INTLIST = array();
    $INTBUSY = 0;
    $backup_target = null;
    $fromDepartment = $fromDepartmentBusy = false;
    if (!empty($USER->Browsers[0]->DesiredChatPartner) && isset($INTERNAL[$USER->Browsers[0]->DesiredChatPartner]) && $INTERNAL[$USER->Browsers[0]->DesiredChatPartner]->Status < USER_STATUS_OFFLINE) {
        if (!(!empty($USER->Browsers[0]->DesiredChatGroup) && !in_array($USER->Browsers[0]->DesiredChatGroup, $INTERNAL[$USER->Browsers[0]->DesiredChatPartner]->Groups))) {
            $desired = $USER->Browsers[0]->DesiredChatPartner;
        }
    } else {
        $USER->Browsers[0]->DesiredChatPartner = null;
        if (isset($_POST[POST_EXTERN_REQUESTED_INTERNID]) && !empty($_POST[POST_EXTERN_REQUESTED_INTERNID])) {
            $desired = getInternalSystemIdByUserId(AJAXDecode($_POST[POST_EXTERN_REQUESTED_INTERNID]));
        } else {
            if (!isnull(getCookieValue("internal_user")) && !empty($CONFIG["gl_save_op"])) {
                $desired = getInternalSystemIdByUserId(getCookieValue("internal_user"));
                if (!(!empty($USER->Browsers[0]->DesiredChatGroup) && !in_array($USER->Browsers[0]->DesiredChatGroup, $INTERNAL[$desired]->Groups))) {
                    $fromCookie = $desired;
                } else {
                    $desired = "";
                }
            }
        }
    }
    foreach ($GROUPS as $id => $group) {
        $utilization[$id] = 0;
    }
    foreach ($INTERNAL as $sessId => $internal) {
        if ($internal->LastActive > time() - $CONFIG["timeout_clients"]) {
            $group_chats[$sessId] = $internal->GetExternalChatAmount();
            $group_names[$sessId] = $internal->Fullname;
            $group_available[$sessId] = GROUP_STATUS_UNAVAILABLE;
            if (in_array($USER->Browsers[0]->DesiredChatGroup, $internal->Groups)) {
                if ($internal->Status == USER_STATUS_ONLINE && $internal->LastChatAllocation < time() - $CONFIG["poll_frequency_clients"] * 3) {
                    $group_available[$sessId] = GROUP_STATUS_AVAILABLE;
                } elseif ($internal->Status == USER_STATUS_BUSY || $internal->LastChatAllocation >= time() - $CONFIG["poll_frequency_clients"] * 3) {
                    $group_available[$sessId] = GROUP_STATUS_BUSY;
                    $INTBUSY++;
                    if (empty($fromCookie) && $desired == $sessId) {
                        return;
                    }
                }
            } else {
                if ($internal->Status == USER_STATUS_ONLINE) {
                    $backup_target = $internal;
                } else {
                    if ($internal->Status == USER_STATUS_BUSY && empty($backup_target)) {
                        $backup_target = $internal;
                    }
                }
                if (!empty($USER->Browsers[0]->DesiredChatPartner) && $USER->Browsers[0]->DesiredChatPartner == $sessId) {
                    $USER->Browsers[0]->DesiredChatPartner = null;
                }
            }
            for ($count = 0; $count < count($internal->Groups); $count++) {
                if ($USER->Browsers[0]->DesiredChatGroup == $internal->Groups[$count]) {
                    if (!is_array($utilization[$internal->Groups[$count]])) {
                        $utilization[$internal->Groups[$count]] = array();
                    }
                    if ($group_available[$sessId] == GROUP_STATUS_AVAILABLE) {
                        $utilization[$internal->Groups[$count]][$sessId] = $group_chats[$sessId];
                    }
                }
            }
        }
    }
    if (isset($utilization[$USER->Browsers[0]->DesiredChatGroup]) && is_array($utilization[$USER->Browsers[0]->DesiredChatGroup])) {
        arsort($utilization[$USER->Browsers[0]->DesiredChatGroup]);
        reset($utilization[$USER->Browsers[0]->DesiredChatGroup]);
        $util = end($utilization[$USER->Browsers[0]->DesiredChatGroup]);
        $INTLIST = $utilization[$USER->Browsers[0]->DesiredChatGroup];
    }
    if (isset($group_available) && is_array($group_available) && in_array(GROUP_STATUS_AVAILABLE, $group_available)) {
        $fromDepartment = true;
    } elseif (isset($group_available) && is_array($group_available) && in_array(GROUP_STATUS_BUSY, $group_available)) {
        $fromDepartmentBusy = true;
    }
    if (isset($group_chats) && is_array($group_chats) && isset($fromDepartment) && $fromDepartment) {
        foreach ($group_chats as $sessId => $amount) {
            if ($group_available[$sessId] == GROUP_STATUS_AVAILABLE && $amount <= $util || !empty($USER->Browsers[0]->Forward) && $USER->Browsers[0]->Forward->Processed && isset($desired) && $sessId == $desired) {
                $available_internals[] = $sessId;
            }
        }
    }
    if ($fromDepartment && sizeof($available_internals) > 0) {
        if (is_array($available_internals)) {
            if (!empty($desired) && (in_array($desired, $available_internals) || $INTERNAL[$desired]->Status == USER_STATUS_ONLINE)) {
                $matching_internal = $desired;
            } else {
                if (!isnull($inv_sender = $USER->Browsers[0]->GetLastInvitationSender()) && in_array($inv_sender, $available_internals)) {
                    $matching_internal = $inv_sender;
                } else {
                    $matching_internal = array_rand($available_internals, 1);
                    $matching_internal = $available_internals[$matching_internal];
                }
            }
        }
        if ($CONFIG["gl_alloc_mode"] != ALLOCATION_MODE_ALL || $fromCookie == $matching_internal) {
            $USER->Browsers[0]->DesiredChatPartner = $matching_internal;
        }
    } elseif ($fromDepartmentBusy) {
        if (!$USER->Browsers[0]->Waiting) {
            $USER->Browsers[0]->Waiting = true;
        }
    } else {
        $USER->AddFunctionCall("lz_chat_add_system_text(8,null);", false);
        $USER->AddFunctionCall("lz_chat_stop_system();", false);
        $USER->Browsers[0]->CloseChat(3);
        $INTLIST = null;
    }
}
 function BuildVisitorXML()
 {
     global $USER, $BROWSER;
     $visitorDetails = array("userid" => " id=\"" . base64_encode($USER->UserId) . "\"", "resolution" => null, "ip" => null, "lat" => null, "long" => null, "city" => null, "ctryi2" => null, "region" => null, "system" => null, "language" => null, "ka" => null, "requested" => null, "target" => null, "declined" => null, "accepted" => null, "cname" => null, "cemail" => null, "ccompany" => null, "waiting" => null, "timezoneoffset" => null, "visits" => null, "host" => null, "grid" => null, "isp" => null, "cf0" => null, "cf1" => null, "cf2" => null, "cf3" => null, "cf4" => null, "cf5" => null, "cf6" => null, "cf7" => null, "cf8" => null, "cf9" => null, "sys" => null, "bro" => null, "js" => null, "visitlast" => null);
     if ($this->CurrentResponseType != DATA_RESPONSE_TYPE_KEEP_ALIVE) {
         $visitorDetails["ka"] = " ka=\"" . base64_encode(true) . "\"";
         $visitorDetails["requested"] = !empty($BROWSER->ChatRequest) && !$BROWSER->ChatRequest->Accepted && !$BROWSER->ChatRequest->Declined && !$BROWSER->ChatRequest->Closed ? " req=\"" . base64_encode(getInternalSystemIdByUserId($BROWSER->ChatRequest->SenderUserId)) . "\"" : "";
         $visitorDetails["declined"] = !empty($BROWSER->ChatRequest) && $BROWSER->ChatRequest->Declined ? " dec=\"" . base64_encode("1") . "\"" : "";
         $visitorDetails["accepted"] = !empty($BROWSER->ChatRequest) && $BROWSER->ChatRequest->Accepted ? " acc=\"" . base64_encode("1") . "\"" : "";
         $visitorDetails["target"] = !empty($BROWSER->ChatRequest) ? " tbid=\"" . base64_encode($BROWSER->BrowserId) . "\"" : "";
     }
     if ($this->CurrentResponseType == DATA_RESPONSE_TYPE_STATIC) {
         $visitorDetails["resolution"] = " res=\"" . base64_encode($USER->Resolution) . "\"";
         $visitorDetails["ip"] = " ip=\"" . base64_encode($USER->IP) . "\"";
         $visitorDetails["timezoneoffset"] = " tzo=\"" . base64_encode($USER->GeoTimezoneOffset) . "\"";
         $visitorDetails["lat"] = " lat=\"" . base64_encode($USER->GeoLatitude) . "\"";
         $visitorDetails["long"] = " long=\"" . base64_encode($USER->GeoLongitude) . "\"";
         $visitorDetails["city"] = " city=\"" . base64_encode($USER->GeoCity) . "\"";
         $visitorDetails["ctryi2"] = " ctryi2=\"" . base64_encode($USER->GeoCountryISO2) . "\"";
         $visitorDetails["region"] = " region=\"" . base64_encode($USER->GeoRegion) . "\"";
         $visitorDetails["js"] = " js=\"" . base64_encode($USER->Javascript) . "\"";
         $visitorDetails["language"] = " lang=\"" . base64_encode($USER->Language) . "\"";
         $visitorDetails["visits"] = " vts=\"" . base64_encode($USER->Visits) . "\"";
         $visitorDetails["host"] = " ho=\"" . base64_encode($USER->Host) . "\"";
         $visitorDetails["grid"] = " gr=\"" . base64_encode($USER->GeoResultId) . "\"";
         $visitorDetails["isp"] = " isp=\"" . base64_encode($USER->GeoISP) . "\"";
         $visitorDetails["sys"] = " sys=\"" . base64_encode($USER->OperatingSystem) . "\"";
         $visitorDetails["bro"] = " bro=\"" . base64_encode($USER->Browser) . "\"";
         $visitorDetails["visitlast"] = " vl=\"" . base64_encode($USER->VisitLast) . "\"";
     }
     $visitorDetails["waiting"] = $BROWSER->Type == BROWSER_TYPE_CHAT && $BROWSER->Waiting && in_array($BROWSER->DesiredChatGroup, $this->Caller->Groups) ? " w=\"" . base64_encode(1) . "\"" : "";
     if (!empty($BROWSER->ChatRequest)) {
         if (empty($USER->ActiveChatRequest) || !empty($USER->ActiveChatRequest) && $BROWSER->ChatRequest->Created > $USER->ActiveChatRequest->Created) {
             $USER->ActiveChatRequest = $BROWSER->ChatRequest;
         }
     }
     if (!in_array($USER->UserId, $this->AddedVisitors) || !empty($BROWSER->ChatRequest) && $BROWSER->ChatRequest == $USER->ActiveChatRequest) {
         array_push($this->AddedVisitors, $USER->UserId);
         $this->XMLVisitorOpen = true;
         $this->XMLCurrentVisitorTag = "<v" . $visitorDetails["userid"] . $visitorDetails["resolution"] . $visitorDetails["ip"] . $visitorDetails["lat"] . $visitorDetails["long"] . $visitorDetails["region"] . $visitorDetails["city"] . $visitorDetails["ctryi2"] . $visitorDetails["visits"] . $visitorDetails["declined"] . $visitorDetails["accepted"] . $visitorDetails["target"] . $visitorDetails["system"] . $visitorDetails["language"] . $visitorDetails["requested"] . $visitorDetails["cname"] . $visitorDetails["cemail"] . $visitorDetails["ccompany"] . $visitorDetails["timezoneoffset"] . $visitorDetails["host"] . $visitorDetails["grid"] . $visitorDetails["isp"] . $visitorDetails["cf0"] . $visitorDetails["cf1"] . $visitorDetails["cf2"] . $visitorDetails["cf3"] . $visitorDetails["cf4"] . $visitorDetails["cf5"] . $visitorDetails["cf6"] . $visitorDetails["cf7"] . $visitorDetails["cf8"] . $visitorDetails["cf9"] . $visitorDetails["sys"] . $visitorDetails["bro"] . $visitorDetails["js"] . $visitorDetails["visitlast"] . ">\r\n";
     }
     if ($this->CurrentResponseType != DATA_RESPONSE_TYPE_KEEP_ALIVE) {
         $referrer = $BROWSER->History[0]->Referrer != null ? " ref=\"" . base64_encode($BROWSER->History[0]->Referrer->GetAbsoluteUrl()) . "\"" : "";
         $personal = " cname=\"" . base64_encode($BROWSER->Fullname) . "\"";
         $personal .= " cemail=\"" . base64_encode($BROWSER->Email) . "\"";
         $personal .= " ccompany=\"" . base64_encode($BROWSER->Company) . "\"";
         for ($int = 0; $int <= 9; $int++) {
             if (isset($BROWSER->Customs[$int]) && !empty($BROWSER->Customs[$int])) {
                 $personal .= " cf" . $int . "=\"" . base64_encode($BROWSER->Customs[$int]) . "\"";
             }
         }
         $this->XMLCurrentVisitor .= " <b id=\"" . base64_encode($BROWSER->BrowserId) . "\" ss=\"" . base64_encode($BROWSER->Query) . "\"" . $visitorDetails["ka"] . $referrer . $visitorDetails["waiting"] . $personal . ">\r\n";
         for ($i = 0; $i < count($BROWSER->History); $i++) {
             $this->XMLCurrentVisitor .= "  <h time=\"" . base64_encode($BROWSER->History[$i]->Entrance) . "\" url=\"" . base64_encode($BROWSER->History[$i]->Url->GetAbsoluteUrl()) . "\" title=\"" . base64_encode(@$BROWSER->History[$i]->Url->PageTitle) . "\" code=\"" . base64_encode($BROWSER->Type == BROWSER_TYPE_CHAT ? $BROWSER->Code : $BROWSER->History[$i]->Url->AreaCode) . "\" cp=\"" . base64_encode($BROWSER->Type) . "\" />\r\n";
         }
         if (!empty($this->XMLCurrentChat)) {
             $this->XMLCurrentVisitor .= $this->XMLCurrentChat;
         }
         $this->XMLCurrentVisitor .= " </b>\r\n";
     }
 }
function up_3183_3184($_prefix, $_link)
{
    global $INTERNAL, $GROUPS;
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "info` ADD `chat_id` INT NOT NULL DEFAULT '11700'", $_link);
    if (!$result && mysql_errno() != 1060) {
        return mysql_errno() . ": " . mysql_error();
    }
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "info` ADD `ticket_id` INT NOT NULL DEFAULT '11700'", $_link);
    if (!$result && mysql_errno() != 1060) {
        return mysql_errno() . ": " . mysql_error();
    }
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "chats` ADD `transcript_sent` tinyint(1) unsigned NOT NULL default '1'", $_link);
    if (!$result && mysql_errno() != 1060) {
        return mysql_errno() . ": " . mysql_error();
    }
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "res` CHANGE `html` `value` longtext character set utf8 collate utf8_bin NOT NULL", $_link);
    if (!$result && mysql_errno() != 1054) {
        return mysql_errno() . ": " . mysql_error();
    }
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "res` ADD `size` bigint(20) unsigned NOT NULL default '0'", $_link);
    if (!$result && mysql_errno() != 1060) {
        return mysql_errno() . ": " . mysql_error();
    }
    $dirs = array(PATH_UPLOADS_INTERNAL, PATH_UPLOADS_EXTERNAL);
    $baseFolderInternal = $baseFolderExternal = false;
    foreach ($dirs as $tdir) {
        $subdirs = getDirectory($tdir, false, true);
        foreach ($subdirs as $dir) {
            if (@is_dir($tdir . $dir . "/")) {
                if ($tdir == PATH_UPLOADS_INTERNAL) {
                    $owner = getInternalSystemIdByUserId($dir);
                } else {
                    $owner = CALLER_SYSTEM_ID;
                }
                if (!isset($INTERNAL[$owner])) {
                    continue;
                }
                $files = getDirectory($tdir . $dir . "/", false, true);
                foreach ($files as $file) {
                    if ($file != FILE_INDEX && $file != FILE_INDEX_OLD) {
                        if ($tdir == PATH_UPLOADS_INTERNAL) {
                            $parentId = $owner;
                            $type = 3;
                            if (!$baseFolderInternal) {
                                createFileBaseFolders($owner, true);
                                $baseFolderInternal = true;
                            }
                            processResource($owner, $owner, $INTERNAL[$owner]->Fullname, 0, $INTERNAL[$owner]->Fullname, 0, 4, 3);
                        } else {
                            $parentId = 5;
                            $owner = CALLER_SYSTEM_ID;
                            $type = 4;
                            if (!$baseFolderExternal) {
                                createFileBaseFolders($owner, false);
                                $baseFolderExternal = true;
                            }
                        }
                        $cfile = $tdir != PATH_UPLOADS_INTERNAL ? base64_decode($file) : $file;
                        $size = filesize($tdir . $dir . "/" . $file);
                        $fid = md5($file . $owner . $size);
                        $filename = $owner . "_" . $fid;
                        copy($tdir . $dir . "/" . $file, PATH_UPLOADS . $filename);
                        processResource($owner, $fid, $filename, $type, $cfile, 0, $parentId, 4, $size);
                    }
                }
            }
        }
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "predefined` (`id` int(11) unsigned NOT NULL,`internal_id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`group_id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`lang_iso` varchar(2) character set utf8 collate utf8_bin NOT NULL,`invitation` mediumtext character set utf8 collate utf8_bin NOT NULL,`welcome` mediumtext character set utf8 collate utf8_bin NOT NULL,`website_push` mediumtext character set utf8 collate utf8_bin NOT NULL,`browser_ident` tinyint(1) unsigned NOT NULL default '0',`is_default` tinyint(1) unsigned NOT NULL default '0', `auto_welcome` tinyint(1) unsigned NOT NULL default '0',PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    } else {
        if ($result) {
            $counter = 0;
            foreach ($GROUPS as $gid => $group) {
                @mysql_query("INSERT INTO `" . @mysql_real_escape_string($_prefix) . "predefined` (`id` ,`internal_id`, `group_id` ,`lang_iso` ,`invitation` ,`welcome` ,`website_push` ,`browser_ident` ,`is_default` ,`auto_welcome`) VALUES ('" . @mysql_real_escape_string($counter++) . "', '', '" . @mysql_real_escape_string($gid) . "', 'EN', 'Hello, my name is %name%. Do you need help? Start Live-Chat now to get assistance.', 'Hello %external_name%, my name is %name%, how may I help you?', 'Website Operator %name% would like to redirect you to this URL:\r\n\r\n%url%', '1', '1', '1');", $_link);
                @mysql_query("INSERT INTO `" . @mysql_real_escape_string($_prefix) . "predefined` (`id` ,`internal_id`, `group_id` ,`lang_iso` ,`invitation` ,`welcome` ,`website_push` ,`browser_ident` ,`is_default` ,`auto_welcome`) VALUES ('" . @mysql_real_escape_string($counter++) . "', '', '" . @mysql_real_escape_string($gid) . "', 'DE', '" . utf8_encode("Guten Tag, meine Name ist %name%. Benötigen Sie Hilfe? Gerne berate ich Sie in einem Live Chat") . "', 'Guten Tag %external_name%, mein Name ist %name% wie kann ich Ihnen helfen?', '" . utf8_encode("Ein Betreuer dieser Webseite (%name%) möchte Sie auf einen anderen Bereich weiterleiten:\\r\\n\\r\\n%url%") . "', '1', '0', '1');", $_link);
            }
        }
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "rooms` (`id` int(11) NOT NULL,`time` int(11) NOT NULL,`last_active` int(11) NOT NULL,`status` tinyint(1) NOT NULL default '0',`target_group` varchar(64) NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "posts` (`id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`time` int(10) unsigned NOT NULL default '0',`micro` int(10) unsigned NOT NULL default '0',`sender` varchar(32) character set utf8 collate utf8_bin NOT NULL,`receiver` varchar(32) character set utf8 collate utf8_bin NOT NULL,`receiver_group` varchar(32) character set utf8 collate utf8_bin NOT NULL,`text` mediumtext character set utf8 collate utf8_bin NOT NULL,`received` tinyint(1) unsigned NOT NULL default '0',`persistent` tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "tickets` (`id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`user_id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`target_group_id` varchar(32) character set utf8 collate utf8_bin NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "ticket_editors` (`ticket_id` int(10) unsigned NOT NULL,`internal_fullname` varchar(32) character set utf8 collate utf8_bin NOT NULL,`status` tinyint(1) unsigned NOT NULL default '1',`time` int(10) unsigned NOT NULL,PRIMARY KEY  (`ticket_id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "ticket_messages` (`id` int(11) unsigned NOT NULL auto_increment,`time` int(11) unsigned NOT NULL,`ticket_id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`text` mediumtext character set utf8 collate utf8_bin NOT NULL,`fullname` varchar(32) character set utf8 collate utf8_bin NOT NULL,`email` varchar(50) character set utf8 collate utf8_bin NOT NULL,`company` varchar(50) character set utf8 collate utf8_bin NOT NULL,`ip` varchar(15) character set utf8 collate utf8_bin NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin AUTO_INCREMENT=1;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "ratings` (`id` varchar(32) character set utf8 collate utf8_bin NOT NULL, `time` int(11) unsigned NOT NULL, `user_id` varchar(32) character set utf8 collate utf8_bin NOT NULL, `internal_id` varchar(32) character set utf8 collate utf8_bin NOT NULL, `fullname` varchar(32) character set utf8 collate utf8_bin NOT NULL, `email` varchar(50) character set utf8 collate utf8_bin NOT NULL, `company` varchar(50) character set utf8 collate utf8_bin NOT NULL, `qualification` tinyint(1) unsigned NOT NULL, `politeness` tinyint(1) unsigned NOT NULL, `comment` varchar(400) character set utf8 collate utf8_bin NOT NULL, `ip` varchar(15) character set utf8 collate utf8_bin NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    return TRUE;
}
function operatorsAvailable($_amount = 0, $_exclude = null, $include_group = null, $include_user = null)
{
    global $CONFIG, $INTERNAL, $GROUPS;
    if (!DB_CONNECTION) {
        return 0;
    }
    initData(true, true);
    if (!empty($include_user)) {
        $include_group = $INTERNAL[getInternalSystemIdByUserId($include_user)]->Groups;
    }
    foreach ($INTERNAL as $sysId => $internaluser) {
        if ($internaluser->IsExternal($GROUPS, $_exclude, $include_group) && $internaluser->Status < USER_STATUS_OFFLINE) {
            $_amount++;
        }
    }
    return $_amount;
}
 function GetXML($_internal, $_full)
 {
     if ($_full) {
         $intern = isset($_internal[getInternalSystemIdByUserId($this->InternId)]) ? $_internal[getInternalSystemIdByUserId($this->InternId)]->Fullname : $this->InternId;
         return "<val id=\"" . base64_encode($this->Id) . "\" cr=\"" . base64_encode($this->Created) . "\" rc=\"" . base64_encode($this->RateComment) . "\" rp=\"" . base64_encode($this->RatePoliteness) . "\" rq=\"" . base64_encode($this->RateQualification) . "\" fn=\"" . base64_encode($this->Fullname) . "\" em=\"" . base64_encode($this->Email) . "\" co=\"" . base64_encode($this->Company) . "\" ii=\"" . base64_encode($intern) . "\" ui=\"" . base64_encode($this->UserId) . "\" />\r\n";
     } else {
         return "<val id=\"" . base64_encode($this->Id) . "\" cr=\"" . base64_encode($this->Created) . "\" />\r\n";
     }
 }
Exemplo n.º 7
0
    $html = str_replace("<!--server_id-->", substr(md5($CONFIG["gl_lzid"]), 5, 5), $html);
    $html = str_replace("<!--connector_script-->", getFile(TEMPLATE_SCRIPT_CONNECTOR), $html);
    $html = str_replace("<!--group_script-->", getFile(TEMPLATE_SCRIPT_GROUPS), $html);
    $html = str_replace("<!--global_script-->", getFile(TEMPLATE_SCRIPT_GLOBAL), $html);
    $html = str_replace("<!--browser_id-->", $browserId, $html);
    $html = str_replace("<!--extern_timeout-->", $CONFIG["timeout_clients"], $html);
    $html = str_replace("<!--chat_transcript_form_visible-->", parseBool($CONFIG["gl_uret"] && $CONFIG["gl_soct"]), $html);
    $html = str_replace("<!--translation_service_visible-->", parseBool($CONFIG["gl_otrs"]), $html);
    $html = str_replace("<!--extern_frequency-->", $CONFIG["poll_frequency_clients"], $html);
    $html = str_replace("<!--cbcd-->", parseBool($CONFIG["gl_cbcd"]), $html);
    $html = str_replace("<!--bookmark_name-->", base64_encode($CONFIG["gl_site_name"]), $html);
    $html = str_replace("<!--user_id-->", SESSION, $html);
    $html = str_replace("<!--connection_error_span-->", CONNECTION_ERROR_SPAN, $html);
    $html = replaceLoginDetails($html);
    $html = geoReplacements($html);
    $html = str_replace("<!--requested_intern_userid-->", !empty($_GET[GET_EXTERN_INTERN_USER_ID]) && isset($INTERNAL[getInternalSystemIdByUserId(base64UrlDecode($_GET[GET_EXTERN_INTERN_USER_ID]))]) ? base64UrlDecode($_GET[GET_EXTERN_INTERN_USER_ID]) : "", $html);
    $html = str_replace("<!--geo_resolute-->", parseBool(!isSSpanFile() && !empty($CONFIG["gl_pr_ngl"]) && !(getCookieValue("geo_data") != null && getCookieValue("geo_data") > time() - 2592000)), $html);
    $html = str_replace("<!--area_code-->", isset($_GET[GET_TRACK_SPECIAL_AREA_CODE]) ? "&code=" . getParam(GET_TRACK_SPECIAL_AREA_CODE) : "", $html);
    $html = str_replace("<!--template_message_intern-->", base64_encode(getFile(TEMPLATE_HTML_MESSAGE_INTERN)), $html);
    $html = str_replace("<!--template_message_extern-->", base64_encode(getFile(TEMPLATE_HTML_MESSAGE_EXTERN)), $html);
    $html = str_replace("<!--template_message_add-->", base64_encode(getFile(TEMPLATE_HTML_MESSAGE_ADD)), $html);
    $html = str_replace("<!--template_message_add_alt-->", base64_encode(getFile(TEMPLATE_HTML_MESSAGE_ADD_ALTERNATE)), $html);
    $html = str_replace("<!--direct_login-->", parseBool(isset($_GET[GET_EXTERN_USER_NAME]) && !isset($_GET[GET_EXTERN_RESET])), $html);
    $html = str_replace("<!--is_ie-->", parseBool(!empty($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false), $html);
    $html = str_replace("<!--setup_error-->", base64_encode(buildLoginErrorField()), $html);
    $html = str_replace("<!--offline_message_mode-->", $CONFIG["gl_om_mode"], $html);
    $html = str_replace("<!--offline_message_http-->", $CONFIG["gl_om_http"], $html);
    $html = str_replace("<!--offline_message_pre_chat-->", parseBool($CONFIG["gl_no_om_sp"] == 1), $html);
    $html = str_replace("<!--lang_client_queue_message-->", $CONFIG["gl_sho_qu_inf"] == 1 ? $LZLANG["client_queue_message"] : $LZLANG["client_ints_are_busy"], $html);
} else {
    if ($_GET[GET_EXTERN_TEMPLATE] == "lz_chat_frame.3.2.login.1.0") {
Exemplo n.º 8
0
* All rights reserved.
* LiveZilla is a registered trademark.
* 
* Improper changes to this file may cause critical errors.
***************************************************************************************/
define("IN_LIVEZILLA", true);
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 . "_lib/objects.global.users.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php";
if (isset($_GET["intid"]) && setDataProvider()) {
    getData(true, false, false, false);
    $id = getInternalSystemIdByUserId($_GET["intid"]);
    if (isset($INTERNAL[$id])) {
        $INTERNAL[$id]->LoadProfile();
        $INTERNAL[$id]->LoadPictures();
        if (!empty($INTERNAL[$id]->Profile)) {
            header("Content-Type: application/vcard;");
            header("Content-Disposition: attachment; filename=" . utf8_decode($_GET["intid"]) . ".vcf");
            $vcard = getFile("./templates/vcard.tpl");
            $vcard = str_replace("<!--Name-->", qp_encode($INTERNAL[$id]->Profile->Name), $vcard);
            $vcard = str_replace("<!--Firstname-->", qp_encode($INTERNAL[$id]->Profile->Firstname), $vcard);
            $vcard = str_replace("<!--Company-->", qp_encode($INTERNAL[$id]->Profile->Company), $vcard);
            $vcard = str_replace("<!--Comments-->", qp_encode($INTERNAL[$id]->Profile->Comments), $vcard);
            $vcard = str_replace("<!--Phone-->", qp_encode($INTERNAL[$id]->Profile->Phone), $vcard);
            $vcard = str_replace("<!--Fax-->", qp_encode($INTERNAL[$id]->Profile->Fax), $vcard);
            $vcard = str_replace("<!--Street-->", qp_encode($INTERNAL[$id]->Profile->Street), $vcard);
            $vcard = str_replace("<!--City-->", qp_encode($INTERNAL[$id]->Profile->City), $vcard);
Exemplo n.º 9
0
* LiveZilla picture.php
* 
* Copyright 2011 LiveZilla GmbH
* All rights reserved.
* LiveZilla is a registered trademark.
* 
* Improper changes to this file may cause critical errors.
***************************************************************************************/
define("IN_LIVEZILLA", true);
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 . "_lib/objects.global.users.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php";
header("Content-Type: image/jpg;");
if (isset($_GET["intid"]) && setDataProvider()) {
    getData(true, false, false, false);
    $id = getInternalSystemIdByUserId(base64UrlDecode($_GET["intid"]));
    if (isset($INTERNAL[$id])) {
        if ($INTERNAL[$id]->LoadPictures()) {
            if (!empty($INTERNAL[$id]->WebcamPicture)) {
                exit(base64_decode($INTERNAL[$id]->WebcamPicture));
            } else {
                exit(base64_decode($INTERNAL[$id]->ProfilePicture));
            }
        }
    }
}
exit(getFile("./images/nopic.jpg"));