Размер файла: 4.54Kb
- <?
- /*
- =============================================
- Движок: SHCMS Engine
- =============================================
- Название файла: Обменник - Добавление нового файла
- =============================================
- Official website: http://shcms.ru
- =============================================
- */
- define('SHCMS', true);
- include_once'../system/inc/basic_settings.php';
- $shcmsengine['title'] = 'Добавить новый файл';
-
- include_once'../template/head.php';
- if($_GET['dir'])
- {$dir = $_GET['dir'];}
- $world = mysql_fetch_array(mysql_query("SELECT * FROM `download_dir` WHERE `id`='$dir'"));
- switch($act):
- case 'rules':
- echo '<div class="posts">';
- echo'<strong>Правила добавления файла:</strong><br/>
-
- При добавления файла в обменник указывайте автора файла, прикрепите скриншот и обязательно проверьте работаспособность файла.</div>
- <div class="posts">';
- $form = new form('?act=upload&dir='.$dir.'');
- $form->submit('Добавить файл','submit');
- $form->submit('Отменить','no');
- $form->finish();
- echo '</div>';
- break;
-
- case'upload':
-
- if(isset($_POST['no'])){
-
- header("Location: index.php");
- include_once '../template/foot.php';
- exit();
- }
- if($world['vib'] == 1 or $user4['team'] == 6){
- $loaddir = "files_obmen/";
-
- if(!$dir)
- {
- errors("Загрузка файлов неправильно");
- header("Refresh: 1; url=/download/index.php");
- include_once '../template/foot.php';
- exit();
- }
-
-
- function format($name) {
- $f1 = strrpos($name, ".");
- $f2 = substr($name, $f1 + 1, 999);
- $fname = strtolower($f2);
- return $fname;
- }
-
- if(isset($_GET['downloads'])) {
-
-
- if($_POST['textar'])
- {
- $textar = $_POST['textar'];
- }
- $textar = htmlspecialchars($textar);
- $textar = stripslashes($textar);
-
- $files_name = $_FILES['file']['name'];
- $fil = $_FILES['file']['name'];
-
-
- $fil = utf8_win(SHCMS_core::Upload_end($fil));
-
-
- $fil_format = format($fil);
- $fil_size = $_FILES['file']['size'];
-
- $newnamef = "$fil";
- if ((move_uploaded_file($_FILES["file"]["tmp_name"], "$loaddir/$newnamef")) == true)
- {
- $ch = $newnamef;
- @chmod("$ch", 0777);
- @chmod("$loaddir/$ch", 0777);
- if(isset($_FILES['image']))
- {
- $screen_name = $_FILES['image']['name'];
- }
-
- $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')");
-
- if($uploads == true)
- {
- if(!empty($_FILES["image"]))
- {
- if (preg_match("#[а-яё]+#ui",$_FILES["image"]['name'])) {
- errors("В название изображение присутствует недопустимые символы");
- header("Refresh: 1; url=upload.php?act=upload&dir=$dir");
- include_once '../template/foot.php';
- exit;
- }
- $uploaddir = $_SERVER['DOCUMENT_ROOT']."/download/screen/";
- $uploaddir.=$_FILES['image']['name'];
- if(move_uploaded_file($_FILES["image"]["tmp_name"], $uploaddir))
- {
- $screen = new screen_shcms($uploaddir);
- $screen->autoimageresize(640, 480);
- $screen->imagesave($new_image->image_type, $uploaddir);
- $screen->imageout();
- echo '<div class="actshcms">Скриншот успешно загружен</div>';
- }
- else
- {
- echo '<div class="actshcms">Скриншот не загружен</div>';
- }
- }
-
- echo '<div class="actshcms">Файл загружен успешно</div>';
- include_once '../template/foot.php';
- exit();
- }
- else
- {
- echo '<div class="errors">Ошибка при загрузки файла</div>';
- include_once '../template/foot.php';
- exit();
- }
- }
- }
-
-
- echo "<form enctype=\"multipart/form-data\" action='?act=upload&dir=".$dir."&downloads' method=\"post\">";
- echo "Файл:<br /><input name='file' type='file' /><br />\n";
- echo "Скриншот:<br /><input name='image' type='file' /><br />\n";
- echo 'Описание файла:<br/><textarea id="text" name="textar"></textarea>';
- echo "<input type=\"submit\" value=\"Выгрузить\" /><br />\n";
- echo "</form>";
- }
- break;
- endswitch;
- include_once'../template/foot.php';
- ?>