\n Filetype = ".$filetype."
\n"; if ($filetype == "sxw") { $zip = zip_open($filename); if ($zip) { while ($zip_entry = zip_read($zip)) { if (zip_entry_open($zip, $zip_entry, "r")) { if (zip_entry_name($zip_entry) == "mimetype") { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); echo "Mime-type = " . $buf . "
\n"; } if (zip_entry_name($zip_entry) == "meta.xml") { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); $xmlParser = xml_parser_create(); xml_parse_into_struct($xmlParser, $buf, $vals, $index); xml_parser_free($xmlParser); foreach($vals as $value) { if ($value["tag"] == "DC:TITLE") echo "Title = ".$value["value"]. "
\n"; if ($value["tag"] == "DC:DESCRIPTION") echo "Description = ".$value["value"]. "
\n"; if ($value["tag"] == "DC:SUBJECT") echo "Subject = ".$value["value"]. "
\n"; if ($value["tag"] == "DC:DATE") echo "Date = ".str_replace("T", " ", $value["value"]). "
\n"; if ($value["tag"] == "META:INITIAL-CREATOR") echo "Initial Creator = ".$value["value"]. "
\n"; if ($value["tag"] == "DC:CREATION-DATE") echo "Creation Date = ".$value["value"]. "
\n"; if ($value["tag"] == "DC:CREATOR") echo "Creator = ".$value["value"]. "
\n"; if ($value["tag"] == "META:DOCUMENT-STATISTIC") echo "Pages = ".$value["attributes"]["META:PAGE-COUNT"]. "
\n"; } } zip_entry_close($zip_entry); } } zip_close($zip); } } elseif ($filetype == "pdf") { $filename = str_replace("\\", "\\\\", $filename); if (@file_exists($filename)) { $file = fopen($filename, "r"); # read file $regexAuthor = "/\/Author \((.*?)\)/"; $regexTitle = "/\/Title \((.*?)\)/"; $regexSubject = "/\/Subject \((.*?)\)/"; $regexKeywords = "/\/Keywords \((.*?)\)/"; $regexCreationDate = "/\/CreationDate \((.*?)\)/"; $regexModDate = "/\/ModDate \((.*?)\)/"; $regexPages = "/\/N (.*?) /"; $pagesFound = FALSE; while (!feof($file)) { $line = fgets($file); if (!feof($file)) { if (preg_match($regexAuthor, $line, $m)) echo "Author = ".$m[1]."
"; if (preg_match($regexTitle, $line, $m)) echo "Title = ".$m[1]."
"; if (preg_match($regexSubject, $line, $m)) echo "Subject = ".$m[1]."
"; if (preg_match($regexKeywords, $line, $m)) echo "Keywords = ".$m[1]."
"; if (preg_match($regexCreationDate, $line, $m)) echo "Creation Date = ".makeDate($m[1])."
"; if (preg_match($regexModDate, $line, $m)) echo "Modification Date = ".makeDate($m[1])."
"; if (preg_match($regexPages, $line, $m) && !$pagesFound) { $numberPages = trim($m[1]); if ($numberPages > 0) { echo "Number of Pages = ".$m[1]."
"; $pagesFound = TRUE; } } } } fclose($file); } else { echo "file ".$filename." does not exist!
"; } } else { // XLS, DOC, PPT $officetype = TRUE; // starting office switch ($filetype) { case "ppt": $office = new COM("powerpoint.application"); $office->Presentations->Open($filename, True,True,False); $document = $office->Presentations[1]; break; case "doc": $office = new COM("word.application"); $office->Documents->Open($filename); $document = $office->Documents[1]; break; case "xls": $office = new COM("excel.application"); $office->Workbooks->Open($filename); $document = $office->Workbooks[1]; break; default: echo "This filetype can't be handled by this script!"; $officetype = FALSE; } if ($officetype == TRUE) { echo "Display a single Buildin Property
\n"; echo "Author = ".$document->BuiltInDocumentProperties->Item("Author")->Value."
\n"; echo "Buildin properties
\n"; foreach ($document->BuiltInDocumentProperties as $myVar) { try { echo $myVar->Name." = ".$myVar->Value."
\n"; } catch (Exception $e) { // Do nothing ignore property we can't read } } echo "Custom properties
\n"; foreach ($document->CustomDocumentProperties as $myVar) { try { echo $myVar->Name." = ".$myVar->Value."
\n"; } catch (Exception $e) { // Do nothing ignore property we can't read } } // closing $office->Quit(); // free the object $office = null; unset($office); } } } else { echo 'Usage: '.$_SERVER['PHP_SELF'].'?filename=filename.ext'; } ?>