9 * Author: Carlos Reche/Joe Hunt
10 * E-mail: carlosreche@yahoo.com/joe.hunt.consulting@gmail.com
11 * Sorocaba, SP - Brazil/Wellington, New Zealand
13 * Created: Sep 20, 2004
14 * Last Modification: Sep 20, 2004/Apr 01, 2007
20 * graph creates 6 different types of graphics with how many parameters you want. You can
21 * change the appearance of the graphics in 3 different skins, and you can still cross data from 2
22 * graphics in only 1! It's a powerful script, and I recommend you read all the instructions
23 * to learn how to use all of this features. Don't worry, it's very simple to use it.
25 * This script is free. Please keep the credits.
31 INSTRUNCTIONS OF HOW TO USE THIS SCRIPT (Please, take a minute to read it. It's important!)
34 NOTE: make sure that your PHP is compiled to work with GD Lib.
36 ///// START OF EXAMPLE.PHP /////
40 require "class.graphics.inc";
52 In your html file you set it up as:
54 <img src="example.php" border="1" />
57 You can supply extra parameters to display(). Ex. $pg->display("test.png") will save the image to a file.
58 Ex. $pg->display("", true) will paint a border around the image. It might be suitable if you choose to save to
59 file for later presentation.
61 ///// END OF EXAMPLE.PHP /////
65 Here is a list of all parameters you may set:
67 title => Title of the graphic
68 axis_x => Name of values from Axis X
69 axis_y => Name of values from Axis Y
70 graphic_1 => Name of Graphic_1 (only shown if you are gonna cross data from 2 different graphics)
71 graphic_2 => Name of Graphic_2 (same comment of above)
73 type => Type of graphic (values 1 to 6)
74 1 => Vertical bars (default)
81 skin => Skin of the graphic (values 1 to 3)
86 credits => Only if you want to show my credits in the image. :)
87 0 => doesn't show (default)
90 x[0] => Name of the first parameter in Axis X
91 x[1] => Name of the second parameter in Axis X
94 y[0] => Value from "graphic_1" relative for "x[0]"
95 y[1] => Value from "graphic_1" relative for "x[1]"
98 z[0] => Value from "graphic_2" relative for "x[0]"
99 z[1] => Value from "graphic_2" relative for "x[1]"
103 NOTE: You can't cross data between graphics if you use "pie" or "donut" graphic. Values for "z"
104 won't be considerated.
106 That's all! Hope you make a good use of it!
107 It would be nice to receive feedback from others users. All comments are welcome!
140 var $total_parameters;
143 var $biggest_parameter;
144 var $available_types;
147 var $h3d = 15; // 3D height
148 var $built_in = false;
154 global $UTF8_fontfile;
155 $this->encoding = strtoupper($_SESSION['language']->encoding);
156 $path = dirname(__FILE__).'/../fonts/';
158 // If you use UTF-8 encoding you have to download and install FreeSans.ttf font.
159 // It is not bundled with application due to its size.
160 // You can also use another UTF-8 font and put it in config.php with the name in $UTF8_fontfile
161 $this->fontfile = $this->encoding == 'UTF-8' ? (isset($UTF8_fontfile) && $UTF8_fontfile != "" ? $path.$UTF8_fontfile : $path.'FreeSans.ttf') :
162 $path.'LiberationSans-Regular.ttf';
164 $this->x = $this->y = $this->z = array();
165 $this->biggest_x = NULL;
166 $this->biggest_y = NULL;
167 $this->alternate_x = false;
168 $this->graphic_2_exists = false;
169 $this->total_parameters = 0;
170 $this->sum_total = 1;
171 $this->latin_notation = false;
175 function display($save="", $border=false)
177 $this->legend_exists = (preg_match("/(5|6)/", $this->type)) ? true : false;
178 $this->biggest_graphic_name = (strlen($this->graphic_1) > strlen($this->graphic_2)) ? $this->graphic_1 : $this->graphic_2;
179 $this->height_title = (!empty($this->title)) ? ($this->string_height($this->tsize) + 15) : 0;
180 $this->space_between_bars = ($this->type == 1) ? 40 : 30;
181 $this->space_between_dots = 40;
182 $this->higher_value = 0;
183 $this->higher_value_str = 0;
187 $this->graphic_area_width = 0;
188 $this->graphic_area_height = 0;
189 $this->graphic_area_x1 = 30;
190 $this->graphic_area_y1 = 20 + $this->height_title;
191 $this->graphic_area_x2 = $this->graphic_area_x1 + $this->graphic_area_width;
192 $this->graphic_area_y2 = $this->graphic_area_y1 + $this->graphic_area_height;
194 if (count($this->z) && (preg_match("/(1|2|3|4)/", $this->type)))
195 $this->graphic_2_exists = true;
196 $this->total_parameters = count($this->x);
197 for ($i = 0; $i < $this->total_parameters; $i++)
199 if (strlen($this->x[$i]) > strlen($this->biggest_x))
200 $this->biggest_x = $this->x[$i];
201 if ($this->y[$i] > $this->biggest_y)
202 $this->biggest_y = number_format(round($this->y[$i], 1), 1, ".", "");
203 if ($this->graphic_2_exists)
205 if (isset($this->z[$i]) && $this->z[$i] > $this->biggest_y)
206 $this->biggest_y = number_format(round($this->z[$i], 1), 1, ".", "");
210 if (($this->graphic_2_exists == true) && ((!empty($this->graphic_1)) || (!empty($this->graphic_2))))
212 $this->legend_exists = true;
215 $this->sum_total = array_sum($this->y);
216 if ($this->sum_total == 0)
217 $this->sum_total = 1;
218 $this->space_between_bars += ($this->graphic_2_exists == true) ? 10 : 0;
220 $this->calculate_higher_value();
221 $this->calculate_width();
222 $this->calculate_height();
224 $this->create_graphic($save, $border);
227 function create_graphic($save="", $border=false)
230 $this->img = imagecreatetruecolor($this->width, $this->height);
232 $this->load_color_palette();
235 imagefill($this->img, 0, 0, $this->color['background']);
236 //imagefilledrectangle($this->img, 0, 0, $this->width, $this->height, $this->color['background']);
238 // imagerectangle($this->img, 0, 0, $this->width-1, $this->height-1, imagecolorallocate($this->img, 100, 150, 200));
241 if (!empty($this->title))
243 $center = ($this->width / 2) - ($this->string_width($this->title, $this->tsize) / 2);
244 $this->_imagestring($this->img, $this->tsize, $center, 10, $this->title, $this->color['title']);
248 // Draw axis and background lines for "vertical bars", "dots" and "lines"
249 if (preg_match("/^(1|3|4)$/", $this->type))
251 if ($this->legend_exists == true)
253 $this->draw_legend();
256 $higher_value_y = $this->graphic_area_y1 + (0.1 * $this->graphic_area_height);
257 $higher_value_size = 0.9 * $this->graphic_area_height;
259 $less = 7 * strlen($this->higher_value_str);
261 imageline($this->img, $this->graphic_area_x1, $higher_value_y, $this->graphic_area_x2, $higher_value_y, $this->color['bg_lines']);
262 $this->_imagestring($this->img, $this->size, ($this->graphic_area_x1-$less-7), ($higher_value_y-7), $this->higher_value_str, $this->color['axis_values']);
264 for ($i = 1; $i < 10; $i++)
266 $dec_y = $i * ($higher_value_size / 10);
267 $x1 = $this->graphic_area_x1;
268 $y1 = $this->graphic_area_y2 - $dec_y;
269 $x2 = $this->graphic_area_x2;
270 $y2 = $this->graphic_area_y2 - $dec_y;
272 imageline($this->img, $x1, $y1, $x2, $y2, $this->color['bg_lines']);
275 $value = $this->number_formated($this->higher_value * $i / 10, $this->dec1);
276 $len1 = strlen($this->higher_value_str);
277 $len2 = strlen($value);
279 $len2 += ($len1-$len2-1);
281 //$this->_imagestring($this->img, $this->size, ($x1-$less-7), ($y2-7), $value, $this->color['axis_values']);
282 $this->_imagestring($this->img, $this->size, ($x1-$less-7), ($y2-7), $value, $this->color['axis_values']);
287 //$this->_imagestring($this->img, $this->size, $this->graphic_area_x2+10, $this->graphic_area_y2+3, $this->axis_x, $this->color['title']);
288 $this->_imagestring($this->img, $this->size, $this->graphic_area_x2+40, $this->graphic_area_y2+3, $this->axis_x, $this->color['title']);
289 imageline($this->img, $this->graphic_area_x1, $this->graphic_area_y2, $this->graphic_area_x2, $this->graphic_area_y2, $this->color['axis_line']);
291 $this->_imagestring($this->img, $this->size, 20, $this->graphic_area_y1-20, $this->axis_y, $this->color['title']);
292 imageline($this->img, $this->graphic_area_x1, $this->graphic_area_y1, $this->graphic_area_x1, $this->graphic_area_y2, $this->color['axis_line']);
296 // Draw axis and background lines for "horizontal bars"
297 else if ($this->type == 2)
299 if ($this->legend_exists == true)
301 $this->draw_legend();
304 $higher_value_x = $this->graphic_area_x2 - (0.2 * $this->graphic_area_width);
305 $higher_value_size = 0.8 * $this->graphic_area_width;
307 imageline($this->img, ($this->graphic_area_x1+$higher_value_size), $this->graphic_area_y1, ($this->graphic_area_x1+$higher_value_size), $this->graphic_area_y2, $this->color['bg_lines']);
308 $this->_imagestring($this->img, $this->size, (($this->graphic_area_x1+$higher_value_size) - ($this->string_width($this->higher_value, $this->size)/2)), ($this->graphic_area_y2+2), $this->higher_value_str, $this->color['axis_values']);
310 for ($i = 1, $alt = 15; $i < 10; $i++)
312 $dec_x = number_format(round($i * ($higher_value_size / 10), 1), 1, ".", "");
314 imageline($this->img, ($this->graphic_area_x1+$dec_x), $this->graphic_area_y1, ($this->graphic_area_x1+$dec_x), $this->graphic_area_y2, $this->color['bg_lines']);
317 $alt = (strlen($this->biggest_y) > 4 && $alt != 15) ? 15 : 2;
318 $value = $this->number_formated($this->higher_value * $i / 10, $this->dec1);
319 $this->_imagestring($this->img, $this->size, (($this->graphic_area_x1+$dec_x) - ($this->string_width($this->higher_value, $this->size)/2)), ($this->graphic_area_y2), $value, $this->color['axis_values'], $alt);
324 $this->_imagestring($this->img, $this->size, ($this->graphic_area_x2+10), ($this->graphic_area_y2+3), $this->axis_y, $this->color['title']);
325 imageline($this->img, $this->graphic_area_x1, $this->graphic_area_y2, $this->graphic_area_x2, $this->graphic_area_y2, $this->color['axis_line']);
327 $this->_imagestring($this->img, $this->size, 20, ($this->graphic_area_y1-20), $this->axis_x, $this->color['title']);
328 imageline($this->img, $this->graphic_area_x1, $this->graphic_area_y1, $this->graphic_area_x1, $this->graphic_area_y2, $this->color['axis_line']);
332 // Draw legend box for "pie" or "donut"
333 else if (preg_match("/^(5|6)$/", $this->type))
335 $this->draw_legend();
341 * Draw graphic: VERTICAL BARS
343 if ($this->type == 1)
346 $x = $this->graphic_area_x1 + 20;
348 foreach ($this->x as $i => $parameter)
350 if (isset($this->z[$i]))
352 $size = round($this->z[$i] * $higher_value_size / $this->higher_value);
354 $y1 = ($this->graphic_area_y2 - $size) + 1;
356 $y2 = $this->graphic_area_y2 - 1;
357 imageline($this->img, ($x1+1), ($y1-1), $x2, ($y1-1), $this->color['bars_2_shadow']);
358 imageline($this->img, ($x2+1), ($y1-1), ($x2+1), $y2, $this->color['bars_2_shadow']);
359 imageline($this->img, ($x2+2), ($y1-1), ($x2+2), $y2, $this->color['bars_2_shadow']);
360 imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars_2']);
363 $size = round($this->y[$i] * $higher_value_size / $this->higher_value);
364 $alt = (($num % 2 == 0) && (strlen($this->biggest_x) > 5)) ? 15 : 2;
366 $y1 = ($this->graphic_area_y2 - $size) + 1;
368 $y2 = $this->graphic_area_y2 - 1;
369 $x += $this->space_between_bars;
372 imageline($this->img, ($x1+1), ($y1-1), $x2, ($y1-1), $this->color['bars_shadow']);
373 imageline($this->img, ($x2+1), ($y1-1), ($x2+1), $y2, $this->color['bars_shadow']);
374 imageline($this->img, ($x2+2), ($y1-1), ($x2+2), $y2, $this->color['bars_shadow']);
375 imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars']);
376 //$this->_imagestring($this->img, $this->size, ((($x1+$x2)/2) - (strlen($parameter)*7/2)), ($y2+2), $parameter, $this->color['axis_values'], $alt);
377 $this->_imagestring($this->img, $this->size, $x1, ($y2+2), $parameter, $this->color['axis_values'], $alt);
383 * Draw graphic: HORIZONTAL BARS
385 else if ($this->type == 2)
389 foreach ($this->x as $i => $parameter)
391 if (isset($this->z[$i]))
393 $size = round($this->z[$i] * $higher_value_size / $this->higher_value);
394 $x1 = $this->graphic_area_x1 + 1;
395 $y1 = $this->graphic_area_y1 + $y + 10;
398 imageline($this->img, ($x1), ($y2+1), $x2, ($y2+1), $this->color['bars_2_shadow']);
399 imageline($this->img, ($x1), ($y2+2), $x2, ($y2+2), $this->color['bars_2_shadow']);
400 imageline($this->img, ($x2+1), ($y1+1), ($x2+1), ($y2+2), $this->color['bars_2_shadow']);
401 imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars_2']);
402 $this->_imagestring($this->img, $this->size, ($x2+7), ($y1+7), $this->number_formated($this->z[$i], $this->dec2), $this->color['bars_2_shadow']);
405 $size = round(($this->y[$i] / $this->higher_value) * $higher_value_size);
406 $x1 = $this->graphic_area_x1 + 1;
407 $y1 = $this->graphic_area_y1 + $y;
410 $y += $this->space_between_bars;
412 imageline($this->img, ($x1), ($y2+1), $x2, ($y2+1), $this->color['bars_shadow']);
413 imageline($this->img, ($x1), ($y2+2), $x2, ($y2+2), $this->color['bars_shadow']);
414 imageline($this->img, ($x2+1), ($y1+1), ($x2+1), ($y2+2), $this->color['bars_shadow']);
415 imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars']);
416 $this->_imagestring($this->img, $this->size, ($x2+7), ($y1+2), $this->number_formated($this->y[$i], $this->dec2), $this->color['bars_shadow']);
418 //$this->_imagestring($this->img, $this->size, ($x1 - ((strlen($parameter)*7)+7)), ($y1+2), $parameter, $this->color['axis_values']);
419 $this->_imagestring($this->img, $this->size, 30, ($y1+2), $parameter, $this->color['axis_values']);
425 * Draw graphic: DOTS or LINE
427 else if (preg_match("/^(3|4)$/", $this->type))
430 $x[0] = $this->graphic_area_x1+1;
432 foreach ($this->x as $i => $parameter)
434 if ($this->graphic_2_exists == true)
436 $size = round($this->z[$i] * $higher_value_size / $this->higher_value);
437 $z[$i] = $this->graphic_area_y2 - $size;
440 $alt = (($i % 2 == 0) && (strlen($this->biggest_x) > 5)) ? 15 : 2;
441 $size = round($this->y[$i] * $higher_value_size / $this->higher_value);
442 $y[$i] = $this->graphic_area_y2 - $size;
446 imageline($this->img, $x[$i], ($this->graphic_area_y1+10), $x[$i], ($this->graphic_area_y2-1), $this->color['bg_lines']);
448 //$this->_imagestring($this->img, $this->size, ($x[$i] - (strlen($parameter)*7/2 )), ($this->graphic_area_y2+2), $parameter, $this->color['axis_values'], $alt);
449 $this->_imagestring($this->img, $this->size, $x[$i], ($this->graphic_area_y2+2), $parameter, $this->color['axis_values'], $alt);
451 $x[$i+1] = $x[$i] + 40;
454 foreach ($x as $i => $value_x)
456 if ($this->graphic_2_exists == true)
461 if ($this->type == 4)
463 imageline($this->img, $x[$i], $z[$i], $x[$i+1], $z[$i+1], $this->color['line_2']);
464 imageline($this->img, $x[$i], ($z[$i]+1), $x[$i+1], ($z[$i+1]+1), $this->color['line_2']);
466 imagefilledrectangle($this->img, $x[$i]-1, $z[$i]-1, $x[$i]+2, $z[$i]+2, $this->color['line_2']);
470 imagefilledrectangle($this->img, $x[$i-1]-1, $z[$i-1]-1, $x[$i-1]+2, $z[$i-1]+2, $this->color['line_2']);
479 if ($this->type == 4)
481 imageline($this->img, $x[$i], $y[$i], $x[$i+1], $y[$i+1], $this->color['line']);
482 imageline($this->img, $x[$i], ($y[$i]+1), $x[$i+1], ($y[$i+1]+1), $this->color['line']);
484 imagefilledrectangle($this->img, $x[$i]-1, $y[$i]-1, $x[$i]+2, $y[$i]+2, $this->color['line']);
488 imagefilledrectangle($this->img, $x[$i-1]-1, $y[$i-1]-1, $x[$i-1]+2, $y[$i-1]+2, $this->color['line']);
497 * Draw graphic: PIE or DONUT
499 else if (preg_match("/^(5|6)$/", $this->type))
501 $center_x = ($this->graphic_area_x1 + $this->graphic_area_x2) / 2;
502 $center_y = ($this->graphic_area_y1 + $this->graphic_area_y2) / 2;
503 $width = $this->graphic_area_width;
504 $height = $this->graphic_area_height;
508 foreach ($this->x as $i => $parameter)
510 $size = $this->y[$i] * 360 / $this->sum_total;
511 $size = round2($size, 0);
518 if ($this->type == 5)
521 foreach ($sizes as $i => $size)
524 while ($num_color > 7)
528 $color = 'arc_' . $num_color . '_shadow';
530 for ($i = $this->h3d; $i >= 0; $i--)
532 //imagearc($this->img, $center_x, ($center_y+$i), $width, $height, $start, ($start+$size), $this->color[$color]);
534 imagefilledarc($this->img, $center_x, ($center_y+$i), $width, $height, $start, ($start+$size), $this->color[$color], IMG_ARC_NOFILL);
542 foreach ($sizes as $i => $size)
545 while ($num_color > 7)
549 $color = 'arc_' . $num_color;
551 imagefilledarc($this->img, $center_x, $center_y, ($width+2), ($height+2), $start, ($start+$size), $this->color[$color], IMG_ARC_EDGED);
557 else if ($this->type == 6)
559 foreach ($sizes as $i => $size)
562 while ($num_color > 7)
566 $color = 'arc_' . $num_color;
567 $color_shadow = 'arc_' . $num_color . '_shadow';
569 imagefilledarc($this->img, $center_x, $center_y, $width, $height, $start, ($start+$size), $this->color[$color], IMG_ARC_PIE);
572 imagefilledarc($this->img, $center_x, $center_y, 100, 100, 0, 360, $this->color['background'], IMG_ARC_PIE);
573 imagearc($this->img, $center_x, $center_y, 100, 100, 0, 360, $this->color['bg_legend']);
574 imagearc($this->img, $center_x, $center_y, ($width+1), ($height+1), 0, 360, $this->color['bg_legend']);
579 if ($this->credits == true)
581 $this->draw_credits();
584 imagepng($this->img, $save);
587 header('Content-type: image/png');
588 imagepng($this->img);
590 imagedestroy($this->img);
593 function calculate_width()
599 $this->legend_box_width = ($this->legend_exists == true) ? ($this->string_width($this->biggest_graphic_name, $this->tsize) + 25) : 0;
600 $this->graphic_area_width = ($this->space_between_bars * $this->total_parameters) + 30;
601 $this->graphic_area_x1 += $this->string_width(($this->higher_value_str), $this->size);
602 $this->width += $this->graphic_area_x1 + 20;
603 $this->width += ($this->legend_exists == true) ? 50 : ((7 * strlen($this->axis_x)) + 10);
608 $this->legend_box_width = ($this->legend_exists == true) ? ($this->string_width($this->biggest_graphic_name, $this->size) + 25) : 0;
609 $this->graphic_area_width = ($this->string_width($this->higher_value_str, $this->size) > 50) ? (5 * ($this->string_width($this->higher_value_str, $this->size)) * 0.85) : 200;
610 $this->graphic_area_x1 += 7 * strlen($this->biggest_x);
611 $this->width += ($this->legend_exists == true) ? 60 : ((7 * strlen($this->axis_y)) + 30);
612 $this->width += $this->graphic_area_x1;
617 $this->legend_box_width = ($this->legend_exists == true) ? ($this->string_width($this->biggest_graphic_name, $this->size) + 25) : 0;
618 $this->graphic_area_width = ($this->space_between_dots * $this->total_parameters) - 10;
619 $this->graphic_area_x1 += $this->string_width(($this->higher_value_str), $this->size);
620 $this->width += $this->graphic_area_x1 + 20;
621 $this->width += ($this->legend_exists == true) ? 40 : ((7 * strlen($this->axis_x)) + 30);
626 $this->legend_box_width = ($this->legend_exists == true) ? ($this->string_width($this->biggest_graphic_name, $this->size) + 25) : 0;
627 $this->graphic_area_width = ($this->space_between_dots * $this->total_parameters) - 10;
628 $this->graphic_area_x1 += $this->string_width(($this->higher_value_str), $this->size);
629 $this->width += $this->graphic_area_x1 + 20;
630 $this->width += ($this->legend_exists == true) ? 40 : ((7 * strlen($this->axis_x)) + 30);
635 $this->legend_box_width = $this->string_width($this->biggest_x, $this->size) + 85;
636 $this->graphic_area_width = 200;
642 $this->legend_box_width = $this->string_width($this->biggest_x, $this->size) + 85;
643 $this->graphic_area_width = 180;
648 $this->graphic_area_width = max($this->graphic_area_width, $this->string_width($this->title, $this->size));
649 $this->width += $this->graphic_area_width;
650 $this->width += $this->legend_box_width;
653 $this->graphic_area_x2 = $this->graphic_area_x1 + $this->graphic_area_width;
654 $this->legend_box_x1 = $this->graphic_area_x2 + 40;
655 $this->legend_box_x2 = $this->legend_box_x1 + $this->legend_box_width;
658 function calculate_height()
664 $this->legend_box_height = ($this->graphic_2_exists == true) ? 40 : 0;
665 $this->graphic_area_height = 150;
671 $this->legend_box_height = ($this->graphic_2_exists == true) ? 40 : 0;
672 $this->graphic_area_height = ($this->space_between_bars * $this->total_parameters) + 10;
678 $this->legend_box_height = ($this->graphic_2_exists == true) ? 40 : 0;
679 $this->graphic_area_height = 150;
685 $this->legend_box_height = ($this->graphic_2_exists == true) ? 40 : 0;
686 $this->graphic_area_height = 150;
692 $this->legend_box_height = (!empty($this->axis_x)) ? 30 : 5;
693 $this->legend_box_height += (14 * $this->total_parameters);
694 $this->graphic_area_height = 150;
700 $this->legend_box_height = (!empty($this->axis_x)) ? 30 : 5;
701 $this->legend_box_height += (14 * $this->total_parameters);
702 $this->graphic_area_height = 180;
707 $this->height += $this->height_title;
708 $this->height += ($this->legend_box_height > $this->graphic_area_height) ? ($this->legend_box_height - $this->graphic_area_height) : 0;
709 $this->height += $this->graphic_area_height;
711 $this->graphic_area_y2 = $this->graphic_area_y1 + $this->graphic_area_height;
712 $this->legend_box_y1 = $this->graphic_area_y1 + 10;
713 $this->legend_box_y2 = $this->legend_box_y1 + $this->legend_box_height;
716 function draw_legend()
718 $x1 = $this->legend_box_x1;
719 $y1 = $this->legend_box_y1;
720 $x2 = $this->legend_box_x2;
721 $y2 = $this->legend_box_y2;
723 imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bg_legend']);
729 // Draw legend values for VERTICAL BARS, HORIZONTAL BARS, DOTS and LINES
730 if (preg_match("/^(1|2|3|4)$/", $this->type))
732 $color_1 = (preg_match("/^(1|2)$/", $this->type)) ? $this->color['bars'] : $this->color['line'];
733 $color_2 = (preg_match("/^(1|2)$/", $this->type)) ? $this->color['bars_2'] : $this->color['line_2'];
735 imagefilledrectangle($this->img, $x, $y, ($x+10), ($y+10), $color_1);
736 imagerectangle($this->img, $x, $y, ($x+10), ($y+10), $this->color['title']);
737 $this->_imagestring($this->img, $this->size, ($x+15), ($y-2), $this->graphic_1, $this->color['axis_values']);
739 imagefilledrectangle($this->img, $x, $y, ($x+10), ($y+10), $color_2);
740 imagerectangle($this->img, $x, $y, ($x+10), ($y+10), $this->color['title']);
741 $this->_imagestring($this->img, $this->size, ($x+15), ($y-2), $this->graphic_2, $this->color['axis_values']);
744 // Draw legend values for PIE or DONUT
745 else if (preg_match("/^(5|6)$/", $this->type))
747 if (!empty($this->axis_x))
749 $this->_imagestring($this->img, $this->size, ((($x1+$x2)/2) - (strlen($this->axis_x)*7/2)), $y,
750 $this->axis_x." (".$this->graphic_1.")", $this->color['title']);
756 foreach ($this->x as $i => $parameter)
762 $color = 'arc_' . $num;
764 $percent = number_format(round(($this->y[$i] * 100 / $this->sum_total), 2), 2, ".", "") . ' %';
765 $less = (strlen($percent) * 7);
769 imageline($this->img, ($x1+15), ($y-2), ($x2-5), ($y-2), $this->color['bg_lines']);
771 imagefilledrectangle($this->img, $x, $y, ($x+10), ($y+10), $this->color[$color]);
772 imagerectangle($this->img, $x, $y, ($x+10), ($y+10), $this->color['title']);
773 $this->_imagestring($this->img, $this->size, ($x+15), ($y-2), $parameter, $this->color['axis_values']);
774 $this->_imagestring($this->img, $this->size, ($x2-$less), ($y-2), $percent, $this->color['axis_values']);
782 function string_width($string, $size)
784 $single_width = $size + 4;
785 if ($this->encoding == "UTF-8")
786 $width = mb_strlen($string, "UTF-8");
788 $width = strlen($string);
789 return $single_width * $width;
792 function string_height($size)
809 function calculate_higher_value()
811 $digits = strlen(round($this->biggest_y));
812 $interval = pow(10, ($digits-1));
813 $this->higher_value = round(($this->biggest_y - ($this->biggest_y % $interval) + $interval), 1);
814 $this->higher_value_str = $this->number_formated($this->higher_value, $this->dec1);
817 function number_formated($number, $dec_size = 1)
819 if ($this->latin_notation == true)
820 return number_format(round($number, $dec_size), $dec_size, ",", ".");
821 return number_format(round($number, $dec_size), $dec_size, ".", ",");
824 function number_float($number)
826 if ($this->latin_notation == true)
827 $number = str_replace(".", "", $number);
828 return (float)str_replace(",", "", $number);
832 function draw_credits()
834 $this->_imagestring($this->img, $this->size - 2, ($this->width-120), ($this->height-10), "Powered by Carlos Reche", $this->color['title']);
838 function load_color_palette()
844 //$this->color['title'] = imagecolorallocate($this->img, 50, 50, 50);
845 $this->color['title'] = imagecolorallocate($this->img, 40, 70, 130);
846 //$this->color['background'] = imagecolorallocate($this->img, 238, 255, 238);
847 $this->color['background'] = imagecolorallocate($this->img, 255, 255, 255);
848 $this->color['axis_values'] = imagecolorallocate($this->img, 50, 50, 50);
849 $this->color['axis_line'] = imagecolorallocate($this->img, 100, 100, 100);
850 $this->color['bg_lines'] = imagecolorallocate($this->img, 220, 220, 220);
851 $this->color['bg_legend'] = imagecolorallocate($this->img, 255, 255, 255);
853 if (preg_match("/^(1|2)$/", $this->type))
855 $this->color['bars'] = imagecolorallocate($this->img, 100, 150, 200);
856 $this->color['bars_shadow'] = imagecolorallocate($this->img, 50, 100, 150);
857 $this->color['bars_2'] = imagecolorallocate($this->img, 200, 250, 150);
858 $this->color['bars_2_shadow'] = imagecolorallocate($this->img, 120, 170, 70);
860 else if (preg_match("/^(3|4)$/", $this->type))
862 $this->color['line'] = imagecolorallocate($this->img, 100, 150, 200);
863 $this->color['line_2'] = imagecolorallocate($this->img, 230, 100, 100);
865 else if (preg_match("/^(5|6)$/", $this->type))
867 $this->color['arc_1'] = imagecolorallocate($this->img, 255, 150, 0);
868 $this->color['arc_2'] = imagecolorallocate($this->img, 150, 0, 255);
869 $this->color['arc_3'] = imagecolorallocate($this->img, 0, 255, 255);
870 $this->color['arc_4'] = imagecolorallocate($this->img, 255, 0, 0);
871 $this->color['arc_5'] = imagecolorallocate($this->img, 0, 255, 0);
872 $this->color['arc_6'] = imagecolorallocate($this->img, 0, 0, 255);
873 $this->color['arc_7'] = imagecolorallocate($this->img, 255, 255, 0);
874 $this->color['arc_1_shadow'] = imagecolorallocate($this->img, 127, 75, 0);
875 $this->color['arc_2_shadow'] = imagecolorallocate($this->img, 75, 0, 127);
876 $this->color['arc_3_shadow'] = imagecolorallocate($this->img, 0, 127, 127);
877 $this->color['arc_4_shadow'] = imagecolorallocate($this->img, 127, 0, 0);
878 $this->color['arc_5_shadow'] = imagecolorallocate($this->img, 0, 127, 0);
879 $this->color['arc_6_shadow'] = imagecolorallocate($this->img, 0, 0, 127);
880 $this->color['arc_7_shadow'] = imagecolorallocate($this->img, 127, 127, 0);
886 $this->color['title'] = imagecolorallocate($this->img, 255, 255, 255);
887 $this->color['background'] = imagecolorallocate($this->img, 0, 0, 0);
888 $this->color['axis_values'] = imagecolorallocate($this->img, 0, 230, 0);
889 $this->color['axis_line'] = imagecolorallocate($this->img, 0, 200, 0);
890 $this->color['bg_lines'] = imagecolorallocate($this->img, 100, 100, 100);
891 $this->color['bg_legend'] = imagecolorallocate($this->img, 70, 70, 70);
893 if (preg_match("/^(1|2)$/", $this->type))
895 $this->color['bars'] = imagecolorallocate($this->img, 50, 200, 50);
896 $this->color['bars_shadow'] = imagecolorallocate($this->img, 0, 150, 0);
897 $this->color['bars_2'] = imagecolorallocate($this->img, 255, 255, 255);
898 $this->color['bars_2_shadow'] = imagecolorallocate($this->img, 220, 220, 220);
900 else if (preg_match("/^(3|4)$/", $this->type))
902 $this->color['line'] = imagecolorallocate($this->img, 220, 220, 220);
903 $this->color['line_2'] = imagecolorallocate($this->img, 0, 180, 0);
905 else if (preg_match("/^(5|6)$/", $this->type))
907 $this->color['arc_1'] = imagecolorallocate($this->img, 255, 255, 255);
908 $this->color['arc_2'] = imagecolorallocate($this->img, 200, 220, 200);
909 $this->color['arc_3'] = imagecolorallocate($this->img, 160, 200, 160);
910 $this->color['arc_4'] = imagecolorallocate($this->img, 135, 180, 135);
911 $this->color['arc_5'] = imagecolorallocate($this->img, 115, 160, 115);
912 $this->color['arc_6'] = imagecolorallocate($this->img, 100, 140, 100);
913 $this->color['arc_7'] = imagecolorallocate($this->img, 90, 120, 90);
914 $this->color['arc_1_shadow'] = imagecolorallocate($this->img, 127, 127, 127);
915 $this->color['arc_2_shadow'] = imagecolorallocate($this->img, 100, 110, 100);
916 $this->color['arc_3_shadow'] = imagecolorallocate($this->img, 80, 100, 80);
917 $this->color['arc_4_shadow'] = imagecolorallocate($this->img, 67, 90, 67);
918 $this->color['arc_5_shadow'] = imagecolorallocate($this->img, 57, 80, 57);
919 $this->color['arc_6_shadow'] = imagecolorallocate($this->img, 50, 70, 50);
920 $this->color['arc_7_shadow'] = imagecolorallocate($this->img, 45, 60, 45);
927 $this->color['title'] = imagecolorallocate($this->img, 250, 50, 50);
928 //$this->color['background'] = imagecolorallocate($this->img, 250, 250, 220);
929 $this->color['background'] = imagecolorallocate($this->img, 255, 255, 255);
930 $this->color['axis_values'] = imagecolorallocate($this->img, 50, 150, 50);
931 $this->color['axis_line'] = imagecolorallocate($this->img, 50, 100, 50);
932 $this->color['bg_lines'] = imagecolorallocate($this->img, 200, 224, 180);
933 //$this->color['bg_legend'] = imagecolorallocate($this->img, 230, 230, 200);
934 $this->color['bg_legend'] = imagecolorallocate($this->img, 255, 255, 255);
936 if (preg_match("/^(1|2)$/", $this->type))
938 $this->color['bars'] = imagecolorallocate($this->img, 255, 170, 80);
939 $this->color['bars_shadow'] = imagecolorallocate($this->img, 200, 120, 30);
940 $this->color['bars_2'] = imagecolorallocate($this->img, 250, 230, 80);
941 $this->color['bars_2_shadow'] = imagecolorallocate($this->img, 180, 150, 0);
943 else if (preg_match("/^(3|4)$/", $this->type))
945 $this->color['line'] = imagecolorallocate($this->img, 230, 100, 0);
946 $this->color['line_2'] = imagecolorallocate($this->img, 220, 200, 50);
948 else if (preg_match("/^(5|6)$/", $this->type))
950 $this->color['arc_1'] = imagecolorallocate($this->img, 100, 150, 200);
951 $this->color['arc_2'] = imagecolorallocate($this->img, 200, 250, 150);
952 $this->color['arc_3'] = imagecolorallocate($this->img, 250, 200, 150);
953 $this->color['arc_4'] = imagecolorallocate($this->img, 250, 150, 150);
954 $this->color['arc_5'] = imagecolorallocate($this->img, 250, 250, 150);
955 $this->color['arc_6'] = imagecolorallocate($this->img, 230, 180, 250);
956 $this->color['arc_7'] = imagecolorallocate($this->img, 200, 200, 150);
957 $this->color['arc_1_shadow'] = imagecolorallocate($this->img, 50, 75, 100);
958 $this->color['arc_2_shadow'] = imagecolorallocate($this->img, 100, 125, 75);
959 $this->color['arc_3_shadow'] = imagecolorallocate($this->img, 125, 100, 75);
960 $this->color['arc_4_shadow'] = imagecolorallocate($this->img, 125, 75, 75);
961 $this->color['arc_5_shadow'] = imagecolorallocate($this->img, 125, 125, 75);
962 $this->color['arc_6_shadow'] = imagecolorallocate($this->img, 115, 90, 125);
963 $this->color['arc_7_shadow'] = imagecolorallocate($this->img, 100, 100, 75);
970 function _imagestring($img, $size, $x, $y, $string, $col, $alt=0)
972 if ($this->encoding != 'UTF-8') {
973 if (function_exists('iconv'))
974 $string = iconv($this->encoding, 'UTF-8', $string);
976 $string = mb_convert_encoding($string, 'UTF-8', $this->encoding);
979 // New 2014-06-26 Joe Hunt for handling ev. RTL languages
982 if ($this->encoding == 'UTF-8' && is_arabic($string))
986 if (strlen($string) > $alt_len)
987 $string = substr($string, 0, $alt_len);
989 if ($this->encoding == 'UTF-8')
991 if (is_arabic($string))
992 $string = arabic($string, "we");
993 elseif (is_hebrew($string))
994 $string = hebrew($string);
999 imagestring($img, $size, $x, $y + $alt, $string, $col);
1019 imagettftext($img, $size, $angle, $x, $y + $alt, $col, $this->fontfile, $string);
1024 // The following is for handling RTL texts. GD does not handle RTL at all.
1025 // The function, arabic, has been taken from Milad Rastian and
1026 // modified by Bagram Siadat.
1027 // The function has been further modified and several bugs are fixed.
1029 function is_arabic($text)
1031 return preg_match('/\p{Arabic}/u', $text);
1034 function is_hebrew($text)
1036 return preg_match('/\p{Hebrew}/u', $text);
1039 function utf8_strlen($str)
1041 return preg_match_all('/[\x00-\x7F\xC0-\xFD]/', $str, $dummy);
1044 function utf8_chr($uni)
1047 # ASCII range (including control chars)
1048 if ( ($uni >= 0) && ($uni <= 0x007f) )
1050 elseif ($uni <= 0x07ff) // 2 byte sequence
1052 $r .= chr(0xc0 | ($uni >> 6));
1053 $r .= chr(0x80 | ($uni & 0x003f));
1055 elseif($uni == 0xFEFF) // Byte order mark (skip)
1056 return chr(0); // nop -- zap the BOM
1057 elseif ($uni >= 0xD800 && $uni <= 0xDFFF) // Test for illegal surrogates
1058 return chr(0); // found a surrogate
1059 elseif ($uni <= 0xffff) // 3 byte sequence
1061 $r .= chr(0xe0 | ($uni >> 12));
1062 $r .= chr(0x80 | (($uni >> 6) & 0x003f));
1063 $r .= chr(0x80 | ($uni & 0x003f));
1065 elseif ($uni <= 0x10ffff) // 4 byte sequence
1067 $r .= chr(0xf0 | ($uni >> 18));
1068 $r .= chr(0x80 | (($uni >> 12) & 0x3f));
1069 $r .= chr(0x80 | (($uni >> 6) & 0x3f));
1070 $r .= chr(0x80 | ($uni & 0x3f));
1079 utf8_chr(0x0622) => array (utf8_chr(0xfe82), utf8_chr(0xfe82), utf8_chr(0x0622)),
1080 utf8_chr(0x0627) => array (utf8_chr(0xfe8e), utf8_chr(0xfe8e), utf8_chr(0x0627)),
1081 utf8_chr(0x0628) => array (utf8_chr(0xfe90), utf8_chr(0xfe92), utf8_chr(0xfe91)),
1082 utf8_chr(0x067e) => array (utf8_chr(0xfb57), utf8_chr(0xfb59), utf8_chr(0xfb58)),
1083 utf8_chr(0x062a) => array (utf8_chr(0xfe96), utf8_chr(0xfe98), utf8_chr(0xfe97)),
1084 utf8_chr(0x062b) => array (utf8_chr(0xfe9a), utf8_chr(0xfe9c), utf8_chr(0xfe9b)),
1085 utf8_chr(0x062c) => array (utf8_chr(0xfe9e), utf8_chr(0xfea0), utf8_chr(0xfe9f)),
1086 utf8_chr(0x0686) => array (utf8_chr(0xfb7b), utf8_chr(0xfb7d), utf8_chr(0xfb7c)),
1087 utf8_chr(0x062d) => array (utf8_chr(0xfea2), utf8_chr(0xfea4), utf8_chr(0xfea3)),
1088 utf8_chr(0x062e) => array (utf8_chr(0xfea6), utf8_chr(0xfea8), utf8_chr(0xfea7)),
1089 utf8_chr(0x062f) => array (utf8_chr(0xfeaa), utf8_chr(0xfeaa), utf8_chr(0xfea9)),
1090 utf8_chr(0x0630) => array (utf8_chr(0xfeac), utf8_chr(0xfeac), utf8_chr(0xfeab)),
1091 utf8_chr(0x0631) => array (utf8_chr(0xfeae), utf8_chr(0xfeae), utf8_chr(0xfead)),
1092 utf8_chr(0x0632) => array (utf8_chr(0xfeb0), utf8_chr(0xfeb0), utf8_chr(0xfeaf)),
1093 utf8_chr(0x0698) => array (utf8_chr(0xfb8b), utf8_chr(0xfb8b), utf8_chr(0xfb8a)),
1094 utf8_chr(0x0633) => array (utf8_chr(0xfeb2), utf8_chr(0xfeb4), utf8_chr(0xfeb3)),
1095 utf8_chr(0x0634) => array (utf8_chr(0xfeb6), utf8_chr(0xfeb8), utf8_chr(0xfeb7)),
1096 utf8_chr(0x0635) => array (utf8_chr(0xfeba), utf8_chr(0xfebc), utf8_chr(0xfebb)),
1097 utf8_chr(0x0636) => array (utf8_chr(0xfebe), utf8_chr(0xfec0), utf8_chr(0xfebf)),
1098 utf8_chr(0x0637) => array (utf8_chr(0xfec2), utf8_chr(0xfec4), utf8_chr(0xfec3)),
1099 utf8_chr(0x0638) => array (utf8_chr(0xfec6), utf8_chr(0xfec8), utf8_chr(0xfec7)),
1100 utf8_chr(0x0639) => array (utf8_chr(0xfeca), utf8_chr(0xfecc), utf8_chr(0xfecb)),
1101 utf8_chr(0x063a) => array (utf8_chr(0xfece), utf8_chr(0xfed0), utf8_chr(0xfecf)),
1102 utf8_chr(0x0641) => array (utf8_chr(0xfed2), utf8_chr(0xfed4), utf8_chr(0xfed3)),
1103 utf8_chr(0x0642) => array (utf8_chr(0xfed6), utf8_chr(0xfed8), utf8_chr(0xfed7)),
1104 utf8_chr(0x06a9) => array (utf8_chr(0xfeda), utf8_chr(0xfedc), utf8_chr(0xfedb)),
1105 utf8_chr(0x06af) => array (utf8_chr(0xfb93), utf8_chr(0xfb95), utf8_chr(0xfb94)),
1106 utf8_chr(0x0644) => array (utf8_chr(0xfede), utf8_chr(0xfee0), utf8_chr(0xfedf)),
1107 utf8_chr(0x0645) => array (utf8_chr(0xfee2), utf8_chr(0xfee4), utf8_chr(0xfee3)),
1108 utf8_chr(0x0646) => array (utf8_chr(0xfee6), utf8_chr(0xfee8), utf8_chr(0xfee7)),
1109 utf8_chr(0x0648) => array (utf8_chr(0xfeee), utf8_chr(0xfeee), utf8_chr(0xfeed)),
1110 utf8_chr(0x06cc) => array (utf8_chr(0xfbfd), utf8_chr(0xfbff), utf8_chr(0xfbfe)),
1111 utf8_chr(0x0643) => array (utf8_chr(0xfeda), utf8_chr(0xfedc), utf8_chr(0xfedb)),
1112 utf8_chr(0x064a) => array (utf8_chr(0xfef2), utf8_chr(0xfef4), utf8_chr(0xfef3)),
1113 utf8_chr(0x0623) => array (utf8_chr(0xfe84), utf8_chr(0xfe84), utf8_chr(0xfe83)),
1114 utf8_chr(0x0624) => array (utf8_chr(0xfe86), utf8_chr(0xfe86), utf8_chr(0xfe85)),
1115 utf8_chr(0x0625) => array (utf8_chr(0xfe88), utf8_chr(0xfe88), utf8_chr(0xfe87)),
1116 utf8_chr(0x0626) => array (utf8_chr(0xfe8a), utf8_chr(0xfe8c), utf8_chr(0xfe8b)),
1117 utf8_chr(0x0629) => array (utf8_chr(0xfe94), utf8_chr(0xfe98), utf8_chr(0xfe97))
1121 $nastaligh = array (
1122 utf8_chr(0x0647) => array (utf8_chr(0xfbab), utf8_chr(0xfbad), utf8_chr(0xfbac))
1126 utf8_chr(0x0647) => array (utf8_chr(0xfeea), utf8_chr(0xfeec), utf8_chr(0xfeeb))
1130 $mp_chars = array (utf8_chr(0x0622), utf8_chr(0x0627), utf8_chr(0x062f), utf8_chr(0x0630), utf8_chr(0x0631), utf8_chr(0x0632),
1131 utf8_chr(0x0698), utf8_chr(0x0648), utf8_chr(0x0623), utf8_chr(0x0625), utf8_chr(0x0624));
1134 $ignorelist = array (utf8_chr(0x0000), utf8_chr(0x064c), utf8_chr(0x064d), utf8_chr(0x064b), utf8_chr(0x064f), utf8_chr(0x0650),
1135 utf8_chr(0x064e), utf8_chr(0x0651), utf8_chr(0x0653), utf8_chr(0x0670), utf8_chr(0x0654), utf8_chr(0xfe76), utf8_chr(0xfe7a),
1136 utf8_chr(0xfe78), utf8_chr(0xfe7c), utf8_chr(0xfe7e), utf8_chr(0xfe74), utf8_chr(0xfe70), utf8_chr(0xfc5e), utf8_chr(0xfc5f),
1137 utf8_chr(0xfc60), utf8_chr(0xfc61), utf8_chr(0xfc62), utf8_chr(0xfc63));
1140 function arabic($str,$z="",$method='normal')
1142 global $p_chars,$mp_chars, $ignorelist,$nastaligh,$normal;
1143 $str_back = $output = $e_output = $str_next = $str1 = $num = "";
1144 if ($method == 'nastaligh')
1145 $p_chars = array_merge($p_chars, $nastaligh);
1147 $p_chars = array_merge($p_chars, $normal);
1148 $str_len = utf8_strlen($str);
1149 preg_match_all("/./u", $str, $ar);
1150 for ($i = 0; $i < $str_len; $i++)
1152 if (isset($ar[0][$i]))
1154 if(isset($ar[0][$i+1]) && in_array($ar[0][$i+1], $ignorelist))
1156 if (isset($ar[0][$i+2]))
1157 $str_next = $ar[0][$i+2];
1159 $str_back = $ar[0][$i-2];
1160 if ($i > 1 && $i != 2)
1161 $str_back = $ar[0][$i-1];
1163 elseif ($i > 0 && isset($ar[0][$i-1]) && !in_array($ar[0][$i-1], $ignorelist))
1165 if (isset($ar[0][$i+1]))
1166 $str_next = $ar[0][$i+1];
1168 $str_back = $ar[0][$i-1];
1172 if (isset($ar[0][$i+1]) && !empty($ar[0][$i+1]))
1173 $str_next = $ar[0][$i+1];
1174 elseif ($i > 0 && isset($ar[0][$i-1]))
1175 $str_next = $ar[0][$i-1];
1176 if ($i > 1 && isset($ar[0][$i-2]))
1177 $str_back = $ar[0][$i-2];
1179 if (!in_array($str1,$ignorelist))
1181 if (array_key_exists($str1,$p_chars))
1183 if (!$str_back || $str_back==" " || !array_key_exists($str_back,$p_chars))
1185 if (!array_key_exists($str_back, $p_chars) && !array_key_exists($str_next, $p_chars))
1186 $output = $str1.$output;
1188 $output = $p_chars[$str1][2].$output;
1191 elseif (array_key_exists($str_next, $p_chars) && array_key_exists($str_back, $p_chars))
1193 if (in_array($str_back, $mp_chars) && array_key_exists($str_next, $p_chars))
1194 $output = $p_chars[$str1][2].$output;
1196 $output = $p_chars[$str1][1].$output;
1199 elseif (array_key_exists($str_back, $p_chars) && !array_key_exists($str_next, $p_chars))
1201 if (in_array($str_back, $mp_chars))
1202 $output = $str1.$output;
1204 $output = $p_chars[$str1][0].$output;
1210 $number = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
1211 "\xD9\xA0", "\xD9\xA1", "\xD9\xA2", "\xD9\xA3", "\xD9\xA4", "\xD9\xA5", "\xD9\xA6",
1212 "\xD9\xA7", "\xD9\xA8", "\xD9\xA9", "\xDB\xB0", "\xDB\xB1", "\xDB\xB2", "\xDB\xB3",
1213 "\xDB\xB4", "\xDB\xB5", "\xDB\xB6", "\xDB\xB7", "\xDB\xB8", "\xDB\xB9");
1214 if (in_array($str1, $number))
1219 if (!in_array($str_next, $number))
1224 //$output = $str1.$output;
1225 $output = $output.$str1;
1229 $number = array (utf8_chr(0x0660), utf8_chr(0x0661), utf8_chr(0x0662),
1230 utf8_chr(0x0663), utf8_chr(0x0664), utf8_chr(0x0665), utf8_chr(0x0666),
1231 utf8_chr(0x0667), utf8_chr(0x0668), utf8_chr(0x0669), utf8_chr(0x06f4),
1232 utf8_chr(0x06f5), utf8_chr(0x06f6), utf8_chr(0x0030), utf8_chr(0x0031),
1233 utf8_chr(0x0032), utf8_chr(0x0033), utf8_chr(0x0034), utf8_chr(0x0035),
1234 utf8_chr(0x0036), utf8_chr(0x0037), utf8_chr(0x0038), utf8_chr(0x0039));
1262 if (in_array($str1, $number))
1267 if (!in_array($str_next, $number))
1272 $output = $str1.$output;
1276 if (($str1 == utf8_chr(0x060c)) || ($str1 == utf8_chr(0x061f)) || ($str1 == utf8_chr(0x0621)) ||
1277 (array_key_exists($str_next, $p_chars) && array_key_exists($str_back, $p_chars)) ||
1278 ($str1 == " " && array_key_exists($str_back, $p_chars)) || ($str1 == " " &&
1279 array_key_exists($str_next, $p_chars)))
1283 $output = $e_output.$output;
1286 $output = $str1.$output;
1291 if (array_key_exists($str_next, $p_chars) || $str_next == "")
1293 $output = $e_output.$output;
1300 $output = $str1.$output;