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

221 lines
8.6KB

  1. <?php
  2. /**
  3. * 会员模型编辑
  4. *
  5. * @version $Id: member_model_edit.php 1 11:20 2010年7月20日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('c_Edit');
  13. require_once(DEDEINC."/dedetag.class.php");
  14. require_once(DEDEINC."/oxwindow.class.php");
  15. if(empty($dopost)) $dopost="";
  16. $id = (empty($id) ? 0 : intval($id));
  17. /*----------------
  18. function __SaveEdit()
  19. -----------------*/
  20. if($dopost=="save")
  21. {
  22. $state = isset($state) && is_numeric($state) ? $state : 1;
  23. $description = dede_htmlspecialchars($description);
  24. $name = dede_htmlspecialchars($name);
  25. $query = "UPDATE `#@__member_model` SET name = '$name', description = '$description', state='$state' WHERE id='$id' ";
  26. $dsql->ExecuteNoneQuery($query);
  27. //更新会员模型缓存
  28. UpDateMemberModCache();
  29. ShowMsg("成功更改一个会员模型!", "member_model_main.php");
  30. exit();
  31. }
  32. /*----------------
  33. function __Disabled()
  34. -----------------*/
  35. else if($dopost=="disabled")
  36. {
  37. @set_time_limit(0);
  38. CheckPurview('c_Del');
  39. $row = $dsql->GetOne("SELECT * FROM #@__member_model WHERE id='$id'");
  40. $statenum = ($row['state']==0)? 1 : 0;
  41. $statestr = ($row['state']==0)? '启用' : '禁用';
  42. //禁用模型
  43. $dsql->ExecuteNoneQuery("UPDATE #@__member_model SET state={$statenum} WHERE id='$id' ");
  44. //更新会员模型缓存
  45. UpDateMemberModCache();
  46. ShowMsg("成功{$statestr}一个会员模型!","member_model_main.php");
  47. exit();
  48. }
  49. /*----------------
  50. function __Copy()
  51. -----------------*/
  52. else if($dopost=="copy")
  53. {
  54. @set_time_limit(0);
  55. CheckPurview('c_Del');
  56. $row = $dsql->GetOne("SELECT * FROM #@__member_model WHERE id='$id'");
  57. $thisname = $row['name'];
  58. $thistable = $row['table'];
  59. $thisinfo = $row['info'];
  60. $row = $dsql->GetOne("SELECT id From #@__member_model ORDER BY id DESC LIMIT 0,1 ");
  61. if(is_array($row)) $newid = $row['id'] + 1;
  62. else $newid = 1;
  63. if(empty($job)) $job="";
  64. //确认提示
  65. if($job=="")
  66. {
  67. $wintitle = "会员模型管理-复制会员模型";
  68. $wecome_info = "<a href='member_model_main.php'>会员模型管理</a>::复制会员模型";
  69. $win = new OxWindow();
  70. $win->Init("member_model_edit.php","js/blank.js","POST");
  71. $win->AddHidden("job","yes");
  72. $win->AddHidden("dopost",$dopost);
  73. $win->AddHidden("id",$id);
  74. $win->AddTitle("你确实要复制 \"".$thisname."\" 这个会员模型?");
  75. $msg ="";
  76. $msg.="<table width='460' border='0' cellspacing='0' cellpadding='0'>\r\n";
  77. $msg.="<tr>\r\n";
  78. $msg.=" <td width='170' height='24' align='center'>新模型ID:</td>\r\n";
  79. $msg.=" <td width='230'><input name='newid' type='text' id='newid' size='6' value='{$newid}'/></td>\r\n";
  80. $msg.="</tr>\r\n";
  81. $msg.="<tr>\r\n";
  82. $msg.=" <td height='24' align='center'>新模型名称:</td>\r\n";
  83. $msg.=" <td><input name='newname' type='text' id='newname' value='{$thisname}{$newid}' style='width:250px'/></td>\r\n";
  84. $msg.="</tr>\r\n";
  85. $msg.="<tr>\r\n";
  86. $msg.=" <td height='24' align='center'>模型数据表:</td>\r\n";
  87. $msg.=" <td><input name='newtable' type='text' id='newtable' value='{$thistable}{$newid}' style='width:250px'/></td>\r\n";
  88. $msg.="</tr>\r\n";
  89. $msg.="<tr>\r\n";
  90. $msg.=" <td height='24' align='center'>模型字段:</td>\r\n";
  91. $msg.=" <td><font color='red'>模型字段默认已经复制,请在编辑当前模型中查看</font></td>\r\n";
  92. $msg.="</tr>\r\n";
  93. $msg.="<tr>\r\n";
  94. $msg.=" <td height='24' align='center'>新模型描述:</td>\r\n";
  95. $msg.=" <td><label>\r\n";
  96. $msg.=" <textarea name=\"description\" id=\"description\" cols=\"45\" rows=\"5\" onClick=\"this.value=''\">新模型描述</textarea>\r\n";
  97. $msg.=" </label></td>\r\n";
  98. $msg.="</tr>\r\n";
  99. $msg.="<tr>\r\n";
  100. $msg.=" <td height='24' align='center'>模型状态:</td>\r\n";
  101. $msg.=" <td><input name='state' type='radio' id='copytemplet' value='1' class='np' checked='checked'/>\r\n";
  102. $msg.=" 启用\r\n";
  103. $msg.=" &nbsp;\r\n";
  104. $msg.=" <input name='state' type='radio' id='copytemplet' class='np' value='0'/>\r\n";
  105. $msg.=" 禁用</td>\r\n";
  106. $msg.="</tr>\r\n";
  107. $msg.="</table>";
  108. $win->AddMsgItem("<div style='padding:20px;line-height:300%'>$msg</div>");
  109. $winform = $win->GetWindow("ok");
  110. $win->Display();
  111. exit();
  112. }
  113. //操作
  114. else if($job=="yes")
  115. {
  116. if(preg_match("#[^0-9-]#", $newid) || empty($newid))
  117. {
  118. ShowMsg("<font color=red>'会员模型ID'</font>必须为数字!","-1");
  119. exit();
  120. }
  121. if($newtable=="")
  122. {
  123. ShowMsg("表名不能为空!", "-1");
  124. exit();
  125. }
  126. $state = isset($state) && is_numeric($state) ? $state : 0;
  127. $newname = dede_htmlspecialchars($newname);
  128. $row = $dsql->GetOne("SELECT * FROM #@__member_model WHERE id='$newid' OR `table` LIKE '$newtable' OR name LIKE '$newname' ");
  129. if(is_array($row))
  130. {
  131. ShowMsg("可能会员模型的‘ID’、‘名称’在数据库中已存在,不能重复使用!","-1");
  132. exit();
  133. }
  134. //拷贝数据表
  135. if(!$dsql->IsTable($newtable))
  136. {
  137. $dsql->Execute('me',"SHOW CREATE TABLE {$dsql->dbName}.{$thistable}");
  138. $row = $dsql->GetArray('me', MYSQL_BOTH);
  139. $tableStruct = $row[1];
  140. $tb = str_replace('#@__', $cfg_dbprefix, $thistable);
  141. $tableStruct = preg_replace("/CREATE TABLE `$thistable`/iU","CREATE TABLE `$newtable`",$tableStruct);
  142. $dsql->ExecuteNoneQuery($tableStruct);
  143. }
  144. $query = "INSERT INTO #@__member_model (`id`, `name`, `table`, `description`, `issystem`, `state`, `info`) VALUES ('$newid', '$newname', '$newtable', '$description', 0, '$state','$thisinfo')";
  145. $rs = $dsql->ExecuteNoneQuery($query);
  146. if($rs)
  147. {
  148. UpDateMemberModCache();
  149. ShowMsg("成功复制会员模型,现转到详细参数页... ","member_model_edit.php?id={$newid}&dopost=edit");
  150. exit();
  151. }
  152. else
  153. {
  154. $errv = $dsql->GetError();
  155. ShowMsg("系统出错,请把错误代码发送到官方论坛,以检查原因!<br /> 错误代码:member_model_edit.php?dopost=copy $errv","javascript:;");
  156. exit();
  157. }
  158. //echo "Do it!";exit();
  159. }
  160. }
  161. /*----------------
  162. function __Delete()
  163. -----------------*/
  164. else if($dopost=="delete")
  165. {
  166. @set_time_limit(0);
  167. CheckPurview('c_Del');
  168. $row = $dsql->GetOne("SELECT * FROM #@__member_model WHERE id='$id'");
  169. if($row['issystem'] == 1)
  170. {
  171. ShowMsg("系统模型,禁止删除!","-1");
  172. exit();
  173. }
  174. if(empty($job)) $job="";
  175. //确认提示
  176. if($job=="")
  177. {
  178. $wintitle = "会员模型管理-删除会员模型";
  179. $wecome_info = "<a href='member_model_main.php'>会员模型管理</a>::删除会员模型";
  180. $win = new OxWindow();
  181. $win->Init("member_model_edit.php","js/blank.js","POST");
  182. $win->AddHidden("job","yes");
  183. $win->AddHidden("dopost",$dopost);
  184. $win->AddHidden("id",$id);
  185. $win->AddTitle("!将删除所有与该会员模型相关的文件和数据<br />你确实要删除 \"".$row['name']."\" 这个会员模型?");
  186. $winform = $win->GetWindow("ok");
  187. $win->Display();
  188. exit();
  189. }
  190. //操作
  191. else if($job=="yes")
  192. {
  193. $row = $dsql->GetOne("SELECT `table` FROM `#@__member_model` WHERE id='$id'",MYSQL_ASSOC);
  194. if(!is_array($row))
  195. {
  196. ShowMsg("你所指定的会员模型信息不存在!","-1");
  197. exit();
  198. }
  199. //删除表
  200. $dsql->ExecuteNoneQuery("DROP TABLE IF EXISTS `{$row['table']}`;");
  201. //删除频道配置信息
  202. $dsql->ExecuteNoneQuery("DELETE FROM `#@__member_model` WHERE id='$id'");
  203. UpDateMemberModCache();
  204. ShowMsg("成功删除一个会员模型!","member_model_main.php");
  205. exit();
  206. }
  207. }
  208. /*----------------
  209. function edit()
  210. -----------------*/
  211. $row = $dsql->GetOne("SELECT * FROM #@__member_model WHERE id='$id'");
  212. include DEDEADMIN."/templets/member_model_edit.htm";