Bao10jie.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | log.php 后台操作日志
  5. |--------------------------------------------------------------------------
  6. */
  7. namespace DeverApp\Manage\Filter;
  8. use Dever;
  9. require_once(dirname(__FILE__).'/bao10jie/BCPurifyClient.php');
  10. require_once(dirname(__FILE__).'/bao10jie/BCPurifyItem.php');
  11. require_once(dirname(__FILE__).'/bao10jie/BCPurifyResult.php');
  12. class Bao10jie
  13. {
  14. static public function cron($config, $content, $project, $table, $id, $ids)
  15. {
  16. $data = parse_str($content);
  17. $param[0]['isBatch'] = 1;
  18. $param[0]['appType'] = $project;
  19. $param[0]['textId'] = $ids;
  20. $param[0]['threadId'] = '';
  21. $param[0]['class'] = '';
  22. $param[0]['ip'] = Dever::ip();
  23. $param[0]['userId'] = '';
  24. $param[0]['author'] = '';
  25. $param[0]['title']= isset($data['dever_name']) ? $data['dever_name'] : '';
  26. $param[0]['text'] = $content;
  27. $param[0]['url'] = '';
  28. $param[0]['pubDate'] = date('Y-m-d H:i:s');
  29. $param[0]['authorEx'] = '';
  30. $param[0]['contentEx'] = '';
  31. $param[0]['structureEx'] = '';
  32. $param[0]['rules'] = '';
  33. $state = self::run($param, 'Purify');
  34. if($state == 1)
  35. {
  36. self::delete($project, $table, $id);
  37. }
  38. }
  39. static public function delete($project, $table, $id)
  40. {
  41. Dever::load($project . '/' . $table . '-update', array('where_id' => $id, 'set_state' => 2));
  42. }
  43. static private function run($param, $task)
  44. {
  45. // TODO Auto-generated method stub
  46. $item = new BCPurifyItem();
  47. $item->m_hlParmas = $param;
  48. $client = new BCPurifyClient();
  49. // Purify/Feedback/getNotify/getIndexResult
  50. $result = $client->{$task}($item);
  51. if (!$result) {
  52. //客户端内部错误,返回字段校验错误(例:appType cannot be empty)或网络请求错误(例:http code:404)
  53. $error .= $client->getError();
  54. //ErrorLog::addLog($error, 'systemError');
  55. return -1;
  56. }elseif ($result->isBusinessSuccess()){
  57. //成功时取结果集,返回数组对象
  58. if ($result->getMarkResult() != null) {
  59. $status = $result->getMarkResult();
  60. return (int)$status->flag;
  61. }else {
  62. $error .= var_export($param, true);
  63. //ErrorLog::addLog($error, 'unknowError');
  64. return -2;
  65. }
  66. }else {
  67. //失败时取结果集
  68. $status = (array)$result->getMarkResult();
  69. $error .= var_export($status, true);
  70. //ErrorLog::addLog($error, 'verifyError');
  71. return -3;
  72. }
  73. }
  74. }