diff --git a/Application/Common/Conf/config.php b/Application/Common/Conf/config.php index 554195e68..3ed65a968 100644 --- a/Application/Common/Conf/config.php +++ b/Application/Common/Conf/config.php @@ -21,6 +21,7 @@ ':id\d' => 'Home/Item/show?item_id=:1', ':domain\s$' => 'Home/Item/show?item_domain=:1',//item的个性域名 'uid/:id\d' => 'Home/Item/showByUid?uid=:1', + 'page/:id\d' => 'Home/Page/single?page_id=:1', ), 'URL_CASE_INSENSITIVE'=>true, 'SHOW_ERROR_MSG' => true, // 显示错误信息,这样在部署模式下也能显示错误 diff --git a/Application/Home/Controller/BaseController.class.php b/Application/Home/Controller/BaseController.class.php index f384d6bc8..9f0dd31a6 100644 --- a/Application/Home/Controller/BaseController.class.php +++ b/Application/Home/Controller/BaseController.class.php @@ -87,7 +87,7 @@ protected function checkItemCreator($uid , $item_id){ } //判断某用户是否有项目访问权限(公开项目的话所有人可访问,私有项目则项目成员、项目创建者和访问密码输入者可访问) - protected function checkItemVisit($uid , $item_id){ + protected function checkItemVisit($uid , $item_id, $refer_url= ''){ if (session("visit_item_".$item_id)) { return true; } @@ -106,7 +106,7 @@ protected function checkItemVisit($uid , $item_id){ $item = D("Item")->where("item_id = '%d' ",array($item_id))->find(); if ($item['password']) { //跳转到输入访问密码框 - header("location:".U("Home/item/pwd",array("item_id"=>$item_id))); + header("location:".U("Home/item/pwd",array("item_id"=>$item_id,"refer_url"=>base64_encode($refer_url)))); }else{ session("visit_item_".$item_id , 1 ); return true; diff --git a/Application/Home/Controller/CommonController.class.php b/Application/Home/Controller/CommonController.class.php new file mode 100644 index 000000000..3a03cf24e --- /dev/null +++ b/Application/Home/Controller/CommonController.class.php @@ -0,0 +1,16 @@ +png($url, false, 3 , $size, 2); + } + +} \ No newline at end of file diff --git a/Application/Home/Controller/ItemController.class.php b/Application/Home/Controller/ItemController.class.php index 500321451..e25abb8ab 100644 --- a/Application/Home/Controller/ItemController.class.php +++ b/Application/Home/Controller/ItemController.class.php @@ -222,7 +222,10 @@ public function ajaxDelete(){ public function pwd(){ $item_id = I("item_id/d"); $CloseVerify = C('CloseVerify'); + $refer_url = I('refer_url'); + //var_dump(urldecode($refer_url)); $this->assign('CloseVerify',$CloseVerify); + $this->assign('refer_url',$refer_url); if (!IS_POST) { $this->assign("item_id" , $item_id); $this->display (); @@ -234,7 +237,12 @@ public function pwd(){ $item = D("Item")->where("item_id = '$item_id' ")->find(); if ($item['password'] == $password) { session("visit_item_".$item_id , 1 ); - header("location:".U("Home/Item/show").'&item_id='.$item_id); + if ($refer_url) { + header("location:".base64_decode($refer_url)); + }else{ + header("location:".U("Home/Item/show").'&item_id='.$item_id); + } + }else{ $this->message(L('access_password_are_incorrect')); diff --git a/Application/Home/Controller/PageController.class.php b/Application/Home/Controller/PageController.class.php index 24d54a3f7..47833f79d 100644 --- a/Application/Home/Controller/PageController.class.php +++ b/Application/Home/Controller/PageController.class.php @@ -13,7 +13,31 @@ public function index(){ $this->message(L('no_permissions')); return; } - $Parsedown = new \Parsedown(); + + $ItemPermn = $this->checkItemPermn($login_user['uid'] , $page['item_id']) ; + $ItemCreator = $this->checkItemCreator($login_user['uid'],$page['item_id']); + + + //$Parsedown = new \Parsedown(); + //$page['page_content'] = $Parsedown->text(htmlspecialchars_decode($page['page_content'])); + $this->assign("page" , $page); + $this->display(); + } + + //展示单个页面 + public function single(){ + import("Vendor.Parsedown.Parsedown"); + $page_id = I("page_id/d"); + $page = D("Page")->where(" page_id = '$page_id' ")->find(); + $login_user = $this->checkLogin(false); + if (!$this->checkItemVisit($login_user['uid'] , $page['item_id'],$_SERVER['REQUEST_URI'])) { + $this->message(L('no_permissions')); + return; + } + + $ItemPermn = $this->checkItemPermn($login_user['uid'] , $page['item_id']) ; + $ItemCreator = $this->checkItemCreator($login_user['uid'],$page['item_id']); + $page['page_md_content'] = $page['page_content']; //$page['page_html_content'] = $Parsedown->text(htmlspecialchars_decode($page['page_content'])); $this->assign("page" , $page); diff --git a/Application/Home/View/Item/add.html b/Application/Home/View/Item/add.html index 0017cae22..2bd492f8c 100644 --- a/Application/Home/View/Item/add.html +++ b/Application/Home/View/Item/add.html @@ -25,7 +25,7 @@ if (password) { $("#password").val(''); $("#password").attr('type','password'); - $("#password").val('password'); + $("#password").val(password); }; diff --git a/Application/Home/View/Item/pwd.html b/Application/Home/View/Item/pwd.html index f1814000e..c57029f92 100644 --- a/Application/Home/View/Item/pwd.html +++ b/Application/Home/View/Item/pwd.html @@ -6,6 +6,7 @@

{$Think.Lang.input_visit_password}

+
diff --git a/Application/Home/View/Item/show.html b/Application/Home/View/Item/show.html index d5a43145a..ca1a83451 100644 --- a/Application/Home/View/Item/show.html +++ b/Application/Home/View/Item/show.html @@ -141,8 +141,12 @@

{$Think.Lang.share}

@@ -152,13 +156,21 @@

{$Think.Lang.share}

{$Think.Lang.share_page}

- + diff --git a/Application/Home/View/Page/single.html b/Application/Home/View/Page/single.html new file mode 100644 index 000000000..5c5a6cbb4 --- /dev/null +++ b/Application/Home/View/Page/single.html @@ -0,0 +1,140 @@ + + + + + + + +
+
+ +

{$page.page_title}

+
+
+ +
+ + +
+ +
+