本文整理汇总了PHP中Time::now方法的典型用法代码示例。如果您正苦于以下问题:PHP Time::now方法的具体用法?PHP Time::now怎么用?PHP Time::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time::now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: p_signup
public function p_signup()
{
# What data was submitted
//print_r($_POST);
# Encrypt password
$_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']);
$_POST['password2'] = sha1(PASSWORD_SALT . $_POST['password2']);
if ($_POST['password'] != $_POST['password2']) {
Router::redirect('/users/login/new/?error=oh+dip!+password+mismatch,+please+try+again.');
}
# delete confirmation password from post for nice easy insert into db
unset($_POST['password2']);
# Create and encrypt token
$_POST['token'] = sha1(TOKEN_SALT . $_POST['username'] . Utils::generate_random_string());
# Store current timestamp
$_POST['created'] = Time::now();
# This returns the current timestamp
$_POST['modified'] = Time::now();
# Insert
DB::instance(DB_NAME)->insert('users', $_POST);
# set token / cookie so user doesn't have to log in again
$token = $_POST['token'];
setcookie("token", $token, strtotime('+2 weeks'), '/');
Router::redirect('/');
}
示例2: del
/**
* Удаление куков
*
* @param string $name
* @param string $path
* @param string $domain
* @param boolean $secure
* @param boolean $httponly
* @return string|null
*/
public static function del($name, $path = '/', $domain = null, $secure = false, $httponly = false)
{
if (isset($_COOKIE[$name])) {
unset($_COOKIE[$name]);
}
return setcookie($name, null, Time::now() - Time::day(1), $path, $domain, $secure, $httponly);
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Feedback();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$panel_ident = $_REQUEST['panel_ident'];
if (isset($_POST['Feedback'])) {
$model->attributes = $_POST['Feedback'];
$model->q_time = Time::now();
if ($model->save()) {
$model->addTags('tag1, tag2, tag3')->save();
if (isset($_GET['ajax'])) {
$str = Yii::t('cp', 'Create Success On ') . Time::now();
Yii::app()->user->setFlash('success', $str);
$this->renderPartial('create_next', array('model' => $model, 'panel_ident' => $panel_ident), false, true);
exit;
} else {
$this->redirect(array('view', 'id' => $model->id));
}
}
}
if (isset($_GET['ajax'])) {
$this->renderPartial('create', array('model' => $model, 'panel_ident' => $panel_ident), false, true);
} else {
$this->render('create', array('model' => $model));
}
}
示例4: p_signup
public function p_signup()
{
# Check if data was entered
if ($_POST['first_name'] == "" || $_POST['last_name'] == "" || $_POST['password'] == "") {
# Send back to signup with appropriate error
Router::redirect("/users/signup/Please enter all requested information");
}
# Check if email address is of the right form
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
# Send back to signup with appropriate error
Router::redirect("/users/signup/Please enter a valid email address");
}
# Check if passwords match
if ($_POST['password'] != $_POST['password_check']) {
# Send back to signup with appropriate error
Router::redirect("/users/signup/Passwords do not match");
}
# Remove the password check from the array
unset($_POST['password_check']);
# Encrypt the password
$_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']);
# More data we want stored with the user
$_POST['created'] = Time::now();
$_POST['modified'] = Time::now();
$_POST['token'] = sha1(TOKEN_SALT . $_POST['email'] . Utils::generate_random_string());
# Insert this user into the database
$user_id = DB::instance(DB_NAME)->insert("users", $_POST);
# Send the user to the signup success page
$this->template->content = View::instance('v_users_signup_success');
$this->template->title = "Success!";
echo $this->template;
}
示例5: p_signup
public function p_signup()
{
# Dump out the results of POST to see what the form submitted
# print_r($_POST);
# Encrypt the password
$_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']);
# More data we want stored with the user
$_POST['created'] = Time::now();
$_POST['modified'] = Time::now();
$_POST['token'] = sha1(TOKEN_SALT . $_POST['email'] . Utils::generate_random_string());
# Variables to store the first name & email of the user
$firstname = $_POST['first_name'];
$email = $_POST['email'];
# Variable which will store the email which is fetched from database
$email_verify = DB::instance(DB_NAME)->select_row("SELECT email FROM users WHERE email = '" . $_POST['email'] . "'");
# print_r($email_verify);
if ($email_verify == "") {
# Insert this user into the database
$user_id = DB::instance(DB_NAME)->insert("users", $_POST);
# Confirmation to the user on successfully signing up
echo "Congratulations {$firstname} !! You have successfully signed up</br></br>";
# Login again in order to follow users
echo "You need to login again in order to follow users </br>";
echo "<a href='/users/login'> Login </a>";
} else {
#To Display to the user that the email records exist in database.
echo " {$firstname}, Your email '{$email}' matches with our records in database.</br>\n \tYou will be redirected to the signup page in 10 seconds. </br></br>";
echo "<a href='/users/signup'> Signup </a> </br></br>";
echo "<a href='/users/login'> Login </a>";
#Refresh the page and redirect to signup page after 10 secs.
header('Refresh: 10; URL=/users/signup');
ob_end_flush();
}
}
示例6: p_ticket
public function p_ticket()
{
# Sanitize the user input
$_POST = DB::instance(DB_NAME)->sanitize($_POST);
# Backup validation in case of javascript failure
# Not recommended as the page looks terrible without js
# Check if data was entered
if ($_POST['name'] == "" || $_POST['phone'] == "" || $_POST['serial'] == "") {
# Send back to signup with appropriate error
Router::redirect("/tickets");
}
# Check if email address is of the right form
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
# Send back to signup with appropriate error
Router::redirect("/tickets");
}
# Unix timestamp of when this post was created / modified
$_POST['ticket_id'] = date('Ymd\\-his');
$_POST['created'] = Time::now();
$_POST['modified'] = Time::now();
# Add the location
$_POST['location'] = 'Helpdesk';
# Create ticket and computer arrays
$ticket = $_POST;
$computer = $_POST;
# Add ticket status
$ticket['status'] = 'New';
# Remove the unneeded data before submit
unset($ticket['model'], $ticket['serial']);
unset($computer['email'], $computer['phone'], $computer['notes']);
# Insert
DB::instance(DB_NAME)->insert('tickets', $ticket);
DB::instance(DB_NAME)->insert('computers', $computer);
# Build a multi-dimension array of recipients of this email
$to[] = array("name" => $_POST["name"], "email" => $_POST["email"]);
# Build a single-dimension array of who this email is coming from
# note it's using the constants we set in the configuration above)
$from = array("name" => "HSPH Helpdesk", "email" => APP_EMAIL);
# Subject
$subject = "Helpdesk Computer Drop Off: " . $_POST["subject"];
# Generate Time
# You can set the body as just a string of text
$body = "This is confirmation that you have delivered your " . $_POST['model'] . " with the serial number " . $_POST['serial'] . " to the helpdesk at " . date('g\\:i a \\o\\n F d\\, Y') . " with the following notes: <br>" . $_POST['notes'] . "<br><br>Thank you and have a great day!" . "<br>The Helpdesk<br>(617) 432-4357<br>helpdesk@hsph.harvard.edu";
# OR, if your email is complex and involves HTML/CSS, you can build the body via a View just like we do in our controllers
# $body = View::instance('e_users_welcome');
# Why not send an email to the test account as well
# Build multi-dimension arrays of name / email pairs for cc / bcc if you want to
$cc = "";
$bcc = "nathanielvarney.com@gmail.com";
# With everything set, send the email
if (!($email = Email::send($to, $from, $subject, $body, true, $cc, $bcc))) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
# Load the success page
$this->template->content = View::instance('v_tickets_p_ticket_success');
$this->template->title = "Success!";
echo $this->template;
}
}
示例7: test_between_array
public function test_between_array()
{
Time::set(strtotime('2011-11-01 15:00:00'));
$this->assertEquals('2011-11-01 15:00:00', Time::now());
$this->assertTrue(Time::between(array('2011-11-01 15:00:00', '2011-11-01 16:00:00')));
$this->assertTrue(Time::between(array('2011-11-01 14:00:00', '2011-11-01 15:00:00')));
$this->assertFalse(Time::between(array('2011-11-01 14:00:00', '2011-11-01 14:59:59')));
$this->assertFalse(Time::between(array('2011-11-01 15:00:01', '2011-11-01 16:00:00')));
}
示例8: follow
public function follow($user_id_followed)
{
# Prepare our data array to be inserted
$data = array("created" => Time::now(), "user_id" => $this->user->user_id, "user_id_followed" => $user_id_followed);
# Do the insert
DB::instance(DB_NAME)->insert('users_users', $data);
# Send them back
Router::redirect("/posts/users");
}
示例9: set_visit_time
public static function set_visit_time($identifier = NULL)
{
$cookie_name = "visit_" . Router::$controller . "_" . Router::$method . "_" . $identifier;
$cookie_value = Time::now();
# Suppress notice for instances when cookie does not exist
$last_visit = @$_COOKIE[$cookie_name];
setcookie($cookie_name, $cookie_value, strtotime('+1 year'), '/');
return $last_visit;
}
示例10: return_pc
public function return_pc($serial_number)
{
# Prepare our data array to be inserted
$data = array("modified" => Time::now(), "location" => "Returned");
# Match to serial number
$where_condition = "WHERE serial = \"" . $serial_number . "\"";
# Do the insert
DB::instance(DB_NAME)->update('computers', $data, $where_condition);
# Send them back
Router::redirect("/inventory");
}
示例11: p_add
public function p_add()
{
# Associate this post with this user
$_POST['user_id'] = $this->user->user_id;
#print_r($POST);
# Unix timestamp of when this post was created / modified
$_POST['created'] = Time::now();
$_POST['modified'] = Time::now();
#Insert
DB::instance(DB_NAME)->insert('posts', $_POST);
echo "Your post has been added. <a href='/posts/add'> Add another if you wish to. </a>";
}
示例12: add_twitt
public function add_twitt()
{
$_POST = DB::instance(DB_NAME)->sanitize($_POST);
$source = $_POST['source'];
unset($_POST['source']);
$_POST['user_id'] = $this->user->user_id;
$_POST['created'] = Time::now();
$_POST['modified'] = Time::now();
DB::instance(DB_NAME)->insert('twitts', $_POST);
# redirect back to wherever this came from
Router::redirect($source);
}
示例13: p_signup
public function p_signup()
{
# Dump out the results of POST to see what the form submitted
// print_r($_POST);
# encrypt password
$_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']);
$_POST['created'] = Time::now();
$_POST['modified'] = Time::now();
$_POST['token'] = sha1(TOKEN_SALT . $_POST['email'] . Utils::generate_random_string());
# Insert this user into the database
$user_id = DB::instance(DB_NAME)->insert("users", $_POST);
# For now, just confirm they've signed up - we can make this fancier later
echo "You're signed up";
}
示例14: actionSignout
public function actionSignout()
{
$user = User::model()->findByPk(User()->id);
if ($user) {
$user->last_logout_time = Time::now();
$user->last_ip = API::get_ip();
$user->save();
}
Yii::app()->user->logout();
if (isset($_GET['rurl'])) {
$this->redirect(array($_GET['rurl']));
} else {
$this->redirect(Yii::app()->homeUrl);
}
}
示例15: p_signup
public function p_signup()
{
# What data was submitted
//print_r($_POST);
# Encrypt password
$_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']);
# Create and encrypt token
$_POST['token'] = sha1(TOKEN_SALT . $_POST['email'] . Utils::generate_random_string());
# Store current timestamp
$_POST['created'] = Time::now();
# This returns the current timestamp
$_POST['modified'] = Time::now();
# Insert
DB::instance(DB_NAME)->insert('users', $_POST);
echo "You're registered! Now go <a href='/users/login'>login</a>";
}