Просмотр поста

.
ramzes

за одно нате вам

компрессор css файлов (+/-)
function comp($name)
{

    $root = 'tpl/default/style/css/';
    $target = 'compressed/';


    if(file_exists($root.$name)){

        $css_file = file_get_contents($root.$name);
        $css_file = preg_replace('|/\*[^\*]+\*/|s', '', $css_file);
        $css_file = preg_replace ("|[\r\n]+|si",' ', $css_file);
        $css_file = preg_replace ('|[\s]+|si',' ', $css_file);
        $css_file = str_replace('  ', ' ', str_replace("\n", '', str_replace("\r", '', $css_file)));
        $css_file = str_replace('; ', ';', $css_file);
        $css_file = str_replace(': ', ':', $css_file);
        $css_file = str_replace('} ', '}', $css_file);
        $css_file = str_replace('{ ', '{', $css_file);
        $css_file = str_replace(' {', '{', $css_file);
        $css_file = str_replace(', ', ',', $css_file);
        file_put_contents($target.$name, $css_file);

        echo '<div style="border-bottom: 1px solid #357; padding: 2px; width: 400px"><b style="display: inline-block; min-width: 150px;">'.$name.'</b> Сжат. Экономия '.(round( (filesize($root.$name) - filesize($target.$name))/1024, 3) ).'kb</div>';
    }
    
}



$scan = scandir('tpl/default/style/css/');
echo '<h2>Scaning....</h2>';
foreach ($scan as $n=>$file){
    if($file!='.' AND $file!='..'){
        comp($file);
    }
}


Scaning....

_account.css Сжат. Экономия 2.64kb
_administraror.css Сжат. Экономия 0.742kb
_events.css Сжат. Экономия 0.939kb
_forum.css Сжат. Экономия 4.356kb
_login.css Сжат. Экономия 0.159kb
_mail.css Сжат. Экономия 0.401kb
_music.css Сжат. Экономия 0.992kb
_user.css Сжат. Экономия 3.311kb
audio.css Сжат. Экономия 5.235kb
colors.css Сжат. Экономия 3.607kb
core.css Сжат. Экономия 3.278kb
editor.css Сжат. Экономия 0.065kb