国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

2 年前
2 年前
2 年前
2 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * 自定义表单
  4. *
  5. * @version $id:diy.php$
  6. * @package DedeBIZ.Site
  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__)."/../system/common.inc.php");
  12. $diyid = isset($diyid) && is_numeric($diyid) ? $diyid : 0;
  13. $action = isset($action) && in_array($action, array('post', 'list', 'view')) ? $action : 'post';
  14. $id = isset($id) && is_numeric($id) ? $id : 0;
  15. if (empty($diyid)) {
  16. showMsg('非法操作', 'javascript:;');
  17. exit();
  18. }
  19. require_once DEDEINC.'/diyform.class.php';
  20. $diy = new diyform($diyid);
  21. /*----------------------------
  22. function Post(){ }
  23. ---------------------------*/
  24. if ($action == 'post') {
  25. if (empty($do)) {
  26. $postform = $diy->getForm(true);
  27. include DEDEROOT."/theme/plus/{$diy->postTemplate}";
  28. exit();
  29. } elseif ($do == 2) {
  30. $dede_fields = empty($dede_fields) ? '' : trim($dede_fields);
  31. $dede_fieldshash = empty($dede_fieldshash) ? '' : trim($dede_fieldshash);
  32. if (!empty($dede_fields)) {
  33. if ($dede_fieldshash != md5($dede_fields.$cfg_cookie_encode)) {
  34. showMsg('数据校验不对,程序返回', '-1');
  35. exit();
  36. }
  37. }
  38. $diyform = $dsql->getOne("SELECT * FROM `#@__diyforms` WHERE diyid='$diyid' ");
  39. if (!is_array($diyform)) {
  40. showmsg('自定义表单不存在', '-1');
  41. exit();
  42. }
  43. $addvar = $addvalue = '';
  44. if (!empty($dede_fields)) {
  45. $fieldarr = explode(';', $dede_fields);
  46. if (is_array($fieldarr)) {
  47. foreach ($fieldarr as $field) {
  48. if ($field == '') continue;
  49. $fieldinfo = explode(',', $field);
  50. if ($fieldinfo[1] == 'textdata') {
  51. ${$fieldinfo[0]} = FilterSearch(stripslashes(${$fieldinfo[0]}));
  52. ${$fieldinfo[0]} = addslashes(${$fieldinfo[0]});
  53. }
  54. //获取地址,表单添加text数据类型ip字段型后模板用<input type="hidden" name="ip" value="">
  55. if ($fieldinfo[0] == 'ip')
  56. {
  57. ${$fieldinfo[0]}=GetIP();
  58. }
  59. //获取时间,表单添加text数据类型sj字段型后模板用<input type="hidden" name="sj" value="">
  60. if ($fieldinfo[0] == 'sj')
  61. {
  62. ${$fieldinfo[0]}=date("Y-m-d H:i");
  63. } else {
  64. ${$fieldinfo[0]} = GetFieldValue(${$fieldinfo[0]}, $fieldinfo[1],0,'add','','diy', $fieldinfo[0]);
  65. }
  66. $addvar .= ', `'.$fieldinfo[0].'`';
  67. $addvalue .= ", '".${$fieldinfo[0]}."'";
  68. }
  69. }
  70. }
  71. $query = "INSERT INTO `{$diy->table}` (`id`, `ifcheck` $addvar) VALUES (NULL, 0 $addvalue); ";
  72. if ($dsql->ExecuteNoneQuery($query)) {
  73. $id = $dsql->GetLastID();
  74. if ($diy->public == 2)
  75. {
  76. $goto = "diy.php?action=list&diyid={$diy->diyid}";
  77. $bkmsg = '发布成功,现在跳转表单列表页';
  78. } else {
  79. $goto = !empty($cfg_cmspath) ? $cfg_cmspath : '/';
  80. $bkmsg = '发布成功,请等待管理员处理';
  81. //提交后返回提交页面
  82. echo"<script>alert('提交成功');history.go(-1)</script>";
  83. }
  84. showmsg($bkmsg, $goto);
  85. }
  86. }
  87. }
  88. /*----------------------------
  89. function list(){ }
  90. ---------------------------*/
  91. else if ($action == 'list') {
  92. if (empty($diy->public)) {
  93. ShowMsg('后台关闭前台浏览', 'javascript:;');
  94. exit();
  95. }
  96. include_once DEDEINC.'/datalistcp.class.php';
  97. if ($diy->public == 2)
  98. $query = "SELECT * FROM `{$diy->table}` ORDER BY id DESC";
  99. else
  100. $query = "SELECT * FROM `{$diy->table}` WHERE ifcheck=1 ORDER BY id DESC";
  101. $datalist = new DataListCP();
  102. $datalist->pagesize = 10;
  103. $datalist->SetParameter('action', 'list');
  104. $datalist->SetParameter('diyid', $diyid);
  105. $datalist->SetTemplate(DEDEINC."/../theme/plus/{$diy->listTemplate}");
  106. $datalist->SetSource($query);
  107. $fieldlist = $diy->getFieldList();
  108. $datalist->Display();
  109. } else if ($action == 'view') {
  110. if (empty($diy->public)) {
  111. showMsg('后台关闭前台浏览', 'javascript:;');
  112. exit();
  113. }
  114. if (empty($id)) {
  115. showMsg('非法操作未指定id', 'javascript:;');
  116. exit();
  117. }
  118. if ($diy->public == 2) {
  119. $query = "SELECT * FROM `{$diy->table}` WHERE id='$id' ";
  120. } else {
  121. $query = "SELECT * FROM `{$diy->table}` WHERE id='$id' AND ifcheck=1";
  122. }
  123. $row = $dsql->GetOne($query);
  124. if (!is_array($row)) {
  125. showmsg('您浏览的记录不存在或未经审核', '-1');
  126. exit();
  127. }
  128. $fieldlist = $diy->getFieldList();
  129. include DEDEROOT."/theme/plus/{$diy->viewTemplate}";
  130. }
  131. ?>