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

102 lines
3.2KB

  1. <?php
  2. /**
  3. * 导入采集规则
  4. *
  5. * @version $Id: co_get_corule.php 1 17:13 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(dirname(__FILE__)."/config.php");
  13. CheckPurview('co_AddNote');
  14. if(empty($job))
  15. {
  16. $job='';
  17. }
  18. if($job=='')
  19. {
  20. require_once(DEDEINC."/../include/oxwindow.class.php");
  21. $wintitle = "导入采集规则";
  22. $wecome_info = "<a href='co_main.php'><u>采集点管理</u></a>::导入采集规则";
  23. $win = new OxWindow();
  24. $win->Init("co_get_corule.php","js/blank.js","POST");
  25. $win->AddHidden("job","yes");
  26. $win->AddTitle("请在下面输入你要导入的文本配置:(建议用base64编码[支持不编码的规则,但不兼容旧版规则])");
  27. $win->AddMsgItem("<textarea name='notes' style='width:100%;height:300px'></textarea>");
  28. $winform = $win->GetWindow("ok");
  29. $win->Display();
  30. exit();
  31. }
  32. else
  33. {
  34. CheckPurview('co_AddNote');
  35. require_once(DEDEINC."/dedetag.class.php");
  36. $notes = trim($notes);
  37. //对Base64格式的规则进行解码
  38. if(ereg('^BASE64:',$notes))
  39. {
  40. if(!ereg(':END$',$notes))
  41. {
  42. ShowMsg('该规则不合法,Base64格式的采集规则为:BASE64:base64编码后的配置:END !','-1');
  43. exit();
  44. }
  45. $notess = explode(':',$notes);
  46. $notes = $notess[1];
  47. $notes = base64_decode(ereg_replace("[\r\n\t ]",'',$notes)) OR die('配置字符串有错误!');
  48. }
  49. else
  50. {
  51. $notes = stripslashes($notes);
  52. }
  53. $dtp = new DedeTagParse();
  54. $dtp->LoadString($notes);
  55. if(!is_array($dtp->CTags))
  56. {
  57. ShowMsg('该规则不合法,无法导入!','-1');
  58. exit();
  59. }
  60. $ctag1 = $dtp->GetTagByName('listconfig');
  61. $ctag2 = $dtp->GetTagByName('itemconfig');
  62. $listconfig = $ctag1->GetInnerText();
  63. $itemconfig = addslashes($ctag2->GetInnerText());
  64. $dtp->LoadString($listconfig);
  65. $listconfig = addslashes($listconfig);
  66. $noteinfo = $dtp->GetTagByName('noteinfo');
  67. if(!is_object($noteinfo))
  68. {
  69. ShowMsg("该规则不合法,无法导入!","-1");
  70. exit();
  71. }
  72. foreach($noteinfo->CAttribute->Items as $k=>$v)
  73. {
  74. $$k = addslashes($v);
  75. }
  76. $uptime = time();
  77. if(empty($freq))
  78. {
  79. $freq = 1;
  80. }
  81. if(empty($extypeid))
  82. {
  83. $extypeid = 0;
  84. }
  85. if(empty($islisten))
  86. {
  87. $islisten = 0;
  88. }
  89. $inquery = " INSERT INTO `#@__co_note`(`channelid`,`notename`,`sourcelang`,`uptime`,`cotime`,`pnum`,`isok`,`usemore`,`listconfig`,`itemconfig`)
  90. VALUES ('$channelid','$notename','$sourcelang','$uptime','0','0','0','$usemore','$listconfig','$itemconfig'); ";
  91. $rs = $dsql->ExecuteNoneQuery($inquery);
  92. if(!$rs)
  93. {
  94. ShowMsg("保存信息时出现错误!".$dsql->GetError(),"-1");
  95. exit();
  96. }
  97. ShowMsg("成功导入一个规则!","co_main.php");
  98. exit();
  99. }
  100. ?>