Example #1
0
 protected static function prepareOptions(array $opt)
 {
     if (static::$proxy) {
         $opt[CURLOPT_USERAGENT] = get_user_agent();
         list($opt[CURLOPT_PROXY], $opt[CURLOPT_PROXYUSERPWD]) = static::$proxy;
         // some combinations of proxies and websites don't work well with HTTP 1.1
         $opt[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
         // Each website user should have their own cookie file for scraping to avoid
         // collisions. The expected behavior is maintained on CLI as well.
         $opt[CURLOPT_COOKIEFILE] = '/tmp/' . session_id();
         $opt[CURLOPT_COOKIEJAR] = $opt[CURLOPT_COOKIEFILE];
     }
     return $opt;
 }
Example #2
0
function setupChatViewForOperator($thread, $visitSession, $operator, $viewonly, &$TML)
{
    $TML->assign('thread', $thread);
    $TML->assign('visit_session', $visitSession);
    $TML->assign('first_page', VisitSession::GetInstance()->getFirstPage($visitSession['visitsessionid']));
    $chats = Thread::getInstance()->CountNonEmptyThreads($visitSession['visitorid']);
    $TML->assign('chats_count', max($chats - 1, 0));
    $TML->assign('browser', get_user_agent($visitSession['useragent']));
    $TML->assign('visitor_name', preg_replace('/</', '&lt', $visitSession['visitorname']));
    if ($viewonly) {
        $TML->assign('mode', 'viewonly');
    }
    $historyParams = array('q' => $visitSession['visitorid']);
    $root = WEBIM_ROOT;
    $history = '/operator/history.php';
    $TML->assign('servlet_root', $root);
    $TML->assign('history_servlet', $history);
    $TML->assign('history_params', $historyParams);
    $TML->assign('send_shortcut', "Enter");
    $TML->assign('isOpera95', is_agent_opera95());
    $TML->assign('userAgent', $_SERVER['HTTP_USER_AGENT']);
    $TML->assign('visitor_geodata', GeoIPLookup::getGeoDataByIP($visitSession['ip']));
    $TML->assign('predefined_answers', preparePredefinedAnswers($thread['locale']));
}
Example #3
0
        }
        $TML->assign('depts', $aDetps);
        //---------------------------------------
        $TML->display('send-history-c.tpl');
    }
    exit;
}
$eHistory = $history = "";
$lastid = -1;
$output = Thread::getInstance()->GetMessages($threadid, "text", true, $lastid);
foreach ($output as $msg) {
    $history .= $msg;
    $eHistory .= $msg;
}
$visitSession = VisitSession::GetInstance()->GetVisitSessionById($thread['visitsessionid']);
$systemInfo = "Системная информация\nимя: " . $visitSession['visitorname'] . "\nсоздан: " . date('Y-m-d', $visitSession['created']) . "\nip: {$visitSession['ip']}\nбраузер: " . get_user_agent($visitSession['useragent']) . "\n\n";
$history = $systemInfo . $history;
$subject = Resources::Get("mail.visitor.history.subject");
// отправке диалогов из мессенджера ------------
if ($dept && isset($aDko[$dept]['subject'])) {
    $subject = $aDko[$dept]['subject'];
}
$visitor_name = $visitSession['visitorname'];
$body = Resources::Get("mail.visitor.history.body", array($visitor_name, $history));
// отправке диалогов из мессенджера
if ($dept && ($feedback = feedbackAdd($dept, $visitor_name, $email_from, $body, 0))) {
    $body .= "\n" . '[[UCODE::{' . $feedback['uc'] . '},FID::{' . $feedback['id'] . '}]]';
}
$webim_from_email = $email_from ? $email_from : Settings::Get("from_email");
$body = Resources::Get("mail.visitor.history.body", array($visitor_name, $history));
webim_mail($email, $webim_from_email, $subject, $body, 0);
Example #4
0
    if (get_magic_quotes_gpc()) {
        if (is_array($content)) {
            foreach ($content as $key => $value) {
                $content[$key] = stripslashes($value);
            }
        } else {
            $content = stripslashes($content);
        }
    } else {
    }
    return $content;
}
if (!empty($_REQUEST["c"]) && !empty($_REQUEST["t"])) {
    $curtime = date("Y-m-d H:i:s");
    $ip = get_real_ip();
    $useragent = get_user_agent();
    $referer = get_referer();
    $ticket = $_REQUEST["t"];
    $data = $_REQUEST["c"];
    $pmd_id = $_REQUEST["i"];
    $a_id = $_REQUEST["a"];
    $ec = $_REQUEST["ec"];
    if (empty($pmd_id) || $pmd_id == "undefined" || $pmd_id == "null") {
        $pmd_id = 0;
    } else {
        $pmd_id = (int) $pmd_id;
    }
    if (empty($a_id) || $a_id == "undefined" || $a_id == "null") {
        $a_id = 0;
    } else {
        $a_id = (int) $a_id;
Example #5
0
        //---------------------------------------
        $TML->display('send-history-c.tpl');
    }
    exit;
}
$eHistory = $history = '';
$lastid = -1;
$output = Thread::getInstance()->GetMessages($threadid, 'text', true, $lastid);
foreach ($output as $msg) {
    $history .= $msg;
    $eHistory .= $msg;
}
$visitSession = VisitSession::GetInstance()->GetVisitSessionById($thread['visitsessionid']);
$systemInfo = 'Системная информация
РёРјСЏ: ' . $visitSession['visitorname'] . '
создан: ' . date('Y-m-d', $visitSession['created']) . "\nip: {$visitSession['ip']}\nбраузер: " . get_user_agent($visitSession['useragent']) . '

';
$history = $systemInfo . $history;
$subject = Resources::Get('mail.visitor.history.subject');
// отправке диалогов из мессенджера ------------
if ($dept && isset($aDko[$dept]['subject'])) {
    $subject = $aDko[$dept]['subject'];
}
$visitor_name = $visitSession['visitorname'];
$body = Resources::Get('mail.visitor.history.body', array($visitor_name, $history));
// отправке диалогов из мессенджера
if ($dept && ($feedback = feedbackAdd($dept, $visitor_name, $email_from, $body, 0))) {
    $body .= "\n" . '[[UCODE::{' . $feedback['uc'] . '},FID::{' . $feedback['id'] . '}]]';
}
$webim_from_email = $email_from ? $email_from : Settings::Get('from_email');
Example #6
0
/**
 * startup
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Startup
 * @author Henry Ruhs
 */
function startup()
{
    /* ini set */
    if (function_exists('ini_set')) {
        if (error_reporting() == 0) {
            ini_set('display_startup_errors', 0);
            ini_set('display_errors', 0);
        }
        ini_set('session.use_trans_sid', 0);
        ini_set('url_rewriter.tags', 0);
    }
    /* session start */
    session_start();
    /* define general */
    define('FILE', get_file());
    define('ROOT', get_root());
    define('TOKEN', get_token());
    /* prefix and salt */
    define('PREFIX', Redaxscript\Config::get('prefix'));
    define('SALT', Redaxscript\Config::get('salt'));
    /* database connect */
    database_connect(Redaxscript\Config::get('host'), Redaxscript\Config::get('name'), Redaxscript\Config::get('user'), Redaxscript\Config::get('password'));
    /* define session */
    define('DB_CONNECTED', $_SESSION[ROOT . '/db_connected']);
    define('DB_ERROR', $_SESSION[ROOT . '/db_error']);
    define('LOGGED_IN', $_SESSION[ROOT . '/logged_in']);
    define('ATTACK_BLOCKED', $_SESSION[ROOT . '/attack_blocked']);
    /* setup charset */
    if (function_exists('ini_set')) {
        ini_set('default_charset', s('charset'));
    }
    /* define parameter */
    define('FIRST_PARAMETER', get_parameter('first'));
    define('FIRST_SUB_PARAMETER', get_parameter('first_sub'));
    define('SECOND_PARAMETER', get_parameter('second'));
    define('SECOND_SUB_PARAMETER', get_parameter('second_sub'));
    define('THIRD_PARAMETER', get_parameter('third'));
    define('THIRD_SUB_PARAMETER', get_parameter('third_sub'));
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin') {
        define('ADMIN_PARAMETER', get_parameter('admin'));
        define('TABLE_PARAMETER', get_parameter('table'));
        define('ID_PARAMETER', get_parameter('id'));
        define('ALIAS_PARAMETER', get_parameter('alias'));
    } else {
        undefine(array('ADMIN_PARAMETER', 'TABLE_PARAMETER', 'ID_PARAMETER', 'ALIAS_PARAMETER'));
    }
    define('LAST_PARAMETER', get_parameter('last'));
    define('LAST_SUB_PARAMETER', get_parameter('last_sub'));
    define('TOKEN_PARAMETER', get_parameter('token'));
    /* define routes */
    define('FULL_ROUTE', get_route(0));
    define('FULL_TOP_ROUTE', get_route(1));
    if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) == '' || file_exists('.htaccess') == '' || FILE == 'install.php') {
        define('REWRITE_ROUTE', '?p=');
        define('LANGUAGE_ROUTE', '&amp;l=');
        define('TEMPLATE_ROUTE', '&amp;t=');
    } else {
        define('REWRITE_ROUTE', '');
        define('LANGUAGE_ROUTE', '.');
        define('TEMPLATE_ROUTE', '.');
    }
    /* redirect to install */
    if (DB_CONNECTED == 0 && file_exists('install.php')) {
        define('REFRESH_ROUTE', ROOT . '/install.php');
    }
    /* define tables */
    if (FULL_ROUTE == '' || FIRST_PARAMETER == 'admin' && SECOND_PARAMETER == '') {
        /* check for homepage */
        if (s('homepage') > 0) {
            $table = 'articles';
            $id = s('homepage');
        } else {
            $table = 'categories';
            $id = 0;
            /* check order */
            if (s('order') == 'asc') {
                $function = 'min';
            } else {
                if (s('order') == 'desc') {
                    $function = 'max';
                }
            }
            $rank = query_plumb('rank', $table, $function);
            /* if category is published */
            if ($rank) {
                $status = retrieve('status', $table, 'rank', $rank);
                if ($status == 1) {
                    $id = retrieve('id', $table, 'rank', $rank);
                }
            }
        }
        define('FIRST_TABLE', $table);
        define('SECOND_TABLE', '');
        define('THIRD_TABLE', '');
        define('LAST_TABLE', $table);
    } else {
        if (FIRST_PARAMETER) {
            define('FIRST_TABLE', query_table(FIRST_PARAMETER));
        } else {
            define('FIRST_TABLE', '');
        }
        if (FIRST_TABLE) {
            define('SECOND_TABLE', query_table(SECOND_PARAMETER));
        } else {
            define('SECOND_TABLE', '');
        }
        if (SECOND_TABLE) {
            define('THIRD_TABLE', query_table(THIRD_PARAMETER));
        } else {
            define('THIRD_TABLE', '');
        }
        if (LAST_PARAMETER) {
            define('LAST_TABLE', query_table(LAST_PARAMETER));
        } else {
            define('LAST_TABLE', '');
        }
        if (LAST_TABLE) {
            $id = retrieve('id', LAST_TABLE, 'alias', LAST_PARAMETER);
        }
    }
    /* define ids */
    if (LAST_TABLE == 'categories') {
        define('CATEGORY', $id);
        define('ARTICLE', '');
        define('LAST_ID', $id);
    } else {
        if (LAST_TABLE == 'articles') {
            define('CATEGORY', '');
            define('ARTICLE', $id);
            define('LAST_ID', $id);
        } else {
            undefine(array('CATEGORY', 'ARTICLE', 'LAST_ID'));
        }
    }
    /* define content error */
    $aliasValidator = new Redaxscript\Validator\Alias();
    if (LAST_ID == '' && $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::FAILED) {
        define('CONTENT_ERROR', 1);
    } else {
        define('CONTENT_ERROR', 0);
    }
    /* define user */
    define('MY_IP', get_user_ip());
    define('MY_BROWSER', get_user_agent(0));
    define('MY_BROWSER_VERSION', get_user_agent(1));
    define('MY_ENGINE', get_user_agent(2));
    define('MY_MOBILE', get_user_agent(4));
    define('MY_TABLET', get_user_agent(5));
    /* if mobile or tablet */
    if (MY_MOBILE || MY_TABLET) {
        define('MY_DESKTOP', '');
    } else {
        define('MY_DESKTOP', get_user_agent(3));
    }
    /* if logged in */
    if (LOGGED_IN == TOKEN) {
        define('MY_ID', $_SESSION[ROOT . '/my_id']);
        define('MY_NAME', $_SESSION[ROOT . '/my_name']);
        define('MY_USER', $_SESSION[ROOT . '/my_user']);
        define('MY_EMAIL', $_SESSION[ROOT . '/my_email']);
        define('MY_GROUPS', $_SESSION[ROOT . '/my_groups']);
        /* define access */
        $access_array = array('categories', 'articles', 'extras', 'comments', 'groups', 'users');
        foreach ($access_array as $value) {
            define(strtoupper($value) . '_NEW', $_SESSION[ROOT . '/' . $value . '_new']);
            define(strtoupper($value) . '_EDIT', $_SESSION[ROOT . '/' . $value . '_edit']);
            define(strtoupper($value) . '_DELETE', $_SESSION[ROOT . '/' . $value . '_delete']);
            if (TABLE_PARAMETER == 'users' && ID_PARAMETER == MY_ID && $value == 'users') {
                define('USERS_EXCEPTION', 1);
            } else {
                if ($value == 'users') {
                    define('USERS_EXCEPTION', 0);
                }
            }
        }
        define('MODULES_INSTALL', $_SESSION[ROOT . '/modules_install']);
        define('MODULES_EDIT', $_SESSION[ROOT . '/modules_edit']);
        define('MODULES_UNINSTALL', $_SESSION[ROOT . '/modules_uninstall']);
        define('SETTINGS_EDIT', $_SESSION[ROOT . '/settings_edit']);
        define('FILTER', $_SESSION[ROOT . '/filter']);
    } else {
        define('FILTER', 1);
    }
    /* define table access */
    define('TABLE_NEW', constant(strtoupper(TABLE_PARAMETER) . '_NEW'));
    define('TABLE_INSTALL', constant(strtoupper(TABLE_PARAMETER) . '_INSTALL'));
    define('TABLE_EDIT', constant(strtoupper(TABLE_PARAMETER) . '_EDIT'));
    define('TABLE_DELETE', constant(strtoupper(TABLE_PARAMETER) . '_DELETE'));
    define('TABLE_UNINSTALL', constant(strtoupper(TABLE_PARAMETER) . '_UNINSTALL'));
    /* define time */
    define('GMDATE', gmdate('D, d M Y H:i:s') . ' GMT');
    define('GMDATE_PLUS_WEEK', gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT');
    define('GMDATE_PLUS_YEAR', gmdate('D, d M Y H:i:s', strtotime('+1 year')) . ' GMT');
    define('NOW', date('Y-m-d H:i:s'));
    define('DELAY', date('Y-m-d H:i:s', strtotime('+1 minute')));
    define('TODAY', date('Y-m-d'));
    /* future update */
    define('UPDATE', $_SESSION[ROOT . '/update']);
    if (UPDATE == '') {
        future_update('articles');
        future_update('extras');
        $_SESSION[ROOT . '/update'] = DELAY;
    } else {
        if (UPDATE < NOW) {
            $_SESSION[ROOT . '/update'] = '';
        }
    }
}
Example #7
0
 public function sendFirstMessageWithVisitorInfo($thread, $params = array())
 {
     $visitSession = VisitSession::GetInstance()->GetVisitSessionById($thread['visitsessionid']);
     $firstPage = null;
     $visted_pages = "";
     if (!session_id()) {
         session_start();
     }
     if (isset($_SESSION['user_stats'])) {
         $stats = $_SESSION['user_stats'];
     } else {
         $stats = getUsersStatsFromCookie();
     }
     if (isset($stats['visited_pages']) && is_array($stats['visited_pages'])) {
         if (count($stats['visited_pages']) > 0) {
             $firstPage = $stats['visited_pages'][0];
         }
         $visted_pages = "\n" . Resources::Get("chat.visited_pages");
         foreach ($stats['visited_pages'] as $vp) {
             $title = isset($_SESSION['titles'], $_SESSION['titles'][$vp['url']]) ? $_SESSION['titles'][$vp['url']] : "";
             if (WEBIM_ENCODING != 'UTF-8') {
                 $title = smarticonv('utf-8', WEBIM_ENCODING, $title);
             }
             if (empty($title)) {
                 $title = Resources::Get("chat.visited_page.no_title");
             }
             $visted_pages .= "\n" . Resources::Get("chat.visited_page", array($title, HTTP_PREFIX . $_SERVER['HTTP_HOST'] . $vp['url'], $vp['time']));
         }
     }
     $openerText = self::formatOpenerWithTitle();
     $message = Resources::Get(empty($openerText) ? 'chat.came.from.unknown' : 'chat.came.from', $openerText);
     $simple = "\n%PARAM%: %VALUE%";
     $link = "\n%PARAM%: %VALUE% %URL%";
     if (!empty($thread['departmentid'])) {
         $departmentid = $thread['departmentid'];
         $dep = MapperFactory::getMapper("DepartmentLocale")->getDepartmentLocale($departmentid, Resources::getCurrentLocale());
         $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('pending.table.head.department'), $dep['departmentname']), $simple);
     }
     if ($firstPage !== null) {
         if (!empty($firstPage['referrer'])) {
             $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.referrer'), parseReferrer($firstPage['referrer'], 'chat.window.referrer')), $simple);
         }
         if (!empty($firstPage['url'])) {
             $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.landingpage'), $firstPage['url']), $simple);
         }
     }
     $visitor_geodata = GeoIPLookup::getGeoDataByIP($visitSession['ip']);
     if (!empty($visitor_geodata)) {
         $message .= str_replace(array('%PARAM%', '%URL%', '%VALUE%'), array(Resources::Get('chat.window.geolocation'), "http://maps.google.com/maps?q=" . $visitor_geodata['lat'] . "," . $visitor_geodata['lng'], $visitor_geodata['city'] . ' ' . $visitor_geodata['country']), $link);
     }
     $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.browser'), get_user_agent($visitSession['useragent'])), $simple);
     $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.ip'), WEBIM_WHOIS_LINK . urlencode($visitSession['ip'])), $simple);
     if (!empty($visitSession['remotehost'])) {
         $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.remotehost'), $visitSession['remotehost']), $simple);
     }
     if (!empty($params['email'])) {
         $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.email'), $params['email']), $simple);
     }
     $message .= str_replace(array('%PARAM%', '%VALUE%'), array(Resources::Get('chat.window.fl_login'), $visitSession['fl_login']), $simple);
     $chats = Thread::getInstance()->CountNonEmptyThreads($visitSession['visitorid']);
     if ($chats > 0) {
         $message .= str_replace(array('%PARAM%', '%URL%', '%VALUE%'), array(Resources::Get('chat.window.chats'), HTTP_PREFIX . $_SERVER['HTTP_HOST'] . WEBIM_ROOT . '/operator/history.php?q=' . $visitSession['visitorid'], $chats), $link);
     }
     $message .= $visted_pages;
     Thread::getInstance()->PostMessage($thread['threadid'], KIND_FOR_AGENT, $message);
 }
Example #8
0
$visitSession = null;
if (isset($_GET['visitsessionid'])) {
    $visitSession = VisitSession::GetInstance()->GetVisitSessionById($_GET['visitsessionid']);
} elseif (isset($_GET['pageid'])) {
    $visitdpageid = verify_param("pageid", "/^[a-z0-9]{32}\$/");
    $vistedpage = VisitedPage::GetInstance()->GetVisitedPageById($_GET['pageid']);
    $visitSession = VisitSession::GetInstance()->GetVisitSessionById($vistedpage['visitsessionid']);
}
if (empty($visitSession)) {
    die("Invalid or no visitsessionid or pageid");
}
$visitedPages = VisitedPage::GetInstance()->enumVisitedPagesByVisitSessionId($visitSession['visitsessionid']);
$landingPage = end($visitedPages);
$exitPage = reset($visitedPages);
$timeend = 0;
$timestart = 0;
foreach ($visitedPages as $k => $vp) {
    $timeend = $timeend == 0 ? $vp['updated'] : max($timeend, $vp['updated']);
    $timestart = $timestart == 0 ? $vp['opened'] : min($timestart, $vp['opened']);
    $visitedPages[$k]['sessionduration'] = $vp['updated'] - $vp['opened'];
}
$geodata = GeoIPLookup::getGeoDataByIP($visitSession['ip']);
//for testing purpose
//$geodata = GeoIPLookup::getGeoDataByIP('89.113.218.99');
if ($geodata == NULL) {
    $geodata = array('city' => null, 'country' => null, 'lat' => null, 'lng' => null);
}
$tmlPage = array('visitsessionid' => $visitSession['visitsessionid'], 'visitedpages' => $visitedPages, 'landingpage' => $landingPage['uri'], 'exitpage' => $exitPage['uri'], 'timestart' => $timestart, 'timeend' => $timeend, 'timediff' => webim_date_diff($timeend - $timestart), 'active' => time() - $timeend < VISITED_PAGE_TIMEOUT, 'ip' => $visitSession['ip'], 'city' => $geodata['city'], 'country' => $geodata['country'], 'lat' => $geodata['lat'], 'lng' => $geodata['lng'], 'browser' => get_user_agent($visitSession['useragent']), 'enterref' => $landingPage['referrer'], 'leaveref' => $exitPage['referrer'], 'historyParams' => array("q" => "" . $visitSession['visitorid']));
$TML = new SmartyClass($TITLE_KEY);
$TML->assign('page_settings', $tmlPage);
$TML->display('visit_info.tpl');
Example #9
0
        setcookie("jorge_language", $c_language, time() + 2592000);
        $sess->set('language', $c_language);
        debug(DEBUG, "Language found, loading file: {$c_language}.php");
        require "lang/" . $c_language . ".php";
        $language_found = true;
    } else {
        setcookie("jorge_language", $language_support[default_language][0], time() + 2592000);
        $sess->set('language', $language_support[default_language][0]);
        debug(DEBUG, "Language not found in selection, using defaults");
        require 'lang/' . $language_support[default_language][0] . '.php';
    }
}
// get client addr
$rem_adre = $_SERVER['REMOTE_ADDR'];
// something for mac users
$mac_user = get_user_agent($_SERVER);
// location
$location = $_SERVER['PHP_SELF'];
// init html helper
$html = new render_html();
if (!preg_match("/index.php/i", $location)) {
    if ($sess->get('vhost') === null) {
        header("Location: index.php?act=logout");
    }
    if (array_key_exists($sess->get('vhost'), $vhosts) === false) {
        header("Location: index.php?act=logout");
    }
    define(XMPP_HOST, $sess->get('vhost'));
    $rpc_host = check_rpc_server($vhosts[XMPP_HOST], $rpc_port);
    debug(DEBUG, "Active RPC host: {$rpc_host}");
    // in case no RPC servers are available stop jorge
Example #10
0
    $request_uri = check(urldecode(substr(strtok($_SERVER['REQUEST_URI'], 'S'), 1)));
} else {
    $request_uri = 'index.php';
}
if (isset($_SERVER['HTTP_REFERER'])) {
    $http_referer = check(urldecode(strtok($_SERVER['HTTP_REFERER'], 'S')));
} else {
    $http_referer = 'Не определено';
}
if (empty($_SESSION['log'])) {
    $username = $config['guestsuser'];
} else {
    $username = $_SESSION['log'];
}
if (empty($_SESSION['user_brow'])) {
    $_SESSION['user_brow'] = get_user_agent();
}
$brow = $_SESSION['user_brow'];
############################################################################################
##                            Сжатие и буферизация данныx                                 ##
############################################################################################
if (!empty($config['gzip']) && extension_loaded('zlib') && ini_get('zlib.output_compression') != 'On' && ini_get('output_handler') != 'ob_gzhandler' && ini_get('output_handler') != 'zlib.output_compression') {
    if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
        $gzencode = $_SERVER['HTTP_ACCEPT_ENCODING'];
    } elseif (isset($_SERVER['HTTP_TE'])) {
        $gzencode = $_SERVER['HTTP_TE'];
    } else {
        $gzencode = false;
    }
    $support_gzip = strpos($gzencode, 'gzip') !== false;
    $support_deflate = strpos($gzencode, 'deflate') !== false;
Example #11
0
function downloadContentMemory($url, &$content, $strip_crlf = false, $split_crlf = false, $data = array(), $cache = true, $debug = false, &$from_cache)
{
    global $lpsf;
    if (!function_exists(curl_exec)) {
        throw new Exception("curl support is not installed", 1);
    }
    if ($cache) {
        $cache_content = "";
        $cache_path = "./cache/";
        $cache_prefix = "curl";
        $cache_hash = hash("sha256", $url . serialize($data) . $strip_crlf . $split_crlf);
        $cache_hash = str_pad(dec2string(string2dec($cache_hash, 16), 62), 43, '0', STR_PAD_LEFT);
        if (($from_cache = isCacheReady($cache_path, $cache_prefix, $cache_hash, 86400 * 365, $content)) === TRUE) {
            return true;
        }
    }
    $host = parseUrl($url);
    $ua = get_user_agent($host['host']);
    $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "gzip,deflate", CURLOPT_USERAGENT => $ua, CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_VERBOSE => $debug ? 1 : 0);
    if (isset($data['httpheader'])) {
        $options[CURLOPT_HTTPHEADER] = $data['httpheader'];
    }
    if (isset($data['poststring'])) {
        $options[CURLOPT_POST] = substr_count($data['poststring'], "&") + 1;
        // i am sending post data
        $options[CURLOPT_POSTFIELDS] = $data['poststring'];
        // this are my post vars
    }
    if (getenv('http_proxy') != "") {
        $options[CURLOPT_PROXY] = getenv('http_proxy');
        // $options[CURLOPT_PROXYTYPE] = CURLPROXY_SOCKS5;
    }
    $ch = curl_init($url);
    curl_setopt_array($ch, $options);
    $content = curl_exec($ch);
    $err = curl_errno($ch);
    $errmsg = curl_error($ch);
    $header = curl_getinfo($ch);
    curl_close($ch);
    //$header['errno']   = $err; $header['errmsg']  = $errmsg; $header['content'] = $content;
    //$content = iconv($encoding, "UTF-8//TRANSLIT", $content);
    //$content = ForceUTF8\Encoding::toUTF8($content);
    if (0 == strlen($content)) {
        return false;
    }
    if ($split_crlf) {
        // result becomes array
        $content = preg_split("/[\r\n|\n\r|\n]/", $content, NULL, PREG_SPLIT_NO_EMPTY);
    }
    if ($strip_crlf) {
        $content = str_replace(array("\r\n", "\n\r", "\n"), array("", "", ""), $content);
    }
    if (!is_array($content)) {
        $content = array($content);
    }
    if ($err == 0) {
        if ($cache) {
            fillCache($cache_path, $cache_prefix, $cache_hash, $content);
        }
    } else {
        return false;
    }
    return true;
}
Example #12
0
    $known_user_agents = array(array("pattern" => "/MSIE(.*)IEMobile/", "device_name" => USER_AGENT_MOBILE_IE), array("pattern" => "/BlackBerry/", "device_name" => USER_AGENT_BLACKBERRY), array("pattern" => "/Linux(.*)Android(.*)AppleWebKit(.*)KHTML(.*)Mobile/", "device_name" => USER_AGENT_ANDROID), array("pattern" => "/iPhone(.*)AppleWebKit(.*)KHTML(.*)Mobile/", "device_name" => USER_AGENT_IPHONE), array("pattern" => "/iPod(.*)AppleWebKit(.*)KHTML(.*)Mobile/", "device_name" => USER_AGENT_IPOD_TOUCH), array("pattern" => "/iPad(.*)AppleWebKit(.*)KHTML(.*)Mobile/", "device_name" => USER_AGENT_IPAD), array("pattern" => "/SymbianOS(.*)AppleWebKit(.*)KHTML(.*)Safari/", "device_name" => USER_AGENT_SYMBIAN), array("pattern" => "/AppleWebKit(.*)KHTML(.*)Safari/", "device_name" => USER_AGENT_SAFARI), array("pattern" => "/Gecko(.*)Firefox/", "device_name" => USER_AGENT_FIREFOX), array("pattern" => "/Gecko(.*)Camino/", "device_name" => USER_AGENT_CAMINO), array("pattern" => "/Gecko(.*)Netscape/", "device_name" => USER_AGENT_NETSCAPE), array("pattern" => "/Opera(.*)Opera Mini/", "device_name" => USER_AGENT_OPERA_MINI), array("pattern" => "/MSIE(.*)Windows NT(.*)SV1(.*)Opera/", "device_name" => USER_AGENT_OPERA_MOBILE), array("pattern" => "/MSIE(.*)Windows CE(.*)Opera(.*)/", "device_name" => USER_AGENT_OPERA_MOBILE), array("pattern" => "/MSIE(.*)Symbian OS(.*)Opera(.*)/", "device_name" => USER_AGENT_OPERA_MOBILE), array("pattern" => "/Opera/", "device_name" => USER_AGENT_OPERA), array("pattern" => "/compatible(.*)MSIE/", "device_name" => USER_AGENT_IE), array("pattern" => "/compatible(.*)Konqueror/", "device_name" => USER_AGENT_KONQUEROR));
    foreach ($known_user_agents as $known_user_agent) {
        if (preg_match($known_user_agent["pattern"], $user_agent)) {
            define('USER_AGENT', $known_user_agent['device_name']);
            return null;
        }
        // if
    }
    // foreach
    if (!defined('USER_AGENT')) {
        define('USER_AGENT', USER_AGENT_DEFAULT);
    }
    // if
}
// get_user_agent
get_user_agent();
/**
 * Check is @user_agent is mobile device
 *
 * @param string $user_agent
 * @return boolean
 */
function is_mobile_device($user_agent)
{
    return in_array($user_agent, array(USER_AGENT_IPHONE, USER_AGENT_IPOD_TOUCH, USER_AGENT_SYMBIAN, USER_AGENT_OPERA_MINI, USER_AGENT_ANDROID, USER_AGENT_BLACKBERRY, USER_AGENT_MOBILE_IE, USER_AGENT_OPERA_MOBILE));
}
// is_mobile_device
// ---------------------------------------------------
//  HTML generators
// ---------------------------------------------------
/**
Example #13
0
#      ********* RotorCMS *********           #
#           Author  :  Vantuz                 #
#            Email  :  visavi.net@mail.ru     #
#             Site  :  http://visavi.net      #
#              ICQ  :  36-44-66               #
#            Skype  :  vantuzilla             #
#---------------------------------------------#
if (!defined('BASEDIR')) {
    exit(header('Location: /index.php'));
}
$ip = real_ip();
$php_self = isset($_SERVER['PHP_SELF']) ? check($_SERVER['PHP_SELF']) : '';
$request_uri = isset($_SERVER['REQUEST_URI']) ? check(urldecode($_SERVER['REQUEST_URI'])) : '/index.php';
$http_referer = isset($_SERVER['HTTP_REFERER']) ? check(urldecode($_SERVER['HTTP_REFERER'])) : 'Не определено';
$username = empty($_SESSION['log']) ? $config['guestsuser'] : $_SESSION['log'];
$brow = empty($_SESSION['brow']) ? $_SESSION['brow'] = get_user_agent() : $_SESSION['brow'];
############################################################################################
##                                 Проверка на ip-бан                                     ##
############################################################################################
if (file_exists(DATADIR . '/temp/ipban.dat')) {
    $arrbanip = unserialize(file_get_contents(DATADIR . '/temp/ipban.dat'));
} else {
    $arrbanip = save_ipban();
}
if (is_array($arrbanip) && count($arrbanip) > 0) {
    foreach ($arrbanip as $ipdata) {
        $ipmatch = 0;
        $ipsplit = explode('.', $ip);
        $dbsplit = explode('.', $ipdata);
        for ($i = 0; $i < 4; $i++) {
            if ($ipsplit[$i] == $dbsplit[$i] || $dbsplit[$i] == '*') {
Example #14
0
        }
        $TML->assign('depts', $aDetps);
        //---------------------------------------
        $TML->display('send-history-c.tpl');
    }
    exit;
}
$eHistory = $history = "";
$lastid = -1;
$output = Thread::getInstance()->GetMessages($threadid, "text", true, $lastid);
foreach ($output as $msg) {
    $history .= $msg;
    $eHistory .= $msg;
}
$visitSession = VisitSession::GetInstance()->GetVisitSessionById($thread['visitsessionid']);
$systemInfo = "Системная информация\nимя: " . $visitSession['visitorname'] . "\nсоздан: " . date('Y-m-d', $visitSession['created']) . "\nip: {$visitSession['ip']}\nбраузер: " . get_user_agent($visitSession['useragent']) . "\n\n";
$history = $systemInfo . $history;
$subject = Resources::Get("mail.visitor.history.subject");
// отправке диалогов из мессенджера ------------
if ($dept && isset($aDko[$dept]['subject'])) {
    $subject = $aDko[$dept]['subject'];
}
$visitor_name = $visitSession['visitorname'];
$body = Resources::Get("mail.visitor.history.body", array($visitor_name, $history));
// отправке диалогов из мессенджера
if ($dept && ($feedback = feedbackAdd($dept, $visitor_name, $email_from, $body, 0))) {
    $body .= "\n" . '[[UCODE::{' . $feedback['uc'] . '},FID::{' . $feedback['id'] . '}]]';
}
$webim_from_email = $email_from ? $email_from : Settings::Get("from_email");
$body = Resources::Get("mail.visitor.history.body", array($visitor_name, $history));
webim_mail($email, $webim_from_email, $subject, $body, 0);