File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- 2.9.2
1+ 2.9.3
222.9
332
Original file line number Diff line number Diff line change @@ -21,22 +21,27 @@ class Helper {
2121 * @param $link the url to follow its redirects
2222 */
2323 public static function getFinalUrl ( string $ link ) : string {
24- $ ch = curl_init ();
25-
26- curl_setopt ($ ch , CURLOPT_URL , $ link );
27- curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'HEAD ' );
28- curl_setopt ($ ch , CURLOPT_NOBODY , true );
29- curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true );
30-
31- if ( curl_exec ($ ch ) ){
32- $ url = curl_getinfo ($ ch , CURLINFO_EFFECTIVE_URL );
33- } else {
34- $ url = $ link ;
24+ if ( function_exists ('curl_init ' ) ){
25+ $ ch = curl_init ();
26+
27+ curl_setopt ($ ch , CURLOPT_URL , $ link );
28+ curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , 'HEAD ' );
29+ curl_setopt ($ ch , CURLOPT_NOBODY , true );
30+ curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true );
31+
32+ if ( curl_exec ($ ch ) ){
33+ $ url = curl_getinfo ($ ch , CURLINFO_EFFECTIVE_URL );
34+ } else {
35+ $ url = $ link ;
36+ }
37+
38+ curl_close ($ ch );
39+
40+ return $ url ;
3541 }
3642
37- curl_close ($ ch );
38-
39- return $ url ;
43+ error_log ("Warning: Please install CURL for better support of Proxy " );
44+ return $ link ;
4045 }
4146
4247 public static function checkFilename ( $ n ) : bool {
Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ public static function open( $url ){
114114
115115 if ( $ f !== false ){
116116 self ::sendHeader ($ header );
117+ // unset the execution limit (long time proxying)
118+ set_time_limit (0 );
119+ // while something to proxy and still a client
117120 while (!feof ($ f ) && !connection_aborted () ){
118121 echo fread ($ f , 128 );
119122 flush ();
Original file line number Diff line number Diff line change 5555 if ( !empty ($ url ) && filter_var ( $ url , FILTER_VALIDATE_URL ) !== false ){
5656 $ url = filter_var ($ url , FILTER_SANITIZE_URL ); //clean url
5757
58+ // the proxy does not support redirects!, so do them before
59+ $ url = Helper::getFinalUrl ($ url );
60+
5861 if (!DOCKER_MODE ){ // use a PHP based proxy
5962 SimpleProxy::open ( $ url );
6063 die ();
6164 }
6265
63- // the proxy does not support redirects!, so do them before
64- $ url = Helper::getFinalUrl ($ url );
65-
66-
6766 // get hostname and url parts before and after
6867 $ matches = array ();
6968 $ matchok = preg_match ( '/^(https?:\/\/)([^\/]+\.?[a-zA-Z]+)((?::[0-9]+)?(?:\/.*)?)$/ ' , $ url , $ matches ); // get host
You can’t perform that action at this time.
0 commit comments