yii学习笔记--url解析
2013-07-04 09:33
316 查看
在通过yiic命令生成了一个app之后,我们通过浏览器访问会看到这样的一个页面。
View Code
?php class SiteController extends Controller { /** * Declares class-based actions. */ public function actions() { return array( // captcha action renders the CAPTCHA image displayed on the contact page 'captcha'=>array( 'class'=>'CCaptchaAction', 'backColor'=>0xFFFFFF, ), // page action renders "static" pages stored under 'protected/views/site/pages' // They can be accessed via: index.php?r=site/page&view=FileName 'page'=>array( 'class'=>'CViewAction', ), ); } /** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { // renders the view file 'protected/views/site/index.php' // using the default layout 'protected/views/layouts/main.php' $this->render('index'); } /** * This is the action to handle external exceptions. */ public function actionError() { if($error=Yii::app()->errorHandler->error) { if(Yii::app()->request->isAjaxRequest) echo $error['message']; else $this->render('error', $error); } }/** * Displays the contact page */ public function actionContact() { $model=new ContactForm; if(isset($_POST['ContactForm'])) { $model->attributes=$_POST['ContactForm']; if($model->validate()) { $name='=?UTF-8?B?'.base64_encode($model->name).'?='; $subject='=?UTF-8?B?'.base64_encode($model->subject).'?='; $headers="From: $name <{$model->email}>\r\n". "Reply-To: {$model->email}\r\n". "MIME-Version: 1.0\r\n". "Content-type: text/plain; charset=UTF-8"; mail(Yii::app()->params['adminEmail'],$subject,$model->body,$headers); Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.'); $this->refresh(); } } $this->render('contact',array('model'=>$model)); }/** * Displays the login page */ public function actionLogin() { $model=new LoginForm; // if it is ajax validation request if(isset($_POST['ajax']) && $_POST['ajax']==='login-form') { echo CActiveForm::validate($model); Yii::app()->end(); } // collect user input data if(isset($_POST['LoginForm'])) { $model->attributes=$_POST['LoginForm']; // validate user input and redirect to the previous page if valid if($model->validate() && $model->login()) $this->redirect(Yii::app()->user->returnUrl); } // display the login form $this->render('login',array('model'=>$model)); } /** * Logs out the current user and redirect to homepage. */ public function actionLogout() { Yii::app()->user->logout(); $this->redirect(Yii::app()->homeUrl); } }
View Code
相关文章推荐
- <第三章>Node 学习笔记 |>URL网站解析<|
- 前端攻城狮学习笔记三:实现一个URI解析方法,把url里#之后的参数解析成指定的数据结构。
- Androidx学习笔记(34)---新闻客户端之获取新闻xml文件并解析
- Json.Net学习笔记(十二) 协议解析
- Android 学习 笔记_07. XML文件解析
- 安卓学习笔记---使用浏览器打开app指定协议(Url Scheme)
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q4-Q5)
- HTML学习笔记-a标签+URL+img(三)
- haproxy学习笔记2:1.3.0的配置文件解析
- 《Pro ASP.NET MVC 3 Framework》学习笔记之二十一【Area及URL架构的最佳实践】
- Sharepoint学习笔记—习题系列--70-573习题解析 -(Q22-Q24)
- 七、GO语言库学习--net/url包--go语言笔记
- YII学习笔记-登录后的session的总结
- date命令解析_学习笔记
- JMeter学习笔记--使用URL回写来处理用户会话
- 第114讲:Hadoop集群安装解析学习笔记
- yii学习笔记
- [原创]java WEB学习笔记77:Hibernate学习之路---Hibernate 版本 helloword 与 解析,.环境搭建,hibernate.cfg.xml文件及参数说明,持久化类,对象-关系映射文件.hbm.xml,Hibernate API (Configuration 类,SessionFactory 接口,Session 接口,Transaction(事务))
- JSTL学习笔记3-----URL相关标签的使用
- python cookbook第三版学习笔记八:解析码流