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

145 lines
6.0KB

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