X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=d157a7ed00344842431105feecb76d2b92f85811;hp=2276a0f42b35d7aec9db2ec014aa7ab8926f6c53;hb=48b997e125d13e5184281449feb9f4c8caf48e56;hpb=5071030af40e69ca4284642f44758964e18f5be8 diff --git a/inc/functions.php b/inc/functions.php index 2276a0f42b..d157a7ed00 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -905,7 +905,7 @@ function redirectToUrl ($URL) { } // END - if // Three different debug ways... - /* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL)); + //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL)); //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, $URL); //* DEBUG: */ die($URL); @@ -1216,7 +1216,7 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') { // Deprecated : $length // Optional : $DATA // -function generateRandomCodde ($length, $code, $uid, $DATA = '') { +function generateRandomCode ($length, $code, $uid, $DATA = '') { // Fix missing _MAX constant // @TODO Rewrite this unnice code if (!defined('_MAX')) define('_MAX', 15235); @@ -1715,7 +1715,7 @@ function extractHostnameFromUrl (&$script) { $url = constant('SERVER_URL'); // Is this URL valid? - if (substr($script, 0, 7) == "http://") { + if (substr($script, 0, 7) == 'http://') { // Use the hostname from script URL as new hostname $url = substr($script, 7); $extract = explode('/', $url); @@ -1724,12 +1724,12 @@ function extractHostnameFromUrl (&$script) { } // END - if // Extract host name - $host = str_replace("http://", '', $url); + $host = str_replace('http://', '', $url); if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/')); // Generate relative URL //* DEBUG: */ print("SCRIPT=".$script."
\n"); - if (substr(strtolower($script), 0, 7) == "http://") { + if (substr(strtolower($script), 0, 7) == 'http://') { // But only if http:// is in front! $script = substr($script, (strlen($url) + 7)); } elseif (substr(strtolower($script), 0, 8) == "https://") { @@ -1753,17 +1753,17 @@ function sendGetRequest ($script) { $host = extractHostnameFromUrl($script); // Generate GET request header - $request = "GET /" . trim($script) . " HTTP/1.1\r\n"; - $request .= "Host: " . $host . "\r\n"; - $request .= "Referer: " . constant('URL') . "/admin.php\r\n"; + $request = "GET /" . trim($script) . " HTTP/1.1" . getConfig('HTTP_EOL'); + $request .= "Host: " . $host . getConfig('HTTP_EOL'); + $request .= "Referer: " . constant('URL') . "/admin.php" . getConfig('HTTP_EOL'); if (defined('FULL_VERSION')) { - $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . "\r\n"; + $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . getConfig('HTTP_EOL'); } else { - $request .= "User-Agent: " . constant('TITLE') . "/?.?.?\r\n"; + $request .= "User-Agent: " . constant('TITLE') . "/?.?.?" . getConfig('HTTP_EOL'); } - $request .= "Content-Type: text/plain\r\n"; - $request .= "Cache-Control: no-cache\r\n"; - $request .= "Connection: Close\r\n\r\n"; + $request .= "Content-Type: text/plain" . getConfig('HTTP_EOL'); + $request .= "Cache-Control: no-cache" . getConfig('HTTP_EOL'); + $request .= "Connection: Close" . getConfig('HTTP_EOL') . getConfig('HTTP_EOL'); // Send the raw request $response = sendRawRequest($host, $request); @@ -1791,14 +1791,14 @@ function sendPostRequest ($script, $postData) { $data = http_build_query($postData, '','&'); // Generate POST request header - $request = "POST /" . trim($script) . " HTTP/1.1\r\n"; - $request .= "Host: " . $host . "\r\n"; - $request .= "Referer: " . constant('URL') . "/admin.php\r\n"; - $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . "\r\n"; - $request .= "Content-type: application/x-www-form-urlencoded\r\n"; - $request .= "Content-length: " . strlen($data) . "\r\n"; - $request .= "Cache-Control: no-cache\r\n"; - $request .= "Connection: Close\r\n\r\n"; + $request = "POST /" . trim($script) . " HTTP/1.1" . getConfig('HTTP_EOL'); + $request .= "Host: " . $host . getConfig('HTTP_EOL'); + $request .= "Referer: " . constant('URL') . "/admin.php" . getConfig('HTTP_EOL'); + $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . getConfig('HTTP_EOL'); + $request .= "Content-type: application/x-www-form-urlencoded" . getConfig('HTTP_EOL'); + $request .= "Content-length: " . strlen($data) . getConfig('HTTP_EOL'); + $request .= "Cache-Control: no-cache" . getConfig('HTTP_EOL'); + $request .= "Connection: Close" . getConfig('HTTP_EOL') . getConfig('HTTP_EOL'); $request .= $data; // Send the raw request @@ -1810,6 +1810,9 @@ function sendPostRequest ($script, $postData) { // Sends a raw request to another host function sendRawRequest ($host, $request) { + // Init errno and errdesc with 'all fine' values + $errno = 0; $errdesc = ''; + // Initialize array $response = array('', '', ''); @@ -1824,9 +1827,11 @@ function sendRawRequest ($host, $request) { // Open connection //* DEBUG: */ die("SCRIPT=".$script."
\n"); - if ($useProxy) { - $fp = @fsockopen(COMPILE_CODE(getConfig('proxy_host')), getConfig('proxy_port'), $errno, $errdesc, 30); + if ($useProxy === true) { + // Connect to host through proxy connection + $fp = @fsockopen(COMPILE_CODE(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30); } else { + // Connect to host directly $fp = @fsockopen($host, 80, $errno, $errdesc, 30); } @@ -1837,20 +1842,20 @@ function sendRawRequest ($host, $request) { } // END - if // Do we use proxy? - if ($useProxy) { + if ($useProxy === true) { // Generate CONNECT request header - $proxyTunnel = "CONNECT ".$host.":80 HTTP/1.1\r\n"; - $proxyTunnel .= "Host: ".$host."\r\n"; + $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(COMPILE_CODE(getConfig('proxy_username')).getConfig('ENCRYPT_SEPERATOR').COMPILE_CODE(getConfig('proxy_password'))); - $proxyTunnel .= "Proxy-Authorization: Basic ".$encodedAuth."\r\n"; + $encodedAuth = base64_encode(COMPILE_CODE(getConfig('proxy_username')) . getConfig('ENCRYPT_SEPERATOR') . COMPILE_CODE(getConfig('proxy_password'))); + $proxyTunnel .= "Proxy-Authorization: Basic " . $encodedAuth . getConfig('HTTP_EOL'); } // END - if // Add last new-line - $proxyTunnel .= "\r\n"; + $proxyTunnel .= getConfig('HTTP_EOL'); //* DEBUG: */ print("proxyTunnel=
".$proxyTunnel."
"); // Write request @@ -1901,7 +1906,7 @@ function sendRawRequest ($host, $request) { //* DEBUG: */ print("Response:
".print_r($response, true)."
"); // Proxy agent found? - if ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy)) { + if ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy === true)) { // Proxy header detected, so remove two lines array_shift($response); array_shift($response); @@ -2611,7 +2616,7 @@ function debug_report_bug ($message = '') { } // END - if // Add output - $debug .= "Please report this bug at bugs.mxchange.org:
";
+	$debug .= "Please report this bug at bugs.mxchange.org and include the logfile from inc/cache/debug.log in your report (you cannot attach files!):
";
 	$debug .= debug_get_printable_backtrace();
 	$debug .= "
\nRequest-URI: ".$_SERVER['REQUEST_URI']."
\n"; $debug .= "Thank you for finding bugs."; @@ -2650,7 +2655,7 @@ function convertCodeToMessage ($code) { case getCode('EXTENSION_PROBLEM'): if (REQUEST_ISSET_GET('ext')) { - $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), REQUEST_GET('ext')); + $msg = generateExtensionInactiveMessage(REQUEST_GET('ext')); } else { $msg = getMessage('EXTENSION_PROBLEM_UNSET_EXT'); } @@ -3290,6 +3295,27 @@ function isExtraTitleSet () { return ((isset($GLOBALS['extra_title'])) && (!empty($GLOBALS['extra_title']))); } +// Generates a 'extension foo inactive' message +function generateExtensionInactiveMessage ($ext) { + // Is the extension empty? + if (empty($ext)) { + // This should not happen + trigger_error(__FUNCTION__ . ': Parameter ext is empty. This should not happen.'); + } // END - if + + // Default message + $msg = sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), $ext); + + // Is an admin logged in? + if (IS_ADMIN()) { + // Then output admin message + $msg = sprintf(getMessage('ADMIN_EXTENSION_PROBLEM_EXT_INACTIVE'), $ext); + } // END - if + + // Return prepared message + return $msg; +} + ////////////////////////////////////////////////// // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // //////////////////////////////////////////////////