X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=2d4fcf45df00abd20358f9515859241ca8e889f6;hb=247435718942b91af153c729c0347be3af1fecf9;hp=e50b598ef3d220c6d14fcbba8174b886635ce4cc;hpb=fe1bba9b9c61a08d4f3eda0019012ec033a98719;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index e50b598ef3..2d4fcf45df 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -636,12 +636,12 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' if (empty($isHtml)) $isHtml = 'N'; if (isDebugModeEnabled()) { // In debug mode we want to display the mail instead of sending it away so we can debug this part - outputHtml("
-".htmlentities(trim($mailHeader))." -To : " . $toEmail." -Subject : " . $subject." -Message : " . $message." -\n"); + outputHtml('
+Headers : ' . htmlentities(trim($mailHeader)) . ' +To : ' . $toEmail . ' +Subject : ' . $subject . ' +Message : ' . $message . ' +'); } elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) { // Send mail as HTML away sendHtmlEmail($toEmail, $subject, $message, $mailHeader); @@ -1742,10 +1742,25 @@ function extractHostnameFromUrl (&$script) { } // Send a GET request -function sendGetRequest ($script) { +function sendGetRequest ($script, $data = array()) { // Extract host name from script $host = extractHostnameFromUrl($script); + // Add data + $scriptData = http_build_query($data, '', '&'); + + // Do we have a question-mark in the script? + if (strpos($script, '?') === false) { + // No, so first char must be question mark + $scriptData = '?' . $scriptData; + } else { + // Ok, add & + $scriptData = '&' . $scriptData; + } + + // Add script data + $script .= $scriptData; + // Generate GET request header $request = 'GET /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL'); $request .= 'Host: ' . $host . getConfig('HTTP_EOL'); @@ -1782,7 +1797,7 @@ function sendPostRequest ($script, $postData) { $host = extractHostnameFromUrl($script); // Construct request - $data = http_build_query($postData, '','&'); + $data = http_build_query($postData, '', '&'); // Generate POST request header $request = 'POST /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL'); @@ -3561,5 +3576,29 @@ if (!function_exists('html_entity_decode')) { } } // END - if +if (!function_exists('http_build_query')) { + // Taken from documentation on www.php.net, credits to Marco K. (Germany) + function http_build_query($data, $prefix='', $sep='', $key='') { + $ret = array(); + foreach ((array)$data as $k => $v) { + if (is_int($k) && $prefix != null) { + $k = urlencode($prefix . $k); + } // END - if + + if ((!empty($key)) || ($key === 0)) $k = $key.'['.urlencode($k).']'; + + if (is_array($v) || is_object($v)) { + array_push($ret, http_build_query($v, '', $sep, $k)); + } else { + array_push($ret, $k.'='.urlencode($v)); + } + } // END - foreach + + if (empty($sep)) $sep = ini_get('arg_separator.output'); + + return implode($sep, $ret); + } +}// // END - if + // [EOF] ?>