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

Размер файла: 4.54Kb
  1. <?
  2. /*
  3. =============================================
  4. Движок: SHCMS Engine
  5. =============================================
  6. Название файла: Обменник - Добавление нового файла
  7. =============================================
  8. Official website: http://shcms.ru
  9. =============================================
  10. */
  11. define('SHCMS', true);
  12. include_once'../system/inc/basic_settings.php';
  13. $shcmsengine['title'] = 'Добавить новый файл';
  14.  
  15. include_once'../template/head.php';
  16. if($_GET['dir'])
  17. {$dir = $_GET['dir'];}
  18. $world = mysql_fetch_array(mysql_query("SELECT * FROM `download_dir` WHERE `id`='$dir'"));
  19. switch($act):
  20. case 'rules':
  21. echo '<div class="posts">';
  22. echo'<strong>Правила добавления файла:</strong><br/>
  23.  
  24. При добавления файла в обменник указывайте автора файла, прикрепите скриншот и обязательно проверьте работаспособность файла.</div>
  25. <div class="posts">';
  26. $form = new form('?act=upload&dir='.$dir.'');
  27. $form->submit('Добавить файл','submit');
  28. $form->submit('Отменить','no');
  29. $form->finish();
  30. echo '</div>';
  31. break;
  32.  
  33. case'upload':
  34.  
  35. if(isset($_POST['no'])){
  36.  
  37. header("Location: index.php");
  38. include_once '../template/foot.php';
  39. exit();
  40. }
  41. if($world['vib'] == 1 or $user4['team'] == 6){
  42. $loaddir = "files_obmen/";
  43.  
  44. if(!$dir)
  45. {
  46. errors("Загрузка файлов неправильно");
  47. header("Refresh: 1; url=/download/index.php");
  48. include_once '../template/foot.php';
  49. exit();
  50. }
  51.  
  52.  
  53. function format($name) {
  54. $f1 = strrpos($name, ".");
  55. $f2 = substr($name, $f1 + 1, 999);
  56. $fname = strtolower($f2);
  57. return $fname;
  58. }
  59.  
  60. if(isset($_GET['downloads'])) {
  61.  
  62.  
  63. if($_POST['textar'])
  64. {
  65. $textar = $_POST['textar'];
  66. }
  67. $textar = htmlspecialchars($textar);
  68. $textar = stripslashes($textar);
  69.  
  70. $files_name = $_FILES['file']['name'];
  71. $fil = $_FILES['file']['name'];
  72.  
  73.  
  74. $fil = utf8_win(SHCMS_core::Upload_end($fil));
  75.  
  76. $fil_format = format($fil);
  77. $fil_size = $_FILES['file']['size'];
  78.  
  79. $newnamef = "$fil";
  80. if ((move_uploaded_file($_FILES["file"]["tmp_name"], "$loaddir/$newnamef")) == true)
  81. {
  82. $ch = $newnamef;
  83. @chmod("$ch", 0777);
  84. @chmod("$loaddir/$ch", 0777);
  85. if(isset($_FILES['image']))
  86. {
  87. $screen_name = $_FILES['image']['name'];
  88. }
  89. $uploads = mysql_query("INSERT INTO `download_file` (`id_dir`,`name`,`size`,`type`,`time`,`user_id`,`author`,`message`,`screen`,`names`) VALUES ('$dir','$fil','$fil_size','$fil_format','".time()."','$user_id','$user4[login]','$textar','$screen_name','$files_name')");
  90.  
  91. if($uploads == true)
  92. {
  93. if(!empty($_FILES["image"]))
  94. {
  95. if (preg_match("#[а-яё]+#ui",$_FILES["image"]['name'])) {
  96. errors("В название изображение присутствует недопустимые символы");
  97. header("Refresh: 1; url=upload.php?act=upload&dir=$dir");
  98. include_once '../template/foot.php';
  99. exit;
  100. }
  101. $uploaddir = $_SERVER['DOCUMENT_ROOT']."/download/screen/";
  102. $uploaddir.=$_FILES['image']['name'];
  103. if(move_uploaded_file($_FILES["image"]["tmp_name"], $uploaddir))
  104. {
  105. $screen = new screen_shcms($uploaddir);
  106. $screen->autoimageresize(640, 480);
  107. $screen->imagesave($new_image->image_type, $uploaddir);
  108. $screen->imageout();
  109. echo '<div class="actshcms">Скриншот успешно загружен</div>';
  110. }
  111. else
  112. {
  113. echo '<div class="actshcms">Скриншот не загружен</div>';
  114. }
  115. }
  116.  
  117. echo '<div class="actshcms">Файл загружен успешно</div>';
  118. include_once '../template/foot.php';
  119. exit();
  120. }
  121. else
  122. {
  123. echo '<div class="errors">Ошибка при загрузки файла</div>';
  124. include_once '../template/foot.php';
  125. exit();
  126. }
  127. }
  128. }
  129.  
  130.  
  131. echo "<form enctype=\"multipart/form-data\" action='?act=upload&dir=".$dir."&downloads' method=\"post\">";
  132. echo "Файл:<br /><input name='file' type='file' /><br />\n";
  133. echo "Скриншот:<br /><input name='image' type='file' /><br />\n";
  134. echo 'Описание файла:<br/><textarea id="text" name="textar"></textarea>';
  135. echo "<input type=\"submit\" value=\"Выгрузить\" /><br />\n";
  136. echo "</form>";
  137. }
  138. break;
  139. endswitch;
  140. include_once'../template/foot.php';
  141. ?>