<commit_before><?php
/**
 *
 * PHP Versions 4
 *
 * @package  WizMobile
 * @author  gusagi<<EMAIL>>
 * @copyright  2007 - 2008 gusagi
 *
 */

if ( ! class_exists('WizMobile') ) {
    class WizMobile extends Wizin_StdClass
    {
        function WizMobile()
        {
            $this->_require();
            $this->_define();
            $this->_setup();
            $this->_mobileFilter();
        }

        function &getSingleton()
        {
            static $instance;
            if ( ! isset($instance) ) {
                $instance = new WizMobile();
            }
            return $instance;
        }

        function _require()
        {
            require_once XOOPS_TRUST_PATH . '/wizin/src/user/Wizin_User.class.php';
            require_once XOOPS_TRUST_PATH . '/wizin/src/session/Wizin_Session.class.php';
            require_once XOOPS_TRUST_PATH . '/wizin/src/filter/Wizin_Filter.class.php';
            $language = empty( $GLOBALS['xoopsConfig']['language'] ) ? 'english' : $GLOBALS['xoopsConfig']['language'];
            if( file_exists( dirname(dirname(__FILE__)) . '/language/' . $language . '/main.php' ) ) {
                require dirname(dirname(__FILE__)) . '/language/' . $language . '/main.php';
            }
        }

        function _define()
        {
            if ( ! empty($_REQUEST['mobilebid']) ) {
                $connecter = substr( WIZXC_CURRENT_URI, strpos(WIZXC_CURRENT_URI, 'mobilebid') - 1, 1 );
                if ( $connecter === '?' ) {
                    $deleteStr = 'mobilebid=' . $_REQUEST['mobilebid'] . '&';
                } else if ( $connecter === '&' ) {
                    $deleteStr = '&mobilebid=' . $_REQUEST['mobilebid'];
                }
                define( 'WIZMOBILE_CURRENT_URI', str_replace($deleteStr, '', WIZXC_CURRENT_URI) );
            } else {
                define( 'WIZMOBILE_CURRENT_URI', WIZXC_CURRENT_URI );
            }
        }

        function _setup()
        {
            $xcRoot =& XCube_Root::getSingleton();
            $user = & Wizin_User::getSingleton();
            $filter = & Wizin_Filter::getSingleton();
            @ $mobileConfig = $xcRoot->getSiteConfig( 'Mobile' );
            $lookup = false;
            $otherMobile = false;
            if ( ! empty($mobileConfig) ) {
                if ( ! empty($mobileConfig['lookup']) && $mobileConfig['lookup'] == true ) {
                    $lookup = true;
                }
                if ( ! empty($mobileConfig['othermobile']) && $mobileConfig['othermobile'] == true ) {
                    $otherMobile = true;
                }
            }
            $user->checkClient( $lookup );
            if ( $user->sCarrier === 'othermobile' ) {
                $user->bIsMobile = $otherMobile;
            }
        }

        function _mobileFilter()
        {
            $user = & Wizin_User::getSingleton();
            if ( $user->bIsMobile ) {
                Wizin_Session::overrideSessionIni( false );
                $this->_inputFilter();
                $this->_outputFilter();
                $this->_exchangeRenderSystem();
                register_shutdown_function( array($this, '_sendHeader') );
            }
            ini_set( 'default_charset', _CHARSET );
        }

        function _inputFilter()
        {
            $filter =& Wizin_Filter::getSingleton();
            $filter->filterInputEncoding();
        }

        function _outputFilter()
        {
            $user = & Wizin_User::getSingleton();
            $filter =& Wizin_Filter::getSingleton();
            $filter->filterOutputEncoding( $user->sEncoding, $user->sCharset );
        }

        function checkMobileSession()
        {
            $xcRoot =& XCube_Root::getSingleton();
            $userAgent = getenv( 'HTTP_USER_AGENT' );
            if ( empty($_SESSION['WIZ_USER_AGENT']) ) {
                $_SESSION['WIZ_USER_AGENT'] = $userAgent;
            } else if ( $_SESSION['WIZ_USER_AGENT'] !== $userAgent ) {
                WizXcUtil::sessionDestroy();
                $_SESSION["redirect_message"] = WIZMOBILE_MSG_SESSION_LIMIT_TIME;
                $_SESSION['WIZ_SESSION_ZERO_POINT'] = time();
                header("Location: " . XOOPS_URL. '/' . '?' . SID );
                exit();
            }
            if ( empty($_SESSION['WIZ_SESSION_ZERO_POINT']) ) {
                $_SESSION['WIZ_SESSION_ZERO_POINT'] = time();
            } else if ( $_SESSION['WIZ_SESSION_ZERO_POINT'] < time() - 300 ) {
                $encodeSession = session_encode();
                $_SESSION = array();
                session_regenerate_id();
                session_decode( $encodeSession );
                $_SESSION['WIZ_SESSION_ZERO_POINT'] = time();
            }
            if ( $_SESSION['WIZ_SESSION_LAST_ACCESS'] < time() - 900 && is_object($xcRoot->mContext->mXoopsUser) ) {
                WizXcUtil::sessionDestroy();
                session_regenerate_id();
                $_SESSION["redirect_message"] = WIZMOBILE_MSG_SESSION_LIMIT_TIME;
                $_SESSION['WIZ_SESSION_ZERO_POINT'] = time();
                $_SESSION['WIZ_SESSION_LAST_ACCESS'] = time();
                header("Location: " . XOOPS_URL. '/' . '?' . SID );
                exit();
            }
            $_SESSION['WIZ_SESSION_LAST_ACCESS'] = time();
        }

        function _exchangeRenderSystem()
        {
            $xcRoot =& XCube_Root::getSingleton();
            $xcRoot->mDelegateManager->add( 'LegacyThemeHandler.GetInstalledThemes',
                'LegacyWizMobileRender_DelegateFunctions::getInstalledThemes',
                XOOPS_TRUST_PATH . '/modules/wizmobile/class/DelegateFunctions.class.php' );
        }

        function exchangeTheme()
        {
            $xcRoot =& XCube_Root::getSingleton();
            @ $mobileConfig = $xcRoot->getSiteConfig( 'Mobile' );
            if ( ! empty($mobileConfig) ) {
                // theme
                if ( ! empty($mobileConfig['theme']) && $mobileConfig['theme'] !== 'mobile' ) {
                    $theme = $mobileConfig['theme'];<commit_msg>modify session lifetime check.<commit_after><?php
/**
 *
 * PHP Versions 4
 *
 * @package  WizMobile
 * @author  gusagi<<EMAIL>>
 * @copyright  2007 - 2008 gusagi
 *
 */

if ( ! class_exists('WizMobile') ) {
    class WizMobile extends Wizin_StdClass
    {
        function WizMobile()
        {
            $this->_require();
            $this->_define();
            $this->_setup();
            $this->_mobileFilter();
        }

        function &getSingleton()
        {
            static $instance;
            if ( ! isset($instance) ) {
                $instance = new WizMobile();
            }
            return $instance;
        }

        function _require()
        {
            require_once XOOPS_TRUST_PATH . '/wizin/src/user/Wizin_User.class.php';
            require_once XOOPS_TRUST_PATH . '/wizin/src/session/Wizin_Session.class.php';
            require_once XOOPS_TRUST_PATH . '/wizin/src/filter/Wizin_Filter.class.php';
            $language = empty( $GLOBALS['xoopsConfig']['language'] ) ? 'english' : $GLOBALS['xoopsConfig']['language'];
            if( file_exists( dirname(dirname(__FILE__)) . '/language/' . $language . '/main.php' ) ) {
                require dirname(dirname(__FILE__)) . '/language/' . $language . '/main.php';
            }
        }

        function _define()
        {
            if ( ! empty($_REQUEST['mobilebid']) ) {
                $connecter = substr( WIZXC_CURRENT_URI, strpos(WIZXC_CURRENT_URI, 'mobilebid') - 1, 1 );
                if ( $connecter === '?' ) {
                    $deleteStr = 'mobilebid=' . $_REQUEST['mobilebid'] . '&';
                } else if ( $connecter === '&' ) {
                    $deleteStr = '&mobilebid=' . $_REQUEST['mobilebid'];
                }
                define( 'WIZMOBILE_CURRENT_URI', str_replace($deleteStr, '', WIZXC_CURRENT_URI) );
            } else {
                define( 'WIZMOBILE_CURRENT_URI', WIZXC_CURRENT_URI );
            }
        }

        function _setup()
        {
            $xcRoot =& XCube_Root::getSingleton();
            $user = & Wizin_User::getSingleton();
            $filter = & Wizin_Filter::getSingleton();
            @ $mobileConfig = $xcRoot->getSiteConfig( 'Mobile' );
            $lookup = false;
            $otherMobile = false;
            if ( ! empty($mobileConfig) ) {
                if ( ! empty($mobileConfig['lookup']) && $mobileConfig['lookup'] == true ) {
                    $lookup = true;
                }
                if ( ! empty($mobileConfig['othermobile']) && $mobileConfig['othermobile'] == true ) {
                    $otherMobile = true;
                }
            }
            $user->checkClient( $lookup );
            if ( $user->sCarrier === 'othermobile' ) {
                $user->bIsMobile = $otherMobile;
            }
        }

        function _mobileFilter()
        {
            $user = & Wizin_User::getSingleton();
            if ( $user->bIsMobile ) {
                Wizin_Session::overrideSessionIni( false );
                $this->_inputFilter();
                $this->_outputFilter();
                $this->_exchangeRenderSystem();
                register_shutdown_function( array($this, '_sendHeader') );
            }
            ini_set( 'default_charset', _CHARSET );
        }

        function _inputFilter()
        {
            $filter =& Wizin_Filter::getSingleton();
            $filter->filterInputEncoding();
        }

        function _outputFilter()
        {
            $user = & Wizin_User::getSingleton();
            $filter =& Wizin_Filter::getSingleton();
            $filter->filterOutputEncoding( $user->sEncoding, $user->sCharset );
        }

        function checkMobileSession()
        {
            $xcRoot =& XCube_Root::getSingleton();
            $userAgent = getenv( 'HTTP_USER_AGENT' );
            if ( empty($_SESSION['WIZ_USER_AGENT']) ) {
                $_SESSION['WIZ_USER_AGENT'] = $userAgent;
            } else if ( $_SESSION['WIZ_USER_AGENT'] !== $userAgent ) {
                WizXcUtil::sessionDestroy();
                $_SESSION["redirect_message"] = WIZMOBILE_MSG_SESSION_LIMIT_TIME;
                $_SESSION['WIZ_SESSION_ZERO_POINT'] = time();
                header("Location: " . XOOPS_URL. '/' . '?' . SID );
                exit();
            }
            if ( empty($_SESSION['WIZ_SESSION_ZERO_POINT']) ) {
                $_SESSION['WIZ_SESSION_ZERO_POINT'] = time();
            } else if ( $_SESSION['WIZ_SESSION_ZERO_POINT'] < time() - 300 ) {
                $encodeSession = session_encode();
                $_SESSION = array();
                session_regenerate_id();
                session_decode( $encodeSession );
                $_SESSION['WIZ_SESSION_ZERO_POINT'] = time();
            }
            if ( ! empty($_SESSION['WIZ_SESSION_LAST_ACCESS']) &&
                $_SESSION['WIZ_SESSION_LAST_ACCESS'] < time() - 900 &&
                is_object($xcRoot->mContext->mXoopsUser) ) {
                WizXcUtil::sessionDestroy();
                session_regenerate_id();
                $_SESSION["redirect_message"] = WIZMOBILE_MSG_SESSION_LIMIT_TIME;
                $_SESSION['WIZ_SESSION_ZERO_POINT'] = time();
                $_SESSION['WIZ_SESSION_LAST_ACCESS'] = time();
                header("Location: " . XOOPS_URL. '/' . '?' . SID );
                exit();
            }
            $_SESSION['WIZ_SESSION_LAST_ACCESS'] = time();
        }

        function _exchangeRenderSystem()
        {
            $xcRoot =& XCube_Root::getSingleton();
            $xcRoot->mDelegateManager->add( 'LegacyThemeHandler.GetInstalledThemes',
                'LegacyWizMobileRender_DelegateFunctions::getInstalledThemes',
                XOOPS_TRUST_PATH . '/modules/wizmobile/class/DelegateFunctions.class.php' );
        }

        function exchangeTheme()
        {
            $xcRoot =& XCube_Root::getSingleton();
            @ $mobileConfig = $xcRoot->getSiteConfig( 'Mobile' );
            if ( ! empty($mobileConfig) ) {
                // theme
                if ( ! empty($mobileConfig['theme']) && $mobileConfig['theme'] !== 'mobile' ) {
                    $theme = $mobileConfig['theme'];
{'fraction_non_alphanumeric': 0.1397718011409943, 'fraction_numerical': 0.0027709861450692748, 'mean_word_length': 1.7353990191707536, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3523053', 'n_tokens_mistral': 3590, 'n_tokens_neox': 3425, 'n_words': 493}