It works fine with simple content, but I don't know how to handle GET -variables in it.
I convert my tags to html with this code:
Code: Select all
<?php
$file = file("file.txt");
// Printing file
for ($i = 0; $i < count($file); $i++) {
$line = $file[$i];
// Getting the size of an image
if (strstr($line, '[pict]')) {
$picture = trim($line);
$picture = str_replace('[pict]', '', $picture);
$picture = str_replace('[/pict]', '', $picture);
list($width, $height, $type, $attr) = getimagesize($picture);
$picture = '<img src="' . $picture . '" width="' . $width . '" height="' . $height . '" alt="" border="0">';
$line = $picture;
}
// Linking to a page
$line = str_replace('[link]', '<a href="', $line);
$line = str_replace('[linktext]', '">', $line);
$line = str_replace('[/link]', '</a>', $line);
// Showing a title
$line = str_replace('[title]', '<font size="+1"><b>', $line);
$line = str_replace('[/title]', '</b></font><br>', $line);
// Making a line feed
$line = str_replace('[linefeed]', '<br>', $line);
// Centering content
$line = str_replace('[center]', '<p align="center" style="margin: 0px;">', $line);
$line = str_replace('[/center]', '</p>', $line);
echo $line;
}
?>file.txt:
Code: Select all
[title]Test Page[/title]
[linefeed]
[pict]picture.jpg[/pict]
[linefeed]
[linefeed]
[link]http://www.google.com/[linktext]Go to Google...[/link]
[center]Centered text[/center]I want this functionality to file.txt...
Code: Select all
<?php
if($_GET['p'] =="1") {
// content of page 1
}
if($_GET['p'] =="2") {
// content of page 2
}
if($_GET['p'] =="3") {
// content of page 3
}
?>Code: Select all
[title]Links[/title]
[link]index.php?p=1[linktext]Go to page 1[/link]
[link]index.php?p=1[linktext]Go to page 2[/link]
[link]index.php?p=1[linktext]Go to page 3[/link]
[start_page]1
[title]Test Page 1[/title]
[linefeed]
[pict]picture1.jpg[/pict]
[stop_page]1
[start_page]2
[title]Test Page 2[/title]
[linefeed]
[pict]picture2.jpg[/pict]
[stop_page]2
[start_page]3
[title]Test Page 3[/title]
[linefeed]
[pict]picture3.jpg[/pict]
[stop_page]3So how do I do it?