You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

407 lines
11 KiB
PHP

<?php
include( 'rtf/rtfparser.php' );
// CreateTitle macht aus "/htdocs/xx/yy/thisfile.php einen
// Title der mit printf("Titleformat%s", basename(php_self)
// gebildet wird.
function PrintTitle()
{
global $sys_titelformat;
global $navtext;
global $sys_dokutitel;
global $sys_admin;
global $sys_doku_gen;
echo $sys_dokutitel.'"';
if ($sys_admin && $sys_doku_gen){
echo HtmlText(sprintf( $sys_titelformat,$navtext.' - Anzeige aus Generierten Files wenn möglich'));
}
else{
echo HtmlText(sprintf( $sys_titelformat,$navtext));;
}
echo '"';
}
function PrintBrowser()
{
global $sprache_browser;
global $sys_browser;
global $sys_default_browser;
if ($sprache_browser != '' and $sys_default_browser != '' and $sys_browser[browser] != $sys_default_browser){
echo '<br>'.$sprache_browser;
}
}
// Liefert Author
function PrintAuthor()
{
global $sys_author;
echo '"';
echo HtmlText($sys_author);
echo '"';
}
// Liefert Editor
function GetEditor($ueditor)
{
$l_root = substr( $_SERVER['SCRIPT_FILENAME'], 0, strpos( $_SERVER['SCRIPT_FILENAME'], '/' ));
foreach ($ueditor as $l_editor){
if (file_exists($l_root.$l_editor)){
return $l_root.$l_editor;
}
}
return '';
}
// Gibt den Parameterbereich eines Tags zurück
function GetParamBlock($line){
global $act_htmltag;
$param_start_pos = strpos($line,$act_htmltag) + strlen($act_htmltag);
$param_ende_pos = strpos($line,'>',$param_start_pos);
// kompletten block bis abschliessendem '>' ausschneiden
return(substr($line, $param_start_pos, $param_ende_pos - $param_start_pos));
}
// Ersetzt das alte Tag mit dem neuen Wert
function GetNewTag($param_block,$html_code,$line){
global $act_tag;
global $act_htmltag;
global $act_nr;
global $act_endtag;
global $zeile_nr;
if ($act_nr++ > 10){
echo "ACHTUNG TAGFEHLER STELLE '.$act_tag.' Zeile ".$zeile_nr."<BR>\n";
echo "Zeilentext:".$line."<BR>\n";
exit; // Notaustieg bei falschem tag
}
return(str_replace($act_htmltag.$param_block.$act_endtag,$html_code,$line));
}
// Setzt replace file falls notwendig
function GetReplaceFile($orig_file){
global $act_nr;
global $act_tag;
global $zeile_nr;
global $_replzlnr;
global $_repllnknr;
$replfile = 'repl'.$act_tag;
// Diese $_GET nicht ändern - sind dynamisch
if ($_GET[$replfile] != '' && $_replzlnr == $zeile_nr && $_repllnknr == $act_nr){
return ($_GET[$replfile]);
}
else{
return($orig_file);
}
}
// Button erstellen
function GetButton($button,$text,$onclick){
return ( '<div id="button" onclick="'.$onclick.'">'.
'<div id="button_'.$button.'">'.
'<p>'.$text.'</p></div></div>'
);
}
// Aktuellen Tag setzten
function SetActTag($tag){
global $act_nr;
$act_nr = 0;
global $act_tag;
$act_tag = $tag;
global $act_htmltag;
$act_htmltag = '<!'.$tag.'=';
global $act_endtag;
$act_endtag = '>';
}
// Aktuellen Tag ersetzten
function ResetActTag($tag){
global $act_tag;
$act_tag = $tag;
global $act_htmltag;
$act_htmltag = '<!'.$tag.'=';
}
function GetHtmlAnker()
{
global $act_tag;
global $act_nr;
global $zeile_nr;
return($act_tag.'anker-z'.$zeile_nr.'-n'.$act_nr);
}
// Gibt Linkbutton für indexe.php zurück (einhängen con files und links)
function GetEditButton($file,$alttext,$button,$err_button,$parm1,$parm2){
global $sys_admin;
global $navpos;
global $zeile_nr;
global $act_nr;
global $act_tag;
global $sys_sonderzeichen_suche_href;
global $sys_sonderzeichen_ersetze_href;
global $_self;
if ($sys_admin){
$htmltext['ok'] = '<a name="'.GetHtmlAnker().'"></a>'.
'<a href="'.
HtmlHref( 'indexe.php'.
'?basis='.$_self. // Rücksprungsbasisadresse
'&ap='. $navpos. // Anzeige name
'&an='. GetHtmlAnker(). // Anzeige Anker
'&file='. $file. // Zu änderndes File
'&zlnr='. $zeile_nr. // Zeile der Änderung
'&lnknr='.$act_nr. // Tagnr der änderung (wenn merere gleiche Tags in einer Zeile)
'&tag='. $act_tag. // Tagname ohne <! und =
'&lnk1='. $parm1. // Parm1
'&lnk2='. $parm2 // Parm2
).
'"><img src="'.$button.'" alt=" '.$alttext.' "></a>';
$htmltext['err'] = '<a name="'.GetHtmlAnker().'"></a>'.
'<a href="'.
HtmlHref( 'indexe.php'.
'?basis='.$_self. // Rücksprungsbasisadresse
'&ap='. $navpos. // Anzeige name
'&an='. GetHtmlAnker(). // Anzeige Anker
'&file='. $file. // Zu änderndes File
'&zlnr='. $zeile_nr. // Zeile der Änderung
'&lnknr='.$act_nr. // Tagnr der änderung (wenn merere gleiche Tags in einer Zeile)
'&tag='. $act_tag. // Tagname ohne <! und =
'&lnk1='. $parm1. // Parm1
'&lnk2='. $parm2 // Parm2
).
'"><img src="'.$err_button.'" alt=" '.$alttext.' "></a>';
}
else {
$htmltext['ok'] = '<a name="'.GetHtmlAnker().'"></a>';
$htmltext['err'] = '<a name="'.GetHtmlAnker().'"></a>';
}
return $htmltext;
}
// Gibt den Filenamen zurück falls das file schon angelegt ist
function GetExists($upath,$ufile)
{
if (!file_exists($upath."/".$ufile)){
return $ufile;
}
else{
return '';
}
}
function EchoText($utext){
echo str_replace(" ","&nbsp;",$utext)."<br>\n";
}
function HtmlHref($utext){
global $sys_sonderzeichen_suche_href;
global $sys_sonderzeichen_ersetze_href;
return str_replace($sys_sonderzeichen_suche_href,
$sys_sonderzeichen_ersetze_href,
$utext);
}
function HtmlText($utext){
global $sys_sonderzeichen_suche_full;
global $sys_sonderzeichen_ersetze_full;
return str_replace($sys_sonderzeichen_suche_full,
$sys_sonderzeichen_ersetze_full,
$utext);
}
function PrintFehler($utext){
echo "==>".str_replace(" ","&nbsp;","<big>".$utext."</big><br>\n");
global $err;
global $ierr;
$err = true;
$ierr++;
}
function PrintFile($ufile){
global $sys_sonderzeichen_suche;
global $sys_sonderzeichen_ersetze;
if ($lfile = fopen($ufile, 'r')){
echo str_replace( $sys_sonderzeichen_suche,
$sys_sonderzeichen_ersetzte,
trim(fread($lfile,filesize($ufile))));
fclose($lfile);
}
}
// Stetzt farbe je nach fileoption
function GetEditColour($udir,$ufile,$ufarbe){
$f_weiss = ' style="background-color: rgb(202,202,202);"';
$f_gruen = ' style="background-color: rgb(50,202,50);"';
$f_blau = ' style="background-color: rgb(50,50,202);"';
$f_rot = ' style="background-color: rgb(202,50,50);"';
switch($ufarbe)
{
case 'rot':
return $f_rot;
case 'gruen':
return $f_gruen;
case 'blau':
return $f_blau;
case 'weiss':
return $f_weiss;
default:
if (!file_exists($udir."/".$ufile)){
return $f_gruen;
}
else{
if (in_array($ufile,$_SESSION["lastedit"])){
if (in_array($ufile,$_SESSION["deledit"])){
return $f_rot;
}
else {
return $f_blau;
}
}
}
return $f_weiss;
}
}
function GetAnkermenuetext($ufile,$umenunamen)
{
global $sys_anz_ueberschriften;
global $verz_rtf;
if ($lfile = fopen($ufile, 'r')){
while (!feof ($lfile)){
$line = trim(fgets ($lfile, 4096));
$k = 0;
while (++$k<=$sys_anz_ueberschriften){
while ((strpos($line,'<!h'.$k.'a=') !== false )){
// auf das Zeichen 'w' und letztes Zeichen positionieren
$param_start_pos = strpos($line,'<!h'.$k.'a=') + 6;
$param_ende_pos = strpos($line,'>',$param_start_pos);
// param_block = name der span Klasse
$param_block = substr($line, $param_start_pos, $param_ende_pos - $param_start_pos);
$line = str_replace('<!h'.$k.'a='.$param_block.'>','',$line);
list($menuename,$menuetext) = split(',',$param_block);
if ($menuename == $umenunamen){
if ($menuetext != ''){
return($menuetext);
}
else{
return($menuename);
}
}
}
}
}
}
return('');
}
// Setzt Menuetag um $uaktion a nur anker, r nur rtf, b beide
function Get_Anker_Styles_HX($ufile,$uaktion)
{
global $anker;
global $sys_anz_ueberschriften;
global $verz_rtf;
global $act_htmltag;
global $act_endtag;
global $act_nr;
global $zeile_nr;
$zeile_nr = 0;
unset($anker['menuename']);
unset($anker['menuetext']);
$j = 0;
if (!file_exists($ufile) || is_dir($ufile)){
return;
}
if ($lfile = fopen($ufile, 'r')){
while (!feof ($lfile)){
$line = trim(fgets ($lfile, 4096));
$zeile_nr++;
// a Anker oder b Both
if ($uaktion == 'a' || $uaktion == 'b'){
$k = 0;
// Durchlesen aller <!h?=> oder <!h?a=> Tags
while (++$k<=$sys_anz_ueberschriften){
SetActTag('h'.$k.'a'); // Aktives Tag setzten
while (strpos($line,$act_htmltag) !== false ) {
$param_block = GetParamBlock($line); // Inhalt des Tags holen
list($anker['menuename'][$j],$anker['menuetext'][$j]) = split(',',$param_block);
if ($anker['menuetext'][$j] == ''){
$anker['menuetext'][$j] = $anker['menuename'][$j];
}
$j++;
$line = GetNewTag($param_block,'',$line);
}
}
}
// r RTF oder b Both
if ($uaktion == 'r' || $uaktion == 'b'){
SetActTag('rtf');
while (strpos($line,$act_htmltag) !== false ) {
$param_block = GetParamBlock($line); // Inhalt des Tags holen
$rtf_file = $param_block;
// extension wird geadded wenn fehlt
if( strpos($rtf_file,".rtf") == FALSE ){
$rtf_file .= ".rtf";
}
$rtf_file = GetReplaceFile($rtf_file); // Replacefile holen falls notwendig
$rtf_filename = $verz_rtf.'/'.$rtf_file;
$classname = 'rtf'.$zeile_nr.$act_nr. "cf"; // erstes file in einem dokument bekommt cf0
// Files testen und RTF code generieren
if( file_exists($rtf_filename)){
$rtf = file_get_contents( $rtf_filename );
echo parse_styles($rtf,$classname);
}
$line = GetNewTag($param_block,'',$line);
}
}
}
fclose($lfile);
}
/*
// Testeinbau Anfang
echo ":::".$anker['menuetext'][0].":::\n";
echo ":::".$anker['menuetext'][1].":::\n";
echo ":::".$anker['menuetext'][2].":::\n";
echo ":::".$anker['menuename'][0].":::\n";
echo ":::".$anker['menuename'][1].":::\n";
echo ":::".$anker['menuename'][2].":::\n";
exit;
// Testeinbau Ende
*/
}
// Verzeichnisstruktur lesen und in array stellen
//
function ListCss($udir,$uext,$uvlg)
{
global $sprache_aktivieren;
global $sprache_abbrechen;
global $_self;
if ($fudir = opendir($udir))
{
global $sys_css;
echo '<form action="' . HtmlHref($_self . '?ap=' . $_ap) . '" method="get">'."\n";
echo "<p>\n";
echo '<select name="css" size="3">'."\n";
while (false !== ($file = readdir($fudir))) {
if (strpos($file,$uext)) {
if ($uvlg == $file){
echo '<option selected>' . $file . "</option>\n";
}
else{
echo '<option>' . $file . "</option>\n";
}
}
}
closedir($fudir);
echo "</select>\n";
echo "</p>\n";
echo '<input type="submit" value="'.HtmlText($sprache_aktivieren).'">'."<br>\n";
echo '<input type="reset" value="'.HtmlText($sprache_abbrechen).' ">' ;
echo "</form>\n";
}
}
?>