$GLOBALS['fatal_messages'][] = $message;
// Log fatal messages away
- debug_report_bug($message);
logDebugMessage($F, $L, 'Fatal error message: ' . $message);
}
// Do we have to compile the code?
$ret = '';
- if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (strpos($GLOBALS['tpl_content'], '{--') !== false) || (strpos($GLOBALS['tpl_content'], '{!') !== false) || (strpos($GLOBALS['tpl_content'], '{?') !== false)) {
+ if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (strpos($GLOBALS['tpl_content'], '{--') !== false) || (strpos($GLOBALS['tpl_content'], '{!') !== false) || (strpos($GLOBALS['tpl_content'], '{?') !== false) || (strpos($GLOBALS['tpl_content'], '{%') !== false)) {
// Normal HTML output?
if (getOutputMode() == '0') {
// Add surrounding HTML comments to help finding bugs faster
// Is content an array?
if (is_array($content)) {
// Add expiration to array
- if (getConfig('auto_purge') == '0') {
+ if ((isConfigEntrySet('auto_purge')) && (getConfig('auto_purge') == '0')) {
// Will never expire!
$content['expiration'] = getMessage('MAIL_WILL_NEVER_EXPIRE');
- } else {
+ } elseif (isConfigEntrySet('auto_purge')) {
// Create nice date string
$content['expiration'] = createFancyTime(getConfig('auto_purge'));
+ } else {
+ // Missing entry
+ $content['expiration'] = getMessage('MAIL_NO_CONFIG_AUTO_PURGE');
}
} // END - if
if (isDebugModeEnabled()) {
// In debug mode we want to display the mail instead of sending it away so we can debug this part
outputHtml('<pre>
-Headers : ' . htmlentities(trim($mailHeader)) . '
-To : ' . htmlentities($toEmail) . '
-Subject : ' . htmlentities($subject) . '
-Message : ' . htmlentities($message) . '
+Headers : ' . htmlentities(utf8_decode(trim($mailHeader))) . '
+To : ' . htmlentities(utf8_decode($toEmail)) . '
+Subject : ' . htmlentities(utf8_decode($subject)) . '
+Message : ' . htmlentities(utf8_decode($message)) . '
</pre>');
} elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) {
// Send mail as HTML away
}
// Create selection box or array of splitted timestamp
function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $return_array=false) {
+ // Do not continue if ONE_DAY is absend
+ if (!isConfigEntrySet('ONE_DAY')) {
+ // And return the timestamp itself or empty array
+ if ($return_array === true) {
+ return array();
+ } else {
+ return $timestamp;
+ }
+ } // END - if
+
// Calculate 2-seconds timestamp
$stamp = round($timestamp);
//* DEBUG: */ print("*" . $stamp.'/' . $timestamp."*<br />");
// Add script data
$script .= $body;
+ // Remove trailed & to make it more conform
+ if (substr($script, -1, 1) == '&') $script = substr($script, 0, -1);
+
// Generate GET request header
$request = 'GET /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL');
$request .= 'Host: ' . $host . getConfig('HTTP_EOL');
$request .= 'Cache-Control: no-cache' . getConfig('HTTP_EOL');
$request .= 'Content-Type: text/plain' . getConfig('HTTP_EOL');
$request .= 'Content-Length: '.strlen($body) . getConfig('HTTP_EOL');
- $request .= 'Connection: Close' . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
+ $request .= 'Connection: close' . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
// Send the raw request
$response = sendRawRequest($host, $request);
$request .= 'User-Agent: ' . getConfig('TITLE') . '/' . getConfig('FULL_VERSION') . getConfig('HTTP_EOL');
$request .= 'Cache-Control: no-cache' . getConfig('HTTP_EOL');
$request .= 'Content-Type: application/x-www-form-urlencoded' . getConfig('HTTP_EOL');
- $request .= 'Connection: Close' . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
+ $request .= 'Connection: close' . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
$request .= $body;
// Send the raw request
//* DEBUG: */ die("SCRIPT=" . $script.'<br />');
if ($useProxy === true) {
// Connect to host through proxy connection
- $fp = @fsockopen(compileRawCode(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
+ $fp = fsockopen(compileRawCode(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
} else {
// Connect to host directly
- $fp = @fsockopen($host, 80, $errno, $errdesc, 30);
+ $fp = fsockopen($host, 80, $errno, $errdesc, 30);
}
// Is there a link?
if (!is_resource($fp)) {
// Failed!
+ logDebugMessage(__FUNCTION__, __LINE__, $errdesc . ' (' . $errno . ')');
return $response;
- } // END - if
+ } elseif ((!stream_set_blocking($fp, 0)) || (!stream_set_timeout($fp, 1))) {
+ // Cannot set non-blocking mode or timeout
+ logDebugMessage(__FUNCTION__, __LINE__, socket_strerror(socket_last_error()));
+ return $response;
+ }
// Do we use proxy?
if ($useProxy === true) {
//* DEBUG: */ print('<strong>proxyTunnel=</strong><pre>' . $proxyTunnel.'</pre>');
// Write request
- fputs($fp, $proxyTunnel);
+ fwrite($fp, $proxyTunnel);
// Got response?
if (feof($fp)) {
} // END - if
// Write request
- fputs($fp, $request);
+ fwrite($fp, $request);
+
+ // Start counting
+ $start = microtime(true);
// Read response
while (!feof($fp)) {
- $response[] = trim(fgets($fp, 1024));
+ // Get info from stream
+ $info = stream_get_meta_data($fp);
+
+ // Is it timed out? 15 seconds is a really patient...
+ if (($info['timed_out'] == true) || (microtime(true) - $start) > 15) {
+ // Timeout
+ logDebugMessage(__FUNCTION__, __LINE__, 'Timed out to get data from host ' . $host);
+
+ // Abort here
+ break;
+ } // END - if
+
+ // Get line from stream
+ $line = fgets($fp, 128);
+
+ // Ignore empty lines because of non-blocking mode
+ if (empty($line)) {
+ // uslepp a little to avoid 100% CPU load
+ usleep(10);
+
+ // Skip this
+ continue;
+ } // END - if
+
+ // Add it to response
+ $response[] = trim($line);
} // END - while
// Close socket
//* DEBUG: */ print('<strong>Response:</strong><pre>'.print_r($response, true).'</pre>');
- // Proxy agent found?
- if ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy === true)) {
+ // Proxy agent found or something went wrong?
+ if (!isset($response[0])) {
+ // No response, maybe timeout
+ $response = array('', '', '');
+ } elseif ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy === true)) {
// Proxy header detected, so remove two lines
array_shift($response);
array_shift($response);
$scrambleNums = explode(':', genScrambleString(strlen($str)));
}
+ // Compare both lengths and abort if different
+ if (strlen($str) != count($scrambleNums)) return $str;
+
// Scramble string here
//* DEBUG: */ outputHtml('***Original=' . $str.'***<br />');
for ($idx = '0'; $idx < strlen($str); $idx++) {
$debug .= "Thank you for finding bugs.";
// Send an email? (e.g. not wanted for evaluation errors)
- if ($sendEmail === true) {
+ if (($sendEmail === true) && (!isInstallationPhase())) {
// Prepare content
$content = array(
'message' => trim($message),
} // END - if
// Write to temp file
- fputs($fp_tmp, $line);
+ fwrite($fp_tmp, $line);
} // END - while
// Close temp file
// Call the filter chain 'shutdown'
runFilterChain('shutdown', null);
- if (SQL_IS_LINK_UP()) {
+ // Check if not in installation phase and the link is up
+ if ((!isInstallationPhase()) && (SQL_IS_LINK_UP())) {
// Close link
SQL_CLOSE(__FILE__, __LINE__);
} elseif (!isInstallationPhase()) {
if (strpos($url, session_name()) !== false) return $url;
// Do we have a valid session?
- if ((($GLOBALS['valid_session'] === false) || (!isset($_COOKIE[session_name()]))) && (isSpider() === false)) {
+ if (((!isset($GLOBALS['valid_session'])) || ($GLOBALS['valid_session'] === false) || (!isset($_COOKIE[session_name()]))) && (isSpider() === false)) {
// Invalid session
// Determine right seperator
$seperator = '&';