PageRenderTime 35ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Quản lý website shop bán domain hosting PHP/admin/advert/bannerList.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 125 lines | 81 code | 25 blank | 19 comment | 10 complexity | 745342fd9c70768b333db5c4cd45af01 MD5 | raw file
  1. <?php
  2. /*-----------------------------------
  3. | LIST OF BANNER SHOWS ON TOP
  4. -------------------------------------*/
  5. // Check for security
  6. if (!defined('HCR'))
  7. {
  8. print '<h1>Incorrect Access!</h1>';
  9. exit();
  10. }
  11. $cnt = new content;
  12. class content{
  13. public $title = "Danh sách banner";
  14. public $text = "";
  15. private $process = "";
  16. private $frmValue = array('update' => '');
  17. private $page = "";
  18. function __construct()
  19. {
  20. global $str, $sess, $db;
  21. $this->get_input();
  22. // Delete banner from list
  23. if ($this->process == 'delBanner')
  24. {
  25. unlink(B_IMG.$_GET['bname']);
  26. // Update xml file
  27. require_once 'fw.php';
  28. }
  29. $this->text = $this->show_form($this->frmValue);
  30. }
  31. /*----------------------------------------
  32. | SHOW FORM
  33. + ----------------------------------------*/
  34. function show_form($frmValue)
  35. {
  36. global $frm, $db, $str, $sess, $time, $token, $hpaging, $paging_info;
  37. $text = '<link rel="stylesheet" href="'. DIR_LIGHTBOX .'css/lightbox.css" type="text/css" media="screen" />
  38. <script src="'. DIR_LIGHTBOX .'js/prototype.js" type="text/javascript"></script>
  39. <script src="'. DIR_LIGHTBOX .'js/scriptaculous.js?load=effects" type="text/javascript"></script>
  40. <script src="'. DIR_LIGHTBOX .'js/lightbox.js" type="text/javascript"></script>';
  41. // Prepare the form
  42. $text .= $frm->draw_form("", "", 2, "POST", "frm_Banner");
  43. $text .= "<div class='div_add'>
  44. <img src='". ADMIN_IMG ."add.png' border='0'/>
  45. <a href='?mod=bannerAdd' class='topadd'>Upload banner</a>
  46. &nbsp;|&nbsp;
  47. <img src='". ADMIN_IMG ."refresh.png' border='0' align='absmiddle'/>
  48. <a href='?mod=bannerList' class='topadd'>Refresh</a>
  49. </div><br/>";
  50. $text .= "<table cellspacing='0' cellpadding='6' class='tbl_main' align='center'>";
  51. $text .= "<tr class='trc'>
  52. <td>Banner</td>
  53. <td>Chọn xóa&nbsp;<input type='checkbox' name='banid' value='ON' onclick='CheckAll();'></td>
  54. </tr>";
  55. // Get list of banner unde libbanner/banner/
  56. $needToRead = B_IMG;
  57. $img_array = array();
  58. // List of file type to filter
  59. $type = array('.gif', '.jpg', '.jpeg');
  60. // Open directory
  61. if ($handle = opendir($needToRead))
  62. {
  63. // Read all file in this directory
  64. while (false !== ($file = readdir($handle)))
  65. {
  66. // Exclude system file
  67. if ($file != "." && $file != "..")
  68. {
  69. // Get file extention
  70. $extention = strtolower(strrchr($file,'.'));
  71. if (in_array($extention, $type))
  72. {
  73. $img_array[] = $file;
  74. }
  75. }
  76. }
  77. closedir($handle);
  78. }
  79. $count = 0;
  80. foreach ($img_array as $k=>$v)
  81. {
  82. $count += 1;
  83. $text .= "<tr class=".($count%2? "ho" : "hr").">";
  84. $text .= "<td><a href='". B_IMG . $v ."' rel='lightbox[]'><img src='". B_IMG . $v ."' class='banner' title='Nhấp để xem kích thước thật'/></a></td>";
  85. $text .= "<td align='center'><a href='?mod=bannerList&action=delBanner&bname=".$v."'>Xóa banner</a></td>
  86. </tr>";
  87. }
  88. $text .= "</table>";
  89. return $text;
  90. }
  91. /*---------------------------------------------
  92. | GET INPUT DATA AND ACTIONS
  93. +----------------------------------------------*/
  94. function get_input()
  95. {
  96. global $str;
  97. $this->process = isset($_GET['action']) ? $str->input($_GET['action']) : "";
  98. }
  99. }
  100. ?>