国内流行的内容管理系统(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_add.php 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * 增加自定义表单
  4. *
  5. * @version $Id: diy_add.php 1 14:31 2010年7月12日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2021, 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. $mysql_version = $dsql->GetVersion();
  14. $mysql_versions = explode(".", trim($mysql_version));
  15. $mysql_version = $mysql_versions[0].".".$mysql_versions[1];
  16. if (empty($action)) {
  17. $row = $dsql->GetOne("SELECT diyid FROM #@__diyforms ORDER BY diyid DESC LIMIT 0,1 ");
  18. if (is_array($row)) $newdiyid = $row['diyid'] + 1;
  19. else $newdiyid = 1;
  20. include(DEDEADMIN."/templets/diy_add.htm");
  21. } else {
  22. if (preg_match("#[^0-9-]#", $diyid) || empty($diyid)) {
  23. ShowMsg("<font color=red>'自定义表单diyid'</font>必须为数字!", "-1");
  24. exit();
  25. }
  26. if ($table == "") {
  27. ShowMsg("表名不能为空!", "-1");
  28. exit();
  29. }
  30. $public = isset($public) && is_numeric($public) ? $public : 0;
  31. $name = dede_htmlspecialchars($name);
  32. $row = $dsql->GetOne("SELECT * FROM #@__diyforms WHERE diyid='$diyid' OR `table` LIKE '$table' OR name LIKE '$name' ");
  33. if (is_array($row)) {
  34. ShowMsg("可能自定义表单的‘diyid’、‘名称’在数据库中已存在,不能重复使用!", "-1");
  35. exit();
  36. }
  37. $query = "SHOW TABLES FROM {$dsql->dbName} ";
  38. $dsql->SetQuery($query);
  39. $dsql->Execute();
  40. while ($row = $dsql->getarray()) {
  41. if (empty($row[0])) $row[0] = '';
  42. if ($table == $row[0]) {
  43. showmsg('指定的表在数据库中重复', '-1');
  44. exit();
  45. }
  46. }
  47. $sql = "CREATE TABLE IF NOT EXISTS `$table`(
  48. `id` int(10) unsigned NOT NULL auto_increment,
  49. `ifcheck` tinyint(1) NOT NULL default '0',
  50. ";
  51. if ($mysql_version < 4.1) {
  52. $sql .= " PRIMARY KEY (`id`)\r\n) TYPE=MyISAM; ";
  53. } else {
  54. $sql .= " PRIMARY KEY (`id`)\r\n) ENGINE=MyISAM DEFAULT CHARSET=".$cfg_db_language."; ";
  55. }
  56. if ($dsql->ExecuteNoneQuery($sql)) {
  57. $query = "INSERT INTO #@__diyforms (`diyid`, `name`, `table`, `info`, `listtemplate`, `viewtemplate`, `posttemplate`, `public` ) VALUES ('$diyid', '$name', '$table', '', '$listtemplate', '$viewtemplate', '$posttemplate', '$public')";
  58. $dsql->ExecuteNoneQuery($query);
  59. showmsg('自定义表单创建成功,请自行添加字段', 'diy_main.php');
  60. } else {
  61. showmsg('自定义表单创建失败', '-1');
  62. }
  63. }