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/";
167 if ($storageLocation ===
false) {
173 return strpos($storageLocation, $downloadFolder) !==
false;
183 $this->_sRelativeFilePath =
'';
184 $sFileHash = $this->oxfiles__oxstorehash->value;
185 $sFileName = $this->oxfiles__oxfilename->value;
189 $sFileName = basename($sFileName);
194 $this->_sRelativeFilePath .= DIR_SEP . $sFileHash;
196 $this->_sRelativeFilePath = DIR_SEP . $this->_sManualUploadDir . DIR_SEP . $sFileName;
213 $sDir = substr($sFileHash, 0, 2);
216 if (!is_dir($sAbsDir)) {
217 mkdir($sAbsDir, 0755);
232 return md5_file( $sFileName );
246 $blDone = move_uploaded_file( $sSource, $sTarget );
249 $blDone = @chmod( $sTarget, 0644 );
266 if ($this->oxfiles__oxstorehash->value) {
279 public function delete( $sOxId = null )
281 $sOxId = $sOxId ? $sOxId : $this->
getId();
285 if ($blDeleted = parent::delete( $sOxId ) ) {
303 $sHash = $this->oxfiles__oxstorehash->value;
305 $iCount = $oDb->getOne(
306 'SELECT COUNT(*) FROM `oxfiles` WHERE `OXSTOREHASH` = ' . $oDb->quote( $sHash ),
false, false );
321 return rawurlencode($this->oxfiles__oxfilename->value);
337 $oUtils->setHeader(
"Pragma: public");
338 $oUtils->setHeader(
"Expires: 0");
339 $oUtils->setHeader(
"Cache-Control: must-revalidate, post-check=0, pre-check=0, private");
340 $oUtils->setHeader(
'Content-Disposition: attachment;filename=' . $sFileName);
341 $oUtils->setHeader(
"Content-Type: application/octet-stream");
342 if ( $iFileSize = $this->
getSize() ) {
343 $oUtils->setHeader(
"Content-Length: " . $iFileSize);
345 readfile( $sFileLocations );
346 $oUtils->showMessageAndExit( null );
366 if ( $this->_blHasValidDownloads == null ) {
367 $this->_blHasValidDownloads =
false;
368 $sNow = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime() );
369 $sFileId = $this->
getId();
374 `oxorderfiles`.`oxid`
376 LEFT JOIN `oxorderarticles` ON `oxorderarticles`.`oxid` = `oxorderfiles`.`oxorderarticleid`
377 LEFT JOIN `oxorder` ON `oxorder`.`oxid` = `oxorderfiles`.`oxorderid`
378 WHERE `oxorderfiles`.`oxfileid` = " . $oDb->quote($sFileId) .
"
379 AND ( ! `oxorderfiles`.`oxmaxdownloadcount` OR `oxorderfiles`.`oxmaxdownloadcount` > `oxorderfiles`.`oxdownloadcount`)
380 AND ( `oxorderfiles`.`oxvaliduntil` = '0000-00-00 00:00:00' OR `oxorderfiles`.`oxvaliduntil` > '{$sNow}' )
381 AND `oxorder`.`oxstorno` = 0
382 AND `oxorderarticles`.`oxstorno` = 0";
384 if ( $oDb->getOne( $sSql ) ) {
385 $this->_blHasValidDownloads =
true;
398 $iMaxCount = $this->oxfiles__oxmaxdownloads->value;
400 if ( $iMaxCount < 0) {
401 $iMaxCount = $this->
getConfig()->getConfigParam(
"iMaxDownloadsCount" );
413 $iMaxCount = $this->oxfiles__oxmaxunregdownloads->value;
415 if ( $iMaxCount < 0) {
416 $iMaxCount = $this->
getConfig()->getConfigParam(
"iMaxDownloadsCountUnregistered" );
428 $iExpTime = $this->oxfiles__oxlinkexptime->value;
430 if ( $iExpTime < 0) {
431 $iExpTime = $this->
getConfig()->getConfigParam(
"iLinkExpirationTime" );
443 $iExpTime = $this->oxfiles__oxdownloadexptime->value;
445 if ( $iExpTime < 0) {
446 $iExpTime = $this->
getConfig()->getConfigParam(
"iDownloadExpirationTime" );
459 if ( $this->
exist() ) {