コード例 #1
0
ファイル: class_ext.php プロジェクト: huming17/dzmvc
<?php

ext::creatapp();
class ext
{
    private static $_app;
    public static $user_realname = array();
    public static $role_name = array();
    public static $d_name = array();
    public static $school_name = array();
    public static function app()
    {
        return self::$_app;
    }
    public static function creatapp()
    {
        if (!is_object(self::$_app)) {
            self::$_app = site_init::instance();
        }
        return self::$_app;
    }
    public static function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0)
    {
        $ckey_length = 4;
        $key = md5($key != '' ? $key : self::getglobal('authkey'));
        $keya = md5(substr($key, 0, 16));
        $keyb = md5(substr($key, 16, 16));
        $keyc = $ckey_length ? $operation == 'DECODE' ? substr($string, 0, $ckey_length) : substr(md5(microtime()), -$ckey_length) : '';
        $cryptkey = $keya . md5($keya . $keyc);
        $key_length = strlen($cryptkey);
        $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0) . substr(md5($string . $keyb), 0, 16) . $string;