more smoothly in Adding Onedrive disk
parent
f2d53d45af
commit
1b8287062d
|
@ -446,7 +446,7 @@ class Onedrive {
|
||||||
|
|
||||||
$envs = '';
|
$envs = '';
|
||||||
foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', ';
|
foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', ';
|
||||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
$url = path_format($_SERVER['base_path'] . '/');
|
||||||
//$this->api_url = splitfirst($_SERVER['api_url'], '/v1.0')[0] . '/v1.0';
|
//$this->api_url = splitfirst($_SERVER['api_url'], '/v1.0')[0] . '/v1.0';
|
||||||
|
|
||||||
if (isset($_GET['Finish'])) {
|
if (isset($_GET['Finish'])) {
|
||||||
|
@ -478,8 +478,8 @@ class Onedrive {
|
||||||
} else {
|
} else {
|
||||||
return message($arr['stat'] . $arr['body'], 'Get User ID', $arr['stat']);
|
return message($arr['stat'] . $arr['body'], 'Get User ID', $arr['stat']);
|
||||||
}*/
|
}*/
|
||||||
if (get_class($this)=='Sharepoint') $tmp['Driver'] = 'Onedrive';
|
if ($tmp['Driver']=='Sharepoint') $tmp['Driver'] = 'Onedrive';
|
||||||
elseif (get_class($this)=='SharepointCN') $tmp['Driver'] = 'OnedriveCN';
|
elseif ($tmp['Driver']=='SharepointCN') $tmp['Driver'] = 'OnedriveCN';
|
||||||
$tmp['sharepointSite'] = '';
|
$tmp['sharepointSite'] = '';
|
||||||
$tmp['siteid'] = '';
|
$tmp['siteid'] = '';
|
||||||
} elseif ($_POST['DriveType']=='Custom') {
|
} elseif ($_POST['DriveType']=='Custom') {
|
||||||
|
@ -492,14 +492,14 @@ class Onedrive {
|
||||||
//if ($arr['stat']!=200) return message($arr['stat'] . $arr['body'], 'Get Sharepoint Drive ID ' . $_POST['DriveType'], $arr['stat']);
|
//if ($arr['stat']!=200) return message($arr['stat'] . $arr['body'], 'Get Sharepoint Drive ID ' . $_POST['DriveType'], $arr['stat']);
|
||||||
$tmp['siteid'] = $siteid;
|
$tmp['siteid'] = $siteid;
|
||||||
$tmp['sharepointSite'] = $_POST['sharepointSite'];
|
$tmp['sharepointSite'] = $_POST['sharepointSite'];
|
||||||
if (get_class($this)=='Onedrive') $tmp['Driver'] = 'Sharepoint';
|
if ($tmp['Driver']=='Onedrive') $tmp['Driver'] = 'Sharepoint';
|
||||||
elseif (get_class($this)=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
|
elseif ($tmp['Driver']=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
|
||||||
} else {
|
} else {
|
||||||
// 直接是siteid
|
// 直接是siteid
|
||||||
$tmp['siteid'] = $_POST['DriveType'];
|
$tmp['siteid'] = $_POST['DriveType'];
|
||||||
$tmp['sharepointSite'] = $_POST['sharepointSiteUrl'];
|
$tmp['sharepointSite'] = $_POST['sharepointSiteUrl'];
|
||||||
if (get_class($this)=='Onedrive') $tmp['Driver'] = 'Sharepoint';
|
if ($tmp['Driver']=='Onedrive') $tmp['Driver'] = 'Sharepoint';
|
||||||
elseif (get_class($this)=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
|
elseif ($tmp['Driver']=='OnedriveCN') $tmp['Driver'] = 'SharepointCN';
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
|
$response = setConfigResponse( setConfig($tmp, $this->disktag) );
|
||||||
|
@ -520,11 +520,11 @@ class Onedrive {
|
||||||
console.log(i++);
|
console.log(i++);
|
||||||
} else {
|
} else {
|
||||||
clearInterval(uploadList);
|
clearInterval(uploadList);
|
||||||
location.href = "' . $url . '";
|
location.href = "' . $url . '?setup&disktag=' . $_GET['disktag'] . '";
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
</script>';
|
</script>';
|
||||||
return message($html, getconstStr('WaitJumpIndex'), 201, 1);
|
return message($html, getconstStr('Wait'), 201, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,12 +554,13 @@ class Onedrive {
|
||||||
$title = 'Select Driver';
|
$title = 'Select Driver';
|
||||||
$html = '
|
$html = '
|
||||||
<div>
|
<div>
|
||||||
<form action="?Finish&disktag=' . $_GET['disktag'] . '&AddDisk=' . get_class($this) . '" method="post" onsubmit="return notnull(this);">
|
<form name="form1" action="?Finish&disktag=' . $_GET['disktag'] . '&AddDisk=' . get_class($this) . '" method="post" onsubmit="return notnull(this);">
|
||||||
<label><input type="radio" name="DriveType" value="Onedrive" checked>' . 'Use Onedrive ' . getconstStr(' ') . '</label><br>';
|
<label><input type="radio" name="DriveType" value="Onedrive">' . 'Use Onedrive ' . getconstStr(' ') . '</label><br>';
|
||||||
if ($sites[0]!='') foreach ($sites as $k => $v) {
|
if ($sites[0]!='') foreach ($sites as $k => $v) {
|
||||||
$html .= '
|
$html .= '
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" name="DriveType" value="' . $v['id'] . '" onclick="document.getElementById(\'sharepointSiteUrl\').value=\'' . $v['webUrl'] . '\';">' . 'Use Sharepoint: <br><div style="width:100%;margin:0px 35px">webUrl: ' . $v['webUrl'] . '<br>siteid: ' . $v['id'] . '</div>
|
<input type="radio" name="DriveType" value="' . $v['id'] . '" onclick="document.getElementById(\'sharepointSiteUrl\').value=\'' . $v['webUrl'] . '\';">' . 'Use Sharepoint: <br><div style="width:100%;margin:0px 35px">webUrl: ' . $v['webUrl'] . '<br>siteid: ' . $v['id'] . '</div>
|
||||||
|
<input type="hidden" id="' . $v['id'] . '" name="' . $v['id'] . '" value="' . $v['webUrl'] . '">
|
||||||
</label>';
|
</label>';
|
||||||
}
|
}
|
||||||
$html .= '
|
$html .= '
|
||||||
|
@ -576,22 +577,42 @@ class Onedrive {
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
function notnull(t)
|
var driver = "' . $_GET['AddDisk'] . '";
|
||||||
{
|
if (driver=="Onedrive"||driver=="OnedriveCN") {
|
||||||
if (t.DriveType.value==\'\') {
|
document.form1.DriveType[0].checked = true;
|
||||||
alert(\'Select a Disk\');
|
} else {
|
||||||
return false;
|
var siteid = "' . getConfig('siteid', $this->disktag) . '";
|
||||||
}
|
if (siteid==="") {
|
||||||
if (t.DriveType.value==\'Custom\') {
|
document.form1.DriveType[document.form1.DriveType.length-1].checked = true;
|
||||||
if (t.sharepointSite.value==\'\') {
|
} else {
|
||||||
alert(\'sharepoint Site Address\');
|
for (i=0; i<document.form1.DriveType.length; i++) {
|
||||||
return false;
|
if (document.form1.DriveType[i].value==siteid) {
|
||||||
|
document.form1.DriveType[i].checked = true;
|
||||||
|
document.getElementById(\'sharepointSiteUrl\').value = document.getElementById(siteid).value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
if (document.getElementById(\'sharepointSiteUrl\').value=="") {
|
||||||
|
document.form1.DriveType[document.form1.DriveType.length-1].checked = true;
|
||||||
|
document.getElementById(\'sharepointSite\').value = "' . getConfig('sharepointSite', $this->disktag) . '";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
}
|
||||||
';
|
function notnull(t)
|
||||||
|
{
|
||||||
|
if (t.DriveType.value==\'\') {
|
||||||
|
alert(\'Select a Disk\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (t.DriveType.value==\'Custom\') {
|
||||||
|
if (t.sharepointSite.value==\'\') {
|
||||||
|
alert(\'sharepoint Site Address\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
';
|
||||||
return message($html, $title, 201);
|
return message($html, $title, 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,7 +632,7 @@ class Onedrive {
|
||||||
texta[i].style.height = texta[i].scrollHeight + \'px\';
|
texta[i].style.height = texta[i].scrollHeight + \'px\';
|
||||||
}
|
}
|
||||||
</script>';
|
</script>';
|
||||||
$tmptoken['Driver'] = get_class($this);
|
$tmptoken['Driver'] = $_GET['AddDisk'];
|
||||||
$tmptoken['refresh_token'] = $refresh_token;
|
$tmptoken['refresh_token'] = $refresh_token;
|
||||||
$tmptoken['token_expires'] = time()+7*24*60*60;
|
$tmptoken['token_expires'] = time()+7*24*60*60;
|
||||||
$response = setConfigResponse( setConfig($tmptoken, $this->disktag) );
|
$response = setConfigResponse( setConfig($tmptoken, $this->disktag) );
|
||||||
|
@ -629,7 +650,7 @@ class Onedrive {
|
||||||
console.log(i++);
|
console.log(i++);
|
||||||
} else {
|
} else {
|
||||||
clearInterval(uploadList);
|
clearInterval(uploadList);
|
||||||
location.href = "' . $url . '?AddDisk=' . get_class($this) . '&disktag=' . $_GET['disktag'] . '&SelectDrive";
|
location.href = "' . $url . '?AddDisk=' . $_GET['AddDisk'] . '&disktag=' . $_GET['disktag'] . '&SelectDrive";
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
</script>';
|
</script>';
|
||||||
|
@ -641,7 +662,7 @@ class Onedrive {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['install1'])) {
|
if (isset($_GET['install1'])) {
|
||||||
if (get_class($this)=='Onedrive' || get_class($this)=='OnedriveCN') {
|
//if (get_class($this)=='Onedrive' || get_class($this)=='OnedriveCN') {
|
||||||
return message('
|
return message('
|
||||||
<a href="" id="a1">' . getconstStr('JumptoOffice') . '</a>
|
<a href="" id="a1">' . getconstStr('JumptoOffice') . '</a>
|
||||||
<script>
|
<script>
|
||||||
|
@ -652,9 +673,9 @@ class Onedrive {
|
||||||
location.href = url;
|
location.href = url;
|
||||||
</script>
|
</script>
|
||||||
', getconstStr('Wait') . ' 1s', 201);
|
', getconstStr('Wait') . ' 1s', 201);
|
||||||
} else {
|
//} else {
|
||||||
return message('Something error, retry after a few seconds.', 'Retry', 201);
|
// return message('Something error, retry after a few seconds.', 'Retry', 201);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['install0'])) {
|
if (isset($_GET['install0'])) {
|
||||||
|
@ -681,7 +702,8 @@ class Onedrive {
|
||||||
//$this->disktag = $_POST['disktag_add'];
|
//$this->disktag = $_POST['disktag_add'];
|
||||||
$tmp['disktag_add'] = $_POST['disktag_add'];
|
$tmp['disktag_add'] = $_POST['disktag_add'];
|
||||||
$tmp['diskname'] = $_POST['diskname'];
|
$tmp['diskname'] = $_POST['diskname'];
|
||||||
$tmp['Driver'] = $_POST['Drive_ver'];
|
//$tmp['Driver'] = $_POST['Drive_ver'];
|
||||||
|
$tmp['Driver'] = $_GET['AddDisk'];
|
||||||
if ($_POST['Drive_ver']=='Sharelink') {
|
if ($_POST['Drive_ver']=='Sharelink') {
|
||||||
$tmp['shareurl'] = $_POST['shareurl'];
|
$tmp['shareurl'] = $_POST['shareurl'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -701,7 +723,7 @@ class Onedrive {
|
||||||
} else {
|
} else {
|
||||||
$title = getconstStr('MayinEnv');
|
$title = getconstStr('MayinEnv');
|
||||||
$html = getconstStr('Wait');
|
$html = getconstStr('Wait');
|
||||||
if ($_POST['Drive_ver']!='Sharelink') $url .= '?install1&disktag=' . $_GET['disktag'] . '&AddDisk=' . $_POST['Drive_ver'];
|
if ($_POST['Drive_ver']!='Sharelink') $url .= '?install1&disktag=' . $_GET['disktag'] . '&AddDisk=' . $_GET['AddDisk'];
|
||||||
$html .= '<script>
|
$html .= '<script>
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var status = "' . $response['DplStatus'] . '";
|
var status = "' . $response['DplStatus'] . '";
|
||||||
|
@ -722,7 +744,7 @@ class Onedrive {
|
||||||
|
|
||||||
$html = '
|
$html = '
|
||||||
<div>
|
<div>
|
||||||
<form id="form1" action="" method="post" onsubmit="return notnull(this);">
|
<form id="form1" name="form1" action="" method="post" onsubmit="return notnull(this);">
|
||||||
' . getconstStr('DiskTag') . ': (' . getConfig('disktag') . ')
|
' . getconstStr('DiskTag') . ': (' . getConfig('disktag') . ')
|
||||||
<input type="text" name="disktag_add" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '" style="width:100%"><br>
|
<input type="text" name="disktag_add" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '" style="width:100%"><br>
|
||||||
' . getconstStr('DiskName') . ':
|
' . getconstStr('DiskName') . ':
|
||||||
|
@ -762,6 +784,21 @@ class Onedrive {
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
var driver = "' . get_class($this) . '";
|
||||||
|
if (driver=="Onedrive" || driver=="Sharepoint") {
|
||||||
|
document.form1.Drive_ver[0].checked = true;
|
||||||
|
document.getElementById(\'NT_custom\').style.display=\'\';
|
||||||
|
//document.getElementById(\'CN_custom\').style.display=\'\';
|
||||||
|
//document.getElementById(\'inputshareurl\').style.display=\'none\';
|
||||||
|
}
|
||||||
|
if (driver=="OnedriveCN" || driver=="SharepointCN") {
|
||||||
|
document.form1.Drive_ver[1].checked = true;
|
||||||
|
document.getElementById(\'CN_custom\').style.display=\'\';
|
||||||
|
}
|
||||||
|
if (driver=="Sharelink") {
|
||||||
|
document.form1.Drive_ver[2].checked = true;
|
||||||
|
document.getElementById(\'inputshareurl\').style.display=\'\';
|
||||||
|
}
|
||||||
function notnull(t)
|
function notnull(t)
|
||||||
{
|
{
|
||||||
if (t.disktag_add.value==\'\') {
|
if (t.disktag_add.value==\'\') {
|
||||||
|
@ -770,7 +807,7 @@ class Onedrive {
|
||||||
}
|
}
|
||||||
envs = [' . $envs . '];
|
envs = [' . $envs . '];
|
||||||
if (envs.indexOf(t.disktag_add.value)>-1) {
|
if (envs.indexOf(t.disktag_add.value)>-1) {
|
||||||
alert("Do not input ' . $envs . '");
|
alert("Do not input \"" + t.disktag_add.value + "\" in ' . getconstStr('DiskTag') . '");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
|
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
|
||||||
|
@ -787,25 +824,28 @@ class Onedrive {
|
||||||
alert(\'shareurl\');
|
alert(\'shareurl\');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
driver = \'Sharelink\';
|
||||||
} else {
|
} else {
|
||||||
if ((t.Drive_ver.value==\'Onedrive\') && t.NT_Drive_custom.checked==true) {
|
if (t.Drive_ver.value==\'Onedrive\') {
|
||||||
if (t.NT_client_secret.value==\'\'||t.NT_client_id.value==\'\') {
|
if (t.NT_Drive_custom.checked==true) {
|
||||||
alert(\'client_id & client_secret\');
|
if (t.NT_client_secret.value==\'\'||t.NT_client_id.value==\'\') {
|
||||||
return false;
|
alert(\'client_id & client_secret\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (driver!="Onedrive" && driver!="Sharepoint") driver = "Onedrive";
|
||||||
}
|
}
|
||||||
if ((t.Drive_ver.value==\'OnedriveCN\') && t.CN_Drive_custom.checked==true) {
|
if (t.Drive_ver.value==\'OnedriveCN\') {
|
||||||
if (t.CN_client_secret.value==\'\'||t.CN_client_id.value==\'\') {
|
if (t.CN_Drive_custom.checked==true) {
|
||||||
alert(\'client_id & client_secret\');
|
if (t.CN_client_secret.value==\'\'||t.CN_client_id.value==\'\') {
|
||||||
return false;
|
alert(\'client_id & client_secret\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (driver!="OnedriveCN" && driver!="SharepointCN") driver = "OnedriveCN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.getElementById("form1").action="?install0&disktag=" + t.disktag_add.value + "&AddDisk=" + t.Drive_ver.value;
|
document.getElementById("form1").action="?install0&disktag=" + t.disktag_add.value + "&AddDisk=" + driver;
|
||||||
//var expd = new Date();
|
|
||||||
//expd.setTime(expd.getTime()+(2*60*60*1000));
|
|
||||||
//var expires = "expires="+expd.toGMTString();
|
|
||||||
//document.cookie=\'disktag=\'+t.disktag_add.value+\'; path=/; \'+expires;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
</script>';
|
</script>';
|
||||||
|
|
Loading…
Reference in New Issue