国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

100 lignes
3.5KB

  1. <?php
  2. /**
  3. * 增加自定义表单字段
  4. *
  5. * @version $id:diy_field_add.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. //增加权限检查
  13. require_once(DEDEADMIN.'/inc/inc_admin_channel.php');
  14. if (empty($action)) $action = '';
  15. $mysql_version = $dsql->GetVersion();
  16. $mysql_versions = explode(".", trim($mysql_version));
  17. $mysql_version = $mysql_versions[0].".".$mysql_versions[1];
  18. /*----------------------
  19. function Save()
  20. ---------------------*/
  21. if ($action == 'save') {
  22. //模型信息
  23. $fieldname = strtolower($fieldname);
  24. $row = $dsql->GetOne("SELECT `table`,`info` FROM `#@__diyforms` WHERE diyid='$diyid'");
  25. $fieldset = stripslashes($row['info']);
  26. require_once(DEDEINC."/dedetag.class.php");
  27. $dtp = new DedeTagParse();
  28. $dtp->SetNameSpace("field", "<", ">");
  29. $dtp->LoadSource($fieldset);
  30. $trueTable = $row['table'];
  31. //修改字段配置信息
  32. $dfvalue = trim($vdefault);
  33. $isnull = ($isnull == 1 ? "true" : "false");
  34. $mxlen = $maxlength;
  35. //检测被修改的字段类型
  36. $fieldinfos = GetFieldMake($dtype, $fieldname, $dfvalue, $mxlen);
  37. $ntabsql = $fieldinfos[0];
  38. $buideType = $fieldinfos[1];
  39. $rs = $dsql->ExecuteNoneQuery(" ALTER TABLE `$trueTable` ADD $ntabsql ");
  40. if (!$rs) {
  41. $gerr = $dsql->GetError();
  42. ShowMsg("增加字段失败,错误提示为:".$gerr, "javascript:;");
  43. exit();
  44. }
  45. $ok = FALSE;
  46. //检测旧配置信息,并替换为新配置
  47. if (is_array($dtp->CTags)) {
  48. //遍历旧配置
  49. foreach ($dtp->CTags as $tagid => $ctag) {
  50. if ($fieldname == strtolower($ctag->GetName())) {
  51. $dtp->Assign($tagid, stripslashes($fieldstring), FALSE);
  52. $ok = TRUE;
  53. break;
  54. }
  55. }
  56. $oksetting = $ok ? $dtp->GetResultNP() : $fieldset."\n".stripslashes($fieldstring);
  57. } else {
  58. //原来的配置为空
  59. $oksetting = $fieldset."\n".stripslashes($fieldstring);
  60. }
  61. $addlist = GetAddFieldList($dtp, $oksetting);
  62. $oksetting = addslashes($oksetting);
  63. $rs = $dsql->ExecuteNoneQuery("UPDATE `#@__diyforms` SET `info`='$oksetting' WHERE diyid='$diyid' ");
  64. if (!$rs) {
  65. $grr = $dsql->GetError();
  66. ShowMsg("保存节点配置出错".$grr, "javascript:;");
  67. exit();
  68. }
  69. ShowMsg("成功增加一个字段", "diy_edit.php?diyid=$diyid");
  70. exit();
  71. }
  72. //检测模型相关信息,并初始化相关数据
  73. /*----------------------
  74. function ShowPage()
  75. ---------------------*/
  76. $row = $dsql->GetOne("SELECT `table` FROM `#@__diyforms` WHERE diyid='$diyid'");
  77. $trueTable = $row['table'];
  78. $tabsql = "CREATE TABLE IF NOT EXISTS `$trueTable`(
  79. `id` int(10) unsigned NOT NULL auto_increment,
  80. `ifcheck` tinyint(1) NOT NULL default '0',
  81. ";
  82. if ($mysql_version < 4.1) {
  83. $tabsql .= " PRIMARY KEY (`id`)\r\n) TYPE=MyISAM; ";
  84. } else {
  85. $tabsql .= " PRIMARY KEY (`id`)\r\n) ENGINE=MyISAM DEFAULT CHARSET=".$cfg_db_language."; ";
  86. }
  87. $dsql->ExecuteNoneQuery($tabsql);
  88. //检测附加表里含有的字段
  89. $fields = array();
  90. $rs = $dsql->SetQuery("show fields from `$trueTable`");
  91. $dsql->Execute('a');
  92. while ($nrow = $dsql->GetArray('a', MYSQL_ASSOC)) {
  93. $fields[strtolower($nrow['Field'])] = 1;
  94. }
  95. $f = '';
  96. foreach ($fields as $k => $v) {
  97. $f .= ($f == '' ? $k : ' '.$k);
  98. }
  99. require_once(DEDEADMIN."/templets/diy_field_add.htm");
  100. ?>