if (!empty($_GET[SYSUTIL_ML_PARAM_NAME]) && ($sysutil_ml_langname = sysutil_ml_getlangname($_GET[SYSUTIL_ML_PARAM_NAME]))) {
        $xoopsConfig['language'] = $sysutil_ml_langname;
        $_SERVER['QUERY_STRING'] = preg_replace('/(^|&)' . SYSUTIL_ML_PARAM_NAME . '\\=.*$/', '', $_SERVER['QUERY_STRING']);
        $_SERVER['argv'][0] = preg_replace('/(^|&)' . SYSUTIL_ML_PARAM_NAME . '\\=.*$/', '', $_SERVER['argv'][0]);
    } else {
        if (!empty($_COOKIE[SYSUTIL_ML_COOKIE_NAME])) {
            $xoopsConfig['language'] = $_COOKIE[SYSUTIL_ML_COOKIE_NAME];
        } else {
            $xoopsConfig['language'] = sysutil_get_xoops_option('sysutil', 'sysutil_default_lang');
        }
    }
    if (empty($_COOKIE[SYSUTIL_ML_COOKIE_NAME]) || $_COOKIE[SYSUTIL_ML_COOKIE_NAME] != $xoopsConfig['language']) {
        setcookie(SYSUTIL_ML_COOKIE_NAME, $sysutil_ml_langname, time() + SYSUTIL_ML_COOKIELIFETIME, $xoops_cookie_path, '', 0);
    }
} else {
    $xoopsConfig['language'] = sysutil_get_xoops_option('sysutil', 'sysutil_default_lang');
}
// ob filter
function sysutil_ml_filter($s)
{
    global $sysutil_ml_lang, $xoopsUser;
    $sysutil_ml_langs = explode(',', SYSUTIL_ML_LANGS);
    // protection against some injection
    if (!in_array($GLOBALS['sysutil_ml_lang'], $sysutil_ml_langs)) {
        $GLOBALS['sysutil_ml_lang'] = $sysutil_ml_langs[0];
    }
    // escape brackets inside of <input type="text" value="...">
    $s = preg_replace_callback('/(\\<input)(?=.*type\\=[\'\\"]?text[\'\\"]?)([^>]*)(\\>)/isU', 'sysutil_ml_escape_bracket', $s);
    // escape brackets inside of <textarea></textarea>
    $s = preg_replace_callback('/(\\<textarea[^>]*\\>)(.*)(<\\/textarea\\>)/isU', 'sysutil_ml_escape_bracket', $s);
    // multilanguage image tag
        if ($_GET['op'] == 'logout') {
            header('Location: ' . XOOPS_URL . '/modules/sysutil/index.php?op=logout');
            exit;
        }
    }
} else {
    if (strpos($_SERVER['REQUEST_URI'], '/register.php') === 0) {
        $config_handler =& xoops_gethandler('config');
        $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
        if (!$xoopsConfigUser['allow_register']) {
            redirect_header('index.php', 6, _US_NOREGISTER);
            exit;
        }
    }
}
define('SYSUTIL_AUTOLOGIN_LIFETIME', sysutil_get_xoops_option('sysutil', 'sysutil_login_lifetime') * 3600);
if (empty($_SESSION['xoopsUserId'])) {
    if (isset($_COOKIE['autologin_uname']) && isset($_COOKIE['autologin_pass'])) {
        $confirm_url = '/modules/autologin/index.php';
        if (!empty($_POST)) {
            $_SESSION['AUTOLOGIN_POST'] = $_POST;
            $_SESSION['AUTOLOGIN_REQUEST_URI'] = $_SERVER['REQUEST_URI'];
            redirect_header(XOOPS_URL . $confirm_url . '?op=confirm', 0, '&nbsp;');
        } else {
            if (!empty($_SERVER['QUERY_STRING']) && substr($_SERVER['SCRIPT_NAME'], -strlen($confirm_url)) != $confirm_url) {
                $_SESSION['AUTOLOGIN_REQUEST_URI'] = $_SERVER['REQUEST_URI'];
                redirect_header(XOOPS_URL . $confirm_url . '?op=confirm', 0, '&nbsp;');
            }
        }
        $member_handler =& xoops_gethandler('member');
        $myts =& MyTextSanitizer::getInstance();
 /**
  * truncate text
  *
  * @access public
  * @param string $text src
  * @param int $length maximum char width
  * @param string $etc appending text if $text truncated
  * @return string dist
  */
 function truncate($text, $length, $etc = '...')
 {
     // multi language extension support - strip ml tags
     if (defined('XOOPS_CUBE_LEGACY')) {
         // cubeutil module
         if (isset($GLOBALS['cubeUtilMlang'])) {
             $text = $GLOBALS['cubeUtilMlang']->obFilter($text);
         }
     } else {
         // sysutil module
         if (function_exists('sysutil_get_xoops_option')) {
             if (sysutil_get_xoops_option('sysutil', 'sysutil_use_ml')) {
                 if (function_exists('sysutil_ml_filter')) {
                     $text = sysutil_ml_filter($text);
                 }
             }
         }
     }
     $olen = strlen($text);
     // trim width
     if (XOOPS_USE_MULTIBYTES) {
         $text = mb_strimwidth($text, 0, $length, '', mb_detect_encoding($text));
     } else {
         $text = substr($text, 0, $length);
     }
     // remove broken html entity from trimed strig
     $text = preg_replace('/&#[^;]*$/s', '', $text);
     // append $etc char if text is trimed
     if ($olen != strlen($text)) {
         $text .= $etc;
     }
     return $text;
 }
<?php

include_once dirname(__FILE__) . '/common.inc.php';
if (sysutil_get_xoops_option('sysutil', 'sysutil_use_ml')) {
    include_once dirname(__FILE__) . '/sysutil_ml.inc.php';
} else {
    if (sysutil_get_xoops_option('sysutil', 'sysutil_default_lang')) {
        $xoopsConfig['language'] = sysutil_get_xoops_option('sysutil', 'sysutil_default_lang');
    } else {
        $xoopsConfig['language'] = SYSUTIL_ML_DEFAULT_LANGUNAME;
    }
}
if (file_exists(XOOPS_ROOT_PATH . "/language/" . $xoopsConfig['language'] . "/global.php")) {
    include_once XOOPS_ROOT_PATH . "/language/" . $xoopsConfig['language'] . "/global.php";
} else {
    include_once XOOPS_ROOT_PATH . "/language/english/global.php";
}
if (sysutil_get_xoops_option('sysutil', 'sysutil_use_autologin')) {
    sysutil_session_pre_start();
    include_once dirname(__FILE__) . '/sysutil_autologin.inc.php';
    sysutil_session_pre_close();
}