Файл: public_html/modules/library/comments.php
Строк: 89
<?php
/**********************************
* @package: PerfCMS *
* @year: 2012 *
* @author: Artas *
* @link: http://perfcms.net *
* ------------------------------- *
* @package: PerfCMS Ultra *
* @year: 2013 *
* @author: wanya26ua & Tesla *
* @link: http://perfclub.ru *
**********************************/
$locate = 'in_library';
$id = abs(intval($_GET['id']));
$library_ed = $db->query("SELECT * FROM `library_comms` WHERE `id` = '".$_GET['id_post']."'")->fetch();
if(isset($_GET['act']) && $_GET['act'] == 'edit') {
if(isset($_POST['edit'])) {
if(!empty($_POST['text'])) {
$text = substr(input($_POST['text']), 0, 5000);
$db->query("UPDATE `library_comms` SET `text` = '". $text ."' WHERE `id` = '".abs(intval($_GET['id_post']))."'");
}
header('location: /library/'.$library_ed['id_note'].'/comments/');
exit;
}
if(($_GET['id'] != 0 || !empty($_GET['id_post'])) && $user['level'] >= 5 || $library_ed['id_user'] == $user['id']) {
$title = $lang->word('edit_post');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('edit_post'));
echo '<form action="" method="post">
<div class="menu">
<b>'. $lang->word('message') .'</b>:<br/>
<textarea name="text" rows="5" cols="26">'.$library_ed['text'].'</textarea><br/>
<input name="edit" type="submit" value="'. $lang->word('edit') .'" /><br/>
</div>
</form>';
$tpl->div('block', NAV .'<a href="/library/'.$library_ed['id_note'].'/comments/">'. $lang->word('back') .'</a><br/>'. NAV .'<a href="/library/">'. $lang->word('library') .'</a><br/>' . HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
exit;
} else { $tpl->div('error', $lang->word('chat_not_g')); }
}
if($db->query("SELECT * FROM `library` WHERE `id` = '". $id ."'")->rowCount() == 0) {
$title = $lang->word('library');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('library'));
$tpl->div('menu', $lang->word('not_note'));
$tpl->div('block', NAV.' <a href="/library/">'. $lang->word('library') .'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
exit;
}
$note_c = $db->query("SELECT * FROM `library_comms` WHERE `id_note` = '".$id ."'")->rowCount();
$title = $lang->word('comments');
require_once(SYS.'/view/header.php');
$pages = new Paginator($note_c, $ames);
$tpl->div('title', $lang->word('comments'));
if(isset($_GET['act']) && $_GET['act'] == 'spam') {
$tpl->div('block', $lang->word('spam') .' <b>'.$system['spam'].'</b> '.$lang->word('sec'));
}
if($note_c == 0)
{
$tpl->div('menu', $lang->word('no_comments'));
} else {
$comm_sql = $db->query("SELECT * FROM `library_comms` ORDER by id DESC LIMIT $start, $ames");
while($comm = $comm_sql->fetch()) {
echo '<div class="menu"> '.nick($comm['id_user']).'</a> ('.rtime($comm['time']).')
<span style="float:right">'.($comm['id_user'] != $user['id'] ? '<a href="/library/'.(isset($user) && $settings['fast_mess'] == 'yes' ? ''.$id.'/comments/?reply_to='.tnick($comm['id_user']).'' : 'add_comm/?id='.$id.'&reply_to='.tnick($comm['id_user']).'').' " title="'. $lang->word('reply') .'">'.img('reply_11.png').'</a>': NULL) .' '.($user['level'] >=5 || $comm['id_user'] == $user['id'] ? '<a href="/library/del_comm/?id='.$comm['id'] .'&id_note='.$id.'">'. img('delete_11.png') .'</a> <a href="?act=edit&id_post='. $comm['id'] .'" title="'. $lang->word('edit') .'">'. img('edit_11.png') .'</a>' : NULL) .'</span>
<br/>
'.output($comm['text']).' </div>';
}
$pages->view('/library/'.$id.'/comments/?');
}
if($settings['fast_mess'] == 'yes') {
$tpl->div('post', '<form action="/library/add_comm/?act=create&id='.abs(intval($_GET['id'])) .'" method="post">
<textarea name="text" rows="5" cols="26">'.(isset($_GET['reply_to']) ? '[b]'.input($_GET['reply_to']).'[/b], ' : NULL).'</textarea>
<br/>
[ <a href="/pages/smiles.php">'. $lang->word('smiles') .'</a> | <a href="/pages/tags.php">'. $lang->word('tags') .'</a> ]<br/><input type="submit" name="create" value="'. $lang->word('send') .'" /><br/>
</form>');
}
$add_comm = ''.(isset($user) ? NAV .'<a href="/library/add_comm/?id='.$id.'">'. $lang->word('add_comm') .'</a><br/>' : NULL).'';
$tpl->div('block', $add_comm . NAV.' <a href="/library/">'. $lang->word('library').'</a><br/>'. HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
?>