示例#1
0
<?php

include "../config.php";
include "../functions.php";
include "../private_functions.php";
if (isset($_GET['pID'])) {
    $dbh = db_connect($MY_HOST, $MY_DB_PORT, $MY_DB, $DB_USER, $DB_PW);
    $resp = get_num_votes($dbh, $_GET['pID']);
    close_db_connection($dbh);
    echo json_encode($resp);
} else {
    echo json_encode(array("status" => -1));
}
示例#2
0
function html_post($dbh, $post)
{
    $votes = get_num_votes($dbh, $post['pID']);
    $num_votes = $votes['count'];
    echo '<div id="post-' . $post['pID'] . '" class="row post">
			<div class="col-md-3">' . user_link($post['username']) . '</div>
			<div class="col-md-9">' . htmlentities($post['title']) . '<span style="font-size:12px; color: #888; padding:5px; padding-left: 10px;">' . format_post_time($post['time']) . '</span>
      <span style="font-size:12px; color: #888; padding:5px; padding-left: 10px;">' . $num_votes . ' votes</span>
      <button class="btn btn-xs btn-primary" onclick="vote(\'' . $post['pID'] . '\', this);" type="button">vote</button>
      <button class="btn btn-xs btn-primary" onclick="unvote(\'' . $post['pID'] . '\', this);" type="button">unvote</button>
      </div>

      		<div class="col-md-3"><span style="font-size:16px;">Loc:(' . htmlentities($post['coorX']) . ',' . htmlentities($post['coorY']) . ')</span></div>
			<div class="col-md-9"><span style="font-size:16px;">' . htmlentities($post['content']) . '</span><span style="font-size:12px; color: #888; padding:5px; padding-left: 10px;"></span></div>
		</div>';
}