update_notif.php 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. require_once($_SERVER['DOCUMENT_ROOT'] . "/modules/core/header.php");
  3. if(!isset($link))
  4. {
  5. $link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
  6. if($link === false)
  7. {
  8. die("ERROR: Could not connect.");
  9. }
  10. }
  11. $user_check_query = "SELECT `ID`, `title`, `time`, `read`, `friend`, `sender` FROM `notifications` WHERE `master` = '$playersqlid' ORDER BY `ID` DESC LIMIT 4";
  12. $result = mysqli_query($link, $user_check_query);
  13. $notif_counti = $result->num_rows;
  14. $seen_count = 0;
  15. if($notif_counti > 0)
  16. {
  17. $user_check_query = "SELECT `ID` FROM `notifications` WHERE `master` = '$playersqlid' AND `read` = '0' LIMIT 4";
  18. $result2 = mysqli_query($link, $user_check_query);
  19. $seen_count = $result2->num_rows;
  20. }
  21. ?>
  22. <div id="test321"><?php echo $seen_count; ?></div>
  23. <div id="notif_update">
  24. <header _ngcontent-tnh-c150="">
  25. <h2 _ngcontent-tnh-c150="">Notifications</h2><i _ngcontent-tnh-c150="" class="fal fa-fw fa-times fl-ri close cursor-pointer" onclick="toggleNotif()"></i></header>
  26. <ul _ngcontent-tnh-c150="">
  27. <?php
  28. while($result2 = mysqli_fetch_array($result, MYSQLI_ASSOC))
  29. {
  30. $notifidd = $result2['ID'];
  31. $title_nav = $result2['title'];
  32. $time_nav = $result2['time'];
  33. $read_nav = $result2['read'];
  34. $friend_nav = $result2['friend'];
  35. if($friend_nav == 0)
  36. {
  37. ?>
  38. <li _ngcontent-tnh-c150="" id="notfid_<?php echo $notifidd; ?>" class="<?php if($read_nav == 1) { ?>read<?php } else { ?>cursor-pointer<?php } ?>" onClick="document.location.href='./panel/inbox/<?php echo $notifidd; ?>'"><i _ngcontent-tnh-c150="" class="fa fa-fw fa-bell icon"></i><span _ngcontent-tnh-c150="" class="label"> <?php echo $title_nav; ?> <span _ngcontent-tnh-c150="" class="time" title="<?php echo $time_nav; ?>"> <?php echo $time_nav; ?> </span></span>
  39. </li>
  40. <?php
  41. }
  42. else if($friend_nav == -1)
  43. {
  44. $sender_nav = $result2['sender'];
  45. ?>
  46. <li _ngcontent-tnh-c150="" id="notfid_<?php echo $notifidd; ?>" class="<?php if($read_nav == 1) { ?>read<?php } ?> cursor-pointer"><i _ngcontent-tnh-c150="" class="fa fa-fw fa-user-friends icon"></i><span _ngcontent-tnh-c150="" class="label"> <?php echo $sender_nav; ?> approved your friend request <span _ngcontent-tnh-c150="" class="time" title="<?php echo $time_nav; ?>"> <?php echo $time_nav; ?> </span></span>
  47. </li>
  48. <?php
  49. }
  50. else
  51. {
  52. $sender_nav = $result2['sender'];
  53. ?>
  54. <li _ngcontent-tnh-c150="" id="notfid_<?php echo $notifidd; ?>" class="<?php if($read_nav == 1) { ?>read<?php } ?> cursor-pointer" onclick="function_AcceptFriend(<?php echo $friend_nav; ?>)"><i _ngcontent-tnh-c150="" class="fa fa-fw fa-user-friends icon"></i><span _ngcontent-tnh-c150="" class="label"> <?php echo $sender_nav; ?> sent you a friend request <span _ngcontent-tnh-c150="" class="time" title="<?php echo $time_nav; ?>"> <?php echo $time_nav; ?> </span></span>
  55. </li>
  56. <?php
  57. }
  58. $notif_count++;
  59. }
  60. mysqli_free_result($result);
  61. mysqli_close($link);
  62. ?>
  63. <!---->
  64. </ul>
  65. <footer _ngcontent-tnh-c150=""><a _ngcontent-tnh-c150="" href="javascript:void(0);" <?php if($notif_count > 0) { ?>onClick="document.location.href='./mark_all_read.php?lasturl=./panel/inbox<?php } ?>">Mark all read</a> | <a _ngcontent-tnh-c150="" href="javascript:void(0);" onclick="changeCurrentPage('inbox', '/panel/inbox')">Inbox</a> </footer>