We will use base64_encode and base64_decode to generate download links for thunder, express train, and QQ tornado in php. we will look at two examples below to help you. in some resource download sharing sites, I... we will use base64_encode and base64_decode to generate download links for thunder, express train, and QQ tornado in php. we will look at two examples below to help you.
In some resource download sharing sites, we often encounter the need to add various download tool links on the download page, the traditional use of the download tool official script (. js). Its drawbacks have become increasingly prominent, such as slow loading and client compatibility issues.
This article describes how to use PHP functions to easily generate link data for various third-party download tools and directly output the data to the front-end.
PHP functions used by this function:
1. base64_encode: used to encrypt strings in base64 mode.
2. base64_decode: used to decrypt strings encrypted in base64 mode.
Example 1: Download the PHP code from the original third-party tool:
$ Url = 'http: // www.example.com/document.zip'; // you can refer to the following code to find the exact structure of the download links of various third-party tools: $ url_thunder = 'Thunder ://'. base64_encode ('A '. $ url. 'zz '); $ url_flashget = 'flashget ://'. base64_encode ('[FLASHGET]'. $ url. '[FLASHGET]'); $ url_qqdl = 'qqdl ://'. base64_encode ($ url); restores the original link PHP code from the third-party tool Download link: $ url_old = ''; // separate the string with a slash (//). $ temp = explode ('//', $ url_old, 2); // determine the character before // (converted to lowercase) switch (strtolower ($ temp [0]) {case 'Thunder: ': $ url_new = substr (base64_decode ($ temp [1]), 2,-2); break; case 'flashget: ': $ url_new = substr (base64_decode ($ temp [1]), 10,-10); break; case 'qqdl :': $ url_new = base64_decode ($ temp [1]); break ;}
Example 2: The code is as follows:
Actual address: "target =" _ blank ">
Thunder chain: "target =" _ blank ">
Express link: "target =" _ blank ">
Tornado chain: "target =" _ blank ">
Tutorial link:
Reprint at will ~ However, please keep the tutorial address★