Example #1
0
function discuss($ID)
{
    global $comments_disabled_after;
    $preview = ps('preview');
    extract(safe_row("Annotate,AnnotateInvite,unix_timestamp(Posted) as uPosted", "textpattern", "ID='{$ID}'"));
    $darr = !$preview ? fetchComments($ID) : array(psas(array('name', 'email', 'web', 'message', 'parentid', 'remember')));
    $out = n . '<h3 style="margin-top:2em" id="comment">' . $AnnotateInvite . '</h3>' . n;
    if ($darr) {
        $out .= '<ol>' . n;
        $out .= formatComments($darr);
        $out .= n . '</ol>';
    }
    $wasAnnotated = !$Annotate ? getCount('txp_discuss', "parentid={$ID}") : '';
    if (!$Annotate) {
        $out .= graf(gTxt("comments_closed"));
    } else {
        if ($comments_disabled_after) {
            $lifespan = $comments_disabled_after * 86400;
            $timesince = time() - $uPosted;
            if ($lifespan > $timesince) {
                $out .= commentForm($ID);
            } else {
                $out .= graf(gTxt("comments_closed"));
            }
        } else {
            $out .= commentForm($ID);
        }
    }
    return $out;
}
Example #2
0
			<p class="errorbox"><?php 
        echo gettext('Comment does not exist');
        ?>
</p>
			<?php 
    }
} else {
    // Set up some view option variables.
    if (isset($_GET['fulltext']) && $_GET['fulltext']) {
        $fulltext = true;
        $fulltexturl = '?fulltext = 1';
    } else {
        $fulltext = false;
        $fulltexturl = '';
    }
    $allcomments = fetchComments(NULL);
    $pagenum = max((int) @$_GET['subpage'], 1);
    $comments = array_slice($allcomments, ($pagenum - 1) * COMMENTS_PER_PAGE, COMMENTS_PER_PAGE);
    $allcommentscount = count($allcomments);
    $totalpages = ceil($allcommentscount / COMMENTS_PER_PAGE);
    unset($allcomments);
    ?>
		<h1><?php 
    echo gettext("Comments");
    ?>
</h1>

		<?php 
    zp_apply_filter('admin_note', '  comments', '  list');
    /* Display a message if needed. Fade out and hide after 2 seconds. */
    if (isset($_GET['bulk'])) {
Example #3
0
			</div>
			<div id="overview-maint_r">
			<?php 
        }
    }
    ?>
	</div>
</div>
<div class="box" id="overview-maint">
<h2 class="h2_bordered"><?php 
    echo gettext("10 Most Recent Comments");
    ?>
</h2>
<ul>
<?php 
    $comments = fetchComments(10);
    foreach ($comments as $comment) {
        $id = $comment['id'];
        $author = $comment['name'];
        $email = $comment['email'];
        $link = gettext('<strong>database error</strong> ');
        // incase of such
        // establish default values for all these fields in case of an error.
        if (getOption("zp_plugin_zenpage")) {
            require_once dirname(__FILE__) . '/plugins/zenpage/zenpage-class-page.php';
            require_once dirname(__FILE__) . '/plugins/zenpage/zenpage-class-news.php';
        }
        // ZENPAGE: switch added for zenpage comment support
        switch ($comment['type']) {
            case "albums":
                $image = '';
Example #4
0
/**
 * Generic comment adding routine. Called by album objects or image objects
 * to add comments.
 *
 * Returns a code for the success of the comment add:
 *    0: Bad entry
 *    1: Marked for moderation
 *    2: Successfully posted
 *
 * @param string $name Comment author name
 * @param string $email Comment author email
 * @param string $website Comment author website
 * @param string $comment body of the comment
 * @param string $code Captcha code entered
 * @param string $code_ok Captcha md5 expected
 * @param string $type 'albums' if it is an album or 'images' if it is an image comment
 * @param object $receiver the object (image or album) to which to post the comment
 * @param string $ip the IP address of the comment poster
 * @param bool $private set to true if the comment is for the admin only
 * @param bool $anon set to true if the poster wishes to remain anonymous
 * @return int
 */
function postComment($name, $email, $website, $comment, $code, $code_ok, $receiver, $ip, $private, $anon)
{
    global $_zp_captcha;
    $result = commentObjectClass($receiver);
    list($type, $class) = $result;
    $receiver->getComments();
    $name = trim($name);
    $email = trim($email);
    $website = trim($website);
    $admins = getAdministrators();
    $admin = array_shift($admins);
    $key = $admin['pass'];
    // Let the comment have trailing line breaks and space? Nah...
    // Also (in)validate HTML here, and in $name.
    $comment = trim($comment);
    if (getOption('comment_email_required') && (empty($email) || !is_valid_email_zp($email))) {
        return -2;
    }
    if (getOption('comment_name_required') && empty($name)) {
        return -3;
    }
    if (getOption('comment_web_required') && (empty($website) || !isValidURL($website))) {
        return -4;
    }
    if (getOption('Use_Captcha')) {
        if (!$_zp_captcha->checkCaptcha($code, $code_ok)) {
            return -5;
        }
    }
    if (empty($comment)) {
        return -6;
    }
    if (!empty($website) && substr($website, 0, 7) != "http://") {
        $website = "http://" . $website;
    }
    $goodMessage = 2;
    $gallery = new gallery();
    if (!(false === ($requirePath = getPlugin('spamfilters/' . UTF8ToFileSystem(getOption('spam_filter')) . ".php", false)))) {
        require_once $requirePath;
        $spamfilter = new SpamFilter();
        $goodMessage = $spamfilter->filterMessage($name, $email, $website, $comment, isImageClass($receiver) ? $receiver->getFullImage() : NULL, $ip);
    }
    if ($goodMessage) {
        if ($goodMessage == 1) {
            $moderate = 1;
        } else {
            $moderate = 0;
        }
        if ($private) {
            $private = 1;
        } else {
            $private = 0;
        }
        if ($anon) {
            $anon = 1;
        } else {
            $anon = 0;
        }
        $receiverid = $receiver->id;
        // Update the database entry with the new comment
        query("INSERT INTO " . prefix("comments") . " (`ownerid`, `name`, `email`, `website`, `comment`, `inmoderation`, `date`, `type`, `ip`, `private`, `anon`) VALUES " . ' ("' . $receiverid . '", "' . mysql_real_escape_string($name) . '", "' . mysql_real_escape_string($email) . '", "' . mysql_real_escape_string($website) . '", "' . mysql_real_escape_string($comment) . '", "' . $moderate . '", NOW()' . ', "' . $type . '", "' . $ip . '", "' . $private . '", "' . $anon . '")');
        if ($moderate) {
            $action = "placed in moderation";
        } else {
            //  add to comments array and notify the admin user
            $newcomment = array();
            $newcomment['name'] = $name;
            $newcomment['email'] = $email;
            $newcomment['website'] = $website;
            $newcomment['comment'] = $comment;
            $newcomment['date'] = time();
            $receiver->comments[] = $newcomment;
            $action = "posted";
        }
        // switch added for zenpage support
        $class = get_class($receiver);
        switch ($class) {
            case "Albums":
                $on = $receiver->name;
                $url = "album=" . urlencode($receiver->name);
                $ur_album = getUrAlbum($receiver);
                break;
            case "ZenpageNews":
                $on = $receiver->getTitlelink();
                $url = "p=" . ZENPAGE_NEWS . "&title=" . urlencode($receiver->getTitlelink());
                break;
            case "ZenpagePage":
                $on = $receiver->getTitlelink();
                $url = "p=" . ZENPAGE_PAGES . "&title=" . urlencode($receiver->getTitlelink());
                break;
            default:
                // all image types
                $on = $receiver->getAlbumName() . " about " . $receiver->getTitle();
                $url = "album=" . urlencode($receiver->album->name) . "&image=" . urlencode($receiver->filename);
                $album = $receiver->getAlbum();
                $ur_album = getUrAlbum($album);
                break;
        }
        if (getOption('email_new_comments')) {
            $last_comment = fetchComments(1);
            $last_comment = $last_comment[0]['id'];
            $message = gettext("A comment has been {$action} in your album") . " {$on}\n" . "\n" . "Author: " . $name . "\n" . "Email: " . $email . "\n" . "Website: " . $website . "\n" . "Comment:\n" . $comment . "\n" . "\n" . "You can view all comments about this image here:\n" . "http://" . $_SERVER['SERVER_NAME'] . WEBPATH . "/index.php?{$url}\n" . "\n" . "You can edit the comment here:\n" . "http://" . $_SERVER['SERVER_NAME'] . WEBPATH . "/" . ZENFOLDER . "/admin-comments.php?page=editcomment&id={$last_comment}\n";
            $emails = array();
            $admin_users = getAdministrators();
            foreach ($admin_users as $admin) {
                // mail anyone else with full rights
                if ($admin['rights'] & ADMIN_RIGHTS && $admin['rights'] & COMMENT_RIGHTS && !empty($admin['email'])) {
                    $emails[] = $admin['email'];
                    unset($admin_users[$admin['id']]);
                }
            }
            // take out for zenpage comments since there are no album admins
            if ($type === "images" or $type === "albums") {
                $id = $ur_album->getAlbumID();
                $sql = "SELECT `adminid` FROM " . prefix('admintoalbum') . " WHERE `albumid`={$id}";
                $result = query_full_array($sql);
                foreach ($result as $anadmin) {
                    $admin = $admin_users[$anadmin['adminid']];
                    if (!empty($admin['email'])) {
                        $emails[] = $admin['email'];
                    }
                }
            }
            zp_mail("[" . get_language_string(getOption('gallery_title'), getOption('locale')) . "] Comment posted on {$on}", $message, "", $emails);
        }
    }
    return $goodMessage;
}
Example #5
0
 //then likes
 $sql2 = 'SELECT username, picture_id FROM likes';
 $records2 = $db->prepare($sql2, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
 $records2->execute();
 $likes = $records2->fetchAll();
 //and finally comments
 $sql3 = 'SELECT username, picture_id, comment, date_published FROM Comments';
 $records3 = $db->prepare($sql3, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
 $records3->execute();
 $comments = $records3->fetchAll();
 $found = -1;
 for ($index = 0; $index < count($pictures); $index++) {
     if ($pictures[$index]["id"] == $pic_id) {
         $found = $index;
         $pic_likes = fetchLikes($pictures[$index]["id"], $likes);
         $pic_comments = fetchComments($pictures[$index]["id"], $comments);
         break;
     }
 }
 if ($found > -1) {
     $username = $_SESSION['username'];
     $response = array();
     $response[0] = $username;
     $response[1] = $pictures[$found]["title"];
     $response[2] = $pictures[$found]["date"];
     $response[3] = $pictures[$found]["username"];
     $response[4] = $pictures[$found]["id"];
     $response[5] = $pic_likes;
     $response[6] = $pic_comments;
     echo json_encode($response);
 } else {
Example #6
0
/**
 * Admin overview summary
 */
function comment_form_print10Most()
{
    ?>
	<div class="box overview-utility">
		<h2 class="h2_bordered"><?php 
    echo gettext("10 Most Recent Comments");
    ?>
</h2>
		<ul>
			<?php 
    $comments = fetchComments(10);
    foreach ($comments as $comment) {
        $id = $comment['id'];
        $author = $comment['name'];
        $email = $comment['email'];
        $link = gettext('<strong>database error</strong> ');
        // incase of such
        // ZENPAGE: switch added for zenpage comment support
        switch ($comment['type']) {
            case "albums":
                $album = getItemByID('albums', $comment['ownerid']);
                if ($album) {
                    $link = "<a href=\"" . $album->getlink() . "\">" . $album->gettitle() . "</a>";
                }
                break;
            case "news":
                // ZENPAGE: if plugin is installed
                if (extensionEnabled('zenpage')) {
                    $news = getItemByID('news', $comment['ownerid']);
                    if ($news) {
                        $link = "<a href=\"" . $news->getLink() . "\">" . $news->getTitle() . "</a> " . gettext("[news]");
                    }
                }
                break;
            case "pages":
                // ZENPAGE: if plugin is installed
                if (extensionEnabled('zenpage')) {
                    $page = getItemByID('pages', $comment['ownerid']);
                    if ($page) {
                        $link = "<a href=\"" . $page->getlink() . "\">" . $page->getTitle() . "</a> " . gettext("[page]");
                    }
                }
                break;
            default:
                // all of the image types
                $image = getItemByID('images', $comment['ownerid']);
                if ($image) {
                    $link = "<a href=\"" . $image->getLink() . "\">" . $image->getTitle() . "</a>";
                }
                break;
        }
        $comment = shortenContent($comment['comment'], 123, '...');
        echo "<li><div class=\"commentmeta\">" . sprintf(gettext('<em>%1$s</em> commented on %2$s:'), $author, $link) . "</div><div class=\"commentbody\">{$comment}</div></li>";
    }
    ?>
		</ul>
	</div>
	<?php 
}
Example #7
0
/**
 * Admin overview summary
 */
function comment_form_print10Most($side)
{
    if ($side == 'right') {
        ?>
		<div class="box" id="overview-comments">
		<h2 class="h2_bordered"><?php 
        echo gettext("10 Most Recent Comments");
        ?>
</h2>
		<ul>
		<?php 
        $comments = fetchComments(10);
        foreach ($comments as $comment) {
            $id = $comment['id'];
            $author = $comment['name'];
            $email = $comment['email'];
            $link = gettext('<strong>database error</strong> ');
            // incase of such
            // ZENPAGE: switch added for zenpage comment support
            switch ($comment['type']) {
                case "albums":
                    $image = '';
                    $title = '';
                    $albmdata = query_full_array("SELECT `title`, `folder` FROM " . prefix('albums') . " WHERE `id`=" . $comment['ownerid']);
                    if ($albmdata) {
                        $albumdata = $albmdata[0];
                        $album = $albumdata['folder'];
                        $albumtitle = get_language_string($albumdata['title']);
                        $link = "<a href=\"" . rewrite_path("/{$album}", "/index.php?album=" . pathurlencode($album)) . "\">" . $albumtitle . $title . "</a>";
                        if (empty($albumtitle)) {
                            $albumtitle = $album;
                        }
                    }
                    break;
                case "news":
                    // ZENPAGE: if plugin is installed
                    if (getOption("zp_plugin_zenpage")) {
                        $titlelink = '';
                        $title = '';
                        $newsdata = query_full_array("SELECT `title`, `titlelink` FROM " . prefix('news') . " WHERE `id`=" . $comment['ownerid']);
                        if ($newsdata) {
                            $newsdata = $newsdata[0];
                            $titlelink = $newsdata['titlelink'];
                            $title = get_language_string($newsdata['title']);
                            $link = "<a href=\"" . rewrite_path("/news/" . $titlelink, "/index.php?p=news&amp;title=" . urlencode($titlelink)) . "\">" . $title . "</a> " . gettext("[news]");
                        }
                    }
                    break;
                case "pages":
                    // ZENPAGE: if plugin is installed
                    if (getOption("zp_plugin_zenpage")) {
                        $image = '';
                        $title = '';
                        $pagesdata = query_full_array("SELECT `title`, `titlelink` FROM " . prefix('pages') . " WHERE `id`=" . $comment['ownerid']);
                        if ($pagesdata) {
                            $pagesdata = $pagesdata[0];
                            $titlelink = $pagesdata['titlelink'];
                            $title = get_language_string($pagesdata['title']);
                            $link = "<a href=\"" . rewrite_path("/pages/" . $titlelink, "/index.php?p=pages&amp;title=" . urlencode($titlelink)) . "\">" . $title . "</a> " . gettext("[page]");
                        }
                    }
                    break;
                default:
                    // all of the image types
                    $imagedata = query_full_array("SELECT `title`, `filename`, `albumid` FROM " . prefix('images') . " WHERE `id`=" . $comment['ownerid']);
                    if ($imagedata) {
                        $imgdata = $imagedata[0];
                        $image = $imgdata['filename'];
                        if ($imgdata['title'] == "") {
                            $title = $image;
                        } else {
                            $title = get_language_string($imgdata['title']);
                        }
                        $title = '/ ' . $title;
                        $albmdata = query_full_array("SELECT `folder`, `title` FROM " . prefix('albums') . " WHERE `id`=" . $imgdata['albumid']);
                        if ($albmdata) {
                            $albumdata = $albmdata[0];
                            $album = $albumdata['folder'];
                            $albumtitle = get_language_string($albumdata['title']);
                            $link = "<a href=\"" . rewrite_path("/{$album}/{$image}", "/index.php?album=" . pathurlencode($album) . "&amp;image=" . urlencode($image)) . "\">" . $albumtitle . $title . "</a>";
                            if (empty($albumtitle)) {
                                $albumtitle = $album;
                            }
                        }
                    }
                    break;
            }
            $comment = truncate_string($comment['comment'], 123);
            echo "<li><div class=\"commentmeta\">" . sprintf(gettext('<em>%1$s</em> commented on %2$s:'), $author, $link) . "</div><div class=\"commentbody\">{$comment}</div></li>";
        }
        ?>
		</ul>
		</div>
		<?php 
    }
    return $side;
}