Пример #1
0
function comment_show_comments($id, $type)
{
    $nr = 0;
    $inloggad = login_check_logged_in_mini();
    //Hämta alla kommentarer
    $sql = "SELECT * FROM " . PREFIX . "comment WHERE comment_on=" . sql_safe($id) . " AND comment_type='{$type}' AND is_spam<1;";
    if ($cc = @mysql_query($sql)) {
        while ($c = mysql_fetch_array($cc)) {
            $nr++;
            //Kolla om författaren är admin
            $admin = user_get_admin($c['user']);
            //skriv ut en anchor-pryl
            echo '<span class="anchor" id="anchor_comment_' . $c['id'] . '"></span>';
            //Skriv ut kommentar
            if ($admin < 2) {
                echo "<div class=\"comment\" id=\"comment_" . $c['id'] . "\">";
            } else {
                echo "<div class=\"comment admin_comment\" id=\"comment_" . $c['id'] . "\">";
            }
            comment_display_single($c['id']);
            //Visa knapp för borttagning om man är admin
            if ($inloggad > 1) {
                echo "<form id=\"delete_comment_" . $c['id'] . "\" method=\"post\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"id\" value=\"" . $c['id'] . "\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"deletecomment\" value=\"" . $c['id'] . "\">\n\t\t\t\t\t\t<input type=\"button\" name=\"deletecomment_button\" onclick=\"confirmation_delete('delete_comment_" . $c['id'] . "', '" . _("Do you really want to delete the comment? This cannot be undone.") . "')\"  value=\"" . _("Remove comment") . "\">\n\t\t\t\t\t</form>";
                // <input type=\"button\" name=\"deletecomment_button\" onclick=\"return confirm('"._("Do you really want to delete the comment? This cannot be undone.")."');\"  value=\""._("Remove comment")."\">
                if ($aa = mysql_query("SELECT user from " . PREFIX . "comment WHERE id=" . sql_safe($c['id']) . ";")) {
                    if ($a = mysql_fetch_array($aa)) {
                        //Kolla om det är användarens kommentar.
                        if (strcmp($a['user'], $_SESSION[PREFIX . "user_id"])) {
                            spam_show_clicker($c['id'], "comment");
                        }
                    }
                }
            } else {
                if ($inloggad >= 1) {
                    //Om det är ens egen kommentar och den inte har några svar ska man kunna ta bort den.
                    if ($aa = mysql_query("SELECT user from " . PREFIX . "comment WHERE id=" . sql_safe($c['id']) . ";")) {
                        if ($a = mysql_fetch_array($aa)) {
                            //Kolla om det är användarens kommentar.
                            if (!strcmp($a['user'], $_SESSION[PREFIX . "user_id"])) {
                                //Kolla så att det inte finns några svar
                                if ($dd = mysql_query("SELECT id from " . PREFIX . "comment WHERE comment_on=" . sql_safe($c['id']) . " AND comment_type='comment';")) {
                                    if (mysql_affected_rows() < 1) {
                                        echo "<form id=\"delete_comment_" . $c['id'] . "\" method=\"post\">\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"id\" value=\"" . $c['id'] . "\">\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"deletecomment\" value=\"" . $c['id'] . "\">\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"button\" name=\"deletecomment_button\" onclick=\"confirmation_delete('delete_comment_" . $c['id'] . "', '" . _("Do you really want to delete the comment? This cannot be undone.") . "')\"  value=\"" . _("Remove comment") . "\">\n\t\t\t\t\t\t\t\t\t\t</form>";
                                        // <input type=\"button\" name=\"deletecomment_button\" onclick=\"return confirm('"._("Do you really want to delete the comment? This cannot be undone.")."');\"  value=\""._("Remove comment")."\">
                                    }
                                }
                            } else {
                                spam_show_clicker($c['id'], "comment");
                            }
                        }
                    }
                }
            }
            if ($inloggad > 0) {
                //Om man är inloggad ska man kunna svara
                echo "<a class=\"button\" onClick=\"showhide('replyto" . $c['id'] . "');\" href=\"#reply\">" . _("Reply") . "</a>";
                echo "<div id=\"replyto" . $c['id'] . "\" style=\"display:none\">";
                comment_form_show($c['id'], "comment", "");
                echo "</div>";
            } else {
                //Om man inte är inloggad ska man kunna svara med captcha
                echo "<a class=\"button\" onClick=\"showhide('replyto" . $c['id'] . "');\" href=\"#reply\">" . _("Reply") . "</a>";
                echo "<div id=\"replyto" . $c['id'] . "\" style=\"display:none\">";
                comment_form_show($c['id'], "comment", "");
                echo "</div>";
            }
            //Skriv ut svar på denna
            //echo "<br />DEBUG: $nr + comment_show_comments = ";
            $nr += comment_show_comments($c['id'], "comment");
            //echo "$nr";
            echo "</div>";
        }
    }
    //echo "<br />DEBUG: return $nr;";
    return $nr;
}
Пример #2
0
function feedback_display_body($id, $hidden = FALSE)
{
    if ($hidden) {
        $hide_str = "style=\"display: none;\"";
    } else {
        $hide_str = "";
    }
    //Shows everything but headline, username and time
    $shown = 0;
    $sql = "SELECT id, text, user, flattrID, plusones FROM " . PREFIX . "feedback WHERE id=" . sql_safe($id) . ";";
    if ($dd = mysql_query($sql)) {
        if ($d = mysql_fetch_array($dd)) {
            echo '<div class="row">';
            echo "<div id=\"feedback_body_" . $id . "\" " . $hide_str . " class=\"feedback_body col-lg-12\">";
            //Text
            $text_body = sql_safe(str_replace("\r\n", "<br />", str_replace("\r\n\r\n", "</p><p>", $d['text'])));
            echo "<div class=\"col-lg-9 feedback_text\"><p>" . $text_body . "</p>";
            echo "</div>";
            //Side thing with buttons
            echo "<div class=\"col-lg-3\">";
            echo "<div class=\"col-lg-12\" id=\"feedback_" . $id . "_flattr\">";
            //Eventuellt Flattr-knapp
            // echo "<p>Eventuellt Flattr-knapp</p>";
            if ($d['user'] != NULL) {
                if (flattr_get_flattr_choice($d['user'], "feedback")) {
                    flattr_button_show(flattr_get_flattrID($d['user']), SITE_URL . "?p=feedback&amp;id=" . $id, feedback_get_title($id) . " - a feedback post on " . SITE_NAME, $d['text'], 'compact', 'en_GB');
                }
            } else {
                if ($d['flattrID'] != NULL) {
                    flattr_button_show($d['flattrID'], SITE_URL . "?p=feedback&amp;id=" . $d['id'], feedback_get_title($id) . " - a feedback post on " . SITE_NAME, $d['text'], 'compact', 'en_GB');
                }
            }
            echo "</div>";
            echo "<div class=\"col-lg-12\">";
            //Plus-knapp
            echo "<div class=\"plusone\">";
            // echo "<p>Plus-knapp</p>";
            echo "<form method=\"post\">";
            echo "<input type=\"submit\" name=\"feedback_plusone\" value=\"+" . ($d['plusones'] + 1) . "\">\n\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"id\" value=\"" . $d['id'] . "\">";
            echo "<br />" . $d['plusones'] . " +1's";
            echo "</form>";
            echo "</div>";
            echo "</div>";
            echo "<div class=\"col-lg-12\">";
            //Kolla om det är användarens feedback.
            if ($d['user'] == NULL || isset($_SESSION[PREFIX . 'user_id']) && strcmp($d['user'], $_SESSION[PREFIX . 'user_id'])) {
                spam_show_clicker($d['id'], "feedback");
            }
            echo "</div>";
            echo "</div>";
            echo "</div>";
            $shown = 1;
            echo "</div>";
        }
    }
    if (!$shown) {
        echo "<p class=\"error\">Feedback could not be shown</p>";
    }
}