* $Author:: $ *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team *
* For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
reportBug(__FUNCTION__, __LINE__, '<strong>{--FATAL_ERROR--}:</strong> {--NO_RENDER_DIRECT--}');
break;
} // END - switch
- } elseif ((getPhpCaching() == 'on') && ((!isset($GLOBALS['http_header'])) || (count($GLOBALS['http_header']) == 0)) && (!isRawOutputMode())) {
+ } elseif ((getPhpCaching() == 'on') && (!isFilledArray($GLOBALS['http_header'])) && (!isRawOutputMode())) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getPhpCaching()=' . getPhpCaching() . ',isset(http_header)=' . intval(isset($GLOBALS['http_header'])) . ',getScriptOutputMode()=' . getScriptOutputMode() . '');
// Output cached HTML code
$GLOBALS['__output'] = ob_get_contents();
// Compiles the final output
function compileFinalOutput () {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '__output(length)=' . strlen($GLOBALS['__output']) . ',getScriptOutputMode()=' . getScriptOutputMode() . ' - ENTERED!');
+ // Is this function called?
+ if (isset($GLOBALS[__FUNCTION__])) {
+ // Abort here
+ reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' causes problems with sent headers.');
+ } // END - if
+
+ // Mark this function as called
+ $GLOBALS[__FUNCTION__] = TRUE;
+
// Add page header and footer
addPageHeaderFooter();
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '__output(length)=' . strlen($GLOBALS['__output']) . ' - After addPageHeaderFooter() call.');
enableTemplateHtml($insertComments);
// Init counter
- $count = 0;
+ $totalCompilations = 0;
// Compile all out
- while (((isInString('{--', $code)) || (isInString('{DQUOTE}', $code)) || (isInString('{?', $code)) || (isInString('{%', $code) !== FALSE)) && ($count < 7)) {
+ while (((isInString('{--', $code)) || (isInString('{DQUOTE}', $code)) || (isInString('{?', $code)) || (isInString('{%', $code) !== FALSE)) && ($totalCompilations < 7)) {
// Init common variables
$content = array();
$newContent = '';
// Compile it
- //* DEBUG: */ debugOutput('<pre>'.linenumberCode($code).'</pre>');
+ //* DEBUG: */ debugOutput('<pre>'.lineNumberCode($code).'</pre>');
$eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code), $enableCodes)) . '";';
- //* DEBUG: */ if (!$insertComments) print('EVAL=<pre>'.linenumberCode($eval).'</pre>');
+ //* DEBUG: */ if (!$insertComments) print('EVAL=<pre>'.lineNumberCode($eval).'</pre>');
eval($eval);
- //* DEBUG: */ if (!$insertComments) print('NEW=<pre>'.linenumberCode($newContent).'</pre>');
+ //* DEBUG: */ if (!$insertComments) print('NEW=<pre>'.lineNumberCode($newContent).'</pre>');
//* DEBUG: */ die('<pre>'.encodeEntities($newContent).'</pre>');
// Was that eval okay?
if (empty($newContent)) {
// Something went wrong!
- reportBug(__FUNCTION__, __LINE__, 'Evaluation error:<pre>' . linenumberCode($eval) . '</pre>', FALSE);
+ reportBug(__FUNCTION__, __LINE__, 'Evaluation error:<pre>' . lineNumberCode($eval) . '</pre>', FALSE);
} // END - if
// Use it again
} // END - if
// Count round
- $count++;
+ $totalCompilations++;
} // END - while
// Add debugging data in HTML code, if mode is enabled
- if ((isDebugModeEnabled()) && ($insertComments === TRUE) && ((isHtmlOutputMode()) || (isCssOutputMode()))) {
+ if ((isDebugModeEnabled()) && ($insertComments === TRUE) && (isHtmlOutputMode())) {
// Add loop count
- $code .= '<!-- Total compilation loop=' . $count . ' //-->';
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isDebugModeEnabled()=' . intval(isDebugModeEnabled()) . ',insertComments=' . intval($insertComments) . ',isHtmlOutputMode()=' . intval(isHtmlOutputMode()));
+ $code .= '<!-- Total compilation loop=' . $totalCompilations . ' //-->';
} // END - if
// Return the compiled code
$template = strtolower($template);
// Base directory
- $basePath = sprintf("%stemplates/%s/html/", getPath(), getLanguage());
+ $basePath = getTemplateBasePath('html');
$extraPath = detectExtraTemplatePath('html', $template);
// Generate FQFN
- $FQFN = $basePath . $extraPath . $template . '.tpl';
+ $FQFN = $basePath . '/' . $extraPath . $template . '.tpl';
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Template ' . $template . ' is solved to FQFN=' . $FQFN);
// Does the special template exists?
if (!isFileReadable($FQFN)) {
// Reset to default template
- $FQFN = $basePath . $template . '.tpl';
+ $FQFN = $basePath . '/' . $template . '.tpl';
} // END - if
// Now does the final template exists?
unset($GLOBALS['template_eval']['email'][$template]);
} elseif (!isset($GLOBALS['template_eval']['email'][$template])) {
// Base directory
- $basePath = sprintf("%stemplates/%s/emails/", getPath(), getLanguage());
+ $basePath = getTemplateBasePath('emails');
// Detect extra path
$extraPath = detectExtraTemplatePath('email', $template);
// Generate full FQFN
- $FQFN = $basePath . $extraPath . $template . '.tpl';
+ $FQFN = $basePath . '/' . $extraPath . $template . '.tpl';
// Does the special template exists?
if (!isFileReadable($FQFN)) {
// Reset to default template
- $FQFN = $basePath . $template . '.tpl';
+ $FQFN = $basePath . '/' . $template . '.tpl';
} // END - if
// Now does the final template exists?
// Eval the code
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'template=' . $template . ' - BEFORE EVAL');
//* DEBUG: */ print('<pre>'.htmlentities($GLOBALS['template_eval']['email'][$template]).'</pre>');
+ //* DEBUG: */ die('<pre>'.print_r($content, TRUE).'</pre><pre>'.htmlentities($GLOBALS['template_eval']['email'][$template]).'</pre>');
eval($GLOBALS['template_eval']['email'][$template]);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'template=' . $template . ' - AFTER EVAL');
} // END - if
// Generate XHTML code for the CAPTCHA
function generateCaptchaCode ($code, $type, $urlId, $userid) {
- return '<img border="0" alt="Code ' . $code . '" src="{%url=mailid_top.php?userid=' . $userid . '&' . $type . '=' . $urlId . '&do=img&code=' . $code . '%}" />';
+ return '<img border="0" alt="Code ' . $code . '" src="{%url=mailid.php?userid=' . $userid . '&' . $type . '=' . $urlId . '&do=img&code=' . $code . '%}" />';
}
// Compiles the given HTML/mail code
//* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Second regex gave ' . count($matches[0]) . ' matches.');
// Are some matches found?
- if ((count($matches) > 0) && (count($matches[0]) > 0)) {
+ if ((isFilledArray($matches)) && (isFilledArray($matches[0]))) {
// Replace all matches
$matchesFound = array();
foreach ($matches[0] as $key => $match) {
// Fuzzy look has failed by default
$fuzzyFound = FALSE;
+ // "Cache" match length
+ $matchLength = strlen($match);
+
// Fuzzy look on match if already found
foreach ($matchesFound as $found => $set) {
// Get test part
- $test = substr($found, 0, strlen($match));
+ $test = substr($found, 0, $matchLength);
// Does this entry exist?
//* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'found=' . $found . ',match=' . $match . ',set=' . $set);
preg_match_all('/\$([a-z_A-Z\[\]]){0,}/', $code, $matches);
// Are some matches found?
- if ((count($matches) > 0) && (count($matches[0]) > 0)) {
+ if ((isFilledArray($matches)) && (isFilledArray($matches[0]))) {
// Scan all matches for not $content
foreach ($matches[0] as $match) {
// Trim match
}
//
-function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 'form_select') {
+function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'form_select') {
$OUT = '';
if ($type == 'yn') {
// This is a yes/no selection only!
- if ($id > 0) $prefix .= '[' . $id . ']';
+ if (isValidId($id)) $prefix .= '[' . $id . ']';
$OUT .= '<select name="' . $prefix . '" class="' . $class . '" size="1">';
} else {
// Begin with regular selection box here
if (!empty($prefix)) $prefix .= '_';
$type2 = $type;
- if ($id > 0) $type2 .= '[' . $id . ']';
+ if (isValidId($id)) $type2 .= '[' . $id . ']';
$OUT .= '<select name="' . strtolower($prefix . $type2) . '" class="' . $class . '" size="1">';
}
switch ($type) {
- case 'day': // Day
- for ($idx = 1; $idx < 32; $idx++) {
- $OUT .= '<option value="' . $idx . '"';
- if ($default == $idx) $OUT .= ' selected="selected"';
- $OUT .= '>' . $idx . '</option>';
- } // END - for
- break;
-
- case 'month': // Month
- foreach ($GLOBALS['month_descr'] as $idx => $descr) {
- $OUT .= '<option value="' . $idx . '"';
- if ($default == $idx) $OUT .= ' selected="selected"';
- $OUT .= '>' . $descr . '</option>';
- } // END - for
- break;
-
- case 'year': // Year
+ case 'ye': // Years
// Get current year
$year = getYear();
// Use configured min age or fixed?
if (isExtensionInstalledAndNewer('other', '0.2.1')) {
// Configured
- $startYear = $year - getConfig('min_age');
+ $startYear = $year - getMinAge();
} else {
// Fixed 16 years
$startYear = $year - 16;
} else {
// Get current year and subtract the configured minimum age
$OUT .= '<option value="' . ($minYear - 1) . '"><' . $minYear . '</option>';
- // Calculate earliest year depending on extension version
- if (isExtensionInstalledAndNewer('other', '0.2.1')) {
- // Use configured minimum age
- $year = getYear() - getConfig('min_age');
- } else {
- // Use fixed 16 years age
- $year = getYear() - 16;
- }
// Construct year selection list
- for ($idx = $minYear; $idx <= $year; $idx++) {
+ for ($idx = $minYear; $idx <= $startYear; $idx++) {
$OUT .= '<option value="' . $idx . '"';
if ($default == $idx) $OUT .= ' selected="selected"';
$OUT .= '>' . $idx . '</option>';
}
break;
- case 'sec':
- case 'min':
- for ($idx = 0; $idx < 60; $idx+=5) {
- if (strlen($idx) == 1) $idx = 0 . $idx;
+ case 'mo': // Months
+ foreach ($GLOBALS['month_descr'] as $idx => $descr) {
$OUT .= '<option value="' . $idx . '"';
if ($default == $idx) $OUT .= ' selected="selected"';
- $OUT .= '>' . $idx . '</option>';
+ $OUT .= '>' . $descr . '</option>';
} // END - for
break;
- case 'hour':
- for ($idx = 0; $idx < 24; $idx++) {
- if (strlen($idx) == 1) $idx = 0 . $idx;
+ case 'mn': // Months, numeric
+ for ($idx = 0; $idx <= 12; $idx++) {
$OUT .= '<option value="' . $idx . '"';
if ($default == $idx) $OUT .= ' selected="selected"';
+ $OUT .= '>{%pipe,padLeftZero=' . $idx . '%}</option>';
+ } // END - for
+ break;
+
+ case 'we': // Weeks
+ for ($idx = 0; $idx <= 4; $idx++) {
+ $OUT .= ' <option value="' . $idx . '"';
+ if ($default == $idx) $OUT .= ' selected="selected"';
$OUT .= '>' . $idx . '</option>';
} // END - for
break;
- case 'yn':
+ case 'da': // Days
+ for ($idx = 0; $idx <= 31; $idx++) {
+ $OUT .= '<option value="' . $idx . '"';
+ if ($default == $idx) $OUT .= ' selected="selected"';
+ $OUT .= '>{%pipe,padLeftZero=' . $idx . '%}</option>';
+ } // END - for
+ break;
+
+ case 'ho': // Hours
+ for ($idx = 0; $idx <= 23; $idx++) {
+ $padded = padLeftZero($idx);
+ $OUT .= '<option value="' . $padded . '"';
+ if ($default == $padded) $OUT .= ' selected="selected"';
+ $OUT .= '>' . $padded . '</option>';
+ } // END - for
+ break;
+
+ case 'mi': // Minutes
+ case 'se': // Seconds
+ for ($idx = 0; $idx <= 59; $idx+=5) {
+ $padded = padLeftZero($idx);
+ $OUT .= '<option value="' . $padded . '"';
+ if ($default == $padded) $OUT .= ' selected="selected"';
+ $OUT .= '>' . $padded . '</option>';
+ } // END - for
+ break;
+
+ case 'yn': // Yes/No
$OUT .= '<option value="Y"';
if ($default == 'Y') $OUT .= ' selected="selected"';
$OUT .= '>{--YES--}</option><option value="N"';
if ($default != 'Y') $OUT .= ' selected="selected"';
$OUT .= '>{--NO--}</option>';
break;
+
+ default: // Not detected
+ reportBug(__FUNCTION__, __LINE__, 'type=' . $type . ',default=' . $default . ',prefix=' . $prefix . ',id[' . gettype($id) . ']=' . $id . ',class=' . $class . ' - is not supported.');
+ break;
}
$OUT .= '</select>';
return $OUT;
}
// Load image
- $img = sprintf("%s/theme/%s/images/code_bg.%s",
+ $img = sprintf('%s/theme/%s/images/code_bg.%s',
getPath(),
getCurrentTheme(),
getImgType()
} // END - switch
} else {
// Silently log the error
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("File for image-type %s in theme %s not found.", getImgType(), getCurrentTheme()));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf('File for image-type %s in theme %s not found.', getImgType(), getCurrentTheme()));
return;
}
} // END - switch
// First of all years...
- $Y = abs(floor($timestamp / (31536000 + $SWITCH)));
- //* DEBUG: */ debugOutput('Y=' . $Y);
+ $year = abs(floor($timestamp / (31536000 + $SWITCH)));
+ //* DEBUG: */ debugOutput('year=' . $year);
// Next months...
- $M = abs(floor($timestamp / 2628000 - $Y * 12));
- //* DEBUG: */ debugOutput('M=' . $M);
+ $month = abs(floor($timestamp / 2628000 - $year * 12));
+ //* DEBUG: */ debugOutput('month=' . $month);
// Next weeks
- $W = abs(floor($timestamp / 604800 - $Y * ((365 + $SWITCH / getOneDay()) / 7) - ($M / 12 * (365 + $SWITCH / getOneDay()) / 7)));
- //* DEBUG: */ debugOutput('W=' . $W);
+ $week = abs(floor($timestamp / 604800 - $year * ((365 + $SWITCH / getOneDay()) / 7) - ($month / 12 * (365 + $SWITCH / getOneDay()) / 7)));
+ //* DEBUG: */ debugOutput('week=' . $week);
// Next days...
- $D = abs(floor($timestamp / 86400 - $Y * (365 + $SWITCH / getOneDay()) - ($M / 12 * (365 + $SWITCH / getOneDay())) - $W * 7));
- //* DEBUG: */ debugOutput('D=' . $D);
+ $day = abs(floor($timestamp / 86400 - $year * (365 + $SWITCH / getOneDay()) - ($month / 12 * (365 + $SWITCH / getOneDay())) - $week * 7));
+ //* DEBUG: */ debugOutput('day=' . $day);
// Next hours...
- $h = abs(floor($timestamp / 3600 - $Y * (365 + $SWITCH / getOneDay()) * 24 - ($M / 12 * (365 + $SWITCH / getOneDay()) * 24) - $W * 7 * 24 - $D * 24));
- //* DEBUG: */ debugOutput('h=' . $h);
+ $hour = abs(floor($timestamp / 3600 - $year * (365 + $SWITCH / getOneDay()) * 24 - ($month / 12 * (365 + $SWITCH / getOneDay()) * 24) - $week * 7 * 24 - $day * 24));
+ //* DEBUG: */ debugOutput('hour=' . $hour);
// Next minutes..
- $m = abs(floor($timestamp / 60 - $Y * (365 + $SWITCH / getOneDay()) * 24 * 60 - ($M / 12 * (365 + $SWITCH / getOneDay()) * 24 * 60) - $W * 7 * 24 * 60 - $D * 24 * 60 - $h * 60));
- //* DEBUG: */ debugOutput('m=' . $m);
+ $minute = abs(floor($timestamp / 60 - $year * (365 + $SWITCH / getOneDay()) * 24 * 60 - ($month / 12 * (365 + $SWITCH / getOneDay()) * 24 * 60) - $week * 7 * 24 * 60 - $day * 24 * 60 - $hour * 60));
+ //* DEBUG: */ debugOutput('minute=' . $minute);
// And at last seconds...
- $s = abs(floor($timestamp - $Y * (365 + $SWITCH / getOneDay()) * 24 * 3600 - ($M / 12 * (365 + $SWITCH / getOneDay()) * 24 * 3600) - $W * 7 * 24 * 3600 - $D * 24 * 3600 - $h * 3600 - $m * 60));
- //* DEBUG: */ debugOutput('s=' . $s);
+ $second = abs(floor($timestamp - $year * (365 + $SWITCH / getOneDay()) * 24 * 3600 - ($month / 12 * (365 + $SWITCH / getOneDay()) * 24 * 3600) - $week * 7 * 24 * 3600 - $day * 24 * 3600 - $hour * 3600 - $minute * 60));
+ //* DEBUG: */ debugOutput('second=' . $second);
// Is seconds zero and time is < 60 seconds?
- if (($s == '0') && ($timestamp < 60)) {
+ if (($second < 1) && ($timestamp < 60)) {
// Fix seconds
- $s = round($timestamp);
+ $second = round($timestamp);
} // END - if
+ // Put all calculated values in array
+ $data = array(
+ 'Y' => $year,
+ 'M' => $month,
+ 'W' => $week,
+ 'D' => $day,
+ 'h' => $hour,
+ 'm' => $minute,
+ 's' => $second
+ );
+
//
// Now we convert them in seconds...
//
if ($asArray === TRUE) {
- // Just put all data in an array for later use
- $OUT = array(
- 'Y' => $Y,
- 'M' => $M,
- 'W' => $W,
- 'D' => $D,
- 'h' => $h,
- 'm' => $m,
- 's' => $s
- );
+ // Just put data array out
+ $OUT = $data;
} else {
+ // Init array
+ $units = array(
+ // Time unit -> field name
+ 'unit_field' => array(
+ 'Y' => 'ye',
+ 'M' => 'mn',
+ 'W' => 'we',
+ 'D' => 'da',
+ 'h' => 'ho',
+ 'm' => 'mi',
+ 's' => 'se'
+ ),
+ // Time unit -> label
+ 'unit_label' => array(
+ 'Y' => 'YEAR',
+ 'M' => 'MONTH',
+ 'W' => 'WEEK',
+ 'D' => 'DAY',
+ 'h' => 'HOUR',
+ 'm' => 'MINUTE',
+ 's' => 'SECOND'
+ )
+ );
+
// Generate table
$OUT = '<div align="' . $align . '">';
$OUT .= '<table border="0" cellspacing="0" cellpadding="0" class="timebox_table dashed">';
$OUT .= '<tr>';
- if (isInString('Y', $display) || (empty($display))) {
- $OUT .= '<td align="center" class="timebox_column bottom"><div class="tiny">{--TIME_UNIT_YEAR--}</strong></td>';
- } // END - if
-
- if (isInString('M', $display) || (empty($display))) {
- $OUT .= '<td align="center" class="timebox_column bottom"><div class="tiny">{--TIME_UNIT_MONTH--}</strong></td>';
- } // END - if
-
- if (isInString('W', $display) || (empty($display))) {
- $OUT .= '<td align="center" class="timebox_column bottom"><div class="tiny">{--TIME_UNIT_WEEK--}</strong></td>';
- } // END - if
-
- if (isInString('D', $display) || (empty($display))) {
- $OUT .= '<td align="center" class="timebox_column bottom"><div class="tiny">{--TIME_UNIT_DAY--}</strong></td>';
- } // END - if
-
- if (isInString('h', $display) || (empty($display))) {
- $OUT .= '<td align="center" class="timebox_column bottom"><div class="tiny">{--TIME_UNIT_HOUR--}</strong></td>';
- } // END - if
-
- if (isInString('m', $display) || (empty($display))) {
- $OUT .= '<td align="center" class="timebox_column bottom"><div class="tiny">{--TIME_UNIT_MINUTE--}</strong></td>';
- } // END - if
-
- if (isInString('s', $display) || (empty($display))) {
- $OUT .= '<td align="center" class="timebox_column bottom"><div class="tiny">{--TIME_UNIT_SECOND--}</strong></td>';
- } // END - if
+ // "Walk" through all units
+ foreach ($units['unit_field'] as $unit => $field) {
+ // Is this displayed or zero?
+ if (isInString($unit, $display) || (empty($display))) {
+ // @TODO <label for="' . $prefix . '_' . $field . '"></<label> not working here
+ $OUT .= '<td align="center" class="timebox_column bottom"><div class="tiny">{--TIME_UNIT_' . $units['unit_label'][$unit] . '--}</div></td>';
+ } // END - if
+ } // END - foreach
+ // Close table row and open new one
$OUT .= '</tr>';
$OUT .= '<tr>';
- if (isInString('Y', $display) || (empty($display))) {
- // Generate year selection
- $OUT .= '<td align="center"><select class="mini_select" name="' . $prefix . '_ye" size="1">';
- for ($idx = 0; $idx <= 10; $idx++) {
- $OUT .= '<option class="mini_select" value="' . $idx . '"';
- if ($idx == $Y) $OUT .= ' selected="selected"';
- $OUT .= '>' . $idx . '</option>';
- } // END - for
- $OUT .= '</select></td>';
- } else {
- $OUT .= '<input type="hidden" name="' . $prefix . '_ye" value="0" />';
- }
-
- if (isInString('M', $display) || (empty($display))) {
- // Generate month selection
- $OUT .= '<td align="center"><select class="mini_select" name="' . $prefix . '_mo" size="1">';
- for ($idx = 0; $idx <= 11; $idx++) {
- $OUT .= ' <option class="mini_select" value="' . $idx . '"';
- if ($idx == $M) $OUT .= ' selected="selected"';
- $OUT .= '>' . $idx . '</option>';
- } // END - for
- $OUT .= '</select></td>';
- } else {
- $OUT .= '<input type="hidden" name="' . $prefix . '_mo" value="0" />';
- }
-
- if (isInString('W', $display) || (empty($display))) {
- // Generate week selection
- $OUT .= '<td align="center"><select class="mini_select" name="' . $prefix . '_we" size="1">';
- for ($idx = 0; $idx <= 4; $idx++) {
- $OUT .= ' <option class="mini_select" value="' . $idx . '"';
- if ($idx == $W) $OUT .= ' selected="selected"';
- $OUT .= '>' . $idx . '</option>';
- } // END - for
- $OUT .= '</select></td>';
- } else {
- $OUT .= '<input type="hidden" name="' . $prefix . '_we" value="0" />';
- }
-
- if (isInString('D', $display) || (empty($display))) {
- // Generate day selection
- $OUT .= '<td align="center"><select class="mini_select" name="' . $prefix . '_da" size="1">';
- for ($idx = 0; $idx <= 31; $idx++) {
- $OUT .= ' <option class="mini_select" value="' . $idx . '"';
- if ($idx == $D) $OUT .= ' selected="selected"';
- $OUT .= '>' . $idx . '</option>';
- } // END - for
- $OUT .= '</select></td>';
- } else {
- $OUT .= '<input type="hidden" name="' . $prefix . '_da" value="0" />';
- }
-
- if (isInString('h', $display) || (empty($display))) {
- // Generate hour selection
- $OUT .= '<td align="center"><select class="mini_select" name="' . $prefix . '_ho" size="1">';
- for ($idx = 0; $idx <= 23; $idx++) {
- $OUT .= ' <option class="mini_select" value="' . $idx . '"';
- if ($idx == $h) $OUT .= ' selected="selected"';
- $OUT .= '>' . $idx . '</option>';
- } // END - for
- $OUT .= '</select></td>';
- } else {
- $OUT .= '<input type="hidden" name="' . $prefix . '_ho" value="0" />';
- }
-
- if (isInString('m', $display) || (empty($display))) {
- // Generate minute selection
- $OUT .= '<td align="center"><select class="mini_select" name="' . $prefix . '_mi" size="1">';
- for ($idx = 0; $idx <= 59; $idx++) {
- $OUT .= ' <option class="mini_select" value="' . $idx . '"';
- if ($idx == $m) $OUT .= ' selected="selected"';
- $OUT .= '>' . $idx . '</option>';
- } // END - for
- $OUT .= '</select></td>';
- } else {
- $OUT .= '<input type="hidden" name="' . $prefix . '_mi" value="0" />';
- }
+ // "Walk" through all units again
+ foreach ($units['unit_field'] as $unit => $field) {
+ // Is this used?
+ if (isInString($unit, $display) || (empty($display))) {
+ // Generate year selection
+ $OUT .= '<td align="center">';
+ $OUT .= addSelectionBox($field, $data[$unit], $prefix, NULL, 'mini_select');
+ $OUT .= '</td>';
+ } else {
+ $OUT .= '<input type="hidden" name="' . $prefix . '_' . $field . '" value="0" />';
+ }
+ } // END - foreach
- if (isInString('s', $display) || (empty($display))) {
- // Generate second selection
- $OUT .= '<td align="center"><select class="mini_select" name="' . $prefix . '_se" size="1">';
- for ($idx = 0; $idx <= 59; $idx++) {
- $OUT .= ' <option class="mini_select" value="' . $idx . '"';
- if ($idx == $s) $OUT .= ' selected="selected"';
- $OUT .= '>' . $idx . '</option>';
- } // END - for
- $OUT .= '</select></td>';
- } else {
- $OUT .= '<input type="hidden" name="' . $prefix . '_se" value="0" />';
- }
+ // Close all tags
$OUT .= '</tr>';
$OUT .= '</table>';
$OUT .= '</div>';
}
- // Return generated HTML code
+ // Return generated HTML code or data array
return $OUT;
}
* functionality like logging and admin notification (which you can configure
* through your admin area).
*
- * @param $F Function or file basename where the error came from
- * @param $L Line number where the error came from
+ * @param $file Function or file basename where the error came from
+ * @param $line Line number where the error came from
* @param $message Message which shall be output to web
* @return void
*/
-function app_exit ($F, $L, $message) {
+function app_exit ($file, $line, $message) {
// Check if Script is already dieing and not let it kill itself another 1000 times
if (isset($GLOBALS['app_died'])) {
// Script tried to kill itself twice
- die('[' . __FUNCTION__ . ':' . __LINE__ . ']: Script wanted to kill itself more than once! Raw message=' . $message . ', file/function=' . $F . ', line=' . $L);
+ die('[' . __FUNCTION__ . ':' . __LINE__ . ']: Script wanted to kill itself more than once! Raw message=' . $message . ', file/function=' . $file . ', line=' . $line);
} // END - if
// Make sure, that the script realy realy diese here and now
// Rewrite message for output
$message = sprintf(
getMessage('MAILER_HAS_DIED'),
- basename($F),
- $L,
+ basename($file),
+ $line,
$message
);
// Load the template
$GLOBALS['__page_footer'] .= loadTemplate('show_timings', TRUE, $content);
+
+ // Is debug enabled?
+ if (isDebugModeEnabled()) {
+ // Log loading of total includes
+ //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Loaded includes: ' . count($GLOBALS['inc_loaded']) . ', readable files: ' . count($GLOBALS['file_readable']));
+ } // END - if
}
/**
* app_exit() is more a "private" function and will only output a bug message to
* the user, no email and no logging.
*
- * @param $F Function or file basename where the error came from
- * @param $L Line number where the error came from
+ * @param $file Function or file basename where the error came from
+ * @param $line Line number where the error came from
* @param $sendEmail Wether to send an email to all configured administrators
* @return void
*/
-function reportBug ($F, $L, $message = '', $sendEmail = TRUE) {
+function reportBug ($file, $line, $message = '', $sendEmail = TRUE) {
// Is this already called?
if (isset($GLOBALS[__FUNCTION__])) {
// Other backtrace
- print '[' . $F . ':' . $L . ':] ' . __FUNCTION__ . ' has already died! Message:' . $message . '<br />Backtrace:<pre>';
+ print '[' . $file . ':' . $line . ':] ' . __FUNCTION__ . '() has already died! Message:' . $message . '<br />Backtrace:<pre>';
debug_print_backtrace();
die('</pre>');
} // END - if
);
// @TODO Add a little more infos here
- logDebugMessage($F, $L, strip_tags($message));
+ logDebugMessage($file, $line, strip_tags($message));
} // END - if
// Add output
$debug .= '<div class="para">Thank you for finding bugs.</div>';
// Send an email? (e.g. not wanted for evaluation errors)
- if (($sendEmail === TRUE) && (!isInstallationPhase())) {
+ if (($sendEmail === TRUE) && (!isInstaller()) && (isAdminRegistered())) {
// Prepare content
$content = array(
'message' => trim($message),
sendAdminNotification('{--REPORT_BUG_SUBJECT--}', 'admin_report_bug', $content);
} // END - if
- // Is there HTML/CSS/AJAX mode?
- if ((isHtmlOutputMode()) || (isCssOutputMode()) || (isAjaxOutputMode())) {
+ // Is there HTML/CSS/AJAX mode while debug-mode is enabled?
+ if ((isDebugModeEnabled()) && ((isHtmlOutputMode()) || (isCssOutputMode()) || (isAjaxOutputMode()))) {
// And abort here
- app_exit($F, $L, $debug);
+ app_exit($file, $line, $debug);
+ } elseif (isAjaxOutputMode()) {
+ // Load include (again?)
+ loadIncludeOnce('inc/ajax-functions.php');
+
+ // Init AJAX
+ initAjax();
+
+ // Set HTTP status to 500 again
+ setHttpStatus('500 Internal Server Error');
+
+ // Is AJAX output mode, then output message as JSON
+ setAjaxReplyContent($debug);
+
+ // Send it out to browser
+ sendAjaxContent(TRUE);
+
+ // Include footer
+ loadIncludeOnce('inc/footer.php');
} else {
// Raw/image output mode and all other modes doesn't work well with text ...
die();
}
// Print code with line numbers
-function linenumberCode ($code) {
+function lineNumberCode ($code) {
// By default copy the code
$codeE = $code;
$pageTitle = '';
// Config and database connection valid?
- if ((isConfigLocalLoaded()) && (isConfigurationLoaded()) && (SQL_IS_LINK_UP()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) {
+ if ((isConfigLocalLoaded()) && (isConfigurationLoaded()) && (isSqlLinkUp()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) {
// Title decoration enabled?
if ((isTitleDecorationEnabled()) && (getTitleLeft() != '')) {
$pageTitle .= '{%config,trim=title_left%} ';
return loadTemplate('admin_settings_saved', $return, $message);
}
+// Displays given error message in admin_settings_saved template
+function displayErrorMessage ($message, $return = FALSE) {
+ // Load the template
+ return loadTemplate('admin_settings_unsaved', $return, $message);
+}
+
// Generates a selection box for (maybe) given gender
function generateGenderSelectionBox ($selectedGender = '', $fieldName = 'gender') {
// Start the HTML code
return $OUT;
}
+// Tries to anonymize some sensitive data (e.g. IP address, user agent, referrer, etc.)
+function anonymizeSensitiveData ($data) {
+ // Trim it
+ $data = trim($data);
+
+ // Is it empty?
+ if (empty($data)) {
+ // Then add three dashes
+ $data = '---';
+ } elseif (isUrlValid($data)) {
+ // Is a referrer, so is it black-listed?
+ if (isAdmin()) {
+ // Is admin, has always priority
+ $data = '[<a href="{%pipe,generateFrametesterUrl=' . $data . '%}" target="_blank">{--ADMIN_TEST_URL--}</a>]';
+ } elseif ((isExtensionActive('blacklist')) && (isUrlBlacklisted($data))) {
+ // Yes, so replace it with text
+ $data = '<em>{--URL_IS_BLACKLISTED--}</em>';
+ } else {
+ // A member is viewing this referral URL
+ $data = '[<a href="{%pipe,generateDereferrerUrl=' . $data . '%}" target="_blank">{--MEMBER_TEST_URL--}</a>]';
+ }
+ } elseif (isIp4AddressValid($data)) {
+ // Is an IPv4 address
+ $ipArray = explode('.', $data);
+
+ // Only display first 2 octets
+ $data = $ipArray[0] . '.' . $ipArray[1] . '.?.?';
+ } else {
+ // Generic data
+ $data = '<em>{--DATA_IS_HIDDEN--}</em>';
+ }
+
+ // Return it (hopefully) anonymized
+ return $data;
+}
+
+/**
+ * Removes all comments, tabs and new-line characters to compact the content
+ *
+ * @param $uncompactedContent The uncompacted content
+ * @return $compactedContent The compacted content
+ */
+function compactContent ($uncompactedContent) {
+ // First, remove all tab/new-line/revert characters
+ $compactedContent = str_replace(chr(9), '', str_replace(PHP_EOL, '', str_replace(chr(13), '', $uncompactedContent)));
+
+ // Make a space after >
+ $compactedContent = str_replace(array('>', ' '), array('> ', ' '), $compactedContent);
+
+ // Then regex all comments like <!-- //--> away
+ preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $compactedContent, $matches);
+
+ // Do we have entries?
+ if (isset($matches[0][0])) {
+ // Remove all
+ foreach ($matches[0] as $match) {
+ // Remove the match
+ $compactedContent = str_replace($match, '', $compactedContent);
+ } // END - foreach
+ } // END - if
+
+ // Return compacted content
+ return $compactedContent;
+}
+
//-----------------------------------------------------------------------------
// Template helper functions for EL code
//-----------------------------------------------------------------------------
$OUT = '<span title="{--ADMIN_EXTENSION_IS_DEPRECATED_TITLE--}">---</span>';
} elseif (isExtensionProductive($ext_name)) {
// Productive code
- $OUT = '<a title="{--ADMIN_REGISTER_EXTENSION_TITLE--}" href="{%url=modules.php?module=admin&what=extensions&register_ext=' . $ext_name . '%}">{--ADMIN_REGISTER_EXTENSION--}</a>';
+ $OUT = '<a title="{--ADMIN_TASK_REGISTER_EXTENSION_TITLE--}" href="{%url=modules.php?module=admin&what=extensions&register_ext=' . $ext_name . '%}">{--ADMIN_TASK_REGISTER_EXTENSION--}</a>';
}
// Return code
// Helper function to create bonus mail admin links
function doTemplateAdminBonusMailLinks ($templateName, $clear, $bonusId) {
// Call the inner function
- return generateAdminMailLinks('bid', $bonusId);
+ return generateAdminMailLinks('bonus', $bonusId);
}
// Helper function to create member mail admin links
function doTemplateAdminMemberMailLinks ($templateName, $clear, $mailId) {
// Call the inner function
- return generateAdminMailLinks('mid', $mailId);
+ return generateAdminMailLinks('normal', $mailId);
}
// Helper function to create a selection box for YES/NO configuration entries
return fixEmptyContentToDashes($url);
}
-// Tries to anonymize some sensitive data (e.g. IP address, user agent, referrer, etc.)
-function anonymizeSensitiveData ($data) {
- // Trim it
- $data = trim($data);
+// Load another template and return its content
+function doTemplateLoadTemplate ($templateName, $clear = FALSE, $theTemplate, $content = array()) {
+ // Load "the" template
+ return loadTemplate($theTemplate, TRUE, $content);
+}
- // Is it empty?
- if (empty($data)) {
- // Then add three dashes
- $data = '---';
- } elseif (isUrlValid($data)) {
- // Is a referrer, so is it black-listed?
- if (isAdmin()) {
- // Is admin, has always priority
- $data = '[<a href="{%pipe,generateFrametesterUrl=' . $data . '%}" target="_blank">{--ADMIN_TEST_URL--}</a>]';
- } elseif (isUrlBlacklisted($data)) {
- // Yes, so replace it with text
- $data = '<em>{--URL_IS_BLACKLISTED--}</em>';
- } else {
- // A member is viewing this referral URL
- $data = '[<a href="{%pipe,generateDereferrerUrl=' . $data . '%}" target="_blank">{--MEMBER_TEST_URL--}</a>]';
- }
- } elseif (isIp4AddressValid($data)) {
- // Is an IPv4 address
- $ipArray = explode('.', $data);
+// Output HTML code for favicon.ico, if found
+function doTemplateMetaFavIcon ($templateName, $clear = FALSE) {
+ // Default is not found
+ $out = '';
- // Only display first 2 octets
- $data = $ipArray[0] . '.' . $ipArray[1] . '.?.?';
- } else {
- // Generic data
- $data = '<em>{--DATA_IS_HIDDEN--}</em>';
- }
+ // Check all common extensions
+ foreach (array('ico', 'gif', 'png') as $extension) {
+ // Is the file there?
+ if (isFileReadable(getPath() . 'favicon.' . $extension)) {
+ // Then use this and abort
+ $out = '<link rel="shortcut icon" href="{%url=favicon.' . $extension . '%}" type="image/' . $extension . '" />';
+ break;
+ } // END - if
+ } // END - while
- // Return it (hopefully) anonymized
- return $data;
+ // Return code
+ return $out;
}
-/**
- * Removes all commentd, tabs and new-line characters to compact the content
- *
- * @param $uncompactedContent The uncompacted content
- * @return $compactedContent The compacted content
- */
-function compactContent ($uncompactedContent) {
- // First, remove all tab/new-line/revert characters
- $compactedContent = str_replace(chr(9), '', str_replace(PHP_EOL, '', str_replace(chr(13), '', $uncompactedContent)));
-
- // Then regex all comments like <!-- //--> away
- preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $compactedContent, $matches);
-
- // Do we have entries?
- if (isset($matches[0][0])) {
- // Remove all
- foreach ($matches[0] as $match) {
- // Remove the match
- $compactedContent = str_replace($match, '', $compactedContent);
- } // END - foreach
+// "Getter" for template base path
+function getTemplateBasePath ($part) {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__][$part])) {
+ // "Build" path
+ $GLOBALS[__FUNCTION__][$part] = sprintf('%stemplates/%s/%s', getPath(), getLanguage(), $part);
} // END - if
- // Set the content again
- // @TODO Is this needed for e.g. $GLOBALS['template_content'] ? $this->setRawTemplateData($compactedContent);
-
- // Return compacted content
- return $compactedContent;
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$part];
}
// [EOF]