本文整理汇总了PHP中Admin::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::model方法的具体用法?PHP Admin::model怎么用?PHP Admin::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Admin
的用法示例。
在下文中一共展示了Admin::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionLogin
public function actionLogin()
{
$this->layout = "login_layout";
$request = Yii::app()->request;
if ($request->isPostRequest && isset($_POST)) {
try {
$admin_name = Yii::app()->request->getPost('admin_name');
$admin_password = Yii::app()->request->getPost('admin_password');
$user = Admin::model()->findByAttributes(array('admin_name' => $admin_name));
if ($user) {
//user existed, check password
if ($user->admin_password == md5($admin_password)) {
Yii::app()->session['admin_id'] = $user->admin_id;
$this->redirect($this->md('home/user'));
} else {
//wrong device token
// echo "đm lỗi2";
// die();
$this->redirect('login');
}
// }
} else {
//user not existed
// echo "đm lỗi3";
// die();
$this->redirect('login');
}
} catch (exception $e) {
echo $e->getMessage();
}
}
$this->render('login/index');
}
示例2: run
public function run($args)
{
$user_info = Admin::model()->findAll();
$count = Advice::model()->count('status=0');
foreach ($user_info as $row) {
if ($row->send_email == 0 || empty($row->email)) {
continue;
}
$message = "您今天新增" . $count . "条后勤办反馈建议\n\t \t\t'http://localhost/logistics/index.php?r=admin/index/index' 点击链接登录后台进行查看";
$mailer = Yii::createComponent('application.extensions.mailer.EMailer');
$mailer->Host = 'smtp.qq.com';
$mailer->IsSMTP();
$mailer->SMTPAuth = true;
$mailer->From = '472406004@qq.com';
$mailer->AddReplyTo("{$row->email}");
$mailer->AddAddress("{$row->email}");
$mailer->FromName = '你大爷';
$mailer->Username = '472406004';
//这里输入发件地址的用户名
$mailer->Password = '199401045216hyf';
//这里输入发件地址的密码
$mailer->SMTPDebug = true;
//设置SMTPDebug为true,就可以打开Debug功能,根据提示去修改配置
$mailer->CharSet = 'UTF-8';
$mailer->Subject = Yii::t('demo', 'Yii rulez!');
$mailer->Body = $message;
$x = $mailer->Send();
$x = $mailer->Send();
}
}
示例3: authenticate
/**
* Authenticates user dengan menggunakan user model (Admin.php)
*/
public function authenticate()
{
/* find data dengan atribut username
* menggunakan model Admin */
$user = Admin::model()->findByAttributes(array('username' => $this->username));
/* jika user hasilnya null maka
* kasih error invalid username */
if ($user === null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
/* jika tidak null */
} else {
/* cek jika password yang ada didalam database
* tidak sama dengan password yang dienkrip maka
* kasih error password invalid */
if ($user->password !== $user->encrypt($this->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
/* jika sama password_database==password_enkrip */
} else {
/* jika password yang dienkrip sama dengan
* yang ada di dalam database maka */
/* ambil data user id dan
* ditampung oleh variable _id */
$this->_id = $user->admin_id;
/* set state username agar dapat ditampilkan
* sebagai data user yang login
*/
$this->setState('username', $user->username);
$this->setState('adminLogin', TRUE);
/* kasih error none pada variable errorCode */
$this->errorCode = self::ERROR_NONE;
}
}
/* kembalikan bukan error code */
return !$this->errorCode;
}
示例4: actionAddBlog
public function actionAddBlog()
{
$model = new Post();
$rec = Lookup::model()->findAll(array('condition' => 'type=:t', 'params' => array(':t' => 'PostStatus')));
$admin = Admin::model()->find();
$adminId = $admin->id;
foreach ($rec as $type) {
$id[] = $type->id;
$name[] = $type->name;
$op = array_combine($id, $name);
}
if (isset($_POST['Post'])) {
$model->attributes = $_POST['Post'];
if ($model->validate()) {
$model->author_id = $adminId;
if ($model->save()) {
$this->redirect(array('postlisting', 'id' => $model->id));
}
} else {
$errors = $model->getErrors();
//var_dump($errors);
}
}
$this->render('addblog', array('model' => $model, 'type' => $op));
}
示例5: it_allows_manually_create_model_configuration
/** @test */
public function it_allows_manually_create_model_configuration()
{
$model = new ModelConfiguration('My\\Model');
Admin::instance()->setModel('My\\Model', $model);
$model = Admin::model('My\\Model');
$this->assertInstanceOf('SleepingOwl\\Admin\\Model\\ModelConfiguration', $model);
}
示例6: authenticate
public function authenticate()
{
/*
$users=array(
// username => password
'demo'=>'demo',
'admin'=>'admin',
);
if(!isset($users[$this->username]))
$this->errorCode=self::ERROR_USERNAME_INVALID;
elseif($users[$this->username]!==$this->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
$this->errorCode=self::ERROR_NONE;
return !$this->errorCode;
*/
$username = strtolower($this->username);
$user = Admin::model()->find('LOWER(username)=?', array($username));
if ($user === null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} else {
if ($user->PASSWORD != $this->password) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
// successful login
$this->_id = $user->ID_ADMIN;
$this->username = $user->USERNAME;
//$this->setState('level', $user->level);
//untuk memanggil level di database menggunakan EWebUser.php nanti
$this->errorCode = self::ERROR_NONE;
}
}
return $this->errorCode == self::ERROR_NONE;
}
示例7: login
/**
* admin login, dengan meng-input email dan password
*/
public function login()
{
/*jika _indentity null maka*/
if ($this->_identity === null) {
/*panggil component CustomerLogin dengan param
*email, dan password
*dan ditampung oleh variabel _identity
*/
$this->_identity = new CustomerLogin($this->customer_email, $this->customer_password);
/*panggil fungsi authenticate()
*yang ada di component CustomerLogin
*yang akan memvalidasi email dan password*/
$this->_identity->authenticate();
}
/*jika errorCode/error email dan password benar maka*/
if ($this->_identity->errorCode === CustomerLogin::ERROR_NONE) {
//membuat remember me durasi 30 hari
$duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
// 30 days
Yii::app()->user->login($this->_identity, $duration);
//update last_login_time admin
Admin::model()->updateByPk($this->_identity->id, array('last_login_time' => new CDbExpression('NOW()')));
return true;
} else {
return false;
}
}
示例8: actionLogin
public function actionLogin()
{
ob_start();
Yii::app()->theme = 'back';
$model = new LoginForm();
//echo "Mohit";die;
// 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'];
$uName = $_POST['LoginForm']['username'];
$uPass = $_POST['LoginForm']['password'];
$pass = md5($uPass);
$admin = Admin::model()->findByAttributes(array('username' => $uName, 'password' => $pass));
$count = count($admin);
//echo $count;die;
// validate user input and redirect to the previous page if valid
if ($model->validate() && $model->login()) {
//$this->redirect(Yii::app()->user->returnUrl);
Yii::app()->session['username'] = $uName;
}
if ($count > 0) {
//Yii::app()->session['username']=$uName;
$this->redirect('dashboard', array('model' => $model));
} else {
$this->render('index', array('model' => $model));
}
}
// display the login form
//$this->render('index',array('model'=>$model));
}
示例9: actionIndex
/**
* 首页
*/
public function actionIndex()
{
Tool::p('xx');
$result = Admin::model()->findByPk(1);
Tool::p($result);
$this->render('login');
}
示例10: loadModel
private function loadModel($id)
{
$model=Admin::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
示例11: authenticate
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
$admins = Admin::model()->find('name=:name',array(':name'=>$this->username));
if($admins == NULL){
$this->errorCode=self::ERROR_USERNAME_INVALID;
return false;
}
if($admins->password !== md5($this->password)){
$this->errorCode=self::ERROR_PASSWORD_INVALID;
return false;
}
$this->errorCode=self::ERROR_NONE;
// $_SESSION['adminInfo']=array(
// 'id'=>$admins->id,
// 'rid'=>$admins->rid,
// 'name'=>$admins->name,
// 'purview'=>explode(';',$admins->purview)
// );
return true;
/* if(!isset($users[$this->username]))
$this->errorCode=self::ERROR_USERNAME_INVALID;
elseif($users[$this->username]!==$this->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
$this->errorCode=self::ERROR_NONE;
return !$this->errorCode; */
}
示例12: actionUpdateNotebook
/**
* 更新备忘
*
*/
public function actionUpdateNotebook()
{
$notebook = $this->_gets->getParam('notebook');
$model = Admin::model()->findByPk($this->_admini['userId']);
$model->notebook = trim($notebook);
if ($model->save()) {
exit('更新完成');
} else {
exit('更新失败');
}
}
示例13: authenticate
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
$user_info = Admin::model()->find('username = :username', array(':username' => $this->username));
if (!isset($user_info->password)) {
return $this->errorCode = self::ERROR_USERNAME_INVALID;
}
if ($user_info->password != $this->password) {
return $this->errorCode = self::ERROR_PASSWORD_INVALID;
}
return !($this->errorCode = self::ERROR_NONE);
}
示例14: authenticate
public function authenticate()
{
$user = Admin::model()->find("LOWER(username)=? and password=? and status=1", array(strtolower($this->username), md5($this->password)));
if ($user === null) {
return false;
} else {
$this->_id = $user->id;
$this->setState('userInfo', $user);
$this->errorCode = UserIdentity::ERROR_NONE;
return true;
}
}
示例15: authenticate
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
$users = Admin::model()->findByAttributes(array('name' => $this->username));
if ($users == null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} elseif ($users->password != md5($this->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
Yii::app()->user->name = $users->name;
$this->errorCode = self::ERROR_NONE;
}
return !$this->errorCode;
}