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

/advertising.php

https://github.com/minea94/DboorZ
PHP | 115 lines | 100 code | 8 blank | 7 comment | 29 complexity | 68787931eb8ad902fff5c0382f636a7c 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."advertising.php" );
  11. class GPage extends securegamepage
  12. {
  13. public $isAdmin = FALSE;
  14. public $Advertisings = array( );
  15. public $pageSize = 20;
  16. public $pageIndex = NULL;
  17. public $pageCount = NULL;
  18. public function GPage( )
  19. {
  20. parent::securegamepage( );
  21. $this->viewFile = "advertising.phtml";
  22. $this->contentCssClass = "player";
  23. }
  24. public function load( )
  25. {
  26. parent::load( );
  27. $this->pageIndex = isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ? intval( $_GET['p'] ) : 0;
  28. $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
  29. if ( !$this->isAdmin )
  30. {
  31. exit( 0 );
  32. }
  33. else
  34. {
  35. $m = new AdvertisingModel( );
  36. $rowsCount = $m->getAdvertisingCount( );
  37. $this->pageCount = 0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1;
  38. if ( isset( $_GET['DAdv'] ) && !empty( $_GET['DAdv'] ) )
  39. {
  40. $advID = mysql_real_escape_string( trim( $_GET['DAdv'] ) );
  41. if ( $advID != "" )
  42. {
  43. $m->DeleteAdvertising( $advID );
  44. $m->dispose( );
  45. $this->redirect( "advertising.php" );
  46. }
  47. }
  48. else if ( $this->isPost( ) )
  49. {
  50. $post = array( );
  51. $type = isset( $_POST['do'] ) && $_POST['do'] != "add" ? "edit" : "add";
  52. $post['name'] = "SPSLink.NET";
  53. $post['url'] = isset( $_POST['url'] ) && $_POST['url'] != "" ? mysql_real_escape_string( trim( $_POST['url'] ) ) : "http://www.spslink.net";
  54. $post['cat'] = isset( $_POST['cat'] ) && $_POST['cat'] != "" ? mysql_real_escape_string( trim( $_POST['cat'] ) ) : "1";
  55. $post['image'] = isset( $_POST['image'] ) && $_POST['image'] != "" ? mysql_real_escape_string( trim( $_POST['image'] ) ) : "assets/default/img/characters.png";
  56. $ext = strtolower( end( explode( ".", mysql_real_escape_string( trim( $post['image'] ) ) ) ) );
  57. $post['type'] = $ext == "swf" ? "flash" : "image";
  58. $post['ID'] = isset( $_POST['ID'] ) && $_POST['ID'] != "" ? mysql_real_escape_string( trim( $_POST['ID'] ) ) : 0;
  59. $m->Advertising( $post, $type );
  60. $m->dispose( );
  61. $this->redirect( "advertising.php" );
  62. }
  63. else
  64. {
  65. $this->Advertisings = $m->GetAdvertisings( $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 = "advertising.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 = "advertising.php".$link;
  102. return "<a href=\"".$link."\">".$text."</a>";
  103. }
  104. }
  105. $p = new GPage( );
  106. $p->run( );
  107. ?>