PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/friends.php

https://github.com/minea94/DboorZ
PHP | 120 lines | 105 code | 8 blank | 7 comment | 23 complexity | 55dd1d3a8d756e7a2e45127fc27d92da MD5 | raw file
  1. <?php
  2. /*********************/
  3. /* */
  4. /* Version : 5.1.0 */
  5. /* Author : RM */
  6. /* Comment : 071223 */
  7. /* */
  8. /*********************/
  9. require( ".".DIRECTORY_SEPARATOR."app".DIRECTORY_SEPARATOR."boot.php" );
  10. require_once( MODEL_PATH."friends.php" );
  11. class GPage extends securegamepage
  12. {
  13. public $friends = array( );
  14. public $pageSize = 20;
  15. public $pageIndex = NULL;
  16. public $pageCount = NULL;
  17. public function GPage( )
  18. {
  19. parent::securegamepage( );
  20. $this->viewFile = "friends.phtml";
  21. $this->contentCssClass = "player";
  22. }
  23. public function load( )
  24. {
  25. parent::load( );
  26. $this->pageIndex = isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ? intval( $_GET['p'] ) : 0;
  27. $m = new FriendsModel( );
  28. $rowsCount = $m->getFriendsCount( $this->player->playerId );
  29. $this->pageCount = 0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1;
  30. if ( isset( $_GET['DFid'] ) && !empty( $_GET['DFid'] ) )
  31. {
  32. $FriendID = mysql_real_escape_string( trim( $_GET['DFid'] ) );
  33. if ( $FriendID != "" )
  34. {
  35. $m->DeleteFriend( $FriendID, $this->player->playerId );
  36. $m->dispose( );
  37. $this->redirect( "friends.php" );
  38. }
  39. }
  40. else
  41. {
  42. if ( isset( $_GET['CFid'] ) && !empty( $_GET['CFid'] ) )
  43. {
  44. $ConfirmID = mysql_real_escape_string( trim( $_GET['CFid'] ) );
  45. if ( $ConfirmID != "" )
  46. {
  47. $m->ConfirmInvitation( $ConfirmID, $this->player->playerId );
  48. $m->dispose( );
  49. $this->redirect( "friends.php" );
  50. }
  51. }
  52. else
  53. {
  54. if ( $this->isPost( ) )
  55. {
  56. $post = array( );
  57. $post['playerId1'] = $this->player->playerId;
  58. $post['myname'] = $this->data['name'];
  59. $post['playerName'] = isset( $_POST['playerName'] ) && $_POST['playerName'] != "" ? trim( $_POST['playerName'] ) : trim( $_POST['playerName'] );
  60. if ( $post['playerName'] != "" )
  61. {
  62. $m->SendInvitation( $post );
  63. }
  64. else
  65. {
  66. echo "<pre> Error : Wrong name";
  67. }
  68. $m->dispose( );
  69. }
  70. $this->friends = $m->GetFriends( $this->player->playerId, $this->pageIndex, $this->pageSize );
  71. $m->dispose( );
  72. }
  73. }
  74. }
  75. public function getNextLink( )
  76. {
  77. $text = text_nextpage_lang." »";
  78. if ( $this->pageIndex + 1 == $this->pageCount )
  79. {
  80. return $text;
  81. }
  82. $link = "p=".( $this->pageIndex + 1 );
  83. $link = "friends.php?".$link;
  84. return "<a href=\"".$link."\">".$text."</a>";
  85. }
  86. public function getPreviousLink( )
  87. {
  88. $text = "« ".text_prevpage_lang;
  89. if ( $this->pageIndex == 0 )
  90. {
  91. return $text;
  92. }
  93. $link = "";
  94. if ( 0 < $this->pageIndex )
  95. {
  96. if ( $link != "" )
  97. {
  98. $link .= "&";
  99. }
  100. $link .= "p=".( $this->pageIndex - 1 );
  101. }
  102. if ( $link != "" )
  103. {
  104. $link = "?".$link;
  105. }
  106. $link = "friends.php".$link;
  107. return "<a href=\"".$link."\">".$text."</a>";
  108. }
  109. }
  110. $p = new GPage( );
  111. $p->run( );
  112. ?>