Просмотр файла download/include/edit_screen.php

Размер файла: 4.7Kb
  1. <?php
  2.  
  3. $set['title'] = 'Управление скриншотами';
  4. include H.'engine/includes/head.php';
  5.  
  6.  
  7. $sql->query("SELECT * FROM `down_files` WHERE `id` = '$id' AND (`type` = 2 OR `type` = 3) LIMIT 1");
  8. $res_down = $sql->fetch();
  9. if ($sql->num_rows() == 0 || !is_file($res_down['dir'] . '/' . $res_down['name']) || !$moder) {
  10. echo '<a href="index.php">К категориям</a>';
  11. include H.'engine/includes/foot.php';
  12.  
  13. }
  14.  
  15. $upload_max_filesize=ini_get('upload_max_filesize');
  16. if (preg_match('#([0-9]*)([a-z]*)#i',$upload_max_filesize,$varrs))
  17. {
  18. if ($varrs[2]=='M')$upload_max_filesize=$varrs[1]*1048576;
  19. elseif ($varrs[2]=='K')$upload_max_filesize=$varrs[1]*1024;
  20. elseif ($varrs[2]=='G')$upload_max_filesize=$varrs[1]*1024*1048576;
  21. }
  22.  
  23. $screen = array();
  24. if ($do && is_file($screenroot . '/' . $id . '/' . $do)) {
  25. unlink($screenroot . '/' . $id . '/' . $do);
  26. header('Location: index.php?act=edit_screen&id=' . $id);
  27. exit;
  28. }
  29. else
  30. if (isset($_POST['submit'])) {
  31. require_once H.'engine/classes/class_upload.php';
  32. $handle = new upload($_FILES['screen']);
  33. if ($handle->uploaded) {
  34. $handle->file_new_name_body = $time;
  35. $handle->allowed = array('image/jpeg', 'image/gif', 'image/png');
  36. $handle->file_max_size = $upload_max_filesize;
  37. $handle->file_overwrite = true;
  38. $handle->image_resize = true;
  39. $handle->image_x = 240;
  40. $handle->image_ratio_y = true;
  41. $handle->image_convert = 'jpg';
  42. $handle->process($filesroot . '/screen/' . $id . '/');
  43. if ($handle->processed) {
  44. echo '<div class="msg"><b>Скриншот прикреплен</b>';
  45. if (file_exists(H.'engine/files/tmp/download[file='.$id.';page=1].swc'))
  46. unlink(H.'engine/files/tmp/download[file='.$id.';page=1].swc');
  47. }
  48. else
  49. echo '<div class="err"><b>Скриншот не прикреплен: ' . $handle->error . '</b>';
  50.  
  51. }
  52. else
  53. echo '<div class="err"><b>Не выбран файл</b>';
  54. echo '<br /><a href="index.php?act=edit_screen&amp;id=' . $id . '">Вернуться</a><br /><a href="index.php?act=view&amp;id=' . $id . '">К файлу</a></div>';
  55. }
  56. else {
  57. echo '<div class="p_m"><b>' . text::output($res_down['rus_name']) . '</b></div><div class="p_t"><b>Cкриншот</b></div>';
  58. if ($screen)
  59. echo '<div class="news"><img src="' . $screen . '" alt="screen"/></div>';
  60. echo '<div class="post"><form action="index.php?act=edit_screen&amp;id=' . $id . '" method="post" enctype="multipart/form-data"><input type="file" name="screen"/><br /><input type="submit" name="submit" value="Выгрузить"/>';
  61. if ($screen)
  62. echo '&nbsp;<input type="submit" name="delscreen" value="Удалить"/>';
  63. echo '</form></div><div class="p_m"><small>Max. вес: ' . text::size_data($upload_max_filesize) . '<br />Скриншот будет автоматически преоброзаван в картинку, шириной не превышающую 240px (высота будет вычислина автоматически)<br />Новый файл заменить старый</small></div>';
  64. if (is_dir($screenroot . '/' . $id)) {
  65. $screen = glob($screenroot . '/' . $id . '/*.gif');
  66. $screen = array_merge($screen, glob($screenroot . '/' . $id . '/*.jpg'));
  67. $screen = array_merge($screen, glob($screenroot . '/' . $id . '/*.png'));
  68. }
  69. else {
  70. $dir = mkdir("$screenroot/$id", 0777);
  71. if ($dir = true)
  72. chmod("$screenroot/$id", 0777);
  73. }
  74. if ($screen) {
  75. $total = count($screen);
  76. $page = new page($total, $set['p_str']);
  77. for ($i = $page->start(); $i < $total; $i++) {
  78. $screen_name = htmlentities($screen[$i], ENT_QUOTES, 'utf-8');
  79. $file = preg_replace('#^' . $screenroot . '/' . $id . '/(.*?)$#isU', '$1', $screen_name, 1);
  80. echo (($i % 2) ? '<div class="p_m">' : '<div class="p_t">') . '
  81. <table width="100%"><tr><td width="40" valign="top"><a href="' . $screen_name . '"><img src="preview.php?type=1&amp;img=' . urlencode($screen_name) . '" alt="screen_' . $i . '" /></a></td><td>' . $file . '<div class="status"><a href="index.php?act=edit_screen&amp;id=' .
  82. $id . '&amp;do=' . $file . '">Удалить</a></div></td></tr></table></div>';
  83. }
  84. }
  85. echo '<div class="p_m"><a href="index.php?act=view&amp;id=' . $id . '">Назад</a></div>';
  86. }