82 $aFileInfo = $this->
getConfig()->getUploadedFile($sFileIndex);
86 $sFileHash = $this->
_getFileHash($aFileInfo[
'tmp_name']);
90 if (!$this->
_uploadFile($aFileInfo[
'tmp_name'], $sUploadTo)) {
91 throw new oxException(
'EXCEPTION_COULDNOTWRITETOFILE');
104 if (!isset($aFileInfo[
'name']) || !isset($aFileInfo[
'tmp_name'])) {
109 if (isset($aFileInfo[
'error']) && $aFileInfo[
'error']) {
110 throw new oxException(
'EXCEPTION_FILEUPLOADERROR_' . ((
int) $aFileInfo[
'error']));
125 if ($sConfigValue && $sConfigValue[0] == DIR_SEP) {
126 return $sConfigValue;
131 $sPath = getShopBasePath() . DIR_SEP . $sConfigValue;
137 $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);
214 return md5_file($sFileName);
228 $blDone = move_uploaded_file($sSource, $sTarget);
231 $blDone = @chmod($sTarget, 0644);
248 if ($this->oxfiles__oxstorehash->value) {
262 public function delete($sOxId = null)
264 $sOxId = $sOxId ? $sOxId : $this->
getId();
268 if ($blDeleted = parent::delete($sOxId)) {
286 $sHash = $this->oxfiles__oxstorehash->value;
288 $iCount = $oDb->getOne(
289 'SELECT COUNT(*) FROM `oxfiles` WHERE `OXSTOREHASH` = ' . $oDb->quote($sHash),
false, false
305 return rawurlencode($this->oxfiles__oxfilename->value);
317 if (!$this->
exist()) {
321 $oUtils->setHeader(
"Pragma: public");
322 $oUtils->setHeader(
"Expires: 0");
323 $oUtils->setHeader(
"Cache-Control: must-revalidate, post-check=0, pre-check=0, private");
324 $oUtils->setHeader(
'Content-Disposition: attachment;filename=' . $sFileName);
325 $oUtils->setHeader(
"Content-Type: application/octet-stream");
326 if ($iFileSize = $this->
getSize()) {
327 $oUtils->setHeader(
"Content-Length: " . $iFileSize);
329 readfile($sFileLocations);
330 $oUtils->showMessageAndExit(null);
350 if ($this->_blHasValidDownloads == null) {
351 $this->_blHasValidDownloads =
false;
352 $sNow = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
353 $sFileId = $this->
getId();
358 `oxorderfiles`.`oxid`
360 LEFT JOIN `oxorderarticles` ON `oxorderarticles`.`oxid` = `oxorderfiles`.`oxorderarticleid`
361 LEFT JOIN `oxorder` ON `oxorder`.`oxid` = `oxorderfiles`.`oxorderid`
362 WHERE `oxorderfiles`.`oxfileid` = " . $oDb->quote($sFileId) .
"
363 AND ( ! `oxorderfiles`.`oxmaxdownloadcount` OR `oxorderfiles`.`oxmaxdownloadcount` > `oxorderfiles`.`oxdownloadcount`)
364 AND ( `oxorderfiles`.`oxvaliduntil` = '0000-00-00 00:00:00' OR `oxorderfiles`.`oxvaliduntil` > '{$sNow}' )
365 AND `oxorder`.`oxstorno` = 0
366 AND `oxorderarticles`.`oxstorno` = 0";
368 if ($oDb->getOne($sSql)) {
369 $this->_blHasValidDownloads =
true;
383 $iMaxCount = $this->oxfiles__oxmaxdownloads->value;
385 if ($iMaxCount < 0) {
386 $iMaxCount = $this->
getConfig()->getConfigParam(
"iMaxDownloadsCount");
399 $iMaxCount = $this->oxfiles__oxmaxunregdownloads->value;
401 if ($iMaxCount < 0) {
402 $iMaxCount = $this->
getConfig()->getConfigParam(
"iMaxDownloadsCountUnregistered");
415 $iExpTime = $this->oxfiles__oxlinkexptime->value;
418 $iExpTime = $this->
getConfig()->getConfigParam(
"iLinkExpirationTime");
431 $iExpTime = $this->oxfiles__oxdownloadexptime->value;
434 $iExpTime = $this->
getConfig()->getConfigParam(
"iDownloadExpirationTime");
448 if ($this->
exist()) {