[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: 853
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

[3.2][DEV] Download limit

Post by dmzx »

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 for 3.3.x

Image
- Code update for excluding groups when change to other group.

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 Sat Dec 07, 2019 4:06 pm, edited 3 times in total.
Contact me on dmzx-web.net
Buy me a beer Donate and try binance.com or try CentOS Web Panel
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [3.2][DEV] Download limit

Post by 2600 »

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?
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
dmzx
Registered User
Posts: 853
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx »

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
Buy me a beer Donate and try binance.com or try CentOS Web Panel
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [3.2][DEV] Download limit

Post by 2600 »

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.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
dmzx
Registered User
Posts: 853
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx »

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
Buy me a beer Donate and try binance.com or try CentOS Web Panel
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [3.2][DEV] Download limit

Post by 2600 »

Doesn't seem to work. And I don't know code and have no idea what to look for in listener.php
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
dmzx
Registered User
Posts: 853
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx »

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
Buy me a beer Donate and try binance.com or try CentOS Web Panel
User avatar
spaceace
Registered User
Posts: 1999
Joined: Wed Jan 30, 2008 8:50 pm
Contact:

Re: [3.2][DEV] Download limit

Post by spaceace »

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: 853
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx »

Yes will add that to ACP next release
Contact me on dmzx-web.net
Buy me a beer Donate and try binance.com or try CentOS Web Panel
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [3.2][DEV] Download limit

Post by 2600 »

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?
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
dmzx
Registered User
Posts: 853
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx »

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
Buy me a beer Donate and try binance.com or try CentOS Web Panel
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [3.2][DEV] Download limit

Post by 2600 »

I don't understand. I have added the extension. I know how to add extensions just looking at the composer.json.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
dmzx
Registered User
Posts: 853
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx »

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
Buy me a beer Donate and try binance.com or try CentOS Web Panel
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [3.2][DEV] Download limit

Post by 2600 »

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
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
dmzx
Registered User
Posts: 853
Joined: Fri Sep 05, 2014 6:48 am
Location: The Netherlands
Contact:

Re: [3.2][DEV] Download limit

Post by dmzx »

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
Buy me a beer Donate and try binance.com or try CentOS Web Panel
Post Reply

Return to “Extensions in Development”