<table class="table table-striped table-hover table-bordered"> <tr> <th>ردیف</th> <th>نام</th> <th>ایمیل</th> <th>متن کامنت</th> <th>تاریخ ثبت</th> <th>شماره پست</th> <th>فعال</th> <th>عملیات</th> </tr> <?php if (isset($_POST['edit'])) { DatabaseHandler::execute("UPDATE `comments` SET `activate` = !`activate` WHERE `id` = '{$_POST['comment_id']}' ; "); } $comments = COMMENTS::comments_SelectAll(); $i = 1; foreach ($comments as $comment) { $comment["add_time"] = jdate("Y/m/d", $comment["add_time"]); $checked = ""; if ($comment["activate"]) { $comment["activate"] = "<span style='color:green'>فعال</span>"; $checked = "checked"; } else { $comment["activate"] = "<span style='color:red'>غیر فعال</span>"; } $blog = BLOGS::blogs_SelectRow($comment["blog_id"]); echo "\n\t\t <tr>\n\t\t \t\t\t<td>{$i}</td>\n\t\t\t\t\t<td>{$comment['full_name']}</td>\n\t\t\t\t\t<td>{$comment['mail']}</td>\n\t\t\t\t\t<td>{$comment['text']}</td>\n\t\t\t\t\t<td>{$comment['add_time']}</td>\n\t\t\t\t\t<td>{$blog['title']}</td>\n\t\t\t\t\t<td>{$comment['activate']} <form method='post' id='form{$comment['id']}'><input type='hidden' name='comment_id' value='{$comment['id']}'><input onchange='\$(" . '"#form' . $comment["id"] . '"' . ").submit();' type='checkbox' name='edit' class='edit'></form></td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<a href='#'>پاسخ</a>\n\t\t\t\t\t</td>\t\n\t\t </tr>"; $i++; } ?>
function listplug_table_itemlist($template, $type) { $cssclass = null; switch ($type) { case 'HEAD': echo "<th>" . _LIST_ITEM_INFO . "</th><th>" . _LIST_ITEM_CONTENT . "</th><th style=\"white-space:nowrap\" colspan='1'>" . _LISTS_ACTIONS . "</th>"; break; case 'BODY': $current = $template['current']; $current->itime = strtotime($current->itime); // string -> unix timestamp if ($current->idraft == 1) { $cssclass = "class='draft'"; } // (can't use offset time since offsets might vary between blogs) if ($current->itime > $template['now']) { $cssclass = "class='future'"; } $action = requestVar('action'); echo '<td ' . $cssclass . ' style="white-space:nowrap;">'; if ($action !== 'itemlist') { echo _LIST_ITEM_BLOG . ' ', htmlspecialchars($current->bshortname) . ' <br />'; } echo _LIST_ITEM_CAT, ' ', htmlspecialchars($current->cname) . ' <br />'; if ($action !== 'browseownitems') { echo _LIST_ITEM_AUTHOR, ' ', htmlspecialchars($current->mname) . ' <br />'; } echo date("Y-m-d", $current->itime), " " . date("H:i", $current->itime); echo "</td>"; echo "<td {$cssclass}>"; $id = listplug_nextBatchId(); echo '<input type="checkbox" id="batch', $id, '" name="batch[', $id, ']" value="', $current->inumber, '" />'; echo '<label for="batch', $id, '">'; echo "<b>" . htmlspecialchars(strip_tags($current->ititle)) . "</b>"; echo '</label>'; echo "<br />"; $current->ibody = strip_tags($current->ibody); $current->ibody = htmlspecialchars(shorten($current->ibody, 200, '...')); $COMMENTS = new COMMENTS($current->inumber); echo "{$current->ibody}</td>"; echo "<td style=\"white-space:nowrap\" {$cssclass}>"; echo "<a href='index.php?action=itemedit&itemid={$current->inumber}'>" . _LISTS_EDIT . "</a>"; echo " / <a href='index.php?action=itemmove&itemid={$current->inumber}'>" . _LISTS_MOVE . "</a>"; echo " / <a href='index.php?action=itemdelete&itemid={$current->inumber}'>" . _LISTS_DELETE . "</a><br />"; // evaluate amount of comments for the item $camount = $COMMENTS->amountComments(); if ($camount > 0) { echo "<a href='index.php?action=itemcommentlist&itemid={$current->inumber}'>"; echo "( " . sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments()) . " )</a>"; } else { echo _LIST_ITEM_NOCONTENT; } echo "</td>"; break; } }
* Created by PhpStorm. * User: pooya * Date: 9/1/15 * Time: 18:47 PM */ require_once "../core/core.php"; if (isset($_POST["comment"])) { parse_str($_POST['comment'], $comment); if ($comment["full_name"] == "" || $comment["email"] == "" || $comment["text"] == "") { echo COMMENT_FAILED; } else { $result = COMMENTS::comments_Insert($comment["full_name"], $comment["email"], $comment["text"], time(), 0, $_SERVER["REMOTE_ADDR"], 0, 0, $comment["blog_id"], 0); if ($result) { echo COMMENT_SUCCESS; } else { echo COMMENT_FAILED; } } } if (isset($_POST["sub_comment"])) { if ($_POST["full_name"] == "" || $_POST["email"] == "" || $_POST["text"] == "") { echo COMMENT_FAILED; } else { $result = COMMENTS::comments_Insert($_POST["full_name"], $_POST["email"], $_POST["text"], time(), 0, $_SERVER["REMOTE_ADDR"], 0, 0, $_POST["blog_id"], $_POST["comment_id"]); if ($result) { echo COMMENT_SUCCESS; } else { echo COMMENT_FAILED; } } }
/** * Adds a new comment to an item (if IP isn't banned) */ function addComment() { global $CONF, $errormessage, $manager; $post['itemid'] = intPostVar('itemid'); $post['user'] = postVar('user'); $post['userid'] = postVar('userid'); $post['email'] = postVar('email'); $post['body'] = postVar('body'); $post['remember'] = intPostVar('remember'); // set cookies when required #$remember = intPostVar('remember'); // begin if: "Remember Me" box checked if ($post['remember'] == 1) { $lifetime = time() + 2592000; setcookie($CONF['CookiePrefix'] . 'comment_user', $post['user'], $lifetime, '/', '', 0); setcookie($CONF['CookiePrefix'] . 'comment_userid', $post['userid'], $lifetime, '/', '', 0); setcookie($CONF['CookiePrefix'] . 'comment_email', $post['email'], $lifetime, '/', '', 0); } // end if $comments = new COMMENTS($post['itemid']); $blog_id = getBlogIDFromItemID($post['itemid']); $this->checkban($blog_id); $blog =& $manager->getBlog($blog_id); // note: PreAddComment and PostAddComment gets called somewhere inside addComment $errormessage = $comments->addComment($blog->getCorrectTime(), $post); // begin if: if ($errormessage == '1') { // redirect when adding comments succeeded if (postVar('url')) { redirect(postVar('url')); } else { $url = createItemLink($post['itemid']); redirect($url); } // end if } else { return array('message' => $errormessage, 'skinid' => $blog->getDefaultSkin()); } // end if exit; }