Файл: mob-lave.ru/moduls/notebook/index.php
Строк: 92
<?php
require_once '../../core/set.php';
reg();
// ----------- Удалить ------------- //
if(isset($_GET['delete']) && mysql_result(mysql_query("SELECT * FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]' && `id` = '".num($_GET['delete'])."'"),0) == true){
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]' && `id` = '".num($_GET['del'])."'"));
mysql_query("DELETE FROM `$system[perfix]_notebook` WHERE `id` = '".num($_GET['delete'])."' && `id_user` = '$user[id]'");
header('Location: /moduls/notebook/');
$_SESSION['message'] = 'Запись удалена';
}
if(isset($_GET['del']) && mysql_result(mysql_query("SELECT * FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]' && `id` = '".num($_GET['del'])."'"),0) == true){
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]' && `id` = '".num($_GET['del'])."'"));
$set['title'] = 'Редактирование записи';
require_once H.'core/head.php';
require_once H.'core/panel.php';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/notebook/">Ежедневник</a>'.$z.'<a href="/moduls/notebook/?read='.num($_GET['del']).'">К записи</a>'.$z. $set['title'].'</div>';
echo '<div class="mess">Вы действительно хотите удалить эту запись?<br/><a href="?delete='.num($post['id']).'"><div id="dark" class="icon-checkmark"></div> Да</a> | <a href="?read='.num($post['id']).'"><div id="dark" class="icon-undo2 "></div> Нет</a></div>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/notebook/">Ежедневник</a>'.$z.'<a href="/moduls/notebook/?read='.num($_GET['del']).'">К записи</a>'.$z. $set['title'].'</div>';
require_once H.'core/foot.php';
exit();
}
// ----------- Редактировать ------------- //
if(isset($_GET['edit']) && mysql_result(mysql_query("SELECT * FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]' && `id` = '".num($_GET['edit'])."'"),0) == true){
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]' && `id` = '".num($_GET['edit'])."'"));
$set['title'] = 'Редактирование записи';
require_once H.'core/head.php';
require_once H.'core/panel.php';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/notebook/">Ежедневник</a>'.$z.'<a href="/moduls/notebook/?read='.num($_GET['edit']).'">К записи</a>'.$z. $set['title'].'</div>';
if(isset($_POST['msg'])){
$msg = check($_POST['msg']);
if(strlen($msg) < 3 or strlen($msg) > 20000) $err = 'Текст должен быть в пределах 3 - 20 000 символов';
err();
if(!isset($err)){
mysql_query("UPDATE `$system[perfix]_notebook` SET `msg` = '$msg' WHERE `id` = '".num($post['id'])."' && `id_user` = '$user[id]'");
header("Location: /moduls/notebook/?read=$post[id]");
$_SESSION['message'] = 'Ежедневник изменен';
}
}
echo '<form method="post">';
panel_bb('textarea');
echo '<textarea id="textarea" name="msg">'.$post['msg'].'</textarea><br/>
<input type="submit" value="Сохранить"/>
</form>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/notebook/">Ежедневник</a>'.$z.'<a href="/moduls/notebook/?read='.num($_GET['edit']).'">К записи</a>'.$z. $set['title'].'</div>';
require_once H.'core/foot.php';
exit();
}
// ------------- Читать ----------- //
if(isset($_GET['read']) && mysql_result(mysql_query("SELECT * FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]' && `id` = '".num($_GET['read'])."'"),0) == true){
$set['title'] = 'Запись';
require_once H.'core/head.php';
require_once H.'core/panel.php';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/notebook/">Ежедневник</a>'.$z. $set['title'].'</div>';
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]' && `id` = '".num($_GET['read'])."'"));
echo '<div class="menu">'.text($post['msg']).'<br/><div id="dark" class="icon-clock"></div> '.vremja($post['time']);
echo '<br/><div id="dark" class="icon-pencil"></div> <a href="?edit='.num($post['id']).'">Ред</a> | <div id="dark" class="icon-cancel"></div> <a href="?del='.num($post['id']).'">Удл</a>';
echo '</div>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/notebook/">Ежедневник</a>'.$z. $set['title'].'</div>';
require_once H.'core/foot.php';
exit();
}
$set['title'] = 'Ваш ежедневник';
require_once H.'core/head.php';
require_once H.'core/panel.php';
echo '<div class="navig">'.$home. $z. $set['title'].'</div>';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]'"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
if ($k_post == 0) echo '<div class="menu">Нет записей</div>';
$q = mysql_query("SELECT * FROM `$system[perfix]_notebook` WHERE `id_user` = '$user[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while($note= mysql_fetch_assoc($q)){
echo '<div class="menu_touch"><a href="?read='.num($note['id']).'">'.rez_text(text($note['msg'])).'<br/><div id="dark" class="icon-clock"></div> '.vremja($note['time']).'</div>';
echo '</a></div>';
}
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
echo '<div class="navig">'.$home. $z. $set['title'].'</div>';
require_once H.'core/foot.php';
?>