ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
cssgen.php
Go to the documentation of this file.
1<?php
2/*************************************************************************************
3 * cssgen.php
4 * ----------
5 * Author: Nigel McNie (nigel@geshi.org)
6 * Copyright: (c) 2004 Nigel McNie
7 * Release Version: 1.0.8.12
8 * Date Started: 2004/05/20
9 *
10 * Application to generate custom CSS files for GeSHi (based on an idea by Andreas
11 * Gohr)
12 *
13 *************************************************************************************
14 *
15 * This file is part of GeSHi.
16 *
17 * GeSHi is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * GeSHi is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with GeSHi; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 *
31 ************************************************************************************/
32
33set_magic_quotes_runtime(0);
34//
35// Functions
36//
37
38function make_header ( $title )
39{
40 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
41<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
42<head>
43 <title>GeSHi CSS Generator :: ' . $title . ' </title>
44 <style type="text/css" media="screen">
45 <!--
46 html {
47 font-family: Verdana, Arial, sans-serif;
48 font-size: 80%;
49 background-color: #d0d0d0;
50 }
51 body {
52 margin: 10px;
53 padding: 5px;
54 border: 1px solid #f0f0f0;
55 background-color: #f6f6f6;
56 }
57 h1 {
58 border-bottom: 2px solid #e0e0e0;
59 font-weight: normal;
60 font-size: 150%;
61 color: #c0c0c0;
62 }
63 input, textarea {
64 border: 1px solid #d0d0d0;
65 }
66 th {
67 text-align: right;
68 font-weight: normal;
69 }
70 pre {
71 font-size: 110%;
72 color: #202020;
73 }
74 #footer {
75 color: #b0b0b0;
76 text-align: center;
77 font-size: 90%;
78 margin: 0 auto;
79 border-top: 1px solid #e0e0e0;
80 }
81 #footer a {
82 color: #c0c0c0;
83 }
84 -->
85 </style>
86 <script type="text/javascript">
87 function select (state)
88 {
89 var cboxes = document.getElementsByTagName(\'input\');
90 for (var i = 0; i < cboxes.length; i++) {
91 if (cboxes[i].type == "checkbox") {
92 if (state == "true") {
93 cboxes[i].checked = true;
94 } elseif (state == "false") {
95 cboxes[i].checked = false;
96 } elseif (state == "invert") {
97 cboxes[i].checked = !cboxes[i].checked;
98 }
99 }
100 }
101 }
102 </script>
103</head>
104<body>
105<h1>' . $title . '</h1>
106';
107}
108
109function make_footer ()
110{
111 echo '<div id="footer"><a href="http://qbnz.com/highlighter/">GeSHi</a> &copy; Nigel McNie, 2004, released under the GPL</div></body>
112</html>';
113}
114
115
116function get_var ( $var_name )
117{
118 if ( isset($_GET[$var_name]) )
119 {
120 return str_replace("\'", "'", $_GET[$var_name]);
121 }
122 elseif ( isset($_POST[$var_name]) )
123 {
124 return str_replace("\'", "'", $_POST[$var_name]);
125 }
126 return null;
127}
128
129
130
131//
132// Unset everything
133//
134foreach ( $_REQUEST as $var )
135{
136 unset($$var);
137}
138foreach ( array(
139 '_POST' => 'HTTP_POST_VARS',
140 '_GET' => 'HTTP_GET_VARS',
141 '_COOKIE' => 'HTTP_COOKIE_VARS',
142 '_SERVER' => 'HTTP_SERVER_VARS',
143 '_ENV' => 'HTTP_ENV_VARS',
144 '_FILES' => 'HTTP_POST_FILES') as $array => $other )
145{
146 if ( !isset($$array) )
147 {
148 $$array = $$other;
149 }
150 unset($$other);
151}
152
153
154// Get what step we're up to
155$step = get_var('step');
156
157if ( !$step || $step == 1 )
158{
159 $errors = 0;
160 make_header('Step 1');
161 echo "Welcome to the GeSHi CSS generator.<br /><pre>Searching for GeSHi... ";
162
163 // Find GeSHi
164 $geshi_path = get_var('geshi-path');
165 $geshi_lang_path = get_var('geshi-lang-path');
166
167 if(strstr($geshi_path, '..')) {
168 unset($geshi_path);
169 }
170 if(strstr($geshi_lang_path, '..')) {
171 unset($geshi_lang_path);
172 }
173
174 if ( !$geshi_path )
175 {
176 $geshi_path = '../geshi.php';
177 }
178 if ( !$geshi_lang_path )
179 {
180 $geshi_lang_path = '../geshi/';
181 }
182
183 if ( is_file($geshi_path) && is_readable($geshi_path) )
184 {
185 // Get file contents and see if GeSHi is in here
186 $file = @file($geshi_path);
187 $contents = '';
188 foreach ( $file as $line )
189 {
190 $contents .= $line;
191 }
192 if ( strpos($contents, '<?php";
378
379 if ( $overall != '' )
380 {
381 $stylesheet .= "\n$overall_selector {{$overall_styles}}";
382 }
383 if ( $default_styles != '' )
384 {
385 $default_selector = str_replace(array('{PART1}', '{PART2}'), array('.de1', '.de2'), $part_selector_2);
386 $stylesheet .= "\n$default_selector {{$default_styles}}";
387 }
388
389 // Do keywords
390 $keywords_1 = get_var('keywords-1');
391 $keyword_selector_1 = str_replace('{PART}', '.kw1', $part_selector_1);
392 if ( $keywords_1 != '' )
393 {
394 $stylesheet .= "\n$keyword_selector_1 {{$keywords_1}}";
395 }
396
397 $keywords_2 = get_var('keywords-2');
398 $keyword_selector_2 = str_replace('{PART}', '.kw2', $part_selector_1);
399 if ( $keywords_2 != '' )
400 {
401 $stylesheet .= "\n$keyword_selector_2 {{$keywords_2}}";
402 }
403
404 $keywords_3 = get_var('keywords-3');
405 $keyword_selector_3 = str_replace('{PART}', '.kw3', $part_selector_1);
406 if ( $keywords_3 != '' )
407 {
408 $stylesheet .= "\n$keyword_selector_3 {{$keywords_3}}";
409 }
410
411 $keywords_4 = get_var('keywords-4');
412 $keyword_selector_4 = str_replace('{PART}', '.kw4', $part_selector_1);
413 if ( $keywords_4 != '' )
414 {
415 $stylesheet .= "\n$keyword_selector_4 {{$keywords_4}}";
416 }
417
418 // Do other lexics
419 $comments = get_var('comments');
420 $comment_selector = str_replace(array('{PART1}', '{PART2}', '{PART3}'), array('.co1', '.co2', '.coMULTI'), $part_selector_3);
421 if ( $comments != '' )
422 {
423 $stylesheet .= "\n$comment_selector {{$comments}}";
424 }
425
426 $esc = get_var('escaped-chars');
427 $esc_selector = str_replace('{PART}', '.es0', $part_selector_1);
428 if ( $esc != '' )
429 {
430 $stylesheet .= "\n$esc_selector {{$esc}}";
431 }
432
433 $brackets = get_var('brackets');
434 $brk_selector = str_replace('{PART}', '.br0', $part_selector_1);
435 if ( $brackets != '' )
436 {
437 $stylesheet .= "\n$brk_selector {{$brackets}}";
438 }
439
440 $strings = get_var('strings');
441 $string_selector = str_replace('{PART}', '.st0', $part_selector_1);
442 if ( $strings != '' )
443 {
444 $stylesheet .= "\n$string_selector {{$strings}}";
445 }
446
447 $numbers = get_var('numbers');
448 $num_selector = str_replace('{PART}', '.nu0', $part_selector_1);
449 if ( $numbers != '' )
450 {
451 $stylesheet .= "\n$num_selector {{$numbers}}";
452 }
453
454 $methods = get_var('methods');
455 $method_selector = str_replace('{PART}', '.me0', $part_selector_1);
456 if ( $methods != '' )
457 {
458 $stylesheet .= "\n$method_selector {{$methods}}";
459 }
460
461 echo "<pre>$stylesheet</pre>";
462
463 make_footer();
464}
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
make_header( $title)
Definition: cssgen.php:38
foreach($_REQUEST as $var) foreach(array('_POST'=> 'HTTP_POST_VARS', '_GET'=> 'HTTP_GET_VARS', '_COOKIE'=> 'HTTP_COOKIE_VARS', '_SERVER'=> 'HTTP_SERVER_VARS', '_ENV'=> 'HTTP_ENV_VARS', '_FILES'=> 'HTTP_POST_FILES') as $array=> $other) $step
Definition: cssgen.php:155
get_var( $var_name)
Definition: cssgen.php:116
make_footer()
Definition: cssgen.php:109
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
$errors