Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $wpis=$_POST['wpis'];
- $feedback=$_POST['feedback'];
- $comment=$_POST['comment'];
- $name=$_POST['name'];
- $lastName=$_POST['lastName'];
- $nick=$_POST['nick'];
- $directory = new RecursiveDirectoryIterator('.');
- $BlogDirectory = NULL;
- $fileToComment = NULL;
- foreach (new RecursiveIteratorIterator($directory) as $sciezkaDoPliku => $plik) {
- echo basename($plik)." ";
- if (! ($plik->isDir())) {
- if (basename($plik) === $wpis.".txt") {
- $withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $plik);
- $fileToComment = $withoutExt;
- $BlogDirectory = dirname($plik);
- }
- }
- }
- echo $fileToComment;
- if (!file_exists($fileToComment . ".k")) {
- mkdir($fileToComment . ".k", 0777, true);
- }
- // narazie dany katalog na sztywno
- $targetDir=$fileToComment.".k/";
- //iterowanie i szukanie najmlodszego wpisu
- $comNum = 0;
- while (file_exists($targetDir. "/" . $comNum.".txt")) {
- $comNum = $comNum + 1;
- }
- $newCommentPath=$targetDir."/".$comNum.".txt";
- $file=fopen($newCommentPath,"w");
- fwrite($file,$feedback."\n");
- $timestamp=date("Y-m-d H:i:s");
- fwrite($file,$timestamp."\n");
- fwrite($file,$name." ".$lastName." ".$nick."\n");
- fwrite($file,$comment);
- fclose($file);
- header('Location: '.$newURL);
- ?>
- ---------------------------------
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Przykładowa obsługa plków</title>
- <meta http-equiv="content-type"content="text/html;charset=UTF-8" />
- </head>
- <body>
- <?php include 'navigator.php'; ?>
- <form action="koment.php" method="post"enctype="multipart/form-data"><p>
- Rodzaj Komentarza:<br>
- <input type="radio" name="feedback" value="positive"> positive<br>
- <input type="radio" name="feedback" value="neutral"> neutral<br>
- <input type="radio" name="feedback" value="negative"> negative <br>
- Komentarz:<br>
- <textarea name="comment"></textarea> <br>
- Imie:<br>
- <input type="text" name="name" /><br>
- Nazwisko:<br>
- <input type="text" name="lastName" /><br>
- Nick: <br>
- <input type="text<?php
- $wpis=$_POST['wpis'];
- $feedback=$_POST['feedback'];
- $comment=$_POST['comment'];
- $name=$_POST['name'];
- $lastName=$_POST['lastName'];
- $nick=$_POST['nick'];
- $directory = new RecursiveDirectoryIterator('.');
- $BlogDirectory = NULL;
- $fileToComment = NULL;
- foreach (new RecursiveIteratorIterator($directory) as $sciezkaDoPliku => $plik) {
- echo basename($plik)." ";
- if (! ($plik->isDir())) {
- if (basename($plik) === $wpis.".txt") {
- $withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $plik);
- $fileToComment = $withoutExt;
- $BlogDirectory = dirname($plik);
- }
- }
- }
- echo $fileToComment;
- if (!file_exists($fileToComment . ".k")) {
- mkdir($fileToComment . ".k", 0777, true);
- }
- // narazie dany katalog na sztywno
- $targetDir=$fileToComment.".k/";
- //iterowanie i szukanie najmlodszego wpisu
- $comNum = 0;
- while (file_exists($targetDir. "/" . $comNum.".txt")) {
- $comNum = $comNum + 1;
- }
- $newCommentPath=$targetDir."/".$comNum.".txt";
- $file=fopen($newCommentPath,"w");
- fwrite($file,$feedback."\n");
- $timestamp=date("Y-m-d H:i:s");
- fwrite($file,$timestamp."\n");
- fwrite($file,$name." ".$lastName." ".$nick."\n");
- fwrite($file,$comment);
- fclose($file);
- header('Location: '.$newURL);
- ?>" name="nick" /><br>
- <input type="hidden" name="wpis" value="<?php echo $_GET['wpis'] ?>" /><br>
- <input type="submit" value="dodaj" /></p><input type="reset" value="wyczyść" /></p>
- </form>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement