| 1 |
cvsjoko |
1.1 |
<? |
| 2 |
|
|
|
| 3 |
|
|
function dumpBenchmarkProfiling($profiling, $title) { |
| 4 |
|
|
print '<table class="benchmark" cellspacing="2" cellpadding="2" >'; |
| 5 |
|
|
print "<tr><td colspan=\"3\" align=\"center\" bgcolor=\"#dddddd\"><b>$title</b></td></tr>"; |
| 6 |
|
|
print "<tr><td><b>name</b></td><!--<td><b>time</b></td>--><td><b>diff</b></td><td><b>total</b></td></tr>\n"; |
| 7 |
|
|
while($entry = current($profiling)) { |
| 8 |
|
|
$diff = $entry['diff']; |
| 9 |
|
|
if ($diff >= .01) { |
| 10 |
|
|
array_walk($entry, create_function('&$item', '$item="<font color=\"red\">$item</font>";')); |
| 11 |
|
|
} |
| 12 |
|
|
print "<tr><td>{$entry['name']}</td><!--<td>{$entry['time']}</td>--><td>{$entry['diff']}</td><td>{$entry['total']}</td></tr>\n"; |
| 13 |
|
|
next($profiling); |
| 14 |
|
|
} |
| 15 |
|
|
print '</table>'; |
| 16 |
|
|
} |
| 17 |
|
|
|
| 18 |
|
|
|
| 19 |
|
|
function slog($logstring) { |
| 20 |
|
|
|
| 21 |
|
|
global $glbl_bool_logging; |
| 22 |
|
|
if (!$glbl_bool_logging) { return; } |
| 23 |
|
|
|
| 24 |
|
|
global $slog_level; |
| 25 |
|
|
#global $cp; |
| 26 |
|
|
|
| 27 |
|
|
#if (!is_array($slog_level)) { $slog_level = array(); } |
| 28 |
|
|
|
| 29 |
|
|
#$index = count($slog_level); |
| 30 |
|
|
#$curlevel = $slog_level[$index]; |
| 31 |
|
|
#$curlevel = $cp; |
| 32 |
|
|
$curlevel = ""; |
| 33 |
|
|
|
| 34 |
|
|
$fh = fopen('patman.log', 'a+'); |
| 35 |
|
|
fputs($fh, $curlevel . ": " . $logstring . "\n"); |
| 36 |
|
|
fclose($fh); |
| 37 |
|
|
|
| 38 |
|
|
} |
| 39 |
|
|
|
| 40 |
|
|
function Today() { |
| 41 |
|
|
$d = getdate(); |
| 42 |
|
|
//return $d['year'] . '-' . $d['mon'] . '-' . $d['mday']; |
| 43 |
|
|
return $d['mday'] . '.' . $d['mon'] . '.' . $d['year']; |
| 44 |
|
|
} |
| 45 |
|
|
|
| 46 |
|
|
function DayTime() { |
| 47 |
|
|
return date('H:i:s', time()); |
| 48 |
|
|
} |
| 49 |
|
|
|
| 50 |
|
|
function getFileTimestamp() { |
| 51 |
|
|
return convertDate(Today(), 'english') . '_' . str_replace(':', '-', DayTime()); |
| 52 |
|
|
} |
| 53 |
|
|
|
| 54 |
|
|
function convertDate($date, $mode) { |
| 55 |
|
|
|
| 56 |
|
|
$retval = $date; |
| 57 |
|
|
|
| 58 |
|
|
switch($mode) { |
| 59 |
|
|
|
| 60 |
|
|
case 'german': |
| 61 |
|
|
$da = split('-', $date); |
| 62 |
|
|
if (count($da) == 3) { |
| 63 |
|
|
$retval = $da[2] . '.' . $da[1] . '.' . $da[0]; |
| 64 |
|
|
} |
| 65 |
|
|
break; |
| 66 |
|
|
|
| 67 |
|
|
case 'english': |
| 68 |
|
|
$da = split('\.', $date); |
| 69 |
|
|
if (count($da) == 3) { |
| 70 |
|
|
$retval = $da[2] . '-' . $da[1] . '-' . $da[0]; |
| 71 |
|
|
} |
| 72 |
|
|
break; |
| 73 |
|
|
|
| 74 |
|
|
} |
| 75 |
|
|
|
| 76 |
|
|
return $retval; |
| 77 |
|
|
|
| 78 |
|
|
} |
| 79 |
|
|
|
| 80 |
|
|
function getUniqueId() { |
| 81 |
|
|
$better_token = md5 (uniqid (rand())); |
| 82 |
|
|
return $better_token; |
| 83 |
|
|
} |
| 84 |
|
|
|
| 85 |
|
|
?> |