Размер файла: 3.28Kb
- <?
- /*
- =============================================
- Движок: SHCMS Engine
- =============================================
- Название файла: Комментарии
- =============================================
- Official website: http://shcms.ru
- =============================================
- Данный код защищен авторскими правами
- =============================================
- */
- define('SHCMS', true);
- include_once'../system/inc/basic_settings.php';
- if($_GET['id']){
- $id = $_GET['id'];
- }
-
- $photo_comm = mysql_fetch_array(mysql_query("SELECT * FROM `photo_users` WHERE `id` = '$id'"));
- $shcmsengine['title'] = 'Комментарии к '.$photo_comm['name'].'';
- include_once'../template/head.php';
-
- $allfield = mysql_result(mysql_query("SELECT COUNT(*) FROM `photo_comm` WHERE `id_comm` = '$id'"),0);
- $newlist = new Navigation($allfield,10, true);
-
- if($user_id)
- {
- echo '<strong>Текст комментария:</strong><br/>';
-
- echo '<form action="?id='.$id.'" method="post" name="form">';
- echo '<textarea id="text" name="text"></textarea><br/>';
- echo '<input type="submit" name="submit" value="Написать"> ';
- echo '<input type="submit" name="refresh" value="Обновить">';
- echo '</form>';
- echo '<br/>';
- }
-
- $where_comm = mysql_query("SELECT * FROM `photo_comm` WHERE `id_comm` = '$id' ORDER BY `id` DESC ". $newlist->limit()."");
-
- if(mysql_num_rows($where_comm) > 0)
- {
- while($whire_comm = mysql_fetch_array($where_comm))
- {
- $users = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$whire_comm[user_id]'"));
- echo '<div class="posts">';
- users_profile($users['id']);
- echo list_users($users['id']).'';
- echo '<br/>'.processing($whire_comm['text']).'<span style="float: right">'.$timedate->times($whire_comm['time']).'</span></div>';
- }
-
- echo '<div class="pages">';
- echo $newlist->pagination('id='.$id.'');
- echo '</div>';
- }
- else
- {
- echo '<div class="posts">Комментарии не добавлены</div>';
- }
-
- if($_POST['submit'])
- {
- $submit = $_POST['submit'];
- }
- if(isset($submit))
- {
- if($_POST['text'])
- {
- $text = $_POST['text'];
- }
-
- if(empty($text))
- {
- echo '<div class="errors">Введите текст комментарии</div>';
- header("Refresh: 1; url=?id=$id");
- include_once'../template/foot.php';
- exit;
- }
-
-
- $comm = mysql_query("INSERT INTO `photo_comm` (`user_id`,`id_comm`,`time`,`text`) VALUES ('$user_id','$id','".time()."','$text')");
- if($comm == true)
- {
- echo '<div class="actshcms">Комментария успешно добавлена</div>';
- header("Refresh: 1; url=?id=$id");
- include_once'../template/foot.php';
- exit;
- }
- else {
- errors('Возникла ошибка при добавлении комментарии');
- header("Refresh: 1; url=?id=$id");
- include_once'../template/foot.php';
- exit;
- }
-
- }
-
-
- include_once'../template/foot.php';
-
- ?>