memberfun.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. <?php
  2. //********************************** 会员字段 **********************************
  3. //返回字段值
  4. function ReturnMFvalue($value)
  5. {
  6. $value=str_replace("\r\n","|",$value);
  7. return $value;
  8. }
  9. //取得会员表单元素html代码
  10. function GetMemberFform($type,$f,$fvalue,$fformsize=''){
  11. if($type=="select"||$type=="radio"||$type=="checkbox")
  12. {
  13. return GetMFformSelect($type,$f,$fvalue,$fformsize);
  14. }
  15. $file="../data/html/memberfhtml.txt";
  16. $data=ReadFiletext($file);
  17. $exp="[!--".$type."--]";
  18. $r=explode($exp,$data);
  19. $string=str_replace("[!--enews.var--]",$f,$r[1]);
  20. $string=str_replace("[!--enews.def.val--]",$fvalue,$string);
  21. $string=RepMFformSize($f,$string,$type,$fformsize);
  22. return fAddAddsData($string);
  23. }
  24. //取得select/radio元素代码
  25. function GetMFformSelect($type,$f,$fvalue,$fformsize=''){
  26. $vr=explode("|",$fvalue);
  27. $count=count($vr);
  28. $change="";
  29. $def=':default';
  30. for($i=0;$i<$count;$i++)
  31. {
  32. $val=$vr[$i];
  33. $isdef="";
  34. if(strstr($val,$def))
  35. {
  36. $dr=explode($def,$val);
  37. $val=$dr[0];
  38. $isdef="||\$ecmsfirstpost==1";
  39. }
  40. if($type=='select')
  41. {
  42. $change.="<option value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' selected':''?>>".$val."</option>";
  43. }
  44. elseif($type=='checkbox')
  45. {
  46. $change.="<input name=\"".$f."[]\" type=\"checkbox\" value=\"".$val."\"<?=strstr(\$r[".$f."],\"|".$val."|\")".$isdef."?' checked':''?>>".$val;
  47. }
  48. else
  49. {
  50. $change.="<input name=\"".$f."\" type=\"radio\" value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' checked':''?>>".$val;
  51. }
  52. }
  53. if($type=="select")
  54. {
  55. if($fformsize)
  56. {
  57. $addsize=' style="width:'.$fformsize.'"';
  58. }
  59. $change="<select name=\"".$f."\" id=\"".$f."\"".$addsize.">".$change."</select>";
  60. }
  61. return $change;
  62. }
  63. //替换表单元素长度
  64. function RepMFformSize($f,$string,$type,$fformsize=''){
  65. $fformsize=ReturnDefMFformSize($f,$type,$fformsize);
  66. if($type=='textarea')
  67. {
  68. $r=explode(',',$fformsize);
  69. $string=str_replace('[!--fsize.w--]',$r[0],$string);
  70. $string=str_replace('[!--fsize.h--]',$r[1],$string);
  71. }
  72. else
  73. {
  74. $string=str_replace('[!--fsize.w--]',$fformsize,$string);
  75. }
  76. return $string;
  77. }
  78. //返回默认长度
  79. function ReturnDefMFformSize($f,$type,$fformsize){
  80. if(empty($fformsize))
  81. {
  82. if($type=='textarea')
  83. {
  84. $fformsize='60,10';
  85. }
  86. elseif($type=='img')
  87. {
  88. $fformsize='45';
  89. }
  90. elseif($type=='file')
  91. {
  92. $fformsize='45';
  93. }
  94. elseif($type=='flash')
  95. {
  96. $fformsize='45';
  97. }
  98. elseif($type=='date')
  99. {
  100. $fformsize='12';
  101. }
  102. elseif($type=='color')
  103. {
  104. $fformsize='10';
  105. }
  106. elseif($type=='linkfield')
  107. {
  108. $fformsize='45';
  109. }
  110. elseif($type=='downpath')
  111. {
  112. $fformsize='45';
  113. }
  114. elseif($type=='onlinepath')
  115. {
  116. $fformsize='45';
  117. }
  118. }
  119. return $fformsize;
  120. }
  121. //增加会员字段
  122. function AddMemberF($add,$userid,$username){
  123. global $empire,$dbtbpre;
  124. //验证权限
  125. CheckLevel($userid,$username,$classid,"memberf");
  126. $add[f]=RepPostVar($add[f]);
  127. if(empty($add[f])||empty($add[fname]))
  128. {
  129. printerror("EmptyF","");
  130. }
  131. //字段是否重复
  132. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsmemberadd");
  133. $b=0;
  134. while($r=$empire->fetch($s))
  135. {
  136. if($r[Field]==$add[f])
  137. {
  138. $b=1;
  139. break;
  140. }
  141. }
  142. if($b)
  143. {
  144. printerror("ReF","");
  145. }
  146. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsmember");
  147. $b=0;
  148. while($r=$empire->fetch($s))
  149. {
  150. if($r[Field]==$add[f])
  151. {
  152. $b=1;
  153. break;
  154. }
  155. }
  156. if($b)
  157. {
  158. printerror("ReF","");
  159. }
  160. $add[fvalue]=ReturnMFvalue($add[fvalue]);//初始化值
  161. //字段类型
  162. if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
  163. {
  164. $def=" default '0'";
  165. }
  166. elseif($add[ftype]=="VARCHAR")
  167. {
  168. $def=" default ''";
  169. }
  170. else
  171. {
  172. $def="";
  173. }
  174. $type=$add[ftype];
  175. //VARCHAR
  176. if($add[ftype]=='VARCHAR'&&empty($add[flen]))
  177. {
  178. $add[flen]='255';
  179. }
  180. //字段长度
  181. if($add[flen]){
  182. if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
  183. $type.="(".$add[flen].")";
  184. }
  185. }
  186. $field="`".$add[f]."` ".$type." NOT NULL".$def;
  187. //新增字段
  188. $asql=$empire->query("alter table {$dbtbpre}enewsmemberadd add ".$field);
  189. //替换代码
  190. $fhtml=GetMemberFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
  191. if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
  192. {
  193. $fhtml=str_replace("\$r[","\$addr[",$fhtml);
  194. }
  195. //处理变量
  196. $add[myorder]=(int)$add[myorder];
  197. $sql=$empire->query("insert into {$dbtbpre}enewsmemberf(f,fname,fform,fhtml,fzs,myorder,ftype,flen,fvalue,fformsize) values('$add[f]','$add[fname]','$add[fform]','".eaddslashes2($fhtml)."','".eaddslashes($add[fzs])."',$add[myorder],'$add[ftype]','$add[flen]','".eaddslashes2($add[fvalue])."','$add[fformsize]');");
  198. $lastid=$empire->lastid();
  199. if($asql&&$sql)
  200. {
  201. //操作日志
  202. insert_dolog("fid=".$lastid."<br>f=".$add[f]);
  203. printerror("AddFSuccess","member/AddMemberF.php?enews=AddMemberF".hReturnEcmsHashStrHref2(0));
  204. }
  205. else
  206. {
  207. printerror("DbError","history.go(-1)");
  208. }
  209. }
  210. //修改会员字段
  211. function EditMemberF($add,$userid,$username){
  212. global $empire,$dbtbpre;
  213. //验证权限
  214. CheckLevel($userid,$username,$classid,"memberf");
  215. $fid=(int)$add['fid'];
  216. $add[f]=RepPostVar($add[f]);
  217. $add[oldf]=RepPostVar($add[oldf]);
  218. if(empty($add[f])||empty($add[fname])||!$fid){
  219. printerror("EmptyF","history.go(-1)");
  220. }
  221. if($add[f]<>$add[oldf]){
  222. //字段是否重复
  223. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsmemberadd");
  224. $b=0;
  225. while($r=$empire->fetch($s)){
  226. if($r[Field]==$add[f]){
  227. $b=1;
  228. break;
  229. }
  230. }
  231. if($b){
  232. printerror("ReF","history.go(-1)");
  233. }
  234. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsmember");
  235. $b=0;
  236. while($r=$empire->fetch($s))
  237. {
  238. if($r[Field]==$add[f])
  239. {
  240. $b=1;
  241. break;
  242. }
  243. }
  244. if($b)
  245. {
  246. printerror("ReF","");
  247. }
  248. }
  249. $add[fvalue]=ReturnMFvalue($add[fvalue]);//初始化值
  250. //字段类型
  251. if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
  252. {
  253. $def=" default '0'";
  254. }
  255. elseif($add[ftype]=="VARCHAR")
  256. {
  257. $def=" default ''";
  258. }
  259. else
  260. {
  261. $def="";
  262. }
  263. $type=$add[ftype];
  264. //VARCHAR
  265. if($add[ftype]=='VARCHAR'&&empty($add[flen]))
  266. {
  267. $add[flen]='255';
  268. }
  269. //字段长度
  270. if($add[flen]){
  271. if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
  272. $type.="(".$add[flen].")";
  273. }
  274. }
  275. $field="`".$add[f]."` ".$type." NOT NULL".$def;
  276. $usql=$empire->query("alter table {$dbtbpre}enewsmemberadd change `".$add[oldf]."` ".$field);
  277. //替换代码
  278. if($add[f]<>$add[oldf]||$add[fform]<>$add[oldfform]||$add[fvalue]<>$add[oldfvalue]||$add[fformsize]<>$add[oldfformsize]){
  279. $fhtml=GetMemberFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
  280. if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
  281. {
  282. $fhtml=str_replace("\$r[","\$addr[",$fhtml);
  283. }
  284. }
  285. else{
  286. $fhtml=$add[fhtml];
  287. }
  288. //处理变量
  289. $add[myorder]=(int)$add[myorder];
  290. $sql=$empire->query("update {$dbtbpre}enewsmemberf set f='$add[f]',fname='$add[fname]',fform='$add[fform]',fhtml='".eaddslashes2($fhtml)."',fzs='".eaddslashes($add[fzs])."',myorder=$add[myorder],ftype='$add[ftype]',flen='$add[flen]',fvalue='".eaddslashes2($add[fvalue])."',fformsize='$add[fformsize]' where fid=$fid");
  291. //更新表单
  292. $record="<!--record-->";
  293. $field="<!--field--->";
  294. $like=$field.$add[oldf].$record;
  295. $newlike=$field.$add[f].$record;
  296. $slike=",".$add[oldf].",";
  297. $newslike=",".$add[f].",";
  298. $csql=$empire->query("select fid,ftemp,enter,mustenter,filef,imgf,tobrf,viewenter,searchvar,canaddf,caneditf,checkboxf from {$dbtbpre}enewsmemberform where enter like '%$like%'");
  299. while($cr=$empire->fetch($csql))
  300. {
  301. $setf="";
  302. $newftemp=str_replace('[!--'.$add[oldf].'--]','[!--'.$add[f].'--]',stripSlashes($cr['ftemp']));
  303. $setf.=",ftemp='".addslashes($newftemp)."'";
  304. if(strstr($cr['mustenter'],$slike)){
  305. $setf.=",mustenter=REPLACE(mustenter,'$slike','$newslike')";
  306. }
  307. if(strstr($cr['filef'],$slike)){
  308. $setf.=",filef=REPLACE(filef,'$slike','$newslike')";
  309. }
  310. if(strstr($cr['imgf'],$slike)){
  311. $setf.=",imgf=REPLACE(imgf,'$slike','$newslike')";
  312. }
  313. if(strstr($cr['tobrf'],$slike)){
  314. $setf.=",tobrf=REPLACE(tobrf,'$slike','$newslike')";
  315. }
  316. if(strstr($cr[viewenter],$like)){
  317. $setf.=",viewenter=REPLACE(viewenter,'$like','$newlike')";
  318. }
  319. if(strstr($cr['searchvar'],$slike)){
  320. $setf.=",searchvar=REPLACE(searchvar,'$slike','$newslike')";
  321. }
  322. if(strstr($cr['canaddf'],$slike)){
  323. $setf.=",canaddf=REPLACE(canaddf,'$slike','$newslike')";
  324. }
  325. if(strstr($cr['caneditf'],$slike)){
  326. $setf.=",caneditf=REPLACE(caneditf,'$slike','$newslike')";
  327. }
  328. if(strstr($cr['checkboxf'],$slike))
  329. {
  330. $setf.=",checkboxf=REPLACE(checkboxf,'$slike','$newslike')";
  331. }
  332. $cusql=$empire->query("update {$dbtbpre}enewsmemberform set enter=REPLACE(enter,'$like','$newlike')".$setf." where fid='$cr[fid]'");
  333. //生成表单页面
  334. ChangeMemberForm($cr[fid],$newftemp);
  335. }
  336. if($usql&&$sql)
  337. {
  338. insert_dolog("fid=".$fid."<br>f=".$add[f]);//操作日志
  339. printerror("EditFSuccess","member/ListMemberF.php".hReturnEcmsHashStrHref2(1));
  340. }
  341. else
  342. {printerror("DbError","history.go(-1)");}
  343. }
  344. //删除会员字段
  345. function DelMemberF($add,$userid,$username){
  346. global $empire,$dbtbpre;
  347. //验证权限
  348. CheckLevel($userid,$username,$classid,"memberf");
  349. $fid=(int)$add['fid'];
  350. if(empty($fid)){
  351. printerror("EmptyFid","history.go(-1)");
  352. }
  353. $r=$empire->fetch1("select f from {$dbtbpre}enewsmemberf where fid=$fid");
  354. if(!$r[f]){
  355. printerror("EmptyFid","history.go(-1)");
  356. }
  357. $usql=$empire->query("alter table {$dbtbpre}enewsmemberadd drop COLUMN `".$r[f]."`");
  358. $sql=$empire->query("delete from {$dbtbpre}enewsmemberf where fid=$fid");
  359. //更新表单表
  360. $record="<!--record-->";
  361. $field="<!--field--->";
  362. $like=$field.$r[f].$record;
  363. $slike=",".$r[f].",";
  364. $csql=$empire->query("select fid,ftemp,enter,mustenter,filef,imgf,tobrf,viewenter,searchvar,canaddf,caneditf,checkboxf from {$dbtbpre}enewsmemberform where enter like '%$like%'");
  365. while($cr=$empire->fetch($csql))
  366. {
  367. $setf="";
  368. if(strstr($cr['mustenter'],$slike))
  369. {
  370. $setf.=",mustenter=REPLACE(mustenter,'$slike',',')";
  371. }
  372. if(strstr($cr['filef'],$slike))
  373. {
  374. $setf.=",filef=REPLACE(filef,'$slike',',')";
  375. }
  376. if(strstr($cr['imgf'],$slike))
  377. {
  378. $setf.=",imgf=REPLACE(imgf,'$slike',',')";
  379. }
  380. if(strstr($cr['tobrf'],$slike))
  381. {
  382. $setf.=",tobrf=REPLACE(tobrf,'$slike',',')";
  383. }
  384. //录入项
  385. $enter="";
  386. $re1=explode($record,$cr[enter]);
  387. for($i=0;$i<count($re1)-1;$i++)
  388. {
  389. if(strstr($re1[$i].$record,$like))
  390. {continue;}
  391. $enter.=$re1[$i].$record;
  392. }
  393. //前台显示
  394. if(strstr($cr[viewenter],$like)){
  395. $viewenter='';
  396. $re2=explode($record,$cr[viewenter]);
  397. for($i=0;$i<count($re2)-1;$i++){
  398. if(strstr($re2[$i].$record,$like)){
  399. continue;
  400. }
  401. $viewenter.=$re2[$i].$record;
  402. }
  403. $setf.=",viewenter='".$viewenter."'";
  404. }
  405. //搜索项
  406. if(strstr($cr['searchvar'],$slike))
  407. {
  408. $setf.=",searchvar=REPLACE(searchvar,'$slike',',')";
  409. }
  410. //增加项
  411. if(strstr($cr['canaddf'],$slike))
  412. {
  413. $setf.=",canaddf=REPLACE(canaddf,'$slike',',')";
  414. }
  415. //修改项
  416. if(strstr($cr['caneditf'],$slike))
  417. {
  418. $setf.=",caneditf=REPLACE(caneditf,'$slike',',')";
  419. }
  420. //复选框
  421. if(strstr($cr['checkboxf'],$slike))
  422. {
  423. $setf.=",checkboxf=REPLACE(checkboxf,'$slike',',')";
  424. }
  425. $cusql=$empire->query("update {$dbtbpre}enewsmemberform set enter='$enter'".$setf." where fid='$cr[fid]'");
  426. }
  427. if($usql&&$sql)
  428. {
  429. insert_dolog("fid=".$fid."<br>f=".$r[f]);//操作日志
  430. printerror("DelFSuccess","member/ListMemberF.php".hReturnEcmsHashStrHref2(1));
  431. }
  432. else
  433. {printerror("DbError","history.go(-1)");}
  434. }
  435. //修改会员字段顺序
  436. function EditMemberFOrder($fid,$myorder,$userid,$username){
  437. global $empire,$dbtbpre;
  438. //验证权限
  439. CheckLevel($userid,$username,$classid,"memberf");
  440. for($i=0;$i<count($myorder);$i++)
  441. {
  442. $fid[$i]=(int)$fid[$i];
  443. $newmyorder=(int)$myorder[$i];
  444. $usql=$empire->query("update {$dbtbpre}enewsmemberf set myorder=$newmyorder where fid='$fid[$i]'");
  445. }
  446. printerror("EditFOrderSuccess","member/ListMemberF.php".hReturnEcmsHashStrHref2(1));
  447. }
  448. //********************************** 会员表单 **********************************
  449. //返回自动生成会员表单模板
  450. function ReturnMemberFtemp($cname,$center){
  451. $temp="<tr><td width='16%' height=25 bgcolor='ffffff'>enews.name</td><td bgcolor='ffffff'>[!--enews.var--]</td></tr>";
  452. for($i=0;$i<count($center);$i++){
  453. $v=$center[$i];
  454. $data.=str_replace("enews.var",$v,str_replace("enews.name",$cname[$v],$temp));
  455. }
  456. return "<table width='100%' align='center' cellpadding=3 cellspacing=1 bgcolor='#DBEAF5'>".$data."</table>";
  457. }
  458. //更新会员表单文件
  459. function ChangeMemberForm($fid,$mtemp){
  460. global $empire,$dbtbpre;
  461. $file="../data/html/memberform".$fid.".php";
  462. $sql=$empire->query("select f,fhtml from {$dbtbpre}enewsmemberf");
  463. while($r=$empire->fetch($sql)){
  464. $mtemp=str_replace("[!--".$r[f]."--]",$r[fhtml],$mtemp);
  465. }
  466. $mtemp="<?php
  467. if(!defined('InEmpireCMS'))
  468. {exit();}
  469. ?>".$mtemp;
  470. WriteFiletext($file,$mtemp);
  471. }
  472. //组合投稿项
  473. function TogMemberqenter($cname,$cqenter){
  474. $record="<!--record-->";
  475. $field="<!--field--->";
  476. $c="";
  477. for($i=0;$i<count($cqenter);$i++)
  478. {
  479. $v=$cqenter[$i];
  480. $name=str_replace($field,"",$cname[$v]);
  481. $name=str_replace($record,"",$name);
  482. $c.=$name.$field.$v.$record;
  483. }
  484. return $c;
  485. }
  486. //组合必填项
  487. function TogMemberMustf($cname,$menter){
  488. $c="";
  489. for($i=0;$i<count($menter);$i++)
  490. {
  491. $v=$menter[$i];
  492. $c.=$v.",";
  493. }
  494. if($c)
  495. {
  496. $c=",".$c;
  497. }
  498. return $c;
  499. }
  500. //增加会员表单
  501. function AddMemberForm($add,$userid,$username){
  502. global $empire,$dbtbpre;
  503. if(empty($add[fname]))
  504. {
  505. printerror("EmptyMemberForm","");
  506. }
  507. //验证权限
  508. CheckLevel($userid,$username,$classid,"memberf");
  509. $enter=TogMemberqenter($add['cname'],$add['center']);//录入项
  510. $viewenter=TogMemberqenter($add['cname'],$add['venter']);//显示项
  511. $mustenter=TogMemberMustf($add['cname'],$add['menter']);//必填项
  512. $canaddf=TogMemberMustf($add['cname'],$add['canadd']);//增加项
  513. $caneditf=TogMemberMustf($add['cname'],$add['canedit']);//修改项
  514. $searchvar=TogMemberMustf($add['cname'],$add['schange']);//搜索项
  515. $filef=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"file");
  516. $imgf=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"img");
  517. $tobrf=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"textarea");
  518. $checkboxf=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"checkbox");
  519. //自动生成表单
  520. if($add[ftype])
  521. {
  522. $add[ftemp]=ReturnMemberFtemp($add['cname'],$add['center']);
  523. }
  524. $sql=$empire->query("insert into {$dbtbpre}enewsmemberform(fname,ftemp,fzs,enter,mustenter,filef,imgf,tobrf,viewenter,searchvar,canaddf,caneditf,checkboxf) values('$add[fname]','".eaddslashes2($add[ftemp])."','".addslashes($add[fzs])."','$enter','$mustenter','$filef','$imgf','$tobrf','$viewenter','$searchvar','$canaddf','$caneditf','$checkboxf');");
  525. $fid=$empire->lastid();
  526. //生成表单页面
  527. ChangeMemberForm($fid,$add[ftemp]);
  528. if($sql)
  529. {
  530. insert_dolog("fid=".$fid."<br>fname=".$add[fname]);//操作日志
  531. printerror("AddMemberFormSuccess","member/AddMemberForm.php?enews=AddMemberForm".hReturnEcmsHashStrHref2(0));
  532. }
  533. else
  534. {printerror("DbError","history.go(-1)");}
  535. }
  536. //修改会员表单
  537. function EditMemberForm($add,$userid,$username){
  538. global $empire,$dbtbpre;
  539. $fid=(int)$add['fid'];
  540. if(empty($add[fname])||!$fid)
  541. {
  542. printerror("EmptyMemberForm","history.go(-1)");
  543. }
  544. //验证权限
  545. CheckLevel($userid,$username,$classid,"memberf");
  546. $enter=TogMemberqenter($add['cname'],$add['center']);//录入项
  547. $viewenter=TogMemberqenter($add['cname'],$add['venter']);//显示项
  548. $mustenter=TogMemberMustf($add['cname'],$add['menter']);//必填项
  549. $canaddf=TogMemberMustf($add['cname'],$add['canadd']);//增加项
  550. $caneditf=TogMemberMustf($add['cname'],$add['canedit']);//修改项
  551. $searchvar=TogMemberMustf($add['cname'],$add['schange']);//搜索项
  552. $filef=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"file");
  553. $imgf=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"img");
  554. $tobrf=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"textarea");
  555. $checkboxf=ReturnMFileF($enter,$dbtbpre."enewsmemberf",0,"checkbox");
  556. //自动生成表单
  557. if($add[ftype])
  558. {
  559. $add[ftemp]=ReturnMemberFtemp($add['cname'],$add['center']);
  560. }
  561. $sql=$empire->query("update {$dbtbpre}enewsmemberform set fname='$add[fname]',ftemp='".eaddslashes2($add[ftemp])."',fzs='".addslashes($add[fzs])."',enter='$enter',mustenter='$mustenter',filef='$filef',imgf='$imgf',tobrf='$tobrf',viewenter='$viewenter',searchvar='$searchvar',canaddf='$canaddf',caneditf='$caneditf',checkboxf='$checkboxf' where fid=$fid");
  562. //生成表单页面
  563. ChangeMemberForm($fid,$add[ftemp]);
  564. if($sql)
  565. {
  566. insert_dolog("fid=".$fid."<br>fname=".$add[fname]);//操作日志
  567. printerror("EditMemberFormSuccess","member/ListMemberForm.php".hReturnEcmsHashStrHref2(1));
  568. }
  569. else
  570. {printerror("DbError","history.go(-1)");}
  571. }
  572. //删除会员表单
  573. function DelMemberForm($add,$userid,$username){
  574. global $empire,$dbtbpre;
  575. $fid=(int)$add['fid'];
  576. if(!$fid)
  577. {
  578. printerror("EmptyMemberFormId","history.go(-1)");
  579. }
  580. //验证权限
  581. CheckLevel($userid,$username,$classid,"memberf");
  582. $r=$empire->fetch1("select fid,fname from {$dbtbpre}enewsmemberform where fid=$fid;");
  583. if(!$r['fid'])
  584. {
  585. printerror("EmptyMemberFormId","history.go(-1)");
  586. }
  587. $sql=$empire->query("delete from {$dbtbpre}enewsmemberform where fid=$fid;");
  588. //删除表单文件
  589. $file="../data/html/memberform".$fid.".php";
  590. DelFiletext($file);
  591. if($sql)
  592. {
  593. insert_dolog("fid=".$fid."<br>fname=".$r[fname]);//操作日志
  594. printerror("DelMemberFormSuccess","member/ListMemberForm.php".hReturnEcmsHashStrHref2(1));
  595. }
  596. else
  597. {printerror("DbError","history.go(-1)");}
  598. }
  599. //********************************** 会员组 **********************************
  600. //增加会员组
  601. function AddMemberGroup($add,$userid,$username){
  602. global $empire,$dbtbpre;
  603. if(empty($add[groupname])||empty($add[level]))
  604. {printerror("EmptyMemberGroupname","history.go(-1)");}
  605. //验证权限
  606. CheckLevel($userid,$username,$classid,"membergroup");
  607. //处理文件
  608. $add[level]=(int)$add[level];
  609. $add[checked]=(int)$add[checked];
  610. $add[favanum]=(int)$add[favanum];
  611. $add[daydown]=(int)$add[daydown];
  612. $msgnum=(int)$add['msgnum'];
  613. $msglen=(int)$add['msglen'];
  614. $canreg=(int)$add['canreg'];
  615. $formid=(int)$add['formid'];
  616. $regchecked=(int)$add['regchecked'];
  617. $spacestyleid=(int)$add['spacestyleid'];
  618. $add[dayaddinfo]=(int)$add[dayaddinfo];
  619. $add[infochecked]=(int)$add[infochecked];
  620. $add[plchecked]=(int)$add[plchecked];
  621. $sql=$empire->query("insert into {$dbtbpre}enewsmembergroup(groupname,level,checked,favanum,daydown,msglen,msgnum,canreg,formid,regchecked,spacestyleid,dayaddinfo,infochecked,plchecked) values('$add[groupname]',$add[level],$add[checked],$add[favanum],$add[daydown],$msglen,$msgnum,$canreg,$formid,$regchecked,$spacestyleid,'$add[dayaddinfo]','$add[infochecked]','$add[plchecked]');");
  622. $groupid=$empire->lastid();
  623. //更新缓存
  624. GetMemberLevel();
  625. if($sql)
  626. {
  627. //操作日志
  628. insert_dolog("groupid=".$groupid."<br>groupname=".$add[groupname]);
  629. printerror("AddMemberGroupSuccess","member/AddMemberGroup.php?enews=AddMemberGroup".hReturnEcmsHashStrHref2(0));
  630. }
  631. else
  632. {printerror("DbError","history.go(-1)");}
  633. }
  634. //修改会员组
  635. function EditMemberGroup($add,$userid,$username){
  636. global $empire,$dbtbpre;
  637. $add[groupid]=(int)$add[groupid];
  638. if(empty($add[groupid])||empty($add[groupname])||empty($add[level]))
  639. {printerror("EmptyMemberGroupname","history.go(-1)");}
  640. //验证权限
  641. CheckLevel($userid,$username,$classid,"membergroup");
  642. //处理文件
  643. $add[level]=(int)$add[level];
  644. $add[checked]=(int)$add[checked];
  645. $add[favanum]=(int)$add[favanum];
  646. $add[daydown]=(int)$add[daydown];
  647. $msgnum=(int)$add['msgnum'];
  648. $msglen=(int)$add['msglen'];
  649. $canreg=(int)$add['canreg'];
  650. $formid=(int)$add['formid'];
  651. $regchecked=(int)$add['regchecked'];
  652. $spacestyleid=(int)$add['spacestyleid'];
  653. $add[dayaddinfo]=(int)$add[dayaddinfo];
  654. $add[infochecked]=(int)$add[infochecked];
  655. $add[plchecked]=(int)$add[plchecked];
  656. $sql=$empire->query("update {$dbtbpre}enewsmembergroup set groupname='$add[groupname]',level=$add[level],checked=$add[checked],favanum=$add[favanum],daydown=$add[daydown],msglen=$msglen,msgnum=$msgnum,canreg=$canreg,formid=$formid,regchecked=$regchecked,spacestyleid=$spacestyleid,dayaddinfo='$add[dayaddinfo]',infochecked='$add[infochecked]',plchecked='$add[plchecked]' where groupid='$add[groupid]'");
  657. //更新缓存
  658. GetMemberLevel();
  659. if($sql)
  660. {
  661. //操作日志
  662. insert_dolog("groupid=".$add[groupid]."<br>groupname=".$add[groupname]);
  663. printerror("EditMemberGroupSuccess","member/ListMemberGroup.php".hReturnEcmsHashStrHref2(1));
  664. }
  665. else
  666. {printerror("DbError","history.go(-1)");}
  667. }
  668. //删除会员组
  669. function DelMemberGroup($groupid,$userid,$username){
  670. global $empire,$dbtbpre;
  671. $groupid=(int)$groupid;
  672. if(empty($groupid))
  673. {printerror("NotDelMemberGroupid","history.go(-1)");}
  674. //验证权限
  675. CheckLevel($userid,$username,$classid,"membergroup");
  676. $r=$empire->fetch1("select groupname from {$dbtbpre}enewsmembergroup where groupid='$groupid'");
  677. $sql=$empire->query("delete from {$dbtbpre}enewsmembergroup where groupid='$groupid'");
  678. //更新缓存
  679. GetMemberLevel();
  680. if($sql)
  681. {
  682. //操作日志
  683. insert_dolog("groupid=".$groupid."<br>groupname=".$r[groupname]);
  684. printerror("DelMemberGroupSuccess","member/ListMemberGroup.php".hReturnEcmsHashStrHref2(1));
  685. }
  686. else
  687. {printerror("DbError","history.go(-1)");}
  688. }
  689. ?>