PageRenderTime 72ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/reporting/includes/class.graphic.inc

https://bitbucket.org/meerdevelopersoffice/bolivia
PHP | 1307 lines | 994 code | 131 blank | 182 comment | 215 complexity | e591a4f7dd8c991654b0ce38f3e21815 MD5 | raw file
Possible License(s): Apache-2.0, GPL-3.0, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. *
  4. * graph
  5. * version 1.0
  6. *
  7. *
  8. *
  9. * Author: Carlos Reche/Joe Hunt
  10. * E-mail: carlosreche@yahoo.com/joe.hunt.consulting@gmail.com
  11. * Sorocaba, SP - Brazil/Wellington, New Zealand
  12. *
  13. * Created: Sep 20, 2004
  14. * Last Modification: Sep 20, 2004/Apr 01, 2007
  15. *
  16. *
  17. *
  18. * Authors' comments:
  19. *
  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.
  24. *
  25. * This script is free. Please keep the credits.
  26. *
  27. */
  28. /**
  29. INSTRUNCTIONS OF HOW TO USE THIS SCRIPT (Please, take a minute to read it. It's important!)
  30. NOTE: make sure that your PHP is compiled to work with GD Lib.
  31. ///// START OF EXAMPLE.PHP /////
  32. <?php
  33. require "class.graphics.inc";
  34. $pg = new graph;
  35. $pg->title = "Sex";
  36. $pg->type = "5";
  37. $pg->x[0] = "male";
  38. $pg->y[0] = "50";
  39. $pg->x[1] = "female";
  40. $pg->y[1] = "55";
  41. $pg->display();
  42. ?>
  43. In your html file you set it up as:
  44. .....
  45. <img src="example.php" border="1" />
  46. .....
  47. You can supply extra parameters to display(). Ex. $pg->display("test.png") will save the image to a file.
  48. Ex. $pg->display("", true) will paint a border around the image. It might be suitable if you choose to save to
  49. file for later presentation.
  50. ///// END OF EXAMPLE.PHP /////
  51. Here is a list of all parameters you may set:
  52. title => Title of the graphic
  53. axis_x => Name of values from Axis X
  54. axis_y => Name of values from Axis Y
  55. graphic_1 => Name of Graphic_1 (only shown if you are gonna cross data from 2 different graphics)
  56. graphic_2 => Name of Graphic_2 (same comment of above)
  57. type => Type of graphic (values 1 to 6)
  58. 1 => Vertical bars (default)
  59. 2 => Horizontal bars
  60. 3 => Dots
  61. 4 => Lines
  62. 5 => Pie
  63. 6 => Donut
  64. skin => Skin of the graphic (values 1 to 3)
  65. 1 => Office (default)
  66. 2 => Matrix
  67. 3 => Spring
  68. credits => Only if you want to show my credits in the image. :)
  69. 0 => doesn't show (default)
  70. 1 => shows
  71. x[0] => Name of the first parameter in Axis X
  72. x[1] => Name of the second parameter in Axis X
  73. ... (etc)
  74. y[0] => Value from "graphic_1" relative for "x[0]"
  75. y[1] => Value from "graphic_1" relative for "x[1]"
  76. ... (etc)
  77. z[0] => Value from "graphic_2" relative for "x[0]"
  78. z[1] => Value from "graphic_2" relative for "x[1]"
  79. ... (etc)
  80. NOTE: You can't cross data between graphics if you use "pie" or "donut" graphic. Values for "z"
  81. won't be considerated.
  82. That's all! Hope you make a good use of it!
  83. It would be nice to receive feedback from others users. All comments are welcome!
  84. Regards,
  85. Carlos Reche
  86. */
  87. class graph
  88. {
  89. var $x;
  90. var $y;
  91. var $z;
  92. var $title;
  93. var $axis_x;
  94. var $axis_y;
  95. var $graphic_1;
  96. var $graphic_2;
  97. var $type = 1;
  98. var $skin = 1;
  99. var $credits = 0;
  100. var $latin_notation;
  101. var $width;
  102. var $height;
  103. var $height_title;
  104. var $alternate_x;
  105. var $size = 2;
  106. var $tsize = 5;
  107. var $total_parameters;
  108. var $sum_total;
  109. var $biggest_value;
  110. var $biggest_parameter;
  111. var $available_types;
  112. var $dec1 = 0;
  113. var $dec2 = 0;
  114. var $h3d = 15; // 3D height
  115. var $built_in = false;
  116. var $fontfile = "";
  117. var $encoding;
  118. function graph()
  119. {
  120. global $UTF8_fontfile;
  121. $this->encoding = strtoupper($_SESSION['language']->encoding);
  122. $path = dirname(__FILE__).'/../fonts/';
  123. // If you use UTF-8 encoding you have to download and install FreeSans.ttf font.
  124. // It is not bundled with application due to its size.
  125. // You can also use another UTF-8 font and put it in config.php with the name in $UTF8_fontfile
  126. $this->fontfile = $this->encoding == 'UTF-8' ? (isset($UTF8_fontfile) && $UTF8_fontfile != "" ? $path.$UTF8_fontfile : $path.'FreeSans.ttf') :
  127. $path.'LiberationSans-Regular.ttf';
  128. $this->x = $this->y = $this->z = array();
  129. $this->biggest_x = NULL;
  130. $this->biggest_y = NULL;
  131. $this->alternate_x = false;
  132. $this->graphic_2_exists = false;
  133. $this->total_parameters = 0;
  134. $this->sum_total = 1;
  135. $this->latin_notation = false;
  136. }
  137. function display($save="", $border=false)
  138. {
  139. $this->legend_exists = (preg_match("/(5|6)/", $this->type)) ? true : false;
  140. $this->biggest_graphic_name = (strlen($this->graphic_1) > strlen($this->graphic_2)) ? $this->graphic_1 : $this->graphic_2;
  141. $this->height_title = (!empty($this->title)) ? ($this->string_height($this->tsize) + 15) : 0;
  142. $this->space_between_bars = ($this->type == 1) ? 40 : 30;
  143. $this->space_between_dots = 40;
  144. $this->higher_value = 0;
  145. $this->higher_value_str = 0;
  146. $this->width = 0;
  147. $this->height = 0;
  148. $this->graphic_area_width = 0;
  149. $this->graphic_area_height = 0;
  150. $this->graphic_area_x1 = 30;
  151. $this->graphic_area_y1 = 20 + $this->height_title;
  152. $this->graphic_area_x2 = $this->graphic_area_x1 + $this->graphic_area_width;
  153. $this->graphic_area_y2 = $this->graphic_area_y1 + $this->graphic_area_height;
  154. if (count($this->z) && (preg_match("/(1|2|3|4)/", $this->type)))
  155. $this->graphic_2_exists = true;
  156. $this->total_parameters = count($this->x);
  157. for ($i = 0; $i < $this->total_parameters; $i++)
  158. {
  159. if (strlen($this->x[$i]) > strlen($this->biggest_x))
  160. $this->biggest_x = $this->x[$i];
  161. if ($this->y[$i] > $this->biggest_y)
  162. $this->biggest_y = number_format(round($this->y[$i], 1), 1, ".", "");
  163. if ($this->graphic_2_exists)
  164. {
  165. if (isset($this->z[$i]) && $this->z[$i] > $this->biggest_y)
  166. $this->biggest_y = number_format(round($this->z[$i], 1), 1, ".", "");
  167. }
  168. }
  169. if (($this->graphic_2_exists == true) && ((!empty($this->graphic_1)) || (!empty($this->graphic_2))))
  170. {
  171. $this->legend_exists = true;
  172. }
  173. $this->sum_total = array_sum($this->y);
  174. if ($this->sum_total == 0)
  175. $this->sum_total = 1;
  176. $this->space_between_bars += ($this->graphic_2_exists == true) ? 10 : 0;
  177. $this->calculate_higher_value();
  178. $this->calculate_width();
  179. $this->calculate_height();
  180. $this->create_graphic($save, $border);
  181. }
  182. function create_graphic($save="", $border=false)
  183. {
  184. $size = 3;
  185. $this->img = imagecreatetruecolor($this->width, $this->height);
  186. $this->load_color_palette();
  187. // Fill background
  188. imagefill($this->img, 0, 0, $this->color['background']);
  189. //imagefilledrectangle($this->img, 0, 0, $this->width, $this->height, $this->color['background']);
  190. //if ($border)
  191. // imagerectangle($this->img, 0, 0, $this->width-1, $this->height-1, imagecolorallocate($this->img, 100, 150, 200));
  192. // Draw title
  193. if (!empty($this->title))
  194. {
  195. $center = ($this->width / 2) - ($this->string_width($this->title, $this->tsize) / 2);
  196. $this->_imagestring($this->img, $this->tsize, $center, 10, $this->title, $this->color['title']);
  197. }
  198. // Draw axis and background lines for "vertical bars", "dots" and "lines"
  199. if (preg_match("/^(1|3|4)$/", $this->type))
  200. {
  201. if ($this->legend_exists == true)
  202. {
  203. $this->draw_legend();
  204. }
  205. $higher_value_y = $this->graphic_area_y1 + (0.1 * $this->graphic_area_height);
  206. $higher_value_size = 0.9 * $this->graphic_area_height;
  207. $less = 7 * strlen($this->higher_value_str);
  208. imageline($this->img, $this->graphic_area_x1, $higher_value_y, $this->graphic_area_x2, $higher_value_y, $this->color['bg_lines']);
  209. $this->_imagestring($this->img, $this->size, ($this->graphic_area_x1-$less-7), ($higher_value_y-7), $this->higher_value_str, $this->color['axis_values']);
  210. for ($i = 1; $i < 10; $i++)
  211. {
  212. $dec_y = $i * ($higher_value_size / 10);
  213. $x1 = $this->graphic_area_x1;
  214. $y1 = $this->graphic_area_y2 - $dec_y;
  215. $x2 = $this->graphic_area_x2;
  216. $y2 = $this->graphic_area_y2 - $dec_y;
  217. imageline($this->img, $x1, $y1, $x2, $y2, $this->color['bg_lines']);
  218. if ($i % 2 == 0)
  219. {
  220. $value = $this->number_formated($this->higher_value * $i / 10, $this->dec1);
  221. $len1 = strlen($this->higher_value_str);
  222. $len2 = strlen($value);
  223. if ($len2 < $len1)
  224. $len2 += ($len1-$len2-1);
  225. $less = 7 * $len2;
  226. //$this->_imagestring($this->img, $this->size, ($x1-$less-7), ($y2-7), $value, $this->color['axis_values']);
  227. $this->_imagestring($this->img, $this->size, ($x1-$less-7), ($y2-7), $value, $this->color['axis_values']);
  228. }
  229. }
  230. // Axis X
  231. //$this->_imagestring($this->img, $this->size, $this->graphic_area_x2+10, $this->graphic_area_y2+3, $this->axis_x, $this->color['title']);
  232. $this->_imagestring($this->img, $this->size, $this->graphic_area_x2+40, $this->graphic_area_y2+3, $this->axis_x, $this->color['title']);
  233. imageline($this->img, $this->graphic_area_x1, $this->graphic_area_y2, $this->graphic_area_x2, $this->graphic_area_y2, $this->color['axis_line']);
  234. // Axis Y
  235. $this->_imagestring($this->img, $this->size, 20, $this->graphic_area_y1-20, $this->axis_y, $this->color['title']);
  236. imageline($this->img, $this->graphic_area_x1, $this->graphic_area_y1, $this->graphic_area_x1, $this->graphic_area_y2, $this->color['axis_line']);
  237. }
  238. // Draw axis and background lines for "horizontal bars"
  239. else if ($this->type == 2)
  240. {
  241. if ($this->legend_exists == true)
  242. {
  243. $this->draw_legend();
  244. }
  245. $higher_value_x = $this->graphic_area_x2 - (0.2 * $this->graphic_area_width);
  246. $higher_value_size = 0.8 * $this->graphic_area_width;
  247. 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']);
  248. $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']);
  249. for ($i = 1, $alt = 15; $i < 10; $i++)
  250. {
  251. $dec_x = number_format(round($i * ($higher_value_size / 10), 1), 1, ".", "");
  252. 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']);
  253. if ($i % 2 == 0)
  254. {
  255. $alt = (strlen($this->biggest_y) > 4 && $alt != 15) ? 15 : 2;
  256. $value = $this->number_formated($this->higher_value * $i / 10, $this->dec1);
  257. $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);
  258. }
  259. }
  260. // Axis X
  261. $this->_imagestring($this->img, $this->size, ($this->graphic_area_x2+10), ($this->graphic_area_y2+3), $this->axis_y, $this->color['title']);
  262. imageline($this->img, $this->graphic_area_x1, $this->graphic_area_y2, $this->graphic_area_x2, $this->graphic_area_y2, $this->color['axis_line']);
  263. // Axis Y
  264. $this->_imagestring($this->img, $this->size, 20, ($this->graphic_area_y1-20), $this->axis_x, $this->color['title']);
  265. imageline($this->img, $this->graphic_area_x1, $this->graphic_area_y1, $this->graphic_area_x1, $this->graphic_area_y2, $this->color['axis_line']);
  266. }
  267. // Draw legend box for "pie" or "donut"
  268. else if (preg_match("/^(5|6)$/", $this->type))
  269. {
  270. $this->draw_legend();
  271. }
  272. /**
  273. * Draw graphic: VERTICAL BARS
  274. */
  275. if ($this->type == 1)
  276. {
  277. $num = 1;
  278. $x = $this->graphic_area_x1 + 20;
  279. foreach ($this->x as $i => $parameter)
  280. {
  281. if (isset($this->z[$i]))
  282. {
  283. $size = round($this->z[$i] * $higher_value_size / $this->higher_value);
  284. $x1 = $x + 10;
  285. $y1 = ($this->graphic_area_y2 - $size) + 1;
  286. $x2 = $x1 + 20;
  287. $y2 = $this->graphic_area_y2 - 1;
  288. imageline($this->img, ($x1+1), ($y1-1), $x2, ($y1-1), $this->color['bars_2_shadow']);
  289. imageline($this->img, ($x2+1), ($y1-1), ($x2+1), $y2, $this->color['bars_2_shadow']);
  290. imageline($this->img, ($x2+2), ($y1-1), ($x2+2), $y2, $this->color['bars_2_shadow']);
  291. imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars_2']);
  292. }
  293. $size = round($this->y[$i] * $higher_value_size / $this->higher_value);
  294. $alt = (($num % 2 == 0) && (strlen($this->biggest_x) > 5)) ? 15 : 2;
  295. $x1 = $x;
  296. $y1 = ($this->graphic_area_y2 - $size) + 1;
  297. $x2 = $x1 + 20;
  298. $y2 = $this->graphic_area_y2 - 1;
  299. $x += $this->space_between_bars;
  300. $num++;
  301. imageline($this->img, ($x1+1), ($y1-1), $x2, ($y1-1), $this->color['bars_shadow']);
  302. imageline($this->img, ($x2+1), ($y1-1), ($x2+1), $y2, $this->color['bars_shadow']);
  303. imageline($this->img, ($x2+2), ($y1-1), ($x2+2), $y2, $this->color['bars_shadow']);
  304. imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars']);
  305. //$this->_imagestring($this->img, $this->size, ((($x1+$x2)/2) - (strlen($parameter)*7/2)), ($y2+2), $parameter, $this->color['axis_values'], $alt);
  306. $this->_imagestring($this->img, $this->size, $x1, ($y2+2), $parameter, $this->color['axis_values'], $alt);
  307. }
  308. }
  309. /**
  310. * Draw graphic: HORIZONTAL BARS
  311. */
  312. else if ($this->type == 2)
  313. {
  314. $y = 10;
  315. foreach ($this->x as $i => $parameter)
  316. {
  317. if (isset($this->z[$i]))
  318. {
  319. $size = round($this->z[$i] * $higher_value_size / $this->higher_value);
  320. $x1 = $this->graphic_area_x1 + 1;
  321. $y1 = $this->graphic_area_y1 + $y + 10;
  322. $x2 = $x1 + $size;
  323. $y2 = $y1 + 15;
  324. imageline($this->img, ($x1), ($y2+1), $x2, ($y2+1), $this->color['bars_2_shadow']);
  325. imageline($this->img, ($x1), ($y2+2), $x2, ($y2+2), $this->color['bars_2_shadow']);
  326. imageline($this->img, ($x2+1), ($y1+1), ($x2+1), ($y2+2), $this->color['bars_2_shadow']);
  327. imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars_2']);
  328. $this->_imagestring($this->img, $this->size, ($x2+7), ($y1+7), $this->number_formated($this->z[$i], $this->dec2), $this->color['bars_2_shadow']);
  329. }
  330. $size = round(($this->y[$i] / $this->higher_value) * $higher_value_size);
  331. $x1 = $this->graphic_area_x1 + 1;
  332. $y1 = $this->graphic_area_y1 + $y;
  333. $x2 = $x1 + $size;
  334. $y2 = $y1 + 15;
  335. $y += $this->space_between_bars;
  336. imageline($this->img, ($x1), ($y2+1), $x2, ($y2+1), $this->color['bars_shadow']);
  337. imageline($this->img, ($x1), ($y2+2), $x2, ($y2+2), $this->color['bars_shadow']);
  338. imageline($this->img, ($x2+1), ($y1+1), ($x2+1), ($y2+2), $this->color['bars_shadow']);
  339. imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars']);
  340. $this->_imagestring($this->img, $this->size, ($x2+7), ($y1+2), $this->number_formated($this->y[$i], $this->dec2), $this->color['bars_shadow']);
  341. //$this->_imagestring($this->img, $this->size, ($x1 - ((strlen($parameter)*7)+7)), ($y1+2), $parameter, $this->color['axis_values']);
  342. $this->_imagestring($this->img, $this->size, 30, ($y1+2), $parameter, $this->color['axis_values']);
  343. }
  344. }
  345. /**
  346. * Draw graphic: DOTS or LINE
  347. */
  348. else if (preg_match("/^(3|4)$/", $this->type))
  349. {
  350. $x[0] = $this->graphic_area_x1+1;
  351. foreach ($this->x as $i => $parameter)
  352. {
  353. if ($this->graphic_2_exists == true)
  354. {
  355. $size = round($this->z[$i] * $higher_value_size / $this->higher_value);
  356. $z[$i] = $this->graphic_area_y2 - $size;
  357. }
  358. $alt = (($i % 2 == 0) && (strlen($this->biggest_x) > 5)) ? 15 : 2;
  359. $size = round($this->y[$i] * $higher_value_size / $this->higher_value);
  360. $y[$i] = $this->graphic_area_y2 - $size;
  361. if ($i != 0)
  362. {
  363. imageline($this->img, $x[$i], ($this->graphic_area_y1+10), $x[$i], ($this->graphic_area_y2-1), $this->color['bg_lines']);
  364. }
  365. //$this->_imagestring($this->img, $this->size, ($x[$i] - (strlen($parameter)*7/2 )), ($this->graphic_area_y2+2), $parameter, $this->color['axis_values'], $alt);
  366. $this->_imagestring($this->img, $this->size, $x[$i], ($this->graphic_area_y2+2), $parameter, $this->color['axis_values'], $alt);
  367. $x[$i+1] = $x[$i] + 40;
  368. }
  369. foreach ($x as $i => $value_x)
  370. {
  371. if ($this->graphic_2_exists == true)
  372. {
  373. if (isset($z[$i+1]))
  374. {
  375. // Draw lines
  376. if ($this->type == 4)
  377. {
  378. imageline($this->img, $x[$i], $z[$i], $x[$i+1], $z[$i+1], $this->color['line_2']);
  379. imageline($this->img, $x[$i], ($z[$i]+1), $x[$i+1], ($z[$i+1]+1), $this->color['line_2']);
  380. }
  381. imagefilledrectangle($this->img, $x[$i]-1, $z[$i]-1, $x[$i]+2, $z[$i]+2, $this->color['line_2']);
  382. }
  383. else
  384. { // Draw last dot
  385. imagefilledrectangle($this->img, $x[$i-1]-1, $z[$i-1]-1, $x[$i-1]+2, $z[$i-1]+2, $this->color['line_2']);
  386. }
  387. }
  388. if (count($y) > 1)
  389. {
  390. if (isset($y[$i+1]))
  391. {
  392. // Draw lines
  393. if ($this->type == 4)
  394. {
  395. imageline($this->img, $x[$i], $y[$i], $x[$i+1], $y[$i+1], $this->color['line']);
  396. imageline($this->img, $x[$i], ($y[$i]+1), $x[$i+1], ($y[$i+1]+1), $this->color['line']);
  397. }
  398. imagefilledrectangle($this->img, $x[$i]-1, $y[$i]-1, $x[$i]+2, $y[$i]+2, $this->color['line']);
  399. }
  400. else
  401. { // Draw last dot
  402. imagefilledrectangle($this->img, $x[$i-1]-1, $y[$i-1]-1, $x[$i-1]+2, $y[$i-1]+2, $this->color['line']);
  403. }
  404. }
  405. }
  406. }
  407. /**
  408. * Draw graphic: PIE or DONUT
  409. */
  410. else if (preg_match("/^(5|6)$/", $this->type))
  411. {
  412. $center_x = ($this->graphic_area_x1 + $this->graphic_area_x2) / 2;
  413. $center_y = ($this->graphic_area_y1 + $this->graphic_area_y2) / 2;
  414. $width = $this->graphic_area_width;
  415. $height = $this->graphic_area_height;
  416. $start = 0;
  417. $sizes = array();
  418. foreach ($this->x as $i => $parameter)
  419. {
  420. $size = $this->y[$i] * 360 / $this->sum_total;
  421. $size = round2($size, 0);
  422. $sizes[] = $size;
  423. $start += $size;
  424. }
  425. $start = 270;
  426. // Draw PIE
  427. if ($this->type == 5)
  428. {
  429. // Draw shadow
  430. foreach ($sizes as $i => $size)
  431. {
  432. $num_color = $i + 1;
  433. while ($num_color > 7)
  434. {
  435. $num_color -= 5;
  436. }
  437. $color = 'arc_' . $num_color . '_shadow';
  438. for ($i = $this->h3d; $i >= 0; $i--)
  439. {
  440. //imagearc($this->img, $center_x, ($center_y+$i), $width, $height, $start, ($start+$size), $this->color[$color]);
  441. if ($size >= 1)
  442. imagefilledarc($this->img, $center_x, ($center_y+$i), $width, $height, $start, ($start+$size), $this->color[$color], IMG_ARC_NOFILL);
  443. }
  444. $start += $size;
  445. }
  446. $start = 270;
  447. // Draw pieces
  448. foreach ($sizes as $i => $size)
  449. {
  450. $num_color = $i + 1;
  451. while ($num_color > 7)
  452. {
  453. $num_color -= 5;
  454. }
  455. $color = 'arc_' . $num_color;
  456. if ($size >= 1)
  457. imagefilledarc($this->img, $center_x, $center_y, ($width+2), ($height+2), $start, ($start+$size), $this->color[$color], IMG_ARC_EDGED);
  458. $start += $size;
  459. }
  460. }
  461. // Draw DONUT
  462. else if ($this->type == 6)
  463. {
  464. foreach ($sizes as $i => $size)
  465. {
  466. $num_color = $i + 1;
  467. while ($num_color > 7)
  468. {
  469. $num_color -= 5;
  470. }
  471. $color = 'arc_' . $num_color;
  472. $color_shadow = 'arc_' . $num_color . '_shadow';
  473. if ($size >= 1)
  474. imagefilledarc($this->img, $center_x, $center_y, $width, $height, $start, ($start+$size), $this->color[$color], IMG_ARC_PIE);
  475. $start += $size;
  476. }
  477. imagefilledarc($this->img, $center_x, $center_y, 100, 100, 0, 360, $this->color['background'], IMG_ARC_PIE);
  478. imagearc($this->img, $center_x, $center_y, 100, 100, 0, 360, $this->color['bg_legend']);
  479. imagearc($this->img, $center_x, $center_y, ($width+1), ($height+1), 0, 360, $this->color['bg_legend']);
  480. }
  481. }
  482. if ($this->credits == true)
  483. {
  484. $this->draw_credits();
  485. }
  486. if ($save != "")
  487. imagepng($this->img, $save);
  488. else
  489. {
  490. header('Content-type: image/png');
  491. imagepng($this->img);
  492. }
  493. imagedestroy($this->img);
  494. }
  495. function calculate_width()
  496. {
  497. switch ($this->type)
  498. {
  499. // Vertical bars
  500. case 1:
  501. $this->legend_box_width = ($this->legend_exists == true) ? ($this->string_width($this->biggest_graphic_name, $this->tsize) + 25) : 0;
  502. $this->graphic_area_width = ($this->space_between_bars * $this->total_parameters) + 30;
  503. $this->graphic_area_x1 += $this->string_width(($this->higher_value_str), $this->size);
  504. $this->width += $this->graphic_area_x1 + 20;
  505. $this->width += ($this->legend_exists == true) ? 50 : ((7 * strlen($this->axis_x)) + 10);
  506. break;
  507. // Horizontal bars
  508. case 2:
  509. $this->legend_box_width = ($this->legend_exists == true) ? ($this->string_width($this->biggest_graphic_name, $this->size) + 25) : 0;
  510. $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;
  511. $this->graphic_area_x1 += 7 * strlen($this->biggest_x);
  512. $this->width += ($this->legend_exists == true) ? 60 : ((7 * strlen($this->axis_y)) + 30);
  513. $this->width += $this->graphic_area_x1;
  514. break;
  515. // Dots
  516. case 3:
  517. $this->legend_box_width = ($this->legend_exists == true) ? ($this->string_width($this->biggest_graphic_name, $this->size) + 25) : 0;
  518. $this->graphic_area_width = ($this->space_between_dots * $this->total_parameters) - 10;
  519. $this->graphic_area_x1 += $this->string_width(($this->higher_value_str), $this->size);
  520. $this->width += $this->graphic_area_x1 + 20;
  521. $this->width += ($this->legend_exists == true) ? 40 : ((7 * strlen($this->axis_x)) + 30);
  522. break;
  523. // Lines
  524. case 4:
  525. $this->legend_box_width = ($this->legend_exists == true) ? ($this->string_width($this->biggest_graphic_name, $this->size) + 25) : 0;
  526. $this->graphic_area_width = ($this->space_between_dots * $this->total_parameters) - 10;
  527. $this->graphic_area_x1 += $this->string_width(($this->higher_value_str), $this->size);
  528. $this->width += $this->graphic_area_x1 + 20;
  529. $this->width += ($this->legend_exists == true) ? 40 : ((7 * strlen($this->axis_x)) + 30);
  530. break;
  531. // Pie
  532. case 5:
  533. $this->legend_box_width = $this->string_width($this->biggest_x, $this->size) + 85;
  534. $this->graphic_area_width = 200;
  535. $this->width += 90;
  536. break;
  537. // Donut
  538. case 6:
  539. $this->legend_box_width = $this->string_width($this->biggest_x, $this->size) + 85;
  540. $this->graphic_area_width = 180;
  541. $this->width += 90;
  542. break;
  543. }
  544. $this->graphic_area_width = max($this->graphic_area_width, $this->string_width($this->title, $this->size));
  545. $this->width += $this->graphic_area_width;
  546. $this->width += $this->legend_box_width;
  547. $this->graphic_area_x2 = $this->graphic_area_x1 + $this->graphic_area_width;
  548. $this->legend_box_x1 = $this->graphic_area_x2 + 40;
  549. $this->legend_box_x2 = $this->legend_box_x1 + $this->legend_box_width;
  550. }
  551. function calculate_height()
  552. {
  553. switch ($this->type)
  554. {
  555. // Vertical bars
  556. case 1:
  557. $this->legend_box_height = ($this->graphic_2_exists == true) ? 40 : 0;
  558. $this->graphic_area_height = 150;
  559. $this->height += 65;
  560. break;
  561. // Horizontal bars
  562. case 2:
  563. $this->legend_box_height = ($this->graphic_2_exists == true) ? 40 : 0;
  564. $this->graphic_area_height = ($this->space_between_bars * $this->total_parameters) + 10;
  565. $this->height += 65;
  566. break;
  567. // Dots
  568. case 3:
  569. $this->legend_box_height = ($this->graphic_2_exists == true) ? 40 : 0;
  570. $this->graphic_area_height = 150;
  571. $this->height += 65;
  572. break;
  573. // Lines
  574. case 4:
  575. $this->legend_box_height = ($this->graphic_2_exists == true) ? 40 : 0;
  576. $this->graphic_area_height = 150;
  577. $this->height += 65;
  578. break;
  579. // Pie
  580. case 5:
  581. $this->legend_box_height = (!empty($this->axis_x)) ? 30 : 5;
  582. $this->legend_box_height += (14 * $this->total_parameters);
  583. $this->graphic_area_height = 150;
  584. $this->height += 50;
  585. break;
  586. // Donut
  587. case 6:
  588. $this->legend_box_height = (!empty($this->axis_x)) ? 30 : 5;
  589. $this->legend_box_height += (14 * $this->total_parameters);
  590. $this->graphic_area_height = 180;
  591. $this->height += 50;
  592. break;
  593. }
  594. $this->height += $this->height_title;
  595. $this->height += ($this->legend_box_height > $this->graphic_area_height) ? ($this->legend_box_height - $this->graphic_area_height) : 0;
  596. $this->height += $this->graphic_area_height;
  597. $this->graphic_area_y2 = $this->graphic_area_y1 + $this->graphic_area_height;
  598. $this->legend_box_y1 = $this->graphic_area_y1 + 10;
  599. $this->legend_box_y2 = $this->legend_box_y1 + $this->legend_box_height;
  600. }
  601. function draw_legend()
  602. {
  603. $x1 = $this->legend_box_x1;
  604. $y1 = $this->legend_box_y1;
  605. $x2 = $this->legend_box_x2;
  606. $y2 = $this->legend_box_y2;
  607. imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bg_legend']);
  608. $x = $x1 + 5;
  609. $y = $y1 + 5;
  610. // Draw legend values for VERTICAL BARS, HORIZONTAL BARS, DOTS and LINES
  611. if (preg_match("/^(1|2|3|4)$/", $this->type))
  612. {
  613. $color_1 = (preg_match("/^(1|2)$/", $this->type)) ? $this->color['bars'] : $this->color['line'];
  614. $color_2 = (preg_match("/^(1|2)$/", $this->type)) ? $this->color['bars_2'] : $this->color['line_2'];
  615. imagefilledrectangle($this->img, $x, $y, ($x+10), ($y+10), $color_1);
  616. imagerectangle($this->img, $x, $y, ($x+10), ($y+10), $this->color['title']);
  617. $this->_imagestring($this->img, $this->size, ($x+15), ($y-2), $this->graphic_1, $this->color['axis_values']);
  618. $y += 20;
  619. imagefilledrectangle($this->img, $x, $y, ($x+10), ($y+10), $color_2);
  620. imagerectangle($this->img, $x, $y, ($x+10), ($y+10), $this->color['title']);
  621. $this->_imagestring($this->img, $this->size, ($x+15), ($y-2), $this->graphic_2, $this->color['axis_values']);
  622. }
  623. // Draw legend values for PIE or DONUT
  624. else if (preg_match("/^(5|6)$/", $this->type))
  625. {
  626. if (!empty($this->axis_x))
  627. {
  628. $this->_imagestring($this->img, $this->size, ((($x1+$x2)/2) - (strlen($this->axis_x)*7/2)), $y,
  629. $this->axis_x." (".$this->graphic_1.")", $this->color['title']);
  630. $y += 25;
  631. }
  632. $num = 1;
  633. foreach ($this->x as $i => $parameter)
  634. {
  635. while ($num > 7)
  636. {
  637. $num -= 5;
  638. }
  639. $color = 'arc_' . $num;
  640. $percent = number_format(round(($this->y[$i] * 100 / $this->sum_total), 2), 2, ".", "") . ' %';
  641. $less = (strlen($percent) * 7);
  642. if ($num != 1)
  643. {
  644. imageline($this->img, ($x1+15), ($y-2), ($x2-5), ($y-2), $this->color['bg_lines']);
  645. }
  646. imagefilledrectangle($this->img, $x, $y, ($x+10), ($y+10), $this->color[$color]);
  647. imagerectangle($this->img, $x, $y, ($x+10), ($y+10), $this->color['title']);
  648. $this->_imagestring($this->img, $this->size, ($x+15), ($y-2), $parameter, $this->color['axis_values']);
  649. $this->_imagestring($this->img, $this->size, ($x2-$less), ($y-2), $percent, $this->color['axis_values']);
  650. $y += 14;
  651. $num++;
  652. }
  653. }
  654. }
  655. function string_width($string, $size)
  656. {
  657. $single_width = $size + 4;
  658. if ($this->encoding == "UTF-8")
  659. $width = mb_strlen($string, "UTF-8");
  660. else
  661. $width = strlen($string);
  662. return $single_width * $width;
  663. }
  664. function string_height($size)
  665. {
  666. if ($size <= 1)
  667. {
  668. $height = 8;
  669. }
  670. else if ($size <= 3)
  671. {
  672. $height = 12;
  673. }
  674. else if ($size >= 4)
  675. {
  676. $height = 14;
  677. }
  678. return $height;
  679. }
  680. function calculate_higher_value()
  681. {
  682. $digits = strlen(round($this->biggest_y));
  683. $interval = pow(10, ($digits-1));
  684. $this->higher_value = round(($this->biggest_y - ($this->biggest_y % $interval) + $interval), 1);
  685. $this->higher_value_str = $this->number_formated($this->higher_value, $this->dec1);
  686. }
  687. function number_formated($number, $dec_size = 1)
  688. {
  689. if ($this->latin_notation == true)
  690. return number_format(round($number, $dec_size), $dec_size, ",", ".");
  691. return number_format(round($number, $dec_size), $dec_size, ".", ",");
  692. }
  693. function number_float($number)
  694. {
  695. if ($this->latin_notation == true)
  696. $number = str_replace(".", "", $number);
  697. return (float)str_replace(",", "", $number);
  698. }
  699. function draw_credits()
  700. {
  701. $this->_imagestring($this->img, $this->size - 2, ($this->width-120), ($this->height-10), "Powered by Carlos Reche", $this->color['title']);
  702. }
  703. function load_color_palette()
  704. {
  705. switch ($this->skin)
  706. {
  707. // Office
  708. case 1:
  709. //$this->color['title'] = imagecolorallocate($this->img, 50, 50, 50);
  710. $this->color['title'] = imagecolorallocate($this->img, 40, 70, 130);
  711. //$this->color['background'] = imagecolorallocate($this->img, 238, 255, 238);
  712. $this->color['background'] = imagecolorallocate($this->img, 255, 255, 255);
  713. $this->color['axis_values'] = imagecolorallocate($this->img, 50, 50, 50);
  714. $this->color['axis_line'] = imagecolorallocate($this->img, 100, 100, 100);
  715. $this->color['bg_lines'] = imagecolorallocate($this->img, 220, 220, 220);
  716. $this->color['bg_legend'] = imagecolorallocate($this->img, 255, 255, 255);
  717. if (preg_match("/^(1|2)$/", $this->type))
  718. {
  719. $this->color['bars'] = imagecolorallocate($this->img, 100, 150, 200);
  720. $this->color['bars_shadow'] = imagecolorallocate($this->img, 50, 100, 150);
  721. $this->color['bars_2'] = imagecolorallocate($this->img, 200, 250, 150);
  722. $this->color['bars_2_shadow'] = imagecolorallocate($this->img, 120, 170, 70);
  723. }
  724. else if (preg_match("/^(3|4)$/", $this->type))
  725. {
  726. $this->color['line'] = imagecolorallocate($this->img, 100, 150, 200);
  727. $this->color['line_2'] = imagecolorallocate($this->img, 230, 100, 100);
  728. }
  729. else if (preg_match("/^(5|6)$/", $this->type))
  730. {
  731. $this->color['arc_1'] = imagecolorallocate($this->img, 255, 150, 0);
  732. $this->color['arc_2'] = imagecolorallocate($this->img, 150, 0, 255);
  733. $this->color['arc_3'] = imagecolorallocate($this->img, 0, 255, 255);
  734. $this->color['arc_4'] = imagecolorallocate($this->img, 255, 0, 0);
  735. $this->color['arc_5'] = imagecolorallocate($this->img, 0, 255, 0);
  736. $this->color['arc_6'] = imagecolorallocate($this->img, 0, 0, 255);
  737. $this->color['arc_7'] = imagecolorallocate($this->img, 255, 255, 0);
  738. $this->color['arc_1_shadow'] = imagecolorallocate($this->img, 127, 75, 0);
  739. $this->color['arc_2_shadow'] = imagecolorallocate($this->img, 75, 0, 127);
  740. $this->color['arc_3_shadow'] = imagecolorallocate($this->img, 0, 127, 127);
  741. $this->color['arc_4_shadow'] = imagecolorallocate($this->img, 127, 0, 0);
  742. $this->color['arc_5_shadow'] = imagecolorallocate($this->img, 0, 127, 0);
  743. $this->color['arc_6_shadow'] = imagecolorallocate($this->img, 0, 0, 127);
  744. $this->color['arc_7_shadow'] = imagecolorallocate($this->img, 127, 127, 0);
  745. }
  746. break;
  747. // Matrix
  748. case 2:
  749. $this->color['title'] = imagecolorallocate($this->img, 255, 255, 255);
  750. $this->color['background'] = imagecolorallocate($this->img, 0, 0, 0);
  751. $this->color['axis_values'] = imagecolorallocate($this->img, 0, 230, 0);
  752. $this->color['axis_line'] = imagecolorallocate($this->img, 0, 200, 0);
  753. $this->color['bg_lines'] = imagecolorallocate($this->img, 100, 100, 100);
  754. $this->color['bg_legend'] = imagecolorallocate($this->img, 70, 70, 70);
  755. if (preg_match("/^(1|2)$/", $this->type))
  756. {
  757. $this->color['bars'] = imagecolorallocate($this->img, 50, 200, 50);
  758. $this->color['bars_shadow'] = imagecolorallocate($this->img, 0, 150, 0);
  759. $this->color['bars_2'] = imagecolorallocate($this->img, 255, 255, 255);
  760. $this->color['bars_2_shadow'] = imagecolorallocate($this->img, 220, 220, 220);
  761. }
  762. else if (preg_match("/^(3|4)$/", $this->type))
  763. {
  764. $this->color['line'] = imagecolorallocate($this->img, 220, 220, 220);
  765. $this->color['line_2'] = imagecolorallocate($this->img, 0, 180, 0);
  766. }
  767. else if (preg_match("/^(5|6)$/", $this->type))
  768. {
  769. $this->color['arc_1'] = imagecolorallocate($this->img, 255, 255, 255);
  770. $this->color['arc_2'] = imagecolorallocate($this->img, 200, 220, 200);
  771. $this->color['arc_3'] = imagecolorallocate($this->img, 160, 200, 160);
  772. $this->color['arc_4'] = imagecolorallocate($this->img, 135, 180, 135);
  773. $this->color['arc_5'] = imagecolorallocate($this->img, 115, 160, 115);
  774. $this->color['arc_6'] = imagecolorallocate($this->img, 100, 140, 100);
  775. $this->color['arc_7'] = imagecolorallocate($this->img, 90, 120, 90);
  776. $this->color['arc_1_shadow'] = imagecolorallocate($this->img, 127, 127, 127);
  777. $this->color['arc_2_shadow'] = imagecolorallocate($this->img, 100, 110, 100);
  778. $this->color['arc_3_shadow'] = imagecolorallocate($this->img, 80, 100, 80);
  779. $this->color['arc_4_shadow'] = imagecolorallocate($this->img, 67, 90, 67);
  780. $this->color['arc_5_shadow'] = imagecolorallocate($this->img, 57, 80, 57);
  781. $this->color['arc_6_shadow'] = imagecolorallocate($this->img, 50, 70, 50);
  782. $this->color['arc_7_shadow'] = imagecolorallocate($this->img, 45, 60, 45);
  783. }
  784. break;
  785. // Spring
  786. case 3:
  787. $this->color['title'] = imagecolorallocate($this->img, 250, 50, 50);
  788. //$this->color['background'] = imagecolorallocate($this->img, 250, 250, 220);
  789. $this->color['background'] = imagecolorallocate($this->img, 255, 255, 255);
  790. $this->color['axis_values'] = imagecolorallocate($this->img, 50, 150, 50);
  791. $this->color['axis_line'] = imagecolorallocate($this->img, 50, 100, 50);
  792. $this->color['bg_lines'] = imagecolorallocate($this->img, 200, 224, 180);
  793. //$this->color['bg_legend'] = imagecolorallocate($this->img, 230, 230, 200);
  794. $this->color['bg_legend'] = imagecolorallocate($this->img, 255, 255, 255);
  795. if (preg_match("/^(1|2)$/", $this->type))
  796. {
  797. $this->color['bars'] = imagecolorallocate($this->img, 255, 170, 80);
  798. $this->color['bars_shadow'] = imagecolorallocate($this->img, 200, 120, 30);
  799. $this->color['bars_2'] = imagecolorallocate($this->img, 250, 230, 80);
  800. $this->color['bars_2_shadow'] = imagecolorallocate($this->img, 180, 150, 0);
  801. }
  802. else if (preg_match("/^(3|4)$/", $this->type))
  803. {
  804. $this->color['line'] = imagecolorallocate($this->img, 230, 100, 0);
  805. $this->color['line_2'] = imagecolorallocate($this->img, 220, 200, 50);
  806. }
  807. else if (preg_match("/^(5|6)$/", $this->type))
  808. {
  809. $this->color['arc_1'] = imagecolorallocate($this->img, 100, 150, 200);
  810. $this->color['arc_2'] = imagecolorallocate($this->img, 200, 250, 150);
  811. $this->color['arc_3'] = imagecolorallocate($this->img, 250, 200, 150);
  812. $this->color['arc_4'] = imagecolorallocate($this->img, 250, 150, 150);
  813. $this->color['arc_5'] = imagecolorallocate($this->img, 250, 250, 150);
  814. $this->color['arc_6'] = imagecolorallocate($this->img, 230, 180, 250);
  815. $this->color['arc_7'] = imagecolorallocate($this->img, 200, 200, 150);
  816. $this->color['arc_1_shadow'] = imagecolorallocate($this->img, 50, 75, 100);
  817. $this->color['arc_2_shadow'] = imagecolorallocate($this->img, 100, 125, 75);
  818. $this->color['arc_3_shadow'] = imagecolorallocate($this->img, 125, 100, 75);
  819. $this->color['arc_4_shadow'] = imagecolorallocate($this->img, 125, 75, 75);
  820. $this->color['arc_5_shadow'] = imagecolorallocate($this->img, 125, 125, 75);
  821. $this->color['arc_6_shadow'] = imagecolorallocate($this->img, 115, 90, 125);
  822. $this->color['arc_7_shadow'] = imagecolorallocate($this->img, 100, 100, 75);
  823. }
  824. break;
  825. }
  826. }
  827. function _imagestring($img, $size, $x, $y, $string, $col, $alt=0)
  828. {
  829. if ($this->encoding != 'UTF-8') {
  830. if (function_exists('iconv'))
  831. $string = iconv($this->encoding, 'UTF-8', $string);
  832. else
  833. $string = mb_convert_encoding($string, 'UTF-8', $this->encoding);
  834. }
  835. // New 2014-06-26 Joe Hunt for handling ev. RTL languages
  836. if ($alt)
  837. {
  838. if ($this->encoding == 'UTF-8' && is_arabic($string))
  839. $alt_len = 18;
  840. else
  841. $alt_len = 12;
  842. if (strlen($string) > $alt_len)
  843. $string = substr($string, 0, $alt_len);
  844. }
  845. if ($this->encoding == 'UTF-8')
  846. {
  847. if (is_arabic($string))
  848. $string = arabic($string, "we");
  849. elseif (is_hebrew($string))
  850. $string = hebrew($string);
  851. }
  852. if ($this->built_in)
  853. {
  854. imagestring($img, $size, $x, $y + $alt, $string, $col);
  855. }
  856. else
  857. {
  858. if ($size == 1)
  859. $size = 7;
  860. elseif ($size == 2)
  861. $size = 8;
  862. elseif ($size == 3)
  863. $size = 9;
  864. elseif ($size == 4)
  865. $size = 11;
  866. else
  867. $size = 12;
  868. $y += $size + 3;
  869. //if ($alt)
  870. // $angle = -15;
  871. //else
  872. $angle = 0;
  873. imagettftext($img, $size, $angle, $x, $y + $alt, $col, $this->fontfile, $string);
  874. }
  875. }
  876. }
  877. // The following is for handling RTL texts. GD does not handle RTL at all.
  878. // The function, arabic, has been taken from Milad Rastian and
  879. // modified by Bagram Siadat.
  880. // The function has been further modified and several bugs are fixed.
  881. function is_arabic($text)
  882. {
  883. return preg_match('/\p{Arabic}/u', $text);
  884. }
  885. function is_hebrew($text)
  886. {
  887. return preg_match('/\p{Hebrew}/u', $text);
  888. }
  889. function utf8_strlen($str)
  890. {
  891. return preg_match_all('/[\x00-\x7F\xC0-\xFD]/', $str, $dummy);
  892. }
  893. function utf8_chr($uni)
  894. {
  895. $r = "";
  896. # ASCII range (including control chars)
  897. if ( ($uni >= 0) && ($uni <= 0x007f) )
  898. $r .= chr($uni);
  899. elseif ($uni <= 0x07ff) // 2 byte sequence
  900. {
  901. $r .= chr(0xc0 | ($uni >> 6));
  902. $r .= chr(0x80 | ($uni & 0x003f));
  903. }
  904. elseif($uni == 0xFEFF) // Byte order mark (skip)
  905. return chr(0); // nop -- zap the BOM
  906. elseif ($uni >= 0xD800 && $uni <= 0xDFFF) // Test for illegal surrogates
  907. return chr(0); // found a surrogate
  908. elseif ($uni <= 0xffff) // 3 byte sequence
  909. {
  910. $r .= chr(0xe0 | ($uni >> 12));
  911. $r .= chr(0x80 | (($uni >> 6) & 0x003f));
  912. $r .= chr(0x80 | ($uni & 0x003f));
  913. }
  914. elseif ($uni <= 0x10ffff) // 4 byte sequence
  915. {
  916. $r .= chr(0xf0 | ($uni >> 18));
  917. $r .= chr(0x80 | (($uni >> 12) & 0x3f));
  918. $r .= chr(0x80 | (($uni >> 6) & 0x3f));
  919. $r .= chr(0x80 | ($uni & 0x3f));
  920. }
  921. else
  922. return chr(0);
  923. return $r;
  924. }
  925. global $p_chars;
  926. $p_chars = array (
  927. utf8_chr(0x0622) => array (utf8_chr(0xfe82), utf8_chr(0xfe82), utf8_chr(0x0622)),
  928. utf8_chr(0x0627) => array (utf8_chr(0xfe8e), utf8_chr(0xfe8e), utf8_chr(0x0627)),
  929. utf8_chr(0x0628) => array (utf8_chr(0xfe90), utf8_chr(0xfe92), utf8_chr(0xfe91)),
  930. utf8_chr(0x067e) => array (utf8_chr(0xfb57), utf8_chr(0xfb59), utf8_chr(0xfb58)),
  931. utf8_chr(0x062a) => array (utf8_chr(0xfe96), utf8_chr(0xfe98), utf8_chr(0xfe97)),
  932. utf8_chr(0x062b) => array (utf8_chr(0xfe9a), utf8_chr(0xfe9c), utf8_chr(0xfe9b)),
  933. utf8_chr(0x062c) => array (utf8_chr(0xfe9e), utf8_chr(0xfea0), utf8_chr(0xfe9f)),
  934. utf8_chr(0x0686) => array (utf8_chr(0xfb7b), utf8_chr(0xfb7d), utf8_chr(0xfb7c)),
  935. utf8_chr(0x062d) => array (utf8_chr(0xfea2), utf8_chr(0xfea4), utf8_chr(0xfea3)),
  936. utf8_chr(0x062e) => array (utf8_chr(0xfea6), utf8_chr(0xfea8), utf8_chr(0xfea7)),
  937. utf8_chr(0x062f) => array (utf8_chr(0xfeaa), utf8_chr(0xfeaa), utf8_chr(0xfea9)),
  938. utf8_chr(0x0630) => array (utf8_chr(0xfeac), utf8_chr(0xfeac), utf8_chr(0xfeab)),
  939. utf8_chr(0x0631) => array (utf8_chr(0xfeae), utf8_chr(0xfeae), utf8_chr(0xfead)),
  940. utf8_chr(0x0632) => array (utf8_chr(0xfeb0), utf8_chr(0xfeb0), utf8_chr(0xfeaf)),
  941. utf8_chr(0x0698) => array (utf8_chr(0xfb8b), utf8_chr(0xfb8b), utf8_chr(0xfb8a)),
  942. utf8_chr(0x0633) => array (utf8_chr(0xfeb2), utf8_chr(0xfeb4), utf8_chr(0xfeb3)),
  943. utf8_chr(0x0634) => array (utf8_chr(0xfeb6), utf8_chr(0xfeb8), utf8_chr(0xfeb7)),
  944. utf8_chr(0x0635) => array (utf8_chr(0xfeba), utf8_chr(0xfebc), utf8_chr(0xfebb)),
  945. utf8_chr(0x0636) => array (utf8_chr(0xfebe), utf8_chr(0xfec0), utf8_chr(0xfebf)),
  946. utf8_chr(0x0637) => array (utf8_chr(0xfec2), utf8_chr(0xfec4), utf8_chr(0xfec3)),
  947. utf8_chr(0x0638) => array (utf8_chr(0xfec6), utf8_chr(0xfec8), utf8_chr(0xfec7)),
  948. utf8_chr(0x0639) => array (utf8_chr(0xfeca), utf8_chr(0xfecc), utf8_chr(0xfecb)),
  949. utf8_chr(0x063a) => array (utf8_chr(0xfece), utf8_chr(0xfed0), utf8_chr(0xfecf)),
  950. utf8_chr(0x0641) => array (utf8_chr(0xfed2), utf8_chr(0xfed4), utf8_chr(0xfed3)),
  951. utf8_chr(0x0642) => array (utf8_chr(0xfed6), utf8_chr(0xfed8), utf8_chr(0xfed7)),
  952. utf8_chr(0x06a9) => array (utf8_chr(0xfeda), utf8_chr(0xfedc), utf8_chr(0xfedb)),
  953. utf8_chr(0x06af) => array (utf8_chr(0xfb93), utf8_chr(0xfb95), utf8_chr(0xfb94)),
  954. utf8_chr(0x0644) => array (utf8_chr(0xfede), utf8_chr(0xfee0), utf8_chr(0xfedf)),
  955. utf8_chr(0x0645) => array (utf8_chr(0xfee2), utf8_chr(0xfee4), utf8_chr(0xfee3)),
  956. utf8_chr(0x0646) => array (utf8_chr(0xfee6), utf8_chr(0xfee8), utf8_chr(0xfee7)),
  957. utf8_chr(0x0648) => array (utf8_chr(0xfeee), utf8_chr(0xfeee), utf8_chr(0xfeed)),
  958. utf8_chr(0x06cc) => array (utf8_chr(0xfbfd), utf8_chr(0xfbff), utf8_chr(0xfbfe)),
  959. utf8_chr(0x0643) => array (utf8_chr(0xfeda), utf8_chr(0xfedc), utf8_chr(0xfedb)),
  960. utf8_chr(0x064a) => array (utf8_chr(0xfef2), utf8_chr(0xfef4), utf8_chr(0xfef3)),
  961. utf8_chr(0x0623) => array (utf8_chr(0xfe84), utf8_chr(0xfe84), utf8_chr(0xfe83)),
  962. utf8_chr(0x0624) => array (utf8_chr(0xfe86), utf8_chr(0xfe86), utf8_chr(0xfe85)),
  963. utf8_chr(0x0625) => array (utf8_chr(0xfe88), utf8_chr(0xfe88), utf8_chr(0xfe87)),
  964. utf8_chr(0x0626) => array (utf8_chr(0xfe8a), utf8_chr(0xfe8c), utf8_chr(0xfe8b)),
  965. utf8_chr(0x0629) => array (utf8_chr(0xfe94), utf8_chr(0xfe98), utf8_chr(0xfe97))
  966. );
  967. global $nastaligh;
  968. $nastaligh = array (
  969. utf8_chr(0x0647) => array (utf8_chr(0xfbab), utf8_chr(0xfbad), utf8_chr(0xfbac))
  970. );
  971. global $normal;
  972. $normal = array (
  973. utf8_chr(0x0647) => array (utf8_chr(0xfeea), utf8_chr(0xfeec), utf8_chr(0xfeeb))
  974. );
  975. global $mp_chars;
  976. $mp_chars = array (utf8_chr(0x0622), utf8_chr(0x0627), utf8_chr(0x062f), utf8_chr(0x0630), utf8_chr(0x0631), utf8_chr(0x0632),
  977. utf8_chr(0x0698), utf8_chr(0x0648), utf8_chr(0x0623), utf8_chr(0x0625), utf8_chr(0x0624));
  978. global $ignorelist;
  979. $ignorelist = array (utf8_chr(0x0000), utf8_chr(0x064c), utf8_chr(0x064d), utf8_chr(0x064b), utf8_chr(0x064f), utf8_chr(0x0650),
  980. utf8_chr(0x064e), utf8_chr(0x0651), utf8_chr(0x0653), utf8_chr(0x0670), utf8_chr(0x0654), utf8_chr(0xfe76), utf8_chr(0xfe7a),
  981. utf8_chr(0xfe78), utf8_chr(0xfe7c), utf8_chr(0xfe7e), utf8_chr(0xfe74), utf8_chr(0xfe70), utf8_chr(0xfc5e), utf8_chr(0xfc5f),
  982. utf8_chr(0xfc60), utf8_chr(0xfc61), utf8_chr(0xfc62), utf8_chr

Large files files are truncated, but you can click here to view the full file