Download the PHP package masugadesign/linkvault without Composer
On this page you can find all versions of the php package masugadesign/linkvault. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download masugadesign/linkvault
More information about masugadesign/linkvault
Files in masugadesign/linkvault
Package linkvault
Short Description Protect and track downloads on your site. Prevent and track leech attempts.
License
Informations about the package linkvault
Link Vault for Craft CMS
Protect and track downloads on your site. Prevent and track leech attempts.
This is a commercial plugin for Craft CMS 5.
Table of Contents
- Requirements
- Installation
- Settings
- Config Variables
- Template Variables
- Events
Requirements
- Craft CMS v5.0.0+
- PHP 8.2+
Installation
Add the following to your composer.json requirements. Be sure to adjust the version number to match the version you wish to install.
Settings
Leech Attempt Template
This template will load with a 403 status whenever someone attempts to leech a download URL as long as leech blocking is enabled. Link Vault provides a default template to use if this setting is left blank.
Missing File Template
This template will load with a 404 status whenever someone attempts to download a file that doesn't exist. Link Vault provides a default template to use if this setting is left blank.
Config Variables
Link Vault has a number of config variables that can be overridden by creating a linkvault.php file in your project's craft/config/ folder. The defaults are displayed below.
Template Variables
downloadUrl
The download URL accepts two parameters:
- file - This may either be an instance of an Asset element or it may be a system path (string) to a file on the server. It can exist anywhere as long as the path is accessible by the webserver.
- additional parameters - This is an array of custom fields or other variables to be saved to the download record.
Examples
As you can see, passing an instance of an Asset element is the simplest way to create a Link Vault download URL. This method also works for files stored on an S3 source.
Below are some examples that make use of the second parameter to pass along element IDs. In Craft, entries and assets have unique element IDs. It is entirely up to you what you store in the linkvault_downloads.elementId
column as it is for informational purposes only. If the first parameter is a valid AssetD, Link Vault stores its ID in the linkvault_downloads.assetId
column automatically.
You can create custom fields to store any data you like with Link Vault. These fields are created from Link Vault's Custom Fields tab in the control panel. Once you do create a field, just use the field's handle in the array parameter.
zipUrl
The zipUrl template variable generates a Link Vault download URL for a collection of files that will be zipped on-the-fly when the URL is followed. Each file is tracked individually in the logs. Zipping files on-the-fly could require a lot of memory depending on the size of the files being zipped. It is recommended to only use this feature on smaller files <10MB.
The first parameter may be an array of Craft Asset elements or Craft Asset IDs. The second parameter is the base name for the zip file that will be generated.
Examples
totalDownloads
The totalDownloads variable returns the total downloads for a given set of criteria. It is very similar to the downloadUrl variable except it only has one parameter which can be one of three things:
- An instance of an Asset element.
- An array of parameters
- A string containing the full system path to a file.
Examples
fileSize
The fileSize template variable fetches a human-readable file size string for a specified file. This can be used for server files not stored in Craft as assets though it will work with asset files as well. For asset elements, the native {{ file.size|filesize }}
may be preferable.
Examples
baseTwoFileSize (Added in v3.1.2)
The baseTwoFileSize template variable is an alias of the fileSize template variable. 1024 is used as the divisor.
baseTenFileSize (Added in v3.1.2)
The baseTenFileSize template variable is similar to fileSize and baseTwoFileSize except the file size is calculated using 1000 as the divisor.
downloads
The downloads template variable fetches download records based on the specified criteria.
Examples
leechAttempts
The leechAttempts template variable works in the exact same manner as the downloads variable except that it only return leech attempt records.
records
The records template variables works in the same manner as downloads and leechAttempts variables except it will return all records regardless of type.
groupCount (Added in v1.0.2)
The groupCount template variable queries record counts and groups them by a particular column name.
customFields (Added in v3.2.0)
The customFields template variable allows for querying Link Vault's defined custom fields.
Events
LinkVaultDownload elements inherit all the standard Craft element events. Below is an example of the craft\base\Element::EVENT_BEFORE_SAVE event:
Additionally, Link Vault contains the following events:
LinkClickEvent (Added in v3.1.0)
This event is triggered immediately after someone clicks/follows a Link Vault URL and the encrypted parameters are decrypted.
ModifyZipUrlFilesEvent (Added in v3.1.0)
This event is triggered immediately before the Link Vault zipUrl tag creates an on-the-fly zip file. The event allows for adding files or removing files from the array of files to be zipped.