国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

diy_list.php 8.4KB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. /**
  3. * 自定义表单列表
  4. *
  5. * @version $id:diy_list.php 18:31 2010年7月12日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('c_New');
  13. $diyid = isset($diyid) && is_numeric($diyid) ? $diyid : 0;
  14. $action = isset($action) && in_array($action, array('post', 'list', 'edit', 'check', 'delete','excel')) ? $action : '';
  15. if (empty($diyid)) {
  16. showMsg("非法操作", 'javascript:;');
  17. exit();
  18. }
  19. require_once DEDEINC.'/diyform.class.php';
  20. $diy = new diyform($diyid);
  21. if ($action == 'post') {
  22. if (empty($do)) {
  23. $postform = $diy->getForm('post', '', 'admin');
  24. include DEDEADMIN.'/templets/diy_post.htm';
  25. } else if ($do == 2) {
  26. $dede_fields = empty($dede_fields) ? '' : trim($dede_fields);
  27. $dede_fieldshash = empty($dede_fieldshash) ? '' : trim($dede_fieldshash);
  28. if (!empty($dede_fields)) {
  29. if ($dede_fieldshash != md5($dede_fields.$cfg_cookie_encode)) {
  30. showMsg("数据校验不对,程序返回", '-1');
  31. exit();
  32. }
  33. }
  34. $diyform = $dsql->getOne("SELECT * FROM `#@__diyforms` WHERE diyid=$diyid");
  35. if (!is_array($diyform)) {
  36. showmsg("自定义表单不存在", '-1');
  37. exit();
  38. }
  39. $addvar = $addvalue = '';
  40. if (!empty($dede_fields)) {
  41. $fieldarr = explode(';', $dede_fields);
  42. if (is_array($fieldarr)) {
  43. foreach ($fieldarr as $field) {
  44. if ($field == '') {
  45. continue;
  46. }
  47. $fieldinfo = explode(',', $field);
  48. if ($fieldinfo[1] == 'htmltext' || $fieldinfo[1] == 'textdata') {
  49. ${$fieldinfo[0]} = HtmlReplace(stripslashes(${$fieldinfo[0]}),1);
  50. ${$fieldinfo[0]} = addslashes(${$fieldinfo[0]});
  51. ${$fieldinfo[0]} = getFieldValue(${$fieldinfo[0]}, $fieldinfo[1], 0, 'add', '', 'member');
  52. } else {
  53. ${$fieldinfo[0]} = getFieldValue(${$fieldinfo[0]}, $fieldinfo[1], 0, 'add', '', 'member');
  54. }
  55. $addvar .= ', `'.$fieldinfo[0].'`';
  56. $addvalue .= ", '".${$fieldinfo[0]}."'";
  57. }
  58. }
  59. }
  60. $query = "INSERT INTO `{$diy->table}` (`id`, `ifcheck` $addvar) VALUES (NULL, 0 $addvalue)";
  61. if ($dsql->ExecuteNoneQuery($query)) {
  62. $goto = "diy_list.php?action=list&diyid={$diy->diyid}";
  63. showmsg('发布成功', $goto);
  64. } else {
  65. showmsg('发布失败', '-1');
  66. }
  67. }
  68. } else if ($action == 'list') {
  69. include_once DEDEINC.'/datalistcp.class.php';
  70. $query = "SELECT * FROM {$diy->table} ORDER BY id DESC";
  71. $datalist = new DataListCP();
  72. $datalist->pagesize = 30;
  73. $datalist->SetParameter('action', 'list');
  74. $datalist->SetParameter('diyid', $diyid);
  75. $datalist->SetTemplate(DEDEADMIN.'/templets/diy_list.htm');
  76. $datalist->SetSource($query);
  77. $fieldlist = $diy->getFieldList();
  78. $datalist->Display();
  79. } else if ($action == 'edit') {
  80. if (empty($do)) {
  81. $id = isset($id) && is_numeric($id) ? $id : 0;
  82. if (empty($id)) {
  83. showMsg('非法操作未指定id', 'javascript:;');
  84. exit();
  85. }
  86. $query = "SELECT * FROM {$diy->table} WHERE id=$id";
  87. $row = $dsql->GetOne($query);
  88. if (!is_array($row)) {
  89. showmsg("您浏览的记录不存在或未经审核", '-1');
  90. exit();
  91. }
  92. $postform = $diy->getForm('edit', $row, 'admin');
  93. $fieldlist = $diy->getFieldList();
  94. $c1 = $row['ifcheck'] == 1 ? 'checked' : '';
  95. $c2 = $row['ifcheck'] == 0 ? 'checked' : '';
  96. include DEDEADMIN.'/templets/diy_edit_content.htm';
  97. } else if ($do == 2) {
  98. $dede_fields = empty($dede_fields) ? '' : trim($dede_fields);
  99. $diyform = $dsql->GetOne("SELECT * FROM `#@__diyforms` WHERE diyid=$diyid");
  100. $diyco = $dsql->GetOne("SELECT * FROM `$diy->table` WHERE id='$id'");
  101. if (!is_array($diyform)) {
  102. showmsg("自定义表单不存在", '-1');
  103. exit();
  104. }
  105. $addsql = '';
  106. if (!empty($dede_fields)) {
  107. $fieldarr = explode(';', $dede_fields);
  108. if (is_array($fieldarr)) {
  109. foreach ($fieldarr as $field) {
  110. if ($field == '') {
  111. continue;
  112. }
  113. $fieldinfo = explode(',', $field);
  114. if ($fieldinfo[1] == 'htmltext' || $fieldinfo[1] == 'textdata') {
  115. ${$fieldinfo[0]} = HtmlReplace(stripslashes(${$fieldinfo[0]}),1);
  116. ${$fieldinfo[0]} = addslashes(${$fieldinfo[0]});
  117. ${$fieldinfo[0]} = GetFieldValue(${$fieldinfo[0]}, $fieldinfo[1], 0, 'add', '', 'member');
  118. ${$fieldinfo[0]} = empty(${$fieldinfo[0]}) ? $diyco[$fieldinfo[0]] : ${$fieldinfo[0]};
  119. } else {
  120. ${$fieldinfo[0]} = GetFieldValue(${$fieldinfo[0]}, $fieldinfo[1], 0, 'add', '', 'diy', $fieldinfo[0]);
  121. ${$fieldinfo[0]} = empty(${$fieldinfo[0]}) ? $diyco[$fieldinfo[0]] : ${$fieldinfo[0]};
  122. }
  123. $addsql .= !empty($addsql) ? ',`'.$fieldinfo[0]."`='".${$fieldinfo[0]}."'" : '`'.$fieldinfo[0]."`='".${$fieldinfo[0]}."'";
  124. }
  125. }
  126. }
  127. $query = "UPDATE `$diy->table` SET $addsql WHERE id=$id";
  128. if ($dsql->ExecuteNoneQuery($query)) {
  129. $goto = "diy_list.php?action=list&diyid={$diy->diyid}";
  130. showmsg('修改成功', $goto);
  131. } else {
  132. showmsg('修改成功', '-1');
  133. }
  134. }
  135. } elseif ($action == 'check') {
  136. if (is_array($id) && is_all_numeric($id)) {
  137. $ids = implode(',', $id);
  138. } else {
  139. showmsg('未选中要操作的文档', '-1');
  140. exit();
  141. }
  142. $query = "UPDATE `$diy->table` SET ifcheck=1 WHERE id IN ($ids)";
  143. if ($dsql->ExecuteNoneQuery($query)) {
  144. showmsg('审核成功', "diy_list.php?action=list&diyid={$diy->diyid}");
  145. } else {
  146. showmsg('审核失败', "diy_list.php?action=list&diyid={$diy->diyid}");
  147. }
  148. } elseif ($action == 'delete') {
  149. if (empty($do)) {
  150. if (is_array($id)) {
  151. $ids = implode(',', $id);
  152. } else {
  153. showmsg('未选中要操作的文档', '-1');
  154. exit();
  155. }
  156. $query = "DELETE FROM `$diy->table` WHERE id IN ($ids)";
  157. if ($dsql->ExecuteNoneQuery($query)) {
  158. showmsg('删除成功', "diy_list.php?action=list&diyid={$diy->diyid}");
  159. } else {
  160. showmsg('删除失败', "diy_list.php?action=list&diyid={$diy->diyid}");
  161. }
  162. } else if ($do = 1) {
  163. $row = $dsql->GetOne("SELECT * FROM `$diy->table` WHERE id='$id'");
  164. if (file_exists($cfg_basedir.$row[$name])) {
  165. unlink($cfg_basedir.$row[$name]);
  166. $dsql->ExecuteNoneQuery("UPDATE `$diy->table` SET $name='' WHERE id='$id'");
  167. showmsg('文件删除成功', "diy_list.php?action=list&diyid={$diy->diyid}");
  168. } else {
  169. showmsg('文件不存在', '-1');
  170. }
  171. }
  172. }
  173. elseif ($action == 'excel') {
  174. ob_end_clean();//清除缓冲区,避免乱码
  175. header("Content-type:application/vnd.ms-excel");
  176. header("Content-Disposition:attachment;filename={$diy->name}_".date("Y-m-d").".xls");
  177. print(chr(0xEF).chr(0xBB).chr(0xBF));//清除bom
  178. $fieldlist = (array)$diy->getFieldList();
  179. echo "<table><tr>";
  180. foreach($fieldlist as $field=>$fielddata)
  181. {
  182. echo "<th>{$fielddata[0]}</th>";
  183. }
  184. echo "<th>状态</th>";
  185. echo "</tr>";
  186. $sql = "SELECT * FROM {$diy->table} ORDER BY id DESC";
  187. $dsql->SetQuery($sql);
  188. $dsql->Execute('t');
  189. while($arr = $dsql->GetArray('t'))
  190. {
  191. echo "<tr>";
  192. foreach($fieldlist as $key => $field)
  193. {
  194. echo "<td>".$arr[$key]."</td>";
  195. }
  196. $status = $arr['ifcheck'] == 1 ? '<span class="btn btn-outline-success btn-sm">已审核</span>' : '<span class="btn btn-outline-danger btn-sm">未审核</span>';
  197. echo "<td>".$status."</td>";
  198. echo "</tr>";
  199. }
  200. echo "</table>";
  201. } else {
  202. showmsg('未定义操作', "-1");
  203. }
  204. ?>