public function reAction($token) { $item = Website::find(array('conditions' => 'token = ?1', 'bind' => array(1 => $token), 'cache' => array('key' => $token, 'lifetime' => 7200 * 24)))->getFirst(); if ($item) { $item->vote += rand(1, 10); $item->save(); $this->response->redirect($item->href, true); } else { $this->response->redirect('/', true); } }
/** * [home 网站设置] * @return [type] [description] */ public function home() { if (IS_POST) { $data = ['web_title' => I('post.web_title'), 'web_keyword' => I('post.web_keyword'), 'web_desription' => I('post.web_desription'), 'web_footer' => I('post.web_footer')]; Website::where(['id' => 1])->update($data); View::success('更新成功'); die; } $webData = Website::find(1)->toArray(); //print_r($webData); $this->smarty->assign('webData', $webData); $this->smarty->assign('title', '网站设置_ISisWeb中文网后台管理_ISirPHPFramework'); $this->smarty->display('Admin/System/home.html'); die; // $this->view = View::make('/Admin/System/home') // ->with('webData',$webData) // ->with('title','网站设置_ISirWeb中文网'); }
/** * [artice 文章内容] * @return [type] [description] */ public function artice($slug) { $webSite = Website::find(1)->toArray(); $arcData = Article::with('belongsToCategory')->find($slug)->toArray(); //print_r($arcData); $hotArcData = Article::with('belongsToCategory')->where(['is_del' => 0])->get()->toArray(); $linkData = Link::where(['is_look' => 1])->get()->toArray(); //print_r($linkData); $cateData = Category::where(['is_del' => 0])->get()->toArray(); //print_r($cateData); $item = []; foreach ($cateData as $k => $v) { if (!isset($item[$v['id']])) { $item[$v['id']] = $v; } else { $item[$v['id']] = $v; } } //上一篇 $pre = Article::get_pre($slug); //print_r($pre); //下一篇 $next = Article::get_next($slug); //print_r($next); //相关文章 $this->smarty->assign('pre', $pre); $this->smarty->assign('next', $next); $this->smarty->assign('webSite', $webSite); $this->smarty->assign('hotArcData', $hotArcData); $this->smarty->assign('cateData', $item); $this->smarty->assign('slug', $slug); $this->smarty->assign('linkData', $linkData); $this->smarty->assign('article', $arcData); $this->smarty->display('Index/article.html'); }