隐藏 MP3 完整网址 [英] Hide MP3 full url

查看:41
本文介绍了隐藏 MP3 完整网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用以下语法链接到歌曲的音乐播放器:

I have a music player that links to a song using the following syntax:

<li><a href="" data-src="http://s3.amazonaws.com/audiojs/02-juicy-r.mp3">title</a></li>

有什么办法可以让我执行服务器端,然后像(见下文)那样为用户显示?

Is there any way that I could have that executed server side and then be displayed like (see below) for the user?

在搜索时,我遇到了这个......我喜欢拥有一个包含数据的外部文件背后的想法......比如:

While searching, I ran across this...I like the idea behind having an external file that has the data...like:

<?php
// get-file.php
// call with: http://yoururl.com/path/get-file.php?id=1
$id = (isset($_GET["id"])) ? strval($_GET["id"]) : "1";
// lookup
$url[1] = 'link.mp3';
$url[2] = 'link2.mp3';
header("Location: $url[$id]");
exit;
?>

然后使用:http://yoururl.com/path/get-file.php?id=1 作为链接...唯一的问题是当你输入 http://yoururl.com/path/get-file.php?id=1 用户直接进入文件......有没有办法禁用该功能......也许get-file.php 本身的一些代码?

then using: http://yoururl.com/path/get-file.php?id=1 as the link...the only problem is that when you type http://yoururl.com/path/get-file.php?id=1 the user goes straight to the file...is there any way to disable that ability...maybe some code on get-file.php itself?

推荐答案

好的,所以我做了一些我满意的组合......虽然不是完全安全,但它确实帮助我模糊了它.

Ok, so I did a combination of things that I am satisfied with...although not completely secure, it definitely helped me obscure it quite a bit.

首先,我使用AudioJS播放器播放音乐——可以找到:http://kolber.github.com/audiojs/

First of all, I am using the AudioJS player to play music - which can be found: http://kolber.github.com/audiojs/

基本上我所做的是:

  1. 我没有使用data-src"作为我歌曲的路径,而是将其称为key",这样人们就不一定会认为这是一条路径.
  2. 我没有使用my-song-title"作为歌曲名称,而是将其更改为类似 7364920 之类的数字,这样人们就无法在源中查找并以这种方式找到 url.
  3. 我在 javascript 代码中添加了所有关键"变量之后的mp3",这样我就不必在模糊链接中声明它.
  4. 我使用了诸如./8273019283/"之类的相对路径,而不是your-domain.com/8273019283/",这样就很难判断我正在显示一个网址.
  5. 添加了指向 href 的 iTunes 链接,这样人们可能会对我提取文件的方式感到困惑.

所以,现在我的内联 javascript 看起来像:

So, now my inline javascript looks like:

<script type="text/javascript">
        $(function() {
            // Play entire album
            var a = audiojs.createAll({
                trackEnded: function() {
                    var next = $("ul li.playing").next();
                    if (!next.length) next = $("ul li").first();
                    next.addClass("playing").siblings().removeClass("playing");
                    audio.load($("a", next).attr("key") + "mp3");
                    audio.play();
                }
            });
            // Load the first song
            var audio = a[0];
            first = $("ul a").attr("key") + "mp3";
            $("ul li").first().addClass("playing");
            audio.load(first);
            // Load when clicked
            $("ul li").click(function(e) {
                e.preventDefault();
                $(this).addClass("playing").siblings().removeClass("playing");
                audio.load($('a', this).attr('key') + "mp3");
                audio.play();
            });
        });
    </script>

我的链接看起来像:

<a href="<?php $link = 'http://itunes.apple.com/us/album/falling/id504779876?i=504779883&uo=4'; $obfuscatedLink = ""; for ($i=0; $i<strlen($link); $i++){ $obfuscatedLink .= "&#" . ord($link[$i]) . ";"; } echo $obfuscatedLink; ?>" target="itunes_store" key="<?php $link = './8249795872/9273847591.'; $obfuscatedLink = ""; for ($i=0; $i<strlen($link); $i++){ $obfuscatedLink .= "&#" . ord($link[$i]) . ";"; } echo $obfuscatedLink; ?>">Falling</a>

当您在浏览器中加载它并查看源代码时,您会看到:

When you load it up in the browser and you view the source you'll see:

<a href="&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#105;&#116;&#117;&#110;&#101;&#115;&#46;&#97;&#112;&#112;&#108;&#101;&#46;&#99;&#111;&#109;&#47;&#117;&#115;&#47;&#97;&#108;&#98;&#117;&#109;&#47;&#102;&#97;&#108;&#108;&#105;&#110;&#103;&#47;&#105;&#100;&#53;&#48;&#52;&#55;&#55;&#57;&#56;&#55;&#54;&#63;&#105;&#61;&#53;&#48;&#52;&#55;&#55;&#57;&#56;&#56;&#51;&#38;&#117;&#111;&#61;&#52;" target="itunes_store" key="&#46;&#47;&#56;&#50;&#52;&#57;&#55;&#57;&#53;&#56;&#55;&#50;&#47;&#57;&#50;&#55;&#51;&#56;&#52;&#55;&#53;&#57;&#49;&#46;">Falling</a>

然后当您使用 Web Inspector 或 Firebug 时,您会看到:

Then when you use Web Inspector or Firebug you'll see:

<a href="http://itunes.apple.com/us/album/falling/id504779876?i=504779883&amp;uo=4" target="itunes_store" key="./8249795872/9273847591.">Falling</a> - *which doesn't completely give the url away

基本上我所做的是让链接看起来像是某种 API 密钥.很酷的事情是你不能直接从视图源或直接从 Web Inspector/Firebug 复制链接.它不是万无一失的,并且肯定会被破坏,但用户必须知道他们在做什么.它让大多数人远离,但仍然允许播放器获取播放歌曲所需的 url :)

Basically what I did was make the link look like it's an api-key of some-kind. The cool thing is that you can't just copy the link straight from view source or straight from Web Inspector/Firebug. It's not fool-proof, and can definitely be broken, but the user would have to know what they're doing. It keeps most people away, yet still allows the player to get the url it needs to play the song :)

*此外,我从 Stack Exchange 的某个地方获得了 php 混淆脚本,只是不确定在哪里.

*also, I got the php obfusticate script from somewhere on Stack Exchange, just not sure where.

这篇关于隐藏 MP3 完整网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆