Размер файла: 6.11Kb
<?php
if (defined('BASEDIR')) {
exit (header('Location: /index.php'));
}
$headmod = 'pub';
$textl = 'Библиотека';
require_once ('../includes/start.php');
require_once ('../includes/functions.php');
require_once ('../includes/header.php');
include_once ('../themes/header.php');
require_once ("./inc/conf.php");
# Ограничиваем доступ к Библиотеке
if (!$closed && is_admin(array())) {
$error = 'Библиотека закрыта';
} else if ($closed == 1 && !is_user()) {
$error = 'Доступ в Библиотеку открыт только авторизованным посетителям';
} else if ($dos_load == "0") {
$error = 'Скачивание статей запрешенно!';
}
if ($error) {
echo '<div class="rmenu"><p>' . $error . '</p></div>';
include_once ('../themes/footer.php');
exit;
}
require_once ("panel.dat");
if (empty($_POST['submit'])) {
echo '<form method="post" action="load.php?id='.$id.'"><p>';
echo 'Выберете тип: <br /> <select name="type">';
echo '<option value="1">ZIP</option>';
echo '<option value="2">JAR</option>';
echo '<option value="3">TXT</option>';
echo '</select> <br />';
echo '<img src="/gallery/protect.php" alt="." /><br />';
echo 'Код с картинки: <br /> <input type="text" size="6" maxlength="6" name="kod"/></p>';
echo '<input value="Скачать" type="submit" name="submit"/></form>';
} else {
$type = trim($_POST['type']);
$kod = isset($_POST['kod']) ? check(strtolower($_POST['kod'])) : '';
if ($kod != $_SESSION['protect']) {
$error = 'Проверочный код не верен!';
} else if (empty($kod)) {
$error = 'Проверочный код неведен!';
}
if (empty($error)) {
switch ($type) {
case "1":
include_once './inc/zip.class.php';
$BDzip = DB::run() -> query("SELECT * FROM `pub_arts` WHERE `id`=?;", array($id));
if (!empty($BDzip)) {
$res = $BDzip -> fetch();
$text = stripslashes($res['text']).'';
$Zip = new createZip;
$Zip -> addFile($text, 'text_'.trans2($res['name']).'.txt');
$fileName = "file/load/".date('dmo_Hi').".zip";
if (file_exists ($fileName)) {
@unlink($fileName);
}
$fd = fopen ($fileName, "wb");
fwrite ($fd, $Zip -> getZippedfile());
fclose ($fd);
echo 'Вы можете скачать ZIP-Архив <br /> <a href="'.$fileName.'">Скачать</a> ('.formatsize(filesize($fileName)).') <br />';
} else {
echo '<div class="rmenu">Такой стаьи не существует</div>';
}
break;
case "2":
include_once './inc/zip.class2.php';
$BDjar = DB::run() -> query("SELECT * FROM `pub_arts` WHERE `id`=?;", array($id));
if (!empty($BDjar)) {
$res = $BDjar -> fetch();
$MANIF = file_get_contents('./jar/META-INF/MANIFEST.MF');
$aclass = file_get_contents('./jar/a.class');
$bclass = file_get_contents('./jar/b.class');
$cclass = file_get_contents('./jar/c.class');
$dclass = file_get_contents('./jar/d.class');
$eclass = file_get_contents('./jar/e.class');
$fclass = file_get_contents('./jar/f.class');
$gclass = file_get_contents('./jar/g.class');
$hclass = file_get_contents('./jar/h.class');
$iclass = file_get_contents('./jar/i.class');
$jclass = file_get_contents('./jar/j.class');
$charsets = file_get_contents('./jar/charsets');
$files = file_get_contents('./jar/files');
$htxt = file_get_contents('./jar/h.txt');
$mainclass = file_get_contents('./jar/main.class');
$windows866 = file_get_contents('./jar/windows-866');
$windows1251= file_get_contents('./jar/windows-1251');
$epng = file_get_contents('./jar/e.png');
$cpng = file_get_contents('./jar/c.png');
$text = '<encoding="UTF-8">'."\n".stripslashes($res['text']);
$createZip = new createZip;
$createZip -> addDirectory('META-INF/');
$createZip -> addFile($text, 'text.txt');
$createZip -> addFile($MANIF, 'META-INF/'.'MANIFEST.MF');
$createZip -> addFile($aclass, 'a.class');
$createZip -> addFile($bclass, 'b.class');
$createZip -> addFile($cclass, 'c.class');
$createZip -> addFile($dclass, 'd.class');
$createZip -> addFile($eclass, 'e.class');
$createZip -> addFile($fclass, 'f.class');
$createZip -> addFile($gclass, 'g.class');
$createZip -> addFile($hclass, 'h.class');
$createZip -> addFile($iclass, 'i.class');
$createZip -> addFile($jclass, 'j.class');
$createZip -> addFile($charsets, 'charsets');
$createZip -> addFile($files, 'files');
$createZip -> addFile($htxt, 'h.txt');
$createZip -> addFile($windows866, 'windows-866');
$createZip -> addFile($windows1251, 'windows-1251');
$createZip -> addFile($mainclass, 'main.class');
$createZip -> addFile($epng, 'e.png');
$createZip -> addFile($cpng, 'c.png');
$fileName = "file/load/txt_".date('dmo_Hi').".jar";
if (file_exists($fileName)) {
@unlink($fileName);
}
$fd = fopen ($fileName, "wb");
fwrite ($fd, $createZip -> getZippedfile());
fclose ($fd);
echo 'Вы можете скачать JAR-Архив <br /> <a href="'.$fileName.'">Скачать</a> ('.formatsize(filesize($fileName)).') <br />';
} else {
echo '<div class="rmenu">Такой стаьи не существует</div>';
}
break;
case "3":
$sql = DB::run() -> queryFetch("SELECT `name`, `text` FROM `pub_arts` WHERE `type` = 'file' and `id`=? LIMIT 1;", array($id));
if (!empty($sql)) {
$text = stripslashes($sql['text']);
$name = $sql['name'];
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="text_'.$name.'.txt"');
echo $text;
} else {
show_error('Данной публикации не существует!');
}
break;
}
} else {
echo '<div class="rmenu">'.$error.'</div>';
echo '<a href="?id='.$id.'">Повторить</a> <br />';
}
}
include_once ('../themes/footer.php');
?>