vaulient2
New Member
- Mar 12, 2013
- 27
- 3
Code:
<?PHP
$p1 = 5;
$pages = mysql_query("SELECT COUNT(id) FROM cms_comments");
$p2 = ceil(mysql_result($pages, 0) / $p1);
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $p1;
$uids = $_SESSION['user']['id'];
$id = preg_replace('/\D/', '', $_GET['id']);
function getPost($uid) {
$sql = "SELECT * FROM cms_comments WHERE author = '$uid' LIMIT $start, $p1";
$query = mysql_query($sql) or die(mysql_error());
$nummy = mysql_query("SELECT * FROM cms_comments");
$numrows = mysql_num_rows($nummy);
if(mysql_num_rows($query) > 0 && $_SESSION['user']['rank'] < 0) {
return true;
}
else { return false; }
}
if(getPost($uids) == true) { echo 'You may only post once!'; }
function post($data, $story, $uid) {
$clean = htmlentities(mysql_real_escape_string($data));
$sql = "INSERT INTO cms_comments (story, comment, date, author) VALUES ('$story', '$clean', '". time() ."', '$uid')";
$query = mysql_query($sql) or die(mysql_error());
}
$posts = getPost($uids);
if(isset($_POST['comment']) && strlen($_POST['comment']) > 0 && strlen($_POST['comment']) < 500 && $posts == false) {
post($_POST['comment'], $id, $uids);
echo '<head><meta http-equiv="refresh" content="0"></head>';
}
$sql = "SELECT * FROM cms_comments WHERE story = '{$id}' ORDER BY id DESC";
$query = mysql_query($sql) or die(mysql_error());
while($ua = mysql_fetch_array($query)) {
$uiq = mysql_query("SELECT * FROM users WHERE id = ". $ua['author']) or die(mysql_error());
$ui = mysql_fetch_array($uiq) or die(mysql_error());
if($ui['rank'] >= 10) { $username = '<span style="font-family:Arial,Helvetica,sans-serif; color: #7D0A79;text-shadow: 0px 0px 5px #343434;background:url(/app/tpl/skins/Custom-Habbo/images/glitter.gif);">'. $ui['username'] .'</span>';}
else { $username = '<span style="font-family:Arial,Helvetica,sans-serif;">'. $ui['username'] .'</span>'; }
if($ui['rank'] >= 6) { $username = '<span style="font-family:Arial,Helvetica,sans-serif; color: #7D0A79;text-shadow: 0px 0px 5px #343434;background:url(/app/tpl/skins/Custom-Habbo/images/glitter.gif);">'. $ui['username'] .'</span>';}
else { $username = '<span style="font-family:Arial,Helvetica,sans-serif;">'. $ui['username'] .'</span>'; }
}
echo "Pages: ";
if($p2 >= 1 && $page <= $p2){
for($x=1; $x<=$p2; $x++) {
echo ($x == $page) ? '<strong><a href="?page='.$x.'">'.$x.'</a></strong> ' : '<a href="?page='.$x.'">'.$x.'</a> ';
}
}
?>