83 $aFileInfo = $this->
getConfig()->getUploadedFile( $sFileIndex );
87 $sFileHash = $this->
_getFileHash( $aFileInfo[
'tmp_name'] );
91 if ( !$this->
_uploadFile( $aFileInfo[
'tmp_name'], $sUploadTo ) ) {
92 throw new oxException(
'EXCEPTION_COULDNOTWRITETOFILE' );
107 if ( !isset( $aFileInfo[
'name'] ) || !isset( $aFileInfo[
'tmp_name'] ) ) {
112 if ( isset( $aFileInfo[
'error'] ) && $aFileInfo[
'error'] ) {
113 throw new oxException(
'EXCEPTION_FILEUPLOADERROR_'.( (
int) $aFileInfo[
'error'] ) );
128 if ( $sConfigValue && $sConfigValue[0] == DIR_SEP) {
129 return $sConfigValue;
133 if ( $sConfigValue ) {
134 $sPath = getShopBasePath() . DIR_SEP . $sConfigValue;
139 $sPath = getShopBasePath() .
"/out/downloads/";
164 $this->_sRelativeFilePath =
'';
165 $sFileHash = $this->oxfiles__oxstorehash->value;
166 $sFileName = $this->oxfiles__oxfilename->value;
170 $sFileName = basename($sFileName);
175 $this->_sRelativeFilePath .= DIR_SEP . $sFileHash;
177 $this->_sRelativeFilePath = DIR_SEP . $this->_sManualUploadDir . DIR_SEP . $sFileName;
194 $sDir = substr($sFileHash, 0, 2);
197 if (!is_dir($sAbsDir)) {
198 mkdir($sAbsDir, 0755);
213 return md5_file( $sFileName );
227 $blDone = move_uploaded_file( $sSource, $sTarget );
230 $blDone = @chmod( $sTarget, 0644 );
247 if ($this->oxfiles__oxstorehash->value) {
260 public function delete( $sOxId = null )
262 $sOxId = $sOxId ? $sOxId : $this->
getId();
266 if ($blDeleted = parent::delete( $sOxId ) ) {
284 $sHash = $this->oxfiles__oxstorehash->value;
286 $iCount = $oDb->getOne(
287 'SELECT COUNT(*) FROM `oxfiles` WHERE `OXSTOREHASH` = ' . $oDb->quote( $sHash ),
false, false );
302 return rawurlencode($this->oxfiles__oxfilename->value);
314 if ( !$this->
exist() ) {
318 $oUtils->setHeader(
"Pragma: public");
319 $oUtils->setHeader(
"Expires: 0");
320 $oUtils->setHeader(
"Cache-Control: must-revalidate, post-check=0, pre-check=0, private");
321 $oUtils->setHeader(
'Content-Disposition: attachment;filename=' . $sFileName);
322 $oUtils->setHeader(
"Content-Type: application/octet-stream");
323 if ( $iFileSize = $this->
getSize() ) {
324 $oUtils->setHeader(
"Content-Length: " . $iFileSize);
326 readfile( $sFileLocations );
327 $oUtils->showMessageAndExit( null );
347 if ( $this->_blHasValidDownloads == null ) {
348 $this->_blHasValidDownloads =
false;
349 $sNow = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime() );
350 $sFileId = $this->
getId();
355 `oxorderfiles`.`oxid`
357 LEFT JOIN `oxorderarticles` ON `oxorderarticles`.`oxid` = `oxorderfiles`.`oxorderarticleid`
358 LEFT JOIN `oxorder` ON `oxorder`.`oxid` = `oxorderfiles`.`oxorderid`
359 WHERE `oxorderfiles`.`oxfileid` = " . $oDb->quote($sFileId) .
"
360 AND ( ! `oxorderfiles`.`oxmaxdownloadcount` OR `oxorderfiles`.`oxmaxdownloadcount` > `oxorderfiles`.`oxdownloadcount`)
361 AND ( `oxorderfiles`.`oxvaliduntil` = '0000-00-00 00:00:00' OR `oxorderfiles`.`oxvaliduntil` > '{$sNow}' )
362 AND `oxorder`.`oxstorno` = 0
363 AND `oxorderarticles`.`oxstorno` = 0";
365 if ( $oDb->getOne( $sSql ) ) {
366 $this->_blHasValidDownloads =
true;
379 $iMaxCount = $this->oxfiles__oxmaxdownloads->value;
381 if ( $iMaxCount < 0) {
382 $iMaxCount = $this->
getConfig()->getConfigParam(
"iMaxDownloadsCount" );
394 $iMaxCount = $this->oxfiles__oxmaxunregdownloads->value;
396 if ( $iMaxCount < 0) {
397 $iMaxCount = $this->
getConfig()->getConfigParam(
"iMaxDownloadsCountUnregistered" );
409 $iExpTime = $this->oxfiles__oxlinkexptime->value;
411 if ( $iExpTime < 0) {
412 $iExpTime = $this->
getConfig()->getConfigParam(
"iLinkExpirationTime" );
424 $iExpTime = $this->oxfiles__oxdownloadexptime->value;
426 if ( $iExpTime < 0) {
427 $iExpTime = $this->
getConfig()->getConfigParam(
"iDownloadExpirationTime" );
440 if ( $this->
exist() ) {