Файл: index.php
Строк: 258
<?php
include 'system/mysql.php';
include 'system/sys_func.php';
$title = 'PeasCMS - лучшая CMS для создания сайта.';
if (!isset($_SESSION['user_id'])) {
if (mysql_real_escape_string($_GET['login']) && mysql_real_escape_string($_GET['pass'])) {
$login = mysql_real_escape_string($_GET['login']);
$pass = mysql_real_escape_string($_GET['pass']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `login` = '". $login ."' AND `pass` = '". in_md5($pass) ."' LIMIT 1"), 0)) {
$user = mysql_fetch_assoc(mysql_query("SELECT `id` FROM `users` WHERE `login` = '". $login ."' AND `pass` = '". in_md5($pass) ."' LIMIT 1"));
setcookie('login', $login, time()+60*60*24*14);
setcookie('pass', in_md5($pass), time()+60*60*24*14);
$_SESSION['user_id'] = $user['id'];
header('Location: /pages/personal/');
exit;
} else {
include 'system/head.php';
echo '<div class="title">Вход</div>
<div class="err">Неправильный логин или пароль.</div>
<a class="link" href="/pages/registration/?menu=login"><img src="/design/imgs/arr_b.png" align="center"> Повторить попытку входа</a>
<a class="link" href="/"><img src="/design/imgs/arr_b.png" align="center"> На главную</a>';
include 'system/foot.php';
exit;
}
}
}
if (isset($_GET['logout'])) {
if (isset($_SESSION['user_id'])) {
if (isset($_POST['yes'])) {
unset($_SESSION['user_id']);
setcookie('login');
setcookie('pass');
mysql_query("UPDATE `users` SET `time_last` = ". (time()-600) ." WHERE `id` = '". $user['id'] ."' LIMIT 1");
header('Location: /');
exit;
}
$title = 'Выход';
include 'system/head.php';
echo '<div class="title">Выход</div>
<form method="post">
Вы уверены что хотите выйти?<br>
<input type="submit" name="yes" value="Да, я хочу выйти" /> <a href="/">Нет</a>
</form>';
include 'system/foot.php';
}
}
if (isset($_GET['v'])) {
if (isset($_POST['style'])) {
if (filter($_POST['style']) == 'WEB') setcookie('version', 'web', time()+60*60*24*14);
elseif (filter($_POST['style']) == 'WAP') setcookie('version', '');
header("Location: /");
}
$title = 'Кабинет/Вид сайта';
include 'system/head.php';
echo '<div class="title"><a href="/pages/personal/">Кабинет</a> / Вид сайта</div>';
echo '<form name="settings" method="post">
<b>Вид сайта</b>:<br>
<select name="style">
<option value="WAP" '. (isset($_COOKIE['version']) == NULL ? 'selected="selected"' : NULL) .'>WAP</option>
<option value="WEB" '. (isset($_COOKIE['version']) == 'web' ? 'selected="selected"' : NULL) .'>WEB</option>
</select><br>
<input type="submit" value="Сохранить">
</form>
<a class="link" href="/pages/personal/?menu=settings"><img src="/design/imgs/arr_b.png" align="center"> Настройки</a>
<a class="link" href="/pages/personal/"><img src="/design/imgs/arr_b.png" align="center"> Кабинет</a>';
include 'system/foot.php';
exit;
}
$users_on = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `time_last` > ". (time()-600) .""), 0);
$guests_on = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `guests` WHERE `time` > ". (time()-600) .""), 0);
$n = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `news`"), 0);
$n_n = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `news` WHERE `time` > '". (time()-86400) ."'"), 0);
$d = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `diaries`"), 0);
$d_n = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `diaries` WHERE `time` > '". (time()-86400) ."'"), 0);
$m = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `mchat`"), 0);
$m_n = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `mchat` WHERE `time` > '". (time()-86400) ."'"), 0);
$l = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `user_files`"), 0);
$l_n = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `user_files` WHERE `time` > '". (time()-86400) ."'"), 0);
$f = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `f_theme`"), 0);
$f_n = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `f_theme` WHERE `time` > '". (time()-86400) ."'"), 0);
$u = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users`"), 0);
$u_n = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `time_reg` > '". (time()-86400) ."'"), 0);
$v = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `time_last` > '". (time()-43200) ."'"), 0);
include_once 'system/head.php';
echo '<div class="title">
<center>
<a href="/pages/users/?menu=online">Онлайн: '. $users_on .'</a> (<a href="/pages/users/?menu=online_guests">+ '. $guests_on .' гостей</a>)
</center>
</div>';
if ($n_n == 0) { $n_n = NULL; } else { $n_n = '<span class="new">+'. $n_n .'</span>'; }
if ($d_n == 0) { $d_n = NULL; } else { $d_n = '<span class="new">+'. $d_n .'</span>'; }
if ($m_n == 0) { $m_n = NULL; } else { $m_n = '<span class="new">+'. $m_n .'</span>'; }
if ($l_n == 0) { $l_n = NULL; } else { $l_n = '<span class="new">+'. $l_n .'</span>'; }
if ($f_n == 0) { $f_n = NULL; } else { $f_n = '<span class="new">+'. $f_n .'</span>'; }
if ($u_n == 0) { $u_n = NULL; } else { $u_n = '<span class="new">+'. $u_n .'</span>'; }
echo '<a class="link" href="/pages/news/"><img src="/design/imgs/news.png"> Новости ('. $n .') '. $n_n .'</a>';
$q = mysql_query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1");
while ($news = mysql_fetch_assoc($q)) {
if (string($news['msg']) <= 50) $news_msg = $news['msg'];
else $news_msg = output(cut($news['msg'], 50)) .'...';
echo '<a class="link" href="/pages/news/news.php?id='. $news['id'] .'&page=end"><b>'. $news['name'] .'</b><br>'. $news_msg .'</a>';
}
echo '<a class="link" href="/pages/diaries/"><img src="/design/imgs/diary.png"> Дневники ('. $d .') '. $d_n .'</a>
<a class="link" href="/pages/mchat/"><img src="/design/imgs/chat.png"> Мини-Чат ('. $m .') '. $m_n .'</a>
<a class="link" href="/pages/user.files/?menu=all"><img src="/design/imgs/dfile.png"> Зона обмена ('. $l .') '. $l_n .'</a>';
$q = mysql_query("SELECT * FROM `user_files` ORDER BY `id` DESC LIMIT 1");
while ($file = mysql_fetch_assoc($q)) {
$dir = mysql_fetch_array(mysql_query("SELECT * FROM `user_f_dir` WHERE `id` = '". $file['dir_id'] ."'"));
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '". $file['user_id'] ."'"));
echo '<a class="link" href="/pages/user.files/?menu=file&id='. $file['id'] .'">
<span class="c_date">'. ptime($file['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
if (is_file(H.'files/user.files.screen/'. $file['screenshot'])) {
echo '<img src="/thumb.php?src=user.files.screen/'. $file['screenshot'] .'&t=b">';
} elseif ($file['ext'] == '.jpg' || $file['ext'] == '.jpeg' || $file['ext'] == '.png' || $file['ext'] == '.gif') {
echo '<img src="/thumb.php?src=user.files/'. $file['filename'].$file['ext'] .'&t=b">';
}
echo ' </td>
<td>';
echo online($ank['id']);
echo $ank['login'] .'<br>
<img src="/design/imgs/file.png"> '. $file['name'].$file['ext'] .' ('. size($file['size']) .')<br>';
echo '
</td>
</tr>
</table>
</a>';
}
echo '<a class="link" href="/pages/forum/"><img src="/design/imgs/forum.png"> Форум ('. $f .') '. $f_n .'</a>';
$q = mysql_query("SELECT * FROM `f_theme` ORDER BY `last_post` DESC LIMIT 3");
while ($them = mysql_fetch_assoc($q)) {
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum` WHERE `id` = '". $them['forum_id'] ."' LIMIT 1"));
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `f_category` WHERE `id` = '". $them['cat_id'] ."' LIMIT 1"));
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '". $them['id_user'] ."' LIMIT 1"));
echo '<div class="post">
<span class="c_date">'. ptime($them['time']) .'</span>';
if ($them['fix']==1) echo '<img src="/design/imgs/stick.gif" alt="top" /> ';
echo '<a href="/pages/forum/topic.php?id='. $them['id'] .'">'. $them['name'] .'</a> ';
echo '('. mysql_result(mysql_query("SELECT COUNT(*) FROM `f_post` WHERE `forum_id` = '$forum[id]' AND `cat_id` = '$cat[id]' AND `them_id` = '$them[id]'"),0) .')';
if ($them['close']==1) echo ' <img src="/design/imgs/topic_locked.gif" alt="top" />';
echo '<br>';
echo online($ank['id']);
echo '<a href="/pages/users/user.php?name='. $ank['login'] .'">'. $ank['login'] .'</a> / ';
$post2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `f_post` WHERE `them_id` = '$them[id]' ORDER BY `time` DESC LIMIT 1"));
$ank2 = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$post2[id_user]'"));
if (isset($post2['id_user'])) {
echo online($ank2['id']);
if ($ank['login'] == $ank2['login']) {
echo ' '. $ank2['login'] .' ('. ptime($them['time']) .')';
} else {
echo ' <a href="/pages/users/user.php?name='. $ank2['login'] .'">'. $ank2['login'] .'</a> ('. ptime($post2['time']) .')';
}
} else {
echo online($ank['id']);
echo $ank['login'] .' ('. ptime($them['time']) .')';
}
echo '</div>';
}
echo '<a class="link" href="/pages/users/"><img src="/design/imgs/users.png"> Пользователи ('. $u .') '. $u_n .'</a>';
if ($u != 0) {
echo '<div class="post">';
$q = mysql_query("SELECT * FROM `users` ORDER BY `id` DESC LIMIT 1");
while ($user = mysql_fetch_assoc($q)) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '". $user['id'] ."'"));
echo online($ank['id']);
echo '<a href="/pages/users/user.php?name='. $ank['login'] .'">'. $ank['login'] .'</a>';
echo '<br>Дата регистрации: '. ptime($user['time_reg']);
}
echo '</div>';
}
echo '<a class="link" href="/pages/users/?menu=visitors"><img src="/design/imgs/visit.png"> Посетители ('. $v .')</a>';
include 'system/foot.php';
?>