本文整理汇总了PHP中valid::date方法的典型用法代码示例。如果您正苦于以下问题:PHP valid::date方法的具体用法?PHP valid::date怎么用?PHP valid::date使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类valid
的用法示例。
在下文中一共展示了valid::date方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: day
/**
* Day view
*
* @param int $year
* @param int $month
* @param int $day
*/
public function day($year, $month, $day)
{
$this->tab_id = 'browse';
if (valid::date($year . '-' . $month . '-' . $day)) {
$this->type = 'day';
$this->date->setDate($year, $month, $day);
$this->page_title = text::title($this->date->format('j.n.Y'));
$this->_build_calendar();
}
}
示例2: date
/**
* Tests the valid::date() function.
* @dataProvider date_provider
* @group core.helpers.valid.date
* @test
*/
public function date($input_date, $expected_result)
{
$result = valid::date($input_date);
$this->assertEquals($expected_result, $result);
}
示例3: login
/**
* Attempt to log in a user by using an ORM object and plain-text password.
*
* @param string username to log in
* @param string password to check against
* @param boolean enable auto-login
* @return boolean
*/
public function login($user, $password, $remember = FALSE)
{
//get password field name from config
$password_field = $this->config['password'];
//$user and $password must set, ane they must be string type
if (empty($password) or !is_string($password) or !is_string($user)) {
return FALSE;
}
$user = new Auth_Users_Model(array('username' => $user, 'password' => $password));
//if there is no such user in database, quit
if (!$user->check_id()) {
return FALSE;
}
if (is_string($password)) {
// Create a hashed password using the secrets from config
$password = $this->hash($password);
}
// If user is active and the passwords match, perform a login
if (intval($user->active) === 1 and $user->{$password_field} == $password) {
//check if user has not expired
if (valid::date($user->active_to)) {
$now = date('Y-m-d H:i:s');
if ($user->active_to < $now) {
return FALSE;
}
}
if ($remember === TRUE) {
// Create a new autologin token
$token_model = new Auth_User_Tokens_Model();
// delete old user tokens
$token_model->delete_user_tokens($user->id);
// Set token data
$token_model->user_id = $user->id;
$token_model->expires = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s') + $this->config['lifetime'], date('m'), date('d'), date('Y')));
//save token
$token_model->save();
// Set the autologin cookie
cookie::set($this->config['cookie_key'], $token_model->token, $this->config['lifetime']);
}
// Finish the login
$this->complete_login($user);
return TRUE;
}
// Login failed
return FALSE;
}