Merge pull request #47 from qkqpttgf/master

pull
pull/98/head
Mr.Lin 2020-03-19 14:02:54 +08:00 committed by GitHub
commit 436b85ee18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 108 additions and 95 deletions

View File

@ -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>';
@ -1227,7 +1240,7 @@ function get_refresh_token()
$app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink);
$html = '
<form action="?AddDisk&install0" method="post" onsubmit="return notnull(this);">
'.getconstStr('OnedriveDiskTag').':<input type="text" name="disktag_add" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '" style="width:100%"><br>
'.getconstStr('OnedriveDiskTag').': ('.getConfig('disktag').')<input type="text" name="disktag_add" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '" style="width:100%"><br>
'.getconstStr('OnedriveDiskName').':<input type="text" name="diskname" placeholder="' . getconstStr('EnvironmentsDescription')['diskname'] . '" style="width:100%"><br>
Onedrive_Ver<br>
<label><input type="radio" name="Onedrive_ver" value="MS" checked>MS: '.getconstStr('OndriveVerMS').'</label><br>

View File

@ -2,7 +2,7 @@
<!DOCTYPE html>
<html lang="<?php echo $constStr['language']; ?>">
<head>
<title><?php echo $pretitle;?> - <?php echo $_SERVER['sitename'];?></title>
<title><?php echo $pretitle; if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) echo ' - ' . getConfig('diskname');?> - <?php echo $_SERVER['sitename'];?></title>
<meta charset=utf-8>
<meta http-equiv=X-UA-Compatible content="IE=edge">
<meta name=viewport content="width=device-width,initial-scale=1">