From 41e31ab387869735b99fa7b288039bf3775ad455 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 27 Aug 2011 02:43:24 +0000 Subject: [PATCH] Added function sendHttpRequest() which will help ext-network for simplified sending of a request to the API --- inc/http-functions.php | 32 ++++++++++- inc/language/network_de.php | 1 + .../de/html/admin/admin_list_networks.tpl | 55 ++++++++++--------- 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/inc/http-functions.php b/inc/http-functions.php index 36f0296eab..b657298105 100644 --- a/inc/http-functions.php +++ b/inc/http-functions.php @@ -130,14 +130,42 @@ function removeHttpHostNameFromUrl ($url) { return $url; } -// Send a HEAD request +// Sends a HTTP request (GET, POST, HEAD are currently supported) +function sendHttpRequest ($requestType, $baseUrl, $requestData = array(), $removeHeader = false) { + // Init response + $response = array(); + + // Start "detecting" the request type + switch ($requestType) { + case 'HEAD': // Send a HTTP/1.1 HEAD request + $response = sendHeadRequest($baseUrl, $requestData); + break; + + case 'GET': // Send a HTTP/1.1 GET request + $response = sendGetRequest($baseUrl, $requestData, $removeHeader); + break; + + case 'POST': // Send a HTTP/1.1 POST request + $response = sendPostRequest($baseUrl, $requestData, $removeHeader); + break; + + default: // Unsupported HTTP request, this is really bad and needs fixing + debug_report_bug(__FUNCTION__, __LINE__, 'Unsupported request detected. requestType=' . $requestType . ',baseUrl=' . $baseUrl . ',requestData()=' . count($requestData)); + break; + } // END - switch + + // Return response + return $response; +} + +// Sends a HEAD request function sendHeadRequest ($baseUrl, $requestData = array()) { // Generate full GET URL $getUrl = generateGetUrlFromBaseUrlData($baseUrl, $requestData); // Do we have http[s]:// in front of the URL? if (isFullQualifiedUrl($getUrl)) { - // Remove http[s]:// from url + // Remove http[s]:// from URL $getUrl = removeHttpHostNameFromUrl($getUrl); } elseif (substr($getUrl, 0, 1) != '/') { // Prepend a slash diff --git a/inc/language/network_de.php b/inc/language/network_de.php index 17c0379b08..bdb6f284d6 100644 --- a/inc/language/network_de.php +++ b/inc/language/network_de.php @@ -171,6 +171,7 @@ addMessages(array( 'ADMIN_NETWORK_TYPES_PAGEPEEL' => "Page-Peel", 'ADMIN_NETWORK_TYPES_TRAFFIC' => "Traffic", // These are visitor exchanges like ext-surfbar! // - Sponsor networks + 'ADMIN_LIST_NEWORK_DATA_TITLE' => "Auflistung der Grunddaten aller Werbenetzwerke", 'ADMIN_NETWORK_NONE_SUPPORTED' => "Es sind noch keine Werbenetzwerke eingerichtet.", 'ADMIN_NETWORK_SHORT_NAME' => "Kurzname:", 'ADMIN_NETWORK_TITLE' => "Linktitel:", diff --git a/templates/de/html/admin/admin_list_networks.tpl b/templates/de/html/admin/admin_list_networks.tpl index 64fa0f1096..3a5c50c491 100644 --- a/templates/de/html/admin/admin_list_networks.tpl +++ b/templates/de/html/admin/admin_list_networks.tpl @@ -1,31 +1,36 @@
- - - - - - - - - - - - - - - - $content - - - + + + + + + + + + + + + + + + + + + +$content + + +
  - {--ADMIN_NETWORK_SEPARATOR--} -  
{--ID_SELECT--}{--ADMIN_NETWORK_SHORT_NAME--}{--ADMIN_NETWORK_REFERRAL_LINK--}{--ADMIN_NETWORK_DATA_SEPARATOR2--}{--ADMIN_NETWORK_ROW_SEPARATOR2--}{--ADMIN_NETWORK_REQUEST_TYPE--}{--ADMIN_NETWORK_CHARSET--}{--ADMIN_NETWORK_REQUIRE_ID_CARD--}
+ {--ADMIN_LIST_NEWORK_DATA_TITLE--} +
  + {--ADMIN_NETWORK_SEPARATOR--} +  
{--ID_SELECT--}{--ADMIN_NETWORK_SHORT_NAME--}{--ADMIN_NETWORK_REFERRAL_LINK--}{--ADMIN_NETWORK_DATA_SEPARATOR2--}{--ADMIN_NETWORK_ROW_SEPARATOR2--}{--ADMIN_NETWORK_REQUEST_TYPE--}{--ADMIN_NETWORK_CHARSET--}{--ADMIN_NETWORK_REQUIRE_ID_CARD--}
-- 2.39.2