/**
  *主控程序开始
  */
 public function __construct()
 {
     if (empty(Conf::$remote_path) && (Conf::$is_developing || !@file_exists(YYUC_FRAME_PATH . YYUC_PUB . '/@system'))) {
         include YYUC_LIB . 'plugin/@system/compress.php';
         $cp = new Compress();
         $cp->cpcss();
         $cp->cpjs();
         @File::all_copy(YYUC_FRAME_PATH . 'view/' . Conf::$view_folder . '/@style/media', YYUC_FRAME_PATH . YYUC_PUB . '/media', true);
         @File::all_copy(YYUC_LIB . 'forders/pub/@system', YYUC_FRAME_PATH . YYUC_PUB . '/@system', true);
     }
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function init()
 {
     $this->connect();
     $this->tmpFile();
     if (!is_file($this->config->file) || !is_readable($this->config->file)) {
         throw new Exception('Unable to access the source file.');
     }
     if ($this->compress) {
         $gzip = new Compress();
         $gzip->unpack($this->config->file, $this->temp);
     } else {
         copy($this->config->file, $this->temp);
     }
     $this->open($this->temp, 'r');
     $this->import();
     $this->close();
     $this->clean();
 }
Exemple #3
0
 public function insert($key, $var, $time, $compressed)
 {
     if ($compressed !== false) {
         $var = \Compress::driver($compressed)->compress($var);
     }
     $datas = array('time' => time(), 'ttl' => $time, 'data' => $var);
     if (\File::write($this->path . $key, serialize($datas))) {
         \File::permission($this->path . $key, 0640);
         return true;
     }
     return false;
 }
 /**
  * Takes rendered piece of html inside compress tag
  * and finds all css and js files to compress them.
  * @param string piece of rendered html
  * @return html with compressed css or js file
  */
 public static function compress($html)
 {
     if (in_array(Kohana::$environment, Kohana::$config->load('compress_for_twig.disabled_in_environments'))) {
         return $html;
     }
     preg_match_all('/<link[ a-zA-Z0-9="]+href="(.+?)"/s', $html, $files);
     if (Arr::get($files, 1)) {
         $result = Compress::instance('stylesheets')->styles(self::fix_paths(Arr::get($files, 1)));
         return HTML::style($result);
     }
     preg_match_all('/<script[ a-zA-Z0-9="]+src="(.+?)"/s', $html, $files);
     if (Arr::get($files, 1)) {
         $result = Compress::instance('javascripts')->scripts(self::fix_paths(Arr::get($files, 1)));
         return HTML::script($result);
     }
     return $html;
 }
$WEBSITE['JSCRIPT_FILES'][] = 'js/windows/WinType43/WinType43.js';
$WEBSITE['JSCRIPT_FILES'][] = 'js/windows/WinType43/WinType43Init.js';
$WEBSITE['JSCRIPT_FILES'][] = 'js/windows/WinType43/WinType43Listen.js';
$WEBSITE['JSCRIPT_FILES'][] = 'js/windows/WinType43/init.js';
$WEBSITE['JSCRIPT_FILES'][] = 'js/windows/bag_7x6/bag_7x6.js';
$WEBSITE['JSCRIPT_FILES'][] = 'js/windows/bag_7x6/bag_7x6Init.js';
$WEBSITE['JSCRIPT_FILES'][] = 'js/windows/bag_7x6/bag_7x6Listen.js';
$WEBSITE['JSCRIPT_FILES'][] = 'js/windows/bag_7x6/init.js';
//=========================================================
// Merge & compress script (static script to beginning of file)
//=========================================================
$js_file_content = '';
foreach ($WEBSITE['JSCRIPT_FILES'] as $file) {
    $js_file_content .= file_get_contents($file) . "\n";
}
$WEBSITE['JSCRIPT'] = $WEBSITE['COMPRESS_JS'] ? Compress::jscript($js_file_content . $WEBSITE['JSCRIPT']) : $js_file_content . $WEBSITE['JSCRIPT'];
//=========================================================
// Write script to script.js
// TODO: Might cause error whenever users open site simultaniously
//=========================================================
$result = file_put_contents('script.js', $WEBSITE['JSCRIPT_NS'] . $WEBSITE['JSCRIPT']);
//$result = file_put_contents('script.js', JSMin::minify($WEBSITE['JSCRIPT']));
//=========================================================
// Print script reference
//=========================================================
if ($result) {
    echo '<script type="text/javascript" src="script.js" /></script>';
} else {
    foreach ($WEBSITE['JSCRIPT_FILES'] as $file) {
        echo '<script type="text/javascript" src="' . $file . '" /></script>';
    }
 public function getDataUrl($url, $hasHeader = 'no', $follow = 'yes', $isGooglebot = 'yes')
 {
     $headers = array();
     // $headers[] = 'X-Apple-Tz: 0';
     // $headers[] = 'X-Apple-Store-Front: 143444,12';
     // $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
     // $headers[] = 'Accept-Encoding: gzip, deflate';
     // $headers[] = 'Accept-Language: en-US,en;q=0.5';
     $headers[] = 'Cache-Control: max-age=0';
     $headers[] = 'Content-Type: text/html';
     $headers[] = 'Connection: keep-alive';
     $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
     $headers[] = 'Accept-Encoding: gzip, deflate, sdch';
     // $headers[] = 'Host: www.example.com';
     // $headers[] = 'Referer: http://www.example.com/index.php'; //Your referrer address
     // $headers[] = 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0';
     // $headers[] = 'X-MicrosoftAjax: Delta=true';
     $ch = curl_init();
     if ($follow == 'yes') {
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     }
     curl_setopt($ch, CURLOPT_URL, $url);
     if ($hasHeader == 'yes') {
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5000);
     curl_setopt($ch, CURLOPT_TIMEOUT, 5000);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     $result = curl_exec($ch);
     // $result=gzuncompress($result);
     if ($hasHeader == 'yes') {
         $result = Compress::gzdecode($result);
     }
     // File::create(ROOT_PATH.'accc.txt',$result);
     return $result;
 }
Exemple #7
0
<?php

define('MINIPATH', realpath(dirname(__FILE__)) . '/');
define('SITEPATH', MINIPATH . '../../');
$params = array('debug' => TRUE, 'theme' => isset($_GET['theme']) ? $_GET['theme'] : 'default');
$compress = new Compress($params);
if (isset($_GET['js'])) {
    $_GET['js'] = $_GET['js'] == '' ? 'js' : $_GET['js'];
    $compress->serve_js($_GET['js']);
} else {
    if (isset($_GET['css'])) {
        $_GET['css'] = $_GET['css'] == '' ? 'styles' : $_GET['css'];
        $compress->serve_css($_GET['css']);
    }
}
class Compress
{
    private $debug = TRUE;
    private $charset = 'UTF-8';
    private $theme;
    private $js_path;
    private $css_path;
    private $cache_path;
    private $default_css = array('styles.css' => array('bootstrap.min.css', 'default.css', 'layout.css', 'content.css'));
    private $default_js = array();
    public function __construct($params)
    {
        $this->initialize($params);
    }
    public function serve_js($files)
    {
// Add global style
//=========================================================
$WEBSITE['CSS_FILES'][] = 'css/reset.css';
$WEBSITE['CSS_FILES'][] = 'css/main.css';
$WEBSITE['CSS_FILES'][] = 'css/win_mngr.css';
$WEBSITE['CSS_FILES'][] = 'css/windows/WinType42.css';
$WEBSITE['CSS_FILES'][] = 'css/windows/WinType43.css';
$WEBSITE['CSS_FILES'][] = 'css/windows/bag_7x6.css';
//=========================================================
// Merge & compress style (static style to beginning of file)
//=========================================================
$css_file_content = '';
foreach ($WEBSITE['CSS_FILES'] as $file) {
    $css_file_content .= file_get_contents($file) . "\n";
}
$WEBSITE['CSS'] = $WEBSITE['COMPRESS_CSS'] ? Compress::css($css_file_content . $WEBSITE['CSS']) : $css_file_content . $WEBSITE['CSS'];
//=========================================================
// Write style to style.css
//=========================================================
$result = file_put_contents('style.css', $WEBSITE['CSS']);
//=========================================================
// Print style reference
//=========================================================
if ($result) {
    echo '<link rel="stylesheet" type="text/css" media="all" href="style.css" />';
    //echo '<link rel="stylesheet" type="text/css" media="only screen and (max-width: 800px), only screen and (max-device-width: 800px)" href="css/stylesheet.css" />';
} else {
    foreach ($WEBSITE['CSS_FILES'] as $file) {
        echo '<link rel="stylesheet" type="text/css" media="all" href="' . $file . '" />';
    }
}
Exemple #9
0
 /**
  * Moves a temporary file to the final location.
  *
  * @return bool
  * @throws Exception
  */
 protected function move()
 {
     if ($this->compress) {
         $gzip = new Compress($this->config);
         $gzip->pack($this->temp, $this->config->file);
         unlink($this->temp);
         return true;
     }
     if (@rename($this->temp, $this->config->file)) {
         return true;
     }
     if (@copy($this->temp, $this->config->file) && unlink($this->temp)) {
         return true;
     }
     throw new Exception('Unable to move the temporary file.');
 }
	.footer a:hover {
		color: #000;
	}

</style>
</head>

<body>
<div class="wrapper">
<div class="header">
<h1>Release JS</h1>
</div>
<h2>List of Concatenated Files</h2>
<div class="list">
<?php 
$compress = new Compress();
$compress->addFolder("../lib/com/utensil/");
$compress->addFolder("../lib/com/fahimchowdhury/");
$compress->releaseURL = "../release/";
$compress->archiveURL = "../release/archive/";
$compress->releasePrefix = "toolkitMax-v";
$compress->addToIgnoreFile("PIE.js");
$compress->addToIgnoreFile("TouchController.js");
$compress->addToIgnoreFile("DebugTest.js");
$compress->addToIgnoreFolder("report");
$compress->addToIgnoreFolder("media");
$compress->addToIgnoreFolder("game");
$compress->init();
$html = file_get_contents("release_test.html");
$html = str_replace("toolkitMax-v" . ($compress->version - $compress->versionIncrement) . ".js", "toolkitMax-v" . $compress->version . ".js", $html);
file_put_contents("release_test.html", $html);