} $hash = hash_file("md5", $filename); $r = $conn->query("SELECT id FROM notes WHERE hash = '{$hash}' AND password=''")->num_rows; if ($r != 0) { echo json_encode(array("code" => 3, "file" => "{$r}")); die; } //Credits //MS Doc + slsx for catdoc // http://www.wagner.pp.ru/~vitus/software/catdoc/ // http://stackoverflow.com/questions/5671988/how-to-extract-just-plain-text-from-doc-docx-files-unix //PDF // https://gist.github.com/smalot/6183152 // pdftotext $str = ""; if ($file->getType() == "doc") { $str = exec("catdoc '" . escapeshellcmd($filename) . "'"); } if ($file->getType() == "docx") { $str = exec("unzip -p '" . escapeshellcmd($filename) . "' word/document.xml | sed -e 's/<\\/w:p>/\n/g; s/<[^>]\\{1,\\}>//g; s/[^[:print:]\n]\\{1,\\}//g'"); } if ($file->getType() == "pdf") { include "pdfparser.php"; $parser = new PdfParser(); $str = $parser->parseFile($filename); $im = new imagick($filename); $im->setImageFormat('jpg'); $imdata = base64_encode($im); } $textarr1 = preg_split("/\\s+/", $str); $textarr = [];
public function getFiletype() { return $this->file->getType(); }
/** * Returns the fileType of this file * * @return int $fileType */ public function getType() { return (int) $this->originalFile->getType(); }