/controller/admin.php
PHP | 6972 lines | 6693 code | 20 blank | 259 comment | 247 complexity | 53807590d2640c136dbb828ed06c5aa3 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * File from WEBO Site SpeedUp, WEBO Software (http://www.webogroup.com/)
- * Provides admin interface.
- *
- **/
- class admin {
- /**
- * Constructor
- * Sets the options and defines the gzip headers
- **/
- function admin ($options = null) {
- if (!empty($options['skip_startup'])) {
- return;
- }
- foreach ($options as $key => $value) {
- $this->$key = $value;
- }
- $this->skip_render = empty($this->skip_render) ? 0 : $this->skip_render;
- $this->time = time();
- if (!$this->skip_render) {
- /* Fixes time zone for future usage */
- if (function_exists('date_default_timezone_set')) {
- @date_default_timezone_set('Europe/Moscow');
- }
- /* Ensure no caching */
- header('Expires: ' . @date("r"));
- header("Cache-Control: no-store, no-cache, must-revalidate, private");
- header("Pragma: no-cache");
- }
- /* define website host */
- $host = empty($_SERVER['HTTP_HOST']) ? '' : strtolower($_SERVER['HTTP_HOST']);
- if (strpos($host, "www.") === 0) {
- $host = substr($host, 4);
- }
- /* Set name of options file, multi-configs supported */
- if ($host && @file_exists($this->basepath . $host . ".config.webo.php")) {
- $this->options_file = $host . ".config.webo.php";
- } else {
- $this->options_file = "config.webo.php";
- }
- /* try to restore options backup */
- if (@is_file($this->basepath . '.config.webo.php') && !strpos($this->file_get_contents($this->basepath . $this->options_file), '$compress_options[\'license\']')) {
- @copy($this->basepath . '.config.webo.php', $this->basepath . $this->options_file);
- $this->error = array(-1 => 1);
- }
- require($this->basepath . $this->options_file);
- $this->compress_options = empty($compress_options) ? '' : $compress_options;
- $this->start_cache_engine();
- /* to check and download new Web Optimizer version */
- $this->svn_generic = 'http://web-optimizator.googlecode.com/svn/';
- $this->svn = $this->svn_generic . 'trunk-stable/';
- $this->svn_beta = $this->svn_generic . 'trunk/';
- $this->version = str_replace(array("\r", "\n"), "", $this->file_get_contents($this->basepath . 'version'));
- $this->version_stable = preg_replace("[^0-9\.]", "", empty($this->input['wss_version_stable']) ? '' : $this->input['wss_version_stable']);
- /* get the latest version */
- $version_new_file = $this->compress_options['html_cachedir'] . 'version.new';
- $this->input['wss_page'] = empty($this->input['wss_page']) ? '' : $this->input['wss_page'];
- if (in_array($this->input['wss_page'],
- array('install_dashboard',
- 'install_set_password',
- 'install_enter_password',
- 'install_system',
- 'install_update',
- 'install_beta',
- 'install_stable',
- 'install_rollback'))) {
- $this->view->download($this->svn . 'version', $version_new_file, 5);
- }
- $this->version_new = $this->version . '+';
- if (@is_file($version_new_file)) {
- $this->version_new = str_replace(array("\r", "\n"), "", $this->file_get_contents($version_new_file));
- @unlink($version_new_file);
- }
- $this->version_beta = $this->version;
- /* check for beta version */
- if (in_array($this->input['wss_page'],
- array('install_system',
- 'install_beta',
- 'install_stable',
- 'install_rollback'))) {
- $this->view->download($this->svn_beta . 'version', $version_new_file, 5);
- if (@is_file($version_new_file)) {
- $this->version_beta = str_replace(array("\r", "\n"), "", $this->file_get_contents($version_new_file));
- @unlink($version_new_file);
- }
- }
- /* validate license */
- if (!empty($compress_options)) {
- /* reset license check */
- if (!empty($this->input['wss_license']) && $this->input['wss_license'] != $this->compress_options['license']) {
- @unlink($this->compress_options['html_cachedir'] . 'wo');
- }
- $this->compress_options['license'] =
- empty($this->input['wss_license']) ?
- $this->compress_options['license'] :
- $this->input['wss_license'];
- $this->premium = $this->view->validate_license($this->compress_options['license'],
- $this->compress_options['html_cachedir'], $this->compress_options['host']);
- $this->need_access = in_array($this->input['wss_page'],
- array('install_enter_password', 'install_set_password'));
- /* Make sure password valid */
- $this->check_password();
- if (!$this->access) {
- $this->input['wss_page'] = 'install_set_password';
- } elseif ($this->need_access) {
- $this->input['wss_page'] = 'install_dashboard';
- }
- /* default multiple hosts */
- $this->default_hosts = array('img', 'img1', 'img2', 'img3', 'img4', 'i', 'i1', 'i2', 'i3', 'i4', 'image', 'images', 'assets', 'static', 'css', 'js');
- /* Set page functions for the installation and admin, makes sure nothing else can be run */
- $this->page_functions = array('install_set_password', 'install_enter_password', 'install_dashboard', 'install_install', 'install_uninstall', 'install_promo', 'install_about', 'install_minify', 'install_gzip', 'install_image', 'install_cdn', 'install_status', 'install_account', 'install_refresh', 'install_renew', 'install_options', 'install_system', 'install_update', 'install_stable', 'install_rollback', 'install_beta', 'install_awards', 'install_balance', 'install_wizard', 'dashboard_cache', 'dashboard_system', 'dashboard_options', 'dashboard_speed', 'dashboard_awards', 'compress_gzip', 'compress_image', 'compress_cdn', 'compress_minify', 'options_configuration', 'options_delete');
- /* inializa stage for chained optimization */
- $this->web_optimizer_stage =
- round(empty($this->input['web_optimizer_stage']) ? 0 :
- $this->input['web_optimizer_stage']);
- /* grade URL from webo.name */
- $this->webo_grade = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?key=AIzaSyD1VD8YlfdF1RZpPrhOZ1awzuMs4t143Fo&url=http://' .
- $this->compress_options['host'] .
- str_replace($this->compress_options['document_root'], '/',
- $this->compress_options['website_root']);
- /* download counter */
- if (!is_file($this->basepath . 'web-optimizer-counter')) {
- $this->view->download('http://web-optimizator.googlecode.com/files/web-optimizer-counter',
- $this->basepath . 'web-optimizer-counter', 10);
- }
- /* download WPT evaluation */
- if (!is_file($this->basepath . 'web-optimizer-wpt') && !empty($this->compress_options['host'])) {
- $this->view->download('http://webo.name/check/wpt.php?url=http://' .
- $this->compress_options['host'] .
- str_replace($this->compress_options['document_root'], '/',
- $this->compress_options['website_root']) .
- '&email=' . $this->compress_options['email'], $this->basepath . 'web-optimizer-wpt');
- }
- }
- /* define constants for stats */
- $this->index_check = 'index.check';
- $this->index_before = 'index.before';
- $this->index_after = 'index.after';
- /* initialize info about cache types */
- $this->cache_types = array(
- 'js' => array('*.js', '*.js.gz'),
- 'js_php' => array('*script.php', '*script.php.gz', '*script.php.df'),
- 'css' => array('*.css', '*.css.gz'),
- 'css_php' => array('*link.php', '*link.php.gz', '*link.php.df'),
- 'res' => array('*.css.css', '*.css.css.gz', '*.php.php', '*.php.php.gz'),
- 'sprites' => array('webo.*.png', 'webo.*.jpg'),
- 'imgs' => array('*.png', '*.jpg', '*.gif', '*.bmp'),
- 'html' => array('*.html','*.html.gz', '*.html.df'),
- 'scripts' => array('*.php', '*.php.gz', '*.php.df')
- );
- /* define if we can skip some info */
- $this->internal = preg_match("@wp-content|components|modules|administrator|addons|app|engine@",
- str_replace($this->compress_options['document_root'], '/', $this->basepath));
- /* detect CS-Cart to */
- $this->cscart = strpos($this->basepath, 'addons/webositespeedup');
- /* check for database driver , WordPress */
- $this->internal_sql = strpos($this->basepath, "wp-content") !== false ||
- /* Joomla! 1.5x */
- (strpos($this->basepath, "components") !== false && @is_file($this->compress_options['website_root'] . 'libraries/joomla/database/database/WeboMySql.php'));
- /* fix for not supported languages */
- $this->language = empty($this->language) ? '' : $this->language;
- $this->language = in_array($this->language, array('en', 'de', 'es', 'ru', 'ua', 'fr', 'ur', 'it', 'da', 'bg')) ? $this->language : 'en';
- /* calculate configuration files for Extended and Corporate Editions */
- $this->find_configs($this->premium > 1 && $this->premium < 10);
- if ($this->compress_options['active']) {
- $this->validate();
- }
- $this->iis = !empty($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') !== false;
- /* show page */
- if (!empty($this->input) &&
- in_array($this->input['wss_page'], $this->page_functions) &&
- method_exists($this, $this->input['wss_page']) &&
- ($this->input['wss_page'] != 'install_set_password' ||
- empty($this->internal))) {
- $func = $this->input['wss_page'];
- $this->$func();
- }
- }
- /*
- * Return status of synced file
- *
- **/
- function compress_cdn () {
- $file = realpath($this->input['wss_file']);
- $size = @filesize($file);
- $error = 0;
- $success = 1;
- if (strpos($file, $this->view->paths['full']['document_root']) !== false &&
- !empty($this->compress_options['parallel']['ftp']) &&
- @function_exists('curl_init')) {
- $mime = '';
- /* calculate MIME type */
- switch (strtolower(preg_replace("!.*\.!is", "", $file))) {
- case 'js':
- $mime = 'application/x-javascript';
- break;
- case 'css':
- $mime = 'text/css';
- break;
- case 'jpg':
- $mime = 'jpeg';
- case 'jpeg':
- case 'bmp':
- case 'gif':
- case 'png':
- $mime = 'image/' . $mime;
- break;
- case 'cur':
- $mime = 'image/vnd.microsoft.icon';
- break;
- case 'ico':
- $mime = 'image/x-icon';
- break;
- case 'otf':
- $mime = 'application/x-font-opentype';
- break;
- case 'ttf':
- $mime = 'application/x-font-truetype';
- break;
- case 'svg':
- $mime = 'image/svg+xml';
- break;
- case 'eot':
- $mime = 'application/vnd.ms-fontobject';
- break;
- case 'woff':
- $mime = 'font/woff';
- break;
- }
- $error = $this->view->upload_cdn($file,
- $this->compress_options['html_cachedir'],
- $this->compress_options['parallel']['ftp'],
- $mime,
- $this->compress_options['host']);
- if (strpos($error, 'Error:') !== false) {
- $success = 0;
- }
- }
- $page_variables = array(
- "file" => $file,
- "size" => $size,
- "compressed" => $size,
- "success" => $success,
- "error" => $error,
- "skip_render" => $this->skip_render
- );
- $this->view->render("compress_gzip", $page_variables);
- }
- /*
- * Return size of specific (optimized images) files
- *
- **/
- function compress_image () {
- $file = str_replace('\\', '/', realpath($this->input['wss_file']));
- $service = empty($this->input['wss_service']) ? 0 : round($this->input['wss_service']);
- $mtime = @filemtime($file);
- $size = @filesize($file);
- $backup = empty($this->input['wss_backup']) ? '' : $file . '.backup';
- $compressed_size = $size;
- $error = 0;
- if (strpos($file, $this->view->paths['full']['document_root']) !== false) {
- if (!$backup || !@is_file($backup) || $mtime != @filemtime($backup)) {
- require(dirname(__FILE__) . '/../libs/php/css.sprites.optimize.php');
- $optimizer = new css_sprites_optimize();
- /* CSS Sprites uses .backup itself, so just prepare another backup */
- if ($backup && @is_file($backup)) {
- @copy($backup, $file . '.bkp');
- } else {
- @copy($file, $file . '.bkp');
- }
- $optimizer->website_root = $this->view->paths['full']['document_root'];
- switch ($service) {
- case 2:
- $optimizer->punypng($file);
- break;
- case 1:
- $optimizer->webolk($file);
- break;
- default:
- $optimizer->smushit($file);
- break;
- }
- /* copy backup back */
- if ($backup) {
- @copy($file . '.bkp', $backup);
- }
- @unlink($file . '.bkp');
- $mtime2 = @filemtime($file);
- /* Has file been changed? */
- $success = $mtime2 > $mtime ? 1 : 0;
- if ($success) {
- $compressed_size = @filesize($file);
- @touch($backup, $mtime2);
- /* can't overwrite targeted file */
- } else {
- $error = 1;
- }
- } else {
- $success = 1;
- }
- }
- $page_variables = array(
- "file" => $file,
- "size" => $size,
- "compressed" => $compressed_size,
- "success" => $success,
- "error" => $error,
- "skip_render" => $this->skip_render
- );
- $this->view->render("compress_gzip", $page_variables);
- }
- /*
- * Return size of specific (minified) files
- *
- **/
- function compress_minify () {
- $file = realpath($this->input['wss_file']);
- $size = @filesize($file);
- $chunks = explode(".", $file);
- $extension = array_pop($chunks);
- $gzipped = $file;
- $gzipped_size = $size;
- $success = 0;
- $error = 0;
- if (strpos($file, $this->view->paths['full']['document_root']) !== false) {
- $content = '';
- $c = $this->file_get_contents($file);
- $not_buffered = 1;
- require(dirname(__FILE__) . '/../web.optimizer.php');
- $not_buffered = 1;
- switch (strtolower($extension)) {
- case 'css':
- switch ($this->compress_options['minify']['css_min']) {
- case 1:
- $content = $web_optimizer->minify_text($c);
- break;
- case 2:
- $c = preg_replace("!/\*.*?\*/!is", "", $c);
- require(dirname(__FILE__) . '/../libs/php/class.csstidy.php');
- $csstidy = new csstidy();
- $csstidy->load_template(dirname(__FILE__) . '/../libs/php/css.template.tpl');
- $csstidy->parse($c);
- $content = $csstidy->print->plain();
- break;
- }
- break;
- case 'js':
- foreach ($web_optimizer->libraries as $klass => $library) {
- if (!class_exists($klass, false)) {
- require($web_optimizer->options['css']['installdir'] . 'libs/php/' . $library);
- }
- }
- $content = $web_optimizer->minify_javascript($c, $web_optimizer->options['javascript']);
- break;
- }
- if (strlen($content)) {
- @copy($file, $file . '.backup');
- $success = $this->write_file($gzipped, $content);
- /* can't overwrite targeted file */
- if (!$success) {
- $error = 1;
- }
- } else {
- $success = 0;
- /* cam't gzip file */
- $error = 2;
- }
- if ($success) {
- @touch($gzipped, @filemtime($file));
- $gzipped_size = @filesize($gzipped);
- }
- }
- $page_variables = array(
- "file" => $file,
- "size" => $size,
- "compressed" => $gzipped_size,
- "success" => $success,
- "error" => $error,
- "skip_render" => $this->skip_render
- );
- $this->view->render("compress_gzip", $page_variables);
- }
- /*
- * Return size of specific (compressed) files
- *
- **/
- function compress_gzip () {
- $file = realpath($this->input['wss_file']);
- $size = @filesize($file);
- $gzipped = $file . '.gz';
- $gzipped_size = $size;
- $success = 0;
- $error = 0;
- if (strpos($file, $this->view->paths['full']['document_root']) !== false) {
- if (!@is_file($gzipped) || !@filesize($gzipped)) {
- $raw = !function_exists('shell_exec');
- $success = 1;
- if (!$raw) {
- @shell_exec('gzip -c -n -9 ' . $file . ' > ' . $gzipped);
- if (!@is_file($gzipped) || !@filesize($gzipped)) {
- $raw = 1;
- }
- }
- if ($raw) {
- $content = @gzencode($this->file_get_contents($file), 9, FORCE_GZIP);
- if (strlen($content)) {
- $success = $this->write_file($gzipped, $content);
- /* can't overwrite targeted file */
- if (!$success) {
- $error = 1;
- }
- } else {
- $success = 0;
- /* cam't gzip file */
- $error = 2;
- }
- }
- if ($success) {
- @touch($gzipped, @filemtime($file));
- $gzipped_size = @filesize($gzipped);
- }
- } else {
- $success = 1;
- $gzipped_size = @filesize($gzipped);
- }
- }
- $page_variables = array(
- "file" => $file,
- "size" => $size,
- "compressed" => $gzipped_size,
- "success" => $success,
- "error" => $error,
- "skip_render" => $this->skip_render
- );
- $this->view->render("compress_gzip", $page_variables);
- }
- /*
- * Returns all info about current award + retrieves them from server
- *
- **/
- function calculate_awards () {
- $evaluation1 = $this->file_get_contents($this->basepath . $this->index_before);
- $evaluation1 = strpos($evaluation1, 'responseCode": 200') === false ? '' : $evaluation1;
- $evaluation2 = $this->file_get_contents($this->basepath . $this->index_after);
- $evaluation2 = strpos($evaluation1, 'responseCode": 200') === false ? '' : $evaluation2;
- /* first level - WEBO grade (YSlow + Page Speed + WEBO) */
- $grade = round(preg_replace("!.*score\":\s*([0-9]+),.*!s", "$1", $evaluation2));
- $level1 = $grade > 50 ? $grade > 70 ? $grade > 90 ? 3 : 2 : 1 : 0;
- /* second level - website home page size savings */
- $size11 = round(preg_replace("!.*htmlResponseBytes\":\s*([0-9]+),.*!", "$1", $evaluation1));
- $size12 = round(preg_replace("!.*cssResponseBytes\":\s*([0-9]+),.*!", "$1", $evaluation1));
- $size13 = round(preg_replace("!.*imageResponseBytes\":\s*([0-9]+),.*!", "$1", $evaluation1));
- $size14 = round(preg_replace("!.*javascriptResponseBytes\":\s*([0-9]+),.*!", "$1", $evaluation1));
- $size1 = $size11 + $size12 + $size13 + $size14;
- $size21 = round(preg_replace("!.*htmlResponseBytes\":\s*([0-9]+),.*!", "$1", $evaluation2));
- $size22 = round(preg_replace("!.*cssResponseBytes\":\s*([0-9]+),.*!", "$1", $evaluation2));
- $size23 = round(preg_replace("!.*imageResponseBytes\":\s*([0-9]+),.*!", "$1", $evaluation2));
- $size24 = round(preg_replace("!.*javascriptResponseBytes\":\s*([0-9]+),.*!", "$1", $evaluation2));
- $size2 = $size21 + $size22 + $size23 + $size24;
- $delta = ($size1 - $size2) / ($size1 + 0.01);
- $level2 = $size1 && $size2 && $delta > 0.25 ? $delta > 0.5 ? $delta > 0.75 ? 3 : 2 : 1 : 0;
- /* fourth level - number of files on home page */
- $files1 = round(preg_replace("!.*numberResources\":\s*([0-9]+),.*!", "$1", $evaluation1));
- $files = round(preg_replace("!.*numberResources\":\s*([0-9]+),.*!", "$1", $evaluation2));
- $level4 = $files ? !$files || $files < 35 ? $files < 20 ? $files < 10 ? 3 : 2 : 1 : 0 : 0;
- /* third level - gained acceleration */
- $time1 = round(preg_replace("!.*numberHosts\":\s*([0-9]+),.*!", "$1", $evaluation1));
- $time2 = round(preg_replace("!.*numberHosts\":\s*([0-9]+),.*!", "$1", $evaluation2));
- $time1 *= $size1 * $files1;
- $time2 *= $size2 * $files;
- $speedup = ($time1 - $time2) / ($time1 + 0.01);
- $speedup = $speedup < 0 || $speedup > 0.9998 ? 0 : $speedup;
- $level3 = $speedup > 0.5 ? $speedup > 0.65 ? $speedup > 0.8 ? 3 : 2 : 1 : 0;
- /* fifth level - WEBO Site SpeedUp options */
- $errors = $this->options_count();
- /* count delta */
- $deltas = array(28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- $options = $deltas[round($this->premium)];
- foreach ($errors as $key => $value) {
- $options += $value;
- }
- $level5 = $options < 50 ? $options < 25 ? $options < 5 ? 3 : 2 : 1 : 0;
- $awards = $level1 . $level2 . $level3 . $level4 . $level5;
- $host = $this->compress_options['host'];
- /* check for images existence */
- if (!@is_file($this->compress_options['css_cachedir'] . 'webo-site-speedup.back.jpg')) {
- @copy($this->basepath . 'libs/css/webo-site-speedup.back.jpg',
- $this->compress_options['css_cachedir'] . 'webo-site-speedup.back.jpg');
- }
- if (!@is_file($this->compress_options['css_cachedir'] . 'webo-site-speedup.rocket.png')) {
- @copy($this->basepath . 'libs/css/rocket.main.png',
- $this->compress_options['css_cachedir'] . 'webo-site-speedup.rocket.png');
- }
- if ($this->compress_options['awards'] != $awards ||
- !@is_file($this->compress_options['css_cachedir'] . 'webo-site-speedup88.png')) {
- $sizes = array('88', '125', '161', '250');
- foreach ($sizes as $size) {
- $this->view->download("http://webo.in/rocket/?size=$size&top=$level1&middle=$level2&bottom=$level3&tail=$level4&circle=$level5",
- $this->compress_options['css_cachedir'] . 'webo-site-speedup' . $size . '.png');
- $this->view->download("http://webo.in/webonautes/?url=$host&options=" . (100 - $options),
- $this->compress_options['css_cachedir'] . 'webonautes.png');
- for ($i=1; $i<6; $i++) {
- $this->view->download("http://webo.in/webonautes/?size=$size&type=$i&url=$host&options=" . (100 - $options),
- $this->compress_options['css_cachedir'] . 'webonaut' . $i . '-' . $size . '.png');
- }
- }
- $local = @is_file($this->compress_options['css_cachedir'] . 'webo-site-speedup250.png');
- $this->save_option("['awards']", $awards);
- /* save final page with awards */
- @ob_start();
- include($this->basepath . 'view/external_awards.php');
- $content = @ob_get_contents();
- @ob_end_clean();
- /* add gzip / charset envelope */
- $content = '<?php header("Content-type:text/html;charset=utf-8");ob_start(\'a\');function a($b){$c=empty($_SERVER[\'HTTP_ACCEPT_ENCODING\'])?\'\':$_SERVER[\'HTTP_ACCEPT_ENCODING\'];$d=empty($_SERVER["HTTP_USER_AGENT"])?\'\':$_SERVER["HTTP_USER_AGENT"];if(!empty($b)&&(strpos($c,\'gzip\')!==\'false\'||strpos($c,\'deflate\')!==\'false\')){if(!strstr($d,"Opera")&&preg_match("/compatible; MSIE ([0-9]\.[0-9])/i",$d,$matches)){$e=floatval($matches[1]);if($e<7){$b=str_repeat(" ", 2048)."\r\n".$b;}}$g=@gzencode($b,7,strpos($c,\'gzip\')!==\'false\'?FORCE_GZIP:FORCE_DEFLATE);if(!empty($g)){header(\'Content-Encoding: gzip\');header(\'Vary: Accept-Encoding,User-Agent\');return $g;}}return $b;}?>' . $content;
- $this->write_file($this->compress_options['css_cachedir'] . 'webo-site-speedup.php', $content);
- $url = 'mhtml:http://' . $host .
- str_replace($this->compress_options['document_root'], "/",
- $this->compress_options['css_cachedir']) .
- 'webo-site-speedup.css!';
- $content = '.wg-teeth{background-image:url(' .
- $url .
- '1)}.wg-footer-logo{background-image:url(' .
- $url .
- "2);display:inline;zoom:1}/*\nContent-Type:multipart/related;boundary=\"_\"" .
- "\n\n--_\nContent-Location:1\nContent-Transfer-Encoding:base64\n\n" .
- 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAJCAYAAAALpr0TAAAATklEQVQYGY3BTRFAUAAGwG8EEEGNF0YVI4wwasjg7LDGifG/m5ygRZs3aDBjRpM7qDDajahyhs5VnyMULK4WlGxQY/JsQh0Mvg3xU/y0AgXf++/+7UXZAAAAAElFTkSuQmCC' .
- "\n\n--_\nContent-Location:2\nContent-Transfer-Encoding:base64\n\n" .
- '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' .
- "\n\n--_--\n*/";
- $this->write_file($this->compress_options['css_cachedir'] . 'webo-site-speedup.css', $content);
- }
- /* download shorten link for twitter */
- $this->view->download('http://api.bit.ly/v3/shorten?login=wboptimizer&apiKey=R_c4fd5b38fe32971ae146abbf85aee568&uri='.
- urlencode('http://' . $this->compress_options['host'] .
- str_replace($this->compress_options['document_root'], "/",
- $this->compress_options['css_cachedir']) .
- 'webo-site-speedup.php') .
- '&format=txt', $this->compress_options['css_cachedir'] . 'url');
- $short_link = $this->file_get_contents($this->compress_options['css_cachedir'] . 'url');
- @unlink($this->compress_options['css_cachedir'] . 'url');
- return array($level1, $level2, $level3, $level4, $level5,
- 100 - $options, $grade, $files, round($size2 / 1024),
- round(100*((1 / (0.9999 - $speedup)) - 1)), $short_link);
- }
-
- /*
- * Calculate the best options for website.
- * Shows wizard page
- *
- **/
- function install_wizard () {
- $wizard = round(isset($_GET['web_optimizer_wizard']) ? $_GET['web_optimizer_wizard'] : 0);
- /* calculate options */
- if ($wizard) {
- $wizard_options = isset($_GET['web_optimizer_wizard_options']) ? $_GET['web_optimizer_wizard_options'] : '';
- /* 1 - disable application, calculate .htaccess, enable client&server side caching
- 2 - enable combine CSS
- 3 - disable combine inline CSS
- 4 - disable combine external CSS
- 5 - enable minify CSS
- 6 - disable minify CSS
- 7 - disable combine CSS
- 8 - enable gzip CSS
- 9 - disable gzip CSS
- 10 - enable combine JS
- 11 - disable combine inline JS
- 12 - move JS to head
- 13 - move JS to /head, disable combine external JS
- 14 - exclude JS from combine
- 15 - enable minify JS with JSMin
- 16 - enable minify JS with YUI Compressor
- 17 - enable minify JS with Packer
- 18 - disable minify JS
- 19 - enable duplicates removal
- 20 - disable duplicates removal
- 21 - disable combine JS
- 22 - enable gzip JS
- 23 - disable gzip JS
- 24 - enable minify HTML
- 25 - disable minify HTML
- 26 - enable remove HTML comments
- 27 - disable remove HTML comments
- 28 - enable gzip HTML
- 29 - disable gzip HTML
- 30 - enable plain string + no mtime
- 31 - disable plain string
- 32 - enable data:URI + mhtml + separation
- 33 - disable separation data:URI
- 34 - disable data:URI + mhtml
- 35 - set JS host
- 36 - set CSS host
- 37 - set IMG host
- 38 - enable CDN
- 39 - disable CDN
- 40 - enable HTML Sprites
- 41 - enable HTML Sprites restriction
- 42 - disable HTML Sprites
- 43 - move JS to /body
- 44 - move JS to /head
- 45 - enable unobtrusive JavaScript
- 46 - disable unobtrusive JavaScript
- 47 - show selection screen (step2/step3)
- 48 - show server side screen
- 49 - enable or disable server side caching
- 50 - show step3 screen
- 51 - save settings
- 100 - final check
- */
- switch ($wizard) {
- /* check htaccess, disable all options */
- case 1:
- /* disable application for future tests */
- $this->save_option("['active']", 0);
- /* disable all the other options */
- foreach ($this->compress_options as $group => $options) {
- if (is_array($options)) {
- foreach ($options as $key => $option) {
- if ($option === '1') {
- $this->save_option("['". $group ."']['" . $key . "']", 0);
- }
- }
- }
- }
- /* detect .htaccess */
- $this->get_modules();
- $ht = count($this->apache_modules) ? 1 : 0;
- /* enable .htaccess */
- $this->save_option("['htaccess']['enabled']", $ht);
- $this->save_option("['htaccess']['local']", $ht);
- $modules = array(
- 'mod_deflate',
- 'mod_gzip',
- 'mod_expires',
- 'mod_mime',
- 'mod_headers',
- 'mod_setenvif',
- 'mod_rewrite');
- foreach ($modules as $module) {
- if ($ht && in_array($module, $this->apache_modules)) {
- $this->save_option("['htaccess']['" . $module . "']", 1);
- $this->input['wss_htaccess_' . $module] = 1;
- }
- }
- if ($ht) {
- $this->compress_options['active'] = 1;
- $this->input['wss_htaccess_enabled'] = 1;
- $this->input['wss_htaccess_local'] = 1;
- $this->input['wss_gzip_fonts'] = 1;
- $this->input['wss_far_future_expires_css'] = 1;
- $this->input['wss_far_future_expires_images'] = 1;
- $this->input['wss_far_future_expires_javascript'] = 1;
- $this->input['wss_far_future_expires_fonts'] = 1;
- $this->input['wss_far_future_expires_video'] = 1;
- $this->input['wss_far_future_expires_static'] = 1;
- /* write complete test set of rules */
- $this->write_htaccess();
- }
- $test_file = $this->compress_options['html_cachedir'] . 'index.test';
- $t = time() + microtime();
- $this->view->download("http://" . $_SERVER['HTTP_HOST'] .
- str_replace($this->compress_options['document_root'], "/", $this->compress_options['website_root']),
- $test_file, 20);
- /* enable HTML caching if server side expenses are more than 500ms + we have known engine */
- if (time() + microtime() - $t > 0.5 && $this->internal) {
- $this->save_option("['html_cache']['enabled']", 1);
- $this->save_option("['html_cache']['timeout']", 3600);
- $this->save_option("['sql_cache']['enabled']", 1);
- $this->save_option("['sql_cache']['timeout']", 600);
- /* check for caching extensions */
- if (function_exists('xcache_set')) {
- $this->save_option("['performance']['cache_engine']", 3);
- } elseif (function_exists('apc_store')) {
- $this->save_option("['performance']['cache_engine']", 2);
- } elseif (@class_exists('Memcached') || @class_exists('Memcache')) {
- $this->save_option("['performance']['cache_engine']", 1);
- }
- }
- /* some errors with .htaccess, disable all options */
- if ($ht && !$this->file_get_contents($test_file)) {
- foreach ($modules as $module) {
- $this->save_option("['htaccess']['" . $module . "']", 0);
- $this->input['wss_htaccess_' . $module] = 0;
- }
- $this->save_option("['htaccess']['enabled']", 0);
- $this->write_htaccess();
- }
- @unlink($test_file);
- $this->save_option("['footer']['spot']", 1);
- /* enable client side caching */
- $this->save_option("['far_future_expires']['css']", 1);
- $this->save_option("['far_future_expires']['javascript']", 1);
- $this->save_option("['far_future_expires']['fonts']", 1);
- $this->save_option("['far_future_expires']['images']", 1);
- $this->save_option("['far_future_expires']['video']", 1);
- $this->save_option("['far_future_expires']['static']", 1);
- break;
- /* enable combine CSS */
- case 2:
- if ($wizard_options) {
- $this->save_option("['minify']['css_body']", 1);
- }
- $this->save_option("['minify']['css']", 1);
- $this->save_option("['external_scripts']['css']", 1);
- $this->save_option("['external_scripts']['css_inline']", 1);
- break;
- /* disable inline CSS */
- case 3:
- $this->save_option("['external_scripts']['css_inline']", 0);
- break;
- /* disable external CSS */
- case 4:
- $this->save_option("['external_scripts']['css']", 0);
- break;
- /* enable minify CSS */
- case 5:
- $this->save_option("['minify']['css_min']", 1);
- break;
- /* disable minify CSS */
- case 6:
- $this->save_option("['minify']['css_min']", 0);
- break;
- /* disable combine CSS */
- case 7:
- $this->save_option("['minify']['css']", 0);
- $this->save_option("['minify']['css_body']", 0);
- break;
- /* enable gzip CSS */
- case 8:
- $this->save_option("['gzip']['css']", 1);
- $this->save_option("['htaccess']['enabled']", 1);
- $this->compress_options['active'] = 1;
- $this->compress_options['htaccess']['enabled'] = 1;
- $this->compress_options['gzip']['css'] = 1;
- foreach ($this->compress_options as $group => $options) {
- if (is_array($options)) {
- foreach ($options as $key => $option) {
- $this->input['wss_'. $group . '_' . $key] = $option;
- }
- }
- }
- $this->write_htaccess();
- break;
- /* disable gzip CSS */
- case 9:
- $this->save_option("['gzip']['css']", 0);
- $this->save_option("['htaccess']['enabled']", 0);
- $this->input['wss_htaccess_enabled'] = 0;
- $this->write_htaccess();
- break;
- /* enable combine JS */
- case 10:
- $this->save_option("['minify']['javascript']", 1);
- $this->save_option("['external_scripts']['on']", 1);
- $this->save_option("['external_scripts']['inline']", 1);
- $this->save_option("['external_scripts']['head_end']", 1);
- break;
- /* disable combine inline JS */
- case 11:
- $this->save_option("['external_scripts']['inline']", 0);
- break;
- /* move JS to head */
- case 12:
- $this->save_option("['external_scripts']['head_end']", 0);
- break;
- /* move JS to /head, disable combine external JS */
- case 13:
- $this->save_option("['external_scripts']['head_end']", 1);
- $this->save_option("['external_scripts']['on']", 0);
- break;
- /* exclude JS from combine */
- case 14:
- $this->save_option("['external_scripts']['ignore_list']", htmlspecialchars($wizard_options));
- break;
- /* enable minify JS with JSMin */
- case 15:
- $this->save_option("['minify']['with_jsmin']", 1);
- break;
- /* enable minify JS with YUI Compressor */
- case 16:
- $this->save_option("['minify']['with_jsmin']", 0);
- $this->save_option("['minify']['with_yui']", 1);
- break;
- /* enable minify JS with Packer */
- case 17:
- $this->save_option("['minify']['with_jsmin']", 0);
- $this->save_option("['minify']['with_yui']", 0);
- $this->save_option("['minify']['with_packer']", 1);
- break;
- /* disable minify JS */
- case 18:
- $this->save_option("['minify']['with_jsmin']", 0);
- $this->save_option("['minify']['with_yui']", 0);
- $this->save_option("['minify']['with_packer']", 0);
- break;
- /* enable duplicates removal */
- case 19:
- $this->save_option("['external_scripts']['duplicates']", 1);
- break;
- /* disable duplicates removal */
- case 20:
- $this->save_option("['external_scripts']['duplicates']", 0);
- break;
- /* disable combine JS */
- case 21:
- $this->save_option("['minify']['javascript']", 0);
- break;
- /* enable gzip JS */
- case 22:
- $this->save_option("['gzip']['javascript']", 1);
- $this->save_option("['htaccess']['enabled']", 1);
- $this->compress_options['active'] = 1;
- $this->compress_options['htaccess']['enabled'] = 1;
- $this->compress_options['gzip']['javascript'] = 1;
- foreach ($this->compress_options as $group => $options) {
- if (is_array($options)) {
- foreach ($options as $key => $option) {
- $this->input['wss_'. $group . '_' . $key] = $option;
- }
- }
- }
- $this->write_htaccess();
- break;
- /* disable gzip JS */
- case 23:
- $this->save_option("['gzip']['javascript']", 0);
- $this->save_option("['htaccess']['enabled']", 0);
- $this->input['wss_htaccess_enabled'] = 0;
- $this->write_htaccess();
- break;
- /* enable minify HTML */
- case 24:
- $this->save_option("['minify']['page']", 1);
- break;
- /* disable minify HTML */
- case 25:
- $this->save_option("['minify']['page']", 0);
- break;
- /* enable remove HTML comments */
- case 26:
- $this->save_option("['minify']['html_comments']", 1);
- break;
- /* disable remove HTML comments */
- case 27:
- $this->save_option("['minify']['html_comments']", 0);
- break;
- /* enable plain string + no mtime */
- case 28:
- $this->save_option("['performance']['mtime']", 1);
- $this->save_option("['performance']['plain_string']", 1);
- break;
- /* disable plain string */
- case 29:
- $this->save_option("['performance']['plain_string']", 0);
- break;
- /* enable gzip HTML */
- case 30:
- $this->save_option("['gzip']['page']", 1);
- $this->save_option("['gzip']['fonts']", 1);
- $this->save_option("['gzip']['cookie']", 1);
- $this->save_option("['gzip']['noie']", 1);
- $this->save_option("['htaccess']['enabled']", 1);
- $this->compress_options['active'] = 1;
- $this->compress_options['htaccess']['enabled'] = 1;
- $this->compress_options['gzip']['page'] = 1;
- foreach ($this->compress_options as $group => $options) {
- if (is_array($options)) {
- foreach ($options as $key => $option) {
- $this->input['wss_'. $group . '_' . $key] = $option;
- }
- }
- }
- $this->write_htaccess();
- break;
- /* disable gzip HTML */
- case 31:
- $this->save_option("['gzip']['page']", 0);
- $this->save_option("['gzip']['fonts']", 0);
- $this->save_option("['gzip']['cookie']", 0);
- $this->save_option("['gzip']['noie']", 0);
- $this->save_option("['htaccess']['enabled']", 0);
- foreach ($this->compress_options as $group => $options) {
- if (is_array($options)) {
- foreach ($options as $key => $option) {
- $this->input['wss_'. $group . '_' . $key] = $option;
- }
- }
- }
- $this->input['wss_htaccess_enabled'] = 0;
- $this->write_htaccess();
- break;
- /* enable data:URI + mhtml + separation */
- case 32:
- $this->save_option("['data_uris']['on']", 1);
- $this->save_option("['data_uris']['separate']", 1);
- $this->save_option("['unobtrusive']['background']", 1);
- break;
- /* disable separation data:URI */
- case 33:
- $this->save_option("['data_uris']['separate']", 0);
- $this->save_option("['unobtrusive']['background']", 0);
- break;
- /* disable data:URI + mhtml */
- case 34:
- $this->save_option("['data_uris']['on']", 0);
- $this->save_option("['data_uris']['separate']", 0);
- $this->save_option("['unobtrusive']['background']", 0);
- break;
- /* set JS host */
- case 35:
- $this->save_option("['minify']['javascript_host']", htmlspecialchars($wizard_options));
- break;
- /* set CSS host */
- case 36:
- $this->save_option("['minify']['css_host']", htmlspecialchars($wizard_options));
- break;
- /* set IMG host */
- case 37:
- $this->save_option("['parallel']['allowed_list']", htmlspecialchars($wizard_options));
- break;
- /* enable CDN */
- case 38:
- $this->save_option("['parallel']['custom']", 0);
- $this->save_option("['parallel']['css']", $this->compress_options['minify']['css_host'] ? 1 : 0);
- $this->save_option("['parallel']['javascript']", $this->compress_options['minify']['javascript_host'] ? 1 : 0);
- $this->save_option("['parallel']['enabled']", $this->compress_options['parallel']['allowed_list'] ? 1 : 0);
- break;
- /* disable CDN */
- case 39:
- $this->save_option("['parallel']['custom']", 0);
- $this->save_option("['parallel']['css']", 0);
- $this->save_option("['parallel']['javascript']", 0);
- $this->save_option("['parallel']['enabled']", 0);
- $this->save_option("['minify']['css_host']", '');
- $this->save_option("['minify']['javascript_host']", '');
- $this->save_option("['parallel']['allowed_list']", '');
- break;
- /* enable HTML Sprites */
- case 40:
- $this->save_option("['css_sprites']['html_sprites']", 1);
- $this->save_option("['css_sprites']['html_limit']", 16);
- $this->save_option("['css_sprites']['html_page']", 1);
- break;
- /* disable HTML Sprites */
- case 41:
- $this->save_option("['css_sprites']['html_sprites']", 0);
- break;
- /* enable HTML images scaling */
- case 42:
- $this->save_option("['performance']['scale']", 1);
- break;
- /* disable HTML images scaling */
- case 43:
- $this->save_option("['performance']['scale']", 0);
- break;
- /* move JS to /body */
- case 44:
- $this->save_option("['unobtrusive']['body']", 1);
- break;
- /* move JS to /head */
- case 45:
- $this->save_option("['unobtrusive']['body']", 0);
- break;
- /* enable unobtrusive JavaScript */
- case 46:
- $wizard_options = round($wizard_options);
- $this->save_option("['unobtrusive']['informers']", ($wizard_options & 1) ? 1 : 0);
- $this->save_option("['unobtrusive']['counters']", ($wizard_options & 2) ? 1 : 0);
- $this->save_option("['unobtrusive']['ads']", ($wizard_options & 4) ? 1 : 0);
- $this->save_option("['unobtrusive']['iframes']", ($wizard_options & 8) ? 1 : 0);
- break;
- /* disable unobtrusive JavaScript */
- case 47:
- $this->save_option("['unobtrusive']['informers']", 0);
- $this->save_option("['unobtrusive']['counters']", 0);
- $this->save_option("['unobtrusive']['ads']", 0);
- $this->save_option("['unobtrusive']['iframes']", 0);
- break;
- /* switch to manual mode */
- case 48:
- break;
- case 49:
- /* enable or disable server side caching */
- $wizard_options = round($wizard_options);
- switch ($wizard_options) {
- case 1:
- $this->save_option("['html_cache']['enabled']", 0);
- $this->save_option("['sql_cache']['enabled']", 0);
- break;
- case 2:
- $this->save_option("['html_cache']['enabled']", 1);
- $this->save_option("['sql_cache']['enabled']", 1);
- break;
- }
- $this->install_clean_cache(0, 1);
- break;
- /* save config */
- case 51:
- $this->save_option("['active']", 1);
- $this->compress_options['active'] = 1;
- foreach ($this->compress_options as $group => $options) {
- if (is_array($options)) {
- foreach ($options as $key => $option) {
- $this->input['wss_'. $group . '_' . $key] = $option;
- }
- }
- }
- /* detect .htaccess */
- $this->get_modules();
- if (count($this->apache_modules)) {
- $this->save_option("['htaccess']['enabled']", 1);
- $this->input['wss_htaccess_enabled'] = 1;
- $this->compress_options['htaccess']['enabled'] = 1;
- $this->write_htaccess();
- }
- /* create fake options */
- $this->input['wss_combine_css'] = $this->input['wss_minify_css'] * 2 + $this->input['wss_minify_css_body'];
- $this->input['wss_minify_javascript'] = $this->input['wss_minify_javascript'] * 2 + $this->input['wss_minify_javascript_body'];
- $this->input['wss_minify_js'] = $this->input['wss_minify_with_google'] ? 5 :
- ($this->input['wss_minify_with_packer'] ? 4 :
- ($this->input['wss_minify_with_yui'] ? 3 :
- ($this->input['wss_minify_with_jsmin'] ? 2 : 1)));
- /* define configuration file */
- if (@is_file($this->basepath . 'config.auto.php')) {
- $i = 1;
- while (@is_file($this->basepath . 'config.auto'. ($i++) .'.php')) {}
- $this->input['wss_config'] = 'auto' . ($i - 1);
- } else {
- $this->input['wss_config'] = 'auto';
- }
- $this->save_option("['config']", $this->input['wss_config']);
- $this->input['wss_title'] = 'Auto Config';
- $this->input['wss_description'] = 'Created by WEBO Wizard on ' . @date("Y-m-d");
- $this->input['wss_page'] = 'install_options';
- $this->set_options();
- break;
- }
- } else {
- /* show generic page */
- }
- $page_variables = array(
- "version" => $this->version,
- "premium" => $this->premium,
- "skip_render" => $this->skip_render,
- "wizard_mode" => $wizard,
- "website_root" => str_replace($this->compress_options['document_root'], "/", $this->compress_options['website_root'])
- );
- $this->view->render("install_wizard", $page_variables);
- }
- /*
- * Renders awards page
- *
- **/
- function install_awards () {
- $info = $this->calculate_awards();
- $level_options = array(
- array(
- array('gzip', 'clientside', 'combinecss'),
- array('minify', 'combine_js', 'data_uri', 'css_sprites'),
- array('unobtrusive', 'multiple_hosts', 'performance')),
- array(
- array('gzip', 'minify', 'htaccess'),
- array('combinecss', 'combine_js'),
- array('data_uri', 'css_sprites', 'performance')),
- array(
- array('gzip', 'clientside', 'htaccess', 'combinecss'),
- array('minify', 'combine_js', 'data_uri', 'css_sprites', 'serverside'),
- array('unobtrusive', 'multiple_hosts', 'performance')),
- array(
- array('combinecss', 'combine_js'),
- array('data_uri', 'css_sprites'),
- array('multiple_hosts', 'css_sprites')),
- array(
- array('htaccess', 'gzip', 'performance', 'unobtrusive'),
- array('minify', 'clientside', 'combinecss', 'combine_js'),
- array('css_sprites', 'data_uri', 'multiple_hosts'))
- );
- $page_variables = array(
- "version" => $this->version,
- "premium" => $this->premium,
- "skip_render" => $this->skip_render,
- "level1" => $info[0],
- "level2" => $info[1],
- "level3" => $info[2],
- "level4" => $info[3],
- "level5" => $info[4],
- "local" => @is_file($this->compress_options['css_cachedir'] . 'webo-site-speedup250.png'),
- "cachedir" => str_replace($this->compress_options['document_root'], "/",
- $this->compress_options['css_cachedir']),
- "short_link" => $info[10],
- "level_options" => $level_options,
- "host" => $this->compress_options['host'],
- "options" => $info[5]
- );
- $this->view->render("install_awards", $page_variables);
- }
- /*
- * Renders account page
- *
- **/
- function install_account () {
- $allow = $this->compress_options['optimization'];
- $email = $this->compress_options['email'];
- $name = $this->compress_options['name'];
- $license = $this->compress_options['license'];
- $submit = empty($this->input['wss_Submit']) ? '' : $this->input['wss_Submit'];
- $error = array();
- if (!empty($submit)) {
- $email = $this->input['wss_email'];
- $allow = empty($this->input['wss_allow']) ? 0 : 1;
- $license = trim($this->input['wss_license']);
- $name = $this->input['wss_name'];
- if (!$this->internal && (empty($this->input['wss_password']) ||
- md5($this->input['wss_password']) !=
- $this->input['wss__password'])) {
- $error[1] = 1;
- }
- if (empty($this->input['wss_email']) ||
- !preg_match("/.+@.+\..+/", $this->input['wss_email'])) {
- $error[2] = 1;
- }
- if (!empty($this->input['wss_new']) &&
- (empty($this->input['wss_confirm']) ||
- $this->input['wss_confirm'] !=
- $this->input['wss_new']) && !$this->internal) {
- $error[3] = 1;
- }
- $this->premium = $this->view->validate_license($license);
- /* save new options */
- if (!count($error)) {
- $this->save_option("['email']", htmlspecialchars($email));
- $this->save_option("['optimization']", $allow);
- $this->save_option("['license']", htmlspecialchars($license));
- $this->save_option("['name']", htmlspecialchars($name));
- if (!empty($this->input['wss_new'])) {
- $this->save_option("['password']", md5($this->input['wss_new']));
- }
- }
- }
- $expires = -1;
- if (empty($this->premium) && !empty($license)) {
- $error[4] = 1;
- } elseif (@is_file($this->basepath . 'cache/wo')) {
- $expires = $this->file_get_contents($this->basepath . 'cache/wo');
- }
- /* check for additional libraries */
- if ($this->premium > 1) {
- $jars_to_download = array(
- 'yuicompressor/yuicompressor.jar',
- 'googlecompiler/googlecompiler.jar'
- );
- foreach ($jars_to_download as $jar) {
- $jar = 'libs/' . $jar;
- if (!@is_file($this->basepath . $jar)) {
- $this->view->download($this->svn . $jar, $this->basepath . $jar);
- /* make lib executable */
- @chmod($this->basepath . $jar, octdec("0755"));
- }
- }
- }
- $page_variables = array(
- "version" => $this->version,
- "premium" => $this->premium,
- "submit" => $submit,
- "expires" => $expires,
- "allow" => $allow,
- "email" => $email,
- "name" => $name,
- "license" => $license,
- "error" => $error,
- "skip_render" => $this->skip_render,
- "internal" => $this->internal,
- "language" => $this->language,
- "root" => str_replace($this->compress_options['document_root'], '/', $this->basepath)
- );
- $this->view->render("install_account", $page_variables);
- }
-
- /*
- * Renders about page
- *
- **/
- function install_about () {
- $email = empty($this->input['wss_email']) ? '' : $this->input['wss_email'];
- $message = empty($this->input['wss_message']) ? '' : $this->input['wss_message'];
- $submit = empty($this->input['wss_Submit']) ? 0 : 1;
- $error = array();
- if ($submit) {
- if (empty($email) ||
- !preg_match("/.+@.+\..+/", $email)) {
- $error[1] = 1;
- }
- if (empty($message)) {
- $error[2] = 1;
- }
- /* send a email to info@webo.name */
- if (!count($error)) {
- $this->send_message($email, $message);
- }
- }
- $page_variables = array(
- "version" => $this->version,
- "premium" => $this->premium,
- "email" => $email,
- "message" => $message,
- "error" => $error,
- "submit" => $submit,
- "skip_render" => $this->skip_render,
- "ready" => @is_file($this->basepath . 'ready')
- );
- $this->view->render("install_about", $page_variables);
- }
- /*
- * Sends a message from given e-mail
- *
- **/
- function send_message ($email, $message, $uninstall = false) {
- $headers = 'From: ' . $email . "\r\n" . 'Reply-To: ' . $email . "\r\n";
- $headers .= 'Content-Type: text/plain; charset=utf-8'."\r\n";
- $headers .= 'Content-Transfer-Encoding: base64';
- /* general info */
- $message = "On " . @date("Y-m-d") . " at " . @date("H:i:s") . " " .
- $this->compress_options['name'] .
- " (" . $this->compress_options['email'] . ") send a message: " .
- ($uninstall ? "(after uninstalltion) " : "") . "\r\n" . $message;
- /* application info */
- $this->cms_version = $this->system_info($this->compress_options['document_root']);
- $message .= "\r\n\r\nWEBO Site SpeedUp " . $this->version . " was " .
- ($this->compress_options['active'] ? "enabled" : "disabled") .
- " on " . $this->cms_version . ($this->internal ? " (plugin…
Large files files are truncated, but you can click here to view the full file