Beispiel #1
0
    $signxorderpseconds = $signxorder + $seconds;
    $score = round($signxorderpseconds / 45000, 7);
    return $score;
}
$query = $conn->prepare("SELECT * FROM posts ORDER BY id DESC LIMIT 100");
$query->execute();
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $postid = $row['postid'];
    $userid = $row['user'];
    $title = $row['title'];
    $tagling = $row['tagline'];
    $link = $row['link'];
    $post_time = $row['post_time'];
    $total_votes = totalvotes($postid, $conn);
    $hotrank = getscore($total_votes, $post_time);
    $isvoted = isuservoted($postid, $conn);
    $gu = $conn->prepare("SELECT * FROM users WHERE userid = :id LIMIT 1");
    $gu->execute(array(':id' => $userid));
    $gur = $gu->fetch(PDO::FETCH_ASSOC);
    $user_name = $gur['name'];
    $user_propic = $gur['propic'];
    $gcoms = totalcomments($postid, $conn);
    $allposts[] = ['datalink' => $postid, 'user_id' => $userid, 'upropic' => $user_propic, 'user' => $user_name, 'title' => $title, 'tag_line' => $tagling, 'post_url' => $link, 'votecount' => $total_votes, 'hot_rank' => $hotrank, 'isVoted' => $isvoted, 'post_time' => $post_time, 'num_comments' => $gcoms];
}
usort($allposts, function ($a, $b) {
    return $a['hot_rank'] < $b['hot_rank'] ? -1 : 1;
    //   return $a['hot_rank'] - $b['hot_rank'];
});
$rsl = array_reverse($allposts);
$sl = array_slice($rsl, 0, 20);
if (isset($_REQUEST['pre'])) {
Beispiel #2
0
<?php

//Get details of each post
session_start();
require_once 'mysql.php';
require_once 'functions.php';
$id = strip_tags($_GET['postid']);
$query = $conn->prepare("SELECT * FROM posts WHERE postid = :id LIMIT 1");
$query->execute(array(':id' => $id));
$row = $query->fetch(PDO::FETCH_ASSOC);
if ($row == true) {
    $title = $row['title'];
    $tagline = $row['tagline'];
    $link = $row['link'];
    $time = $row['post_time'];
    $user = $row['user'];
    $query = $conn->prepare("SELECT * FROM users WHERE userid = :user LIMIT 1");
    $query->execute(array(':user' => $user));
    $getuser = $query->fetch(PDO::FETCH_ASSOC);
    $user_name = $getuser['name'];
    $pro_pic = $getuser['propic'];
    $isvoted = isuservoted($id, $conn);
    $total_votes = totalvotes($id, $conn);
    $post_status = ['title' => $title, 'tagline' => $tagline, 'isVoted' => $isvoted, 'datalink' => $id, 'user' => $user_name, 'upropic' => $pro_pic, 'votecount' => $total_votes, 'post_date' => $time, 'post_url' => $link];
    $post_status = json_encode($post_status);
    print $post_status;
} else {
    print "nopost";
}