Justin Beitler
 Nuke Active Member Posts:21

 |
06/06/2010 8:58 PM |
|
Hi all, i'm trying to figure out how to run some basic server side code which will hide a private key... I did this before with PHP, but now in DNN I can't figure out how to do anything other than normal HTML... Below is the code I am trying to replicate (with generic keys put in obviously)
function get_signed_player($videokey,$playerkey) {
$path = "players/".$videokey."-".$playerkey.".js";
$expires = time() + 3600;
$secret = "Ksi99h9938sjKfha9JaheEMp";
$signature = md5($path.':'.$expires.':'.$secret);
$url = 'http://content.mysite.com/'.$path.'?exp='.$expires.'&sig='.$signature;
return $url;
};
echo "Watch this cool video:";
echo "script type='text/javascript' src='".get_signed_player('nPrip99l','ALJ9XQCI')."'>";
?>
" |
|
|
|
|
Joseph Craig DNN MVP Posts:11667

 |
06/07/2010 6:35 AM |
|
Where are you trying to put this? Normally, something like this would be part of the code behind in a module. |
|
Joe Craig, Patapsco Research Group Complete DNN Support |
|
|
Justin Beitler
 Nuke Active Member Posts:21

 |
06/09/2010 12:12 PM |
|
I'm trying to put this on any page (i.e. in an HTML module) So, to explain, I am playing video on my website. The video is hosted somewhere else and the "embeded link" needs to be authenticated (and has a time component, so it eventually expires)... In order to properly embed the video, I have to put the link on my page which automatically generates a new link with a new time expiration. Problem is that if I do all this through normal HTML, anyone can see my "secret" keys and could embed the video on their website. Ideally I need to do this calculation server side and then have it generate a completed link (hence the PHP script above) I just need some way to generate this link server side and then spit out the HTML code.. Is there any way to just use a normal PHP or ASP style code to do this? Seems like it would be relatively simple, no? |
|
|
|
|
Joseph Craig DNN MVP Posts:11667

 |
06/09/2010 6:55 PM |
|
You can probably do this by using an IFrame to show an asp page.
It would be better, though, to do this in a simple module. Essentially, you can convert your asp script to asp.net code in a module. Modules that are basically code and don't require database access or settings are a relative snap to create.
You also can do this with OWS or DotNetMushroom.
|
|
Joe Craig, Patapsco Research Group Complete DNN Support |
|
|
Justin Beitler
 Nuke Active Member Posts:21

 |
06/10/2010 12:14 AM |
|
K, silly question, but I've got no idea how to create a module. Any places I can find instructions for how to do this (given the fact that I'm not accessing the database at all I'm guessing this would be relatively simple...) |
|
|
|
|
Joseph Craig DNN MVP Posts:11667

 |
06/10/2010 7:22 AM |
|
This example is a good one. You put your "script" code (converted to vb or c#) in the codebehind file for view.ascx. Ask if you need more pointers or help. |
|
Joe Craig, Patapsco Research Group Complete DNN Support |
|
|
Justin Beitler
 Nuke Active Member Posts:21

 |
06/10/2010 6:04 PM |
|
OK, I think I can do that, but I don't use VB a whole lot...
Could you help me translate the above PHP code into VB, making sure I have one input for "PATH"
(essentially I need a module where I could drop in the "path" to the specific video, and then it would do all the above calculations server side, and spit out the proper javascript / URL and thus display the video)
(Here is the full script example from the other website, except that I spelled out the word "plus" because I couldn't figure out how to get the symbol to show up here..:
* This PHP function will generate a signed URL. Parameters:
*
* $path - The path of the video or player you want to sign, e.g. "videos/KsoieJsu-123.mp4"
* Note this excludes the domain and excludes the trailing slash.
* $secret - The API secret of your account, e.g. "Jau8Ya71hakdpF0A".
* This acts as a shared secret between your server and BOTR.
* $timeout -The time in seconds you want the signed URL to remain valid, e.g. "3600".
* Typical timeouts are between a minute and a few hours. Default is "3600".
* Make sure the time on your server is set correctly, or URLs with short timeouts will fail!
* $domain - The masked domain name you want to use for signing the content, e.g. "video.mysite.com".
* Use this if you have setup DNS masking. Defaults to "content.bitsontherun.com".
**/
function get_signed_url($path,$secret,$timeout,$domain) {
if($timeout) {
$expires = time() "plus" $timeout;
} else {
$expires = time() "plus" 3600;
}
$signature = md5($path.':'.$expires.':'.$secret);
if($domain) {
$url = 'http://'.$domain.'/'.$path.'?exp='.$expires.'&sig='.$signature;
} else {
$url = 'http://content.mydomain.com/'.$path.'?exp='.$expires.'&sig='.$signature;
}
return $url;
};
|
|
|
|
|
Joseph Craig DNN MVP Posts:11667

 |
06/11/2010 10:15 AM |
|
I did a quick web search and found some sites that claim to be able to translate php to vb.
|
|
Joe Craig, Patapsco Research Group Complete DNN Support |
|
|
Justin Beitler
 Nuke Active Member Posts:21

 |
06/11/2010 3:52 PM |
|
Ah yes, didn't even think of that. Ok, thank you! |
|
|
|
|