. * * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License * @package csstidy * @author Florian Schmitz (floele at gmail dot com) 2005-2007 * @author Brett Zamir (brettz9 at yahoo dot com) 2007 */ require('class.csstidy.php'); require('lang.inc.php'); if (get_magic_quotes_gpc()) { if (isset($_REQUEST['css_text'])) { $_REQUEST['css_text'] = stripslashes($_REQUEST['css_text']); } if (isset($_REQUEST['custom'])) { $_REQUEST['custom'] = stripslashes($_REQUEST['custom']); } if (isset($_COOKIE['custom_template'])) { $_COOKIE['custom_template'] = stripslashes($_COOKIE['custom_template']); } } function rmdirr($dirname,$oc=0) { // Sanity check if (!file_exists($dirname)) { return false; } // Simple delete for a file if (is_file($dirname) && (time()-fileatime($dirname))>3600) { return unlink($dirname); } // Loop through the folder if(is_dir($dirname)) { $dir = dir($dirname); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry === '.' || $entry === '..') { continue; } // Recurse rmdirr($dirname.'/'.$entry,$oc); } $dir->close(); } // Clean up if ($oc==1) { return rmdir($dirname); } } function options($options, $selected = null, $labelIsValue = false) { $html = ''; settype($selected, 'array'); settype($options, 'array'); foreach ($options as $value=>$label) { if (is_array($label)) { $value = $label[0]; $label = $label[1]; } $label = htmlspecialchars($label, ENT_QUOTES, 'utf-8'); $value = $labelIsValue ? $label : htmlspecialchars($value, ENT_QUOTES, 'utf-8'); $html .= ''; } return $html; } $css = new csstidy(); $is_custom = isset($_REQUEST['custom']) && !empty($_REQUEST['custom']) && isset($_REQUEST['template']) && ($_REQUEST['template'] === '4'); if($is_custom) { setcookie ('custom_template', $_REQUEST['custom'], time()+360000); } rmdirr('temp'); if(isset($_REQUEST['case_properties'])) $css->set_cfg('case_properties',$_REQUEST['case_properties']); if(isset($_REQUEST['lowercase'])) $css->set_cfg('lowercase_s',true); if(!isset($_REQUEST['compress_c']) && isset($_REQUEST['post'])) $css->set_cfg('compress_colors',false); if(!isset($_REQUEST['compress_fw']) && isset($_REQUEST['post'])) $css->set_cfg('compress_font-weight',false); if(isset($_REQUEST['merge_selectors'])) $css->set_cfg('merge_selectors', $_REQUEST['merge_selectors']); if(isset($_REQUEST['optimise_shorthands'])) $css->set_cfg('optimise_shorthands',$_REQUEST['optimise_shorthands']); if(!isset($_REQUEST['rbs']) && isset($_REQUEST['post'])) $css->set_cfg('remove_bslash',false); if(isset($_REQUEST['preserve_css'])) $css->set_cfg('preserve_css',true); if(isset($_REQUEST['sort_sel'])) $css->set_cfg('sort_selectors',true); if(isset($_REQUEST['sort_de'])) $css->set_cfg('sort_properties',true); if(isset($_REQUEST['remove_last_sem'])) $css->set_cfg('remove_last_;',true); if(isset($_REQUEST['discard'])) $css->set_cfg('discard_invalid_properties',true); if(isset($_REQUEST['css_level'])) $css->set_cfg('css_level',$_REQUEST['css_level']); if(isset($_REQUEST['timestamp'])) $css->set_cfg('timestamp',true); // This by itself is enough since our scripts don't use DOM to create elements (in which case the namespace aware ones // should be used when serving as application/xhtml+xml but not when served as text/html ; // also, case will be different when retrieving element names, as HTML DOM returns in upper case, // genuine XHTML DOM (when XHTML served as such) as lower if (stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml')) { $http_accept = 'application/xhtml+xml'; } elseif (stristr($_SERVER['HTTP_ACCEPT'], 'application/xml')) { $http_accept = 'application/xml'; } elseif (stristr($_SERVER['HTTP_ACCEPT'], 'text/xml')) { $http_accept = 'text/xml'; } elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'Opera ') || stristr($_SERVER['HTTP_USER_AGENT'], 'Opera/')) { preg_match('@Opera/(\d)@', $_SERVER['HTTP_USER_AGENT'], $matches); if (isset($matches[1]) && $matches[1] >= 7) { $http_accept = 'application/xhtml+xml'; } else { $http_accept = 'text/html'; } } else { $http_accept = 'text/html'; } header('Content-Type: '.$http_accept.'; charset=utf-8'); if ($http_accept === 'text/html') { ?> <?php echo $lang[$l][0]; echo $css->version; ?>)

csstidy version; ?>)

: English Deutsch French Chinese

size="35" />

get_cfg('preserve_css')) echo 'checked="checked"'; ?> />
get_cfg('sort_selectors')) echo 'checked="checked"'; ?> />
get_cfg('sort_properties')) echo 'checked="checked"'; ?> />


get_cfg('compress_colors')) echo 'checked="checked"';?> />
get_cfg('compress_font-weight')) echo 'checked="checked"';?> />
get_cfg('lowercase_s')) echo 'checked="checked"'; ?> />

get_cfg('case_properties') === 0) echo 'checked="checked"'; ?> /> get_cfg('case_properties') === 1) echo 'checked="checked"'; ?> /> get_cfg('case_properties') === 2) echo 'checked="checked"'; ?> />
get_cfg('remove_bslash')) echo 'checked="checked"'; ?> />
get_cfg('remove_last_;')) echo 'checked="checked"'; ?> />
get_cfg('discard_invalid_properties')) echo 'checked="checked"'; ?> />
get_cfg('timestamp')) echo 'checked="checked"'; ?> />
/>
/>
load_template($_REQUEST['custom'],false); } break; case 3: $css->load_template('highest_compression'); break; case 2: $css->load_template('high_compression'); break; case 0: $css->load_template('low_compression'); break; } } if($url) { if(substr($_REQUEST['url'],0,7) !== 'http://') { $_REQUEST['url'] = 'http://'.$_REQUEST['url']; } $result = $css->parse_from_url($_REQUEST['url'],0); } elseif(isset($_REQUEST['css_text']) && strlen($_REQUEST['css_text'])>5) { $result = $css->parse($_REQUEST['css_text']); } if($result) { $ratio = $css->print->get_ratio(); $diff = $css->print->get_diff(); if(isset($_REQUEST['file_output'])) { $filename = md5(mt_rand().time().mt_rand()); if (!is_dir('temp')) { $madedir = mkdir('temp'); if (!$madedir) { print 'Could not make directory "temp" in '.dirname(__FILE__); exit; } } $handle = fopen('temp/'.$filename.'.css','w'); if($handle) { if(fwrite($handle,$css->print->plain())) { $file_ok = true; } } fclose($handle); } if($ratio>0) $ratio = ''.$ratio.'% ('.$diff.' Bytes)'; else $ratio = ''.$ratio.'% ('.$diff.' Bytes)'; if(count($css->log) > 0): ?>
Messages
log as $line => $array) { echo '
',$line,'
'; $array_size = count($array); for($i = 0; $i < $array_size; ++$i) { echo '
',$array[$i]['m'],'
'; } } ?>
',$lang[$l][37],': ',$css->print->size('input'),'KB, ',$lang[$l][38],':',$css->print->size('output'),'KB, ',$lang[$l][36],': ',$ratio; if($file_ok) { echo ' - Download'; } echo ' - ',$lang[$l][58],''; echo ''; echo ''; echo $css->print->formatted(); echo '

'; echo '
',$lang[$l][64],''; echo '
'; echo '
',$lang[$l][65],''; echo ''; echo '

↑ ',$lang[$l][59],'

'; } elseif(isset($_REQUEST['css_text']) || isset($_REQUEST['url'])) { echo '

',$lang[$l][28],'

'; } ?>

.