Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!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>Dodawanie wpisu</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- </head>
- <body>
- <?php
- if(isset($_POST['userName']) && isset($_POST['password']) && isset($_POST['userText']) && isset($_POST['date'])&& isset($_POST['time'])){
- $userName = $_POST['userName']."\n";
- $password = md5($_POST['password'])."\n";
- $blogs = scandir('Blogi');
- $postsWithSameTime = 0;
- $possible = array();
- foreach($blogs as $value){
- $info = file('Blogi/'.$value.'/info');
- if(($info[0]==$userName) && $info[1]==$password){
- array_push($possible, $value);
- }
- }
- $collection = serialize($_POST);
- if(count($possible)==1){
- $_POST['blog']=$possible[0];
- }
- elseif(count($available) == 0){
- echo 'Nie posiadasz żadnego bloga! <a href="zad1.html">Powrót do formularza dodawania wpisu</a>';
- return;
- }
- else{
- ?>
- <form action="wpis.php" method="POST">
- Do którego bloga chcesz dodać wpis?<br/>
- Lista Twoich blogów:<br/>
- <select name="blog">
- <?php
- foreach($possible as $blog) echo '<option value="'.$blog.'">'.$blog.'</option>';
- ?>
- </select>
- <?php
- echo '<input type="hidden" name="postvals" value="'.$collection.'" />';
- ?>
- </form>
- <?php
- $collection = unserialize($_POST['postvals']);
- }
- $path = 'Blogi/'.$_POST['blog'];
- $date = $collection['date'];
- echo $date;
- $time = $collection['time'];
- $filename = $date[2].$date[1].$date[0].$time[0].$time[1].date("s");
- while(file_exists($path.'/'.$filename.$uidstring)){
- $postsWithSameTime++;
- if($uid<10) $uidstring = '0'.$postsWithSameTime;
- else $uidstring = $postsWithSameTime;
- }
- $filename = $path.'/'.$filename.$uidstring;
- echo $fileName;
- $file = fopen($filename, "w");
- fwrite($info, $collection['userText']);
- fclose();
- }
- else{
- echo "Puste pola w formularzu";
- echo '<a href="zad2.html">Powrót do formularza dodawania wpisu></a>';
- return;
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement