From c284fed0f51a29be3e1777277874e2eebb4be548 Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 23 Feb 2010 19:58:06 +0000 Subject: [PATCH] Add a debug_() routine and use it in curl --- admin/curl.inc.php | 6 +++--- common.inc.php | 35 ++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/admin/curl.inc.php b/admin/curl.inc.php index ee122df..1cbad72 100644 --- a/admin/curl.inc.php +++ b/admin/curl.inc.php @@ -86,7 +86,7 @@ break; } -// echo "
Curl Send: (type:{$fair['type']}=>$url) ".htmlspecialchars($str)."
"; + debug_("Curl Send: (type:{$fair['type']}=>$url) $str"); $ch = curl_init(); /// initialize a cURL session curl_setopt ($ch, CURLOPT_URL, $url); @@ -101,7 +101,7 @@ $datastream = curl_exec ($ch); /// execute the curl session and return the output to a variable $datastream curl_close ($ch); /// close the curl session -// echo "
Server Returned: ".htmlspecialchars(urldecode($datastream))."
"; + debug_("Server Returned: ".urldecode($datastream)); switch($fair['type']) { case 'sfiab': @@ -145,7 +145,7 @@ } break; } -// echo "
Server Returned: ";print_r($ret);echo "

"; + debug_("Returning: ".print_r($ret, true)); return $ret; } ?> diff --git a/common.inc.php b/common.inc.php index d00a2f1..e43b7d5 100644 --- a/common.inc.php +++ b/common.inc.php @@ -629,7 +629,7 @@ if(substr($config['version'], -1) % 2 != 0) echo "SFIAB Version ".$config['version']."{$extra}"; ?> -
Debug...
+
Debug...
@@ -1245,22 +1245,35 @@ function error_($str, $i18n_array=array(), $timeout=-1) notice_($str, $i18n_array, $timeout, 'error'); } +function debug_($str) +{ + if($_SESSION['debug'] != true) return; + hexdump($str); + $s = str_replace("\n", "", nl2br(htmlspecialchars($str))).'
'; + echo ""; +} + //this function returns a HTML colour code ranging between red and green, with yellow in the middle based on the percent passed into it -function colour_to_percent($percent) { - //0 is red - //50 is yellow - //100 is green +function colour_to_percent($percent) +{ + //0 is red + //50 is yellow + //100 is green - if($percent<=50) $red=255; - else $red=(100-$percent)*2/100*255;; + if($percent<=50) $red=255; + else $red=(100-$percent)*2/100*255;; - if($percent>50) $green=255; - else $green=($percent)*2/100*255;; + if($percent>50) $green=255; + else $green=($percent)*2/100*255;; // echo "red=$red"; // echo "green=$green"; - $str="#".sprintf("%02s",dechex($red)).sprintf("%02s",dechex($green))."00"; - return $str; + $str="#".sprintf("%02s",dechex($red)).sprintf("%02s",dechex($green))."00"; + return $str; }