public function __construct($path, $siteId = null) { parent::__construct($path, $siteId); }
protected function assertOutputZipfileOK($files, $options) { if (0 < sizeof($files)) { // php5.3 does not combine empty arrays $files = array_combine(array_map(function ($element) { return $element->filename; }, $files), $files); } $output = $this->getOutput(); $eocdrec = EndOfCentralDirectoryRecord::constructFromString($output); $this->assertEquals(strlen($output) - 1, $eocdrec->end, "EOCDR last item in file"); if ($options['zip64']) { $eocdrec->assertValues(array("numberDisk" => 0xffff, "numberDiskStartCD" => 0xffff, "numberEntriesDisk" => 0xffff, "numberEntriesCD" => 0xffff, "size" => 0xffffffff, "offsetStart" => 0xffffffff, "lengthComment" => 0, "comment" => '')); $z64eocdloc = Zip64EndOfCentralDirectoryLocator::constructFromString($output, strlen($output) - ($eocdrec->begin + 1)); $this->assertEquals($z64eocdloc->end + 1, $eocdrec->begin, "Z64EOCDL directly before EOCDR"); $z64eocdloc->assertValues(array("numberDiskStartZ64EOCDL" => 0, "numberDisks" => 1)); $z64eocdrec = Zip64EndOfCentralDirectoryRecord::constructFromString($output, strlen($output) - ($z64eocdloc->begin + 1)); $this->assertEquals(Count64::construct($z64eocdrec->begin), $z64eocdloc->offsetStart, "Z64EOCDR begin"); $this->assertEquals($z64eocdrec->end + 1, $z64eocdloc->begin, "Z64EOCDR directly before Z64EOCDL"); $z64eocdrec->assertValues(array("size" => Count64::construct(44), "madeByVersion" => pack16le(self::ATTR_MADE_BY_VERSION), "versionToExtract" => pack16le($this->getVersionToExtract($options['zip64'], False)), "numberDisk" => 0, "numberDiskStartCDR" => 0, "numberEntriesDisk" => Count64::construct(sizeof($files)), "numberEntriesCD" => Count64::construct(sizeof($files)))); $sizeCD = $z64eocdrec->sizeCD->getLoBytes(); $offsetCD = $z64eocdrec->offsetStart->getLoBytes(); $beginFollowingRecord = $z64eocdrec->begin; } else { $eocdrec->assertValues(array("numberDisk" => 0, "numberDiskStartCD" => 0, "numberEntriesDisk" => sizeof($files), "numberEntriesCD" => sizeof($files), "lengthComment" => 0, "comment" => '')); $sizeCD = $eocdrec->size; $offsetCD = $eocdrec->offsetStart; $beginFollowingRecord = $eocdrec->begin; } $cdheaders = array(); $pos = $offsetCD; $cdhead = null; while ($pos < $beginFollowingRecord) { $cdhead = CentralDirectoryHeader::constructFromString($output, $pos); $filename = $cdhead->filename; $pos = $cdhead->end + 1; $cdheaders[$filename] = $cdhead; $this->assertArrayHasKey($filename, $files, "CDH entry has valid name"); $cdhead->assertValues(array("madeByVersion" => pack16le(self::ATTR_MADE_BY_VERSION), "versionToExtract" => pack16le($this->getVersionToExtract($options['zip64'], File::DIR == $files[$filename]->type)), "gpFlags" => File::FILE == $files[$filename]->type ? pack16le(GPFLAGS::ADD) : pack16le(GPFLAGS::NONE), "gzMethod" => File::FILE == $files[$filename]->type ? pack16le($options['compress']) : pack16le(COMPR::STORE), "dosTime" => pack32le(ZipStreamer::getDosTime($files[$filename]->date)), "lengthFilename" => strlen($filename), "lengthComment" => 0, "fileAttrInternal" => pack16le(0x0), "fileAttrExternal" => File::FILE == $files[$filename]->type ? pack32le(self::EXT_FILE_ATTR_FILE) : pack32le(self::EXT_FILE_ATTR_DIR))); if ($options['zip64']) { $cdhead->assertValues(array("sizeCompressed" => 0xffffffff, "size" => 0xffffffff, "lengthExtraField" => 32, "diskNumberStart" => 0xffff, "offsetStart" => 0xffffffff)); $cdhead->z64Ext->assertValues(array("sizeField" => 28, "size" => Count64::construct($files[$filename]->getSize()), "diskNumberStart" => 0)); } else { $cdhead->assertValues(array("size" => $files[$filename]->getSize(), "lengthExtraField" => 0, "diskNumberStart" => 0)); } } if (0 < sizeof($files)) { $this->assertEquals($cdhead->end + 1, $beginFollowingRecord, "CDH directly before following record"); $this->assertEquals(sizeof($files), sizeof($cdheaders), "CDH has correct number of entries"); $this->assertEquals($sizeCD, $beginFollowingRecord - $offsetCD, "CDH has correct size"); } else { $this->assertNull($cdhead); } $first = True; foreach ($cdheaders as $filename => $cdhead) { if ($options['zip64']) { $sizeCompressed = $cdhead->z64Ext->sizeCompressed->getLoBytes(); $offsetStart = $cdhead->z64Ext->offsetStart->getLoBytes(); } else { $sizeCompressed = $cdhead->sizeCompressed; $offsetStart = $cdhead->offsetStart; } if ($first) { $this->assertEquals(0, $offsetStart, "first file directly at beginning of zipfile"); } else { $this->assertEquals($endLastFile + 1, $offsetStart, "file immediately after last file"); } $file = FileEntry::constructFromString($output, $offsetStart, $sizeCompressed); $this->assertEquals($files[$filename]->data, $file->data); $this->assertEquals(crc32($files[$filename]->data), $cdhead->dataCRC32); if (GPFLAGS::ADD & $file->lfh->gpFlags) { $this->assertNotNull($file->dd, "data descriptor present (flag ADD set)"); } if ($options['zip64']) { $file->lfh->assertValues(array("sizeCompressed" => 0xffffffff, "size" => 0xffffffff)); $file->lfh->z64Ext->assertValues(array("sizeField" => 28, "size" => Count64::construct(0), "sizeCompressed" => Count64::construct(0), "diskNumberStart" => 0)); } else { $file->lfh->assertValues(array("sizeCompressed" => 0, "size" => 0)); } $file->lfh->assertValues(array("versionToExtract" => pack16le($this->getVersionToExtract($options['zip64'], File::DIR == $files[$filename]->type)), "gpFlags" => File::FILE == $files[$filename]->type ? GPFLAGS::ADD : GPFLAGS::NONE, "gzMethod" => File::FILE == $files[$filename]->type ? $options['compress'] : COMPR::STORE, "dosTime" => pack32le(ZipStreamer::getDosTime($files[$filename]->date)), "dataCRC32" => 0x0, "lengthFilename" => strlen($filename), "filename" => $filename)); $endLastFile = $file->end; $first = False; } if (0 < sizeof($files)) { $this->assertEquals($offsetCD, $endLastFile + 1, "last file directly before CDH"); } else { $this->assertEquals(0, $beginFollowingRecord, "empty zip file, CD records at beginning of file"); } }
/** * Serialize a single file. * * @param FileEntry $file The file to serialize. * * @return StreamWriter */ private function serializeFile(FileEntry $file) { $result = new StreamWriter('php://temp'); $fileName = $file->getFilename(); $metaData = $file->getMetadata(); if (!empty($metaData)) { $metaData = serialize($metaData); } $result->writeUint32le(strlen($fileName))->write($fileName)->writeUint32le($file->getSizeUncompressed())->writeUint32le($file->getTime()->getTimestamp())->writeUint32le($file->getSizeCompressed())->writeUint32le($file->getCrc())->writeUint32le($file->getFlags())->writeUint32le(strlen($metaData))->write($metaData)->seek(0); $this->bins->write($file->getCompressedContent()); return $result; }
</script> <div class="row page_title_icon_container"> <h2>Outlines By Student</h2> </div> <!-- Last Names --> <div class="row"> <?php //Alphabet $array_alphabet = array_merge(range('A', 'Z')); foreach ($array_alphabet as $item) { #$query = DB::table('file_entries')->where('submitting_user_last_name', 'like', ''.$item.'%')->get(); $query = FileEntry::where('submitting_user_last_name', 'like', '' . $item . '%')->where('submitting_user_reveal_id', '=', 'yes')->get(); $array_alphabet_2 = []; echo '<div class="browse_by_student_row">'; echo '<div class="col-md-4">'; echo '<h1 class="last_name_initial">' . $item . '</h1>'; echo '</div>'; foreach ($query as $letter[$item]) { #print_r($letter['B']); echo '<div class="col-md-8 last_names">'; $array_alphabet_2[] = $query; echo '<div class="row">'; foreach ($array_alphabet_2 as $item2) { foreach ($item2 as $item3) { echo '<p class="lead"><a data-toggle="modal" data-target="#ModalStudentOutlines' . $item3->submitting_user_id . '">' . $item3->submitting_user_last_name . ', ' . $item3->submitting_user_first_name . '</a> (Class of ' . $item3->submitting_user_projected_graduation_year . ')</p>'; break; }
/** * Read a file entry from the file. * * @param int $fileBinaryOffset The offset in the file to start reading from. * * @return FileEntry * * @throws \RuntimeException When the file name length in the dictionary is zero (corrupted dictionary). */ private function readFile($fileBinaryOffset) { $filenameLength = $this->file->readUint32le(); if (0 === $filenameLength) { throw new \RuntimeException('Unnamed file found.'); } $filename = $this->file->read($filenameLength); $fileSizeUncompressed = $this->file->readUint32le(); $timestamp = new \DateTime('@' . $this->file->readUint32le()); $fileSizeCompressed = $this->file->readUint32le(); $crc = $this->file->readUint32le(); $flags = $this->file->readUint32le(); if (0 < ($fileMetadataLength = $this->file->readUint32le())) { $metadata = unserialize($this->file->read($fileMetadataLength)); } $this->file->savePosition(); $this->file->seek($fileBinaryOffset); $content = $this->file->read($fileSizeCompressed); $this->file->loadPosition(); $file = FileEntry::createFromPhar($filename, $fileSizeUncompressed, $fileSizeCompressed, $timestamp, $crc, $flags, isset($metadata) ? $metadata : null, $content); // Ensure the crc is correct and the data can be decompressed. $file->getContent(); $this->phar->addFile($file); return $file; }
public function __construct($path) { parent::__construct($path); }