setup.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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_AUTOLOAD_PREPEND" => array(
  193. "desc" => "Prepend the dompdf autoload function to the SPL autoload functions already registered instead of appending it",
  194. ),
  195. "DOMPDF_ADMIN_USERNAME" => array(
  196. "desc" => "The username required to access restricted sections",
  197. "secret" => true,
  198. ),
  199. "DOMPDF_ADMIN_PASSWORD" => array(
  200. "desc" => "The password required to access restricted sections",
  201. "secret" => true,
  202. "success" => "auth",
  203. ),
  204. );
  205. ?>
  206. <table class="setup">
  207. <tr>
  208. <th>Config name</th>
  209. <th>Value</th>
  210. <th>Description</th>
  211. <th>Status</th>
  212. </tr>
  213. <?php foreach($defined_constants["user"] as $const => $value) { ?>
  214. <tr>
  215. <td class="title"><?php echo $const; ?></td>
  216. <td>
  217. <?php
  218. if (isset($constants[$const]["secret"])) {
  219. echo "******";
  220. }
  221. else {
  222. var_export($value);
  223. }
  224. ?>
  225. </td>
  226. <td><?php if (isset($constants[$const]["desc"])) echo $constants[$const]["desc"]; ?></td>
  227. <td <?php
  228. $message = "";
  229. if (isset($constants[$const]["success"])) {
  230. switch($constants[$const]["success"]) {
  231. case "read":
  232. $success = is_readable($value);
  233. $message = ($success ? "Readable" : "Not readable");
  234. break;
  235. case "write":
  236. $success = is_writable($value);
  237. $message = ($success ? "Writable" : "Not writable");
  238. break;
  239. case "remote":
  240. $success = ini_get("allow_url_fopen");
  241. $message = ($success ? "allow_url_fopen enabled" : "allow_url_fopen disabled");
  242. break;
  243. case "backend":
  244. switch (strtolower($value)) {
  245. case "cpdf":
  246. $success = true;
  247. break;
  248. case "pdflib":
  249. $success = function_exists("PDF_begin_document");
  250. $message = "The PDFLib backend needs the PDF PECL extension";
  251. break;
  252. case "gd":
  253. $success = function_exists("imagecreate");
  254. $message = "The GD backend requires GD2";
  255. break;
  256. }
  257. break;
  258. case "auth":
  259. $success = !in_array($value, array("admin", "password"));
  260. $message = ($success ? "OK" : "Password should be changed");
  261. break;
  262. }
  263. echo 'class="' . ($success ? "ok" : "failed") . '"';
  264. }
  265. ?>><?php echo $message; ?></td>
  266. </tr>
  267. <?php } ?>
  268. </table>
  269. <?php include("foot.inc"); ?>