Пример #1
0
 /**
  * check $path for updates
  *
  * @param string $path
  */
 public function checkUpdate($path)
 {
     $cachedEntry = $this->cache->get($path);
     if ($this->storage->hasUpdated($path, $cachedEntry['mtime'])) {
         if ($this->storage->is_dir($path)) {
             $this->scanner->scan($path, Scanner::SCAN_SHALLOW);
         } else {
             $this->scanner->scanFile($path);
         }
         if ($cachedEntry['mimetype'] === 'httpd/unix-directory') {
             $this->cleanFolder($path);
         }
         $this->cache->correctFolderSize($path);
     }
 }
Пример #2
0
 /**
  * Update the cache for changes to $path
  *
  * @param string $path
  * @param array $cachedData
  */
 public function update($path, $cachedData)
 {
     if ($this->storage->is_dir($path)) {
         $this->scanner->scan($path, Scanner::SCAN_SHALLOW);
     } else {
         $this->scanner->scanFile($path);
     }
     if ($cachedData['mimetype'] === 'httpd/unix-directory') {
         $this->cleanFolder($path);
     }
     $this->cache->correctFolderSize($path);
 }
Пример #3
0
 /**
  * check $path for updates
  *
  * @param string $path
  * @return boolean|array true if path was updated, otherwise the cached data is returned
  */
 public function checkUpdate($path)
 {
     if ($this->watchPolicy === self::CHECK_ALWAYS or $this->watchPolicy === self::CHECK_ONCE and array_search($path, $this->checkedPaths) === false) {
         $cachedEntry = $this->cache->get($path);
         $this->checkedPaths[] = $path;
         if ($this->storage->hasUpdated($path, $cachedEntry['storage_mtime'])) {
             if ($this->storage->is_dir($path)) {
                 $this->scanner->scan($path, Scanner::SCAN_SHALLOW);
             } else {
                 $this->scanner->scanFile($path);
             }
             if ($cachedEntry['mimetype'] === 'httpd/unix-directory') {
                 $this->cleanFolder($path);
             }
             $this->cache->correctFolderSize($path);
             return true;
         }
         return $cachedEntry;
     } else {
         return false;
     }
 }
Пример #4
0
 /**
  * Update the cache for $path and update the size, etag and mtime of the parent folders
  *
  * @param string $path
  * @param int $time
  */
 public function update($path, $time = null)
 {
     if (!$this->enabled or Scanner::isPartialFile($path)) {
         return;
     }
     if (is_null($time)) {
         $time = time();
     }
     $data = $this->scanner->scan($path, Scanner::SCAN_SHALLOW, -1, false);
     $this->correctParentStorageMtime($path);
     $this->cache->correctFolderSize($path, $data);
     $this->propagator->propagateChange($path, $time);
 }
Пример #5
0
 * @link        http://mobicms.net mobiCMS Project
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 */
defined('MOBICMS') or die('Error: restricted access');
define('ROOT_DIR', '.');
$form = new Mobicms\Form\Form(['action' => App::request()->getUri()]);
$form->infoMessages = false;
$form->title(_m('Anti-Spyware'))->element('radio', 'mode', ['checked' => 1, 'items' => ['1' => _m('Scan to the appropriate distribution'), '2' => _m('Snapshot scan'), '3' => _m('Make snapshot')]])->divider()->element('submit', 'submit', ['value' => _s('Run'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _s('Back') . '</a>');
if ($form->process() === true) {
    require_once dirname(__DIR__) . '/classes/Scanner.php';
    $scanner = new Scanner();
    switch ($form->output['mode']) {
        case 1:
            // Сканируем на соответствие дистрибутиву
            $scanner->scan();
            if (count($scanner->modifiedFiles) || count($scanner->missingFiles) || count($scanner->newFiles)) {
                App::view()->modifiedFiles = $scanner->modifiedFiles;
                App::view()->missingFiles = $scanner->missingFiles;
                App::view()->extraFiles = $scanner->newFiles;
                App::view()->errormsg = _m('Distributive inconsistency!');
            } else {
                App::view()->ok = _m('List of files corresponds to the distributive');
            }
            break;
        case 2:
            // Сканируем на соответствие ранее созданному снимку
            $scanner->scan(true);
            if (count($scanner->whiteList) == 0) {
                App::view()->errormsg = _m('Snapshot image is not created');
            } else {
Пример #6
0
 /**
  * Parse M source code to PHP
  * @param string $source M language source code
  */
 public function parse($source)
 {
     $this->iterator = Scanner::scan($source);
     $this->parseBlock(FALSE);
     return $this;
 }
Пример #7
0
$all = array();
$language = $_SERVER['argv'][1];
$search = '';
for ($i = 2; $i < $_SERVER['argc']; $i++)
{
	$scanIt = $_SERVER['argv'][$i];

	if ($scanIt == 'coorg')
	{
		$sc = new Scanner('coorg/', new StringDictionary('coorg/lang', $language, 'coorg'));
	}
	else
	{
		$prefix = substr($scanIt, 0, strpos($scanIt, ':'));
		$suffix = substr($scanIt, strpos($scanIt, ':') + 1);
	
		$sc = new Scanner($prefix.'/'.$suffix, new StringDictionary($prefix.'/'.$suffix.'/lang', $language, $suffix));
	}
	$sc->scan();
}

foreach ($all as $string => $contexts)
{
	if (count($contexts) > 1)
	{
		echo "'$string' in contexts: " . implode(', ', $contexts)."\n\n";
	}
}
?>
Пример #8
0
 public function testAttributeCallback()
 {
     $called = 0;
     $cb = function () use(&$called) {
         $called++;
         return false;
     };
     $config = new Config();
     $config->addAttributeCallback($cb);
     $scanner = new Scanner($config);
     $scanner->start();
     $output = $scanner->scan("<a href='http://blah.com'>blah</a>");
     $output .= $scanner->end();
     $this->assertEquals(1, $called);
     $this->assertEquals("<a>blah</a>", $output);
 }