Файл: read.php
Строк: 59
<?php
// mod Gemorroj
require 'moduls/config.php';
require 'moduls/header.php';
if (!$setup['lib_change']) {
error('Not found');
}
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
if ($page < 1) {
$page = 1;
}
$banner='';
$Reklames = new Reklames(); // Создаем экземпляр класса Reklames
echo $Reklames->Top();
$banner.= $Reklames->Bottom();
$banner.=$Reklames->Banner();
// Получаем инфу о файле
$v = mysql_fetch_assoc(mysql_query('SELECT * FROM `files` WHERE `id` = ' . $id, $mysql));
$pathinfo = pathinfo($v['path']);
if (!is_file($v['path']) || strtolower($pathinfo['extension']) != 'txt') {
error('File not found',$banner);
}
$back = mysql_fetch_assoc(mysql_query("SELECT `id` FROM `files` WHERE `path` = '" . mysql_real_escape_string($pathinfo['dirname'] . '/', $mysql) . "'", $mysql));
$filename = $v['name'];
if ($_SESSION['langpack'] == 'russian') {
$filename = $v['rus_name'];
}
$title .= $_SESSION['language']['read'] . ' - ' . $filename . ' / ' . $page;
if (isset($_SESSION['lib'])) {
$setup['lib'] = $_SESSION['lib'];
}
echo '<div class="mainzag">'.$filename.'</div>'.$out;
// UTF-8
$fp = fopen($v['path'], 'rb');
if ($page > 1) {
fseek($fp, $page * $setup['lib'] - $setup['lib']);
}
$content = fread($fp, $setup['lib']) . fgets($fp, 1024);
fclose($fp);
if ($page > 1) {
$i = 0;
foreach (str_split($content, 1) as $f) {
if ($f == ' ' || $f == "n" || $f == "r" || $f == "t") {
break;
}
$i++;
}
$content = substr($content, $i);
}
$pages = floor(filesize($v['path']) / $setup['lib']);
if ($setup['lib_str']) {
echo '<pre class="row">' . wordwrap(htmlspecialchars(str_to_utf8($content), ENT_NOQUOTES), $setup['lib_str'], "n", false) . '</pre>' . go($page, $pages, DIRECTORY . 'read/' . $id);
} else {
echo '<pre class="row">' . htmlspecialchars(str_to_utf8($content), ENT_NOQUOTES) . '</pre>' . go($page, $pages, DIRECTORY . 'read/' . $id);
}
if ($back['id']) {
$str = '<a href="' . DIRECTORY . $back['id'] . '">' . $_SESSION['language']['go to the category'] . '</a> |';
} else {
$str = '';
}
echo '<div class="foot"><a href="' . DIRECTORY . 'view/' . $id . '">' . $_SESSION['language']['go to the description of the file'] . '</a> | ' . $str . ' <a href="' . DIRECTORY . '">' . $_SESSION['language']['downloads'] . '</a></div>'.$banner;
require 'moduls/foot.php';
?>