回答編集履歴
1
test
CHANGED
@@ -1,73 +1,33 @@
|
|
1
1
|
まず、userというフォルダ内に[songs]等の適当なフォルダを新しく作ってください。
|
2
|
-
|
3
2
|
そこにuserの曲データをすべて格納させて、.htaccessファイルを作成後に以下を追加してください。
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
```lang-<ここに言語を入力>
|
8
|
-
|
9
4
|
Order Deny,Allow
|
10
|
-
|
11
5
|
Deny from all
|
12
|
-
|
13
|
-
```
|
14
|
-
|
15
|
-
|
16
6
|
|
17
7
|
これで外部からの直接接続を遮断出来るでしょう。
|
18
8
|
|
19
|
-
|
20
|
-
|
21
9
|
次に、曲データへのアクセス方法についてですが、
|
22
|
-
|
23
10
|
曲取得用のPHPスクリプトをuserフォルダ内に用意する方法はどうでしょうか?
|
24
11
|
|
25
|
-
|
26
|
-
|
27
|
-
```lang-<ここに言語を入力>
|
28
|
-
|
29
|
-
/*
|
12
|
+
/*
|
30
|
-
|
31
13
|
* ロジックサンプル
|
32
|
-
|
33
14
|
*/
|
34
15
|
|
35
|
-
|
36
|
-
|
37
16
|
if( !empty( $_GET['song_title'] )) //取得する曲名を確認
|
38
|
-
|
39
17
|
{
|
40
|
-
|
41
|
-
|
18
|
+
if(check_login()) //ログイン確認処理
|
42
|
-
|
43
|
-
|
19
|
+
{
|
44
|
-
|
45
|
-
|
20
|
+
$mp3_data = "{$_SERVER['DOCUMENT_ROOT']}/user/songs/{$_GET['song_title']}.mp3";
|
46
|
-
|
47
|
-
|
21
|
+
if( file_exists( $mp3_data ) )
|
48
|
-
|
49
|
-
|
22
|
+
{
|
50
|
-
|
51
|
-
|
23
|
+
header( 'Cache-Control: public' );
|
52
|
-
|
53
|
-
|
24
|
+
header( 'Content-Description: File Transfer' );
|
54
|
-
|
55
|
-
|
25
|
+
header( "Content-Disposition: attachment; filename={$mp3_data}" );
|
56
|
-
|
57
|
-
|
26
|
+
header( 'Content-Type: application/mp3' );
|
58
|
-
|
59
|
-
|
27
|
+
header( 'Content-Transfer-Encoding: binary' );
|
60
|
-
|
61
|
-
|
28
|
+
readfile( $mp3_data );
|
62
|
-
|
63
|
-
|
29
|
+
exit;
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
}
|
68
|
-
|
69
30
|
}
|
70
|
-
|
31
|
+
}
|
32
|
+
}
|
71
33
|
die( "ERROR発生");
|
72
|
-
|
73
|
-
```
|