Advertisement
Zumina

Untitled

Nov 22nd, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $uids = $_SESSION['user']['id'];
  5. $id = preg_replace('/\D/', '', $_GET['id']);
  6.  
  7. function getPost($uid) {
  8. $sql = "SELECT * FROM cms_comments WHERE author = '$uid'";
  9. $query = mysql_query($sql) or die(mysql_error());
  10. if(mysql_num_rows($query) > 0 && $_SESSION['user']['rank'] < 5) {
  11. return true;
  12. }
  13. else { return false; }
  14. }
  15. if(getPost($uids) == true) { echo 'Du kan bara kommentera en gång!'; }
  16. function post($data, $story, $uid) {
  17. $clean = htmlentities(mysql_real_escape_string($data));
  18. $sql = "INSERT INTO cms_comments (story, comment, date, author) VALUES ('$story', '$clean', '". time() ."', '$uid')";
  19. $query = mysql_query($sql) or die(mysql_error());
  20. }
  21. $posts = getPost($uids);
  22. if(isset($_POST['comment']) && strlen($_POST['comment']) > 0 && strlen($_POST['comment']) < 500 && $posts == false) {
  23. post($_POST['comment'], $id, $uids);
  24. echo '<head><meta http-equiv="refresh" content="0"></head>';
  25. }
  26.  
  27.  
  28.  
  29. $sql = "SELECT * FROM cms_comments WHERE story = '{$id}' ORDER BY id DESC";
  30. $query = mysql_query($sql) or die(mysql_error());
  31.  
  32. while($ua = mysql_fetch_array($query)) {
  33. $uiq = mysql_query("SELECT * FROM users WHERE id = ". $ua['author']) or die(mysql_error());
  34. $ui = mysql_fetch_array($uiq) or die(mysql_error());
  35.  
  36. if($ui['rank'] >= 7) { $username = ''. $ui['username'] .'';}
  37. else { $username = '<span style="font-family:Arial,Helvetica,sans-serif;">'. $ui['username'] .'</span>'; }
  38.  
  39. if($ui['rank'] > 5) { $bg = 'style="border-top: 1px dashed #cccccc;padding: 10px 0;margin-bottom: -1px;text-align: left;';}
  40. else {$bg = 'style="';}
  41.  
  42. echo '
  43. <div class="badge-div" style="float:left;">
  44. <div class="badge-content" style="float:left;margin-right: 8px;">
  45. <label>'. $username .'</label>' . $ua['comment'] . '</div>
  46. <div class="badge-container" style="overflow:hidden;background: url(/app/tpl/skins/habbo/images/bg2/' . $ui['bg2'] . '.png) bottom center;">
  47. <div class="badge-img shadow" style="height:70px;background-image:url(http://habbo.it/habbo-imaging/avatarimage?figure=' . $ui['look'] . '&' . $ui['effect'] . 'direction=2&amp;head_direction=2gesture=sml)">
  48. </div></div><br clear="all"></div>
  49.  
  50.  
  51.  
  52.  
  53. ';
  54.  
  55. }
  56.  
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement