128) return NULL; if (strlen($name) == 0) return NULL; if (!preg_match('/[\w\x20\-\_]+/', $name)) return NULL; return $name; } function validate_basesize($size) { if ($size === NULL) return NULL; $size = (float)$size; if ($size < 3.0) return NULL; if ($size > 100.0) return NULL; return $size; } function validate_pgmargin($size) { if ($size === NULL) return NULL; $size = (float)$size; if ($size < 0.0) return NULL; if ($size > 10.0) return NULL; return $size; } $f1 = $_POST['font1']; $f2 = $_POST['font2']; $bs = $_POST['bsize']; $ms = $_POST['margin']; $f1 = validate_fontname($f1); $f2 = validate_fontname($f2); $bs = validate_basesize($bs); $ms = validate_pgmargin($ms); if ($f1 === NULL) $f1 = $_COOKIE['basefont']; if ($f2 === NULL) $f2 = $_COOKIE['codefont']; if ($bs === NULL) $bs = $_COOKIE['basesize']; if ($ms === NULL) $ms = $_COOKIE['pgmargin']; if ($f1 !== NULL) setcookie('basefont', $f1, time() + 315360000, '/krashan/amigaos/', 'teleinfo.pb.edu.pl'); if ($f2 !== NULL) setcookie('codefont', $f2, time() + 315360000, '/krashan/amigaos/', 'teleinfo.pb.edu.pl'); if ($bs !== NULL) setcookie('basesize', $bs, time() + 315360000, '/krashan/amigaos/', 'teleinfo.pb.edu.pl'); if ($ms !== NULL) setcookie('pgmargin', $ms, time() + 315360000, '/krashan/amigaos/', 'teleinfo.pb.edu.pl'); $f1 = validate_fontname($f1); $f2 = validate_fontname($f2); $bs = validate_basesize($bs); $ms = validate_pgmargin($ms); $n = $_GET['a']; if ($n == '') $n = 'toc'; if (preg_match('/[\w\-]+/', $n)) { $n = 'txt/' . $n . '.txt'; } else $n='txt/404.txt'; if (!file_exists($n)) $n = 'txt/404.txt'; $ct = file($n, FILE_IGNORE_NEW_LINES); /*--------------------------------------------------------------------*/ /* Language detection, first line of file contains thing like '[pl]'. */ /* The default language is English ('en'). If the first line contains */ /* language marker, it is removed from the line array. */ /*--------------------------------------------------------------------*/ $lang = 'en'; $lang2 = array(); if (preg_match('/\[([a-z][a-z])\]/', $ct[0], $lang2)) { $lang = $lang2[1]; unset($ct[0]); } ?> "; } if ($f2 !== NULL) { $google_f2 = str_replace(' ', '+', $f2); echo ""; } ?> . */ $html_from_tbl = array('<', '>', '\\\\'); $html_to_tbl = array('<', '>', '
'); foreach ($ct as $c) { if ($line == 0) { $title = preg_replace('/^=(.*)=$/Uu', '$1', $c); echo '' . $title . ''; if ($n != 'txt/toc.txt') echo '
Spis treści
'; $line = 1; } $c = str_replace($html_from_tbl, $html_to_tbl, $c); /* ====== headers ====== */ $c = preg_replace('/====(\S.+\S)====/U', '

$1

', $c); $c = preg_replace('/===(\S.+\S)===/U', '

$1

', $c); $c = preg_replace('/==(\S.+\S)==/U', '

$1

', $c); $c = preg_replace('/=(\S.+\S)=/U', '

$1

', $c); /* ====== special underlined header for autodocs ====== */ $c = preg_replace('/___(\S.+\S)___/U', '

$1

', $c); /* ====== bold, italic, underline ====== */ $c = preg_replace('/__(.*)__/U', '$1', $c); $c = preg_replace('/\x27\x27\x27(.*)\x27\x27\x27/U', '$1', $c); $c = preg_replace('/\x27\x27(.*)\x27\x27/U', '$1', $c); /* ====== superscripts ======== */ $c = preg_replace('/\^\^(.*)\^\^/U', '$1', $c); /* ====== paragraphs ====== */ if ($c[0] == "\t") $c = "\n

" . substr($c, 1) . "

\n"; // plain, starting with tab if ($c[0] == '_' && $c[1] == '_') $c = "\n
" . substr($c, 2) . "
\n"; // note, starting with "__" if ($c[0] == '^' && $c[1] == '^') $c = "\n
" . substr($c, 2) . "
\n"; // important, starting with "^^" /* ====== code ====== */ if ($c[0] == ' ') { if ($cd == 0) { echo "\n
"; $cd = 1; } $i = 0; $m = ''; $c = str_replace(' ', ' ', substr($c, 1)) . '
'; } else { if ($cd == 1) echo "
\n"; $cd = 0; } /* ====== tables |left|^center|$right| ====== */ if ($c[0] == '|') { if ($tbl == 0) { echo ''; $tbl = 1; } /* centered cells */ $c = preg_replace('/^\|\^/', '', $c); $c = preg_replace('/\|/', '
', $c); $c = preg_replace('/\|\^/', '', $c); /* right aligned cells */ $c = preg_replace('/^\|\$/', '
', $c); $c = preg_replace('/\|\$/', '', $c); /* left aligned cells */ $c = preg_replace('/^\|/', '
', $c); $c = preg_replace('/\|$/', '
', $c); } else { if ($tbl == 1) echo '
'; $tbl = 0; } /* ====== images [[img |