Esempio n. 1
0
         $prefix .= preg_replace('/[^a-z0-9_-]/ui', '', $_REQUEST['css_prefix']);
     }
     $s = new CssSprite($padding, $reduceArtefacts, $prefix);
     $s->addDirectory($dir);
     $s->pack();
     $options = [];
     if ($type == 'jpeg' && isset($_REQUEST['jpeg_quality'])) {
         $options = [min(100, max(0, (int) $_REQUEST['jpeg_quality']))];
     } elseif ($type == 'png') {
         $options = [9, PNG_ALL_FILTERS];
     }
     $filepath = 'uploads/' . $token . '.' . $type;
     file_put_contents($filepath, $s->getImage($type, $options));
     $server = $_SERVER['HTTP_HOST'] == 'localhost:96' ? 'dev.justsayplease.co.uk:96' : $_SERVER['HTTP_HOST'];
     $response->url = 'http://' . $server . dirname($_SERVER['PHP_SELF']) . '/uploads/' . $token . '.' . $type;
     $response->css = $s->getCss();
     //$s->smush($filepath, $response->url);
     $oldSize = 0;
     $response->info = [];
     foreach ($s->getInfo() as $image) {
         $response->info[] = ['file' => $image['pathInfo']['basename'], 'x' => $image['x'], 'y' => $image['y'], 'width' => $image['width'], 'height' => $image['height'], 'class' => $image['class'], 'selector' => $image['selector'], 'css' => $image['css']];
         $oldSize += filesize($image['path']);
     }
     $response->oldSize = $oldSize;
     $response->newSize = filesize($filepath);
     $info = getimagesize($filepath);
     $response->width = $info[0];
     $response->height = $info[1];
 } elseif (isset($_REQUEST['cleanup'])) {
     if (isset($_REQUEST['token'])) {
         if (preg_match('/^[a-z0-9]+$/i', $_REQUEST['token'])) {
Esempio n. 2
0
                    $('#tabs').on('click', 'li', function()
                    {
                        $('#tabs li.selected').removeClass('selected');
                        $(this).addClass('selected');

                        $('div.tab.selected').removeClass('selected');
                        $($(this).find('a').attr('href')).addClass('selected');

                        return false;
                    });
                });
            })(jQuery);
        </script>
        <?php 
if ($done) {
    print '<style type="text/css">' . $sprite->getCss($spriteDataUri) . '</style>';
}
?>
    </head>
    <body>
        <div id="header">
            <div id="header-inner">
                <h1>
                    <a href="http://<?php 
echo htmlentities($_SERVER['HTTP_HOST']);
?>
">CSS Sprite Generator</a>
                </h1>
                <p>
                    Optimize your website using CSS Sprites!
                    Generate CSS Sprites to speed up your website by reducing HTTP requests.