/** * 运行mvc */ static function mvcRun() { /* mvc入口 */ $config = ConfigFactory::get('controller'); foreach (array('module' => 'm', 'controller' => 'c', 'action' => 'a') as $k => $v) { ${$k} = trim($_GET[$v]); if (empty(${$k})) { ${$k} = $config['default' . ucfirst($k)]; } } $classController = ucfirst($controller) . 'Controller'; $path = "{$module}/controllers/{$classController}"; if (preg_match("/^([a-z\\d\\_\\-]+\\/){2}[a-z\\d\\_\\-]+\$/i", $path) && file_exists(WEB_SYSTEM . "/modules/{$path}.php")) { require WEB_SYSTEM . "/modules/{$path}.php"; $instance = new $classController(); $instance->module = $module; $instance->controller = $controller; $instance->action = $action; $methodAction = 'action' . $action; if (method_exists($instance, $methodAction)) { call_user_func(array($instance, 'beforeAction')); call_user_func(array($instance, $methodAction)); call_user_func(array($instance, 'afterAction')); return true; } } die('Invalid params (path:' . htmlspecialchars($path) . ')'); return false; }
/** * 获取redis client实例 * @param string $key * @return IRedis */ static function open($key = 'default') { $instance =& self::$INSTANCES[$key]; if (isset($instance) == false) { $config = ConfigFactory::get('redis', $key); if (empty($config)) { die("Undefined Redis Config \"{$key}\""); } $instance = new RedisClient(); $instance->setServers($config['servers']); } return $instance; }
/** * 获取单例的数据库实例 * @param string $key * @return IDatabase */ static function open($key = 'default') { $instance =& self::$INSTANCES[$key]; if (isset($instance) == false) { $config = ConfigFactory::get('db', $key); if (empty($config)) { die("Undefined Database Config \"{$key}\""); } $className = 'Database' . ucfirst($config['type']); $instance = new $className(); $instance->connect($config['host'], $config['port'], $config['database'], $config['user'], $config['password'], $config['charset']); } return $instance; }
private static function reversible($string, $operation = 'DECODE', $key = '', $expiry = 0) { $ckey_length = 4; $key = md5($key ? $key : ConfigFactory::get('encode', 'defaultReversibleKey')); $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; $string_length = strlen($string); $result = ''; $box = range(0, 255); $rndkey = array(); for ($i = 0; $i <= 255; $i++) { $rndkey[$i] = ord($cryptkey[$i % $key_length]); } for ($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $rndkey[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; } for ($a = $j = $i = 0; $i < $string_length; $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $tmp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $tmp; $result .= chr(ord($string[$i]) ^ $box[($box[$a] + $box[$j]) % 256]); } if ($operation == 'DECODE') { if ((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26) . $keyb), 0, 16)) { return substr($result, 26); } else { return; } } else { return $keyc . str_replace('=', '', base64_encode($result)); } }
<meta name="keywords" content=""> <meta name="description" content=""> <script> var assetsVersion = '<?php echo ConfigFactory::get('controller', 'assetsVersion'); ?> '; var campaignId = <?php echo $campaignId; ?> ; </script> <script src="http://www.sinaimg.cn/gm/hd/hpct/2014/1118/sssy/jquery.min.1.10.1.js"></script> <script src="http://www.sinaimg.cn/gm/hd/hpct/2014/1119/ssgw/index.js?abc"></script> <script src="/assets/js/controller/campaign.js?<?php echo ConfigFactory::get('controller', 'assetsVersion'); ?> "></script> <link rel="stylesheet" href="http://wanwan.sina.com.cn/9/2014/1118/244.css?abc" > <!--[if IE 6]> <script type="text/javascript" src="http://www.sinaimg.cn/gm/webgame/dh/DD_belatedPNG_0.0.8a-min.js"></script> <script type="text/javascript"> DD_belatedPNG.fix('.header span,.start,.wd-down,.nav,.gamelogo a,.header div,.header div a,.number span,.newsimg i,.zclbbox,.zclbbox-b,.llb-box-tt .close') </script> <![endif]--> </head> <body> <div class="windowblack" onclick="closeAll();"></div> <!-- 站外注册 begin --> <div id="outside" class="llb-box"> <div class="llb-box-tt"><a class="close" href="javascript:closeAll();" title="关闭">关闭</a></div>