Guest User

Untitled

a guest
Feb 27th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1. <html>
  2. <head>
  3. <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
  4. <link type="text/css" rel="stylesheet" href="style.css" media="screen" />
  5. </head>
  6. <body>
  7.  
  8. <?php
  9. define("UPLOAD_PATH","/var/www/html/konwertuj_pdf/f/");
  10. ini_set('upload_max_filesize', '999999999');
  11.  
  12.  
  13. if(is_uploaded_file($_FILES['ffilen']['tmp_name'])){
  14.         $fileinfo = pathinfo($_FILES[ffilen][name]);
  15.     if ($fileinfo['extension']!="exe" && $fileinfo['extension']!="php"){
  16.         $path = UPLOAD_PATH.$_FILES[ffilen][name];
  17.         if(!move_uploaded_file($_FILES['ffilen']['tmp_name'],$path)){
  18.           echo '<p class="error">problem: Nie udało się skopiować pliku</p>';
  19.         }
  20.         else{
  21.                  shell_exec ("chmod 777 -R '".UPLOAD_PATH."'");
  22.                  //podliczenie stron pdf
  23.          $c = "pdfinfo '".UPLOAD_PATH.$_FILES[ffilen][name]."' | grep Pages | sed 's/[^0-9]*//'";
  24.          $pgs = shell_exec ($c);
  25.                  //konwertowanie stron pdf do jpg
  26.          $c = "gs -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=".$pgs." -sOutputFile=".UPLOAD_PATH."output%d.jpg -dJPEGQ=90 -r500 -q '".UPLOAD_PATH.$_FILES[ffilen][name]."' -c quit";
  27.                  echo $c;
  28.          shell_exec ($c);
  29.                  //usuwanie pdf
  30.                  $c = "rm '".UPLOAD_PATH.$_FILES[ffilen][name]."'";
  31.          shell_exec ($c);
  32.          //spakowanie do zipa wszystkich zdjec
  33.          $c = " zip -r ".UPLOAD_PATH."out.zip /var/www/html/konwertuj_pdf/f/*.*";
  34.          shell_exec ($c);
  35.                  //usuwanie zdjec
  36.                  $c = "rm ".UPLOAD_PATH."*.jpg";
  37.          shell_exec ($c);              
  38.  
  39.          echo '<p class="success">Plik zawiera '.$pgs.' stron. <a href="http://192.168.0.110/konwertuj_pdf/f/out.zip">Kliknij by pobrac.</a></p>';
  40.         }
  41.     }
  42.     else{
  43.         echo '<p class="error">problem: Niedozwolony format pliku</p>';
  44.         }
  45. }
  46.  
  47. ?>
  48.  
  49.  
  50. <form enctype="multipart/form-data" action="index.php"  method="post" class="box">
  51.  
  52. <h1>Prześlij plik PDF</h1>
  53. <p>
  54. <label>
  55.     <span>Plik</span>
  56.     <input type="file" name="ffilen" />
  57. </label>
  58. </p>
  59.  
  60. <p><input type="submit" value="Wyślij" class="button"/></p>
  61.  
  62. </form>
  63.  
  64. </body>
  65. </html>
Advertisement
Add Comment
Please, Sign In to add comment