4
4
5
5
// strip away extra parameters text/html; charset=UTF-8
6
6
function clean_content_type ($ content_type ){
7
- return preg_replace ('@;.*@ ' , '' , $ content_type );
7
+ return trim ( preg_replace ('@;.*@ ' , '' , $ content_type) );
8
8
}
9
9
10
10
function is_html ($ content_type ){
11
-
12
- $ content_type = clean_content_type ($ content_type );
13
-
14
- $ text = array (
15
- //'text/cmd',
16
- //'text/css',
17
- //'text/csv',
18
- //'text/example',
19
- 'text/html '
20
- //'text/javascript',
21
- //'text/plain',
22
- //'text/rtf',
23
- //'text/vcard',
24
- //'text/vnd.abc',
25
- //'text/xml'
26
- );
27
-
28
- return in_array ($ content_type , $ text );
11
+ return clean_content_type ($ content_type ) == 'text/html ' ;
29
12
}
30
13
31
- function base64_url_encode ($ input ){
32
- // = at the end is just padding to make the length of the str divisible by 4
33
- return rtrim (strtr (base64_encode ($ input ), '+/ ' , '-_ ' ), '= ' );
34
- }
35
-
36
- function base64_url_decode ($ input ){
37
- return base64_decode (str_pad (strtr ($ input , '-_ ' , '+/ ' ), strlen ($ input ) % 4 , '= ' , STR_PAD_RIGHT ));
14
+ function contains ($ haystack , $ needle ){
15
+ return strpos ($ haystack , $ needle ) !== false ;
38
16
}
39
17
40
18
function in_arrayi ($ needle , $ haystack ){
@@ -130,32 +108,37 @@ function time_ms(){
130
108
return round (microtime (true ) * 1000 );
131
109
}
132
110
133
- function contains ($ haystack , $ needle ){
134
- return strpos ($ haystack , $ needle ) !== false ;
111
+ function base64_url_encode ($ input ){
112
+ // = at the end is just padding to make the length of the str divisible by 4
113
+ return rtrim (strtr (base64_encode ($ input ), '+/ ' , '-_ ' ), '= ' );
135
114
}
136
115
137
- function base64_encrypt ($ data , $ key = false ){
116
+ function base64_url_decode ($ input ){
117
+ return base64_decode (str_pad (strtr ($ input , '-_ ' , '+/ ' ), strlen ($ input ) % 4 , '= ' , STR_PAD_RIGHT ));
118
+ }
119
+
120
+ function url_encrypt ($ url , $ key = false ){
138
121
139
122
if ($ key ){
140
- $ data = str_rot_pass ($ data , $ key );
123
+ $ url = str_rot_pass ($ url , $ key );
141
124
} else if (Config::get ('encryption_key ' )){
142
- $ data = str_rot_pass ($ data , Config::get ('encryption_key ' ));
125
+ $ url = str_rot_pass ($ url , Config::get ('encryption_key ' ));
143
126
}
144
127
145
- return base64_url_encode ($ data );
128
+ return Config:: get ( ' url_mode ' ) ? base64_url_encode ($ url ) : rawurlencode ( $ url );
146
129
}
147
130
148
- function base64_decrypt ( $ data , $ key = false ){
131
+ function url_decrypt ( $ url , $ key = false ){
149
132
150
- $ data = base64_url_decode ($ data );
133
+ $ url = Config:: get ( ' url_mode ' ) ? base64_url_decode ($ url ) : rawurldecode ( $ url );
151
134
152
135
if ($ key ){
153
- $ data = str_rot_pass ($ data , $ key , true );
136
+ $ url = str_rot_pass ($ url , $ key , true );
154
137
} else if (Config::get ('encryption_key ' )){
155
- $ data = str_rot_pass ($ data , Config::get ('encryption_key ' ), true );
138
+ $ url = str_rot_pass ($ url , Config::get ('encryption_key ' ), true );
156
139
}
157
140
158
- return $ data ;
141
+ return $ url ;
159
142
}
160
143
161
144
// www.youtube.com TO proxy-app.com/index.php?q=encrypt_url(www.youtube.com)
@@ -164,10 +147,11 @@ function proxify_url($url, $base_url = ''){
164
147
$ url = htmlspecialchars_decode ($ url );
165
148
166
149
if ($ base_url ){
150
+ $ base_url = add_http ($ base_url );
167
151
$ url = rel2abs ($ url , $ base_url );
168
152
}
169
153
170
- return app_url ().'?q= ' .base64_encrypt ($ url );
154
+ return app_url ().'?q= ' .url_encrypt ($ url );
171
155
}
172
156
173
157
function vid_player ($ url , $ width , $ height , $ extension = false ){
0 commit comments