Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 81 lines (67 sloc) 2.458 kB
<?php /*
ocPortal
Copyright (c) ocProducts, 2004-2012
See text/EN/licence.txt for full licencing information.
NOTE TO PROGRAMMERS:
Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
**** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****
*/
/**
* @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
* @copyright ocProducts Ltd
* @package core
*/
/**
* Check a POST inputted date for validity, and get the Unix timestamp for the inputted date.
*
* @param ID_TEXT The stub of the parameter name (stub_year, stub_month, stub_day, stub_hour, stub_minute)
* @param boolean Whether to allow over get parameters also
* @return ?TIME The timestamp of the date (NULL: no input date was chosen)
*/
function _get_input_date($stub,$get_also=false)
{
$timezone=post_param('timezone',get_users_timezone());
if ($get_also)
{
// if (either_param_integer($stub,0)==0) return NULL; // NULL was chosen Doesn't work like this now
$year=either_param_integer($stub.'_year',NULL);
if (is_null($year)) return NULL;
$month=either_param_integer($stub.'_month',NULL);
if (is_null($month)) return NULL;
$day=either_param_integer($stub.'_day',NULL);
if (is_null($day)) return NULL;
$hour=either_param_integer($stub.'_hour',NULL);
$minute=either_param_integer($stub.'_minute',NULL);
} else
{
// if (post_param_integer($stub,0)==0) return NULL; // NULL was chosen Doesn't work like this now
$year=post_param_integer($stub.'_year',NULL);
if (is_null($year)) return NULL;
$month=post_param_integer($stub.'_month',NULL);
if (is_null($month)) return NULL;
$day=post_param_integer($stub.'_day',NULL);
if (is_null($day)) return NULL;
$hour=post_param_integer($stub.'_hour',NULL);
$minute=post_param_integer($stub.'_minute',NULL);
}
if (!checkdate($month,$day,$year)) warn_exit(do_lang_tempcode('INVALID_DATE_GIVEN'));
if (is_null($hour))
{
if (strpos($stub,'end')!==false)
{
$hour=23;
$minute=59;
} else
{
$hour=0;
$minute=0;
}
}
$time=mktime($hour,$minute,0,$month,$day,$year);
if (($year>=1970) || (@strftime('%Y',@mktime(0,0,0,1,1,1963))=='1963')) // Only try and do timezone conversion if we can do proper maths this far back
{
$amount_forward=tz_time($time,$timezone)-$time;
$time=$time-$amount_forward;
}
return $time;
}
Jump to Line
Something went wrong with that request. Please try again.