try fix retry 3 time when net err
							parent
							
								
									634be28769
								
							
						
					
					
						commit
						89546eb76a
					
				| 
						 | 
				
			
			@ -255,7 +255,7 @@ function curl_request($url, $data = false, $headers = [])
 | 
			
		|||
    $response['body'] = curl_exec($ch);
 | 
			
		||||
    $response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
 | 
			
		||||
    curl_close($ch);
 | 
			
		||||
    if ($response['stat']==0) return curl_request($url, $data, $headers);
 | 
			
		||||
    //if ($response['stat']==0) return curl_request($url, $data, $headers);
 | 
			
		||||
    return $response;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -515,11 +515,11 @@ function main($path)
 | 
			
		|||
    $disktags = explode("|",getConfig('disktag'));
 | 
			
		||||
//    echo 'count$disk:'.count($disktags);
 | 
			
		||||
    if (count($disktags)>1) {
 | 
			
		||||
        if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['PHP_SELF'].'/'.$disktags[0]) ]);
 | 
			
		||||
        if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0]) ]);
 | 
			
		||||
        $_SERVER['disktag'] = $path;
 | 
			
		||||
        $pos = strpos($path, '/');
 | 
			
		||||
        if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos);
 | 
			
		||||
        if (!in_array($_SERVER['disktag'], $disktags)) return message('Please visit from <a href="'.$_SERVER['base_path'].'">Home Page</a>.', 'Error', 404);
 | 
			
		||||
        if (!in_array($_SERVER['disktag'], $disktags)) return message('<meta http-equiv="refresh" content="2;URL='.$_SERVER['base_path'].'">Please visit from <a href="'.$_SERVER['base_path'].'">Home Page</a>.', 'Error', 404);
 | 
			
		||||
        $path = substr($path, strlen('/'.$_SERVER['disktag']));
 | 
			
		||||
        if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path']. '/' . $_SERVER['disktag'] . '/');
 | 
			
		||||
    } else $_SERVER['disktag'] = $disktags[0];
 | 
			
		||||
| 
						 | 
				
			
			@ -672,7 +672,8 @@ function list_files($path)
 | 
			
		|||
    } else {
 | 
			
		||||
        $files = fetch_files($path);
 | 
			
		||||
    }
 | 
			
		||||
    if ( isset($files['folder']) || isset($files['file']) || isset($files['error']) ) {
 | 
			
		||||
    return $files;
 | 
			
		||||
    /*if ( isset($files['folder']) || isset($files['file']) || isset($files['error']) ) {
 | 
			
		||||
        return $files;
 | 
			
		||||
    } else {
 | 
			
		||||
        error_log( json_encode($files) . ' Network Error<br>' );
 | 
			
		||||
| 
						 | 
				
			
			@ -680,7 +681,7 @@ function list_files($path)
 | 
			
		|||
        if ($_SERVER['retry'] < 3) {
 | 
			
		||||
            return list_files($path);
 | 
			
		||||
        } else return $files;
 | 
			
		||||
    }
 | 
			
		||||
    }*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function adminform($name = '', $pass = '', $path = '')
 | 
			
		||||
| 
						 | 
				
			
			@ -950,7 +951,10 @@ function fetch_files($path = '/')
 | 
			
		|||
            if (substr($url,-1)=='/') $url=substr($url,0,-1);
 | 
			
		||||
        }
 | 
			
		||||
        $url .= '?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl)';
 | 
			
		||||
        while ($retry<3&&!$arr['stat']) {
 | 
			
		||||
            $arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']]);
 | 
			
		||||
            $retry++;
 | 
			
		||||
        }
 | 
			
		||||
        if ($arr['stat']<500) {
 | 
			
		||||
            $files = json_decode($arr['body'], true);
 | 
			
		||||
            // echo $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
 | 
			
		||||
| 
						 | 
				
			
			@ -972,8 +976,17 @@ function fetch_files($path = '/')
 | 
			
		|||
                $files['error']['stat'] = $arr['stat'];
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            error_log($arr['body']);
 | 
			
		||||
            $files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
 | 
			
		||||
            //error_log($arr['body']);
 | 
			
		||||
            $files = json_decode($arr['body'], true);
 | 
			
		||||
            if (isset($files['error'])) {
 | 
			
		||||
                $files['error']['stat'] = $arr['stat'];
 | 
			
		||||
            } else {
 | 
			
		||||
                $files['error']['stat'] = 503;
 | 
			
		||||
                $files['error']['code'] = 'unknownError';
 | 
			
		||||
                $files['error']['message'] = 'unknownError';
 | 
			
		||||
            }
 | 
			
		||||
            //$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
 | 
			
		||||
            //error_log(json_encode($files, JSON_PRETTY_PRINT));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1016,9 +1029,9 @@ function fetch_files_children($files, $path, $page)
 | 
			
		|||
                    if ($path !== '/') {
 | 
			
		||||
                        $url .= ':' . $path;
 | 
			
		||||
                        if (substr($url,-1)=='/') $url=substr($url,0,-1);
 | 
			
		||||
                        $url .= ':/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime';
 | 
			
		||||
                        $url .= ':/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl';
 | 
			
		||||
                    } else {
 | 
			
		||||
                        $url .= '/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime';
 | 
			
		||||
                        $url .= '/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl';
 | 
			
		||||
                    }
 | 
			
		||||
                    $children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
 | 
			
		||||
                    // echo $url . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue