回答編集履歴

1

2015/02/12 03:03

投稿

aviva
aviva

スコア130

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
- if(check_login()) //ログイン確認処理
18
+ if(check_login()) //ログイン確認処理
42
-
43
- {
19
+ {
44
-
45
- $mp3_data = "{$_SERVER['DOCUMENT_ROOT']}/user/songs/{$_GET['song_title']}.mp3";
20
+ $mp3_data = "{$_SERVER['DOCUMENT_ROOT']}/user/songs/{$_GET['song_title']}.mp3";
46
-
47
- if( file_exists( $mp3_data ) )
21
+ if( file_exists( $mp3_data ) )
48
-
49
- {
22
+ {
50
-
51
- header( 'Cache-Control: public' );
23
+ header( 'Cache-Control: public' );
52
-
53
- header( 'Content-Description: File Transfer' );
24
+ header( 'Content-Description: File Transfer' );
54
-
55
- header( "Content-Disposition: attachment; filename={$mp3_data}" );
25
+ header( "Content-Disposition: attachment; filename={$mp3_data}" );
56
-
57
- header( 'Content-Type: application/mp3' );
26
+ header( 'Content-Type: application/mp3' );
58
-
59
- header( 'Content-Transfer-Encoding: binary' );
27
+ header( 'Content-Transfer-Encoding: binary' );
60
-
61
- readfile( $mp3_data );
28
+ readfile( $mp3_data );
62
-
63
- exit;
29
+ exit;
64
-
65
- }
66
-
67
- }
68
-
69
30
  }
70
-
31
+ }
32
+ }
71
33
  die( "ERROR発生");
72
-
73
- ```