Файл: usscripts/index.php
Строк: 123
<?
require '../config.php';
$title='Скрипты пользователей';
include '../style/head.php';
who_add(0,'us');
aut();
/*$k_user=mysql_result(mysql_query("select COUNT(*) from `scripts_files` WHERE user_id = '".$user['id']."';"),0);
if ($k_user!=$user['scripts_files'])mysql_query('UPDATE `users` SET `scripts_files` = "'.$k_user.'" WHERE `id` = "'.$user['id'].'"');*/
$fid = check(intval($_GET['fid']));
$fid2 = check(intval($_GET['fid2']));
if (empty($_GET['fid'])&&empty($_GET['fid2'])){
echo '<img src="/usscripts/ext/search.png" alt="*"/> <a href="search">Поиск файлов</a><br />
<img src="/usscripts/ext/top.gif" alt="*"/> ТОП '.$set['top_num'].' <a href="top">файлов</a><br />';/*| <a href="users">пользователей</a>*/
/*$new_all_files = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `scripts_files` WHERE `timeupload` > '.(time()-(86400*$set['scripts_day_new'])).''));
if($new_all_files[0]!=0) echo '<img src="/usscripts/ext/new.gif" alt="*"/> <a href="new">Новинки (+'.$new_all_files[0].')</a><br />';*/
echo '<img src="/img/load.png" alt=""/> <a href="/usscripts/upload"><b>Добавить скрипт</b></a><br />';
//echo '<dl><dt></dt></dl>Новые <a href="new_t">Темы</a> | <a href="new_p">Сообщения</a><br />Мои <a href="my_t">Темы</a> | <a href="my_p">Сообщения</a> | <a href="bookmarks_0">Закладки</a> ';
echo '<dl><dt></dt></dl>';
echo '<br />';
$p==1;
$q = @mysql_query("select * from `scripts_cat` order by pos" );
while ($cat = @mysql_fetch_array($q))
{
$f = $cat['id'];
$f_name = $cat['name'];
$allinfolder = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `scripts_files` WHERE `infolder` LIKE "'.$cat['path'].'%";'));
$stime=$time-(3600*24*$set['scripts_day_new']);
if($set['scripts_day_new']!=0) $new_all = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `scripts_files` WHERE `timeupload` > "'.$stime.'" AND `infolder` LIKE "'.$cat['path'].'%";'));
if($new_all[0] and $set['scripts_day_new']!=0) $new_all = '<font color="red">+'.$new_all[0].'</font>'; else $new_all="";
$p++;
if(is_integer($p / 2)) echo $div1; else echo $div2;
if ($user['level']>=8) {
echo '<a href="admin_editcat_'.$f.'"><img src="/usscripts/ext/p.png" alt="*"/></a> <b><a href="'.$f.'">'.$f_name.'</a></b> ('.$allinfolder[0].''.$new_all.')';
} else{
echo '<img src="/usscripts/ext/p.png" alt="*"/> <b><a href="'.$f.'">'.$f_name.'</a></b> ('.$allinfolder[0].''.$new_all.')';
}
echo $div9;
}
if ($user['level']>=8) {echo '<br /><br /><dl><dt></dt></dl>';echo '<a href="admin_addcat"><b>Создать</b></a><br/>';
echo '<dl><dt></dt></dl>';
}
}else if (isset($_GET['fid'])){
$cat = @mysql_fetch_array(mysql_query("select * from `scripts_cat` where id = '".$fid."'" ));
echo $div3.'<a href="/usscripts">Скрипты</a>|'.$cat['name'].''.$div9;
if(!is_dir($cat['path'])){
mysql_query("DELETE FROM `scripts_cat` where id = '".$fid."'");header ('Location: /usscripts/?'.SID); exit;
}
if(!empty($_SESSION["onpage"]) AND !empty($_GET['onpage'])){
$_SESSION["onpage"]=$_GET['onpage'];
}elseif(empty($_SESSION["onpage"]) AND !empty($_GET['onpage'])){
$onpage=$_GET['onpaget'];
session_register ("onpage") ;}
if(!empty($_SESSION["prew"]) AND !empty($_GET['prew']))
$_SESSION["prew"]=$_GET['prew'];
elseif(empty($_SESSION["prew"]) AND !empty($_GET['prew'])){
$prew=$_GET['prew'];
session_register ("prew") ;}
if(!empty($_SESSION["sort"]) AND !empty($_GET['sort']))
$_SESSION["sort"]=$_GET['sort'];
elseif(empty($_SESSION["sort"]) AND !empty($_GET['sort'])){
$sort=$_GET['sort'];
session_register ("sort") ;}
function get2ses($name)
{
global $_GET, $_SESSION, $setup;
$d = $name;
if(!isset($_SESSION[$name])) {$_SESSION[$name] = $setup[$name];}
if(isset($_GET[$name])) {$_SESSION[$name] = $_GET[$name];}
return $$name = $_SESSION[$d];
}
$prew = check(intval($_SESSION["prew"]));
$sort = get2ses('sort');
if($sort == 'name') $sortlink = '<a href="?sort=data">дата</a>|<a href="?sort=size">размер</a>|<a href="?sort=load">популярность</a>|<a href="?sort=eval">рейтинг</a>';
elseif($sort == 'size') $sortlink = '<a href="?sort=data">дата</a>|<a href="?sort=name">имя|<a href="?sort=load">популярность</a></a>|<a href="?sort=eval">рейтинг</a>';
elseif($sort == 'load') $sortlink = '<a href="?sort=data">дата</a>|<a href="?sort=name">имя|<a href="?sort=size">размер</a>|<a href="?sort=eval">рейтинг</a>';
elseif($sort == 'eval') $sortlink = '<a href="?sort=data">дата</a>|<a href="?sort=name">имя|<a href="?sort=size">размер</a>|<a href="?sort=load">популярность</a>';
else $sortlink = '<a href="?sort=name">имя</a>|<a href="?sort=size">размер</a>|<a href="?sort=load">популярность</a>|<a href="?sort=eval">рейтинг</a>';
echo ' Cортировать по:<br />  '.$sortlink.'<br />';
$valid_sort = array('timeupload' => '','name' => '','data' => '','load' => '','size' => '','eval' =>'');
if(!isset($valid_sort[$sort])){
$sort='timeupload';
}
$MODE = '`timeupload` DESC';
if($sort == 'name') $MODE = '`name` DESC';
elseif($sort == 'size') $MODE = '`size` ASC';
elseif($sort == 'load') $MODE = '`loads` DESC';
elseif($sort == 'eval') $MODE = '`yes` DESC ,`no` ASC';
echo '<br />';
if (empty($row['max'])) $row['max']=10;
$max = 10;
$k_post=mysql_result(mysql_query("select COUNT(*) from `scripts_files` WHERE infolder = '".$cat['path']."';"),0);
$k_page=k_page($k_post,$max);
$page=page($k_page);
$start=$max*$page-$max;
if ($k_post==0)echo 'Здесь файлов пока нет :)<br />';
$p==1;
$q = mysql_query( "SELECT * from `scripts_files` WHERE infolder = '".$cat['path']."' ORDER BY ".$MODE." limit $start,$max;" );
while ($file = @mysql_fetch_array(@$q))
{
if(is_file($file['path'])){
$ex = pathinfo($file['path']);
$ext = strtolower($ex['extension']);
//Предосмотр
//Новизна файла
$new_info='';
$filtime2 = $file['timeupload']+(3600*24*$set['scripts_day_new']);
if($filtime2>=$time and $set['scripts_day_new']!=0) $new_info = ' <img src="/usscripts/ext/new.gif" alt=""/>';
//Красивый размер
if($file['size'] < 1024) $file['size'] = '('.$file['size'].' б)';
if($file['size'] < 1048576 and $file['size'] >= 1024) $file['size'] = '('.round($file['size']/1024, 2).' Кб)';
if($file['size'] > 1048576) $file['size'] = '('.round($file['size']/1024/1024, 2).' Мб)';
$ico = '<img src="/usscripts/ext/'.$ext.'.png" alt=""/>';
//Показ расиширения
$extension = "$ext|";
$file['size']=str_replace(')','',$file['size']);
$file['size']=str_replace('(','',$file['size']);
$p++;
if(is_integer($p / 2)) echo $div1; else echo $div2;
echo $ico.' <a href="/usscripts/down/'.$file[id].'"><strong>'.$file['name'].'</strong></a>  ['.$extension.$file['size'].']'.$new_info.$div9;
echo ' <img src="/usscripts/ext/load.gif" alt=""/> <a href="/usscripts/load/'.$file['id'].'">Скачать</a>';
if($ext =='txt')echo '|<a href="/usscripts/read/'.$file['id'].'">Читать</a>';
echo '<br />';
$opis=$file['about'];
$opis=substr($opis,0,100);
$opis = htmlentities($opis, ENT_QUOTES, 'UTF-8');
echo ''.$opis.'...<br />';
/*echo'<a href="komm.php?file='.$id2.'">Ком.: ['.$all_komments.']</a>|Рейтинг:<font color="black">'.$file['yes'].'</font>/<font color="red">'.$file['no'].'</font><font color="blue">|Скач.:</font>['.$file['loads'].']<br/>';*/
}else {mysql_query("DELETE FROM `scripts_files` where id = '".$file['id']."'");
}
echo '<dl></dl>';
}
if ($k_page>1){
echo '<br/><dl><dt></dt></dl>';
str("?",$k_page,$page); // Вывод страниц
echo '<br/><dl><dt></dt></dl>';
}
}
echo "<br/>";
include '../style/foot.php';
?>