[3.2][DEV] Download limit

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Suggested Hosts
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
User avatar
dmzx
Registered User
Posts: 768
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

[3.2][DEV] Download limit

Post by dmzx » Mon Jul 08, 2019 12:35 pm

Extension Name: Download limit
Author: dmzx

Special thanks to: martin

Extension Description:
Download attachment limit. Can set in ACP the amount of downloads and hours and groups.

Image Image Image

Image
- Code update allowed extensions in ACP.
- Code update in listener.php for allowed extension.

Image
- Code update for download count
- Code update in listener.php
- Code update in service.yml
- Code update in downloadlimit_prune.php
- Added allowed_extensions in listener.php

Screenshots:
Image

Image

Image

Image

Image

Image


Extension Download:
Download

Installation:
  1. Download the latest release.
  2. Unzip the downloaded release, and change the name of the folder to `downloadlimit`.
  3. In the `ext` directory of your phpBB board, create a new directory named `dmzx` (if it does not already exist).
  4. Copy the `downloadlimit` folder to `/ext/dmzx/` if done correctly, you'll have the main extension class at
    (your forum root)/ext/dmzx/downloadlimit/composer.json
  5. Navigate in the ACP to `Customise -> Manage extensions`
  6. Look for `Download limit` under the Disabled Extensions list, and click its `Enable` link.
Last edited by dmzx on Wed Jul 10, 2019 2:21 pm, edited 1 time in total.
Contact me on dmzx-web.net
 Need a Host or buy me a beer Donate and try binance.com

User avatar
John connor
Registered User
Posts: 2186
Joined: Fri Nov 14, 2014 5:14 pm
Location: U S Of A
Name: Aaron
Contact:

Re: [3.2][DEV] Download limit

Post by John connor » Mon Jul 08, 2019 1:02 pm

Is this per post or per the whole board? So if 5 is the limit in an hour, a user can only download 5 attachments board-wide in an hour?

User avatar
dmzx
Registered User
Posts: 768
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx » Mon Jul 08, 2019 1:09 pm

John connor wrote:
Mon Jul 08, 2019 1:02 pm
Is this per post or per the whole board? So if 5 is the limit in an hour, a user can only download 5 attachments board-wide in an hour?
Its board wide.
Contact me on dmzx-web.net
 Need a Host or buy me a beer Donate and try binance.com

User avatar
John connor
Registered User
Posts: 2186
Joined: Fri Nov 14, 2014 5:14 pm
Location: U S Of A
Name: Aaron
Contact:

Re: [3.2][DEV] Download limit

Post by John connor » Mon Jul 08, 2019 1:23 pm

Okay, thanks.


I think I'll test this out on my test site. I use an AWS Amazon upload extension so we'll see if it plays nice with that.

User avatar
dmzx
Registered User
Posts: 768
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx » Mon Jul 08, 2019 1:27 pm

John connor wrote:
Mon Jul 08, 2019 1:23 pm
Okay, thanks.


I think I'll test this out on my test site. I use an AWS Amazon upload extension so we'll see if it plays nice with that.
Just keep in mind the note:

Note: Check listener.php for allowed extensions
Contact me on dmzx-web.net
 Need a Host or buy me a beer Donate and try binance.com

User avatar
John connor
Registered User
Posts: 2186
Joined: Fri Nov 14, 2014 5:14 pm
Location: U S Of A
Name: Aaron
Contact:

Re: [3.2][DEV] Download limit

Post by John connor » Mon Jul 08, 2019 1:43 pm

Doesn't seem to work. And I don't know code and have no idea what to look for in listener.php

User avatar
dmzx
Registered User
Posts: 768
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx » Mon Jul 08, 2019 1:53 pm

John connor wrote:
Mon Jul 08, 2019 1:43 pm
Doesn't seem to work.
What does not work?
John connor wrote:
Mon Jul 08, 2019 1:43 pm
And I don't know code and have no idea what to look for in listener.php
Look for this in listener.php:

Code: Select all

private function allowed_extensions()
	{
		// Here you can add additional extensions
		// Always use lower and upper case extensions
		$allowed_extensions = array();
		
		// Archive extenstions
		$allowed_extensions[] = 'zip';
		$allowed_extensions[] = 'ZIP';
		$allowed_extensions[] = 'rar';
		$allowed_extensions[] = 'RAR';
		$allowed_extensions[] = '7z';
		$allowed_extensions[] = '7Z';
		$allowed_extensions[] = 'ace';
		$allowed_extensions[] = 'ACE';
		$allowed_extensions[] = 'gtar';
		$allowed_extensions[] = 'GTAR';
		$allowed_extensions[] = 'gz';
		$allowed_extensions[] = 'GZ';
		$allowed_extensions[] = 'tar';
		$allowed_extensions[] = 'TAR';
		
		return $allowed_extensions;
	}
Contact me on dmzx-web.net
 Need a Host or buy me a beer Donate and try binance.com

User avatar
spaceace
Registered User
Posts: 1857
Joined: Wed Jan 30, 2008 8:50 pm
Contact:

Re: [3.2][DEV] Download limit

Post by spaceace » Mon Jul 08, 2019 2:50 pm

dmzx wrote:
Mon Jul 08, 2019 1:53 pm
Look for this in listener.php:

Code: Select all

private function allowed_extensions()
	{
		// Here you can add additional extensions
		// Always use lower and upper case extensions
		$allowed_extensions = array();
		
		// Archive extenstions
		$allowed_extensions[] = 'zip';
		$allowed_extensions[] = 'ZIP';
		$allowed_extensions[] = 'rar';
		$allowed_extensions[] = 'RAR';
		$allowed_extensions[] = '7z';
		$allowed_extensions[] = '7Z';
		$allowed_extensions[] = 'ace';
		$allowed_extensions[] = 'ACE';
		$allowed_extensions[] = 'gtar';
		$allowed_extensions[] = 'GTAR';
		$allowed_extensions[] = 'gz';
		$allowed_extensions[] = 'GZ';
		$allowed_extensions[] = 'tar';
		$allowed_extensions[] = 'TAR';
		
		return $allowed_extensions;
	}
why not just add that to the ACP so it's easy to add or remove allowed file extensions

User avatar
dmzx
Registered User
Posts: 768
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx » Mon Jul 08, 2019 2:58 pm

Yes will add that to ACP next release
Contact me on dmzx-web.net
 Need a Host or buy me a beer Donate and try binance.com

User avatar
John connor
Registered User
Posts: 2186
Joined: Fri Nov 14, 2014 5:14 pm
Location: U S Of A
Name: Aaron
Contact:

Re: [3.2][DEV] Download limit

Post by John connor » Mon Jul 08, 2019 5:07 pm

I see now. Yeah, the whole thing I think don't work. I was expecting it to handle images so maybe that's why I don't see any text in a user profile or anything related to downloads available shown in your screen shoots?

Should I edit the listener for image types?

User avatar
dmzx
Registered User
Posts: 768
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx » Wed Jul 10, 2019 2:22 pm

First post updated.

John connor wrote:
Mon Jul 08, 2019 5:07 pm
I see now. Yeah, the whole thing I think don't work. I was expecting it to handle images so maybe that's why I don't see any text in a user profile or anything related to downloads available shown in your screen shoots?

Should I edit the listener for image types?
see ACP settings to add the extension
Contact me on dmzx-web.net
 Need a Host or buy me a beer Donate and try binance.com

User avatar
John connor
Registered User
Posts: 2186
Joined: Fri Nov 14, 2014 5:14 pm
Location: U S Of A
Name: Aaron
Contact:

Re: [3.2][DEV] Download limit

Post by John connor » Thu Jul 11, 2019 4:23 am

I don't understand. I have added the extension. I know how to add extensions just looking at the composer.json.

User avatar
dmzx
Registered User
Posts: 768
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx » Thu Jul 11, 2019 5:43 am

John connor wrote:
Thu Jul 11, 2019 4:23 am
I don't understand. I have added the extension. I know how to add extensions just looking at the composer.json.
Look at the Download limit settings in ACP .

There you can add the (file) extension like: zip,jpg,....

Image
Contact me on dmzx-web.net
 Need a Host or buy me a beer Donate and try binance.com

User avatar
John connor
Registered User
Posts: 2186
Joined: Fri Nov 14, 2014 5:14 pm
Location: U S Of A
Name: Aaron
Contact:

Re: [3.2][DEV] Download limit

Post by John connor » Thu Jul 11, 2019 12:19 pm

So it seems to have some text now, but I can still download jpgs. In fact they show up and I can save them to my computer. This is a registered group.



Image

User avatar
dmzx
Registered User
Posts: 768
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx » Thu Jul 11, 2019 1:12 pm

Check if your browser is caching the downloads.
Simple test is if you download (for example a zip) check if the download counter is count up om your forum.
Contact me on dmzx-web.net
 Need a Host or buy me a beer Donate and try binance.com

Post Reply

Return to “Extensions in Development”