$GLOBALS['tpl_content'] = readFromFile($FQFN);
// Run code
- $GLOBALS['tpl_content'] = "\$newContent = decodeEntities(\"".compileRawCode(escapeQuotes($GLOBALS['tpl_content']))."\");";
+ $GLOBALS['tpl_content'] = '$newContent = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['tpl_content'])) . '");';
eval($GLOBALS['tpl_content']);
} elseif (!empty($template)) {
// Template file not found!
eval("\$subject = decodeEntities(\"".compileRawCode(escapeQuotes($subject))."\");");
// Set from header
- if ((!eregi('@', $toEmail)) && ($toEmail > 0)) {
+ if ((!isInStringIgnoreCase('@', $toEmail)) && ($toEmail > 0)) {
// Value detected, is the message extension installed?
// @TODO Extension 'msg' does not exist
if (isExtensionActive('msg')) {
</pre>');
} elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) {
// Send mail as HTML away
- sendHtmlEmail($toEmail, $subject, $message, $mailHeader);
+ return sendHtmlEmail($toEmail, $subject, $message, $mailHeader);
} elseif (!empty($toEmail)) {
// Send Mail away
- sendRawEmail($toEmail, $subject, $message, $mailHeader);
+ return sendRawEmail($toEmail, $subject, $message, $mailHeader);
} elseif ($isHtml != 'Y') {
// Problem found!
- sendRawEmail(getConfig('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
+ return sendRawEmail(getConfig('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
}
}
$mail = new PHPMailer();
// Set charset to UTF-8
- $mail->CharSet('UTF-8');
+ $mail->CharSet = 'UTF-8';
// Path for PHPMailer
$mail->PluginDir = sprintf("%sinc/phpmailer/", getConfig('PATH'));
$mail->AddCustomHeader('Errors-To:' . getConfig('WEBMASTER'));
$mail->AddCustomHeader('X-Loop:' . getConfig('WEBMASTER'));
$mail->Send();
+
+ // Has an error occured?
+ if (!empty($mail->ErrorInfo)) {
+ // Log message
+ logDebugMessage(__FUNCTION__, __LINE__, 'Error while sending mail: ' . $mail->ErrorInfo);
+
+ // Raise an error
+ return false;
+ } else {
+ // All fine!
+ return true;
+ }
} else {
// Use legacy mail() command
- mail($toEmail, $subject, decodeEntities($message), $from);
+ return mail($toEmail, $subject, decodeEntities($message), $from);
}
}
$OUT .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"timebox_table dashed\">\n";
$OUT .= "<tr>\n";
- if (ereg('Y', $display) || (empty($display))) {
+ if (isInString('Y', $display) || (empty($display))) {
$OUT .= " <td align=\"center\" class=\"timebox_column bottom\"><div class=\"tiny\">{--_YEARS--}</strong></td>\n";
}
- if (ereg('M', $display) || (empty($display))) {
+ if (isInString('M', $display) || (empty($display))) {
$OUT .= " <td align=\"center\" class=\"timebox_column bottom\"><div class=\"tiny\">{--_MONTHS--}</strong></td>\n";
}
- if (ereg('W', $display) || (empty($display))) {
+ if (isInString('W', $display) || (empty($display))) {
$OUT .= " <td align=\"center\" class=\"timebox_column bottom\"><div class=\"tiny\">{--_WEEKS--}</strong></td>\n";
}
- if (ereg('D', $display) || (empty($display))) {
+ if (isInString('D', $display) || (empty($display))) {
$OUT .= " <td align=\"center\" class=\"timebox_column bottom\"><div class=\"tiny\">{--_DAYS--}</strong></td>\n";
}
- if (ereg('h', $display) || (empty($display))) {
+ if (isInString('h', $display) || (empty($display))) {
$OUT .= " <td align=\"center\" class=\"timebox_column bottom\"><div class=\"tiny\">{--_HOURS--}</strong></td>\n";
}
- if (ereg('m', $display) || (empty($display))) {
+ if (isInString('m', $display) || (empty($display))) {
$OUT .= " <td align=\"center\" class=\"timebox_column bottom\"><div class=\"tiny\">{--_MINUTES--}</strong></td>\n";
}
- if (ereg('s', $display) || (empty($display))) {
+ if (isInString('s', $display) || (empty($display))) {
$OUT .= " <td align=\"center\" class=\"timebox_column bottom\"><div class=\"tiny\">{--_SECONDS--}</strong></td>\n";
}
$OUT .= "</tr>\n";
$OUT .= "<tr>\n";
- if (ereg('Y', $display) || (empty($display))) {
+ if (isInString('Y', $display) || (empty($display))) {
// Generate year selection
$OUT .= " <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix . "_ye\" size=\"1\">\n";
for ($idx = '0'; $idx <= 10; $idx++) {
$OUT .= '<input type="hidden" name="' . $prefix . '_ye" value="0" />';
}
- if (ereg('M', $display) || (empty($display))) {
+ if (isInString('M', $display) || (empty($display))) {
// Generate month selection
$OUT .= " <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix . "_mo\" size=\"1\">\n";
for ($idx = '0'; $idx <= 11; $idx++)
$OUT .= '<input type="hidden" name="' . $prefix . '_mo" value="0" />';
}
- if (ereg('W', $display) || (empty($display))) {
+ if (isInString('W', $display) || (empty($display))) {
// Generate week selection
$OUT .= " <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix . "_we\" size=\"1\">\n";
for ($idx = '0'; $idx <= 4; $idx++) {
$OUT .= '<input type="hidden" name="' . $prefix . '_we" value="0" />';
}
- if (ereg('D', $display) || (empty($display))) {
+ if (isInString('D', $display) || (empty($display))) {
// Generate day selection
$OUT .= " <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix . "_da\" size=\"1\">\n";
for ($idx = '0'; $idx <= 31; $idx++) {
$OUT .= '<input type="hidden" name="' . $prefix . '_da" value="0" />';
}
- if (ereg('h', $display) || (empty($display))) {
+ if (isInString('h', $display) || (empty($display))) {
// Generate hour selection
$OUT .= " <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix . "_ho\" size=\"1\">\n";
for ($idx = '0'; $idx <= 23; $idx++) {
$OUT .= '<input type="hidden" name="' . $prefix . '_ho" value="0" />';
}
- if (ereg('m', $display) || (empty($display))) {
+ if (isInString('m', $display) || (empty($display))) {
// Generate minute selection
$OUT .= " <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix . "_mi\" size=\"1\">\n";
for ($idx = '0'; $idx <= 59; $idx++) {
$OUT .= '<input type="hidden" name="' . $prefix . '_mi" value="0" />';
}
- if (ereg('s', $display) || (empty($display))) {
+ if (isInString('s', $display) || (empty($display))) {
// Generate second selection
$OUT .= " <td align=\"center\"><select class=\"mini_select\" name=\"" . $prefix . "_se\" size=\"1\">\n";
for ($idx = '0'; $idx <= 59; $idx++) {
// Extract host name
$host = str_replace('http://', '', $url);
- if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/'));
+ if (isInString('/', $host)) $host = substr($host, 0, strpos($host, '/'));
// Generate relative URL
//* DEBUG: */ print("SCRIPT=" . $script.'<br />');
$useProxy = true;
} // END - if
+ // Load include
+ loadIncludeOnce('inc/classes/resolver.class.php');
+
+ // Get resolver instance
+ $resolver = new HostnameResolver();
+
// Open connection
//* DEBUG: */ die("SCRIPT=" . $script.'<br />');
if ($useProxy === true) {
+ // Resolve hostname into IP address
+ $ip = $resolver->resolveHostname(compileRawCode(getConfig('proxy_host')));
+
// Connect to host through proxy connection
- $fp = fsockopen(compileRawCode(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
+ $fp = fsockopen($ip, bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
} else {
+ // Resolve hostname into IP address
+ $ip = $resolver->resolveHostname($host);
+
// Connect to host directly
- $fp = fsockopen($host, 80, $errno, $errdesc, 30);
+ $fp = fsockopen($ip, 80, $errno, $errdesc, 30);
}
// Is there a link?
// Do we use proxy?
if ($useProxy === true) {
- // Generate CONNECT request header
- $proxyTunnel = 'CONNECT ' . $host . ':80 HTTP/1.1' . getConfig('HTTP_EOL');
- $proxyTunnel .= 'Host: ' . $host . getConfig('HTTP_EOL');
-
- // Use login data to proxy? (username at least!)
- if (getConfig('proxy_username') != '') {
- // Add it as well
- $encodedAuth = base64_encode(compileRawCode(getConfig('proxy_username')) . getConfig('ENCRYPT_SEPERATOR') . compileRawCode(getConfig('proxy_password')));
- $proxyTunnel .= 'Proxy-Authorization: Basic ' . $encodedAuth . getConfig('HTTP_EOL');
- } // END - if
-
- // Add last new-line
- $proxyTunnel .= getConfig('HTTP_EOL');
- //* DEBUG: */ print('<strong>proxyTunnel=</strong><pre>' . $proxyTunnel.'</pre>');
+ // Setup proxy tunnel
+ $response = setupProxyTunnel($host, $fp);
- // Write request
- fwrite($fp, $proxyTunnel);
-
- // Got response?
- if (feof($fp)) {
- // No response received
- return $response;
- } // END - if
-
- // Read the first line
- $resp = trim(fgets($fp, 10240));
- $respArray = explode(' ', $resp);
- if ((strtolower($respArray[0]) !== 'http/1.0') || ($respArray[1] != '200')) {
+ // If the response is invalid, abort
+ if ((count($response) == 3) && (empty($response[0])) && (empty($response[1])) && (empty($response[2]))) {
// Invalid response!
+ logDebugMessage(__FUNCTION__, __LINE__, 'Proxy tunnel not working?');
return $response;
} // END - if
} // END - if
// Time request if debug-mode is enabled
if (isDebugModeEnabled()) {
// Add debug message...
- logDebugMessage(__FUNCTION__, __LINE__, 'Request took ' . (microtime(true) - $start) . ' seconds.');
+ logDebugMessage(__FUNCTION__, __LINE__, 'Request took ' . (microtime(true) - $start) . ' seconds and returned ' . count($response) . ' line(s).');
} // END - if
// Skip first empty lines
if (!isset($response[0])) {
// No response, maybe timeout
$response = array('', '', '');
+ logDebugMessage(__FUNCTION__, __LINE__, 'Invalid empty response array, maybe timed out?');
} elseif ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy === true)) {
// Proxy header detected, so remove two lines
array_shift($response);
} // END - if
// Was the request successfull?
- if ((!eregi('200 OK', $response[0])) || (empty($response[0]))) {
+ if ((!isInStringIgnoreCase('200 OK', $response[0])) || (empty($response[0]))) {
// Not found / access forbidden
+ logDebugMessage(__FUNCTION__, __LINE__, 'Unexpected status code ' . $response[0] . ' detected. "200 OK" was expected.');
$response = array('', '', '');
} // END - if
return $response;
}
-// Taken from www.php.net eregi() user comments
+// Sets up a proxy tunnel for given hostname and through resource
+function setupProxyTunnel ($host, $resource) {
+ // Initialize array
+ $response = array('', '', '');
+
+ // Generate CONNECT request header
+ $proxyTunnel = 'CONNECT ' . $host . ':80 HTTP/1.1' . getConfig('HTTP_EOL');
+ $proxyTunnel .= 'Host: ' . $host . getConfig('HTTP_EOL');
+
+ // Use login data to proxy? (username at least!)
+ if (getConfig('proxy_username') != '') {
+ // Add it as well
+ $encodedAuth = base64_encode(compileRawCode(getConfig('proxy_username')) . ':' . compileRawCode(getConfig('proxy_password')));
+ $proxyTunnel .= 'Proxy-Authorization: Basic ' . $encodedAuth . getConfig('HTTP_EOL');
+ } // END - if
+
+ // Add last new-line
+ $proxyTunnel .= getConfig('HTTP_EOL');
+ //* DEBUG: */ print('<strong>proxyTunnel=</strong><pre>' . $proxyTunnel.'</pre>');
+
+ // Write request
+ fwrite($fp, $proxyTunnel);
+
+ // Got response?
+ if (feof($fp)) {
+ // No response received
+ return $response;
+ } // END - if
+
+ // Read the first line
+ $resp = trim(fgets($fp, 10240));
+ $respArray = explode(' ', $resp);
+ if ((strtolower($respArray[0]) !== 'http/1.0') || ($respArray[1] != '200')) {
+ // Invalid response!
+ return $response;
+ } // END - if
+
+ // All fine!
+ return $respArray;
+}
+
+// Taken from www.php.net isInStringIgnoreCase() user comments
function isEmailValid ($email) {
// Check first part of email address
$first = '[-a-z0-9!#$%&\'*+/=?^_<{|}~]+(\.[-a-zA-Z0-9!#$%&\'*+/=?^_<{|}~]+)*';
return preg_match($regex, $email);
}
-// Function taken from user comments on www.php.net / function eregi()
+// Function taken from user comments on www.php.net / function isInStringIgnoreCase()
function isUrlValid ($URL, $compile=true) {
// Trim URL a little
$URL = trim(urldecode($URL));
case getCode('MORE_RECEIVERS2') : $message = getMessage('MEMBER_NO_MORE_RECEIVERS_FOUND'); break;
case getCode('MORE_RECEIVERS3') : $message = getMessage('MEMBER_ENTER_MORE_MIN_RECEIVERS'); break;
case getCode('INVALID_URL') : $message = getMessage('MEMBER_ENTER_INVALID_URL'); break;
+ case getCode('NO_MAIL_TYPE') : $message = getMessage('MEMBER_NO_MAIL_TYPE_SELECTED'); break;
case getCode('UNKNOWN_ERROR') : $message = getMessage('LOGIN_UNKNOWN_ERROR'); break;
case getCode('UNKNOWN_STATUS') : $message = getMessage('LOGIN_UNKNOWN_STATUS'); break;
return $code;
}
-// Function taken from user comments on www.php.net / function eregi()
+// Function taken from user comments on www.php.net / function isInStringIgnoreCase()
function isUrlValidSimple ($url) {
// Prepare URL
$url = secureString(str_replace("\\", '', compileRawCode(urldecode($url))));
} // END - foreach
}
+// "Fixes" null or empty string to count of dashes
+function fixNullEmptyToDashes ($str, $num) {
+ // Use str as default
+ $return = $str;
+
+ // Is it empty?
+ if ((is_null($str)) || (trim($str) == '')) {
+ // Set it
+ $return = str_repeat('-', $num);
+ } // END - if
+
+ // Return final string
+ return $return;
+}
+
//////////////////////////////////////////////////
// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
//////////////////////////////////////////////////