Keine Beschreibung

setup.php 9.2KB

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