暂无描述

debugger.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. require_once "functions.inc.php";
  3. $allowed_hosts = array("::1", "127.0.0.1");
  4. if( !auth_ok() || !in_array($_SERVER['REMOTE_ADDR'], $allowed_hosts) ) {
  5. die("Access denied to host at " . $_SERVER['REMOTE_ADDR']);
  6. }
  7. $files = glob("test/*.{html,htm,php}", GLOB_BRACE);
  8. ?>
  9. <!DOCTYPE html>
  10. <html lang="en">
  11. <head>
  12. <title>dompdf debugger</title>
  13. <meta name="robots" content="noindex">
  14. <script type="text/javascript" src="jquery-1.4.2.js"></script>
  15. <script type="text/javascript">
  16. function updateAddress(){
  17. var addressbar = $('#addressbar'),
  18. preview = $('#preview'),
  19. preview_html = $('#preview_html'),
  20. address = encodeURI(addressbar.val()),
  21. addressHTML = address,
  22. addressPDF = address,
  23. basePath = "";
  24. if ( !/[a-z]+:\/\//.test(address) ) {
  25. addressHTML = "test/"+address+"?"+(new Date).getTime();
  26. basePath = "www/test/";
  27. }
  28. // HTML file
  29. preview_html.attr("src", "about:blank");
  30. preview_html.attr("src", addressHTML);
  31. // PDF file
  32. preview.attr("src", "about:blank");
  33. setTimeout(function(){
  34. address = "../dompdf.php?base_path="+basePath+"&options[Attachment]=0&input_file="+addressPDF+"#toolbar=0&view=FitH&statusbar=0&messages=0&navpanes=0";
  35. preview.attr('src', address);
  36. }, 0.1);
  37. }
  38. function log(str){
  39. var console = $("#console");
  40. str = str || "(nothing)";
  41. console.html(console.html() + str + "<hr />");
  42. console.scrollTop(console[0].scrollHeight);
  43. }
  44. function resizePage(){
  45. var page = $("#page");
  46. var height = $(window).height() - page.offset().top - 40;
  47. $("iframe, #console").height(height);
  48. }
  49. function navigateExamples(way) {
  50. var select = $('#examples')[0],
  51. n = select.options.length;
  52. if (way == "previous")
  53. select.selectedIndex = (select.selectedIndex - 1) % n;
  54. else
  55. select.selectedIndex = (select.selectedIndex + 1) % n;
  56. $('#addressbar').val($("#examples").val());
  57. updateAddress();
  58. }
  59. $(function(){
  60. resizePage();
  61. $(window).resize(resizePage);
  62. $('#preview').load(function(){
  63. if (this.src == "about:blank") return;
  64. $.ajax({
  65. url: '../lib/fonts/log.htm',
  66. success: log,
  67. cache: false
  68. });
  69. });
  70. $('#addressbar').val($("#examples").val());
  71. // Catch F5 to reload the iframes, not the page itself
  72. $(document).keydown(function(event) {
  73. if (event.which == 116) {
  74. event.preventDefault();
  75. updateAddress();
  76. }
  77. });
  78. });
  79. </script>
  80. <style type="text/css">
  81. html, body {
  82. margin: 0;
  83. padding: 0;
  84. }
  85. td {
  86. padding: 0;
  87. }
  88. #page {
  89. width: 100%;
  90. border: none;
  91. border-spacing: 0;
  92. border-collapse: collapse;
  93. }
  94. iframe {
  95. width: 100%;
  96. }
  97. #output td {
  98. border: 1px solid #999;
  99. }
  100. #console-container {
  101. vertical-align: top;
  102. }
  103. #console {
  104. background: #eee;
  105. overflow: scroll;
  106. padding: 4px;
  107. }
  108. #console pre {
  109. margin: 2px 0;
  110. }
  111. #console, #console pre {
  112. font-size: 11px;
  113. font-family: Courier, "Courier new", monospace;
  114. white-space: pre-wrap;
  115. }
  116. </style>
  117. </head>
  118. <body>
  119. <table id="page">
  120. <tr>
  121. <td colspan="3">
  122. <button onclick="$('#console').html('')" style="float: right;">Reset</button>
  123. <button onclick="navigateExamples('previous')">&lt;</button>
  124. <select onchange="$('#addressbar').val($(this).val()); updateAddress()" id="examples">
  125. <?php foreach($files as $file) { ?>
  126. <option value="<?php echo basename($file); ?>"><?php echo basename($file); ?></option>
  127. <?php } ?>
  128. </select>
  129. <button onclick="navigateExamples('next')">&gt;</button>
  130. <input id="addressbar" type="text" size="100" value="" />
  131. <button onclick="updateAddress()">Go</button>
  132. </td>
  133. </tr>
  134. <tr id="output">
  135. <td style="width: 40%;">
  136. <iframe id="preview_html" name="preview_html" src="about:blank" frameborder="0" marginheight="0" marginwidth="0"></iframe>
  137. </td>
  138. <td style="width: 40%;">
  139. <iframe id="preview" name="preview" src="about:blank" frameborder="0" marginheight="0" marginwidth="0"></iframe>
  140. </td>
  141. <td style="min-width: 400px; width: 20%;" id="console-container">
  142. <div id="console"></div>
  143. </td>
  144. </tr>
  145. </table>