⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 namespace.php

📁 Piwik#Opensourcewebanalytics一款可以和GOOGLE媲美的开源统计系统,运用AJAX.功能强大.无色提示:按照需要PHP5.1以上和MySQL数据库支持。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
     */    protected function & __get($name)    {        if ($name === '') {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception("The '$name' key must be a non-empty string");        }        return parent::_namespaceGet($this->_namespace, $name);    }    /**     * __set() - method to set a variable/value in this object's namespace     *     * @param string $name - programmatic name of a key, in a <key,value> pair in the current namespace     * @param mixed $value - value in the <key,value> pair to assign to the $name key     * @throws Zend_Session_Exception     * @return true     */    protected function __set($name, $value)    {        if (isset(self::$_namespaceLocks[$this->_namespace])) {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception('This session/namespace has been marked as read-only.');        }        if ($name === '') {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception("The '$name' key must be a non-empty string");        }        if (parent::$_writable === false) {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG);        }        $name = (string) $name;        $_SESSION[$this->_namespace][$name] = $value;    }    /**     * apply() - enables applying user-selected function, such as array_merge() to the namespace     * Caveat: ignores members expiring now.     *     * Example:     *   $namespace->apply('array_merge', array('tree' => 'apple', 'fruit' => 'peach'), array('flower' => 'rose'));     *   $namespace->apply('count');     *     * @param string $callback - callback function     * @param mixed  OPTIONAL arguments passed to the callback function     */    public function apply($callback)    {        $arg_list = func_get_args();        $arg_list[0] = $_SESSION[$this->_namespace];        return call_user_func_array($callback, $arg_list);    }    /**     * applySet() - enables applying user-selected function, and sets entire namespace to the result     * Result of $callback must be an array. Caveat: ignores members expiring now.     *     * Example:     *   $namespace->applySet('array_merge', array('tree' => 'apple', 'fruit' => 'peach'), array('flower' => 'rose'));     *     * @param string $callback - callback function     * @param mixed  OPTIONAL arguments passed to the callback function     */    public function applySet($callback)    {        $arg_list = func_get_args();        $arg_list[0] = $_SESSION[$this->_namespace];        $result = call_user_func_array($callback, $arg_list);        if (!is_array($result)) {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception("Result must be an array. Got: " . gettype($result));        }        $_SESSION[$this->_namespace] = $result;        return $result;    }    /**     * __isset() - determine if a variable in this object's namespace is set     *     * @param string $name - programmatic name of a key, in a <key,value> pair in the current namespace     * @return bool     */    protected function __isset($name)    {        if ($name === '') {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception("The '$name' key must be a non-empty string");        }        return parent::_namespaceIsset($this->_namespace, $name);    }    /**     * __unset() - unset a variable in this object's namespace.     *     * @param string $name - programmatic name of a key, in a <key,value> pair in the current namespace     * @return true     */    protected function __unset($name)    {        if ($name === '') {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception("The '$name' key must be a non-empty string");        }        return parent::_namespaceUnset($this->_namespace, $name);    }    /**     * setExpirationSeconds() - expire the namespace, or specific variables after a specified     * number of seconds     *     * @param int $seconds     - expires in this many seconds     * @param mixed $variables - OPTIONAL list of variables to expire (defaults to all)     * @throws Zend_Session_Exception     * @return void     */    public function setExpirationSeconds($seconds, $variables = null)    {        if (parent::$_writable === false) {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG);        }        if ($seconds <= 0) {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception('Seconds must be positive.');        }        if ($variables === null) {            // apply expiration to entire namespace            $_SESSION['__ZF'][$this->_namespace]['ENT'] = time() + $seconds;        } else {            if (is_string($variables)) {                $variables = array($variables);            }            foreach ($variables as $variable) {                if (!empty($variable)) {                    $_SESSION['__ZF'][$this->_namespace]['ENVT'][$variable] = time() + $seconds;                }            }        }    }    /**     * setExpirationHops() - expire the namespace, or specific variables after a specified     * number of page hops     *     * @param int $hops        - how many "hops" (number of subsequent requests) before expiring     * @param mixed $variables - OPTIONAL list of variables to expire (defaults to all)     * @param boolean $hopCountOnUsageOnly - OPTIONAL if set, only count a hop/request if this namespace is used     * @throws Zend_Session_Exception     * @return void     */    public function setExpirationHops($hops, $variables = null, $hopCountOnUsageOnly = false)    {        if (parent::$_writable === false) {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG);        }        if ($hops <= 0) {            /**             * @see Zend_Session_Exception             */            require_once 'Zend/Session/Exception.php';            throw new Zend_Session_Exception('Hops must be positive number.');        }        if ($variables === null) {            // apply expiration to entire namespace            if ($hopCountOnUsageOnly === false) {                $_SESSION['__ZF'][$this->_namespace]['ENGH'] = $hops;            } else {                $_SESSION['__ZF'][$this->_namespace]['ENNH'] = $hops;            }        } else {            if (is_string($variables)) {                $variables = array($variables);            }            foreach ($variables as $variable) {                if (!empty($variable)) {                    if ($hopCountOnUsageOnly === false) {                        $_SESSION['__ZF'][$this->_namespace]['ENVGH'][$variable] = $hops;                    } else {                        $_SESSION['__ZF'][$this->_namespace]['ENVNH'][$variable] = $hops;                    }                }            }        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -