Файл: soc-set/moduls/lib2/index.php
Строк: 239
<?php
require_once('../../core/start.php');
check_auth();
switch ($select) {
default:
head('Библиотека');
echo DIV_TITLE . 'Библиотека' . CLOSE_DIV;
if ($_POST['add'] && privilegy('lib')) {
$name = html($_POST['name']);
if (empty($name)) {
echo DIV_ERROR . 'Введите название папки' . CLOSE_DIV;
} else {
DB::$dbs->query("INSERT INTO ".LIB." (`name`) VALUES (?)", array($name));
header("Location: ".HOME."/lib/");
}
}
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LIB."");
if ($all == 0) {
echo DIV_AUT . 'Папки не созданы' . CLOSE_DIV;
} else {
$sql = DB::$dbs->query("SELECT * FROM ".LIB." ORDER BY `id` DESC ");
while($folder = $sql -> fetch()) {
$articls = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LIB_ARTICL." WHERE `folder_id` = ? ", array($folder['id']));
echo DIV_LI . '<a href="'.HOME.'/lib/'.$folder['id'].'/">'.$folder['name'].'</a> ['.$articls.']' . CLOSE_DIV;
}
}
if (privilegy('lib')) {
echo DIV_AUT;
echo '<form action="#" method="POST">';
echo 'Новая папка:<br /><input type="text" name="name" />';
echo '<input type="submit" name="add" value="+" /></form>';
echo CLOSE_DIV;
}
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <b>Библиотека</b>' . CLOSE_DIV;
break;
case 'folder':
$folder = DB::$dbs->queryFetch("SELECT * FROM ".LIB." WHERE `id` = ? ", array(abs(num($_GET['folder']))));
if (empty($folder)) {
head('Каталог не найден');
echo DIV_TITLE . 'Каталог не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
} else {
head('Каталог: ' . $folder['name']);
echo DIV_TITLE . 'Каталог: ' . $folder['name']. CLOSE_DIV;
if (isset($_GET['del'])) {
if (!isset($_GET['go'])) {
echo DIV_LI . '<b>Подтвердите удаление:</b> <a href="?del&go">[Удалить]</a> <a href="'.HOME.'/lib/'.$folder['id'].'/">[Нет]</a>' . CLOSE_DIV;
} else {
DB::$dbs->query("DELETE FROM ".LIB_CAT." WHERE `folder_id` = ? ", array($folder['id']));
DB::$dbs->query("DELETE FROM ".LIB." WHERE `id` = ? ", array($folder['id']));
header("Location: ".HOME."/lib/");
}
}
if (isset($_GET['edit']) && privilegy('lib')) {
if ($_POST['edit']) {
$name = html($_POST['name']);
if (empty($name)) {
echo DIV_ERROR . 'Введите название каталога' . CLOSE_DIV;
} else {
DB::$dbs->query("UPDATE ".LIB." SET `name` = ? WHERE `id` = ? ", array($name, $folder['id']));
header("Location: ".HOME."/lib/".$folder['id']."/");
}
}
echo DIV_AUT;
echo '<form action="#" method="POST">';
echo 'Редактирование каталога:<br /><input type="text" value="'.$folder['name'].'" name="name" />';
echo '<input type="submit" name="edit" value="Изменить" /></form>';
echo CLOSE_DIV;
}
if ($_POST['add'] && privilegy('lib')) {
$name = html($_POST['name']);
if (empty($name)) {
echo DIV_ERROR . 'Введите название каталога' . CLOSE_DIV;
} else {
DB::$dbs->query("INSERT INTO ".LIB_CAT." (`folder_id`, `name`) VALUES (?, ?)", array($folder['id'], $name));
header("Location: ".HOME."/lib/".$folder['id']."/");
}
}
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LIB_CAT." WHERE `folder_id` = ?", array($folder['id']));
if ($all == 0) {
echo DIV_AUT . 'Подкаталогов нет' . CLOSE_DIV;
} else {
$n = new Navigator($all,$config['write']['lib_cat'],'folder='.$folder['id'].'&select=folder');
$sql = DB::$dbs->query("SELECT * FROM ".LIB_CAT." WHERE `folder_id` = ? ORDER BY `id` DESC LIMIT {$n->start()}, ".$config['write']['lib_cat']." ", array($folder['id']));
while($folderc = $sql -> fetch()) {
$articls = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LIB_ARTICL." WHERE `folderc_id` = ? ", array($folderc['id']));
echo DIV_LI . '<a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/">'.$folderc['name'].'</a> ['.$articls.']' . CLOSE_DIV;
}
echo $n->navi();
}
}
if (privilegy('lib')) {
echo DIV_AUT;
echo '<form action="#" method="POST">';
echo 'Новый подкаталог:<br /><input type="text" name="name" />';
echo '<input type="submit" name="add" value="+" /></form>';
echo CLOSE_DIV;
if (!empty($folder)) {
echo DIV_BLOCK;
echo '<a href="?edit">Редактировать каталог <b>'.$folder['name'].'</b></a><br />';
echo '<a href="?del">Удалить каталог <b>'.$folder['name'].'</b></a><br />';
echo CLOSE_DIV;
}
}
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <b>'.(empty($folder) ? 'Каталог не найден' : $folder['name']).'</b>' . CLOSE_DIV;
break;
case 'articls':
$folder = DB::$dbs->queryFetch("SELECT * FROM ".LIB." WHERE `id` = ? ", array(abs(num($_GET['folder']))));
if (empty($folder)) {
head('Каталог не найден');
echo DIV_TITLE . 'Каталог не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <b>Каталог не найден</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
$folderc = DB::$dbs->queryFetch("SELECT * FROM ".LIB_CAT." WHERE `id` = ? ", array(abs(num($_GET['folderc']))));
if (empty($folderc)) {
head('Подкаталог не найден');
echo DIV_TITLE . 'Подкаталог не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <b>Подкаталог не найден</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
head('Статьи подкаталога: ' . $folderc['name']);
echo DIV_TITLE . 'Статьи подкаталога: ' . $folderc['name'] . CLOSE_DIV;
if (isset($_GET['del']) && privilegy('lib')) {
if (!isset($_GET['go'])) {
echo DIV_LI . '<b>Подтвердите удаление:</b> <a href="?del&go">[Удалить]</a> <a href="'.HOME.'/lib/'.$folderc['id'].'/">[Нет]</a>' . CLOSE_DIV;
} else {
DB::$dbs->query("DELETE FROM ".LIB_CAT." WHERE `id` = ? ", array($folderc['id']));
header("Location: ".HOME."/lib/".$folder['id']."/");
}
}
if (isset($_GET['edit']) && privilegy('lib')) {
if ($_POST['edit']) {
$name = html($_POST['name']);
if (empty($name)) {
echo DIV_ERROR . 'Введите название подкаталога' . CLOSE_DIV;
} else {
DB::$dbs->query("UPDATE ".LIB_CAT." SET `name` = ? WHERE `id` = ? ", array($name, $folderc['id']));
header("Location: ".HOME."/lib/".$folder['id']."/".$folderc['id']."/");
}
}
echo DIV_AUT;
echo '<form action="#" method="POST">';
echo 'Редактирование подкаталога:<br /><input type="text" value="'.$folderc['name'].'" name="name" />';
echo '<input type="submit" name="edit" value="Изменить" /></form>';
echo CLOSE_DIV;
}
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LIB_ARTICL." WHERE `folderc_id` = ?", array($folderc['id']));
if ($all == 0) {
echo DIV_AUT . 'Статьи отсуствывают' . CLOSE_DIV;
} else {
$n = new Navigator($all,$config['write']['lib_articl'],'select=articls&folder='.$folder['id'].'&folderc='.$folderc['id']);
$sql = DB::$dbs->query("SELECT * FROM ".LIB_ARTICL." WHERE `folderc_id` = ? ORDER BY `id` DESC LIMIT {$n->start()}, ".$config['write']['lib_articl']." ", array($folderc['id']));
while($articl = $sql -> fetch()) {
echo DIV_LI . '<a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/'.$articl['id'].'/">'.$articl['title'].'</a>' . CLOSE_DIV;
}
echo $n->navi();
}
echo DIV_AUT . '<b>Новая книга:</b><br /><form action="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/add/" enctype="multipart/form-data" method="POST">
* Название:<br /><input type="text" name="name" /><br /><br />
* Текст:<br /><textarea name="text"></textarea><br />
Загрузить книгу:<br />
<input type="file" name="file" /><br /><br />
Описание:<br /><textarea name="info"></textarea><br /><br />
Скриншот:<br />
<input type="file" name="screen" /><br />
<input type="submit" name="add" value="Добавить книгу" /></form>' . CLOSE_DIV;
if (privilegy('lib')) {
echo DIV_BLOCK;
echo '<a href="?edit">Редактировать подкаталог <b>'.$folderc['name'].'</b></a><br />';
echo '<a href="?del">Удалить подкаталог <b>'.$folderc['name'].'</b></a><br />';
echo CLOSE_DIV;
}
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <a href="'.HOME.'/lib/'.$folder['id'].'/">'.$folder['name'].'</a>/ <b>'.$folderc['name'].'</b>' . CLOSE_DIV;
break;
case 'articl':
$folder = DB::$dbs->queryFetch("SELECT * FROM ".LIB." WHERE `id` = ? ", array(abs(num($_GET['folder']))));
if (empty($folder)) {
head('Каталог не найден');
echo DIV_TITLE . 'Каталог не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <b>Каталог не найден</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
$folderc = DB::$dbs->queryFetch("SELECT * FROM ".LIB_CAT." WHERE `id` = ? ", array(abs(num($_GET['folderc']))));
if (empty($folderc)) {
head('Подкаталог не найден');
echo DIV_TITLE . 'Подкаталог не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <b>Подкаталог не найден</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
$articl = DB::$dbs->queryFetch("SELECT * FROM ".LIB_ARTICL." WHERE `id` = ? ", array(abs(num($_GET['articl']))));
if (empty($articl)) {
head('Статья не найдена');
echo DIV_TITLE . 'Статья не найдена' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <b>Статья не найдена</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
head('Статья: ' . $articl['title']);
if (isset($_GET['del'])) {
if (!isset($_GET['go'])) {
echo DIV_LI . '<b>Подтвердите удаление:</b> <a href="?del&go">[Удалить]</a> <a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/'.$articl['id'].'/">[Нет]</a>' . CLOSE_DIV;
} else {
DB::$dbs->query("DELETE FROM ".LIB_COMM." WHERE `articl_id` = ? ", array($articl['id']));
@unlink('../../files/lib/screen/'.$articl['screen']);
@unlink('../../files/lib/jar/'.$articl['id'].'.jar');
@unlink('../../files/lib/jad/'.$articl['id'].'.jad');
@unlink('../../files/lib/text/'.$articl['text']);
DB::$dbs->query("DELETE FROM ".LIB_ARTICL." WHERE `id` = ? ", array($articl['id']));
header("Location: ".HOME."/lib/".$folder['id']."/".$folderc['id']."/");
}
}
echo DIV_TITLE . 'Статья: ' . $articl['title'] . CLOSE_DIV;
echo DIV_BLOCK . '<b><big>' . $articl['title'] . '</big></b><br />';
if (!empty($articl['screen'])) {
echo '<a href="'.HOME.'/files/lib/screen/'.$articl['screen'].'"><img src="'.HOME.'/files/lib/screen/mini_'.$articl['screen'].'"/></a><br />';
}
echo '<b>Описание:</b> ' . text($articl['info']);
echo CLOSE_DIV;
function nav($total,$page,$num,$url) { //view.php?id='.$id.'
if ($page != 1) $pervpage = ' <a href= "'.$url.'?page='. ($page - 1) .'">«</a> ';
// Проверяем нужны ли стрелки вперед
if ($page != $total) $nextpage = ' <a href="'.$url.'?page='. ($page + 1) .'">»</a>';
if ($page - 4 > 0) $first = '<a href="'.$url.'?page=1">1</a>...';
if ($page + 4 <= $total) $last = '...<a href="'.$url.'?page='.$total.'">'.$total.'</a>';
// Находим две ближайшие станицы с обоих краев, если они есть
if($page - 2 > 0) $page2left = ' <a href= "'.$url.'?page='. ($page - 2) .'">'. ($page - 2) .'</a> ';
if($page - 1 > 0) $page1left = '<a href= "'.$url.'?page='. ($page - 1) .'">'. ($page - 1) .'</a> ';
if($page + 2 <= $total) $page2right = ' <a href= "'.$url.'?page='. ($page + 2) .'">'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' <a href="'.$url.'?page='. ($page + 1) .'">'. ($page + 1) .'</a>';
echo '<div class="nav">'.$pervpage.$first.$page2left.$page1left.'['.$page.']'.$page1right.$page2right.$last.$nextpage.'</div>';
}
$simvol = $config['write']['lib_articl_str']; // Число символов на страницу по умолчанию
// Постраничная навигация читаемой статьи
// Используется модифицированный код от hintoz
$tx = file_get_contents('../../files/lib/text/'.$articl['text']);
$strrpos = mb_strrpos($tx, " ");
$pages = 1;
// Вычисляем номер страницы
if (isset($_GET['page'])) {
$page = abs(intval($_GET['page']));
if ($page == 0)
$page = 1;
$start = $page - 1;
}
else {
$page = $start + 1;
}
$t_si = 0;
if ($strrpos) {
while ($t_si < $strrpos) {
$string = mb_substr($tx, $t_si, $simvol);
$t_ki = mb_strrpos($string, " ");
$m_sim = $t_ki;
$strings[$pages] = $string;
$t_si = $t_ki + $t_si;
if ($page == $pages) {
$page_text = $strings[$pages];
}
if ($strings[$pages] == "") {
$t_si = $strrpos++;
}
else {
$pages++;
}
}
if ($page >= $pages) {
$page = $pages - 1;
$page_text = $strings[$page];
}
$pages = $pages - 1;
if ($page != $pages) {
$prb = mb_strrpos($page_text, " ");
$page_text = mb_substr($page_text, 0, $prb);
}
}
else {
$page_text = $tx;
}
// Предварительна фильтрация статьи и вывод
$page_text = htmlentities($page_text, ENT_QUOTES, 'UTF-8');
$page_text = nl2br($page_text);
echo DIV_BLOCK . $page_text . CLOSE_DIV;
if ($pages > 1) {
echo DIV_LI;
nav($pages,$page,$num,'');
echo CLOSE_DIV;
}
echo DIV_BLOCK;
echo 'Скачать: <a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/'.$articl['id'].'/load/?jar">[JAR]</a> <a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/'.$articl['id'].'/load/?jad">[JAD]</a> <a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/'.$articl['id'].'/load/?txt">[TXT]</a><br />';
echo '<br />';
$comm = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LIB_COMM." WHERE `articl_id` = ?", array($articl['id']));
echo '<a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/'.$articl['id'].'/comm/">Комментарии</a> ['.$comm.']<br />';
echo CLOSE_DIV;
if (privilegy('lib')) {
echo DIV_BLOCK;
echo '<a href="?del">Удалить книгу</a><br />';
echo CLOSE_DIV;
}
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <a href="'.HOME.'/lib/'.$folder['id'].'/">'.$folder['name'].'</a> / <a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/">'.$folderc['name'].'</a> / <b>'.$articl['title'].'</b>' . CLOSE_DIV;
break;
case 'comm':
$folder = DB::$dbs->queryFetch("SELECT * FROM ".LIB." WHERE `id` = ? ", array(abs(num($_GET['folder']))));
if (empty($folder)) {
head('Каталог не найден');
echo DIV_TITLE . 'Каталог не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <b>Каталог не найден</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
$folderc = DB::$dbs->queryFetch("SELECT * FROM ".LIB_CAT." WHERE `id` = ? ", array(abs(num($_GET['folderc']))));
if (empty($folderc)) {
head('Подкаталог не найден');
echo DIV_TITLE . 'Подкаталог не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <b>Подкаталог не найден</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
$articl = DB::$dbs->queryFetch("SELECT * FROM ".LIB_ARTICL." WHERE `id` = ? ", array(abs(num($_GET['articl']))));
if (empty($articl)) {
head('Статья не найдена');
echo DIV_TITLE . 'Статья не найдена' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <b>Статья не найдена</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
head('Комментарии к книге');
echo DIV_TITLE . 'Комментарии к книге' . CLOSE_DIV;
if ($_POST) {
$comm = html($_POST['comm']);
if (empty($comm)) {
$err = 'Комментарий пуст';
}
if (!empty($err)) {
echo DIV_ERROR . $err . CLOSE_DIV;
} else {
DB::$dbs->query("INSERT INTO ".LIB_COMM." (`articl_id`, `user_id`, `comm`, `time`) VALUES (?, ?, ?, ?)", array($articl['id'], $user['user_id'], $comm, time()));
balls_operation(2);
echo DIV_MSG . 'Комментарий добавлен' . CLOSE_DIV;
}
}
$comm = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LIB_COMM." WHERE `articl_id` = ?", array($articl['id']));
echo DIV_LI . '<b>Комментарии к книге:</b>' . CLOSE_DIV;
if (!empty($_GET['del_comm'])) {
DB::$dbs->query("DELETE FROM ".LIB_COMM." WHERE `id` = ? ", array(num($_GET['del_comm'])));
}
if (empty($comm)) {
echo DIV_BLOCK . 'Комментарий нет' . CLOSE_DIV;
} else {
$n = new Navigator($comm,$config['write']['lib_comm'],'select=comm&id='.$articl['id']);
$sql = DB::$dbs->query("SELECT * FROM ".LIB_COMM." WHERE `articl_id` = ? ORDER BY `id` DESC LIMIT {$n->start()}, ".$config['write']['lib_comm']."", array($articl['id']));
while($comm = $sql -> fetch()) {
echo DIV_LI . userLink($comm['user_id']) . ' [' . vrem($comm['time']) . ']' . (privilegy('lib_moder') ? ' <a href="?del_comm='.$comm['id'].'">[Удал.]</a>' : NULL) . CLOSE_DIV;
echo DIV_BLOCK . text($comm['comm']) . CLOSE_DIV;
}
echo $n->navi();
}
echo DIV_AUT;
echo '<form action="#" method="POST">';
echo 'Комментарий:<br /><textarea name="comm"></textarea><br />';
echo '<input type="submit" value="Добавить" /></form>';
echo CLOSE_DIV;
bbsmile();
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/lib/">Библиотека</a> / <a href="'.HOME.'/lib/'.$folder['id'].'/">'.$folder['name'].'</a> / <a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/">'.$folderc['name'].'</a> / <a href="'.HOME.'/lib/'.$folder['id'].'/'.$folderc['id'].'/'.$articl['id'].'/">'.$articl['title'].'</a> / <b>Комментарии</b>' . CLOSE_DIV;
break;
case 'load':
head('Загрузка файла');
$articl = DB::$dbs->queryFetch("SELECT * FROM ".LIB_ARTICL." WHERE `id` = ? ", array(abs(num($_GET['articl']))));
echo DIV_TITLE . 'Загрузка файла' . CLOSE_DIV;
echo DIV_BLOCK;
if (isset($_GET['jar'])) {
if (!file_exists('../../files/lib/jar/' . $articl['id'] . '.jar')) {
$text = file_get_contents('../../files/lib/text/'.$articl['text']);
$midlet_name = mb_substr($articl['title'], 0, 10);
$midlet_name = iconv('UTF-8', 'windows-1251', $midlet_name);
// Записываем текст статьи
$files = fopen("java/book.txt", 'w+');
flock($files, LOCK_EX);
$book_name = iconv('UTF-8', 'windows-1251', $articl['title']);
$book_text = iconv('UTF-8', 'windows-1251', $text);
$result = $book_text;
fputs($files, $result);
flock($files, LOCK_UN);
fclose($files);
// Создаем архив
require_once ('../../core/class/pclzip.lib.php');
$archive = new PclZip('../../files/lib/jar/' . $articl['id'] . '.jar');
$list = $archive->create('java', PCLZIP_OPT_REMOVE_PATH, 'java');
}
header("Location: ".HOME."/files/lib/jar/".$articl['id'].".jar");
} elseif (isset($_GET['jad'])) {
$text = file_get_contents('../../files/lib/text/'.$articl['text']);
if (!file_exists('../../files/lib/jar/' . $articl['id'] . '.jar')) {
$midlet_name = mb_substr($articl['title'], 0, 10);
$midlet_name = iconv('UTF-8', 'windows-1251', $midlet_name);
// Записываем текст статьи
$files = fopen("java/book.txt", 'w+');
flock($files, LOCK_EX);
$book_name = iconv('UTF-8', 'windows-1251', $articl['title']);
$book_text = iconv('UTF-8', 'windows-1251', $text);
$result = $book_text;
fputs($files, $result);
flock($files, LOCK_UN);
fclose($files);
// Создаем архив
require_once ('../../core/class/pclzip.lib.php');
$archive = new PclZip('../../files/lib/jar/' . $articl['id'] . '.jar');
$list = $archive->create('java', PCLZIP_OPT_REMOVE_PATH, 'java');
}
if (!file_exists('../../files/lib/jad/' . $articl['id'] . '.jad')) {
$filesize = filesize('../../files/lib/jad/' . $articl['id'] . '.jar');
$jad_text = 'Manifest-Version: 1.0
MIDlet-1: ' . $articl['id'] . ', , br.BookReader
MIDlet-Name: ' . $articl['id'] .'
MIDlet-Vendor: Miledi
MIDlet-Version: 1.5.3
MIDletX-No-Command: true
MIDletX-LG-Contents: true
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-1.0
TCBR-Platform: Generic version (all phones)
MIDlet-Jar-Size: ' . $filesize. '
MIDlet-Jar-URL: ' . HOME . '/files/lib/jar/' . $articl['id'] . '.jar';
$files = fopen('../../files/lib/jad/' . $articl['id'] . '.jad', 'w+');
flock($files, LOCK_EX);
fputs($files, $jad_text);
flock($files, LOCK_UN);
fclose($files);
}
header("Location: ".HOME."/files/lib/jad/".$articl['id'].".jad");
} elseif (isset($_GET['txt'])) {
ob_clean();
ob_implicit_flush();
header('Content-Type: text/plain; charset=utf-8', true);
header('Content-Disposition: attachment; filename='.$articl['id'].'.txt');
$text = file_get_contents('../../files/lib/text/'.$articl['text']);
echo $text;
exit;
} else {
echo 'Ошибка';
}
echo CLOSE_DIV;
require_once('../../core/stop.php');
break;
}
require_once('../../core/stop.php');
?>