View file catalogdeep/test/admin.php

File size: 23.4Kb
<?php

/**
* JAVA download-центр
* (c) USED for МАКСИМКО)))
*/

session_name ( 'sid' );
session_start ();

require_once ( dirname ( __FILE__ ) . "/functions.php" );
require_once ( dirname ( __FILE__ ) . "/config.php" );

$start_time	=	microtime ();

$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` ";
$pg		=	isset ( $_GET['pg'] ) ? ( int ) $_GET['pg'] : 0;
$mod	=	isset ( $_GET['mod'] ) ? $_GET['mod'] : 'sections';


header ( "Content-type: text/html; charset=utf-8" );
echo myHeader ( "Админ-панель" );

if ( isset ( $_POST['pass'] ) )
{
if ( $_POST['pass'] == $admin_pass )
$_SESSION['admin'] = 1;
}
if ( !isset ( $_SESSION['admin'] ) )
{
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">\n";

echo "<div class=\"rut\">\n";
echo "Пароль:<br/><input type=\"password\" name=\"pass\"/><br/>\n";
echo "<input type=\"submit\" value=\"Войти\"/>\n";
echo "</div></form>";
echo "<div class=\"rut2\"><a href=\"/\">На главную</a></div>\n";
echo myFooter ();

$open	=	opendir ( 'tmp' );
while ( $file	=	readdir ( $open ) )
{
if ( is_file ( 'tmp/' . $file ) )
@unlink ( 'tmp/' . $file );
}
closedir ( $open );

exit ();
}

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'" );

switch ( $mod )

{

default:

echo "<div class=\"title\">Админка</div>\n";
echo "<div class=\"menu\">\n";
echo "&#xbb; <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=sections\">Управление разделами</a><br/>\n";
echo "</div>";

break;

case 'sections':
echo "<div class=\"rut\">Управление разделами</div>\n";
echo "<div class=\"rut2\">\n";
// Создание раздела
if ( isset ( $_POST['new'] ) )
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `java_sections` WHERE `name`='".mysql_real_escape_string($_POST['new'])."' LIMIT 1 " ), 0 ) == 0 )
{
mysql_query ( "INSERT INTO `java_sections` ( `name` ) VALUES ( '" . mysql_real_escape_string ( $_POST['new'] ) . "')" ) ? print "Раздел успешно создан!" : print ( "Ошибка создания раздела ( " . mysql_error () . ")" );
echo "<br/><br/>\n";
}
}
$query	=	mysql_query ( "SELECT * FROM `java_sections` ORDER BY name" );
while ($row = mysql_fetch_array($query))
{
echo "&#xbb; <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=list&amp;id=" . $row['id'] . "\">" . stripslashes ( $row['name'] ) . "</a>&nbsp;<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=delsect&amp;id=" . $row['id'] . "\">[X]</a>|<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=sectattr&amp;id=" . $row['id'] . "\">[E]</a><br/>\n";
}
echo "</div>";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?mod=sections&amp;\" method=\"post\">\n";
echo "<div class=\"rut\"><b>Создать новый раздел</b></div><div class=\"rut2\"><br/>\n";
echo "Название:<br/>\n";
echo "<input name=\"new\"/><br/>\n";
echo "<input type=\"submit\" value=\"Создать\"/><form></div>";

break;
###############################################################################
case 'editer':
$id		=	intval ( $_GET['id'] );

$key	=	intval ( $_GET['key'] );
$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'];}
require_once('pclzip.lib.php');
$zip=new PclZip($url);
$content = $zip->extract(PCLZIP_OPT_BY_NAME, "META-INF/MANIFEST.MF" ,PCLZIP_OPT_EXTRACT_AS_STRING);
$time=time();
$vendor=preg_replace("~^.+MIDlet.Vendor:([^\n]+)\s.+$~is","$1",$content[0]['content']);
if (ereg("MIDlet-Icon: ",$content[0]['content']))
{
$jad=explode("MIDlet-Icon: ",$content[0]['content']);
$icon=str_replace("\n"," ", $jad[1]);
$icon=str_replace("\r"," ", $icon);
$icon=strtok($icon,' ');
$icon=ereg_replace("^/","", $icon);
}
else $icon='icon.png';
$content = $zip->extract(PCLZIP_OPT_BY_NAME, "$icon",PCLZIP_OPT_EXTRACT_AS_STRING);
if (!isset($content[0]['content']) || $content[0]['content']=='')exit;
$j=fopen("ico/$time.png", 'w');
fwrite($j, $content[0]['content']);
fclose($j);
@chmod("ico/$time.png", 0777);
mysql_query('UPDATE `java_files` SET `ico`="'.$time.'" WHERE `id`="'.$id.'";');
mysql_query('UPDATE `java_files` SET `vendor`="'.$vendor.'" WHERE `id`="'.$id.'";');
echo 'vendor: '.$vendor;
echo'<br/>ICON: <img src="ico/'.$time.'.png" alt="ico"/><br/>';
break;
##############################################################################
case 'sectattr':

$id	=	isset ( $_GET['id'] ) ? ( int ) $_GET['id'] : NULL;
echo "<div class=\"rut\">Свойства раздела</div>\n";
echo "<div class=\"rut2\">\n";

if ( isset ( $_POST['name'] ) )
{
mysql_query ( "UPDATE `java_sections` SET `name`='" . mysql_real_escape_string ( $_POST['name'] ) . "' WHERE `id`='" . $id . "'" ) ? print "Свойства раздела изменены" : print ( "Ошибка изменения свойств ( " . mysql_error () . ")" );
}
else
{
$info	=	mysql_result ( mysql_query ( "SELECT `name` FROM `java_sections` WHERE `id`='" . $id . "' LIMIT 1" ), 'name' );
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?mod=sectattr&amp;id=" . $id . "\" method=\"post\">\n";
echo "Имя раздела:<br/><input name=\"name\" value=\"" . stripslashes ( $info ) . "\"/><br/>\n";
echo "<input type=\"submit\" value=\"Изменить\"/></form>\n";
echo "</div>";
}
break;

case 'list':

$id = isset ( $_GET['id'] ) ? ( int ) $_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 "<div class=\"rut\">" . stripslashes ( $title ) . "</div>\n";
echo "<div class=\"rut2\">\n";
$query = mysql_query("SELECT * FROM `java_files` WHERE `indir`='".$id."' ORDER BY date DESC LIMIT ".$pg.", ".$onpage);
while ( $row	=	mysql_fetch_array ( $query ) )
{
echo "&#xbb; <a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&amp;id=" . $row['id'] . "&rz=" . $id . "\">" . stripslashes ( $row['name'] ) . "</a><br/>\n";
}
echo "</div>\n";
echo "<div class=\"rut\"><a href=\"" . $_SERVER['PHP_SELF'] . "?mod=addfile&amp;id=" . $id . "\">Добавить файл</a></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=list&amp;id=" . $id . "&amp;pg=" . ( $pg - $onpage ) . "\">&#xab; Назад</a><br/>\n";
if ( $total > $pg + $onpage )
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=list&amp;id=" . $id . "&amp;pg=" . ( $pg + $onpage ) . "\">Вперед &#xbb;</a>\n";

break;

case 'addfile':

$id		=	isset ( $_GET['id'] ) ? ( int ) $_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 "<div class=\"rut\">Добавить файл в \"" . stripslashes ( $title ) . "\"</div>\n";
echo "<div class=\"rut2\">\n";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?mod=process&amp;id=" . $id . "\" method=\"post\" enctype=\"multipart/form-data\">\n";
echo "Имя файла:<br/>\n";
echo "<input name=\"name\"/><br/>\n";
echo "Описание:<br/>\n";
echo "<textarea name=\"descr\" rows=\"8\" cols=\"26\"></textarea><br/>\n";
echo "Адрес скриншота:<br/>\n";
echo "<input name=\"screenurl\"/><br/>\n";
echo "..или выгрузить скрин:<br/>\n";
echo "<input type=\"file\" name=\"screenfile\"/><br/>\n";
echo "Выгружать <input name=\"num\" style=\"-wap-input-format:'5N'\" size=\"2\" value=\"1\"/> файлов<br/>";
echo "способом <input type=\"radio\" name=\"method\" value=\"import\" checked=\"checked\"/>импорт | <input type=\"radio\" name=\"method\" value=\"upload\"/>upload | <input type=\"radio\" name=\"method\" value=\"write\"/>вписать адрес<br/>\n";
echo "<input type=\"submit\" value=\"Вперед\"/></form>\n";
echo "</div>\n";

break;

case 'process':

echo "<div class=\"rut\">Загружаем файлы</div>\n";
echo "<div class=\"rut2\">\n";
// подгружаем скриншот
$md5	=	md5 ( time () . microtime () );
if ( empty ( $_FILES['screenfile']['error'] ) )
{
$fname	=	$_FILES['screenfile']['name'];
$et		=	explode ( '.', $fname );
$rex	=	strtolower ( $et[count($et) - 1] ); # Расширение файла

move_uploaded_file ( $_FILES['screenfile']['tmp_name'], 'tmp/tmp.' . $rex );
markImage ( 'tmp/tmp.' . $rex, 'tmp/' . $md5 . '.png' );
unlink ( 'tmp/tmp.' . $rex );
echo "Скриншот:<br/><img src=\"tmp/" . $md5 . ".png\" alt=\"-\"/><br/>\n";
}
elseif ( isset ( $_POST['screenurl'] ) )
{
$et		=	explode ( '.', $_POST['screenurl'] );
$rex	=	strtolower ( $et[count($et) - 1] ); # Расширение файла
copy ( $_POST['screenurl'], 'tmp/tmp.' . $rex );
markImage ( 'tmp/tmp.' . $rex, 'tmp/' . $md5 . '.png' );
unlink ( 'tmp/tmp.' . $rex );
echo "Скриншот:<br/><img src=\"tmp/" . $md5 . "..png\" alt=\"-\"/><br/>\n";
}
else
echo "Скриншот не загружен..";


echo "<div class=\"rut\">Загружаем файлы</div>\n";
echo "<div class=\"rut2\">\n";
if ( $_POST['method'] ==	'import' )
{
echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?mod=uf&amp;id=" . $_GET['id'] . "\">\n";
for ( $i = 1; $i <= $_POST['num']; $i++ )
{
echo "<b>Файл " . $i . ":</b><br/>\n";
echo "Пояснение:<input name=\"descr" . $i . "\"/><br/>\n";
echo "Адрес:<input name=\"url" . $i . "\"/><br/>\n";
}
}
elseif ( $_POST['method'] == 'upload' )
{
echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?mod=uf&amp;id=" . $_GET['id'] . "\" enctype=\"multipart/form-data\">\n";
for ( $i = 1; $i <= $_POST['num']; $i++ )
{
echo "<b>Файл " . $i . ":</b><br/>\n";
echo "Пояснение:<input name=\"descr" . $i . "\"/><br/>\n";
echo "Файл:<input name=\"file" . $i . "\" type=\"file\"/><br/>\n";
}
}
else
{
echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?mod=uf&amp;id=" . $_GET['id'] . "\">\n";
for ( $i = 1; $i <= $_POST['num']; $i++ )
{
echo "<b>Файл " . $i . ":</b><br/>\n";
echo "Пояснение:<input name=\"descr" . $i . "\"/><br/>\n";
echo "Адрес (относительно скрипта!):<input name=\"url" . $i . "\"/><br/>\n";
}
}
echo "<input type=\"hidden\" name=\"name\" value=\"" . $_POST['name'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"descr\" value=\"" . $_POST['descr'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"method\" value=\"" . $_POST['method'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"id\" value=\"" . $_GET['id'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"num\" value=\"" . $_POST['num'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"screen\" value=\"" . 'tmp/' . $md5 . ".png\"/>\n";
echo "<input type=\"submit\" value=\"Завершить!\"/>";
echo "</form>\n";

break;

case 'uf':

$id		=	( int ) $_POST['id'];
mysql_query ( "INSERT INTO `java_files` ( `name`, `indir`, `descr`, `date` ) VALUES ( '" . mysql_real_escape_string ( $_POST['name'] ) . "', '" . $id . "', '" . mysql_real_escape_string ( $_POST['descr'] ) . "', '" . time () . "')" );
$fid	=	mysql_insert_id ();
$method	=	$_POST['method'];
$num	=	( int ) $_POST['num'];
$array	=	array ();
if ( $method == 'upload' )
{
for ( $i = 1; $i <= $num; $i++ )
{
$url		=	'file' . $i;
//$url		=	$$url;
//exit($url);
move_uploaded_file ( $_FILES[$url]['tmp_name'], 'files/' . $fid . '_' . $i . '.jar' );
$descr		=	'descr'.$i;
$descr		=	$_POST[$descr];
$array[]	=	array ( 'descr'	=>	$descr, 'url'	=> 'files/' . $fid . '_' . $i . '.jar' );
}
}
elseif ( $method == 'import' )
{
for ( $i = 1; $i <= $num; $i++ )
{
$url		=	$_POST['url' . $i];//echo $url;
//$url		=	$$url;
copy ( $url, 'files/' . $fid . '_' . $i . '.jar' );
$descr		=	$_POST['descr'.$i];
//$descr		=	$_POST[$descr];
$array[]	=	array ( 'descr'	=>	$descr, 'url'	=> 'files/' . $fid . '_' . $i . '.jar' );
}
}
else
{
for ( $i = 1; $i <= $num; $i++ )
{
$url		=	$_POST['url' . $i];//echo $url;
//$url		=	$$url;
//copy ( $url, 'files/' . $fid . '_' . $i . '.jar' );
$descr		=	$_POST['descr'.$i];
//$descr		=	$_POST[$descr];
$array[]	=	array ( 'descr'	=>	$descr, 'url2'	=> $url );
}
}
$arr	=	serialize ( $array );
copy ( $_POST['screen'], 'screen/' . $fid . '.png' );
mysql_query ( "UPDATE `java_files` SET `urls`='" . $arr . "' WHERE `id`='" . $fid . "'" );

echo "<div class=\"rut\">Загружаем файлы</div>\n";
echo "<div class=\"rut2\">\n";

echo "Файл успешно выгружен<br/>";
echo "<a href=\"admin.php?id=".$fid."&amp;mod=file&rz=".$id."\">К файлу</a></div>\n";
break;

#######COSMEXE_DORABOTKA##########
case 'xaddfile':
$rz		=	isset ( $_GET['rz'] ) ? ( int ) $_GET['rz'] : NULL;
$id		=	isset ( $_GET['id'] ) ? ( int ) $_GET['id'] : NULL;
$title	=	mysql_result ( mysql_query ( "SELECT `name` FROM `java_sections` WHERE `id`='" . $rz. "' LIMIT 1" ), 'name' );
header ( "Content-type: text/html; charset=utf-8" );
echo "<div class=\"rut\">Добавить файл в \"".stripslashes($title)."\"</div>\n";
echo "<div class=\"rut2\">\n";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?mod=xprocess&amp;rz=" . $rz . "&id=" . $id . "\" method=\"post\" enctype=\"multipart/form-data\">\n";
echo "Выгружать <input name=\"num\" style=\"-wap-input-format:'5N'\" size=\"2\" value=\"1\"/> файлов<br/>";
echo "способом <input type=\"radio\" name=\"method\" value=\"import\" checked=\"checked\"/>импорт | <input type=\"radio\" name=\"method\" value=\"upload\"/>upload | <input type=\"radio\" name=\"method\" value=\"write\"/>вписать адрес<br/>\n";
echo "<input type=\"submit\" value=\"Вперед\"/></form>\n";
echo "</div>\n";

break;

case 'xprocess':
$id		=	isset ( $_GET['id'] ) ? ( int ) $_GET['id'] : NULL;

echo "<div class=\"rut\">Загружаем файлы</div>\n";
echo "<div class=\"rut2\">\n";

if ( $_POST['method'] ==	'import' )
{
echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?mod=xuf&amp;rz=" . $_GET['rz'] . "\">\n";
for ( $i = 1; $i <= $_POST['num']; $i++ )
{
echo "<b>Файл " . $i . ":</b><br/>\n";
echo "Пояснение:<input name=\"descr" . $i . "\"/><br/>\n";
echo "Адрес:<input name=\"url" . $i . "\"/><br/>\n";
}
}
elseif ( $_POST['method'] == 'upload' )
{
echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?mod=xuf&amp;rz=" . $_GET['rz'] . "\" enctype=\"multipart/form-data\">\n";
for ( $i = 1; $i <= $_POST['num']; $i++ )
{
echo "<b>Файл " . $i . ":</b><br/>\n";
echo "Пояснение:<input name=\"descr" . $i . "\"/><br/>\n";
echo "Файл:<input name=\"file" . $i . "\" type=\"file\"/><br/>\n";
}
}
else
{
echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?mod=xuf&amp;rz=" . $_GET['rz'] . "\">\n";
for ( $i = 1; $i <= $_POST['num']; $i++ )
{
echo "<b>Файл " . $i . ":</b><br/>\n";
echo "Пояснение:<input name=\"descr" . $i . "\"/><br/>\n";
echo "Адрес (относительно скрипта!):<input name=\"url" . $i . "\"/><br/>\n";
}
}
echo "<input type=\"hidden\" name=\"id\" value=\"" . $id . "\"/>\n";
echo "<input type=\"hidden\" name=\"name\" value=\"" . $_POST['name'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"descr\" value=\"" . $_POST['descr'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"method\" value=\"" . $_POST['method'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"rz\" value=\"" . $_GET['rz'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"num\" value=\"" . $_POST['num'] . "\"/>\n";
echo "<input type=\"hidden\" name=\"screen\" value=\"" . 'tmp/' . $md5 . ".png\"/>\n";
echo "<input type=\"submit\" value=\"Завершить!\"/>";
echo "</form>\n";

break;

case 'xuf':

$fid		=	( int ) $_POST['id'];
$method	=	$_POST['method'];
$num	=	( int ) $_POST['num'];
$array	=	array ();
if ( $method == 'upload' )
{
for ( $i = 1; $i <= $num; $i++ )
{
$url		=	'file' . $i;
//$url		=	$$url;
//exit($url);
move_uploaded_file ( $_FILES[$url]['tmp_name'], 'files/' . $fid . '_' . $i . '.jar' );
$descr		=	'descr'.$i;
$descr		=	$_POST[$descr];
$array[]	=	array ( 'descr'	=>	$descr, 'url'	=> 'files/' . $fid . '_' . $i . '.jar' );
}
}
elseif ( $method == 'import' )
{
for ( $i = 1; $i <= $num; $i++ )
{
$url		=	$_POST['url' . $i];//echo $url;
//$url		=	$$url;
copy ( $url, 'files/' . $fid . '_' . $i . '.jar' );
$descr		=	$_POST['descr'.$i];
//$descr		=	$_POST[$descr];
$array[]	=	array ( 'descr'	=>	$descr, 'url'	=> 'files/' . $fid . '_' . $i . '.jar' );
}
}
else
{
for ( $i = 1; $i <= $num; $i++ )
{
$url		=	$_POST['url' . $i];//echo $url;
//$url		=	$$url;
//copy ( $url, 'files/' . $fid . '_' . $i . '.jar' );
$descr		=	$_POST['descr'.$i];
//$descr		=	$_POST[$descr];
$array[]	=	array ( 'descr'	=>	$descr, 'url2'	=> $url );
}
}
$arr	=	serialize ( $array );
copy ( $_POST['screen'], 'screen/' . $fid . '.png' );
mysql_query ( "UPDATE `java_files` SET `urls`='" . $arr . "' WHERE `id`='" . $fid . "'" );

echo "<div class=\rut\">Загружаем файлы</div>\n";
echo "<div class=\"rut2\">\n";

echo "Файл успешно выгружен<br/>";
echo "<a href=\"index.php?id=" . $fid . "&amp;mod=file\">К файлу</a></div>\n";

break;

###################END_COSMEXE_DORABOTKA#################

case 'delsect':

if ( !isset ( $_GET['agree'] ) )
{
echo "<div class=\"rut\">Подтверждение удаления</div>\n";
echo "<div class=\"rut2\">\n";
echo "<span style=\"color:red\"><b>Вы подтверждаете удаление папки, а так же всех вложенных в нее файлов, комментариев и т.д.?</b></span><br/>\n";
echo "<div class=\"rut\"><a href=\"" . $_SERVER['PHP_SELF'] . "?mod=delsect&amp;id=" . $_GET['id'] . "&amp;agree\">Да</a>&nbsp;<a href=\"" . $_SERVER['PHP_SELF'] . "\">Нет</a></div></div>\n";
}
else
{
$id		=	intval ( $_GET['id'] );
// Все файлы из категории
$query	=	mysql_query ( "SELECT * FROM `java_files` WHERE `indir`='" . $id . "'" );
while ( $row	=	mysql_fetch_array ( $query ) )
{
$urls	=	unserialize ( $row['urls'] );
foreach ( $urls AS $url )
{
@unlink ( $url['url'] );
}
@unlink ( "screen/" . $row['id'] . ".png" );
mysql_unbuffered_query ( "DELETE FROM `java_comments` WHERE `fid`='" . $row['id'] . "'" );
mysql_unbuffered_query ( "DELETE FROM `java_files` WHERE `id`='" . $row['id'] . "'" );
}
mysql_unbuffered_query ( "DELETE FROM `java_sections` WHERE `id`='" . $id . "'" );
mysql_unbuffered_query ( "OPTIMIZE TABLE `java_sections`" );
mysql_unbuffered_query ( "OPTIMIZE TABLE `java_files`" );
mysql_unbuffered_query ( "OPTIMIZE TABLE `java_comments`" );
echo "<div class=\"all\"><div class=\"head\"><img src=\"http://imsota.ru/imsota.png\"></a></div>\n";
echo "<div class=\"rek\">Завершено</div>\n";
echo "<div class=\"menu3\">\n";
echo "Все папки, файлы, скриншоты, комментарии удалены</div>\n";
}
break;

case 'file':
$rz		=	isset ( $_GET['rz'] ) ? ( int ) $_GET['rz'] : NULL;
$id		=	isset ( $_GET['id'] ) ? ( int ) $_GET['id'] : NULL;

if ( isset ( $_GET['delsrc'] ) )
{
@unlink ( 'screen/' . $id . '.png' );
}

if ( isset ( $_GET['newsrc'] ) AND empty ( $_FILES['file']['error'] ) )
{
$fname	=	$_FILES['file']['name'];
$et		=	explode ( '.', $fname );
$rex	=	strtolower ( $et[count($et) - 1] ); # Расширение файла

@unlink ( 'screen/' . $id . '.png' );

move_uploaded_file ( $_FILES['file']['tmp_name'], 'tmp/tmp.' . $rex );
markImage ( 'tmp/tmp.' . $rex, 'tmp/ggg.png' );
copy ( 'tmp/ggg.png', 'screen/' . $id . '.png' );
@unlink ( 'tmp/tmp.' . $rex );
@unlink ( 'tmp/ggg.png' );echo 'ggggg';
}

if ( isset ( $_GET['modify'] ) )
{
mysql_query ( "UPDATE `java_files` SET `name`='" . mysql_real_escape_string ( $_POST['name'] ) . "', `descr`='" . mysql_real_escape_string ( $_POST['descr'] ) . "' WHERE `id`='" . $id . "'" ) or die ( mysql_error ());
}

if ( isset ( $_GET['delfile'] ) )
{
@unlink ( 'screen/' . $id . '.png' );
mysql_unbuffered_query ( "DELETE FROM `java_comments` WHERE `fid`='" . $id . "'" );
mysql_unbuffered_query ( "DELETE FROM `java_files` WHERE `id`='" . $id . "'" );

echo "<div class=\"menu\">\n";
echo "Файл удален...";
echo "\n</div>\n";

echo "<div class=\"fpic\"><a href=\"" . $_SERVER['PHP_SELF'] . "\">Админка</a><br/><a href=\"/\">На главную</a></div>\n";
echo myFooter ();
exit;
}
$info	=	mysql_fetch_assoc ( mysql_query ( "SELECT * FROM `java_files` WHERE `id`='" . $id . "' LIMIT 1" ) );
header ( "Content-type: text/html; charset=utf-8" );

echo "<div class=\"star\"></div>\n";
echo "<div class=\"title\">".stripslashes($info['name'])."</div>";
echo "<div class=\"menu\"><div class=\"rut\">\n";
if (file_exists('screen/'.$info['id'].".png"))
{
echo "<img src=\"screen/" . $info['id'] . ".png\" alt=\"" . stripslashes ( $info['name'] ) . "\"/><br/><a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&amp;id=" . $id . "&amp;delsrc\">[Удалить скриншот]</a></div>\n";
}

echo "<div class=\"rut2\">\n";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?mod=file&amp;id=" . $id . "&amp;newsrc\" method=\"post\" enctype=\"multipart/form-data\">\n";
echo "<input type=\"file\" name=\"file\"/><br/>\n";
echo "<input type=\"submit\" value=\"Загрузить новый скриншот\"/></form></div>\n";

echo "<div class=\"rut\">\n";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?mod=file&amp;id=" . $id . "&amp;modify\" method=\"post\">\n";
echo "Имя:<br/><input name=\"name\" value=\"" . $info['name'] . "\"/><br/>\n";

echo "Описание<br/><textarea name=\"descr\" rows=\"7\" cols=\"30\">" . stripslashes ( $info['descr'] ) . "</textarea><br/>\n";
echo "<input type=\"submit\" value=\"Обновить\"/>\n";
echo "</form>\n";
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=file&amp;id=" . $id . "&amp;delfile\">Удалить файл</a>\n";
echo "</div>\n";
echo "<div class=\"rut2\">Выберите файл для извлечения картинки и производителя:<br/>";
$urls	=	unserialize ( $info['urls'] );

foreach ( $urls AS $key=>$url )

{

//if (!isset($url['']))

if (isset($url['url']))

echo "> <a href=\"" . $_SERVER['PHP_SELF'] . "?id=" . $id . "&amp;mod=editer&amp;key=" . $key . "\">" . stripslashes ( $url['descr'] ) . "</a> (" . round ( filesize ( $url['url'] ) / 1024, 0 ) . "кб)<br/>\n";

else

echo "> <a href=\"" . $_SERVER['PHP_SELF'] . "?id=" . $id . "&amp;mod=editer&amp;key=" . $key . "\">" . stripslashes ( $url['descr'] ) . "</a> (" . round ( filesize ( $url['url2'] ) / 1024, 0 ) . "кб)<br/>\n";
}
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?mod=xaddfile&amp;id=" . $id . "&rz=" . $rz . "\">Добавить Новый экран</a></div>\n";


break;


}

echo "<div class=\"fpic\"><a href=\"" . $_SERVER['PHP_SELF'] . "\">Админка</a><br/><a href=\"/\">На главную</a></div>\n";
echo myFooter ();

?>