Ejemplo n.º 1
0
 /**
  * Does a file support UnserializePHPPowerPoint ?
  *
  * @param  string    $pFilename
  * @throws \Exception
  * @return boolean
  */
 public function fileSupportsUnserializePHPPowerPoint($pFilename = '')
 {
     // Check if file exists
     if (!file_exists($pFilename)) {
         throw new \Exception("Could not open " . $pFilename . " for reading! File does not exist.");
     }
     // File exists, does it contain PHPPowerPoint.xml?
     return File::fileExists("zip://{$pFilename}#PHPPowerPoint.xml");
 }
Ejemplo n.º 2
0
 /**
  */
 public function testFileExists()
 {
     $pathResources = PHPPOWERPOINT_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR;
     $this->assertTrue(File::fileExists($pathResources . 'images' . DIRECTORY_SEPARATOR . 'PHPPowerPointLogo.png'));
     $this->assertFalse(File::fileExists($pathResources . 'images' . DIRECTORY_SEPARATOR . 'PHPPowerPointLogo_404.png'));
     $this->assertTrue(File::fileExists('zip://' . $pathResources . 'files' . DIRECTORY_SEPARATOR . 'Sample_01_Simple.pptx#[Content_Types].xml'));
     $this->assertFalse(File::fileExists('zip://' . $pathResources . 'files' . DIRECTORY_SEPARATOR . 'Sample_01_Simple.pptx#404.xml'));
     $this->assertFalse(File::fileExists('zip://' . $pathResources . 'files' . DIRECTORY_SEPARATOR . '404.pptx#404.xml'));
 }
Ejemplo n.º 3
0
 /**
  * Get image mime type
  *
  * @param  string    $pFile Filename
  * @return string    Mime Type
  * @throws \Exception
  */
 private function getImageMimeType($pFile = '')
 {
     if (File::fileExists($pFile)) {
         if (strpos($pFile, 'zip://') === 0) {
             $pZIPFile = str_replace('zip://', '', $pFile);
             $pZIPFile = substr($pZIPFile, 0, strpos($pZIPFile, '#'));
             $pImgFile = substr($pFile, strpos($pFile, '#') + 1);
             $oArchive = new \ZipArchive();
             $oArchive->open($pZIPFile);
             $image = getimagesizefromstring($oArchive->getFromName($pImgFile));
         } else {
             $image = getimagesize($pFile);
         }
         return image_type_to_mime_type($image[2]);
     } else {
         throw new \Exception("File {$pFile} does not exist");
     }
 }