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.

142 lines
4.1 KiB
PHP

<?php
// Setzt Menuetag um $uaktion a nur anker, r nur rtf, b beide
function Get_Anker($ufile,$uanz_ueberschriften)
{
global $act_nr;
global $act_tag;
global $act_htmltag;
global $act_endtag;
global $zeile_nr;
$zeile_nr = 0;
$j = 0;
$anker['menuetextk'] = array();
$anker['menuetextl'] = array();
$anker['menuelink'] = array();
errorlog('Anker lesen mit file:'.$ufile);
errorlog('!! Anker wird nur generiert und eingehaengt, wenn Tag <!menue> vorhanden ist !!');
if (file_exists($ufile) && !is_dir($ufile)){
if ($lfile = fopen($ufile, 'r')){
errorlog('File gefunden.');
while (!feof ($lfile)){
$line = trim(fgets ($lfile, 4096));
if (substr($line,0,2) != '//'){ //Kommentar an den erste zwei Positionen herausfiltern
$zeile_nr++;
// a Anker oder b Both
$k = 0;
// Durchlesen aller <!h?=> oder <!h?a=> Tags
while (++$k<=$uanz_ueberschriften){
SetActTag('h'.$k.'a'); // Aktives Tag setzten
while (strpos($line,$act_htmltag) !== false ) {
$param_block = GetParamBlock($line); // Inhalt des Tags holen
list($anker['menuetextk'][$j],$anker['menuetextl'][$j],$anker['menuelink'][$j]) = split(',',$param_block);
$j++;
$line = GetNewTag($param_block,'',$line);
}
}
}
}
fclose($lfile);
}
}
return $anker;
}
// 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.'=';
}
// 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_max;
global $act_htmltag;
global $act_nr;
global $act_endtag;
global $zeile_nr;
if ($act_nr++ > $act_max){
errorlog( "######################################################\n");
errorlog( "######################################################\n");
errorlog( "ACHTUNG TAGFEHLER STELLE '.$act_tag.' Zeile ".$zeile_nr."\n");
errorlog( "Zeilentext:".$line."\n");
errorlog( "######################################################\n");
errorlog( "######################################################\n");
exit; // Notaustieg bei falschem tag
}
return(str_replace($act_htmltag.$param_block.$act_endtag,$html_code,$line));
}
// Gibt Linkbutton für indexe.php zurück (einhängen con files und links)
function GetEditButton($typ,$file,$alttext,$button,$err_button,$efile,$sys_admin){
global $act_nr;
global $act_tag;
global $zeile_nr;
$lanker = GetHtmlAnker();
if ($sys_admin){
$htmlfunktion = 'onclick=Aktionsbutton("'.$typ.'",'. // Kennung IMG (Achtung kein Blank lassen !!!!
'"'.$act_tag.'",'.
'"'.$file.'",'. // htmlFile to edit
'"'.$efile.'",'. // File das angezeigt wird
$zeile_nr.','. // Zeilennummer
$act_nr.','. // Tagnummer
'"'.$lanker.'"'. // Anker
')';
$htmltext['ok'] = '<a name="'.$lanker.'"></a>'.
'<img src="'.$button.'" alt="'.$alttext.'" '.$htmlfunktion.'>';
$htmltext['err'] = '<a name="'.$lanker.'"></a>'.
'<img src="'.$err_button.'" alt="'.$alttext.'" '.$htmlfunktion.'>';
}else{
$htmltext['ok'] = '<a name="'.$lanker.'"></a>';
$htmltext['err'] = '<a name="'.$lanker.'"></a>';
}
return $htmltext;
}
function scramble($u_tab){
$r_tab = array();
while(count($u_tab) > 0){
$i = rand(0,count($u_tab)-1);
array_push($r_tab,$u_tab[$i]);
$u_tab[$i] = chr(255);
sort($u_tab);
array_pop($u_tab);
}
return $r_tab;
}
function GetHtmlAnker()
{
global $act_tag;
global $act_nr;
global $zeile_nr;
return($act_tag.'anker-z'.$zeile_nr.'-n'.$act_nr);
}
?>