Вход Регистрация
Файл: bloodlands.pw/downloads/load.php
Строк: 75
<?php

require '../system/sid.php';
require 
'../system/config.php';
include 
'../system/user.php';

whorm(0, 'fo');

include 
'../system/head.php';

$r = my_int($_REQUEST['r']);

$zip = new ZipArchive;

echo 
$div_title . 'Добавление файла' . $div_end;
echo 
'<div class="menu">';

    
$em = mysql_query("SELECT * FROM fo_cat WHERE id = '$r' LIMIT 1");
    if (
mysql_num_rows($em) == false)
    {
        
err('Раздел не найден!');
        include 
'../system/foot.php';
         exit();
    }

   
//--------------------//
   
$sets = mysql_fetch_array(mysql_query("SELECT `fo_limit`, `fo_moder` FROM `setting` WHERE `ids` = '1'"));
   
$_mod = ($sets[1] == 1) ? '<br/>Файл будет доступен после проверки Администратором.' : '';
   
//--------------------//

   
if (isset($_GET['ok'])) msg('Файл был успешно загружен!' . $_mod);

   if (isset(
$_POST['up'])) {
      
$folder = check($_POST['folder']);
      
$parol = my_int($_POST['parol']);
      
$upl = my_int($_POST['upl']);
      
$name = trim(mysql_real_escape_string(check($_POST['name'])));
      
$opis = trim(mysql_real_escape_string(check($_POST['opis'])));
      if (isset(
$_POST['url'])) $url = htmlentities($_POST['url']);

if (
$upl == 1)
{

      
$FileName = $_FILES['object']['name'];
      
$FileSize = $_FILES['object']['size'];

      
$archive = array('.zip', '.rar', '.tar', '.cab', '.gz', '.gzip');

         
$ext = strtolower(strrchr($FileName, '.'));

         if (
$FileSize > (1024 * $sets[0] * 1024))
         {
            
err('Размер файла не должен быть более ' . $sets[0] . ' Мб.');
         }
         elseif (empty(
$folder))
         {
            
err('Не выбрана папка для загрузки!');
         }
         elseif (empty(
$FileName))
         {
            
err('Не выбран файл!');
         }
         elseif (
preg_match('/(.php|.pl|.htaccess)/i', $FileName) || !in_array($ext, $archive))
         {
            
err('Файл не является архивом!');
         }
         else
         {

            if (
$zip->open($_FILES['object']['tmp_name']) === TRUE)
            {
                
$zip->setArchiveComment($site . ' - best collection of scripts.');
                
$zip->addFromString('ReadMe_'.$site.'.txt', 'Cкрипт скачан с сайта http://' . $site);
                
$zip->close();
            }

            
$NameFile = 'files/archive/' . mt_rand(10000, 99999) . $FileName;
            
copy($_FILES['object']['tmp_name'], $NameFile);
            
$nazvanie = (empty($name)) ? $FileName : $name;

              
mysql_query("INSERT INTO `fo_files` SET
                           `url` = '
$NameFile',
                           `time` = '" 
. time() . "',
                           `author` = '
$user[id]',
                           `title` = '
$nazvanie',
                           `info` = '
$opis',
                           `parol` = '
$parol',
                           `rid` = '
$r',
                           `cat` = '
$folder',
                           `moder` = '
$sets[1]'");

              
header('Location: load.php?r='.$r.'&ok');
        }
    } elseif (
$upl == 2) {
        
$file = getWithOutPath($url);
        
$format = strtolower(strrchr($file, '.'));
        
$ext = array('.zip', '.rar', '.gz', '.gzip', '.tar', '.cab');
        
$f = @fopen($url, 'r');
        while(
$c = @fread($f, 1024)) $filedata .= $c;

        if (!
$f)
        {
            
err('Ошибка импортирования файла!');
        }
        elseif (!
in_array($format, $ext))
        {
            
err('Файл не является архивом!');
        }
        elseif (
strlen($filedata) > (1024 * $sets[0] * 1024))
        {
            
err('Слишком большой размер файла!');
        } else {

            
mkdir('extract', 0777);
            
copy($url, 'extract/' . $file);
            if (
$zip->open('extract/' . $file) === TRUE)
            {
                
$zip->setArchiveComment($site . ' - best collection of scripts.');
                
$zip->addFromString('ReadMe_' . $site . '.txt', 'Файл скачан с сайта http://' . $site);
                
$zip->close();
            }

            
$NameFile = 'files/' . mt_rand(10000, 99999) . $file;
            
copy('extract/' . $file, $NameFile);
            
removeDir('extract');
            
$nazvanie = (empty($name)) ? $file : $name;
            
mysql_query("INSERT INTO `fo_files` SET
                           `url` = '
$NameFile',
                           `time` = '" 
. time() . "',
                           `author` = '
$user[id]',
                           `title` = '
$nazvanie',
                           `info` = '
$opis',
                           `parol` = '
$parol',
                           `rid` = '
$r',
                           `cat` = '
$folder',
                           `moder` = '
$sets[1]'");

              
header('Location: load.php?r='.$r.'&ok');
        }
     }
   }

    echo 
'<FORM action="load.php?" method="POST" ENCTYPE="multipart/form-data">
          <label>Название файла:</label><br/>
          <input type="text" name="name"/>
          <br/>
          <label>Выгрузить файл:</label><br/>
          <input type="file" name="object"/>
          <br/>
          <label>Импортировать файл:</label><br/>
          <input type="text" name="url" value="http://"/>
          <br/>
          <label>Описание файла:</label><br/>
          <textarea name="opis" rows="5" cols="20"></textarea>
          <br/>
          <label>В папку:</label>
          <br/>
          <select name="folder">'
;

    
$lists = mysql_query("SELECT * FROM fo_pod WHERE cid = '$r'");
    echo 
'<option value="0">-Не выбрано-</option>';
    while(
$A = mysql_fetch_assoc($lists))
    {
        echo 
'<option value="'.$A['id'].'">' . $A['title'] . '</option>';
    }

    echo 
'</select>
          <br/>
          <input type="radio" name="upl" checked value="1"/> Обычная загрузка
          <input type="radio" name="upl" value="2"/> Импорт
          <br/>
          <input type="hidden" name="r" value="'
.$r.'"/>
          <input type="submit" name="up" value="Загрузить"/>
          </FORM></div>'
;

include 
'../system/foot.php';
?>
Онлайн: 3
Реклама