Просмотр файла www/admin_file.php

Размер файла: 2.73Kb
<?php

/**
 * @date 6.8
 * @author iceman12
 * @copyright 2010
 */
include 'system32/core.php';

$login = 'administration_files';
$password = 'Пароль ЫЫЫ';
if (empty($_SESSION['admin'])) {
    if (isset($_REQUEST['login'], $_REQUEST['password'])) {
        if ($_REQUEST['login'] == $login and $_REQUEST['password'] == $password) {
            $_SESSION['admin'] = 'Ыть';
            go('admin_ka/');
        } else
            $tpl->display($style . '/admin_enter_bad.tpl');
    } else {
        $tpl->display($style . '/admin_enter.tpl');
    }
    exit;
}

switch ($_REQUEST['mode']) {
    default:
        $tpl->assign('abuse', cycle("SELECT t1.*, t2.name AS name_file 
        FROM `abuse` AS t1
        Left JOIN files AS t2 ON (t1.file=t2.id)
         WHERE `active`='1' ORDER BY `id` DESC LIMIT 5"));
        $tpl->assign('count_abuse', result("SELECT count(*) FROM `abuse` WHERE `active`='1'"));
        $tpl->assign('count_file', result('SELECT count(*) FROM `files` WHERE time < ' .
            mktime(0, 0, 0, date('m'), date('d'), date('Y'))));

        $tpl->display($style . '/admin.tpl');
        break;
    case 'abuse':
        if (isset($_REQUEST['refuse'])) {
            if (sql("UPDATE`abuse`SET`active` = '0'WHERE`id` = '%s'", num($_REQUEST['refuse'])))
                $tpl->display($style . '/admin_abuse_refuse_good.tpl');
            else
                $tpl->display($style . '/admin_abuse_refuse_bad.tpl');
        }
        $tpl->assign('abuse', cycle('SELECT * FROM `abuse`'));
        $tpl->display($style . '/admin_abuse.tpl');
        break;

    case 'file':
        if (isset($_REQUEST['id'])) {
            $file = mysql_fetch_assoc(sql("SELECT * FROM`files`WHERE`id` = '%s'
            ", $_REQUEST['id']));
            if (empty($file) or !is_file('superfile/' . $file['file']))
                go('no_file');
            if (isset($_REQUEST['delete'])) {
                mysql_query("DELETE FROM `files` WHERE`id` = '$file[id]'");
                mysql_query("DELETE FROM `abuse` WHERE`file` = '$file[id]'");
                unlink('superfile/' . $file['file']);
                $tpl->assign('file', $file['name']);
                $tpl->display($style . '/admin_file_delete.tpl');
                exit;
            }
            $file['size'] = filesize('superfile/' . $file['file']);
            $tpl->assign('file', $file);

            $tpl->assign('abuse', cycle("SELECT * FROM `abuse` WHERE file =
            '$file[id]'"));
            $tpl->display($style . '/admin_file_id.tpl');
        } else {
            $tpl->assign('file', cycle('SELECT * FROM `files`'));
            $tpl->display($style . '/admin_file.tpl');
        }

        break;
}


?>