private function _saveHeaders() { if (!$this->saved_headers) { $tempInFile = new \GO\Base\Fs\File(\GO::config()->tmpdir . "smime_tempin.txt"); $tempInFile->parent()->create(); $tempInFile->delete(); $tempOutFile = new \GO\Base\Fs\File(\GO::config()->tmpdir . "smime_tempout.txt"); $tempOutFile->delete(); $this->tempin = $tempInFile->path(); $this->tempout = $tempOutFile->path(); /* * Store the headers of the current message because the PHP function * openssl_pkcs7_sign will rebuilt the MIME structure and will put the main * headers in a nested mimepart. We don't want that so we remove them now * and add them to the new structure later. */ $headers = $this->getHeaders(); $headers->removeAll('MIME-Version'); // $headers->removeAll('Content-Type'); $this->saved_headers = array(); //$headers->toString(); $ignored_headers = array('Content-Transfer-Encoding', 'Content-Type'); $h = $headers->getAll(); foreach ($h as $header) { $name = $header->getFieldName(); if (!in_array($name, $ignored_headers)) { $this->saved_headers[$name] = $header->getFieldBody(); $headers->removeAll($name); } } /* * This class will stream the MIME structure to the tempin text file in * a memory efficient way. */ $fbs = new \Swift_ByteStream_FileByteStream($this->tempin, true); parent::toByteStream($fbs); if (!file_exists($this->tempin)) { throw new \Exception('Could not write temporary message for signing'); } } }
protected function afterSave($wasNew) { if ($wasNew && $this->group) { $stmt = $this->group->admins; foreach ($stmt as $user) { if ($user->user_id != $this->user_id) { //the owner has already been added automatically with manage permission $this->acl->addUser($user->user_id, \GO\Base\Model\Acl::DELETE_PERMISSION); } } } $file = new \GO\Base\Fs\File($this->getPublicIcsPath()); if (!$this->public) { if ($file->exists()) { $file->delete(); } } else { if (!$file->exists()) { $file->touch(true); } $file->putContents($this->toVObject()); } return parent::afterSave($wasNew); }
protected function actionHandleUploads($params) { if (!isset(\GO::session()->values['files']['uploadqueue'])) { \GO::session()->values['files']['uploadqueue'] = array(); } try { $chunkTmpFolder = new \GO\Base\Fs\Folder(\GO::config()->tmpdir . 'juploadqueue/chunks'); $tmpFolder = new \GO\Base\Fs\Folder(\GO::config()->tmpdir . 'juploadqueue'); $tmpFolder->create(); $chunkTmpFolder->create(); $count = 0; while ($uploadedFile = array_shift($_FILES)) { if (isset($params['jupart'])) { $originalFileName = $uploadedFile['name']; $uploadedFile['name'] = $uploadedFile['name'] . '.part' . $params['jupart']; $chunkTmpFolder->create(); \GO\Base\Fs\File::moveUploadedFiles($uploadedFile, $chunkTmpFolder); if (!empty($params['jufinal'])) { $file = new \GO\Base\Fs\File($tmpFolder . '/' . $originalFileName); $fp = fopen($file->path(), 'w+'); for ($i = 1; $i <= $params['jupart']; $i++) { $part = new \GO\Base\Fs\File($chunkTmpFolder . '/' . $originalFileName . '.part' . $i); fwrite($fp, $part->contents()); $part->delete(); } fclose($fp); $chunkTmpFolder->delete(); } else { echo "SUCCESS\n"; return; } } else { $files = \GO\Base\Fs\File::moveUploadedFiles($uploadedFile, $tmpFolder); if (!$files) { throw new \Exception("No file received"); } $file = $files[0]; } $subdir = false; if (!empty($params['relpathinfo' . $count]) && !isset($params['jupart']) || !empty($params['relpathinfo' . $count]) && isset($params['jupart']) && !empty($params['jufinal'])) { $fullpath = \GO::config()->tmpdir . 'juploadqueue' . '/' . str_replace('\\', '/', $params['relpathinfo' . $count]); $dir = new \GO\Base\Fs\Folder($fullpath); $dir->create(); $subdir = true; $file->move($dir); } $count++; if ($subdir) { $parent = $this->_findHighestParent($dir); \GO::debug($parent); if (!in_array($parent->path(), \GO::session()->values['files']['uploadqueue'])) { \GO::session()->values['files']['uploadqueue'][] = $parent->path(); } } else { \GO::session()->values['files']['uploadqueue'][] = $file->path(); } } } catch (\Exception $e) { echo 'WARNING: ' . $e->getMessage() . "\n"; } echo "SUCCESS\n"; }