Advertisement
Guest User

Untitled

a guest
Dec 28th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5.  
  6. <head>
  7. <title>Dodawanie wpisu</title>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  9. </head>
  10.  
  11. <body>
  12. <?php
  13. if(isset($_POST['userName']) && isset($_POST['password']) && isset($_POST['userText']) && isset($_POST['date'])&& isset($_POST['time'])){
  14. $userName = $_POST['userName']."\n";
  15. $password = md5($_POST['password'])."\n";
  16. $blogs = scandir('Blogi');
  17. $postsWithSameTime = 0;
  18. $possible = array();
  19. foreach($blogs as $value){
  20. $info = file('Blogi/'.$value.'/info');
  21. if(($info[0]==$userName) && $info[1]==$password){
  22. array_push($possible, $value);
  23. }
  24. }
  25. $collection = serialize($_POST);
  26. if(count($possible)==1){
  27. $_POST['blog']=$possible[0];
  28. }
  29. elseif(count($possible) == 0){
  30. echo 'Nie posiadasz żadnego bloga! <a href="zad1.html">Powrót do formularza dodawania wpisu</a>';
  31. return;
  32. }
  33. else{
  34. ?>
  35. <form action="wpis.php" method="POST">
  36. Do którego bloga chcesz dodać wpis?<br/>
  37. Lista Twoich blogów:<br/>
  38. <select name="blog">
  39. <?php
  40. foreach($possible as $blog) echo '<option value="'.$blog.'">'.$blog.'</option>';
  41. ?>
  42. </select>
  43. <input type="submit" value="Wybierz"><br/>
  44. <?php
  45. echo '<input type="hidden" name="postvals" value="'.$collection.'" />';
  46. ?>
  47. </form>
  48. <?php
  49. }
  50. if(isset($_POST['postvals'])){
  51. $collection = unserialize($_POST['postvals']);
  52. }
  53. else{
  54. $collection=$_POST;
  55. }
  56. $path = 'Blogi/'.$_POST['blog'];
  57. $date = explode(".", $collection['date']);
  58. $time = explode(":",$collection['time']);
  59. $filename = $date[2].$date[1].$date[0].$time[0].$time[1].date("s");
  60. do{
  61. $postsWithSameTime++;
  62. if($postsWithSameTime<10) $uidstring = '0'.$postsWithSameTime;
  63. else $uidstring = $postsWithSameTime;
  64. }while(file_exists($path.'/'.$filename.$uidstring));
  65. $filename = $path.'/'.$filename.$uidstring;
  66. echo $fileName;
  67. $file = fopen($filename, "w");
  68. fwrite($file, $collection['userText']);
  69. fclose();
  70.  
  71. if(count($_FILES['uploads']['fileUpload'])) {
  72. foreach ($_FILES['uploads']['fileUpload'] as $file) {
  73.  
  74. //do your upload stuff here
  75. echo $file;
  76.  
  77. }
  78. }
  79.  
  80. }
  81. else{
  82. echo "Puste pola w formularzu";
  83. echo '<a href="zad2.html">Powrót do formularza dodawania wpisu></a>';
  84. return;
  85. }
  86.  
  87. ?>
  88.  
  89. </body>
  90. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement