Add a debug_() routine and use it in curl

This commit is contained in:
dave 2010-02-23 19:58:06 +00:00
parent f4d2d636d8
commit c284fed0f5
2 changed files with 27 additions and 14 deletions

View File

@ -86,7 +86,7 @@
break;
}
// echo "<pre>Curl Send: (type:{$fair['type']}=>$url) ".htmlspecialchars($str)."</pre>";
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 "<pre>Server Returned: ".htmlspecialchars(urldecode($datastream))."</pre>";
debug_("Server Returned: ".urldecode($datastream));
switch($fair['type']) {
case 'sfiab':
@ -145,7 +145,7 @@
}
break;
}
// echo "<pre>Server Returned: ";print_r($ret);echo "</pre><br>";
debug_("Returning: ".print_r($ret, true));
return $ret;
}
?>

View File

@ -629,7 +629,7 @@ if(substr($config['version'], -1) % 2 != 0)
echo "<a target=\"blank\" href=\"http://www.sfiab.ca\">SFIAB Version ".$config['version']."{$extra}</a>";
?>
</div>
<div id="debug" style="display:<?=($_SESSION['debug']=='true')?'block':'none'?>">Debug...</div>
<div id="debug" style="display:<?=($_SESSION['debug']=='true')?'block':'none'?>; font-family:monospace; white-space:pre; " >Debug...</div>
<iframe id="content" src="" style="visibility:hidden; width:0px; height:0px"></iframe>
</body>
@ -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))).'<br />';
echo "<script type=\"text/javascript\">
$(document).ready(function() {
$(\"#debug\").append(\"$s\");
});
</script>";
}
//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;
}