PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/sites/all/modules/print/lib/dompdf/www/setup.php

https://gitlab.com/crsr/medtrade
PHP | 290 lines | 272 code | 18 blank | 0 comment | 18 complexity | 0074632535d05263cd2d1d3314ef000e MD5 | raw file
  1. <?php include("head.inc"); ?>
  2. <a name="setup"> </a>
  3. <h2>Setup</h2>
  4. <ul>
  5. <li style="list-style-image: url('images/star_02.gif');"><a href="#system">System Configuration</a></li>
  6. <li style="list-style-image: url('images/star_02.gif');"><a href="#dompdf-config">DOMPDF Configuration</a></li>
  7. </ul>
  8. <h3 id="system">System Configuration</h3>
  9. <?php
  10. require_once("../dompdf_config.inc.php");
  11. $server_configs = array(
  12. "PHP Version" => array(
  13. "required" => "5.0",
  14. "value" => phpversion(),
  15. "result" => version_compare(phpversion(), "5.0"),
  16. ),
  17. "DOMDocument extension" => array(
  18. "required" => true,
  19. "value" => phpversion("DOM"),
  20. "result" => class_exists("DOMDocument"),
  21. ),
  22. "PCRE" => array(
  23. "required" => true,
  24. "value" => phpversion("pcre"),
  25. "result" => function_exists("preg_match") && @preg_match("/./u", "a"),
  26. "failure" => "PCRE is required with Unicode support (the \"u\" modifier)",
  27. ),
  28. "Zlib" => array(
  29. "required" => true,
  30. "value" => phpversion("zlib"),
  31. "result" => function_exists("gzcompress"),
  32. "fallback" => "Recommended to compress PDF documents",
  33. ),
  34. "MBString extension" => array(
  35. "required" => true,
  36. "value" => phpversion("mbstring"),
  37. "result" => function_exists("mb_send_mail"), // Should never be reimplemented in dompdf
  38. "fallback" => "Recommended, will use fallback functions",
  39. ),
  40. "GD" => array(
  41. "required" => true,
  42. "value" => phpversion("gd"),
  43. "result" => function_exists("imagecreate"),
  44. "fallback" => "Required if you have images in your documents",
  45. ),
  46. "APC" => array(
  47. "required" => "For better performances",
  48. "value" => phpversion("apc"),
  49. "result" => function_exists("apc_fetch"),
  50. "fallback" => "Recommended for better performances",
  51. ),
  52. "GMagick or IMagick" => array(
  53. "required" => "Better with transparent PNG images",
  54. "value" => null,
  55. "result" => extension_loaded("gmagick") || extension_loaded("imagick"),
  56. "fallback" => "Recommended for better performances",
  57. ),
  58. );
  59. if (($gm = extension_loaded("gmagick")) || ($im = extension_loaded("imagick"))) {
  60. $server_configs["GMagick or IMagick"]["value"] = ($im ? "IMagick ".phpversion("imagick") : "GMagick ".phpversion("gmagick"));
  61. }
  62. ?>
  63. <table class="setup">
  64. <tr>
  65. <th></th>
  66. <th>Required</th>
  67. <th>Present</th>
  68. </tr>
  69. <?php foreach($server_configs as $label => $server_config) { ?>
  70. <tr>
  71. <td class="title"><?php echo $label; ?></td>
  72. <td><?php echo ($server_config["required"] === true ? "Yes" : $server_config["required"]); ?></td>
  73. <td class="<?php echo ($server_config["result"] ? "ok" : (isset($server_config["fallback"]) ? "warning" : "failed")); ?>">
  74. <?php
  75. echo $server_config["value"];
  76. if ($server_config["result"] && !$server_config["value"]) echo "Yes";
  77. if (!$server_config["result"]) {
  78. if (isset($server_config["fallback"])) {
  79. echo "<div>No. ".$server_config["fallback"]."</div>";
  80. }
  81. if (isset($server_config["failure"])) {
  82. echo "<div>".$server_config["failure"]."</div>";
  83. }
  84. }
  85. ?>
  86. </td>
  87. </tr>
  88. <?php } ?>
  89. </table>
  90. <h3 id="dompdf-config">DOMPDF Configuration</h3>
  91. <?php
  92. $dompdf_constants = array();
  93. $defined_constants = get_defined_constants(true);
  94. $constants = array(
  95. "DOMPDF_DIR" => array(
  96. "desc" => "Root directory of DOMPDF",
  97. "success" => "read",
  98. ),
  99. "DOMPDF_INC_DIR" => array(
  100. "desc" => "Include directory of DOMPDF",
  101. "success" => "read",
  102. ),
  103. "DOMPDF_LIB_DIR" => array(
  104. "desc" => "Third-party libraries directory of DOMPDF",
  105. "success" => "read",
  106. ),
  107. "DOMPDF_FONT_DIR" => array(
  108. "desc" => "Additional fonts directory",
  109. "success" => "read",
  110. ),
  111. "DOMPDF_FONT_CACHE" => array(
  112. "desc" => "Font metrics cache",
  113. "success" => "write",
  114. ),
  115. "DOMPDF_TEMP_DIR" => array(
  116. "desc" => "Temporary folder",
  117. "success" => "write",
  118. ),
  119. "DOMPDF_CHROOT" => array(
  120. "desc" => "Restricted path",
  121. "success" => "read",
  122. ),
  123. "DOMPDF_UNICODE_ENABLED" => array(
  124. "desc" => "Unicode support (thanks to additional fonts)",
  125. ),
  126. "DOMPDF_ENABLE_FONTSUBSETTING" => array(
  127. "desc" => "Enable font subsetting, will make smaller documents when using Unicode fonts",
  128. ),
  129. "DOMPDF_PDF_BACKEND" => array(
  130. "desc" => "Backend library that makes the outputted file (PDF, image)",
  131. "success" => "backend",
  132. ),
  133. "DOMPDF_DEFAULT_MEDIA_TYPE" => array(
  134. "desc" => "Default media type (print, screen, ...)",
  135. ),
  136. "DOMPDF_DEFAULT_PAPER_SIZE" => array(
  137. "desc" => "Default paper size (A4, letter, ...)",
  138. ),
  139. "DOMPDF_DEFAULT_FONT" => array(
  140. "desc" => "Default font, used if the specified font in the CSS stylesheet was not found",
  141. ),
  142. "DOMPDF_DPI" => array(
  143. "desc" => "DPI scale of the document",
  144. ),
  145. "DOMPDF_ENABLE_PHP" => array(
  146. "desc" => "Inline PHP support",
  147. ),
  148. "DOMPDF_ENABLE_JAVASCRIPT" => array(
  149. "desc" => "Inline JavaScript support",
  150. ),
  151. "DOMPDF_ENABLE_REMOTE" => array(
  152. "desc" => "Allow remote stylesheets and images",
  153. "success" => "remote",
  154. ),
  155. "DOMPDF_ENABLE_CSS_FLOAT" => array(
  156. "desc" => "Enable CSS float support (experimental)",
  157. ),
  158. "DOMPDF_ENABLE_HTML5PARSER" => array(
  159. "desc" => "Enable the HTML5 parser (experimental)",
  160. ),
  161. "DEBUGPNG" => array(
  162. "desc" => "Debug PNG images",
  163. ),
  164. "DEBUGKEEPTEMP" => array(
  165. "desc" => "Keep temporary image files",
  166. ),
  167. "DEBUGCSS" => array(
  168. "desc" => "Debug CSS",
  169. ),
  170. "DEBUG_LAYOUT" => array(
  171. "desc" => "Debug layout",
  172. ),
  173. "DEBUG_LAYOUT_LINES" => array(
  174. "desc" => "Debug text lines layout",
  175. ),
  176. "DEBUG_LAYOUT_BLOCKS" => array(
  177. "desc" => "Debug block elements layout",
  178. ),
  179. "DEBUG_LAYOUT_INLINE" => array(
  180. "desc" => "Debug inline elements layout",
  181. ),
  182. "DEBUG_LAYOUT_PADDINGBOX" => array(
  183. "desc" => "Debug padding boxes layout",
  184. ),
  185. "DOMPDF_LOG_OUTPUT_FILE" => array(
  186. "desc" => "The file in which dompdf will write warnings and messages",
  187. "success" => "write",
  188. ),
  189. "DOMPDF_FONT_HEIGHT_RATIO" => array(
  190. "desc" => "The line height ratio to apply to get a render like web browsers",
  191. ),
  192. "DOMPDF_ENABLE_AUTOLOAD" => array(
  193. "desc" => "Enable the DOMPDF autoloader",
  194. ),
  195. "DOMPDF_AUTOLOAD_PREPEND" => array(
  196. "desc" => "Prepend the dompdf autoload function to the SPL autoload functions already registered instead of appending it",
  197. ),
  198. "DOMPDF_ADMIN_USERNAME" => array(
  199. "desc" => "The username required to access restricted sections",
  200. "secret" => true,
  201. ),
  202. "DOMPDF_ADMIN_PASSWORD" => array(
  203. "desc" => "The password required to access restricted sections",
  204. "secret" => true,
  205. "success" => "auth",
  206. ),
  207. );
  208. ?>
  209. <table class="setup">
  210. <tr>
  211. <th>Config name</th>
  212. <th>Value</th>
  213. <th>Description</th>
  214. <th>Status</th>
  215. </tr>
  216. <?php foreach($defined_constants["user"] as $const => $value) { ?>
  217. <tr>
  218. <td class="title"><?php echo $const; ?></td>
  219. <td>
  220. <?php
  221. if (isset($constants[$const]["secret"])) {
  222. echo "******";
  223. }
  224. else {
  225. var_export($value);
  226. }
  227. ?>
  228. </td>
  229. <td><?php if (isset($constants[$const]["desc"])) echo $constants[$const]["desc"]; ?></td>
  230. <td <?php
  231. $message = "";
  232. if (isset($constants[$const]["success"])) {
  233. switch($constants[$const]["success"]) {
  234. case "read":
  235. $success = is_readable($value);
  236. $message = ($success ? "Readable" : "Not readable");
  237. break;
  238. case "write":
  239. $success = is_writable($value);
  240. $message = ($success ? "Writable" : "Not writable");
  241. break;
  242. case "remote":
  243. $success = ini_get("allow_url_fopen");
  244. $message = ($success ? "allow_url_fopen enabled" : "allow_url_fopen disabled");
  245. break;
  246. case "backend":
  247. switch (strtolower($value)) {
  248. case "cpdf":
  249. $success = true;
  250. break;
  251. case "pdflib":
  252. $success = function_exists("PDF_begin_document");
  253. $message = "The PDFLib backend needs the PDF PECL extension";
  254. break;
  255. case "gd":
  256. $success = function_exists("imagecreate");
  257. $message = "The GD backend requires GD2";
  258. break;
  259. }
  260. break;
  261. case "auth":
  262. $success = !in_array($value, array("admin", "password"));
  263. $message = ($success ? "OK" : "Password should be changed");
  264. break;
  265. }
  266. echo 'class="' . ($success ? "ok" : "failed") . '"';
  267. }
  268. ?>><?php echo $message; ?></td>
  269. </tr>
  270. <?php } ?>
  271. </table>
  272. <?php include("foot.inc"); ?>