function __ooFiles_loadSubFiles($subFilesDir) { $subClassesFiles = scandir($subFilesDir); foreach ($subClassesFiles as $currentSubClassFile) { if (is_file($subFilesDir . '/' . $currentSubClassFile)) { require_once $subFilesDir . '/' . $currentSubClassFile; $subClassFilename = AdvancedPathLib::pathinfo($currentSubClassFile, PATHINFO_FILENAME); if (is_dir($subFilesDir . '/' . $subClassFilename)) { __ooFiles_loadSubFiles($subFilesDir . '/' . $subClassFilename); } } } }
public static function submitFile($path) { try { if (!isset($_FILES['Filedata'])) { echo '<div style="font-size:20px;font-family:Helvetica, Arial, Verdana, Sans, FreeSans;margin-top:80px;margin-right:15px;"><center> <img style="position:relative;top:15px"src="index.php?extern=/images/48x48/actions/dialog-close.png" />Error uploading files</center>'; exit; } $Logger = Logger::getLogger('application.upload'); foreach ($_FILES['Filedata']['name'] as $k => $v) { if (!empty($v)) { $filename = $_FILES['Filedata']['name'][$k]; if (!isset($_POST['UPLOAD_IDENTIFIER'])) { $filename = utf8_encode($filename); } $tmpPath = $_FILES['Filedata']['tmp_name'][$k]; $Logger->debug("Filename: " . $filename); if (!is_uploaded_file($tmpPath)) { throw new EyeFileNotFoundException('Uploaded file not found at "' . $tmpPath . '".'); } $request = MMapManager::getCurrentRequest(); $destPath = $path; $filename = str_replace('?', '_', $filename); $filename = str_replace('#', '_', $filename); $tmp = pathinfo($filename); if (isset($tmp['extension']) && "lnk" == $tmp['extension']) { throw new EyeFileNotFoundException('This file cannot be uploaded (file type banned)'); } /* if ( '?' == $filename{0} ) { $filename{0} = "_"; } */ $destFile = FSI::getFile($destPath . '/' . $filename); //The uploaded file is necessarily on the local filesystem and we want to avoid any //permission check through EyeLocalFile, so we use LocalFile directly $tmpFile = new LocalFile($tmpPath); $num = 1; $extension = AdvancedPathLib::pathinfo($filename, PATHINFO_EXTENSION); $filename = AdvancedPathLib::pathinfo($filename, PATHINFO_FILENAME); $Logger->debug("CLASS: " . get_class($destFile)); $Logger->debug("Exists: " . $destFile->exists()); //exit(); while ($destFile->exists()) { $newBasename = $filename . ' (' . $num++ . ')' . ($extension ? '.' . $extension : ''); $destFile = FSI::getFile($destPath . '/' . $newBasename); } $destFile->checkWritePermission(); $tmpFile->moveTo($destFile); $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser(); $settings = MetaManager::getInstance()->retrieveMeta($currentUser); $message = new ClientBusMessage('file', 'uploadComplete', self::getFileInfo($destFile, $settings)); ClientMessageBusController::getInstance()->queueMessage($message); $event = new FileEvent($destFile); $destFile->fireEvent('fileWritten', $event); } } register_shutdown_function('endRequestUpload'); } catch (EyeException $e) { echo '<div style="font-size:20px;font-family:Helvetica, Arial, Verdana, Sans, FreeSans;margin-top:80px;margin-right:15px;"><center> <img style="position:relative;top:15px"src="index.php?extern=/images/48x48/actions/dialog-close.png" />Error uploading files: ' . $e->getMessage() . '</center>'; exit; } }
public function testPathinfo() { $path = '/unix/like/path/file.ext'; $this->assertEquals(array('dirname' => '/unix/like/path', 'basename' => 'file.ext', 'extension' => 'ext', 'filename' => 'file'), AdvancedPathLib::pathinfo($path)); $path = '/unix/like/path/file.ext'; $this->assertEquals('file.ext', AdvancedPathLib::pathinfo($path, PATHINFO_BASENAME)); $path = '/unix/like/path/file.ext'; $this->assertEquals('file', AdvancedPathLib::pathinfo($path, PATHINFO_FILENAME)); $path = '/unix/like/path/file'; $this->assertEquals('file', AdvancedPathLib::pathinfo($path, PATHINFO_FILENAME)); }