<?php
Error_Reporting(0);
/**
* JAVA download-центр
* (c) USED for МАКСИМКО)))
*/
$start_time = microtime ();
require_once ( dirname ( __FILE__ ) . '/config.php' );
mysql_connect ( $mysql_host, $mysql_user, $mysql_password ) &&
mysql_select_db ( $mysql_database ) OR
die ( '<html><body>Зайдите позже, серверу сейчас некогда</body></html>' );
mysql_unbuffered_query ('SET NAMES `utf8`');
if(isset($_GET['mod'])&&$_GET['mod']=='dwl'){
$key = intval ( $_GET['key'] );
if(isset($_GET['jad'])){
$jad=TRUE;
}else{
$jad=FALSE;
}
$id = intval(abs($_GET['id']));
$finfo = mysql_fetch_assoc(mysql_query("SELECT * FROM `java_files` WHERE `id`=" . $id . " LIMIT 1"));
$urls = unserialize ( $finfo['urls'] );
$need = $urls[$key];
if ( isset ( $need['url'] ) ){
$url = $need['url'];
}else{
$url = $need['url2'];}
mysql_unbuffered_query ( "UPDATE `java_files` SET `cnt`=`cnt`+1 WHERE `id`=" . $id );
if ($jad===FALSE) {
header ( "Location: " . $url, true, 301);
exit;
}else{
require_once('pclzip.lib.php');
header('Content-type: text/vnd.sun.j2me.app-descriptor');
header('Content-Disposition: filename='.str_replace('.jar','.jad',$url));
$zip=new PclZip($url);
$f=$zip->extract(PCLZIP_OPT_BY_NAME,'META-INF/MANIFEST.MF',PCLZIP_OPT_EXTRACT_AS_STRING);
print $f[0]['content'].'MIDlet-Jar-Size: '.filesize($url)."\n".'MIDlet-Jar-URL: http://'.$_SERVER['SERVER_NAME'].'/'.$url;
exit;
}}
mysql_unbuffered_query ( "DELETE FROM `java_online` WHERE `last`<" . ( time () - 3600 ) );
require_once ( dirname ( __FILE__ ) . '/functions.php' );
session_name ('sid');
session_start ();
if ( mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `java_online`
WHERE `sid`='" . session_id () . "'" ), 0 ) == 0 )
{
mysql_unbuffered_query ( "INSERT INTO `java_online` (`sid`,`ip`,`ua`,`last`)
VALUES ( '" . session_id () . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . mysql_real_escape_string ( strtok ( $_SERVER['HTTP_USER_AGENT'], '/' ) ) . "', '" . time () . "')" );
}
else
{
mysql_unbuffered_query ( "UPDATE `java_online` SET `last`='" . time () . "' WHERE `sid`='" . session_id () . "' LIMIT 1" );
}
$style = ( isset ( $_SESSION['style'] ) AND file_exists ( dirname ( __FILE__ ) . "/style/" . $_SESSION['style'] . ".css" ) ) ? $_SESSION['style'] : '1';
$onpage = isset ( $_SESSION['onpage'] ) ? ( int ) $_SESSION['onpage'] : 30;
$order = @$_SESSION['order'] == 1 ? " `date` " : " `id` ";
$id = isset($_GET['id']) ? (int)abs($_GET['id']) : NULL;
$pg = isset ( $_GET['pg'] ) ? ( int ) $_GET['pg'] : 0;
$mod = isset ( $_GET['mod'] ) ? $_GET['mod'] : NULL;
switch ( $mod )
{
default:
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( 'Загрузки' );
echo "<div class=\"star\">\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=new\">Новинки!</a> | <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=search\">Поиск Java</a><br/>\n";
echo "</div>\n";
echo '<div class="title">Категории:</div>
<div class="menu">';
$query = mysql_query ( "SELECT * FROM `java_sections` ORDER BY `name`" );
while ( $row = mysql_fetch_array ( $query ) )
{
if($num==1){
echo "<div class=\"rut\">";
$num=0;
}else{
echo "<div class=\"rut2\">";
$num=1;}
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=list&id=" . $row['id'] . "\">" . stripslashes ( $row['name'] ) . "</a> ";
echo '<font color="#a1a1a1">[';
echo mysql_num_rows(mysql_query("SELECT `id` FROM `java_files` WHERE `indir`=" . $row['id'] . ""));
$newfiles=mysql_num_rows(mysql_query("SELECT `id` FROM `java_files` WHERE `indir`=" . $row['id'] . " AND `date`>".(time()-$new_files_time*60*60*24)));
echo ']</font>';
if($newfiles>0){
echo' <font color="red">+'.$newfiles.'</font>';}
echo "</div>";
}
echo "</div>\n";
echo '<div class="pic">Навигация</div><div class="fpic">';
if ( isset ( $_SESSION['admin'] ) )
echo "<img src=\"style/images/cell.png\" alt=\"\" /> <a href=\"admin.php\">Админка</a><br/>\n";
echo "<img src=\"style/images/cell.png\" alt=\"\" /> <a href=\"/\">На главную</a><br/>";
echo "</div>\n";
echo myFooter ();
break;
case 'settings':
if ( count ( $_POST ) > 0 )
{
$_SESSION['onpage'] = ( int ) $_POST['onpage'];
$_SESSION['order'] = ( $_POST['order'] == 'on' ) ? 1 : 0;
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( 'Настройки' );
echo "<div class=\"star\">\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=top\">Топ игр</a><br/>\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=new\">Новинки!</a><br/>\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=search\">Поиск Java</a><br/>\n";
echo "</div>\n";
echo "<div class=\"title\">Настройки центра</div>\n";
echo "<div class=\"menu\">\n";
echo "Пунктов на страницу: " . ( int ) $_POST['onpage'] . "<br/>\n";
echo "Сортировка по дате ";
$_SESSION['order'] == 1 ? print "включена" : print "выключена";
echo "</div>\n";
echo "<div class=\"pic\">Навигация</div><div class=\"fpic\">";
if ( isset ( $_SESSION['admin'] ) )
echo "» <a href=\"admin.php\">Админка</a><br/>\n";
echo "» <a href=\"/\">На главную</a></div>\n";
echo myFooter ();
exit;
}
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( 'Настройки' );
echo "<div class=\"star\">\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=top\">Топ игр</a><br/>\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=new\">Новинки!</a><br/>\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=search\">Поиск Java</a><br/>\n";
echo "</div>\n";
echo "<div class=\"title\">Настройки центра</div>\n";
echo "<div class=\"menu\">\n";
echo "Измените настройки загруз центра как вам требуется:</div>\n";
echo "<div class=\"rut\">\n";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?mod=settings\" method=\"post\">\n";
echo "Количество пунктов на страницу:<br/>\n";
echo "<input name=\"onpage\" style=\"-wap-input-format:'5N'\" value=\"" . $onpage . "\"/>\n";
echo "<br/><br/>\n";
echo "<input type=\"checkbox\" name=\"order\"";
if ( $order == " `date` " )
echo " checked=\"checked\"";
echo "/> Сортировка файлов по дате\n";
echo "<br/><br/><input type=\"submit\" value=\"Применить\"/></form>\n";
echo "</div>\n";
echo "<div class=\"pic\">Навигация</div><div class=\"fpic\">";
if ( isset ( $_SESSION['admin'] ) )
echo "<a href=\"admin.php\">Админка</a><br/>\n";
echo "<a href=\"/\">На главную</a></div>\n";
echo myFooter ();
break;
########################
########################
case 'vendor':
$vendor=htmlspecialchars(urldecode($_GET['who']));
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( stripslashes ( $vendor ) );
echo "<div class=\"star\">\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=top\">Топ игр</a><br/>\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=new\">Новинки!</a><br/>\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=search\">Поиск Java</a><br/>\n";
echo "</div>\n";
echo"<div class=\"title\">Java игры</div>\n";
echo "<div class=\"menu\">\n";
$total = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `java_files` WHERE `vendor`='" . $vendor . "'" ), 0 );
if($total>0){
$query = mysql_query ( "SELECT * FROM `java_files` WHERE `vendor`='" . $vendor . "' ORDER BY `date` DESC LIMIT " . $pg . ", " . $onpage );
while ( $row = mysql_fetch_array ( $query ) )
{
if($row['ico']!=NULL&&file_exists('ico/'.$row['ico'].'.png')){
$ico="<img src=\"ico.php?ico=".$row['ico']."\" alt=\"\"/> ";
}else{
$ico="» ";
}
if($num==1)
{
echo "<div class=\"rut\">";
$num = 0;}
else
{
echo "<div class=\"rut2\">";
$num = 1;}
echo "".$ico."<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&id=" . $row['id'] . "\">" . stripslashes ( $row['name'] ) . "</a><br/>Скачек: ".$row['cnt']."<br/>Добавлено [".date("d.m.Y в H:i",$row['date'])."]<br/>Категория: <a href=\"index.php?mod=list&id=" . $row['indir'] . "\">" . mysql_result(mysql_query("SELECT `name` FROM `java_sections` WHERE `id`='".$row['indir']."'"),0) . "</a></div>\n";
}
}else{
echo'Такого производителя в базе нет!';}
echo "</div></div>\n";
echo '<div class="pic">Навигация</div><div class="fpic">';
if ( $pg >= $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=vendor&who=" . $vendor . "&pg=" . ( $pg - $onpage ) . "\">« Назад</a><br/>\n";
if ( $total > $pg + $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=vendor&who=" . $vendor . "&pg=" . ( $pg + $onpage ) . "\">Вперед »</a><br/>\n";
echo "» <a href=\"/java\">В разделы</a><br/>\n";
echo "» <a href=\"/\">На главную</a><br/></div>\n";
echo myFooter ();
break;
########################
########################
case 'list':
$id = isset($_GET['id']) ? (int)abs($_GET['id']) : NULL;
$title = mysql_result(mysql_query("SELECT `name` FROM `java_sections` WHERE `id`='".$id."' LIMIT 1"), 'name');
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( stripslashes ( $title ) );
echo "<div class=\"star\">\n";
echo "» Мобильные игры!</div>\n";
if(isset($id) && $id != NULL)
{
echo'<div class="title">';
echo stripslashes ( $title ) . "</div>\n";
echo "<div class=\"menu\">\n";
if ( $order == ' `date` ' )
$query = mysql_query ( "SELECT * FROM `java_files` WHERE `indir`='" . $id . "' ORDER BY `date` DESC LIMIT " . $pg . ", " . $onpage );
$query = mysql_query("SELECT * FROM `java_files` WHERE `indir`='".$id."' ORDER BY date DESC LIMIT ".$pg.", ".$onpage);
while ($row = mysql_fetch_array($query))
{
if($row['ico']!=NULL&&file_exists('ico/'.$row['ico'].'.png'))
{
$ico="<img src=\"ico.php?ico=".$row['ico']."\" alt=\".\"/> ";
}else{
$ico="» ";
}
if($num==1)
{echo "<div class=\"rut\">";
$num = 0;}
else
{echo "<div class=\"rut2\">";
$num = 1;}
echo $ico."<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&id=" . $row['id'] . "\">" . stripslashes ( $row['name'] ) . "</a> </div>\n";
}
$adcc = mysql_query("SELECT * FROM java_files WHERE indir = '$id'");
$vanva = mysql_fetch_array($adcc);
if ($vanva <= 0)
{ echo "<div class=\"rut\">В этой категории файлов пока нет =(</div>"; }
echo "</div>\n";
}else
{
echo "Ошибка! Не играйте со стракой браузера =)";
}
echo "<div class=\"pic\">Навигация</div><div class=\"fpic\">";
$total = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `java_files` WHERE `indir`='" . $id . "'" ), 0 );
if ( $pg >= $onpage )
echo "<a href=\"".$_SERVER['PHP_SELF']."?mod=list&id=".$id."&pg=".($pg - $onpage)."\">« Назад</a><br/>\n";
if ($total > $pg + $onpage)
echo "<a href=\"".$_SERVER['PHP_SELF']."?mod=list&id=".$id."&pg=".($pg + $onpage)."\">Вперед »</a><br/>\n";
echo "» <a href=\"/java\">В разделы</a><br/>\n";
echo "» <a href=\"/\">На главную</a></div>\n";
echo myFooter ();
break;
case 'file':
$id = isset($_GET['id']) ? (int)abs($_GET['id']) : NULL;
if (isset($_GET['vote']))
{
if ($_GET['vote'] == 'good')
mysql_unbuffered_query ("UPDATE `java_files` SET `good`=`good`+1 WHERE `id`='".$id."' LIMIT 1");
elseif ($_GET['vote'] == 'bad')
mysql_unbuffered_query ("UPDATE `java_files` SET `bad`=`bad`+1 WHERE `id`='".$id."' LIMIT 1");
}
$info = mysql_fetch_assoc(mysql_query("SELECT * FROM `java_files` WHERE `id`='".$id."' LIMIT 1"));
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( stripslashes ( $info['name'] ) );
echo "<div class=\"star\">» Мобильные игры!</div>";
if (isset($id) && $id != NULL)
{
echo "<div class=\"title\">" . stripslashes ( $info['name'] ) . "</div><div class=\"menu\"><div class=\"rut2\">\n";
if ( file_exists ( 'screen/' . $info['id'] . ".png" ) )
{
echo "<img src=\"screen/" . $info['id'] . ".png\" alt=\"" . stripslashes ( $info['name'] ) . "\" height=\"220\" width=\"176\" /><br/>\n";
}
$categ = mysql_result ( mysql_query ( "SELECT `iname`, `java_files`.`indir`
FROM `java_files`
LEFT JOIN (
SELECT `java_sections`.`id`, `java_sections`.`name` AS `iname`
FROM `java_sections`
) AS `tmp` ON `tmp`.`id`=`java_files`.`indir`
WHERE `java_files`.`id`='" . $id . "'
LIMIT 1"
), 'iname' );
echo stripslashes ( str_replace ( "\n", "<br/>", $info['descr'] ) );
echo "</div>\n";
echo "<div class=\"rut\"><a href=\"" . $_SERVER['PHP_SELF'] . "?mod=com&id=" . $id . "\">Обсудить</a>[" . mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `java_comments` WHERE `fid`='" . $id . "'" ), 0 ) . "]</div>\n";
echo "<div class=\"rut2\">Скачали: " . $info['cnt'];
echo "</div><div class=\"rut\">Оценка: <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&id=" . $id . "&vote=good\"><b>+</b></a> | <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&id=" . $id . "&vote=bad\"><b>-</b></a> (" . $info['good'] . "/" . $info['bad'] . ")</div></div>\n";
echo "<div class=\"title\">Скачать:</div>\n";
echo "<div class=\"menu\"><div class=\"rut\">\n";
$urls = unserialize($info['urls']); //exit(print_r($urls));
foreach ($urls AS $key=>$url)
{
if($daraf==1) {
echo "<div class=\"rut\">";
$daraf = 0;
}
else
{
echo "<div class=\"rut2\">";
$daraf = 1;
}
echo stripslashes($url['descr'])."<br/>\n";
if(isset($url['url']))
echo "» <a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&mod=dwl&key=".$key."\">JAR</a> | <a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&mod=dwl&key=".$key."&jad\">JAD</a> [".round(filesize($url['url']) / 1024, 0 ) . "Kb]\n";
else
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?id=" . $id . "&mod=dwl&key=" . $key . "\">JAR</a> | <a href=\"" . $_SERVER['PHP_SELF'] . "?id=" . $id . "&mod=dwl&key=" . $key . "&jad\">JAD</a> [" . round ( filesize ( $url['url2'] ) / 1024, 0 ) . "Kb]\n";
echo "</div>\n";
}
echo "</div></div>\n";
}
else
{
echo "Ошибка! Не играйте со стракой браузера =)";
}
echo "<div class=\"pic\">Навигация</div><div class=\"fpic\">";
echo "» <a href=\"/java\">В разделы</a><br/>\n";
echo "» <a href=\"/\">На главную</a></div>\n";
echo myFooter ();
break;
case 'com':
$id = intval(abs($_GET['id']));
if ( isset ( $_SESSION['admin'] ) AND isset ( $_GET['delid'] ) )
mysql_unbuffered_query ( "DELETE FROM `java_comments` WHERE `id`='" . intval ( $_GET['delid'] ) . "' LIMIT 1" );
if ( isset ( $_POST['nick'] ) AND isset ( $_POST['text'] ) AND $_SESSION['posted'] != 1 )
{
$name = mysql_real_escape_string ( htmlspecialchars ( strip_tags ( $_POST['nick'] ) ) );
if ( $name == $admin_nick AND !isset ( $_SESSION['admin'] ) )
$name = "Гость";
$text = mysql_real_escape_string ( htmlspecialchars ( strip_tags ( $_POST['text'] ) ) );
$ip = preg_match ( "|[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}|", $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : NULL;
$ua = mysql_real_escape_string ( strtok ( $_SERVER['HTTP_USER_AGENT'], "/" ) );
mysql_query ( "INSERT INTO `java_comments` ( `fid`, `name`, `date`, `text`, `ip`, `ua` ) VALUES ( '" . $id . "', '" . $name . "', '" . time () . "', '" . $text . "', '" . $ip . "', '" . $ua . "') " );
$_SESSION['posted'] = 1;
}
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( "Комментарии" );
echo "<div class=\"star\">» Обсуждение файла</div>\n";
echo "<div class=\"title\">Комментарии</div><div class=\"menu\">";
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=addcom&id=" . $id . "\">Добавить</a><br/>\n";
$query = mysql_query ( "SELECT * FROM `java_comments` WHERE `fid`='" . $id . "' ORDER BY `id` DESC LIMIT " . $pg . ", " . $onpage );
$i = 0;
while ( $row = mysql_fetch_array ( $query ) )
{
if ($i == 0)
{
echo "<div class=\"rut\">\n";
$i = 1;
}
else
{
echo "<div class=\"rut2\">\n";
$i = 0;
}
echo stripslashes($row['name'])." [".date("d.m H:i",$row['date'])."]";
if (isset($_SESSION['admin']))
{
}
if ( isset ( $_SESSION['admin'] ) )
echo "\n<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=com&id=" . $id . "&delid=" . $row['id'] . "\">[X]</a>\n";
echo "<br/>\n".stripslashes($row['text'])."<br/>\n";
if ( isset ( $_SESSION['admin'] ) )
{
if ( !empty ( $row['ip'] ) )
echo "[" . $row['ip'] . "]<br/>\n";
echo stripslashes ( $row['ua'] ) . "\n";
}
echo "</div>\n";
}
echo "</div><div class=\"pic\">Навигация</div><div class=\"fpic\">";
$total = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `java_comments` WHERE `fid`='" . $id . "'" ), 0 );
if ( $pg >= $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=com&id=" . $id . "&pg=" . ( $pg - $onpage ) . "\">« Назад</a><br/>\n";
if ( $total > $pg + $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=com&id=" . $id . "&pg=" . ( $pg + $onpage ) . "\">Вперед »</a>\n";
if ( isset ( $_SESSION['admin'] ) )
echo "<a href=\"admin.php\">Админка</a><br/>\n";
echo "» <a href=\"/java\">В разделы</a><br/>\n";
echo "» <a href=\"/\">На главную</a><br/></div>\n";
echo myFooter ();
break;
case 'addcom':
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( "Добавить" );
$_SESSION['posted'] = 0;
echo "<div class=\"star\">» Добавление комментария</div>\n";
echo "<div class=\"title\">Добавить</div><div class=\"menu\">";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?mod=com&id=" . $_GET['id'] . "\" method=\"post\">\n";
echo "Ваш ник:<br/><input name=\"nick\" size=\"20\" /><br/>\n";
echo "Комментарий:<br/><textarea name=\"text\" rows=\"7\" cols=\"30\"></textarea><br/>\n";
echo "<input type=\"submit\" value=\"Сказать\"/></form></div>\n";
echo "<div class=\"pic\">Навигация</div><div class=\"fpic\">";
if ( isset ( $_SESSION['admin'] ) )
echo "» <a href=\"admin.php\">Админка</a><br/>\n";
echo "» <a href=\"/java\">В разделы</a><br/>\n";
echo "» <a href=\"/\">На главную</a></div>\n";
echo myFooter ();
break;
case 'new':
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( 'Новые файлы' );
echo "<div class=\"star\">» Последние закаченные!</div>\n";
echo "<div class=\"title\">Новые файлы</div><div class=\"menu\">";
$query = mysql_query ( "SELECT * FROM `java_files` ORDER BY `date` DESC LIMIT " . $pg . ", " . $onpage );
while ( $row = mysql_fetch_array ( $query ) )
{
if($row['ico']!=NULL&&file_exists('ico/'.$row['ico'].'.png')){
$ico="<img src=\"ico.php?ico=".$row['ico']."\" alt=\".\"/> ";
}else{
$ico="» ";
}
if($num==1)
{echo "<div class=\"rut\">";
$num = 0;}
else
{echo "<div class=\"rut2\">";
$num = 1;}
echo $ico."<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&id=" . $row['id'] . "\">" . stripslashes ( $row['name'] ) . "</a> <font color=\"#a1a1a1\">[".date("d.m.Y",$row['date'])."]</font><br/>\n";
echo "Описание: ".mb_substr($row['descr'],0,100,"UTF-8")."...<br/>";
echo"Категория: <a href=\"index.php?mod=list&id=" . $row['indir'] . "\">" . mysql_result(mysql_query("SELECT `name` FROM `java_sections` WHERE `id`='".$row['indir']."'"),0) . "</a>\n";
echo "</div>\n";
}
echo "</div>\n";
echo "<div class=\"pic\">Навигация</div><div class=\"fpic\">";
$total = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `java_files` WHERE `indir`='" . $id . "'" ), 0 );
if ( $pg >= $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=new&pg=" . ( $pg - $onpage ) . "\">« Назад</a><br/>\n";
if ( $total > $pg + $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=new&pg=" . ( $pg + $onpage ) . "\">Вперед »</a>\n";
if ( isset ( $_SESSION['admin'] ) )
echo "» <a href=\"admin.php\">Админка</a><br/>\n";
echo "» <a href=\"/java\">В разделы</a><br/>\n";
echo "» <a href=\"/\">На главную</a></div>\n";
echo myFooter ();
break;
case 'top':
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( 'Топ файлов' );
echo "<div class=\"star\">» Топ файлов</div>\n";
echo "<div class=\"title\">Популярные</div><div class=\"menu\">\n";
$query = mysql_query ( "SELECT * FROM `java_files` ORDER BY `cnt` DESC LIMIT " . $pg . ", " . $onpage );
while ( $row = mysql_fetch_array ( $query ) )
{
if($row['ico']!=NULL&&file_exists('ico/'.$row['ico'].'.png')){
$ico="<img src=\"ico.php?ico=".$row['ico']."\" alt=\"\"/>";
}else{
$ico="<img src=\"style/images/loads.gif\" alt=\"\"/>";
}
if($num==1)
{echo "<div class=\"rut\">";
$num = 0;}
else
{echo "<div class=\"rut2\">";
$num = 1;}
echo $ico."<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&id=" . $row['id'] . "\">" . stripslashes ( $row['name'] ) . "</a><br/>\n";
echo "Описание: ".$row['descr']."<br/>";
echo "Категория: <a href=\"index.php?mod=list&id=" . $row['indir'] . "\">" . mysql_result(mysql_query("SELECT `name` FROM `java_sections` WHERE `id`='".$row['indir']."'"),0) . "</a>\n";
/*
echo "Добавлено: " . date ( "d.m.Y в H:i",$row['date']) . "<br/>\n";
*/
echo "</div>\n";
}
$total = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `java_files` WHERE `indir`='" . $id . "'" ), 0 );
if ( $pg >= $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=top&pg=" . ( $pg - $onpage ) . "\">« Назад</a><br/>\n";
if ( $total > $pg + $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=top&pg=" . ( $pg + $onpage ) . "\">Вперед »</a>\n";
echo "</div>\n";
echo "<div class=\"pic\">Навигация</div><div class=\"fpic\">\n";
if ( isset ( $_SESSION['admin'] ) )
echo "<a href=\"admin.php\">Админка</a><br/>\n";
echo "<a href=\"/\">На главную</a><br/></div>\n";
echo myFooter ();
break;
case 'search':
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( 'Поиск' );
echo "<div class=\"star\">» Поиск игры</div>\n";
echo "<div class=\"title\">Поиск игр</div><div class=\"menu\">";
$q = isset ( $_GET['q'] ) ? urldecode ( $_GET['q'] ) : NULL;
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?mod=search\" method=\"get\">\n";
echo "<input name=\"q\" value=\"" . $q . "\"/><br/>\n";
echo "<input type=\"hidden\" name=\"mod\" value=\"search\"/>";
echo "<input type=\"submit\" value=\"Искать\"/>\n";
echo "</form>\n";
echo "</div>\n";
if ( !empty ( $q ) )
{
$sq = iconv ( 'WINDOWS-1251', 'UTF-8', strtolower ( iconv ( 'UTF-8', 'WINDOWS-1251', $q ) ) );
$query = mysql_query ( "SELECT * FROM `java_files` WHERE LOWER(`name`) LIKE '%" . $sq . "%' ORDER BY `cnt` DESC LIMIT " . $pg . ", " . $onpage );
$total = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `java_files` WHERE LOWER(`name`) LIKE '%" . $sq . "%'" ), 0 );
echo "<div class=\"menu\">\n";
echo "Найдено " . $total . "\n</div>\n";
while ( $row = mysql_fetch_array ( $query ) )
{
if($row['ico']!=NULL&&file_exists('ico/'.$row['ico'].'.png')){
$ico="<img src=\"ico.php?ico=".$row['ico']."\" alt=\"\"/>";
}else{
$ico="<img src=\"style/images/loads.gif\" alt=\"\"/>";
}
if($num==1)
{echo "<div class=\"rut\">";
$num = 0;}
else
{echo "<div class=\"rut2\">";
$num = 1;}
echo $ico." <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&id=" . $row['id'] . "\">" . stripslashes ( $row['name'] ) . "</a><br/>\n";
echo $row['descr'];
echo "</div>\n";
}
echo "</div>\n";
if ( $pg >= $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=search&pg=" . ( $pg - $onpage ) . "&q=" . urlencode ( $q ) . "\">« Назад</a><br/>\n";
if ( $total > $pg + $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=search&pg=" . ( $pg + $onpage ) . "&q=" . urlencode ( $q ) . "\">Вперед »</a>\n";
}
echo "<div class=\"pic\">Навигация</div><div class=\"fpic\">";
if ( isset ( $_SESSION['admin'] ) )
echo "» <a href=\"admin.php\">Админка</a><br/>\n";
echo "» <a href=\"/java\">В разделы</a><br/>\n";
echo "» <a href=\"/\">На главную</a></div>\n";
echo myFooter ();
break;
case 'online':
header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( 'Онлайн' );
echo "<div class=\"star\">\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=top\">Топ игр</a><br/>\n";
echo "» <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=new\">Новинки!</a><br/>\n";
echo "</div>\n";
echo "<div class=\"title\">Посетители OnLine</div>\n";
echo "<div class=\"menu\">\n";
$query = mysql_query ( "SELECT * FROM `java_online` LIMIT " . $pg . ", " . $onpage );
while ( $row = mysql_fetch_array ( $query ) )
{
if($num==1)
{echo "<div class=\"rut\">";
$num = 0;}
else
{echo "<div class=\"rut2\">";
$num = 1;}
echo "Активность " . date ( "d.m H:i", $row['last'] ) . "<br/>\n";
if ( !empty ( $row ['ip'] ) )
echo "IP: " . $row['ip'] . "<br/>\n";
echo "Браузер: " . stripslashes ( $row['ua'] );
echo "\n</div>\n";
}
$total = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `java_online`" ), 0 );
if ( $pg >= $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=online&pg=" . ( $pg - $onpage ) . "\">« Назад</a><br/>\n";
if ( $total > $pg + $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=online&pg=" . ( $pg + $onpage ) . "\">Вперед »</a>\n";
echo "</div>\n";
echo "<div class=\"pic\">Навигация</div><div class=\"fpic\">\n";
if ( isset ( $_SESSION['admin'] ) )
echo "<a href=\"admin.php\">Админка</a><br/>\n";
echo "<a href=\"/\">На главную</a></div>\n";
echo myFooter ();
break;
}
mysql_close ();
?>