SMFHacks.com

SMF Gallery Pro => Support => Topic started by: Jonas1975 on February 02, 2015, 10:53:22 am

Title: Some members receiving message of upload limit exceeded wrongly
Post by: Jonas1975 on February 02, 2015, 10:53:22 am
Not sure what is happening but I have some members complaining that they are receiving an error message that they have exceeded their daily upload limit (that I set to 3 pics) even if they didn't upload any pics on the last days.

Don't know what to do about this, so I need some help here.

Edit: Is the restriction made by member account or IP?  If it is the IP, I think I have the explanation for it...
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: SMFHacks on February 02, 2015, 11:06:40 am
It's based on server time. Here is the code for 2.0.x do not see anything with it.
Code: [Select]
function CheckMaxUploadPerDay()
{
global $gallerySettings, $smcFunc, $user_info, $txt;

if (empty($gallerySettings['gallery_set_maxuploadperday']))
return true;

if (allowedTo('smfgallery_manage'))
return true;

// Find total uploads for the last 24 hours for the user
$currenttime = time();

$last24hourstime = $currenttime  -  (1* 24 * 60 * 60);


$dbresult = $smcFunc['db_query']('', "
SELECT
id_picture
FROM {db_prefix}gallery_pic
WHERE id_member = " .$user_info['id'] . " AND date > $last24hourstime");

$totalRow['total'] = $smcFunc['db_num_rows']($dbresult);

if ($totalRow['total'] >= $gallerySettings['gallery_set_maxuploadperday'])
fatal_error($txt['gallery_err_upload_day_limit'] .  $gallerySettings['gallery_set_maxuploadperday'], false);
else
return true;

}
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: Jonas1975 on February 02, 2015, 11:17:12 am
Strange...  I think the server time is correct. What else might lead to the message to be shown?
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: SMFHacks on February 02, 2015, 11:24:32 am
I can only think of it the server time got changed pictures uploaded with the wrong date could throw it off.

Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: Jonas1975 on February 02, 2015, 11:34:39 am
But that would mean that comments and posts would have also the time messed up, right?  And they are correct...

There must be something else...  I will keep searching and will do some tests.
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: SMFHacks on February 02, 2015, 11:59:01 am
I would test this code $totalRow['total'] = $smcFunc['db_num_rows']($dbresult);
Remember to test without using a gallery admin as they are allowed to exceed limits
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: Jonas1975 on February 02, 2015, 12:03:15 pm
Where and how do I test that code?
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: SMFHacks on February 02, 2015, 01:23:15 pm
Sources/Gallery2.php is where you modify.

Then test with a normal member account.
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: Jonas1975 on February 02, 2015, 02:35:54 pm
Ok, I located that exact code on Gallery2.php but I still don't understand what to do... Do I need to modify it? What should I expect as to see when accessing the site as normal user?
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: SMFHacks on February 02, 2015, 02:37:04 pm
Well you should try to upload images and see if you hit a limit or after max of 3 per day.
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: Jonas1975 on February 02, 2015, 02:44:20 pm
I managed to upload my 3 photos as limit and then I got the warning.

Edit: After deleting the images, I'm able again to upload. I think I might ask a member to let me use his profile once the error occurs to check it.
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: Jonas1975 on February 06, 2015, 05:03:31 am
I managed to enter with the account of the member who was reporting this issue and have confirmed that he's receiving the upload limit error even if he hasn't posted any photo in the last 24 hours (and the limit is 3).

I tried with a Testing profile to make 3 comments to check if comments on the gallery could be counting for the photo upload limit and seems it's not.

The server time must be correct as the posts shows the correct date and time.

I'm clueless on what is the origin of this problem.

Edit: Btw, would be interesting to have a log on this "error". I still have uploads on the gallery but have no idea if this is an isolated problem or a common one.
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: SMFHacks on February 06, 2015, 12:06:40 pm
I am at a loss too. It is by date time.  How days have passed since he last uploaded pictures....
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: Jonas1975 on February 06, 2015, 12:22:52 pm
I am at a loss too. It is by date time.  How days have passed since he last uploaded pictures....
It was 2 days and only 1 pic. The other pic was the day or 2 before. So I can't understand what's causing the issue. If posts are made with correct time, it means that server has the correct time too, right? Can the Database be messed up?
Title: Re: Some members receiving message of upload limit exceeded wrongly
Post by: SMFHacks on February 06, 2015, 12:29:00 pm
Database could be if you had wrong date/time upload for that member
Here is the sql query
Code: [Select]
SELECT
*
FROM smf_gallery_pic
WHERE id_member = ####REPLACEMEMBERID#### AND date > ####REPLACEWITHUNIXSTAMP####
The unix time stamp should be 23 hours ago
That will return what pictures it is checking against.