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($possible) == 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>
- <input type="submit" value="Wybierz"><br/>
- <?php
- echo '<input type="hidden" name="postvals" value="'.$collection.'" />';
- ?>
- </form>
- <?php
- }
- if(isset($_POST['postvals'])){
- $collection = unserialize($_POST['postvals']);
- }
- else{
- $collection=$_POST;
- }
- $path = 'Blogi/'.$_POST['blog'];
- $date = explode(".", $collection['date']);
- $time = explode(":",$collection['time']);
- $filename = $date[2].$date[1].$date[0].$time[0].$time[1].date("s");
- do{
- $postsWithSameTime++;
- if($postsWithSameTime<10) $uidstring = '0'.$postsWithSameTime;
- else $uidstring = $postsWithSameTime;
- }while(file_exists($path.'/'.$filename.$uidstring));
- $filename = $path.'/'.$filename.$uidstring;
- echo $fileName;
- $file = fopen($filename, "w");
- fwrite($file, $collection['userText']);
- fclose();
- if(count($_FILES['uploads']['fileUpload'])) {
- foreach ($_FILES['uploads']['fileUpload'] as $file) {
- //do your upload stuff here
- echo $file;
- }
- }
- }
- 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