Powrót do listy

'; $msg .= $msg_text; $msg .= '
'; echo $msg; foother(); exit; } function foother() { echo '

camel © 2006 | Powered by txtStaticPages v 0.1 dev'; echo ''; } function form($fTitle = false, $fName = false, $fContent = false, $fButton = 'Utwórz stronę', $fAction = 'read.php?s=add') { echo '
Tytuł strony:


Nazwa linku (read.php?s="nazwa"). Tylko małe litery, cyfry i "_", bez spacji i polskich znaków:


Treść strony (można używać html):


'; } $new_title = $_POST['title']; $new_link_name = $_POST['link_name']; $new_content = $_POST['content']; echo 'txtStaticPages'; echo '

txtStaticPages - by camel

'; if ($_GET['del']) { $delFile = $path.$_GET['del'].$ex; if ( file_exists($delFile) ) { unlink($delFile); msg('Strona zostala skasowana'); } else { msg('Plik '.$_GET['del'].$ex.' nie istnieje'); } exit; } if(!$_GET['s']) { echo '» Dodaj nowa strone
'; @$dir = opendir($path); if (!$dir) { msg('Nie moge otworzyc katalogu', 1); } while ( $files = readdir($dir) ) { $fileEx = strtolower(strrchr($files, ".")); if($fileEx == $ex) { $fileslist[] = $files; } } echo ''; } elseif ($_GET['s'] == 'add') { echo '« Powrót do listy

'; if (isset($new_title) OR isset($new_link_name) OR isset($new_content)) { if ($new_title == '' OR $new_link_name == '' OR $new_content == '') { echo '« Dodaj nowa strone

'; msg ('Nie wypelniles wszystkich pól', 1); } elseif ( file_exists($path.$new_link_name.$ex) ) { echo '« Dodaj nowa strone

'; msg ('Strona o takiej nazwie juz instnieje', 1); } else { $tmpfname = tempnam($_ENV["DOCUMENT_ROOT"]."/$path", "FOO"); $handle = fopen($tmpfname, "w"); $writing = $new_title."||".$new_content; fwrite($handle, $writing); fclose($handle); ///echo($_ENV["DOCUMENT_ROOT"]); copy($tmpfname, $path.$new_link_name.$ex); chmod($path.$new_link_name.$ex, '777'); if (file_exists($path.$new_link_name.$ex)) { msg ('Strona zostala zapisana', 1); } else { msg ('Wystapil blad podczas dodawania', 1); } } } else { echo 'Dodaj strone:

'; form(); } } else { if (file_exists($path.$_GET['s'].$ex)) { $open = fopen($path.$_GET['s'].$ex, "r"); $dane = fread($open, filesize($path.$_GET['s'].$ex)); } else { msg('Taka strona nie istnieje'); } echo '« Powrót do listy

'; $title = explode( "||", $dane ); $filename = $_GET['s']; $text = nl2br($title[1]); if(isset($_GET['mode']) AND $_GET['mode'] == 'edit') { if ( !isset($_POST['save']) ) { form(stripslashes($title[0]), $filename, $text, 'Zapisz', ''); } else { $modOpen = fopen($path.$_GET['s'].$ex, "w"); $writing = $new_title."||".$new_content; fwrite($modOpen, $writing); //fclose($modOpen); if ( !rename($path.$_GET['s'].$ex, $path.$new_link_name.$ex) ) { msg ('Nie mozna bylo zmodyfikowac strony', 1); } else msg ('Strona zostala zmodyfikowana', 1); } } else { echo 'Tytuł: '.stripslashes($title[0]).'
'; echo 'Nazwa pliku: '.$filename.$ex.'

'; echo '
Tresc strony'.$text.'
'; } fclose($open); } foother(); ?>