./inc/extensions-functions.php:428:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
./inc/extensions-functions.php:544: // @TODO Extension is loaded, what next?
./inc/functions.php:115: // @TODO Extension 'msg' does not exist
-./inc/functions.php:1460: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
-./inc/functions.php:1483: // @TODO Rewrite this old lost code to a template
-./inc/functions.php:1551: // @TODO Are these convertions still required?
-./inc/functions.php:1569:// @TODO Rewrite this function to use readFromFile() and writeToFile()
+./inc/functions.php:1482: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
+./inc/functions.php:1505: // @TODO Rewrite this old lost code to a template
+./inc/functions.php:1573: // @TODO Are these convertions still required?
+./inc/functions.php:1591:// @TODO Rewrite this function to use readFromFile() and writeToFile()
./inc/functions.php:178:// @TODO Rewrite this to an extension 'smtp'
-./inc/functions.php:2222: // @TODO This is still very static, rewrite it somehow
+./inc/functions.php:2244: // @TODO This is still very static, rewrite it somehow
./inc/install-functions.php:63: // @TODO DEACTIVATED: changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
./inc/language/de.php:1141:// @TODO Rewrite these two constants
./inc/language/de.php:1156:// @TODO Rewrite these three constants
./inc/modules/member/what-unconfirmed.php:143: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
./inc/modules/order.php:76: // @TODO Unused: 2,4
./inc/monthly/monthly_bonus.php:69: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1630: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
-./inc/mysql-manager.php:1730: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:2110: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:2154:// @TODO Fix inconsistency between last_module and getWhat()
+./inc/mysql-manager.php:1629: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/mysql-manager.php:1729: // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:2109: // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:2153:// @TODO Fix inconsistency between last_module and getWhat()
./inc/mysql-manager.php:229: // @TODO Nothing helped???
./inc/mysql-manager.php:264: // @TODO Rewrite this to a filter
./inc/mysql-manager.php:589: // @TODO Try to rewrite this to one or more functions
setConfigEntry('SITE_KEY', '');
// CFG: DATE-KEY
-setConfigEntry('DATE_KEY', date('d-m-Y (l-F-T)', time()));
+setConfigEntry('DATE_KEY', generateDateTime(time(), '5'));
// CFG: DEFAULT-LANGUAGE
setConfigEntry('DEFAULT_LANG', 'de');
case '0.5.6': // SQL queries for v0.5.6
// Get current month
- $curr = date('m', time());
+ $curr = getMonth();
if (strlen($curr) == 1) $curr = '0' . $curr;
- if ($curr == "00") $curr = "12";
+ if ($curr == '00') $curr = '12';
// Generate timemark...
- $mark = mktime(0, 0, 0, $curr, 1, date('Y', time()));
+ $mark = mktime(0, 0, 0, $curr, 1, getYear());
// Update accounts which are not active last months
addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_data`
// Is the config entry set?
if (isExtensionInstalledAndNewer('sql_patches', '0.4.2')) {
// Create current week mark
- $currWeek = date('W', time());
+ $currWeek = getWeek();
// Has it changed?
if ((getConfig('last_week') != $currWeek) || ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'))) {
} // END - if
// Create current month mark
- $currMonth = date('m', time());
+ $currMonth = getMonth();
// Has it changed?
if ((getConfig('last_month') != $currMonth) || ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'))) {
if ((isInstallationPhase()) || (!isInstalled()) || (!isAdminRegistered()) || (!isExtensionInstalled('sql_patches'))) return;
// Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D
- if (((date('d', getConfig('last_update')) != date('d', time())) || ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'))) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (getOutputMode() != 1)) {
+ if (((getDay(getConfig('last_update')) != getDay()) || ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'))) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestParameterSet('register')) && (getOutputMode() != 1)) {
// Tell every module we are in reset-mode!
doReset();
} // END - if
// Generates a human-readable timestamp from the Uni* stamp
function generateDateTime ($time, $mode = '0') {
- // Filter out numbers
- $time = bigintval($time);
-
// If the stamp is zero it mostly didn't "happen"
if ($time == '0') {
// Never happend
return '{--NEVER_HAPPENED--}';
} // END - if
+ // Filter out numbers
+ $time = bigintval($time);
+
+ // Is it cached?
+ if (isset($GLOBALS[__FUNCTION__][$time][$mode])) {
+ // Then use it
+ return $GLOBALS[__FUNCTION__][$time][$mode];
+ } // END - if
+
+ // Detect language
switch (getLanguage()) {
case 'de': // German date / time format
switch ($mode) {
case '1': $ret = strtolower(date('d.m.Y - H:i', $time)); break;
case '2': $ret = date('d.m.Y|H:i', $time); break;
case '3': $ret = date('d.m.Y', $time); break;
+ case '4': $ret = date('d.m.Y|H:i:s', $time); break;
+ case '5': $ret = date('d-m-Y (l-F-T)', $time); break;
+ case '6': $ret = date('Ymd', $time); break;
default:
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
break;
default: // Default is the US date / time format!
switch ($mode) {
case '0': $ret = date('r', $time); break;
- case '1': $ret = date('Y-m-d - g:i A', $time); break;
+ case '1': $ret = strtolower(date('Y-m-d - g:i A', $time)); break;
case '2': $ret = date('y-m-d|H:i', $time); break;
case '3': $ret = date('y-m-d', $time); break;
+ case '4': $ret = date('d.m.Y|H:i:s', $time); break;
+ case '5': $ret = date('d-m-Y (l-F-T)', $time); break;
+ case '6': $ret = date('Ymd', $time); break;
default:
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
break;
} // END - switch
} // END - switch
+ // Store it in cache
+ $GLOBALS[__FUNCTION__][$time][$mode] = $ret;
+
// Return result
return $ret;
}
// Translates Y/N to yes/no
function translateYesNo ($yn) {
- // Default
- $translated = '??? (' . $yn . ')';
- switch ($yn) {
- case 'Y': $translated = '{--YES--}'; break;
- case 'N': $translated = '{--NO--}'; break;
- default:
- // Log unknown value
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown value %s. Expected Y/N!", $yn));
- break;
- } // END - switch
+ // Is it cached?
+ if (!isset($GLOBALS[__FUNCTION__][$yn])) {
+ // Default
+ $GLOBALS[__FUNCTION__][$yn] = '??? (' . $yn . ')';
+ switch ($yn) {
+ case 'Y': $GLOBALS[__FUNCTION__][$yn] = '{--YES--}'; break;
+ case 'N': $GLOBALS[__FUNCTION__][$yn] = '{--NO--}'; break;
+ default:
+ // Log unknown value
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown value %s. Expected Y/N!", $yn));
+ break;
+ } // END - switch
+ } // END - if
// Return it
- return $translated;
+ return $GLOBALS[__FUNCTION__][$yn];
}
// Translates the "pool type" into human-readable
// Generates a timestamp (some wrapper for mktime())
function makeTime ($hours, $minutes, $seconds, $stamp) {
// Extract day, month and year from given timestamp
- $days = date('d', $stamp);
- $months = date('m', $stamp);
- $years = date('Y', $stamp);
+ $days = getDay($stamp);
+ $months = getMonth($stamp);
+ $years = getYear($stamp);
// Create timestamp for wished time which depends on extracted date
return mktime(
$keys = getConfig('SITE_KEY') . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY');
if (isConfigEntrySet('secret_key')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key');
if (isConfigEntrySet('file_hash')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash');
- $keys .= getConfig('ENCRYPT_SEPERATOR') . date('d-m-Y (l-F-T)', getConfig('patch_ctime'));
+ $keys .= getConfig('ENCRYPT_SEPERATOR') . getDateFromPatchTime();
if (isConfigEntrySet('master_salt')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
// Build string from misc data
// Do we have a leap year?
$SWITCH = '0';
- $TEST = date('Y', time()) / 4;
- $M1 = date('m', time());
+ $TEST = getYear() / 4;
+ $M1 = getMonth();
// If so and if current time is before 02/29 and estimated time is after 02/29 then add 86400 seconds (one day)
if ((floor($TEST) == $TEST) && ($M1 == '02') && ($postData[$prefix . '_mo'] > '02')) $SWITCH = getConfig('ONE_DAY');
$server = $_SERVER['PHP_SELF'] . getConfig('ENCRYPT_SEPERATOR') . detectUserAgent() . getConfig('ENCRYPT_SEPERATOR') . getenv('SERVER_SOFTWARE') . getConfig('ENCRYPT_SEPERATOR') . detectRemoteAddr();
// Build key string
- $keys = getConfig('SITE_KEY') . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . getConfig('secret_key') . getConfig('ENCRYPT_SEPERATOR') . getConfig('file_hash') . getConfig('ENCRYPT_SEPERATOR') . date('d-m-Y (l-F-T)', getConfig('patch_ctime')) . getConfig('ENCRYPT_SEPERATOR') . getConfig('master_salt');
+ $keys = getConfig('SITE_KEY') . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . getConfig('secret_key') . getConfig('ENCRYPT_SEPERATOR') . getConfig('file_hash') . getConfig('ENCRYPT_SEPERATOR') . getDateFromPatchTime() . getConfig('ENCRYPT_SEPERATOR') . getConfig('master_salt');
// Additional data
$data = $plainText . getConfig('ENCRYPT_SEPERATOR') . uniqid(mt_rand(), true) . getConfig('ENCRYPT_SEPERATOR') . time();
// Log this message away
$fp = fopen(getConfig('CACHE_PATH') . 'debug.log', 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write logfile debug.log!');
- fwrite($fp, date('d.m.Y|H:i:s', time()) . '|' . getModule(false) . '|' . basename($funcFile) . '|' . $line . '|' . $message . "\n");
+ fwrite($fp, generateDateTime(time(), '4') . '|' . getModule(false) . '|' . basename($funcFile) . '|' . $line . '|' . $message . "\n");
fclose($fp);
} // END - if
}
if (getOutputMode() != 0) return;
// Create timemark from saved month
-$mark = mktime(0, 0, 0, getConfig('last_month'), date('d', time()), date('Y', time()));
+$mark = mktime(0, 0, 0, getConfig('last_month'), getDay(), getYear());
$sql = ''; $mode = '';
// Shall I sent activation or deactivation mail?
if (getOutputMode() != 0) return;
// Create timemark from saved month
-$mark = mktime(0, 0, 0, getConfig('last_month'), date('d', time()), date('Y', time()));
+$mark = mktime(0, 0, 0, getConfig('last_month'), getDay(), getYear());
$sql = ''; $mode = '';
// Shall I sent activation or deactivation mail?
$content['notify_options'] = generateOptionList('/ARRAY/', array('Y','N'), array('{--YES--}', '{--NO--}' ));
// Starting day
-$content['start_sec'] = addSelectionBox('sec' , 0 , 'start');
-$content['start_min'] = addSelectionBox('min' , 0 , 'start');
-$content['start_hour'] = addSelectionBox('hour' , date('G', time()), 'start');
-$content['start_day'] = addSelectionBox('day' , date('d', time()), 'start');
-$content['start_month'] = addSelectionBox('month', date('m', time()), 'start');
-$content['start_year'] = addSelectionBox('year' , date('Y', time()), 'start');
+$content['start_sec'] = addSelectionBox('sec' , 0 , 'start');
+$content['start_min'] = addSelectionBox('min' , 0 , 'start');
+$content['start_hour'] = addSelectionBox('hour' , getShortHour() , 'start');
+$content['start_day'] = addSelectionBox('day' , getDay() , 'start');
+$content['start_month'] = addSelectionBox('month', getMonth() , 'start');
+$content['start_year'] = addSelectionBox('year' , getYear() , 'start');
-// Calcualte ending date
-$D = date('d', time() + (getConfig('ONE_DAY') * 7));
-$M = date('m', time() + (getConfig('ONE_DAY') * 7));
-$Y = date('Y', time() + (getConfig('ONE_DAY') * 7));
+// Ending timestamp
+$endingStamp = time() + (getConfig('ONE_DAY') * 7);
// Ending day
-$content['end_sec'] = addSelectionBox('sec' , 0 , 'end');
-$content['end_min'] = addSelectionBox('min' , 0 , 'end');
-$content['end_hour'] = addSelectionBox('hour' , date('G', time()), 'end');
-$content['end_day'] = addSelectionBox('day' , $D , 'end');
-$content['end_month'] = addSelectionBox('month', $M , 'end');
-$content['end_year'] = addSelectionBox('year' , $Y , 'end');
+$content['end_sec'] = addSelectionBox('sec' , 0 , 'end');
+$content['end_min'] = addSelectionBox('min' , 0 , 'end');
+$content['end_hour'] = addSelectionBox('hour' , getShortHour() , 'end');
+$content['end_day'] = addSelectionBox('day' , getDay($endingStamp) , 'end');
+$content['end_month'] = addSelectionBox('month', getMonth($endingStamp), 'end');
+$content['end_year'] = addSelectionBox('year' , getYear($endingStamp) , 'end');
// Transfer (maybe found) templates into constant for the template
$content['templates_selection'] = addReferalRallyeTemplateSelection();
} else {
// Make start editable
$content['mt_start'] =
- addSelectionBox('day' , date('d', time())).
- addSelectionBox('month', date('m', time())).
+ addSelectionBox('day' , getDay()).
+ addSelectionBox('month', getMonth()).
addSelectionBox('year', -1)
;
}
// Shall I withdraw now?
if (isPostRequestParameterSet('withdraw')) {
// Okay, let's prepare...
- $curr = date('m', time()) - 1;
+ $curr = getMonth() - 1;
if (strlen($curr) == 1) $curr = '0' . $curr;
updateConfiguration('last_month', $curr);
loadTemplate('admin_settings_saved', false, '{--ADMIN_BEG_WITHDRAW_PREPARED--}');
$content['total'] = translateComma($total);
// Check if we need to display form or not with manuel withdraw
- if (getConfig('last_month') == date('m', time())) {
+ if (getConfig('last_month') == getMonth()) {
// Load form
$content['withdraw_form'] = loadTemplate('admin_list_beg_form', true);
} else {
// Shall I withdraw now?
if (isPostRequestParameterSet('withdraw')) {
// Okay, let's prepare...
- $curr = date('m', time()) - 1;
+ $curr = getMonth() - 1;
if (strlen($curr) == 1) $curr = '0' . $curr;
updateConfiguration('last_month', $curr);
loadTemplate('admin_settings_saved', false, '{--ADMIN_BONUS_WITHDRAW_PREPARED--}');
$content['total'] = translateComma($total);
// Check if we need to display form or not with manuel withdraw
- if (getConfig('last_month') == date('m', time())) {
+ if (getConfig('last_month') == getMonth()) {
// Load form
$content['withdraw_form'] = loadTemplate('admin_list_bonus_form', true);
} else {
SQL_FREERESULT($result);
// Starting day
- $content['s_sec'] = addSelectionBox('sec' , date('s', $content['start_time']), 'start', $id);
- $content['s_min'] = addSelectionBox('min' , date('i', $content['start_time']), 'start', $id);
- $content['s_hour'] = addSelectionBox('hour' , date('G', $content['start_time']), 'start', $id);
- $content['s_day'] = addSelectionBox('day' , date('d', $content['start_time']), 'start', $id);
- $content['s_month'] = addSelectionBox('month', date('m', $content['start_time']), 'start', $id);
- $content['s_year'] = addSelectionBox('year' , date('Y', $content['start_time']), 'start', $id);
+ $content['s_sec'] = addSelectionBox('sec' , getSecond($content['start_time']) , 'start', $id);
+ $content['s_min'] = addSelectionBox('min' , getMinute($content['start_time']) , 'start', $id);
+ $content['s_hour'] = addSelectionBox('hour' , getShortHour($content['start_time']), 'start', $id);
+ $content['s_day'] = addSelectionBox('day' , getDay($content['start_time']) , 'start', $id);
+ $content['s_month'] = addSelectionBox('month', getMonth($content['start_time']) , 'start', $id);
+ $content['s_year'] = addSelectionBox('year' , getYear($content['start_time']) , 'start', $id);
// Ending day
- $content['e_sec'] = addSelectionBox('sec' , date('s', $content['end_time']) , 'end' , $id);
- $content['e_min'] = addSelectionBox('min' , date('i', $content['end_time']) , 'end' , $id);
- $content['e_hour'] = addSelectionBox('hour' , date('G', $content['end_time']) , 'end' , $id);
- $content['e_day'] = addSelectionBox('day' , date('d', $content['end_time']) , 'end' , $id);
- $content['e_month'] = addSelectionBox('month', date('m', $content['end_time']) , 'end' , $id);
- $content['e_year'] = addSelectionBox('year' , date('Y', $content['end_time']) , 'end' , $id);
+ $content['e_sec'] = addSelectionBox('sec' , getSecond($content['end_time']) , 'end' , $id);
+ $content['e_min'] = addSelectionBox('min' , getMinute($content['end_time']) , 'end' , $id);
+ $content['e_hour'] = addSelectionBox('hour' , getShortHour($content['end_time']) , 'end' , $id);
+ $content['e_day'] = addSelectionBox('day' , getDay($content['end_time']) , 'end' , $id);
+ $content['e_month'] = addSelectionBox('month', getMonth($content['end_time']) , 'end' , $id);
+ $content['e_year'] = addSelectionBox('year' , getYear($content['end_time']) , 'end' , $id);
// Remember other values
$content['templ'] = addReferalRallyeTemplateSelection('templ['.$id.']', $content['template']);
break;
case 'N': // Display activation form
- // Starting day
- $content['start_day'] = addSelectionBox('day' , date('d', (time() + getConfig('ONE_DAY'))), 'start');
- $content['start_month'] = addSelectionBox('month', date('m', (time() + getConfig('ONE_DAY'))), 'start');
- $content['start_year'] = addSelectionBox('year' , date('Y', (time() + getConfig('ONE_DAY'))), 'start');
+ // Cache timestamps
+ $startingStamp = time() + getConfig('ONE_DAY');
+ $endingStamp = $startingStamp + (getConfig('ONE_DAY') * getConfig('holiday_max');
- // Calcualte ending date
- $D = date('d', time() + getConfig('ONE_DAY') + (getConfig('ONE_DAY') * getConfig('holiday_max')));
- $M = date('m', time() + getConfig('ONE_DAY') + (getConfig('ONE_DAY') * getConfig('holiday_max')));
- $Y = date('Y', time() + getConfig('ONE_DAY') + (getConfig('ONE_DAY') * getConfig('holiday_max')));
+ // Starting day
+ $content['start_day'] = addSelectionBox('day' , getDay($startingStamp) , 'start');
+ $content['start_month'] = addSelectionBox('month', getMonth($startingStamp), 'start');
+ $content['start_year'] = addSelectionBox('year' , getYear($startingStamp) , 'start');
// Ending day
- $content['end_day'] = addSelectionBox('day' , $D, 'end');
- $content['end_month'] = addSelectionBox('month', $M, 'end');
- $content['end_year'] = addSelectionBox('year' , $Y, 'end');
+ $content['end_day'] = addSelectionBox('day' , getDay($endingStamp) , 'end');
+ $content['end_month'] = addSelectionBox('month', getMonth($endingStamp), 'end');
+ $content['end_year'] = addSelectionBox('year' , getYear($endingStamp) , 'end');
// Output form
loadTemplate('member_holiday_form', false, $content);
}
// Get current month (2 digits)
-$curr = date('m', time());
+$curr = getMonth();
// Check if month is done
if (($curr != getConfig('last_month')) && (getConfig('last_month') > 0) && (getConfig('beg_ranks') > 0) && (getOutputMode() != 1)) {
}
// Get current month (2 digits)
-$curr = date('m', time());
+$curr = getMonth();
if (($curr != getConfig('last_month')) && (getConfig('bonus_ranks') > 0) && (getOutputMode() != 1)) {
// Extension 'autopurge' is inactive or purging of inactive accounts is deactivated
}
// Get current day (01 to 31), month (01 to 12) and year (4-digits year)
-$day = date('d', time());
-$month = date('m', time());
-$year = date('Y', time());
+$day = getDay();
+$month = getMonth();
+$year = getYear();
// Shall I include only active members?
$add = '%s'; $value = '';
// Load it from database
$result = SQL_QUERY_ESC("SELECT `stats_entry`,`stats_value` FROM `{?_MYSQL_PREFIX?}_stats_%s` ORDER BY `stats_entry` ASC",
- array(date('Ymd', time())), __FUNCTION__, __LINE__);
+ array(generateDateTime(time(), '6')), __FUNCTION__, __LINE__);
// Read all rows
while ($row = SQL_FETCHARRAY($result)) {
// Ask for it
$result = SQL_QUERY_ESC("SHOW TABLES LIKE '{?_MYSQL_PREFIX?}_stats_%s'",
- array(date('Ymd', time())), __FUNCTION__, __LINE__);
+ array(generateDateTime(time(), '6')), __FUNCTION__, __LINE__);
// Do we have a row?
return SQL_NUMROWS($result);
`stats_value` BIGINT(20) NOT NULL DEFAULT 0,
PRIMARY KEY (`stats_entry`)
) TYPE=HEAP COMMENT='Temporary statistics table'",
- array(date('Ymd', time())), __FUNCTION__, __LINE__);
+ array(generateDateTime(time(), '6')), __FUNCTION__, __LINE__);
}
// Write all entries to the table
// Empty the table first
SQL_QUERY_ESC("TRUNCATE `{?_MYSQL_PREFIX?}_stats_%s`",
- array(date('Ymd', time())), __FUNCTION__, __LINE__);
+ array(generateDateTime(time(), '6')), __FUNCTION__, __LINE__);
// Begin the SQL command
$sql = sprintf("REPLACE INTO `{?_MYSQL_PREFIX?}_stats_%s` (`stats_entry`,`stats_value`) VALUES ",
- date('Ymd', time()));
+ generateDateTime(time(), '6'));
// Add all entries to the final query
foreach ($GLOBALS['stats'] as $entry => $value) {
case 'year': // Year
// Get current year
- $year = date('Y', time());
+ $year = getYear();
// Use configured min age or fixed?
if (isExtensionInstalledAndNewer('order', '0.2.1')) {
// Calculate earliest year depending on extension version
if (isExtensionInstalledAndNewer('order', '0.2.1')) {
// Use configured minimum age
- $year = date('Y', time()) - getConfig('min_age');
+ $year = getYear() - getConfig('min_age');
} else {
// Use fixed 16 years age
- $year = date('Y', time()) - 16;
+ $year = getYear() - 16;
}
// Construct year selection list
// Do we have a leap year?
$SWITCH = '0';
- $TEST = date('Y', time()) / 4;
- $M1 = date('m', time());
- $M2 = date('m', (time() + $timestamp));
+ $TEST = getYear() / 4;
+ $M1 = getMonth();
+ $M2 = getMonth(time() + $timestamp);
// If so and if current time is before 02/29 and estimated time is after 02/29 then add 86400 seconds (one day)
if ((floor($TEST) == $TEST) && ($M1 == '02') && ($M2 > '02')) $SWITCH = getConfig('ONE_DAY');
return $str;
}
+// "Getter" for date from patch_ctime
+function getDateFromPatchTime () {
+ // Is it cached?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Then set it
+ $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Getter for current year (default)
+function getYear ($timestamp = null) {
+ // Is it cached?
+ if (!isset($GLOBALS['year'][$timestamp])) {
+ // null is time()
+ if (is_null($timestamp)) $timestamp = time();
+
+ // Then create it
+ $GLOBALS['year'][$timestamp] = date('Y', $timestamp);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['year'][$timestamp];
+}
+
+// Getter for current month (default)
+function getMonth ($timestamp = null) {
+ // Is it cached?
+ if (!isset($GLOBALS['month'][$timestamp])) {
+ // null is time()
+ if (is_null($timestamp)) $timestamp = time();
+
+ // Then create it
+ $GLOBALS['month'][$timestamp] = date('m', $timestamp);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['month'][$timestamp];
+}
+
+// Getter for current day (default)
+function getDay ($timestamp = null) {
+ // Is it cached?
+ if (!isset($GLOBALS['day'][$timestamp])) {
+ // null is time()
+ if (is_null($timestamp)) $timestamp = time();
+
+ // Then create it
+ $GLOBALS['day'][$timestamp] = date('d', $timestamp);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['day'][$timestamp];
+}
+
+// Getter for current week (default)
+function getWeek ($timestamp = null) {
+ // Is it cached?
+ if (!isset($GLOBALS['week'][$timestamp])) {
+ // null is time()
+ if (is_null($timestamp)) $timestamp = time();
+
+ // Then create it
+ $GLOBALS['week'][$timestamp] = date('W', $timestamp);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['week'][$timestamp];
+}
+
+// Getter for current short_hour (default)
+function getShortHour ($timestamp = null) {
+ // Is it cached?
+ if (!isset($GLOBALS['short_hour'][$timestamp])) {
+ // null is time()
+ if (is_null($timestamp)) $timestamp = time();
+
+ // Then create it
+ $GLOBALS['short_hour'][$timestamp] = date('G', $timestamp);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['short_hour'][$timestamp];
+}
+
+// Getter for current long_hour (default)
+function getLongHour ($timestamp = null) {
+ // Is it cached?
+ if (!isset($GLOBALS['long_hour'][$timestamp])) {
+ // null is time()
+ if (is_null($timestamp)) $timestamp = time();
+
+ // Then create it
+ $GLOBALS['long_hour'][$timestamp] = date('H', $timestamp);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['long_hour'][$timestamp];
+}
+
+// Getter for current second (default)
+function getSecond ($timestamp = null) {
+ // Is it cached?
+ if (!isset($GLOBALS['second'][$timestamp])) {
+ // null is time()
+ if (is_null($timestamp)) $timestamp = time();
+
+ // Then create it
+ $GLOBALS['second'][$timestamp] = date('s', $timestamp);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['second'][$timestamp];
+}
+
+// Getter for current minute (default)
+function getMinute ($timestamp = null) {
+ // Is it cached?
+ if (!isset($GLOBALS['minute'][$timestamp])) {
+ // null is time()
+ if (is_null($timestamp)) $timestamp = time();
+
+ // Then create it
+ $GLOBALS['minute'][$timestamp] = date('i', $timestamp);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['minute'][$timestamp];
+}
+
// [EOF]
?>