ldurl.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. namespace app\admin;
  4. class ldurl extends Base
  5. {
  6. public function initialize()
  7. {
  8. parent::initialize();
  9. $this->Administrator(3);
  10. $this->header();
  11. }
  12. public function __destruct()
  13. {
  14. $this->footer();
  15. }
  16. function index($map = [])
  17. {
  18. $result = db('ldurl')->select();
  19. $count = db('ldurl')->count();
  20. ?> <div class="container">
  21. <?php
  22. $this->nav3();
  23. ?> <table class="tb tb2">
  24. <tr>
  25. <th class="partition">域名列表</th>
  26. </tr>
  27. </table>
  28. <form name="form" method="post" action="?c=ldurl&a=editsave">
  29. <table class="tb tb2">
  30. <tr class="header">
  31. <th>编号</th>
  32. <th>域名</th>
  33. <th>状态</th>
  34. <th>排序</th>
  35. <th>操作</th>
  36. </tr>
  37. <?php
  38. if ($count == 0) {
  39. ?> <tr>
  40. <td colspan="2" class="td27">没有落地域名</td>
  41. </tr>
  42. <?php
  43. } else {
  44. foreach ($result as $row) {
  45. ?> <tr class="hover">
  46. <td class="td25"><input class="checkbox" type="checkbox" name="in_id[]"
  47. value="<?php echo $row['in_id'];?>"><?php echo $row['in_id'];?> </td>
  48. <td class="td29"><?php echo $row['in_url'];?></td>
  49. <td class="td29">
  50. <select name="in_status<?php echo $row['in_id'];?>">
  51. <option value="0">关闭</option>
  52. <option value="1" <?php
  53. if ($row['in_status']) {
  54. ?>selected<?php
  55. }
  56. ?>>开启</option>
  57. </select>
  58. </td>
  59. <td>
  60. <div class="parentboard"><input type="text"
  61. name="in_sort<?php echo $row['in_id'];?>"
  62. value="<?php echo $row['in_sort'];?>" class="txt"/>
  63. </div>
  64. </td>
  65. <td><input type="button" class="btn" value="删除"
  66. onclick="location.href='?c=ldurl&a=del&in_id=<?php echo $row['in_id'];?>'"/>
  67. </td>
  68. </tr>
  69. <?php
  70. }
  71. }
  72. ?></table>
  73. <table class="tb tb2">
  74. <tr>
  75. <td class="td25"><input type="checkbox" id="chkall" class="checkbox"
  76. onclick="CheckAll(this.form)"/><label
  77. for="chkall">全选</label></td>
  78. <td colspan="15">
  79. <div class="fixsel"><input type="submit" class="btn" name="editsave" value="批量修改"/></div>
  80. </td>
  81. </tr>
  82. </table>
  83. </form>
  84. <table class="tb tb2">
  85. <tr>
  86. <th class="partition">新增域名</th>
  87. </tr>
  88. </table>
  89. <form method="post" action="?c=ldurl&a=saveadd">
  90. <table class="tb tb2">
  91. <tr>
  92. <td>域名</td>
  93. <td><input type="text" class="txt" name="in_url" id="in_url" style="margin:0;width:200px"></td>
  94. </tr>
  95. <tr>
  96. <td colspan="15">
  97. <div class="fixsel"><input type="submit" id="btnadd" name="saveadd" class="btn"
  98. value="新增域名"/>
  99. </div>
  100. </td>
  101. </tr>
  102. </table>
  103. </form>
  104. </div>
  105. <?php
  106. }
  107. function saveadd()
  108. {
  109. if (!submitcheck('saveadd')) {
  110. $this->ShowMessage("表单验证不符,无法提交!", $_SERVER['PHP_SELF'], "infotitle3", 3000, 1);
  111. }
  112. $in_url = SafeRequest("in_url", "post");
  113. if (empty($in_url)) {
  114. $this->ShowMessage("新增出错,域名不能为空!", "?c=ldurl", "infotitle3", 1000, 1);
  115. }
  116. $find = db('ldurl')->where('in_url', $in_url)->count();
  117. if (!$find) {
  118. db('ldurl')->insert(array('in_url' => $in_url));
  119. }
  120. $this->ShowMessage("恭喜您,域名新增成功!", "?c=ldurl", "infotitle2", 1000, 1);
  121. }
  122. function editsave()
  123. {
  124. if (!submitcheck('editsave')) {
  125. $this->ShowMessage("表单验证不符,无法提交!", $_SERVER['PHP_SELF'], "infotitle3", 3000, 1);
  126. }
  127. $in_id = RequestBox("in_id");
  128. if ($in_id == 0) {
  129. $this->ShowMessage("修改失败,请先勾选要编辑的域名!", "?c=ldurl", "infotitle3", 3000, 1);
  130. } else {
  131. $ID = explode(',', $in_id);
  132. for ($i = 0; $i < count($ID); $i++) {
  133. $in_status = SafeRequest("in_status" . $ID[$i], "post");
  134. $in_sort = SafeRequest("in_sort" . $ID[$i], "post");
  135. db('ldurl')->where('in_id', $ID[$i])->update(array('in_status' => $in_status, 'in_sort' => $in_sort));
  136. }
  137. $this->ShowMessage("恭喜您,域名批量修改成功!", "?c=ldurl", "infotitle2", 3000, 1);
  138. }
  139. }
  140. function del()
  141. {
  142. $in_id = intval(SafeRequest("in_id", "get"));
  143. db('ldurl')->where('in_id', $in_id)->delete();
  144. $this->ShowMessage("恭喜您,域名删除成功!", "?c=ldurl", "infotitle2", 3000, 1);
  145. }
  146. }