Author |
|
ghumar Newbie
Joined: 19 January 2022 Location: Slovenia
Online Status: Offline Posts: 1
|
Posted: 19 January 2022 at 10:30am | IP Logged
|
|
|
Hi,
as I was not able to find any documentation regarding creating download
links that would expire after X days I modified the code by myself.
Maybe it's not a perfect solution but at least it works.
Just in case anyone else needs this function. There is not much code
to change but if you don't not where to start it is a real nightmare.
-----------------------------------------------------------------------
Step 1:
-----------------------------------------------------------------------
Change the code in file
modules/Min/Models/MinHash.php
from
protected $fillable = [
'Id',
'HashId',
'UserId',
'Hash',
'Data'
];
to
protected $fillable = [
'Id',
'HashId',
'UserId',
'Hash',
'Data',
'ExpireDate'
];
If you don't add the last line 'ExpireDate' into this record you will not be able to insert expiration integer value into the ExpireDate field of au_core_min_hashes table
-----------------------------------------------------------------------
Step 2:
-----------------------------------------------------------------------
Insert the following code into a file
modules/Min/Manager.php
right at the beginning of function createMin
$LifetimeHrs = X; (Where X is No. of hours after the link will expire; For link that lasts for a week just replace X with 24*7)
for Example
$iExpireDate = time() + ((int) $LifetimeHrs * 60 * 60);
public function createMin($sHashID, $aParams, $iUserId = null, $iExpireDate = null)
{ $LifetimeHrs = 24*7;
$iExpireDate = time() + ((int) $LifetimeHrs * 60 * 60);
-----------------------------------------------------------------------
Step 3:
-----------------------------------------------------------------------
change the line in file
modules/Min/Cron.php
from
$sDelMinHashesQuery = "DELETE FROM `{$this->oDBPrefix}min_hashes`
to
$sDelMinHashesQuery = "DELETE FROM `{$this->oDBPrefix}core_min_hashes`
and the following 2 lines
from
WHERE expire_date <= {$iTime}
AND expire_date IS NOT NULL
to
WHERE expiredate <= {$iTime}
AND expiredate IS NOT NULL
As "expire_date" is not a correct field name. You should change it.
And the final step:
Add the following command line to cronjob:
/usr/local/bin/php /home/username/public_html/modules/Min/Cron.php
where "username" is account username
I hope this helps someone.
Bye
|
Back to Top |
|
|