mamy sobie plik template.php ...
Kod
<?
$filedirectory = 'http://localhost/template';
$filepath = 'pliki';
$template = 'template_.php';
function die_nice($message){
die("$message");
}
if ( !$file) die_nice("Zle nazwane odwolanie do skryptu! Powinno wygladac tak: template.php?file=filename");
if ( !file_exists("$filepath/$file") ) die_nice("Plik $file nie istnieje!");
$fp = fopen ("$template", "r") or die_nice("Nie mozna odnalesc tempalety: $template");
$contents = fread ($fp, filesize ($template));
fclose ($fp);
$fpf = fopen ("$filepath/$file", "r") or die_nice("Plik $file nie istnieje!");
$lines = file("$filepath/$file");
list($tyt,$tresc) = explode("::", $lines[0]);
$tytul = strtoupper($tyt);
fclose ($fpf);
$contents = str_replace("[TRESC]", $tresc, $contents);
$contents = str_replace("[TYTUL]", $tytul, $contents);
$contents = str_replace("ą", "±", $contents);
$contents = str_replace("ś", "¶", $contents);
$contents = str_replace("ź", "Ľ", $contents);
$contents = str_replace("Ą", "ˇ", $contents);
$contents = str_replace("Ś", "¦", $contents);
$contents = str_replace("Ź", "¬", $contents);
print stripslashes($contents);
?>
$filedirectory = 'http://localhost/template';
$filepath = 'pliki';
$template = 'template_.php';
function die_nice($message){
die("$message");
}
if ( !$file) die_nice("Zle nazwane odwolanie do skryptu! Powinno wygladac tak: template.php?file=filename");
if ( !file_exists("$filepath/$file") ) die_nice("Plik $file nie istnieje!");
$fp = fopen ("$template", "r") or die_nice("Nie mozna odnalesc tempalety: $template");
$contents = fread ($fp, filesize ($template));
fclose ($fp);
$fpf = fopen ("$filepath/$file", "r") or die_nice("Plik $file nie istnieje!");
$lines = file("$filepath/$file");
list($tyt,$tresc) = explode("::", $lines[0]);
$tytul = strtoupper($tyt);
fclose ($fpf);
$contents = str_replace("[TRESC]", $tresc, $contents);
$contents = str_replace("[TYTUL]", $tytul, $contents);
$contents = str_replace("ą", "±", $contents);
$contents = str_replace("ś", "¶", $contents);
$contents = str_replace("ź", "Ľ", $contents);
$contents = str_replace("Ą", "ˇ", $contents);
$contents = str_replace("Ś", "¦", $contents);
$contents = str_replace("Ź", "¬", $contents);
print stripslashes($contents);
?>
... ktory jest odpowiedzialny za wypelnienie pliku template_.php ...
Kod
<html>
<body>
<h1>[TYTUL]</h1><br><hr>
<h4>[TRESC]</h4>
</body>
</html>
<body>
<h1>[TYTUL]</h1><br><hr>
<h4>[TRESC]</h4>
</body>
</html>
... zawartoscia pliku x.txt ...
Kod
jakis tam tytul::i jakas tam tresc...
... odwoluje sie do pliku template.php w ten sposob template.php?file=x.txt i wszystko gra!
ale chcialbym zmienic to na globala, zrobilem to w ten sposob (zawartosc pliku indexx.php):
Kod
<a href=indexx.php?id=1>indexx.php?id=1</a><br><br>
<?
if(!isset($id)) { include("1.php"); }
else { if($id==0){ include("1.php"); }
elseif($id==1){ include("template.php?file=x.txt"); }
}
?>
<?
if(!isset($id)) { include("1.php"); }
else { if($id==0){ include("1.php"); }
elseif($id==1){ include("template.php?file=x.txt"); }
}
?>
oczywiscie takie rozwiazanie nie dziala bo php nie moze odnalezc pliku template.php?file=x.txt
Cytat
Warning: Failed opening 'template.php?file=x.txt' for inclusion (include_path='') in c:foxservwwwtemplateindexx.php on line 6
czy mozna jakos temu zaradzic?? chodzi o to aby odwolanie do template.php?file=x.txt dzialalo tak jak bym sie odwolywal do zwyklego pliku template.php z instukcja ?file=x.txt a nie qrna do template.php?file=x.txt ...
moja wiedza o php jest dosc skromna dlatego bardzo prosze o pomoc ... od dawna obserwuje to forum i wiem ze dla was ludziska taki problem to nie problem :wink: