Run the Normalizer.

@return mixed normalized $value
178603
public function run()
    {
        //check for inline linebreaks
        $search      = ['\r', '\n', '\f', '\t', '\v'];
        $this->value = str_replace($search, ';', $this->value);
        // replace replacement characters regular spaces
        $this->value = str_replace('�', ' ', $this->value);

        //convert real linebreaks
        return preg_replace('/(?:\n|\r|\v)/m', '  ', $this->value);
    }
430958
public function run()
	{
		$timestamp = date( 'Y-m-d H:i:s' );
		$context = clone $this->getContext();

		$context->getLocale()->setLanguageId( null );
		$context->getLocale()->setCurrencyId( null );

		$manager = \Aimeos\MShop\Index\Manager\Factory::create( $context );

		$manager->rebuildIndex();
		$manager->cleanupIndex( $timestamp );
	}
219726
public function run()
	{
		$this->say('Updating ' . $this->getJConfig()->extension . " to " . $this->getJConfig()->version);

		// Reusing the header config here
		$exclude = explode(",", trim($this->getJConfig()->header->exclude));

		$path      = realpath($this->getJConfig()->source);
		$fileTypes = explode(",", trim($this->getJConfig()->header->files));

		$changedFiles = 0;

		foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)) as $filename)
		{
			if (substr($filename, 0, 1) == '.')
			{
				continue;
			}

			$file = new \SplFileInfo($filename);

			if (!in_array($file->getExtension(), $fileTypes))
			{
				continue;
			}

			// Skip directories in exclude list
			if (isset($exclude) && count($exclude))
			{
				$relative = str_replace(realpath($path), "", $file->getPath());

				// It is possible to have multiple exclude directories
				foreach ($exclude as $e)
				{
					if (stripos($relative, $e) !== false)
					{
						$this->say("Excluding " . $filename);
						continue 2;
					}
				}
			}

			// Load the file
			$fileContents = file_get_contents($file->getRealPath());

			if (preg_match('#__DEPLOY_VERSION__#', $fileContents))
			{
				$fileContents = preg_replace('#__DEPLOY_VERSION__#', $this->getJConfig()->version, $fileContents);

				$this->say('Updating file: ' . $file->getRealPath());

				file_put_contents($file->getRealPath(), $fileContents);

				$changedFiles++;
			}
		}

		$this->say('Updated ' . $changedFiles . ' files');

		return true;
	}
1174546
protected function run()
    {
        $constant2 = pack('c*', 0x9A, 0x99, 0x99, 0x99, 0x99, 0x99, 0xF9, 0x3F);
        $separator = pack('c*', 0x9D, 0xFF, 0xFF, 0xFF);
        $scenarioConstant = pack('c*', 0xF6, 0x28, 0x9C, 0x3F);
        $aokSeparator = pack('c*', 0x9A, 0x99, 0x99, 0x3F);
        $aoe2recordScenarioSeparator = pack('c*', 0xAE, 0x47, 0xA1, 0x3F);
        $aoe2recordHeaderSeparator = pack('c*', 0xA3, 0x5F, 0x02, 0x00);

        $rec = $this->rec;
        $this->analysis = new \StdClass;
        $analysis = $this->analysis;

        $playersByIndex = [];
        $gameType = -1;

        $size = strlen($this->header);
        $this->position = 0;

        $this->version = $this->read(VersionAnalyzer::class);
        $version = $this->version;

        $triggerInfoPos = strrpos($this->header, $constant2, $this->position) + strlen($constant2);
        $gameSettingsPos = strrpos($this->header, $separator, -($size - $triggerInfoPos)) + strlen($separator);
        $scenarioSeparator = $scenarioConstant;
        if ($version->isAoK) {
            $scenarioSeparator = $aokSeparator;
        }
        if ($version->isAoe2Record) {
            $scenarioSeparator = $aoe2recordScenarioSeparator;
        }
        $scenarioHeaderPos = strrpos($this->header, $scenarioSeparator, -($size - $gameSettingsPos));
        if ($scenarioHeaderPos !== false) {
            $scenarioHeaderPos -= 4;
        }

        if ($version->isAoe2Record) {
            $aoe2recordHeader = $this->read(Aoe2RecordHeaderAnalyzer::class);
        }

        $includeAi = $this->readHeader('L', 4);
        if ($includeAi !== 0) {
            $this->skipAi();
        }

        $this->position += 4;
        if ($version->isAoe2Record) {
            $this->position += 4;
            $gameSpeed = $aoe2recordHeader['gameSpeed'];
        } else {
            $gameSpeed = $this->readHeader('l', 4);
        }
        // These bytes contain the game speed again several times over, as ints
        // and as floats (On normal speed: 150, 1.5 and 0.15). Why?!
        $this->position += 37;
        $pov = $this->readHeader('v', 2);
        if ($version->isAoe2Record) {
            $numPlayers = $aoe2recordHeader['numPlayers'];
            $gameMode = $aoe2recordHeader['isMultiPlayer'];
            $this->position += 5;
        } else {
            $numPlayers = ord($this->header[$this->position++]);
            $numPlayers -= 1;
            // - 1, because player #0 is GAIA.
            if ($version->isMgx) {
                $this->position += 1; // Is instant building enabled? (cheat "aegis")
                $this->position += 1; // Are cheats enabled?
            }
            $gameMode = $this->readHeader('v', 2);
        }

        // TODO what are these?
        // Something is up here because we do `+=46` just below which makes for `+=58` anyway.
        // For some reason PHP runs out of memory if I do it differently…
        if ($version->subVersion >= 12.50) {
            $this->position += 12;
        }

        $analysis->numPlayers = $numPlayers;

        if ($version->isAoe2Record && $version->subVersion >= 12.49) {
            $this->position += 46;
        } else {
            $this->position += 58;
        }

        $mapData = $this->read(MapDataAnalyzer::class);
        $analysis->mapSize = $mapData->mapSize;

        // int. Value is 10060 in AoK recorded games, 40600 in AoC and on.
        $this->position += 4;

        $playerInfoPos = $this->position;

        $this->analysis->scenarioFilename = null;
        if ($scenarioHeaderPos > 0) {
            $this->position = $scenarioHeaderPos;
            $this->readScenarioHeader();
            // Set game type here, it will be overwritten by data from the
            // recorded game settings later. In MGL files there is no game
            // type field in the recorded game, so this one will be used.
            $gameType = GameSettings::TYPE_SCENARIO;
        }

        $analysis->messages = $this->readMessages();

        // Skip two separators to find the victory condition block.
        $this->position = strpos($this->header, $separator, $this->position);
        $this->position = strpos($this->header, $separator, $this->position + 4);

        $analysis->victory = $this->read(VictorySettingsAnalyzer::class);

        $this->position = $gameSettingsPos + 8;

        // TODO Is 12.3 the correct cutoff point?
        if ($version->subVersion >= 12.3) {
            // TODO what are theeeese?
            $this->position += 16;
        }

        if ($version->isAoe2Record) {
            // Always 0? Map ID is now in the aoe2record front matter and gets
            // parsed below.
            $this->position += 4;
            $mapId = $aoe2recordHeader['mapId'];
        } else if (!$version->isAoK) {
            $mapId = $this->readHeader('l', 4);
        }
        $difficulty = $this->readHeader('l', 4);
        $lockTeams = $this->readHeader('L', 4);

        $players = $this->read(PlayerMetaAnalyzer::class);
        foreach ($players as $player) {
            $playersByIndex[$player->index] = $player;
            if ($player->index === $pov) {
                $player->owner = true;
            }
        }

        // Merge in player from the aoe2record header if it exists.
        // In some cases (eg. civId) the places where the data was originally stored is now empty,
        // with the data instead only being stored in the aoe2record header.
        // Other player analyzers will fall back to this data in those cases.
        if ($version->isAoe2Record && array_key_exists('players', $aoe2recordHeader)) {
            foreach ($players as $i => $player) {
                foreach ($aoe2recordHeader['players'][$i] as $key => $value) {
                    $player->$key = $value;
                }
            }
        }

        $analysis->players = $players;

        $this->position = $triggerInfoPos + 1;
        $this->skipTriggerInfo();

        $teamIndices = [];
        for ($i = 0; $i < 8; $i += 1) {
            $teamIndices[$i] = ord($this->header[$this->position + $i]);
        }
        $this->position += 8;

        foreach ($analysis->players as $i => $player) {
            $player->team = $teamIndices[$i] - 1;
        }

        $restore = $this->position;

        $this->position = $playerInfoPos;
        $playerInfo = $this->read(PlayerInfoBlockAnalyzer::class, $analysis);

        $this->position = $restore;

        if ($version->subVersion < 12.3) {
            $this->position += 1;
        }
        $revealMap = $this->readHeader('l', 4);

        $this->position += 4;
        $mapSize = $this->readHeader('l', 4);
        $popLimit = $this->readHeader('l', 4);

        if ($version->isMgx) {
            $gameType = ord($this->header[$this->position]);
            $lockDiplomacy = ord($this->header[$this->position + 1]);
            $this->position += 2;
        }

        if ($version->subVersion >= 11.96) {
            $this->position += 1;
        }

        if ($version->isHDEdition) {
            $this->position += 4;
        }

        $pregameChat = [];
        if ($version->isMgx) {
            $pregameChat = $this->readChat($players);
        }

        $analysis->teams = $this->buildTeams($players);

        $gameSettings = [
            'gameType' => $gameType,
            'gameSpeed' => $gameSpeed,
            'mapSize' => $mapSize,
            'difficultyLevel' => $difficulty,
            // UserPatch stores the actual population limit divided by 25.
            'popLimit' => $version->isUserPatch ? $popLimit * 25 : $popLimit,
        ];

        if (!$version->isAoK) {
            $gameSettings = array_merge($gameSettings, [
                'mapId' => $mapId,
                'lockDiplomacy' => $lockDiplomacy,
            ]);
        }

        $gameInfo = new GameInfo($this->rec);

        $analysis->mapData = $mapData->terrain;
        $analysis->pregameChat = $pregameChat;
        $analysis->gameSettings = new GameSettings($this->rec, $gameSettings);
        $analysis->gameInfo = $gameInfo;
        $analysis->playerInfo = $playerInfo;

        return $analysis;
    }
975601
public function run()
    {
        $data = [
            'Home',
            'Mobile',
            'Office',
            'Other',
        ];

        foreach ($data as $datum) {
            \CleaniqueCoders\Profile\Models\PhoneType::create([
                'name'  => $datum,
                'label' => Str::slug($datum, '-'),
            ]);
        }
    }
31034
public function run()
    {
        $maxATime = time() - self::TTL;

        $files = Finder::create()
            ->in($this->storePath)
            ->depth(1)
            ->name(Runner::BOOTSTRAP_FILENAME)
            ->filter(function (SplFileInfo $d) use ($maxATime) {
                return $d->getATime() < $maxATime;
            })
        ;

        $directories = array();

        foreach ($files as $file) {
            $directories[] = dirname($file);
        }

        $this->filesystem->remove($directories);
    }
874990
public function run()
    {
 
        
        $sample = file_get_contents($this->parameters['tpl']);
        $target = $this->parameters['target'];
        
        $serverName = $this->parameters['serverName'];
        $documentRoot = $this->parameters['documentRoot'];
        $directory = array();
        
        $it = new RecursiveDirectoryIterator($documentRoot);

        foreach (new RecursiveIteratorIterator($it) as $file) {
            if($file->getFileName() == '.htaccess' 
                && strpos($file->getPath(), 'install/checks/testRewrite') ===false){
              
          
               $pathName = $file->getPathname();
               $path = $file->getPath();
               
               $directory[$path] = "\t<Directory ". $path . ">\n";
               $htaccess = file_get_contents($pathName);
               $directory[$path] .= $htaccess;
               $directory[$path] .= "\n\t</Directory>\n";
               
            }
        }
        
        $directoryContent = implode("\n",array_values($directory));
    
        $maps = array(
        	'{ServerName}' => $serverName,
            '{DocumentRoot}' => $documentRoot,
            '{Directory}' => $directoryContent
        );
        
        $finalContent = str_replace(array_keys($maps), array_values($maps), $sample);
        file_put_contents($target, $finalContent);
    }
944682
public function run() {
        $results = [
            $this->doDelete(),
            $this->doUpdate(),
            $this->doCreate()
        ];
        return array_search(false, $results, true) === false;
    }
1318490
public function normalize()
    {
        $data = $this->get();
        if (is_array($data)) {
            $data = implode($this->separator, $data);
        }
        $data = trim($data, $this->separator);
        if (!$data) {
            $data = null;
        }

        if (get_magic_quotes_gpc()) {
            $this->set(stripslashes($data));
        } else {
            $this->set($data);
        }

        return parent::normalize();
    }
341938
public function run()
    {
        $documents = $this->repo->findAll();

        if ($predicates = $this->predicate->getAll()) {
            $documents = $this->filter($documents, $predicates);
        }

        if ($this->orderBy) {
            $sorts = array();
            foreach ($this->orderBy as $order) {
                $parts = explode(' ', $order, 2);
                // TODO - validate parts
                $sorts[] = array(
                    $parts[0],
                    isset($parts[1]) && $parts[1] == 'DESC' ? SORT_DESC : SORT_ASC
                );
            }

            $documents = $this->sort($documents, $sorts);
        }

        $totalCount = count($documents);

        if ($this->limit) {
            list($count, $offset) = $this->limit;
            $documents = array_slice($documents, $offset, $count);
        }

        return new Result(array_values($documents), $totalCount);
    }
247431
protected function run()
    {
        $versionString = rtrim($this->readHeaderRaw(8));
        $subVersion = round($this->readHeader('f', 4), 2);

        $version = $this->getVersion($versionString, $subVersion);

        $analysis = new Version($this->rec, $versionString, $subVersion);
        $analysis->version = $version;

        $analysis->isTrial = in_array($version, $this->trialVersions);
        $analysis->isAoK = in_array($version, $this->aokVersions);
        $analysis->isUserPatch = in_array($version, $this->userpatchVersions);
        $analysis->isUserPatch15 = $version === Version::VERSION_USERPATCH15;
        $analysis->isHDEdition = in_array($version, $this->hdVersions);
        $analysis->isHDPatch4 = $analysis->isHDEdition && $subVersion >= 12.00;
        $analysis->isAoC = $analysis->isUserPatch || $analysis->isHDEdition ||
            in_array($version, $this->aocVersions);

        $analysis->isMgl = $analysis->isAoK;
        $analysis->isMgx = $analysis->isAoC;
        $analysis->isMgz = $analysis->isUserPatch;
        // FIXME Not sure if this is the correct cutoff point.
        //
        // test/recs/versions/mgx2_simple.mgx2
        //    has subVersion == 12.31
        // test/recs/versions/MP Replay v4.3 @2015.09.11 221142 (2).msx
        //    has subVersion == 12.34
        // So it's somewhere between those two.
        $analysis->isMsx = $subVersion >= 12.32;
        $analysis->isAoe2Record = $subVersion >= 12.36;

        return $analysis;
    }
1273979
public function run()
    {
        if (! $this->runPreSearch()) {
            return $this->value;
        }

        $converted = null;
        //deal with double encoded payload
        $this->value = preg_replace('/&amp;/', '&', $this->value);
        if (preg_match('/&#x?[\w]+/ms', $this->value)) {
            $converted = preg_replace('/(&#x?[\w]{2,6}\d?);?/ms', '$1;', $this->value);
            $converted = html_entity_decode($converted, ENT_QUOTES, 'UTF-8');
            $this->value .= "\n".str_replace(';;', ';', $converted);
        }
        // normalize obfuscated protocol handlers
        $this->value = preg_replace(
            '/(?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t\s*:)|(d\s*a\s*t\s*a\s*:)/ms',
            'javascript:',
            $this->value
        );

        return $this->value;
    }
52158
public function run()
    {
        MaterializeAsset::register($this->getView());
        $html[] = $this->renderItems();

        return implode("\n", $html);
    }
1176040
public function run()
    {
        $this->registerPlugin('Materialbox', '.materialboxed');

        $tag = ArrayHelper::remove($this->options, 'tag', 'div');
        $html[] = Html::beginTag($tag, $this->options);

        $html[] = Html::img($this->imageSrc, $this->imageOptions);

        $html[] = Html::endTag($tag);

        return implode("\n", $html);
    }
186258
public function run()
    {
        //normalize remaining backslashes
        if ($this->value != preg_replace('/(\w)\\\/', '$1', $this->value)) {
            $this->value .= preg_replace('/(\w)\\\/', '$1', $this->value);
        }

        $compare = stripslashes($this->value);

        $pattern = [
            '/(?:<\/\w+>\+<\w+>)/s',
            '/(?:":\d+[^"[]+")/s',
            '/(?:"?"\+\w+\+")/s',
            '/(?:"\s*;[^"]+")|(?:";[^"]+:\s*")/s',
            '/(?:"\s*(?:;|\+)[^"]{8,18}:\s*")/s',
            '/(?:";\w+=)|(?:!""&&")|(?:~)/s',
            '/(?:"?"\+""?\+?"?)|(?:;\w+=")|(?:"[|&]{2,})/s',
            '/(?:"\s*\W+")/s',
            '/(?:";\w\s*\+=\s*\w?\s*")/s',
            '/(?:"[|&;]+\s*[^|&\n]*[|&]+\s*"?)/s',
            '/(?:";\s*\w+\W+\w*\s*[|&]*")/s',
            '/(?:"\s*"\s*\.)/s',
            '/(?:\s*new\s+\w+\s*[+",])/',
            '/(?:(?:^|\s+)(?:do|else)\s+)/',
            '/(?:[{(]\s*new\s+\w+\s*[)}])/',
            '/(?:(this|self)\.)/',
            '/(?:undefined)/',
            '/(?:in\s+)/',
        ];

        // strip out concatenations
        $converted = preg_replace($pattern, null, $compare);

        //strip object traversal
        $converted = preg_replace('/\w(\.\w\()/', '$1', $converted);

        // normalize obfuscated method calls
        $converted = preg_replace('/\)\s*\+/', ')', $converted);

        //convert JS special numbers
        $converted = preg_replace(
            '/(?:\(*[.\d]e[+-]*[^a-z\W]+\)*)|(?:NaN|Infinity)\W/ims',
            1,
            $converted
        );

        if ($converted && ($compare != $converted)) {
            $this->value .= "\n".$converted;
        }

        return $this->value;
    }
351034
public function run() {

		$categories = $this->getItems();

		if (empty($categories)) {
			return;
		}

		return $this->renderFile($this->template, [
        	'data' => [
        		'categories' => $categories,
            	'active_id' => $this->active_id,
            ],
		]);
	}
381393
public function run()
    {
        $params = $this->params;
        $params['content'] = ob_get_clean();
        // render under the existing context
        return $this->view->renderFile($this->viewFile, $params);
    }