From edf26caf1e11592a3049ff476fcc9d85d60eeda6 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 22 Dec 2007 20:49:33 +0000 Subject: [PATCH] - Avoid a divde by zero in label generation - Never allow the number of lines for text data to be zero in the first place. --- admin/reports.inc.php | 5 +++-- admin/reports_editor.php | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/admin/reports.inc.php b/admin/reports.inc.php index fa1668b..c217cf9 100644 --- a/admin/reports.inc.php +++ b/admin/reports.inc.php @@ -281,6 +281,7 @@ foreach($report_stock as $n=>$v) { /* field, value, x, y, w, h, lines, face, align */ $vals = "'$k','$v','0','0','0','0','0','',''"; } else { + if($v['lines'] == 0) $v['lines'] =1; $opts = "{$v['align']} {$v['valign']}"; $vals = "'{$v['field']}','{$v['value']}', '{$v['x']}','{$v['y']}','{$v['w']}', @@ -707,9 +708,9 @@ foreach($report_stock as $n=>$v) { /* Special column, override result with static text */ if($f == 'static_text') $v = $d['value']; - + $lh = ($d['lines'] == 0) ? 0 : $d['h']/$d['lines']; $rep->addLabelText2($d['x'], $d['y'], $d['w'], - $d['h'], $d['h']/$d['lines'], + $d['h'], $lh, $v, $opt); } } diff --git a/admin/reports_editor.php b/admin/reports_editor.php index 9d20cca..f3d0c66 100644 --- a/admin/reports_editor.php +++ b/admin/reports_editor.php @@ -141,6 +141,7 @@ function reportChange() $v = stripslashes($v); } else if(in_array($l, $floatloc)) { $v = floatval($v); + if($l == 'lines' && $v==0) $v=1; } else if($l == 'face') { $v = ($v == 'bold') ? 'bold' : ''; } else if($l == 'align') { @@ -155,7 +156,7 @@ function reportChange() echo "Invalid valignment $v"; exit; } - } + } $a[$l] = $v; } if(trim($a['field']) == '') continue; @@ -271,6 +272,7 @@ function reportChange() $vw = intval($v['w']); $vh = intval($v['h']); $vlines = intval($v['lines']); + if($vlines == 0) $vlines = 1; $face = $v['face']; $align = $v['align']. ' ' . $v['valign']; $value=mysql_escape_string(stripslashes($v['value']));