metanohi-misc-subsites/subsites/projects/algo/themes/links.php

61 lines
2.3 KiB
PHP

<?php
include('indexes.php'); // Get the indexes
$file = $u[$title];
if (!is_file($file))
$file = 'default.css';
if ($type == 'css') {
// Simply include the css file
header('Content-type: text/css');
include($file);
}
elseif ($type == 'js') {
// Read the css file for stuff the the JavaScript environment needs
header('Content-type: text/javascript');
header('content-type: text/plain');
$f = 'default.css';
$file = fopen($f, 'r');
$contents = fread($file, filesize($f));
fclose($file);
function get_from_stylesheet($name, $property) {
global $contents;
$block_start = strpos($contents, $name);
$property_start = strpos($contents, $property, $block_start);
if ($property_start === false) return 0;
$colon_start = strpos($contents, ':', $property_start);
$semicolon_start = strpos($contents, ';', $property_start);
$property = substr($contents, $colon_start + 1, $semicolon_start - $colon_start - 1);
$property = trim($property);
return $property;
}
function rem_px($value) {
return str_replace('px', '', $value);
}
$text = '';
$text .= "scr.hheight = " . get_from_stylesheet('screen', 'hheight');
$text .= "\nscr.margin_g = " . get_from_stylesheet('screen', 'margin_g');
$text .= "\nscr.margin_t = " . get_from_stylesheet('screen', 'margin_t');
$text .= "\nscr.bw = " . get_from_stylesheet('screen', 'bw');
$text .= "\nscr.bh = " . get_from_stylesheet('screen', 'bh');
$text .= "\nabs_scroller_width = " . rem_px(get_from_stylesheet('.abs', 'width'));
$text .= "\nnavi[0].height = " . rem_px(get_from_stylesheet('.navi0', 'height'));
$text .= "\nnavi[0].border = [" . str_replace(' ', ',', rem_px(get_from_stylesheet('.navi0', 'border-width'))) . ']';
$text .= "\nnavi[1].height = " . rem_px(get_from_stylesheet('.navi1', 'height'));
$text .= "\nnavi[1].border = [" . str_replace(' ', ',', rem_px(get_from_stylesheet('.navi1', 'border-width'))) . ']';
$text .= "\nappbox_margin = " . rem_px(get_from_stylesheet('.appboxes *', 'margin'));
$text .= "\nappbox_padding = " . rem_px(get_from_stylesheet('.appboxes *', 'padding'));
$text .= "\nappbox_border = " . rem_px(get_from_stylesheet('.appboxes *', 'border-width'));
echo $text;
}
?>