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

100 lines
3.1KB

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