示例#1
0
 /**
  * Checks if a string is spam or not
  *
  * @param   string|array  $data
  * @return  object
  */
 public function examine(array $data, array $options = array())
 {
     $status = 0;
     $value = null;
     $meta = array();
     if (isset($data['standalone']) && $data['standalone']) {
         $status = 1;
         $meta['field'] = isset($data['title']) ? $data['title'] : $data['id'];
         if (isset($data['introtext'])) {
             $value = $data['introtext'];
         }
         if (isset($data['fulltxt'])) {
             $value = $data['fulltxt'];
         }
         if (!$value) {
             $status = -1;
         }
     }
     $result = new Result();
     $result->set(['scope_id' => $data['id'], 'status' => $status, 'notes' => json_encode($meta)]);
     return $result;
 }
示例#2
0
 /**
  * Checks if a string is spam or not
  *
  * @param   mixed   $data     string|array
  * @param   array   $options
  * @return  object
  */
 public function examine(array $data, array $options = array())
 {
     $path = '';
     $status = 0;
     $meta = array();
     if (isset($data['path']) && $data['path']) {
         $path = ltrim($data['path'], '/');
         $path = trim($path);
         $meta['field'] = $data['path'];
         $status = -1;
         if ($this->isLink($path)) {
             try {
                 $response = $this->client->head($path, ['exceptions' => false, 'timeout' => 10]);
                 $meta['code'] = $response->getStatusCode();
                 if ($response->getStatusCode() == 200) {
                     $status = 1;
                 }
             } catch (\Exception $e) {
                 $meta['error'] = $e->getMessage();
             }
         } else {
             $params = \Component::params('com_resources');
             $base = $params->get('uploadpath', '/site/resources');
             $base = PATH_APP . DS . trim($base, DS) . DS;
             if (is_dir($base . $path)) {
                 $meta['error'] = 'Path is a directory';
             }
             if (file_exists($base . $path)) {
                 $status = 1;
             }
         }
     }
     $result = new Result();
     $result->set(['scope_id' => $data['id'], 'status' => $status, 'notes' => json_encode($meta)]);
     return $result;
 }