1<?php 2/** 3 * reads css files and send them to the browser on the fly with correction 4 * 5 * PHP version 5 6 * 7 * @category PHP 8 * @package PSI_CSS 9 * @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net> 10 * @copyright 2021 phpSysInfo 11 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version 12 * @version Release: 1.0 13 * @link http://phpsysinfo.sourceforge.net 14 */ 15 16$file = isset($_GET['name']) ? basename(htmlspecialchars($_GET['name'])) : null; 17$increase = isset($_GET['increase']) ? (($_GET['increase']>0)? $_GET['increase'] : 0) : 0; 18 19if ($file != null) { 20 $css = $file.'.css'; 21 22 header("content-type: text/css"); 23 24 if (file_exists($css) && is_readable($css)) { 25 $filecontent = file_get_contents($css); 26 if ($increase == 0) { 27 echo $filecontent; 28 } else { 29 $lines = preg_split("/\r?\n/", $filecontent, -1, PREG_SPLIT_NO_EMPTY); 30 $block = ''; 31 foreach ($lines as $line) { 32 if (preg_match('/^(.+)\{/', $line, $tmpbuf)) { 33 $block = strtolower(trim($tmpbuf[1])); 34 echo $line."\n"; 35 } elseif (($block === 'body') || ($block === '.fullsize')) { 36 if (preg_match('/^(\s*_?width\s*:\s*)(\d+)(px.*)/', $line, $widthbuf)) { 37 echo $widthbuf[1].($widthbuf[2]+$increase).$widthbuf[3]."\n"; 38 } elseif (preg_match('/^(\s*background\s*:.+)(url)/', $line, $widthbuf)) { 39 echo $widthbuf[1].";\n"; 40 } else echo $line."\n"; 41 } elseif ($block === '.halfsize') { 42 if (preg_match('/^(\s*_?width\s*:\s*)(\d+)(px.*)/', $line, $widthbuf)) { 43 echo $widthbuf[1].($widthbuf[2]+$increase/2).$widthbuf[3]."\n"; 44 } else echo $line."\n"; 45 } else { 46 echo $line."\n"; 47 } 48 } 49 } 50 } 51} 52