Hi,
How would I get this file gateway php code to work with wordpress? Im using hotfile.com to host the files.
<?php
function encrypt4AM($url='', $pw='', $friendlyname='', $is_file=1){
if ($friendlyname==''){$friendlyname='0';}else{$friendlyname=str_replace('__','_',$friendlyname);}
if ($url==''){$encurl='0';}else{$encurl=encrypt($url);}
if ($pw==''){$encpw='0';}else{$encpw=encrypt($pw);}
$out = 'http://lnkgt.com/0i6510_'.urlencode($friendlyname.'__'.$encurl.'_'.$encpw.'_'.$is_file);
return $out;
}
function encrypt($string){
$result = ''; $key = '65101279627485';
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return base64_encode($result);
}
function decrypt($string){
$result = ''; $key = '65101279627485';
$string = base64_decode($string);
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)-ord($keychar));
$result.=$char;
}
return $result;
}
?>
Usage
First, familiarize yourself with how the file gateway works when you create a link normally (manually) via our website.
This example will mimic a link that we've created manually (http://lnkgt.com/3). As in that demo, we will be linking to a simple text file, located at:
http://rapidshare.com/files/287593924/lnkgt_example.txt
We'll use the PHP code as so:
<?php
$url = "http://rapidshare.com/files/287593924/lnkgt_example.txt";
$url = encrypt4AM($url, '', 'example_file', 1);
echo($url);
?>
This would give us a new URL like this (link):
http://lnkgt.com/0i1441_example_text_file__mKWopGtgYaWaop2cqJ%2BRo5lilKCfYp%2BboJ2oZmJpa2lqZGtlbWGgpqCepJCZrJKeop%2BeYKiwqQ%3D%3D_0_1
The new URL is encrypted, so that visitors can't determine what link you are ultimately sending them to (the text file at Rapidshare, in this example). Remember that your PHP code will give different results, since a different encryption is used for each publisher account.
You can now apply this method to any and all download links on your site.
There are four options to the encrypt4AM function: URL, password, whether the link is to a file (use 0 or 1 to specify), and a "friendly name" to use at the beginning of the URL, to give it some readability ("example_file" in our example). The friendly name should concist only of letters, numbers, underscores, and dots.
I want to place the code in my wordpress blog so all my files can be protected by the gateway all at ones.
Thanks in advance