Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. <?php
  2. $username = $_POST['username'];
  3. $myDir = '';
  4.  
  5. function sendFile($fileToUpload, $number, $fileNamePartTmp){
  6. if(isset($_FILES[$fileToUpload])){
  7. $errors= array();
  8. $file_name = $_FILES[$fileToUpload]['name'];
  9. $file_tmp = $_FILES[$fileToUpload]['tmp_name'];
  10. $file_ext=strtolower(end(explode('.',$_FILES[$fileToUpload]['name'])));
  11.  
  12.  
  13. if(empty($errors)==true) {
  14. move_uploaded_file($file_tmp,"$fileNamePartTmp"."$number"."$file_ext");
  15. echo "Success";
  16. }else{
  17. print_r($errors);
  18. echo "przypal";
  19. }
  20. }
  21.  
  22. }
  23.  
  24.  
  25.  
  26.  
  27. foreach (glob($myDir."*" , GLOB_ONLYDIR) as $currentDir) {
  28. if (file_exists("$currentDir/info")){
  29. $currentFile = fopen("$currentDir/info", "r");
  30. $firstLine = fgets($currentFile);
  31. if(trim($firstLine) == trim($username)){
  32. echo "super\n";
  33. $password = md5($_POST['password']);
  34.  
  35. $secondLine = fgets($currentFile);
  36. if(trim($password) == trim($secondLine)){
  37. echo "haslo super tez\n";
  38. $date = str_replace("-","",$_POST['date']);
  39. $tmp = explode("-",$_POST['hour']);
  40. $date = $date.$tmp[0].$tmp[1].date('s');
  41. echo $date;
  42. $increment = "A00";
  43. while(file_exists("$currentDir/$date".substr($increment,1,2))){
  44. $increment++.PHP_EOL;
  45. }
  46. $newFile = fopen("$currentDir/$date".substr($increment,1,2), "w");
  47. echo "$currentDir/$date".substr($increment,1,2)."\n";
  48. fwrite($newFile, " fajne "."\n" );
  49. fclose($newFile);
  50.  
  51. $fileNamePart = "$currentDir/$date".substr($increment,1,2);
  52.  
  53.  
  54. echo $fileNamePart;
  55.  
  56.  
  57. sendFile( 'fileName1',"1",$fileNamePart);
  58. sendFile( 'fileName2',"2",$fileNamePart);
  59. sendFile( 'fileName3',"3",$fileNamePart);
  60.  
  61.  
  62.  
  63.  
  64.  
  65. /*if(isset($_FILES['file1'])){
  66. $errors= array();
  67. $file_name = $_FILES['file1']['name'];
  68. $file_tmp = $_FILES['file1']['tmp_name'];
  69. $file_ext=strtolower(end(explode('.',$_FILES['file1']['name'])));
  70.  
  71.  
  72. if(empty($errors)==true) {
  73. move_uploaded_file($file_tmp,"$fileNamePart"."$file_ext");
  74. echo "Success";
  75. }else{
  76. print_r($errors);
  77. }
  78. }*/
  79.  
  80. //sendFile("fileName1", "$currentDir/$date".substr($increment,1,2)."1");
  81.  
  82.  
  83.  
  84. /* TESTING INCREMENTATION
  85. $incrementTest = "A00";
  86. for($n = 0; $n < 7; $n++){
  87. echo "$currentDir/$date".substr($incrementTest++.PHP_EOL,1,2)."\n";
  88. }*/
  89.  
  90.  
  91.  
  92.  
  93.  
  94. } else {
  95. echo "$password\n";
  96. echo "$secondLine\n";
  97. echo $_POST['password'];
  98. echo "zle haslo!1!";
  99. }
  100.  
  101.  
  102. }
  103.  
  104. fclose($currentFile);
  105. }
  106. # code...
  107. }
  108.  
  109.  
  110.  
  111. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement