public function testBind() { $request = Request::instance(); Route::bind('index/blog'); Route::get('index/blog/:id', 'index/blog/read'); $result = Route::check($request, '10'); $this->assertEquals(['index', 'blog', 'read'], $result['module']); Route::bind('\\app\\index\\controller', 'namespace'); $this->assertEquals(['type' => 'method', 'method' => ['\\app\\index\\controller\\blog', 'read']], Route::check($request, 'blog/read')); Route::bind('\\app\\index\\controller\\blog', 'class'); $this->assertEquals(['type' => 'method', 'method' => ['\\app\\index\\controller\\blog', 'read']], Route::check($request, 'read')); }
public function testRoot() { Config::set('url_domain_deploy', false); Config::set('url_common_param', false); Url::root('/index.php'); Route::get('blog/:id', 'index/blog/read'); Config::set('url_html_suffix', 'shtml'); $this->assertEquals('/index.php/blog/10/name/thinkphp.shtml', Url::build('index/blog/read?id=10&name=thinkphp')); }
<?php function a2($a, $b) { return $a + $b; } \think\Route::get('getsession/:time', function ($time) { //获取session ssid $arr = array(); $ssid = md5(mt_rand(1, 999999) . time() . mt_rand(1, 999999)); $arr['ssid'] = $ssid; $arr['session_die_time'] = time() + $time; S("ssid_" . $ssid, $arr, $time); return $arr; }); \think\Hook::add('action_begin', function () { //签名验证 return; $getArr = I('get.'); if (!$getArr) { return; } $sign = isset($getArr['sign']) ? $getArr['sign'] : system_error("not_fonud_sign"); unset($getArr['sign']); ksort($getArr); $signstr = ""; foreach ($getArr as $k => $v) { $signstr .= $k . "=" . urlencode($v) . "&"; } $signstr = rtrim($signstr, "&"); if (md5($signstr) != $sign) {
public function testBind() { Route::bind('module', 'index/blog'); $this->assertEquals(['type' => 'module', 'module' => ['index', 'blog', 'read']], Route::parseUrl('read/10')); Route::get('index/blog/:id', 'index/blog/read'); $this->assertEquals(['type' => 'module', 'module' => ['index', 'blog', 'read']], Route::check('10')); Route::bind('namespace', '\\app\\index\\controller'); $this->assertEquals(['type' => 'method', 'method' => ['\\app\\index\\controller\\blog', 'read'], 'params' => []], Route::check('blog/read')); Route::bind('class', '\\app\\index\\controller\\blog'); $this->assertEquals(['type' => 'method', 'method' => ['\\app\\index\\controller\\blog', 'read'], 'params' => []], Route::check('read')); }
public function testBuildAnchor() { Route::get('blog/:id', 'index/blog'); Config::set('url_html_suffix', 'shtml'); $this->assertEquals('/blog/10.shtml#detail', Url::build('/blog/10#detail')); }