PageRenderTime 51ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/Symfony/web/uploads/documents/FlexPaper/php/services/numpages.php

https://bitbucket.org/joseph_b/mti-php-zinreader
PHP | 54 lines | 27 code | 6 blank | 21 comment | 6 complexity | edeee3ea8b1e7400f6d366f3d96dd0b2 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, BSD-3-Clause, BSD-2-Clause, Apache-2.0
  1. <?php
  2. /**
  3. * █▒▓▒░ The FlexPaper Project
  4. *
  5. * Copyright (c) 2009 - 2011 Devaldi Ltd
  6. *
  7. * Document page counter file for PHP. Accepts parameters 'doc'
  8. * Executes specified conversion command if the document has not yet been
  9. * converted and returns the number of pages in the converted document
  10. *
  11. * GNU GENERAL PUBLIC LICENSE Version 3 (GPL).
  12. *
  13. * The GPL requires that you not remove the FlexPaper copyright notices
  14. * from the user interface.
  15. *
  16. * Commercial licenses are available. The commercial player version
  17. * does not require any FlexPaper notices or texts and also provides
  18. * some additional features.
  19. * When purchasing a commercial license, its terms substitute this license.
  20. * Please see http://flexpaper.devaldi.com/ for further details.
  21. *
  22. */
  23. require_once("../lib/config.php");
  24. require_once("../lib/common.php");
  25. require_once("../lib/pdf2swf_php5.php");
  26. $configManager = new Config();
  27. $doc=$_GET["doc"];
  28. $page = "1";
  29. $swfFilePath = $configManager->getConfig('path.swf') . $doc . $page. ".swf";
  30. $pdfFilePath = $configManager->getConfig('path.pdf') . $doc;
  31. $output = "";
  32. if(glob($configManager->getConfig('path.swf') . $doc . "*")!=false)
  33. $pagecount = count(glob($configManager->getConfig('path.swf') . $doc . "*"));
  34. else
  35. $pagecount = 0;
  36. if($pagecount == 0 && validPdfParams($pdfFilePath,$doc,$page)){
  37. $pdfconv=new pdf2swf();
  38. $output=$pdfconv->convert($doc,$page);
  39. if(rtrim($output) === "[Converted]")
  40. $pagecount = count(glob($configManager->getConfig('path.swf') . $doc . "*"));
  41. }else{
  42. $output = "Incorrect document file specified, file may not exist or insufficient permissions to read file" . $configManager->getDocUrl();
  43. }
  44. if($pagecount!=0)
  45. echo $pagecount;
  46. else
  47. echo $output;
  48. ?>