Beruflich Dokumente
Kultur Dokumente
To change the entire look for the entire site, edit layouts/main.php, but be sure to use the echo
$content line where appropriate.
To change the default layout for every Controller, edit this line in components/Controller.php:
public $layout='//layouts/column1';
To change the default layout for every View in an individual Controller, add this line to that Controllers
definition:
// protected/controllers/SiteController.php
public function actionIndex() {
$this->layout = 'home';
And remember that column1.php and column2.php just hijack the page-specific content before it gets
passed on to the main.php layout file.
In addition, for any serious Web applications, we recommend using the following strategy to
enhance the security of cookie-based login.
When a user successfully logs in by filling out a login form, we generate and store a
random key in both the cookie state and in persistent storage on server side (e.g.
database).
Upon a subsequent request, when the user authentication is being done via the cookie
information, we compare the two copies of this random key and ensure a match before
logging in the user.
If the user logs in via the login form again, the key needs to be re-generated.
By using the above strategy, we eliminate the possibility that a user may re-use an old state
cookie which may contain outdated state information.
To implement the above strategy, we need to override the following two methods:
<div id="background">
<div class="register-form">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'register-form',
'action' => '/users/register',
'enableAjaxValidation' => true,
'enableClientValidation' => true,
'clientOptions' => array(
'validateOnChange' => true,
'validateOnSubmit' => true,
),
));
?>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model, 'username'); ?>
<?php echo $form->textField($model, 'username', array('size' => 20,
'maxlength' => 45, 'placeholder' => 'Vai ser seu link!')); ?>
<div class="clear"></div>
<?php echo $form->error($model, 'username'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'password'); ?>
<?php echo $form->passwordField($model, 'password', array('size' => 20,
'maxlength' => 45, 'placeholder' => 'Cuidado pra ningum saber')); ?>
<div class="clear"></div>
<?php echo $form->error($model, 'password'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'confirm_password'); ?>
<?php echo $form->passwordField($model, 'confirm_password', array('size' =>
20, 'maxlength' => 45, 'placeholder' => 'Igual a de cima')); ?>
<div class="clear"></div>
<?php echo $form->error($model, 'confirm_password'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'email'); ?>
<?php echo $form->textField($model, 'email', array('size' => 20, 'maxlength'
=> 45, 'placeholder' => 'something@somethingelse.com')); ?>
<div class="clear"></div>
<?php echo $form->error($model, 'email'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'first_name'); ?>
<?php echo $form->textField($model, 'first_name', array('size' => 20,
'maxlength' => 45, 'placeholder' => 'Qual seu nome?')); ?>
<div class="clear"></div>
<?php echo $form->error($model, 'first_name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'last_name'); ?>
<?php echo $form->textField($model, 'last_name', array('size' => 20,
'maxlength' => 45, 'placeholder' => 'E sobrenome?')); ?>
<div class="clear"></div>
<?php echo $form->error($model, 'last_name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'date_born'); ?>
<?php
$this->widget('CMaskedTextField', array(
'model' => $model,
'attribute' => 'date_born',
'mask' => '99/99/9999',
'htmlOptions' => array('size' => 20, 'placeholder' => 'dd/mm/aaaa')
));
?>
<div class="clear"></div>
<?php echo $form->error($model, 'date_born'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'sex'); ?>
<?php echo $form->dropDownList($model, 'sex', array('m' => 'Masculino', 'f' =>
'Feminino'), array('size' => 1, 'maxlength' => 1)); ?>
</div>
<div class="row-buttons">
<?php echo CHtml::submitButton('Registrar'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
</div>
<?php
class UsersController extends Controller {
/**
* @return array action filters
*/
public function filters() {
return array(
'accessControl', // perform access control for CRUD operations
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules() {
return array(
array('allow', // allow all users to perform 'create' action
'actions' => array('register'),
'users' => array('*'),
),
array('allow', // allow authenticated user to perform 'selfdelete' and
'update' actions
'actions' => array('selfdelete', 'update'),
Using theme
'theme'=>'wpcraft',
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
//tell the application to use your WebUser class instead of the default CWebUser
'class'=>'WebUser',
),