Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL | E_STRICT);
- // Добавлять сообщения обо всех ошибках, кроме E_NOTICE
- //error_reporting(E_ALL & ~E_NOTICE);
- ini_set('display_errors', TRUE);
- ini_set('display_startup_errors', TRUE);
- header('Content-type: text/html; charset=UTF-8');
- $g5 = microtime(true);
- $dir = 'folder'; // в какой директории файлы
- $files0 = array();
- $files1 = scandir($dir);
- $CountFiles1 = count($files1);
- for ($i = 0; $i < $CountFiles1; $i++) {
- $htm = preg_match('/\.html$/', $files1[$i]);
- if($htm == 0){unset($files1[$i]);}
- }
- sort($files1);
- $CountFiles2 = count($files1);
- for ($i = 0; $i < $CountFiles2; $i++) {
- // Это первый файл над которым будем работать
- $filename = "$dir/$files1[$i]";
- $handle = fopen("$filename", "r");
- $contents = fread($handle, filesize($filename));
- fclose($handle);
- ### Блок обрабатывающий длинные title файлов
- $contents = preg_replace("/style=\"(.*?)\"/ism", "", $contents);
- //Записываем в файл и закрываем его
- $handle = fopen("$filename", "w");
- if (fwrite($handle, $contents) === FALSE) {
- echo "Не могу произвести запись в файл ($filename)<br>";
- exit;
- }
- echo "Записано в файл ($filename) id=$i<br>";
- fclose($handle);
- }
- $g6 = microtime(true);
- $timescript = $g6 - $g5; echo $timescript; // время всех фраз
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement