Просмотр файла modules/friends/index.php

Размер файла: 1.93Kb
  1. <?php
  2. if(!isset($user)) {
  3. header('location: /');
  4. exit;
  5. }
  6. if($db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '1'")->rowCount() != 0)
  7. {
  8. $friends_r = $db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '1'")->rowCount();
  9. }
  10. else
  11. {
  12. $friends_r = $db->query("SELECT * FROM `friends` WHERE `user_id` = '". $user['id'] ."' AND `active` = '1'")->rowCount();
  13. }
  14. $title = $lang->word('friends');
  15. require_once(SYS.'/view/header.php');
  16. $tpl->div('title', $lang->word('friends').' ('.$friends_r.')');
  17.  
  18. $pages = new Paginator($friends_r, $ames);
  19. if($friends_r == 0)
  20. {
  21. $tpl->div('menu', $lang->word('friends_no'));
  22. }
  23. else
  24. {
  25. if( $db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '1'")->rowCount() !=0)
  26. {
  27. $friends_q = $db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '1' ORDER BY friend_id DESC LIMIT $start, $ames");
  28. }
  29. else
  30. {
  31. $friends_q = $db->query("SELECT * FROM `friends` WHERE `user_id` = '". $user['id'] ."' AND `active` = '1' ORDER BY friend_id DESC LIMIT $start, $ames");
  32. }
  33. while($friends = $friends_q->fetch())
  34. {
  35. if($friends['user_id'] == $user['id'])
  36. {
  37. $friend_id = $friends['friend_id'];
  38. }
  39. else
  40. {
  41. $friend_id = $friends['user_id'];
  42. }
  43. echo '<div class="menu">
  44. '.nick($friend_id).' [<a href="/friends/delete/'.$friends['id'].'">x</a>]
  45. </div>';
  46. }
  47. $pages->view('/friends/?');
  48. }
  49. $tpl->div('block', NAV.' <a href="/friends/requests">'.$lang->word('friends_requests').'</a> ('.$db->query("SELECT * FROM `friends` WHERE `friend_id` = '". $user['id'] ."' AND `active` = '0'")->rowCount().')<br/> '
  50. . NAV . ' <a href="/user/panel/">'.$lang->word('user_panel').'</a><br/> '
  51. . HICO. ' <a href="/">'. $lang->word('home') .'</a>');
  52. require_once(SYS.'/view/footer.php');
  53. ?>