0) { // Select the Initiate flag to check if an Administrator has initiated the user with a Support request $query = "SELECT `initiate`, `status`, `services` FROM " . $table_prefix . "requests WHERE `id` = '$request_id'"; $row = $SQL->selectquery($query); if (is_array($row)) { $request_initiate_flag = $row['initiate']; $request_status = $row['status']; $request_services = $row['services']; if ($request_initiate_flag > 0) { $request_initiated = true; } // Update Initiate status fields to display the status of the floating popup. if ($initiate == 'Opened') { // Update request flag to show that the guest user OPENED the Online Chat Request $query = "UPDATE " . $table_prefix . "requests SET `refresh` = NOW(), `initiate` = '-1' WHERE `id` = '$request_id'"; $SQL->miscquery($query); } elseif ($initiate == 'Accepted') { // Update request flag to show that the guest user ACCEPTED the Online Chat Request $query = "UPDATE " . $table_prefix . "requests SET `refresh` = NOW(), `initiate` = '-2' WHERE `id` = '$request_id'"; $SQL->miscquery($query); } elseif ($initiate == 'Declined') { // Update request flag to show that the guest user DENIED the Online Chat Request $query = "UPDATE " . $table_prefix . "requests SET `refresh` = NOW(), `initiate` = '-3' WHERE `id` = '$request_id'"; $SQL->miscquery($query); } else { if ($url == '' && $title == '') { // Update current page time $query = "UPDATE " . $table_prefix . "requests SET `refresh` = NOW(), `status` = '$request_status', services = '<".str_replace(",", "><", $_REQUEST['services']).">' WHERE `id` = '$request_id'"; $SQL->miscquery($query); } else { // Update current page details $query = "UPDATE " . $table_prefix . "requests SET `refresh` = NOW(), `request` = NOW(), `url` = '$url', `title` = '$title', `resolution` = '$width x $height', `status` = '0' WHERE `id` = '$request_id'"; $SQL->miscquery($query); } } } } else { //if ($width != '' && $height != '' && $title != '' && $url != '') { if ($width != '' && $height != ''&& $url != '') { //$page = $_REQUEST['URL']; $page = db_escape_string(urldecode(trim($_REQUEST['URL']))); for ($i = 0; $i < 3; $i++) { $pos = strpos($page, '/'); if ($pos === false) { $page = ''; break; } if ($i < 2) { $page = substr($page, $pos + 1); } elseif ($i >= 2) { $page = substr($page, $pos); } } if ($page == '') { $page = '/'; } $page = urldecode(trim($page)); // Update the current URL statistics within the requests tables if ($referrer == '') { $referrer = 'Direct Visit / Bookmark'; } $query = "SELECT name FROM " . $table_prefix . "domains WHERE id_domain = '".$domain_id."'"; $row = $SQL->selectquery($query); $domainName = $row['name']; if ((isset($domain_id)) && (!(strripos($domainName, $refDomain) === false))) { // increase the refresh value from 5 to 30 in order to support safari third-party cookies restriction. $query = "SELECT 1 FROM " . $table_prefix . "requests WHERE ipaddress = '$ipaddress' And useragent = '$useragent' And resolution = '$width x $height' And (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`datetime`)) < 30"; $row = $SQL->selectquery($query); if (!is_array($row)) { $query = "INSERT INTO " . $table_prefix . "requests(`ipaddress`, `useragent`, `resolution`, `datetime`, `request`, `refresh`, `url`, `title`, `referrer`, `path`, `initiate`, `status`, `id_domain`, number_pages, city, region, country_code, country, latitude, longitude) VALUES('$ipaddress', '$useragent', '$width x $height', NOW(), NOW(), NOW(), '$url', '$title', '$referrer', '$page', '0', '0', '" . $domain_id . "', 1, '$city' , '$region', '$countrycode', '$country', '$latitude', '$longitude')"; $request_id = $SQL->insertquery($query); $session = array(); $session['REQUEST'] = $request_id; $session['CHARSET'] = CHARSET; $session['USERID'] = db_escape_string($_REQUEST['USERID']); $session['DOMAINID'] = $domain_id; $session['AGENTID'] = $agent_id; if (isset($_REQUEST['LANGUAGE'])){ $session['LANGUAGE'] = $_REQUEST['LANGUAGE']; }else{ $session['LANGUAGE'] = LANGUAGE_TYPE; } $session['SERVICE'] = db_escape_string($_REQUEST['SERVICE']); //$session['ACCOUNT'] = $account; //$session['TRACKING'] = $tracking; //$session['STATUS_INDICATOR'] = $status_indicator; $data = serialize($session); setcookie($cookieName, $data, false, '/', $cookie_domain, $ssl); header("P3P: CP='$p3p'"); } }else{ $session = array(); $domainIsValid = false; $session['VALID'] = $domainIsValid; $data = serialize($session); setcookie($cookieName, $data, false, '/', $cookie_domain, $ssl); header("P3P: CP='$p3p'"); } } } if ( isset( $_GET[ 'GET_INVITATION_MESSAGE' ] ) ) { $query = "SELECT init_message FROM " . $table_prefix . "requests WHERE id = '". (int) $request_id ."'"; $row = $SQL->selectquery($query); if ( !empty( $row['init_message'] ) ) { if ( isset( $_GET['json'] ) ) { $json = array( 'text' => $row['init_message'] ); echo 's1.checkInitiate_json(' . json_encode($json) . ')'; } else { echo $row['init_message']; } } die( '' ); } header('Content-type: image/gif'); if ($request_initiated == true) { if ( $request_initiate_flag == 2 ) { readfile($install_path . $install_directory . '/import/initiate-message.gif'); } else { readfile($install_path . $install_directory . '/import/initiate.gif'); } } else { readfile($install_path . $install_directory . '/import/tracker.gif'); } ?>