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

173 lines
6.1KB

  1. <?php
  2. /**
  3. * 采集规则编辑
  4. *
  5. * @version $Id: co_edit.php 1 14:31 2010年7月12日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2018, DesDev, Inc.
  8. * @copyright Copyright (c) 2020, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license/v6
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(dirname(__FILE__).'/config.php');
  13. CheckPurview('co_EditNote');
  14. require_once(DEDEINC.'/dedetag.class.php');
  15. $nid = (isset($nid) ? intval($nid) : '');
  16. if($nid=='')
  17. {
  18. ShowMsg('参数无效!','-1');
  19. exit();
  20. }
  21. if(empty($dopost)) $dopost = '';
  22. /*----------------------
  23. function _Save()
  24. ----------------------*/
  25. if($dopost=='save' || $dopost=='saveandtest')
  26. {
  27. $usemore = (!isset($usemore) ? 0 : 1);
  28. $listconfig = "{dede:noteinfo notename=\\\"$notename\\\" channelid=\\\"$channelid\\\" macthtype=\\\"$macthtype\\\"
  29. refurl=\\\"$refurl\\\" sourcelang=\\\"$sourcelang\\\" cosort=\\\"$cosort\\\"
  30. isref=\\\"$isref\\\" exptime=\\\"$exptime\\\" usemore=\\\"$usemore\\\" /}
  31. {dede:listrule sourcetype=\\\"$sourcetype\\\" rssurl=\\\"$rssurl\\\" regxurl=\\\"$regxurl\\\"
  32. startid=\\\"$startid\\\" endid=\\\"$endid\\\" addv=\\\"$addv\\\" urlrule=\\\"$urlrule\\\" musthas=\\\"$musthas\\\"
  33. nothas=\\\"$nothas\\\" listpic=\\\"$listpic\\\" usemore=\\\"$usemore\\\"}
  34. {dede:addurls}$addurls{/dede:addurls}
  35. {dede:batchrule}$batchrule{/dede:batchrule}
  36. {dede:regxrule}$regxrule{/dede:regxrule}
  37. {dede:areastart}$areastart{/dede:areastart}
  38. {dede:areaend}$areaend{/dede:areaend}
  39. {/dede:listrule}\r\n";
  40. $itemconfig = "{dede:sppage sptype=\\'$sptype\\' srul=\\'$srul\\' erul=\\'$erul\\'}$sppage{/dede:sppage}\r\n";
  41. $itemconfig .= "{dede:previewurl}$previewurl{/dede:previewurl}\r\n";
  42. $itemconfig .= "{dede:keywordtrim}$keywordtrim{/dede:keywordtrim}\r\n";
  43. $itemconfig .= "{dede:descriptiontrim}$descriptiontrim{/dede:descriptiontrim}\r\n";
  44. $fs = explode(',','value,match,isunit,isdown,trim,function');
  45. foreach($fields as $field)
  46. {
  47. foreach($fs as $f)
  48. {
  49. $GLOBALS[$f.'_'.$field] = (!isset($GLOBALS[$f.'_'.$field]) ? '' : $GLOBALS[$f.'_'.$field]);
  50. }
  51. $matchstr = $GLOBALS["match_".$field];
  52. $trimstr = $GLOBALS["trim_".$field];
  53. $trimstr = trim(str_replace('&nbsp;', '#n#', $trimstr));
  54. $matchstr = trim(str_replace('&nbsp;', '#n#', $matchstr));
  55. if($trimstr!='' && !preg_match("#{dede:trim#isU", $trimstr))
  56. {
  57. $trimstr = " {dede:trim}$trimstr{/dede:trim}\r\n";
  58. }
  59. $itemconfig .= "{dede:item field=\\'".$field."\\' value=\\'".$GLOBALS["value_".$field]."\\' isunit=\\'".$GLOBALS["isunit_".$field]."\\' isdown=\\'".$GLOBALS["isdown_".$field]."\\'}
  60. {dede:match}".$matchstr."{/dede:match}
  61. $trimstr
  62. {dede:function}".$GLOBALS["function_".$field]."{/dede:function}
  63. {/dede:item}";
  64. }
  65. $uptime = time();
  66. if(empty($freq)) $freq = 1;
  67. if(empty($extypeid)) $extypeid = 0;
  68. if(empty($islisten)) $islisten = 0;
  69. $query = " UPDATE `#@__co_note` SET
  70. `channelid`='$channelid',
  71. `notename`='$notename',
  72. `sourcelang`='$sourcelang',
  73. `uptime`='$uptime',
  74. `isok`='1',
  75. `usemore`='$usemore',
  76. `listconfig`='$listconfig',
  77. `itemconfig`='$itemconfig'
  78. WHERE nid='$nid'; ";
  79. $rs = $dsql->ExecuteNoneQuery($query);
  80. echo $dsql->GetError();
  81. if($donext=='save')
  82. {
  83. ShowMsg("成功保存配置!","co_main.php");
  84. }
  85. else
  86. {
  87. require_once(dirname(__FILE__)."/co_test_rule.php");
  88. }
  89. exit();
  90. }
  91. $arr = $dsql->GetOne("SELECT * FROM `#@__co_note` WHERE nid='$nid'");
  92. //如果内容规则未设置,转到设置内容规则的表单
  93. if(trim($arr['itemconfig'])=='')
  94. {
  95. $channelid = $arr['channelid'];
  96. $nid = $arr['nid'];
  97. if(!isset($previewurl)) $previewurl = '';
  98. require_once(DEDEINC.'/dedetag.class.php');
  99. require_once(DEDEADMIN."/templets/co_add_step2.htm");
  100. exit();
  101. }
  102. $usemore = $arr['usemore'];
  103. $notename = $arr['notename'];
  104. $notes = array();
  105. $dsql->FreeResult();
  106. $dtp = new DedeTagParse();
  107. $dtp2 = new DedeTagParse();
  108. $dtp->LoadString($arr['listconfig'].$arr['itemconfig']);
  109. $channelid = $arr['channelid'];
  110. $notes['keywordtrim'] = '';
  111. $notes['descriptiontrim'] = '';
  112. foreach($dtp->CTags as $tid => $ctag)
  113. {
  114. if($ctag->GetName()=='item')
  115. {
  116. $f = $ctag->GetAtt('field');
  117. $notes[$f]['item'] = $ctag;
  118. $dtp2->LoadString($ctag->GetInnerText());
  119. $notes[$f]['trim'] = '';
  120. foreach($dtp2->CTags as $ctag2)
  121. {
  122. if($ctag2->GetName()=='trim')
  123. {
  124. $notes[$f]['trim'] .= "{dede:trim replace=\"".$ctag2->GetAtt('replace')."\"}".$ctag2->GetInnerText()."{/dede:trim}\r\n";
  125. }
  126. else if($ctag2->GetName()=='match')
  127. {
  128. $notes[$f]['match'] = $ctag2->GetInnerText()."\r\n";
  129. }
  130. else if($ctag2->GetName()=='function')
  131. {
  132. $notes[$f]['function'] = $ctag2->GetInnerText()."\r\n";
  133. }
  134. }
  135. }
  136. else if($ctag->GetName()=='keywordtrim')
  137. {
  138. $notes['keywordtrim'] = $ctag->GetInnerText();
  139. }
  140. else if($ctag->GetName()=='descriptiontrim')
  141. {
  142. $notes['descriptiontrim'] = $ctag->GetInnerText();
  143. }
  144. else if($ctag->GetName()=='noteinfo')
  145. {
  146. $noteinfo = $ctag;
  147. }
  148. else if($ctag->GetName()=='listrule')
  149. {
  150. $listrule = $ctag;
  151. $dtp2->LoadString($ctag->GetInnerText());
  152. $addurls = $dtp2->GetTagByName('addurls');
  153. $regxrule = $dtp2->GetTagByName('regxrule');
  154. $areastart = $dtp2->GetTagByName('areastart');
  155. $areaend = $dtp2->GetTagByName('areaend');
  156. $batchrule = $dtp2->GetTagByName('batchrule');
  157. }
  158. else if($ctag->GetName()=='sppage')
  159. {
  160. $sppage = $ctag;
  161. }
  162. else if($ctag->GetName()=='previewurl')
  163. {
  164. $previewurl = trim($ctag->GetInnerText());
  165. }
  166. }
  167. if(!isset($previewurl)) $previewurl = '';
  168. require_once(DEDEADMIN.'/templets/co_edit.htm');