4 +-----------------------------------------------------------------------+
5 | program/bin/modcss.php |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2007, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Modify CSS source from a URL |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
22 $INSTALL_PATH = realpath("./../") . "/";
23 ini_set('include_path', $INSTALL_PATH.PATH_SEPARATOR.$INSTALL_PATH.'program'.PATH_SEPARATOR.ini_get('include_path'));
25 require 'include/main.inc';
28 if ($url = preg_replace('/[^a-z0-9.-_\?\$&=%]/i', '', $_GET['u']))
30 $a_uri = parse_url($url);
31 $port = $a_uri['port'] ? $a_uri['port'] : 80;
32 $host = $a_uri['host'];
33 $path = $a_uri['path'] . ($a_uri['query'] ? '?'.$a_uri['query'] : '');
36 if ($fp = fsockopen($host, $port, $errno, $errstr, 30))
38 $out = "GET $path HTTP/1.0\r\n";
39 $out .= "Host: $host\r\n";
40 $out .= "Connection: Close\r\n\r\n";
46 $line = trim(fgets($fp, 4048));
48 if ($header && preg_match('/^HTTP\/1\..\s+(\d+)/', $line, $regs) && intval($regs[1]) != 200)
50 else if (empty($line) && $header)
61 header("Content-Type: text/css");
62 echo rcmail_mod_css_styles($source, preg_replace('/[^a-z0-9]/i', '', $_GET['c']), $url);
65 header("HTTP/1.0 404 Not Found");