Example #1
0
<?php

// Present a single comment feed in raw html
// Used by script.php but can also be used directly
if (!isset($sid)) {
    die('Missing sid');
}
require_once 'shared.php';
$site = GetSiteConstants($sid, false);
if (urlError) {
    echo '<div class="commentError">' . urlError . '</div>';
    return;
}
$session = GetSessionConstants();
// Read comments
$query = 'SELECT * FROM Comments
 WHERE SiteID = ' . $sid . ' AND Page = \'' . mysql_real_escape_string($page) . '\'
 AND VerifiedDate IS NOT NULL
 ORDER BY CommentDate ASC';
$result = @mysql_query($query) or die(mysql_error());
//Style
echo '<style type="text/css">';
require 'comments.css';
echo '</style>';
//Feed icon
echo '<div class="commentFeed"><a href="' . service_url . '/inc/' . $sid . '/' . str_replace('+', '%20', urlencode($page)) . '.xml"><img src="' . service_url . '/feed.png" /></a></div>';
$count = mysql_num_rows($result);
if ($count === 0) {
    echo '<p>No comments</p>';
} elseif ($count === 1) {
    echo '<p>One comment</p>';
Example #2
0
//Allow cross site posting, enable other sites to use your service
//Remove these two header lines if you only use the service from the same site.
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
if (isset($_GET['sid'])) {
    $sid = intval($_GET['sid']);
} else {
    $sid = 0;
}
if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = null;
}
require_once 'shared.php';
$site = GetSiteConstants($sid);
if (!isset($_REQUEST['ajax'])) {
    echo '<div><a href="' . service_url . '/inc/' . $sid . '/' . urlencode($page) . '.html">back</a></div>';
}
if (urlError) {
    echo '<div class="commentError">' . urlError . '</div>';
    return;
}
$commentText = trim($_POST['commentText']);
$commentEmail = filter_var($_POST['commentEmail'], FILTER_SANITIZE_EMAIL);
$commentEmail = strtolower($commentEmail);
//Set email cookie to autofill the email field
$url = parse_url(service_url);
setcookie("email", $commentEmail, time() + 3600 * 365, $url['path'], $url['host'], $url['scheme'] === "https", false);
//Verify input
if (strlen($commentText) === 0) {