Вход Регистрация
Файл: www/android/admin/index.php
Строк: 667
<?php

define
('SECURED'true);

include 
'functions.php';

include 
'../ini.php';

include 
'../../config.php';

$admin=admin();

$mod_andr=mod_andr();

$admin_zs=adm_zg();



if(
$admin or $mod_andr or $admin_zs){



div('Админка');

$id=intval($_GET['id']);

function 
pinfo($path){

$path pathinfo($path);

return 
$path['extension'];}

$exps=array('jar','jad','sis','sisx','apk','zip','rar','txt'); //массив с разрешенными расширениями



$rid=intval($_GET['rid']);

$razd=mysql_fetch_array(mysql_query("select * from `files_razd_and` where `id` = '$rid';"));



switch(
$_GET['mode']){

default: 
//index

if(!empty($_GET['down'])){

$r_down=intval($_GET['down']);

list(
$ca)=mysql_fetch_array(mysql_query("select `position` from `categorys_and` where `id`='".$r_down."' and `razd` = '$rid';"));

if(
mysql_affected_rows()!=0){

list(
$lastp,$lastid)=mysql_fetch_array(mysql_query("select `position`,`id` from `categorys_and` where `position`>'$ca' and `razd` = '$rid' order by `position` limit 0,1;"));

if(
mysql_affected_rows()!=0){

mysql_query("update `categorys_and` set `position`='".$lastp."' where `id`='".$r_down."';");

mysql_query("update `categorys_and` set `position`='".$ca."' where `id`='".$lastid."';");

}

}

}



if(!empty(
$_GET['up']))

{

$r_up=intval($_GET['up']);

list(
$ca)=mysql_fetch_array(mysql_query("select `position` from `categorys_and` where `id`='".$r_up."';"));

if(
mysql_affected_rows()!=0)

{

list(
$lastp,$lastid)=mysql_fetch_array(mysql_query("select `position`,`id` from `categorys_and` where `position`<'$ca' order by `position` desc limit 0,1;"));

if(
mysql_affected_rows()!=0)

{

mysql_query("update `categorys_and` set `position`='".$lastp."' where `id`='".$r_up."';");

mysql_query("update `categorys_and` set `position`='".$ca."' where `id`='".$lastid."';");

}

}

}

echo 
"<b>Раздел: $razd[name]</b><br/>";

if(
$admin)

echo 
'<a href="index.php?mode=new_cat">Новая категория</a><br/>';

echo 
'<table border="1" cellspacing="1" cellpadding="5">';

echo
'<tr><td>ID</td>

<td>Категория</td>

<td>Файлов</td>

<td colspan="4" align="center">Действие</td></tr>'
;



$q=mysql_query("select * from `categorys_and` where `razd` = '$rid' order by `position`;");

while(
$category=mysql_fetch_array($q))

{

$total_files mysql_result(mysql_query("SELECT COUNT(*) FROM `games_and` WHERE `cat_id`='$category[id]';"),0);

echo 
'<tr><td>'.$category['id'].'</td>

<td><b><a href="index.php?id='
.$category['id'].'&amp;mode=view_cat">'.$category['name'].'</a></b></td>

<td>'
.$total_files.'</td>';

echo 
'<td><a href="index.php?up='.$category['id'].'"><img src="images/arrow_up.gif" alt="[UP]"/></a></td>

<td><a href="index.php?down='
.$category['id'].'"><img src="images/arrow_down.gif" alt="[DOWN]"/></a></td>

<td><a href="index.php?id='
.$category['id'].'&amp;mode=cat_edit"><img src="images/b_edit.png" alt="[EDIT]"/></a></td> ';

if(
$admin)

echo 
'   <td><a href="index.php?id='.$category['id'].'&amp;mode=cat_del"><img src="images/b_drop.png" alt="[DEL]" /></a></td></tr>';

}

echo 
'</table>';





break;

case 
'view_cat'//просмотр категории

echo '<a href="index.php?mode=upload&amp;id='.$id.'">Загрузить файл</a><br/>';

echo 
'<table border="1" cellspacing="1" cellpadding="5">';

echo
'<tr><td>ID</td>

<td>Игра</td>

<td>Скачано</td>

<td>Версий</td>

<td>Добавлено</td>

<td colspan="2" align="center">Действие</td></tr>'
;



$category=mysql_fetch_array(mysql_query("select * from `categorys_and` where `id`='$id';"));

$num_items=mysql_result(mysql_query("select count(id) from `games_and` where `cat_id`='".$category['id']."';"),0);

$q=mysql_query("select * from `games_and` where `cat_id`='".$category['id']."' order by `added` desc");

while(
$game=mysql_fetch_array($q))

{

echo 
'<tr><td>'.$game['id'].'</td>

<td><b>'
.$game['name'].'</b></td>

<td>'
.$game['downloads'].'</td>

<td><a href="index.php?id='
.$game['id'].'&amp;mode=view_files">'.mysql_result(mysql_query("SELECT COUNT(*) FROM `files_and` WHERE `game_id`='$game[id]';"),0).'</a></td>

<td>'
.date('d.m.y'$game['added']).'</td>';

echo 
'<td><a href="index.php?id='.$game['id'].'&amp;mode=game_edit"><img src="images/b_edit.png" alt="[EDIT]"/></a></td> ';

if(
$admin or $mod_fas or $admin_zs or $vid)

echo 
'<td><a href="index.php?id='.$game['id'].'&amp;mode=game_del"><img src="images/b_drop.png" alt="[DEL]" /></a></td></tr>';

}

echo 
'</table>';

break;

case 
'view_files'//просмотр версий файлов

if(!empty($_GET['down']))

{

$r_down=intval($_GET['down']);

list(
$ca)=mysql_fetch_array(mysql_query("select `position` from `files_and` where `id`='".$r_down."';"));

if(
mysql_affected_rows()!=0)

{

list(
$lastp,$lastid)=mysql_fetch_array(mysql_query("select `position`,`id` from `files_and` where `position`>'$ca' and `game_id`='$id' order by `position` limit 0,1;"));

if(
mysql_affected_rows()!=0)

{

mysql_query("update `files_and` set `position`='".$lastp."' where `id`='".$r_down."';");

mysql_query("update `files_and` set `position`='".$ca."' where `id`='".$lastid."';");

}

}

}



if(!empty(
$_GET['up']))

{

$r_up=intval($_GET['up']);

list(
$ca)=mysql_fetch_array(mysql_query("select `position` from `files_and` where `id`='".$r_up."';"));

if(
mysql_affected_rows()!=0)

{

list(
$lastp,$lastid)=mysql_fetch_array(mysql_query("select `position`,`id` from `files_and` where `position`<'$ca' and `game_id`='$id' order by `position` desc limit 0,1;"));

if(
mysql_affected_rows()!=0)

{

mysql_query("update `files_and` set `position`='".$lastp."' where `id`='".$r_up."';");

mysql_query("update `files_and` set `position`='".$ca."' where `id`='".$lastid."';");

}

}

}



echo 
'<b><u>Добавить файл:</u></b> <a href="index.php?mode=add_file_step1&amp;id='.$id.'&amp;method=upload">upload</a> / <a href="index.php?mode=add_file_step1&amp;id='.$id.'&amp;method=import">импорт</a> / <a href="index.php?mode=add_file_step1&amp;id='.$id.'&amp;method=adress">вписать адрес</a><br/>';

list(
$game)=mysql_fetch_array(mysql_query("select `name` from `games_and` where `id`='$id';"));

echo
"<b>$game</b><br/>";

echo 
'<table border="1" cellspacing="1" cellpadding="5">';

echo
'<tr><td>ID</td>

<td>Описание</td>

<td>Файл</td>

<td>Размер</td>

<td colspan="4" align="center">Действие</td></tr>'
;

$q=mysql_query("select * from `files_and` where `game_id`='$id' order by `position`;");

while(
$file=mysql_fetch_array($q))

{

echo 
'<tr><td>'.$file['id'].'</td>

<td><b>'
.$file['description'].'</b></td>

<td>'
.$file['jar_path'].'</td>

<td>'
.$file['size'].' Kb</td>';

echo 
'<td><a href="index.php?id='.$id.'&amp;mode=view_files&amp;up='.$file['id'].'"><img src="images/arrow_up.gif" alt="[UP]"/></a></td>

<td><a href="index.php?id='
.$id.'&amp;mode=view_files&amp;down='.$file['id'].'"><img src="images/arrow_down.gif" alt="[DOWN]"/></a></td>

<td><a href="index.php?id='
.$file['id'].'&amp;mode=file_edit"><img src="images/b_edit.png" alt="[EDIT]"/></a></td>

<td><a href="index.php?id='
.$file['id'].'&amp;mode=file_del"><img src="images/b_drop.png" alt="[DEL]" /></a></td></tr>';

}

echo 
'</table>';

break;

case 
'new_cat'//создание новой категории

if(!empty($_POST['name']))

{

list(
$lastp)=mysql_fetch_array(mysql_query("select `position` from `categorys_and` order by `position` desc limit 0,1;"));

$lastp++;

mysql_query("INSERT INTO `categorys_and` ( `id` , `name` , `position`, `razd`) VALUES (0, '".mysql_real_escape_string($_POST['name'])."', '$lastp', 0);");

echo 
'<b><u>Категория успешно создана!</u></b><br/>';

}

echo
'<form action="index.php?mode='.$_GET['mode'].'" method="post">

Название новой категории<br/>

<input type="text" name="name" value=""><br/>

<input type="submit" value="Go!"></form>'
;

break;

case 
'cat_edit':

if(!empty(
$_POST['name']))

{

mysql_query("UPDATE `categorys_and` SET `name`='".mysql_real_escape_string($_POST['name'])."' where `id`='$id';");

echo 
'<b><u>Категория успешно переименована!</u></b><br/>';

} else

{

list(
$on)=mysql_fetch_array(mysql_query("select `name` from `categorys_and` where `id`='$id';"));

echo
'<form action="index.php?mode='.$_GET['mode'].'&amp;id='.$id.'" method="post">

Название категории<br/>

<input type="text" name="name" value="'
.$on.'"><br/>

<input type="submit" value="Go!"></form>'
;

}

break;

//case 'cat_del': //удаление категории

//$category=mysql_fetch_array(mysql_query("select * from `categorys` where `id`='$id';"));

if(!isset($_GET['yes']))

{

echo
'Вы действительно хотите удалить эту категорию?<br/>';

echo
'<a href="index.php?id='.$id.'&amp;mode=cat_del&amp;yes">Да</a> | <a href="#" onclick="window.close();">Нет</a><br/>';

} else

{

$q=mysql_query("select * from `files_and` where `cat_id`='$id';");

while(
$file=mysql_fetch_array($q))

{

unlink('../'.$file['jar_path']);

unlink('../'.$file['jad_path']);

}

$q=mysql_query("select * from `games_and` where `cat_id`='$id';");

while(
$game=mysql_fetch_array($q))

{

unlink('../'.$game['screenshot']);

mysql_query("delete from `comments` where `game_id`='$game[id]';");

}

mysql_query("delete from `categorys_and` where `id`='$id';");

mysql_query("delete from `games_and` where `cat_id`='$id';");

mysql_query("delete from `files_and` where `cat_id`='$id';");

echo
'Категория успешно удалена!<br/>

<a href="#" onclick="opener.location.href='
index.php'; window.close();">Закрыть</a>';

}

exit;

break;

case 
'upload'//загрузка игры - часть 1

echo '<b>Загрузить файл</b><hr/>';

echo 
"<form action="" . $_SERVER['PHP_SELF'] . "?mode=process&amp;id=" . $id . "" method="post" enctype="multipart/form-data">n";

echo 
"Название:<br/>n";

echo 
"<input name="name"/><br/>n";

echo 
"Производитель:<br/>n";

echo 
"<input name="vendor"/><br/>n";

// echo "Форум:<br/>http://wap-club.info/forum/4/2/";

//  echo "<input name="forum"/>/<br/>n";

echo "Описание:<br/>n";

echo 
"<textarea name="descr" rows="15" cols="50"></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'//загрузка игры - часть 2

echo '<b>Загружаем игру</b><hr/>';

// подгружаем скриншот

$md5 md5 time () . microtime () );

if ( empty ( 
$_FILES['screenfile']['error'] ) )

{

$fname $_FILES['screenfile']['name'];

$et  explode '.'$fname );

$rex strtolower $et[count($et) - 1] ); # Расширение файла

$scr_name "$md5.$rex";



move_uploaded_file $_FILES['screenfile']['tmp_name'], '../tmp/tmp.' $rex );

markImage '../tmp/tmp.' $rex'../tmp/' $scr_name);

unlink '../tmp/tmp.' $rex );

echo 
"Скриншот:<br/><img src="../tmp/$scr_name" alt="-"/><br/>n";

}

if ( !empty( 
$_POST['screenurl'] ) )

{

$et  explode '.'$_POST['screenurl'] );

$rex strtolower $et[count($et) - 1] ); # Расширение файла

copy $_POST['screenurl'], '../tmp/tmp.' $rex );

markImage '../tmp/tmp.' $rex'../tmp/' $scr_name);

@
unlink '../tmp/tmp.' $rex );

echo 
"Скриншот:<br/><img src="../tmp/$scr_name" alt="-"/><br/>n";

}

else

echo 
"Скриншот не загружен..";



if ( 
$_POST['method'] == 'import' )

{

echo 
"<form method="post" action="" . $_SERVER['PHP_SELF'] . "?mode=uf&amp;id=" . $id . "">n";

for ( 
$i 1$i <= $_POST['num']; $i++ )

{

echo 
"<b>Файл " $i ":</b><br/>n";

echo 
"Пояснение:<textarea name="descr" . $i . ""></textarea><br/>n";

echo 
"Адрес:<input name="url" . $i . ""/><br/>n";

}

}

elseif ( 
$_POST['method'] == 'upload' )

{

echo 
"<form method="post" action="" . $_SERVER['PHP_SELF'] . "?mode=uf&amp;id=" . $id . "" enctype="multipart/form-data">n";

for ( 
$i 1$i <= $_POST['num']; $i++ )

{

echo 
"<b>Файл " $i ":</b><br/>n";

echo 
"Пояснение:<textarea name="descr" . $i . ""></textarea><br/>n";

echo 
"Файл:<input name="file" . $i . "" type="file"/><br/>n";

}

}

else

{

echo 
"<form method="post" action="" . $_SERVER['PHP_SELF'] . "?mode=uf&amp;id=" . $id . "">n";

for ( 
$i 1$i <= $_POST['num']; $i++ )

{

echo 
"<b>Файл " $i ":</b><br/>n";

echo 
"Пояснение:<textarea name="descr" . $i . ""></textarea><br/>n";

echo 
"Адрес (относительно скрипта!):<input name="url" . $i . ""/><br/>n";

echo 
"Размер (кб):<input name="size" . $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="forum" value="" . $_POST['forum'] . ""/>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="vendor" value="" . $_POST['vendor'] . ""/>n";

echo 
"<input type="hidden" name="screen" value="tmp/$scr_name"/>n";

echo 
"<input type="submit" value="Завершить!"/>";

echo 
"</form>n";



break;



case 
'uf'//загрузка игры - часть 3

$id  = ( int ) $_POST['id'];



$cat=mysql_fetch_array(mysql_query("select * from `categorys_and` where `id` = '$id';"));

//mysql_query("INSERT INTO `forum_theme` SET `id_topic`='', `name`='".mysql_real_escape_string($_POST['name'])."', `close`='0', `time_cr`='$time', `time_ed`='$time', `id_user`='$aut[id]'");

//$them['id']=mysql_insert_id();

//mysql_query("UPDATE `forum_topic` SET `time`='$time' WHERE `id_topic`=''");

//$descr=mysql_real_escape_string($_POST['descr']);

//$descr="[img]/games/[/img][br]".mysql_real_escape_string($_POST['descr']);

//$descr.='[br][url=/games/'.$id.']Подробнее...[/url]';

//mysql_query("INSERT INTO `forum_msg` SET `id_theme`='$them[id]', `time`='$time', `msg`='$descr', `id_topic`='', `id_user`='$aut[id]'");

$cat=mysql_fetch_array(mysql_query("select * from `categorys_and` where `id` = '$id';"));

mysql_query ("INSERT INTO `games_and` ( `id` , `cat_id` , `name` , `description`  , `forum` , `vendor` , `added`, `us_from`, `razd`)

VALUES (0, '
$id', '".mysql_real_escape_string($_POST['name'])."', '".mysql_real_escape_string($_POST['descr'])."', '', '".mysql_real_escape_string($_POST['vendor'])."', '".$time."', '".$aut['id']."', '".$cat['razd']."');");

$fid mysql_insert_id ();

$op=fopen($cat['razd'].".txt""a");

$sl="[url=/android/".$fid."]".mysql_real_escape_string($_POST['name'])."[/url], ";

fputs($op$sl);

fclose($op);

$method $_POST['method'];

$num = ( int ) $_POST['num'];

$array = array ();

if ( 
$method == 'upload' )

{

for ( 
$i 1$i <= $num$i++ )

{

$url  'file' $i;

//if(!in_array(pinfo($_FILES[$url]['name']),$exps)) exit('Формат файла запрещен!!!');



move_uploaded_file $_FILES[$url]['tmp_name'], '../files/' $fid '_' $i '.'.pinfo($_FILES[$url]['name']));

$descr  'descr'.$i;

$descr  $_POST[$descr];

$array[] = array ( 'descr' => $descr'url' => 'files/' $fid '_' $i .'.'pinfo($_FILES[$url]['name']) );

}

}

elseif ( 
$method == 'import' )

{

for ( 
$i 1$i <= $num$i++ )

{

$url  $_POST['url' $i];

//if(!in_array($url,$exps)) exit('Формат файла запрещен!!!');

copy $url'../files/' $fid '_' $i '.'.pinfo($url) );

$descr  $_POST['descr'.$i];

$array[] = array ( 'descr' => $descr'url' => 'files/' $fid '_' $i .'.'pinfo($url) );

}

}

else

{

for ( 
$i 1$i <= $num$i++ )

{

$url  mysql_real_escape_string($_POST['url' $i]);

$size1  intval($_POST['size' $i]);

$descr  mysql_real_escape_string($_POST['descr'.$i]);

$array[] = array ( 'descr' => $descr'url' => $url'size' => $size1 );

}

}

//$arr = serialize ( $array );

$s_ext=pathinfo($_POST['screen'],PATHINFO_EXTENSION);

@
copy '../'.$_POST['screen'], '../screen/'.$fid.'.'.$s_ext );

mysql_query "UPDATE `games_and` SET `screenshot`='screen/$fid.$s_ext' WHERE `id`='$fid';");



for(
$i=0;$i<count($array);$i++)

{

$pos=$i+1;

$size round(filesize('../'.$array[$i]['url'])/1024);

if ( 
$method == 'write' )  $size=$array[$i]['size'];

$jad make_jad('../'.$array[$i]['url'],'../files/',$config['jad'].$array[$i]['url']);

$jad str_replace('../'''$jad);

$jad str_replace('//''/'$jad);

mysql_query ("INSERT INTO `files_and` ( `id` , `game_id` , `cat_id` , `description` , `jar_path` , `jad_path` , `size` , `position`, `time` )

VALUES (0, '
$fid', '$id', '".$array[$i]['descr']."', '".$array[$i]['url']."', '$jad', '$size', '$pos', '$time');");

}



echo 
"Файл успешно выгружен<br/>";

echo 
"<a href='/android/$fid'>К файлу</a>";

break;

case 
'game_del'//удаление игры

$game=mysql_fetch_array(mysql_query("select * from `games_and` where `id`='$id';"));

if(!isset(
$_GET['yes']))

{

echo
'Вы действительно хотите удалить игру <b>'.$game['name'].'</b>?<br/>';

echo
'<a href="index.php?id='.$id.'&amp;mode=game_del&amp;yes">Да</a> | <a href="#" onclick="window.close();">Нет</a><br/>';

} else

{

$q=mysql_query("select * from `files_and` where `game_id`='$id';");

while(
$file=mysql_fetch_array($q))

{

unlink('../'.$file['jar_path']);

unlink('../'.$file['jad_path']);

}

unlink('../'.$game['screenshot']);

mysql_query("delete from `games_and` where `id`='$id';");

mysql_query("delete from `comments` where `game_id`='$id';");

mysql_query("delete from `files_and` where `game_id`='$id';");

echo
'Игра успешно удалена!<br/>

<a href="#" onclick="opener.location.href='
index.php?mode=view_cat&amp;id='.$game['cat_id'].''; window.close();">Закрыть</a>';

}

exit;

break;

case 
'game_edit'//редактирование игры

echo '<b>Редактирование игры</b><hr/>';

list(
$scr_path)=mysql_fetch_array(mysql_query("select `screenshot` from `games_and` where `id`='$id';"));

if ( isset ( 
$_GET['delsrc'] ) )

{

@
unlink('../'.$scr_path);

}



if ( isset ( 
$_GET['newsrc'] ) AND empty ( $_FILES['file']['error'] ) )

{

$fname $_FILES['file']['name'];

$et  explode '.'$fname );

$rex strtolower $et[count($et) - 1] ); # Расширение файла



@unlink ('../'.$scr_path);



move_uploaded_file $_FILES['file']['tmp_name'], '../tmp/tmp.' $rex );

markImage '../tmp/tmp.' $rex"../tmp/ggg.$rex);

copy ("../tmp/ggg.$rex"'../screen/' $id '.'.$rex );

@
unlink '../tmp/tmp.' $rex );

@
unlink "../tmp/ggg.$rex);

mysql_query "UPDATE `games_and` SET `screenshot`='screen/".$id.".".$rex."' WHERE `id`='$id';");

$scr_path='screen/'.$id.'.'.$rex;

}



if ( isset ( 
$_GET['modify'] ) )

{

mysql_query "UPDATE `games_and` SET `name`='" mysql_real_escape_string($_POST['name']) . "', `forum`='" mysql_real_escape_string($_POST['forum']) . "', `description`='" mysql_real_escape_string($_POST['descr']) . "', `vendor`='" mysql_real_escape_string($_POST['vendor']) . "' WHERE `id`='" $id "'" );

}



$info mysql_fetch_assoc mysql_query "SELECT * FROM `games_and` WHERE `id`='" $id "' LIMIT 1" ) );

if ( 
file_exists '../'.$scr_path ) )

echo 
"<p align="center"><img src="../$scr_path" alt="" . stripslashes ( $info['name'] ) . ""/><br/><a href="" . $_SERVER['PHP_SELF'] . "?mode=game_edit&amp;id=" . $id . "&amp;delsrc">[Удалить скриншот]</a></p>n";



echo 
"<form action="" . $_SERVER['PHP_SELF'] . "?mode=game_edit&amp;id=" . $id . "&amp;newsrc" method="post" enctype="multipart/form-data">n";

echo 
"<input type="file" name="file"/><br/>n";

echo 
"<input type="file" name="file"/><br/>n";

echo 
"<input type="submit" value="Загрузить новый скриншот"/></form><hr/>n";



echo 
"<form action="" . $_SERVER['PHP_SELF'] . "?mode=game_edit&amp;id=" . $id . "&amp;modify" method="post">n";

echo 
"Имя:<br/><input name="name" value="" . $info['name'] . ""/><br/>n";

echo 
"Форум:<br/><input name="forum" value="" . $info['forum'] . ""/><br/>n";

echo 
"Производитель:<br/><input name="vendor" value="" . $info['vendor'] . ""/><br/>n";

echo 
"Описание<br/><textarea name="descr" rows="15" cols="50">" stripslashes $info['description'] ) . "</textarea><br/>n";

echo 
"<input type="submit" value="Обновить"/>n";

echo 
"</form>n";

echo 
"<a href="" . $_SERVER['PHP_SELF'] . "?mode=view_cat&amp;id=" . $info['cat_id'] . "">Назад в категорию</a><br/>";

break;

case 
'add_file_step1'//загрузка файла - часть 1

echo '<b>Загружаем игру</b><hr/>';



if ( 
$_GET['method'] == 'import' )

{

echo 
"<form method="post" action="" . $_SERVER['PHP_SELF'] . "?mode=add_file_step2&amp;id=" . $id . "">n";

echo 
"<b>Файл:</b><br/>n";

echo 
"Пояснение:<textarea name="descr"></textarea><br/>n";

echo 
"Адрес:<input name="url"/><br/>n";

}

elseif ( 
$_GET['method'] == 'upload' )

{

echo 
"<form method="post" action="" . $_SERVER['PHP_SELF'] . "?mode=add_file_step2&amp;id=" . $id . "" enctype="multipart/form-data">n";

echo 
"<b>Файл:</b><br/>n";

echo 
"Пояснение:<textarea name="descr"></textarea><br/>n";

echo 
"Файл:<input name="file" type="file"/><br/>n";

}

else

{

echo 
"<form method="post" action="" . $_SERVER['PHP_SELF'] . "?mode=add_file_step2&amp;id=" . $id . "">n";

echo 
"<b>Файл:</b><br/>n";

echo 
"Пояснение:<textarea name="descr"></textarea><br/>n";

echo 
"Адрес (относительно скрипта!):<input name="url"/><br/>n";

echo 
"Размер (кб):<input name="size"/><br/>n";

}

echo 
"<input type="hidden" name="method" value="" . $_GET['method'] . ""/>n";

echo 
"<input type="submit" value="Загрузить"/>";

echo 
"</form>n";

break;



case 
'add_file_step2'//загрузка файла - часть 2



$id  = ( int ) $_GET['id'];

$fid $id;

list(
$lp)=mysql_fetch_array(mysql_query("select `position` from `files_and` where `game_id`='$fid' order by `position` desc limit 1;"));

$method $_POST['method'];

$i   =  $lp;

$i++;

$array = array();



if ( 
$method == 'upload' )

{

// if(!in_array(pinfo($_FILES[$url]['name']),$exps)) exit('Формат файла запрещен!!!');

move_uploaded_file $_FILES['file']['tmp_name'], '../files/' $fid '_' $i '.'.pinfo($_FILES['file']['name']) );

$descr  mysql_real_escape_string($_POST['descr']);

$array[] = array ( 'descr' => $descr'url' => 'files/' $fid '_' $i '.'.pinfo($_FILES['file']['name']) );

}

elseif ( 
$method == 'import' )

{

$url $_POST['url'];

//if(!in_array($url,$exps)) exit('Формат файла запрещен!!!');



copy $url'../files/' $fid '_' $i '.'.pinfo($url) );

$descr  mysql_real_escape_string($_POST['descr']);

$array[] = array ( 'descr' => $descr'url' => 'files/' $fid '_' $i '.'.pinfo($url) );

}

else

{

$url  mysql_real_escape_string($_POST['url']);

$descr  mysql_real_escape_string($_POST['descr']);

$size1intval($_POST['size']);

$array[] = array ( 'descr' => $descr'url' => $url'size' => $size1);

}



mysql_query "UPDATE `games_and` SET `two_added`='".$time."' WHERE `id`='$fid';");



list(
$cat_id)=mysql_fetch_array(mysql_query("select `cat_id` from `games_and` where `id`='$fid';"));

$pos=$lp+1;

$size round(filesize('../'.$array[0]['url'])/1024);

if ( 
$method == 'write' )$size=$array[0]['size'];

$jad make_jad('../'.$array[0]['url'],'../files/',$config['jad'].$array[0]['url']);

$jad str_replace('../'''$jad);

$jad str_replace('//''/'$jad);

mysql_query ("INSERT INTO `files_and` ( `id` , `game_id` , `cat_id` , `description` , `jar_path` , `jad_path` , `size` , `position`, `time` )

VALUES (0, '
$fid', '$cat_id', '".$array[0]['descr']."', '".$array[0]['url']."', '$jad', '$size', '$pos', '$time');");



echo 
"Файл успешно выгружен<br/>";

echo 
"<a href="../game.php?ID=".$fid."">Просмотр</a><br/>n";

echo 
"<a href="index.php?mode=view_files&amp;id=" . $fid . "">К файлу в админке</a>n";

break;

case 
'file_edit':

list(
$on,$gid)=mysql_fetch_array(mysql_query("select `description`,`game_id` from `files_and` where `id`='$id';"));

if(!empty(
$_POST['name']))

{

mysql_query("UPDATE `files_and` SET `description`='".mysql_real_escape_string($_POST['name'])."' where `id`='$id';");

mysql_query("UPDATE `files_and` SET `forum`='".mysql_real_escape_string($_POST['forum'])."' where `id`='$id';");

echo 
'<b><u>Файл успешно изменен!</u></b><br/>';

echo 
'<a href="index.php?mode=view_files&amp;id='.$gid.'">Назад</a><br/>';

} else

{

echo
'<form action="index.php?mode='.$_GET['mode'].'&amp;id='.$id.'" method="post">

Описание файла<br/>

<textarea type="text" name="name" value="'
.$on.'"></textarea><br/>

<input type="submit" value="Go!"></form>'
;

}

break;

case 
'file_del':

$file=mysql_fetch_array(mysql_query("select * from `files_and` where `id`='$id';"));

if(!isset(
$_GET['yes']))

{

echo
'Вы действительно хотите удалить файл <b>'.$file['description'].'</b>?<br/>';

echo
'<a href="index.php?id='.$id.'&amp;mode='.$_GET['mode'].'&amp;yes">Да</a> | <a href="#" onclick="window.close();">Нет</a><br/>';

} else

{

unlink('../'.$file['jar_path']);

unlink('../'.$file['jad_path']);

mysql_query("delete from `files_and` where `id`='$id';");

echo
'Игра успешно удалена!<br/>

<a href="#" onclick="opener.location.href='
index.php?mode=view_files&amp;id='.$file['game_id'].''; window.close();">Закрыть</a>';

}

exit;

break;

case
'gb':

if(isset(
$_GET['del']))

{

mysql_query("delete from `guestbook` where `id`='".intval($_GET['del'])."';");

}

if(!empty(
$_POST['msg2answer']) && !empty($_POST['msg2answer_id']))

{

//echo 1;

//echo"$_POST[msg2answer] $_POST[msg2answer_id]";

mysql_query("UPDATE `guestbook` SET `answer`='".mysql_real_escape_string($_POST['msg2answer'])."' where `id`='".intval($_POST['msg2answer_id'])."';");

}



$base_url=$_SERVER['PHP_SELF']."?mode=gb&amp;".SID;

$num_items=mysql_result(mysql_query("select count(id) from `guestbook`;"),0);



echo
'<form action="'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'" method="post">';

$q=mysql_query("select * from `guestbook` order by `posted` desc");

while(
$msg=mysql_fetch_array($q))

{

echo 
'<input type="checkbox" name="msg2answer_id" value="'.$msg['id'].'"/> ';

echo 
'<b>'.(!empty($msg['name']) ? $msg['name'] : 'Гость').'</b> ('.date('H:i d.m',$msg['posted']).')<br/>';

echo 
output($msg['text']).'<br/>';

echo 
'['.$msg['ip'].' | '.$msg['soft'].']<br/>';

if(!empty(
$msg['answer'])) echo '<font color="red">Ответ:</font>'.$msg['answer'].'<br/>';

echo 
'[<a href="index.php?mode=gb&amp;del='.$msg['id'].'">удалить</a>]<br/>';

//|<a href="index.php?mode=gb&amp;edit='.$msg['id'].'">редактировать</a>

echo '<dt></dt>';

}

echo 
'<textarea name="msg2answer" rows="4" cols="15"></textarea><br/>

<input type="submit" name="submit" value="Ответить"/></form>'
;

echo 
'*Отметьте галочкой сообщение, на которое хотите ответить.<br/>';

break;

case
'news':

if(isset(
$_GET['del']))

{

mysql_query("delete from `news` where `id`='".intval($_GET['del'])."';");

}

if(isset(
$_GET['add']))

{

if(!empty(
$_POST['header']) && !empty($_POST['text']))

{

mysql_query("INSERT INTO `news` ( `id` , `header` , `text` , `posted` ) VALUES (0, '".mysql_real_escape_string($_POST['header'])."', '".mysql_real_escape_string($_POST['text'])."', '".time()."');");

}

else

{

echo 
'<form action="'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'" method="post">';

echo 
'Заголовок:<br/><input type="text" name="header"><br/>';

echo 
'Текст:<br/><textarea name="text" rows="4" cols="15"></textarea><br/>';

echo 
'<input type="submit" name="submit" value="Добавить"/></form>';

exit;

}

}

if(!empty(
$_GET['edit']))

{

if(!empty(
$_POST['header']) && !empty($_POST['text']))

{

mysql_query("UPDATE `news` SET `header` = '".mysql_real_escape_string($_POST['header'])."',`text` = '".mysql_real_escape_string($_POST['text'])."' WHERE `id` ='".intval($_GET['edit'])."';");

}

else

{

$news=mysql_fetch_array(mysql_query("select * from `news` where `id`='".intval($_GET['edit'])."';"));

echo 
'<form action="'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'" method="post">';

echo 
'Заголовок:<br/><input type="text" name="header" value="'.$news['header'].'"><br/>';

echo 
'Текст:<br/><textarea name="text" rows="4" cols="15">'.$news['text'].'</textarea><br/>';

echo 
'<input type="submit" name="submit" value="Обновить"/></form>';

exit;

}

}



echo 
'<a href="index.php?mode=news&amp;add">Добавить новость</a><hr/>';



$num_items=mysql_result(mysql_query("select count(id) from `news`;"),0);

$q=mysql_query("select * from `news` order by `posted` desc");

while(
$post=mysql_fetch_array($q))

{

echo 
'<b>'.$post['header'].'</b> ('.date('d.m.Y H:i',$post['posted']).')<br/>';

echo 
output($post['text']).'<br/>';

echo 
'[<a href="index.php?mode=news&amp;del='.$post['id'].'">удалить</a> | <a href="index.php?mode=news&amp;edit='.$post['id'].'">редактировать</a>]<br/>';

echo 
'<dt></dt>';

}

break;

case 
'reklama':

if(!empty(
$_POST['rekla_top']))

{

$text strip_tags($_POST['rekla_top'], '<a><b>');

$file fopen("../links_top.txt","a+");

ftruncate($file,0);

fputs($file$text);

fflush($file);

flock($file,LOCK_UN);

fclose($file);

chmod ("../links_top.txt"0777);

}

if(!empty(
$_POST['rekla_bottom']))

{

$text strip_tags($_POST['rekla_bottom'], '<a><b>');

$file fopen("../links_bottom.txt","a+");

ftruncate($file,0);

fputs($file$text);

fflush($file);

flock($file,LOCK_UN);

fclose($file);

chmod ("../links_bottom.txt"0777);

}















break;

}

}else{

div('Ошибка');

echo 
'Пизда рулю';}



echo 
'</div>';

include 
'../../foot.php';

echo 
'</div>';

?>
Онлайн: 3
Реклама