} else {
            $UserName = $_SESSION['auth']['firstname'];
        }
        unset($_POST['ajax_AddCommentBtn']);
        unset($_POST['UserNameEdt']);
        unset($_POST['CommentEdt']);
        if (isset($_SESSION['auth'])) {
            $vUserID = $_SESSION['auth']['id'];
            $vUnknownUserGUID = "";
        } else {
            $vUserID = "0";
            $vUnknownUserGUID = (string) GetUnknownUserGUID();
        }
        $sql = "select ID " . "from CatalogComments " . "where (CatalogItemID = {$id}) " . "and (UnknownUserGUID = '{$vUnknownUserGUID}') " . "and (UserID = {$vUserID}) " . "and (Text = '{$Comment}');";
        $rec = GetMainConnection()->query($sql)->fetch();
        if (empty($rec['ID'])) {
            $sql = "insert into CatalogComments(CatalogItemID, UserID, UnknownUserGUID, CreateDate, UserName, Text) " . "values({$id}, {$vUserID}, '{$vUnknownUserGUID}', '" . GetLocalDateTimeAsSQLStr() . "', '{$UserName}', '{$Comment}');";
            GetMainConnection()->exec($sql);
        } else {
            $ErrorText = 'Такой отзыв уже существует.';
        }
    }
    // Формат ответа: 1 позиция текст ошибки, 2 позиция кол-во комментов, 3-html для перезаполнения таблицы комментов
    if (empty($ErrorText)) {
        $sql = "select CreateDate, UserID, UserName, Text " . "from CatalogComments " . "where (CatalogItemID = {$id}) " . "and (IsDeleted = 0) " . "order by CreateDate desc;";
        $Comments = GetMainConnection()->query($sql)->fetchAll();
        echo '||' . count($Comments) . '||' . GetCatalogCommentsHTML($Comments);
    } else {
        echo $ErrorText . '||||';
    }
}
Esempio n. 2
0
?>
Добавить</button>
                    </div>

                    <div id="article_line" style="margin: 25px 0 20px 0;">
                        <div id="article_line_100_Percents">
                            <div id="article_line_left"></div>
                            <div id="article_line_middle"></div>
                            <div id="article_line_right"></div>
                        </div>
                    </div>                    
                    
                    <div id="comments_items">
                        <?php 
if (count($comments) > 0) {
    echo GetCatalogCommentsHTML($comments);
    /*foreach ($comments as $k=>$a) { ?>
          <div class="comment_item">
              <div class="comment_title">
                  <label class="comment_user"><?php echo $a["UserName"]; ?></label>
                  <label class="comment_time"><?php echo $UserDesc.date("d.m.Y H:i", strtotime($a['CreateDate'])); ?></label>
              </div>
              <div class="comment_text">
                  <?php echo $a["Text"];?>
              </div>
          </div>
      <?php }*/
} else {
    echo "На данный момент нет данных!";
}
?>