Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rerender_gallery.php 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?
  2. /*
  3. * This page creates previews of all supported stylesheets
  4. * SERVER_ROOT . '/' . STATIC_SERVER . 'stylespreview' must exist and be writable
  5. * Dependencies are PhantomJS (http://phantomjs.org/) and
  6. * ImageMagick (http://www.imagemagick.org/script/index.php)
  7. */
  8. View::show_header('Rerender stylesheet gallery images');
  9. $DB->query('
  10. SELECT
  11. ID,
  12. LOWER(REPLACE(Name," ","_")) AS Name,
  13. Name AS ProperName
  14. FROM stylesheets');
  15. $Styles = $DB->to_array('ID', MYSQLI_BOTH);
  16. $ImagePath = SERVER_ROOT . '/' . STATIC_SERVER . 'stylespreview';
  17. ?>
  18. <div class="thin">
  19. <h2>Rerender stylesheet gallery images</h2>
  20. <div class="sidebar">
  21. <div class="box box_info">
  22. <div class="head colhead_dark">Rendering parameters</div>
  23. <ul class="stats nobullet">
  24. <li>Server root: <?= var_dump(SERVER_ROOT); ?></li>
  25. <li>Static server: <?= var_dump(STATIC_SERVER); ?></li>
  26. <li>Whoami: <? echo(shell_exec('whoami')); ?></li>
  27. <li>Path: <? echo dirname(__FILE__); ?></li>
  28. <li>Phantomjs ver: <? echo (shell_exec('/usr/bin/phantomjs -v;')); ?></li>
  29. </ul>
  30. </div>
  31. </div>
  32. <div class="main_column">
  33. <div class="box">
  34. <div class="head">About rendering</div>
  35. <div class="pad">
  36. <p>You are now rendering stylesheet gallery images.</p>
  37. <p>The used parameters can be seen on the right, returned statuses are displayed below.</p>
  38. </div>
  39. </div>
  40. <div class="box">
  41. <div class="head">Rendering status</div>
  42. <div class="pad">
  43. <?
  44. //set_time_limit(0);
  45. foreach ($Styles as $Style) {
  46. ?>
  47. <div class="box">
  48. <h6><?= $Style['Name'] ?></h6>
  49. <p>Build preview:
  50. <?
  51. $CmdLine = '/usr/bin/phantomjs "' . dirname(__FILE__) . '/render_build_preview.js" "' . SERVER_ROOT . '" "' . STATIC_SERVER . '" "' . $Style['Name'] . '" "' . dirname(__FILE__) . '"';
  52. $BuildResult = json_decode(shell_exec(escapeshellcmd($CmdLine)), true);
  53. switch ($BuildResult['status']) {
  54. case 0:
  55. echo 'Success.';
  56. break;
  57. case -1:
  58. echo 'Err -1: Incorrect paths, are they passed correctly?';
  59. break;
  60. case -2:
  61. echo 'Err -2: Rendering base does not exist. Who broke things?';
  62. break;
  63. case -3:
  64. echo 'Err -3: No permission to write to preview folder.';
  65. break;
  66. case -4:
  67. echo 'Err -4: Failed to store specific preview file.';
  68. break;
  69. default:
  70. echo 'Err: Unknown error returned';
  71. }
  72. ?>
  73. </p>
  74. <?
  75. //If build was successful, snap a preview.
  76. if ($BuildResult['status'] === 0) {
  77. ?>
  78. <p>Snap preview:
  79. <?
  80. $CmdLine = '/usr/bin/phantomjs "' . dirname(__FILE__) . '/render_snap_preview.js" "' . SERVER_ROOT . '" "' . STATIC_SERVER . '" "' . $Style['Name'] . '" "' . dirname(__FILE__) . '"';
  81. $SnapResult = json_decode(shell_exec(escapeshellcmd($CmdLine)), true);
  82. switch ($SnapResult['status']) {
  83. case 0:
  84. echo 'Success.';
  85. $CmdLine = '/usr/bin/convert "' . $ImagePath . '/full_' . $Style['Name'] . '.png" -filter Box -resize 40% -quality 94 "' . $ImagePath . '/thumb_' . $Style['Name'] . '.png"';
  86. $ResizeResult = shell_exec(escapeshellcmd($CmdLine));
  87. if ($ResizeResult !== null) {
  88. echo ' But failed to resize image';
  89. }
  90. break;
  91. case -1:
  92. echo 'Err -1: Incorrect paths. Are they passed correctly? Do all folders exist?';
  93. break;
  94. case -2:
  95. echo 'Err -2: Preview file does not exist; running things in the wrong order perhaps?';
  96. break;
  97. case -3:
  98. echo 'Err -3: Preview is empty; did it get created properly?';
  99. break;
  100. case -4:
  101. echo 'Err -4: No permission to write to preview folder.';
  102. break;
  103. case -5:
  104. echo 'Err -5: Failed to store full image.';
  105. break;
  106. case -6:
  107. echo 'Err -6: Cannot find temp file to remove; are the paths correct?';
  108. break;
  109. default:
  110. echo 'Err: Unknown error returned.';
  111. }
  112. ?>
  113. </p>
  114. <? } ?>
  115. </div>
  116. <? } ?>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. <?
  122. View::show_footer();