Exemple #1
0
 function body()
 {
     if (empty($this->entries)) {
         return "<em>No posts found</em>";
     }
     $out = '<ul class="link-list">';
     foreach ($this->entries as $page) {
         $notes = '';
         $notes .= "Date: <span class='date'>" . gmstrftime('%Y-%m-%d', $page->last_modified) . '</span><br>';
         if ($page->tags) {
             $notes .= "Tags: " . implode(', ', $page->tags) . '<br>';
         }
         if ($page->show_comments) {
             $comments = count(Comments::get_all($page->url));
             if ($comments == 0) {
                 $notes .= "0 comments<br>";
             } elseif ($comments == 1) {
                 $notes .= "1 comment<br>";
             } else {
                 $notes .= "{$comments} comments<br>";
             }
         }
         $out .= "<li>";
         $out .= '<a href="' . htmlspecialchars($page->url) . '">';
         $out .= "<span class='thumbnail {$page->icon}'></span>";
         $out .= "<span class='details'>" . $notes . "</span>";
         $out .= "<span class='title'>" . htmlspecialchars($page->title) . "</span>";
         $out .= "<span class='desc'>" . htmlspecialchars($page->subtitle) . "</span>";
         $out .= "</a></li>\n";
     }
     $out .= "</ul>";
     if ($this->tag) {
         //$out .= "<p><a href='feed/$this->tag'>Feed for posts tagged '$this->tag'</a>";
     } else {
         $out .= "<p><a href='feed'>Subscribe to my feed</a>";
     }
     return $out;
 }
Exemple #2
0
 static function write_comments_wb($page)
 {
     $comments = Comments::get_all($page->url);
     echo "<div id='comments'>\n";
     echo " <div id='comments-body'><a name='comments'></a>\n";
     if (empty($comments)) {
         echo "  <h2>Comment</h2>\n";
     } else {
         echo "  <h2>Comments</h2>\n";
         foreach ($comments as $c) {
             echo "<div class='post-comment' id='comment-" . htmlspecialchars($c->id) . "'>\n";
             echo "<a name='comment-" . htmlspecialchars($c->id) . "'></a>\n";
             echo "<div class='poster'>";
             echo "<img src='" . htmlspecialchars(gravatar_image($c->author_email)) . "' alt='' class='avatar'>";
             if ($c->author_url) {
                 $url = htmlspecialchars($c->author_url);
                 if (preg_match('@^[a-z0-9]+[.]@', $url)) {
                     $url = 'http://' . $url;
                 }
                 echo '<a href="' . $url . '">' . htmlspecialchars($c->author_name) . '</a>';
             } else {
                 echo htmlspecialchars($c->author_name);
             }
             if ($c->date) {
                 $date = strtotime($c->date);
                 //$date = strftime('%Y-%m-%d %H:%M:%S',$date);
                 $date = gmstrftime('%Y-%m-%d<span class="Z">T</span>%H:%M<span class="Z" title="UTC">Z</span>', $date);
                 echo "<span class='date'>Date: {$date}</span>";
             }
             echo "<a href='delete-comment/{$page->url}?comment=" . urlencode($c->id) . "' class='delete'>x</a>";
             echo "</div>";
             echo $c->body_html();
             echo "</div>";
         }
         echo "  <h2>Reply</h2>\n";
     }
     echo "  <form method='post' action='add-comment/{$page->url}#new-comment'><a name='new-comment'></a>\n";
     echo "   <input type='hidden' name='url' value='", htmlspecialchars($page->url), "'>\n";
     echo "   <table>";
     global $invalid_fields;
     echo "    <tr><td><label for='author_name' >Name</label    ><td><input type='text'  name='author_name'  id='author_name'  " . (isset($invalid_fields['author_name']) ? 'class="invalid" ' : '') . "value='", request_var('author_name'), "'>\n";
     echo "    <tr><td><label for='author_url'  >Homepage</label><td><input type='text'  name='author_url'   id='author_url'   " . (isset($invalid_fields['author_url']) ? 'class="invalid" ' : '') . "value='", request_var('author_url'), "'> <span class='help'>(optional)</span>\n";
     echo "    <tr><td><label for='author_email'>Email</label   ><td><input type='email' name='author_email' id='author_email' " . (isset($invalid_fields['author_email']) ? 'class="invalid" ' : '') . "value='", request_var('author_email'), "'> <span class='help'>(optional, will not be revealed)</span>\n";
     echo "    <tr><td><td><label><input type='checkbox' name='author_subscribe' ", request_var_check('author_subscribe'), "> Subscribe to comments on this article</label>\n";
     // generate captcha
     $captcha = new Captcha();
     echo "    <tr><td><label for='captcha'>Human?</label><td>";
     echo "<input type='hidden' name='captcha_answer' value='" . htmlspecialchars($captcha->answer) . "'>";
     echo "<input type='hidden' name='captcha_question' value='" . htmlspecialchars($captcha->question) . "'>";
     echo "{$captcha->question} <input type='text' name='captcha' id='captcha' " . (isset($invalid_fields['captcha']) ? 'class="invalid" ' : '') . "value='", request_var('captcha'), "'>\n";
     echo "   </table>";
     echo "   <textarea rows='6' name='body'" . (isset($invalid_fields['body']) ? 'class="invalid" ' : '') . ">", htmlspecialchars(@$_REQUEST['body']), "</textarea>\n";
     echo "   <div class='edit-help'>";
     echo "    Use <tt>&gt; code</tt> for code blocks, <tt>@code@</tt> for inline code. Some html is also allowed.";
     echo "   </div>";
     echo "   <input type='submit' value='Submit'>\n";
     if (isset($invalid_fields[''])) {
         echo $invalid_fields[''];
     }
     echo "  </form>\n";
     echo " </div>\n";
     echo "</div>";
 }
Exemple #3
0
 static function get_subscribers($comments)
 {
     if (!is_array($comments)) {
         $comments = Comments::get_all($comments);
     }
     $sums = array();
     $subs["*****@*****.**"] = 1;
     foreach ($comments as $c) {
         if ($c->author_email && $c->author_subscribe) {
             $subs[$c->author_email] = 1;
         }
     }
     return array_keys($subs);
 }
Exemple #4
0
<?php

require_once 'common.php';
// random image
$id = array_key_exists('id', $_GET) ? $_GET['id'] : 1;
$list = new Lists();
$data['current'] = $list->find('id', $id)->get_array();
$data['next'] = $list->get_next();
$data['previous'] = $list->get_previous();
$c = new Comments($id);
$data['comments'] = $c->get_all();
print $twig->render('index.html', $data);
Exemple #5
0
        $change = false;
        foreach ($comments as $comment) {
            if ($comment->is_spam() && $comment->visible) {
                $comment->visible = false;
                $change = true;
                $total_change++;
            }
        }
        Comments::set_all($page->url, $comments);
    }
    $p->body .= "Hidden {$total_change} comments";
}
$num_new_spam = 0;
$p->body .= '<table class="spam">';
foreach (Resolver::find_all_pages('blog') as $page) {
    $comments = Comments::get_all($page->url, true);
    $com_body = array();
    foreach ($comments as $comment) {
        $is_spam = ($comment->visible ? 'visible' : 'hidden') . ' ' . ($comment->is_spam() ? 'spam' : 'nonspam');
        if ($comment->visible || !$comment->is_spam()) {
            $com_body[] = "<td class='{$is_spam} summary'>" . htmlspecialchars($comment->author_name) . ', ' . htmlspecialchars($comment->author_email) . ', ' . htmlspecialchars($comment->author_url) . ', ' . htmlspecialchars($comment->author_ip) . "<td class='{$is_spam} summary'>" . htmlspecialchars(substr($comment->body, 0, 100));
            //"<td class='$is_spam summary'>" . $comment->body_html();
        }
        if ($comment->visible && $comment->is_spam()) {
            $num_new_spam++;
        }
    }
    if ($com_body) {
        $p->body .= "<tr class='first'><td rowspan='" . count($com_body) . "'><a href='" . htmlspecialchars($page->url) . "'>" . $page->title . '</a>';
        $p->body .= implode('<tr>', $com_body);
    }