Advertisement
Guest User

Untitled

a guest
Dec 28th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 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($available) == 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. <?php
  44. echo '<input type="hidden" name="postvals" value="'.$collection.'" />';
  45. ?>
  46. </form>
  47. <?php
  48. $collection = unserialize($_POST['postvals']);
  49. }
  50. $path = 'Blogi/'.$_POST['blog'];
  51. $date = $collection['date'];
  52. echo $date;
  53. $time = $collection['time'];
  54. $filename = $date[2].$date[1].$date[0].$time[0].$time[1].date("s");
  55. while(file_exists($path.'/'.$filename.$uidstring)){
  56. $postsWithSameTime++;
  57. if($uid<10) $uidstring = '0'.$postsWithSameTime;
  58. else $uidstring = $postsWithSameTime;
  59. }
  60. $filename = $path.'/'.$filename.$uidstring;
  61. echo $fileName;
  62. $file = fopen($filename, "w");
  63. fwrite($info, $collection['userText']);
  64. fclose();
  65. }
  66. else{
  67. echo "Puste pola w formularzu";
  68. echo '<a href="zad2.html">Powrót do formularza dodawania wpisu></a>';
  69. return;
  70. }
  71.  
  72. ?>
  73.  
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement