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

Размер файла: 6.34Kb
<?php
#--------THE XSIT.RU--------------#
require_once ("../includes/start.php");
require_once ("../includes/functions.php");
require_once ("../includes/header.php");
include_once ("../themes/".$config['themes']."/index.php");
if (isset($_GET['start'])){$start = (int)$_GET['start'];} else {$start = 0;}
show_title('partners.gif', 'Обмен файлов'); 
require 'config.php';
if (!isset($_FILES['userfile'])) {
    echo 'Ошибка при загрузке!<br/><img src="../images/img/back.gif" alt="image" /> <a href="addfile.php?' . SID . '">Заново</a><br/>' ; 
echo '<img src="../images/img/homepage.gif" alt="image" /> <a href="../index.php?'.SID.'">На главную</a><br/>'; 
if($config['kopiring']==1){
echo '<center><b><a href="http://xsit.ru">© Power XSIT</a></b></center><br/>';}
include_once ("../themes/".$config['themes']."/foot.php");
    exit;
}


if (!isset($_POST['op']) || strlen($_POST['op']) < 10) {
    echo 'Описание должно быть более 10 символов<br/><img src="../images/img/back.gif" alt="image" /> <a href="addfile.php?' . SID . '">Заново</a><br/>' ; 
echo '<img src="../images/img/homepage.gif" alt="image" /> <a href="../index.php?'.SID.'">На главную</a><br/>'; 
if($config['kopiring']==1){
echo '<center><b><a href="http://xsit.ru">© Power XSIT</a></b></center><br/>';}
include_once ("../themes/".$config['themes']."/foot.php");
    exit;
}

if (!$_POST['name']) {
    echo 'Вы не ввели имя<br/><img src="../images/img/back.gif" alt="image" /> <a href="addfile.php?' . SID . '">Заново</a><br/>'; 
echo '<img src="../images/img/homepage.gif" alt="image" /> <a href="../index.php?'.SID.'">На главную</a><br/>'; 
if($config['kopiring']==1){
echo '<center><b><a href="http://xsit.ru">© Power XSIT</a></b></center><br/>';}
include_once ("../themes/".$config['themes']."/foot.php");
    exit;
}

if ($_FILES['userfile']['error']) {
    echo 'Ошибка при передаче файла<br/><img src="../images/img/back.gif" alt="image" /> <a href="addfile.php?' . SID . '">Заново</a><br/>'; 
echo '<img src="../images/img/homepage.gif" alt="image" /> <a href="../index.php?'.SID.'">На главную</a><br/>'; 
if($config['kopiring']==1){
echo '<center><b><a href="http://xsit.ru">© Power XSIT</a></b></center><br/>';}
include_once ("../themes/".$config['themes']."/foot.php");
    exit;
}


$name = trim(htmlspecialchars($_POST['name']));

$op = trim(htmlspecialchars($_POST['op']));
$op = str_replace("\r", '', $op);
$op = str_replace("\n", '<br/>', $op);
$op = str_replace('<br/><br/>', '<br/>', $op);


$file[0] = $_FILES['userfile']['name'];
$rs = pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION);

$ext = array();
foreach (scandir('.') as $f) {
    if ($f[0] != '.' && $f != 'data' && is_dir($f)) {
        $ext[$f] = true;
    }
}

if (!isset($ext[$rs])) {
    echo 'Формат вашего файла (' . htmlspecialchars($rs, ENT_NOQUOTES) . ') не поддерживается<br/><img src="../images/img/back.gif" alt="image" /> <a href="addfile.php?' . SID . '">Заново</a><br/>'; 
echo '<img src="../images/img/homepage.gif" alt="image" /> <a href="../index.php?'.SID.'">На главную</a><br/>'; 
if($config['kopiring']==1){
echo '<center><b><a href="http://xsit.ru">© Power XSIT</a></b></center><br/>';}
include_once ("../themes/".$config['themes']."/foot.php");
    exit;
}


$file[0] = str_replace(
    array('Ё', 'Ж', 'Ч', 'Ш', 'Щ', 'Э', 'Ю', 'Я', 'ё', 'ж',
    'ч', 'ш', 'щ', 'э', 'ю', 'я', 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'З', 'И', 'Й', 'К',
    'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ы', 'а', 'б', 'в',
    'г', 'д', 'е', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у',
    'ф', 'х', 'ц'),
    array('JO', 'ZH', 'CH', 'SH', 'SCH', 'JE', 'JY', 'JA', 'jo',
    'zh', 'ch', 'sh', 'sch', 'je', 'jy', 'ja', 'A', 'B', 'V', 'G', 'D', 'E', 'Z',
    'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'Y',
    'a', 'b', 'v', 'g', 'd', 'e', 'z', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r',
    's', 't', 'u', 'f', 'h', 'c'),
    $file[0]
);

$file[0] = str_replace(' ', '_', $file[0]);
$file[0] = str_replace("'", '_', $file[0]);
$file[0] = str_replace('"', '_', $file[0]);
$file[0] = str_replace('?', '', $file[0]);
$file[0] = str_replace('~', '', $file[0]);
$file[0] = str_replace('../', '', $file[0]);
$file[0] = str_replace('|', '', $file[0]);
$file[0] = str_replace('+', '', $file[0]);
$file[0] = str_replace('%', '', $file[0]);
$file[0] = str_replace('^', '', $file[0]);
$file[0] = str_replace('&', '', $file[0]);
$file[0] = str_replace('@', '', $file[0]);
$file[0] = str_replace('!', '', $file[0]);
$file[0] = str_replace('`', '', $file[0]);


$file[0] = ucfirst(strtolower($file[0]));

$odir1 = opendir('.');
while ($dir1 = readdir($odir1)) {
    if (is_dir($dir1) && $dir1[0] != '.' && $dir1 != 'data' && $rs == $dir1) {

        if (file_exists("$dir1/$file[0]")) {
            echo 'Файл с таким именем уже есть, придумайте более оригинальное имя<br/><img src="../images/img/back.gif" alt="image" /> <a href="addfile.php?' . SID . '">Заново</a><br/>'; 
echo '<img src="../images/img/homepage.gif" alt="image" /> <a href="../index.php?'.SID.'">На главную</a><br/>'; 
if($config['kopiring']==1){
echo '<center><b><a href="http://xsit.ru">© Power XSIT</a></b></center><br/>';}
include_once ("../themes/".$config['themes']."/foot.php");
            exit;
        }


        move_uploaded_file($_FILES['userfile']['tmp_name'], "$dir1/$file[0]");
        chmod("$dir1/$file[0]", 0644);

        $fop = $filename;
        $fop = fopen("$dir1/$file[0].dat", 'wb');
        flock($fop, LOCK_EX);
        fputs($fop, "$op|:|:|:|$name\n");
        flock($fop, LOCK_UN);
        fclose($fop);
        chmod("$dir1/$file[0].dat", 0644);

        echo 'Файл успешно загружен<br/><img src="../images/img/back.gif" alt="image" /> <a href="addfile.php?' . SID . '">Загрузить Еще</a><br/>'; 
echo '<img src="../images/img/homepage.gif" alt="image" /> <a href="../index.php?'.SID.'">На главную</a><br/>';
if($config['kopiring']==1){
echo '<center><b><a href="http://xsit.ru">© Power XSIT</a></b></center><br/>';} 
include_once ("../themes/".$config['themes']."/foot.php");
        exit;
    }
}

?>