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

172 lines
6.0KB

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