PageRenderTime 34ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/php/xuzhou58/xuzhou58.com/dede/archives_add.php

http://jqbird.googlecode.com/
PHP | 234 lines | 198 code | 20 blank | 16 comment | 47 complexity | acd2890d6e269c9ccd6adf6df917cee4 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. require_once(dirname(__FILE__).'/config.php');
  3. CheckPurview('a_New,a_AccNew');
  4. require_once(DEDEINC.'/customfields.func.php');
  5. require_once(DEDEADMIN.'/inc/inc_archives_functions.php');
  6. if(empty($dopost))
  7. {
  8. $dopost = '';
  9. }
  10. if($dopost != 'save')
  11. {
  12. require_once(DEDEINC.'/dedetag.class.php');
  13. require_once(DEDEADMIN.'/inc/inc_catalog_options.php');
  14. ClearMyAddon();
  15. $channelid = empty($channelid) ? 0 : intval($channelid);
  16. $cid = empty($cid) ? 0 : intval($cid);
  17. //??????ID
  18. if($cid > 0 && $channelid == 0)
  19. {
  20. $row = $dsql->GetOne("Select channeltype From `#@__arctype` where id='$cid'; ");
  21. $channelid = $row['channeltype'];
  22. }
  23. else
  24. {
  25. if($channelid==0)
  26. {
  27. ShowMsg('????????????????', '-1');
  28. exit();
  29. }
  30. }
  31. //????????
  32. $cInfos = $dsql->GetOne(" Select * From `#@__channeltype` where id='$channelid' ");
  33. $channelid = $cInfos['id'];
  34. //??????id???????
  35. $maxWright = $dsql->GetOne("SELECT COUNT(*) AS cc FROM #@__archives");
  36. include DedeInclude('templets/archives_add.htm');
  37. exit();
  38. }
  39. /*--------------------------------
  40. function __save(){ }
  41. -------------------------------*/
  42. else if($dopost=='save')
  43. {
  44. require_once(DEDEINC.'/image.func.php');
  45. require_once(DEDEINC.'/oxwindow.class.php');
  46. $flag = isset($flags) ? join(',',$flags) : '';
  47. $notpost = isset($notpost) && $notpost == 1 ? 1: 0;
  48. if(empty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click);
  49. if(empty($typeid2)) $typeid2 = 0;
  50. if(!isset($autokey)) $autokey = 0;
  51. if(!isset($remote)) $remote = 0;
  52. if(!isset($dellink)) $dellink = 0;
  53. if(!isset($autolitpic)) $autolitpic = 0;
  54. if(empty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click);
  55. if($typeid==0)
  56. {
  57. ShowMsg('?????????', '-1');
  58. exit();
  59. }
  60. if(empty($channelid))
  61. {
  62. ShowMsg('??????????????????????????', '-1');
  63. exit();
  64. }
  65. if(!CheckChannel($typeid,$channelid) )
  66. {
  67. ShowMsg('?????????????????????????', '-1');
  68. exit();
  69. }
  70. if(!TestPurview('a_New'))
  71. {
  72. CheckCatalog($typeid, "??????????? {$typeid} ????");
  73. }
  74. //??????????
  75. if(empty($writer)) $writer = $cuserLogin->getUserName();
  76. if(empty($source)) $source = '??';
  77. $pubdate = GetMkTime($pubdate);
  78. $senddate = time();
  79. $sortrank = AddDay($pubdate,$sortup);
  80. $ismake = $ishtml == 0 ? -1 : 0;
  81. $title = ereg_replace('"', '?', $title);
  82. $title = cn_substrR($title,$cfg_title_maxlen);
  83. $shorttitle = cn_substrR($shorttitle,36);
  84. $color = cn_substrR($color,7);
  85. $writer = cn_substrR($writer,20);
  86. $source = cn_substrR($source,30);
  87. $description = cn_substrR($description,$cfg_auot_description);
  88. $keywords = cn_substrR($keywords,60);
  89. $filename = trim(cn_substrR($filename,40));
  90. $userip = GetIP();
  91. $isremote = (empty($isremote)? 0 : $isremote);
  92. $serviterm=empty($serviterm)? "" : $serviterm;
  93. if(!TestPurview('a_Check,a_AccCheck,a_MyCheck'))
  94. {
  95. $arcrank = -1;
  96. }
  97. $adminid = $cuserLogin->getUserID();
  98. //????????
  99. if(empty($ddisremote))
  100. {
  101. $ddisremote = 0;
  102. }
  103. $litpic = GetDDImage('none',$picname,$ddisremote);
  104. //????ID
  105. $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$adminid);
  106. if(empty($arcID))
  107. {
  108. ShowMsg("??????????????????","-1");
  109. exit();
  110. }
  111. //?????????
  112. $inadd_f = $inadd_v = '';
  113. if(!empty($dede_addonfields))
  114. {
  115. $addonfields = explode(';', $dede_addonfields);
  116. if(is_array($addonfields))
  117. {
  118. foreach($addonfields as $v)
  119. {
  120. if($v=='') continue;
  121. $vs = explode(',', $v);
  122. if($vs[1]=='htmltext' || $vs[1]=='textdata')
  123. {
  124. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  125. }
  126. else
  127. {
  128. if(!isset(${$vs[0]})) ${$vs[0]} = '';
  129. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  130. }
  131. $inadd_f .= ','.$vs[0];
  132. $inadd_v .= " ,'".${$vs[0]}."' ";
  133. }
  134. }
  135. }
  136. //????????????
  137. if($litpic!='' && !ereg('p',$flag))
  138. {
  139. $flag = ($flag=='' ? 'p' : $flag.',p');
  140. }
  141. if($redirecturl!='' && !ereg('j',$flag))
  142. {
  143. $flag = ($flag=='' ? 'j' : $flag.',j');
  144. }
  145. //????????????
  146. if(ereg('j', $flag)) $ismake = -1;
  147. //?????
  148. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  149. color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight)
  150. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  151. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  152. if(!$dsql->ExecuteNoneQuery($query))
  153. {
  154. $gerr = $dsql->GetError();
  155. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
  156. ShowMsg("??????????? `#@__archives` ?????????????DedeCms???".str_replace('"','',$gerr),"javascript:;");
  157. exit();
  158. }
  159. //??????
  160. $cts = $dsql->GetOne("Select addtable From `#@__channeltype` where id='$channelid' ");
  161. $addtable = trim($cts['addtable']);
  162. if(!empty($addtable))
  163. {
  164. $useip = GetIP();
  165. $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,userip{$inadd_f}) Values('$arcID','$typeid','$redirecturl','$useip'{$inadd_v})";
  166. if(!$dsql->ExecuteNoneQuery($query))
  167. {
  168. $gerr = $dsql->GetError();
  169. $dsql->ExecuteNoneQuery("Delete From `#@__archives` where id='$arcID'");
  170. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
  171. ShowMsg("???????????? `{$addtable}` ?????????????DedeCms???".str_replace('"','',$gerr),"javascript:;");
  172. exit();
  173. }
  174. }
  175. //??HTML
  176. InsertTags($tags, $arcID);
  177. if($cfg_remote_site=='Y' && $isremote=="1")
  178. {
  179. if($serviterm!=""){
  180. list($servurl,$servuser,$servpwd) = explode(',',$serviterm);
  181. $config=array( 'hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd,'debug' => 'TRUE');
  182. }else{
  183. $config=array();
  184. }
  185. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  186. }
  187. $artUrl = MakeArt($arcID, true, true,$isremote);
  188. if($artUrl=='')
  189. {
  190. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  191. }
  192. ClearMyAddon($arcID, $title);
  193. //??????
  194. $msg = " ????????????
  195. <a href='archives_add.php?cid=$typeid'><u>??????</u></a>
  196. &nbsp;&nbsp;
  197. <a href='$artUrl' target='_blank'><u>????</u></a>
  198. &nbsp;&nbsp;
  199. <a href='archives_do.php?aid=".$arcID."&dopost=editArchives'><u>????</u></a>
  200. &nbsp;&nbsp;
  201. <a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>???????</u></a>
  202. &nbsp;&nbsp;
  203. $backurl
  204. ";
  205. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  206. $wintitle = '???????';
  207. $wecome_info = '????::????';
  208. $win = new OxWindow();
  209. $win->AddTitle('???????');
  210. $win->AddMsgItem($msg);
  211. $winform = $win->GetWindow('hand', '&nbsp;', false);
  212. $win->Display();
  213. }
  214. ?>