View file download/upload.php

File size: 3.06Kb
<?
/*
=============================================
Движок: 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"));
$user_s = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id=$user_id"));

if($world['vib'] == 1)
{
$loaddir = "files_obmen/";

if(!$dir)
{
echo 'Ошибка';
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['act']))
{


if($_POST['textar'])
{
$textar = $_POST['textar'];
}
$textar = htmlspecialchars($textar);
$textar = stripslashes($textar);

$fil = $_FILES['file']['name'];
$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'];
}
			$ti_in = 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_date','$user_id','$user_s[login]','$textar','$screen_name','$fil')");

if($ti_in == true)
{
if(!empty($_FILES["image"])) 
   {
     $uploaddir = $_SERVER['DOCUMENT_ROOT']."/download/screen/";
     $uploaddir.=$_FILES['image']['name'];
     if(move_uploaded_file($_FILES["image"]["tmp_name"], $uploaddir))
     {
      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='?dir=".$dir."&act' method=\"post\">";
echo "Файл:<br />\n";
echo "<input name='file' type='file' /><br />\n";
echo "Скриншот:<br />\n";
echo "<input name='image' type='file' /><br />\n";
echo 'Описание файла:<br/><textarea name="textar"></textarea>';
echo "<input type=\"submit\" value=\"Выгрузить\" /><br />\n";


echo "</form>";
}
include_once'../template/foot.php';
?>