XFileSharing Pro - Cron.pl

Message
Author
GMC
Posts: 172
Joined: Aug 15, 2009 4:48 am

Cron.pl

#1 Postby GMC » Feb 22, 2012 12:06 pm

Hi

I have sent this to support and never got a response.

I dont understand the code in cron.pl, but that hasnt stopped me from trying to make changes to it - lol

Only problem is I dont have a test site to run this on to see what damage it might do :)

What I am trying to do is give premium files an additional 30 days after the premium account expires - I am seeing 100's of files being deleted at a time, which can only be a premium account losing thier library.

I just want to give them some leeway from expiry to repurchase, as the site doesnt warn them their premium is about to expire

Here is the code I have changed

Code: Select all

my $list = $db->SelectARef("SELECT f.*
                                     FROM Files f, Users u
                                     WHERE srv_id=?
                                     AND f.usr_id=u.usr_id
                                     AND (usr_premium_expire IS NULL OR usr_premium_expire < NOW())"                                   
                            if $c->{dont_expire_premium};
                                 AND (usr_premium_expire IS NULL OR usr_premium_expire < DATE_ADD(NOW(), INTERVAL -30 DAY) )
                                     if $c->{dont_expire_premium});
         push @files, @$list;
      }


Anyone know if this will work?

Any comments suggestions will be appreciated

Thanks

GMC

nyan
Posts: 163
Joined: Oct 28, 2010 8:01 pm

#2 Postby nyan » Feb 22, 2012 4:51 pm

Post the original snippet, i think the only thing you need to change from that is

Code: Select all

usr_premium_expire < NOW()

to

usr_premium_expire < DATE_ADD(NOW(), INTERVAL -30 DAY)


and make no more changes to the original

GMC
Posts: 172
Joined: Aug 15, 2009 4:48 am

#3 Postby GMC » Feb 23, 2012 12:23 am

nyan wrote:Post the original snippet, i think the only thing you need to change from that is

Code: Select all

usr_premium_expire < NOW()

to

usr_premium_expire < DATE_ADD(NOW(), INTERVAL -30 DAY)


and make no more changes to the original
Please dont tell me its that easy

LOL

Here is the original snippet

Code: Select all

 if($c->{files_expire_access_prem})
      {
         my $list = $db->SelectARef("SELECT f.*
                                     FROM Files f, Users u
                                     WHERE srv_id=?
                                     AND f.usr_id=u.usr_id
                                     AND usr_premium_expire>=NOW()
                                     AND file_last_download < NOW()-INTERVAL ? DAY",
                                     $srv->{srv_id},$c->{files_expire_access_prem});
         push @files, @$list;
      }


Thanks for having a look!!

It is appreciated

GMC

nyan
Posts: 163
Joined: Oct 28, 2010 8:01 pm

#4 Postby nyan » Feb 23, 2012 7:25 pm

This is not the full code snippet that removes expires files
This part only checks for
Users that are currently premium, for the amount of expiry days you set for premium files.

you need to edit another part of the code.

stamos
Posts: 139
Joined: Nov 11, 2010 5:37 pm

#5 Postby stamos » Feb 23, 2012 8:38 pm

I would say the relevant snippet is this:

Code: Select all

      if($c->{files_expire_access_prem})
      {
         my $list = $db->SelectARef("SELECT f.*
                                     FROM Files f, Users u
                                     WHERE srv_id=?
                                     AND f.usr_id=u.usr_id
                                     AND usr_premium_expire>=NOW()
                                     AND file_last_download < NOW()-INTERVAL ? DAY",
                                     $srv->{srv_id},$c->{files_expire_access_prem});
         push @files, @$list;
      }



and here:

AND usr_premium_expire>=NOW()
AND file_last_download < NOW()-INTERVAL ? DAY",

you need to make changes.

maybe to
AND usr_premium_expire>=NOW()-30 DAYS

or something?!
but be carefull, false changes may delete more files than you want to, lol

GMC
Posts: 172
Joined: Aug 15, 2009 4:48 am

#6 Postby GMC » Feb 24, 2012 12:08 am

stamos wrote:but be carefull, false changes may delete more files than you want to, lol
This is what I am really trying to avoid

And as I cant run the software on two domains with the one licence, I dont have a test site, to screw around with the code

I would really like support to jump in on this conversation

GMC

GMC
Posts: 172
Joined: Aug 15, 2009 4:48 am

#7 Postby GMC » Feb 28, 2012 7:19 am

here is the answer

Anyway, this code is deleting premium files which was downloaded more than X days specified in $c->{files_expire_access_prem}



if($c->{files_expire_access_prem})

{

my $list = $db->SelectARef("SELECT f.*

FROM Files f, Users u

WHERE srv_id=?

AND f.usr_id=u.usr_id

AND usr_premium_expire>=NOW()

AND file_last_download < NOW()-INTERVAL ? DAY",

$srv->{srv_id},$c->{files_expire_access_prem});

push @files, @$list;

}



You can just pass ($c->{files_expire_access_prem}+30) there if you want to add 30 more days to their files. So, for example, premium will expire today, but files without downloads will be deleted not earlier than 30 days.

nyan
Posts: 163
Joined: Oct 28, 2010 8:01 pm

#8 Postby nyan » Feb 28, 2012 12:14 pm

You sure...

Code: Select all

AND usr_premium_expire>=NOW()

means that if a user premium account expired, this entire piece of code does not do anything

Code: Select all

AND usr_premium_expire>=DATE_ADD(NOW(), INTERVAL -30 DAY)

if you change it to that ^ , then this piece of code will hold for premium accounts that expired 30 days ago till any date in the future.

However, there should be another piece of code that expires free users files, you need to edit it to exclude users where "premium accounts that expired 30 days ago till any date in the future."


Return to “XFileSharing Pro”



Who is online

Users browsing this forum: No registered users and 0 guests