PageRenderTime 57ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/badwords.php

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