Esempio n. 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;
 }
Esempio n. 2
0
 /**
  * Get summations
  *
  * @return  string
  */
 public function getReport()
 {
     if (!isset($this->report)) {
         $tests = array();
         foreach ($this->getTests() as $key => $audit) {
             if (!isset($tests[$key])) {
                 $tests[$key] = array('name' => $audit->name(), 'total' => 0, 'totals' => array('skipped' => 0, 'passed' => 0, 'failed' => 0));
             }
             $tests[$key]['totals']['skipped'] = Result::all()->whereEquals('scope', $this->scope)->whereEquals('test_id', $key)->whereEquals('status', 0)->total();
             $tests[$key]['totals']['passed'] = Result::all()->whereEquals('scope', $this->scope)->whereEquals('test_id', $key)->whereEquals('status', 1)->total();
             $tests[$key]['totals']['failed'] = Result::all()->whereEquals('scope', $this->scope)->whereEquals('test_id', $key)->whereEquals('status', -1)->total();
             $tests[$key]['total'] += $tests[$key]['totals']['skipped'];
             $tests[$key]['total'] += $tests[$key]['totals']['passed'];
             $tests[$key]['total'] += $tests[$key]['totals']['failed'];
         }
         $this->report = $tests;
     }
     return $this->report;
 }
Esempio n. 3
0
							</tr>
						</thead>
						<tbody>
							<?php 
        switch ($this->status) {
            case 'failed':
                $status = -1;
                break;
            case 'skipped':
                $status = 0;
                break;
            case 'passed':
                $status = 1;
                break;
        }
        $results = \Hubzero\Content\Auditor\Result::all()->whereEquals('scope', 'resource')->whereEquals('test_id', $this->test)->whereEquals('status', $status)->ordered()->rows();
        foreach ($results as $result) {
            ?>
								<tr>
									<th><?php 
            echo $result->get('scope_id');
            ?>
</th>
									<td><a href="<?php 
            echo Route::url('index.php?option=com_resources&task=edit&id=' . $result->get('scope_id'));
            ?>
">
										<?php 
            if ($notes = $result->get('notes')) {
                $notes = json_decode($notes);
                if (isset($notes->field)) {
Esempio n. 4
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;
 }