Download Counter Plugin

Find help with FlatPress plugins, report a plugin bug, request or present new plugins.
Post Reply
User avatar
fraenkiman
Posts: 210
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Download Counter Plugin

Post by fraenkiman » Mon Nov 28, 2022 11:14 pm

Hello all,

I have dug out a legacy plugin for you again and reworked it a bit. The plugin comes from Igor Komin.
The plugin adds a BBCode "download" with a link to the file to download and a counter how many times the file was downloaded.

Image

I have tested the plugin with Smarty 2.6 and 4.
If you are already using FlatPress 1.3dev with Smarty 4, you might have to replace a space in your own name with

Code: Select all

 
This is not very user-friendly, but it works. Maybe someone can track down the cause and fix it.
Details and download can be found in the wiki.
With best regards
Frank
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

User avatar
virtualsky
Posts: 67
Joined: Thu Mar 11, 2021 4:50 am
Location: Saskatchewan, Canada
Contact:

Re: Download Counter Plugin

Post by virtualsky » Tue Nov 29, 2022 12:00 am

Hey, this is great! I'll definitely check it out. Thanks for putting this together.
It ain't retro to me.... it's just how I live!
https://www.thegrove.in.nf/retroblog

User avatar
virtualsky
Posts: 67
Joined: Thu Mar 11, 2021 4:50 am
Location: Saskatchewan, Canada
Contact:

Re: Download Counter Plugin

Post by virtualsky » Wed Nov 30, 2022 3:48 am

Frank, how would I go about changing the default directory that this plug-in references for the files to be downloaded? I'm trying something unique and I want to download files from a particular directory that isn't fp-content/attachs.
It ain't retro to me.... it's just how I live!
https://www.thegrove.in.nf/retroblog

User avatar
fraenkiman
Posts: 210
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: Download Counter Plugin

Post by fraenkiman » Wed Nov 30, 2022 11:37 pm

Hello virtualsky,
you would have to change the path in both files.

In the plugin.downloadctr.php file look for the line (~ line 63)

Code: Select all

$download = ATTACHS_DIR . $file;
and replace it with

Code: Select all

$download = './your_directory/' . $file;
In the file download.php look for the line (~ line 27)

Code: Select all

$download = '../../' . ATTACHS_DIR . $downloadFile;
and replace it with

Code: Select all

$download = './your_directory/' . $downloadFile;
To the "new" directory the web server user must also have write permissions.

With best regards
Frank
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

User avatar
virtualsky
Posts: 67
Joined: Thu Mar 11, 2021 4:50 am
Location: Saskatchewan, Canada
Contact:

Re: Download Counter Plugin

Post by virtualsky » Thu Dec 01, 2022 12:10 am

Fantastic! Thanks, Frank. :D
It ain't retro to me.... it's just how I live!
https://www.thegrove.in.nf/retroblog

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Download Counter Plugin

Post by Arvid » Sun Dec 11, 2022 1:25 pm

A little suggestion: The plugin crashes if the BBCode plugin is not activated. Solution is easy, just check for the existance of plugin_bbcode_init():

Code: Select all

function plugin_bbcode_downloadctr_tag() {
	if (!function_exists('plugin_bbcode_init')) {
		return;
	}
	$bbcode = plugin_bbcode_init(); // import the "global" bbcode object into current function
All the best,
Arvid

User avatar
fraenkiman
Posts: 210
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Download Counter Plugin 1.3.2

Post by fraenkiman » Wed Dec 14, 2022 1:07 am

Hello Arvid,

also here many thanks for your hint and the solution :) .
The fix for the plugin is ready and can be downloaded from the wiki.

With best regards
Frank
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests