multy disks
							parent
							
								
									9f92652973
								
							
						
					
					
						commit
						73792a0fd4
					
				|  | @ -1,5 +1,15 @@ | ||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
|  | $commonEnv = [ | ||||||
|  |     //'admin',
 | ||||||
|  |     'adminloginpage', | ||||||
|  |     //'disktag',
 | ||||||
|  |     'language', | ||||||
|  |     'passfile', | ||||||
|  |     'sitename', | ||||||
|  |     'theme', | ||||||
|  | ]; | ||||||
|  | 
 | ||||||
| function getpath() | function getpath() | ||||||
| { | { | ||||||
|     $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/'); |     $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/'); | ||||||
|  | @ -7,7 +17,7 @@ function getpath() | ||||||
|     if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p); |     if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p); | ||||||
|     else $path = $_SERVER['REQUEST_URI']; |     else $path = $_SERVER['REQUEST_URI']; | ||||||
|     $path = path_format( substr($path, strlen($_SERVER['base_path'])) ); |     $path = path_format( substr($path, strlen($_SERVER['base_path'])) ); | ||||||
|     return $path; |     return substr($path, 1); | ||||||
|     //return spurlencode($path, '/');
 |     //return spurlencode($path, '/');
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -36,11 +46,77 @@ function getGET() | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | function getConfig($str, $disktag = '') | ||||||
|  | { | ||||||
|  |     global $innerEnv; | ||||||
|  |     //include 'config.php';
 | ||||||
|  |     if ($disktag=='') $disktag = $_SERVER['disktag']; | ||||||
|  |     $s = file_get_contents('config.php'); | ||||||
|  |     $configs = substr($s, 18, -2); | ||||||
|  |     if ($configs!='') { | ||||||
|  |         $envs = json_decode($configs, true); | ||||||
|  |         if (in_array($str, $innerEnv)) { | ||||||
|  |             if (isset($envs[$disktag][$str])) return $envs[$disktag][$str]; | ||||||
|  |         } else if (isset($envs[$str])) return $envs[$str]; | ||||||
|  |     } | ||||||
|  |     return ''; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function setConfig($arr, $disktag = '') | ||||||
|  | { | ||||||
|  |     global $innerEnv; | ||||||
|  |     if ($disktag=='') $disktag = $_SERVER['disktag']; | ||||||
|  |     //include 'config.php';
 | ||||||
|  |     $s = file_get_contents('config.php'); | ||||||
|  |     $configs = substr($s, 18, -2); | ||||||
|  |     if ($configs!='') $envs = json_decode($configs, true); | ||||||
|  |     $disktags = explode("|",getConfig('disktag')); | ||||||
|  |     //$indisk = 0;
 | ||||||
|  |     $operatedisk = 0; | ||||||
|  |     foreach ($arr as $k => $v) { | ||||||
|  |         if (in_array($k, $innerEnv)) { | ||||||
|  |             $envs[$disktag][$k] = $v; | ||||||
|  |             /*$diskconfig[$k] = $v; | ||||||
|  |             $indisk = 1;*/ | ||||||
|  |         } elseif ($k=='disktag_add') { | ||||||
|  |             array_push($disktags, $v); | ||||||
|  |             $operatedisk = 1; | ||||||
|  |         } elseif ($k=='disktag_del') { | ||||||
|  |             $disktags = array_diff($disktags, [ $v ]); | ||||||
|  |             $envs[$v] = ''; | ||||||
|  |             $operatedisk = 1; | ||||||
|  |         } else { | ||||||
|  |             $envs[$k] = $v; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     /*if ($indisk) { | ||||||
|  |         $diskconfig = array_filter($diskconfig, 'array_value_isnot_null'); | ||||||
|  |         ksort($diskconfig); | ||||||
|  |         $tmp[$disktag] = json_encode($diskconfig); | ||||||
|  |     }*/ | ||||||
|  |     if ($operatedisk) { | ||||||
|  |         $disktags = array_unique($disktags); | ||||||
|  |         foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|'; | ||||||
|  |         if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1); | ||||||
|  |         else $envs['disktag'] = ''; | ||||||
|  |     } | ||||||
|  |     $envs = array_filter($envs, 'array_value_isnot_null'); | ||||||
|  |     ksort($envs); | ||||||
|  |     //echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
 | ||||||
|  |     $prestr = '<?php $configs = \' | ||||||
|  | '; | ||||||
|  |     $aftstr = ' | ||||||
|  | \';'; | ||||||
|  |     return file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| function get_refresh_token() | function get_refresh_token() | ||||||
| { | { | ||||||
|     global $constStr; |     global $constStr; | ||||||
|     $url = path_format($_SERVER['PHP_SELF'] . '/'); |     $url = path_format($_SERVER['PHP_SELF'] . '/'); | ||||||
|     if ($_GET['authorization_code'] && isset($_GET['code'])) { |     if ($_GET['authorization_code'] && isset($_GET['code'])) { | ||||||
|  |         $_SERVER['disktag'] = $_COOKIE['disktag']; | ||||||
|  |         config_oauth(); | ||||||
|         $tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']); |         $tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']); | ||||||
|         if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true); |         if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true); | ||||||
|         if (isset($ret['refresh_token'])) { |         if (isset($ret['refresh_token'])) { | ||||||
|  | @ -57,24 +133,28 @@ function get_refresh_token() | ||||||
|         Add t1-t'.--$i.' to environments.*/ |         Add t1-t'.--$i.' to environments.*/ | ||||||
|             $str .= ' |             $str .= ' | ||||||
|         <textarea readonly style="width: 95%">' . $tmptoken . '</textarea><br><br> |         <textarea readonly style="width: 95%">' . $tmptoken . '</textarea><br><br> | ||||||
|         Adding refresh_token to Config. |         '.getconstStr('SavingToken').' | ||||||
|         <script> |         <script> | ||||||
|             var texta=document.getElementsByTagName(\'textarea\'); |             var texta=document.getElementsByTagName(\'textarea\'); | ||||||
|             for(i=0;i<texta.length;i++) { |             for(i=0;i<texta.length;i++) { | ||||||
|                 texta[i].style.height = texta[i].scrollHeight + \'px\'; |                 texta[i].style.height = texta[i].scrollHeight + \'px\'; | ||||||
|             } |             } | ||||||
|             document.cookie=\'language=; path=/\'; |             document.cookie=\'language=; path=/\'; | ||||||
|  |             document.cookie=\'disktag=; path=/\'; | ||||||
|         </script>'; |         </script>'; | ||||||
|             setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ]); |             setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ], $_COOKIE['disktag']); | ||||||
|             savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60); |             savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60); | ||||||
|             $str .= ' |             $str .= ' | ||||||
|             <meta http-equiv="refresh" content="5;URL=' . $url . '">'; |             <meta http-equiv="refresh" content="2;URL=' . $url . '">'; | ||||||
|             return message($str, getconstStr('WaitJumpIndex')); |             return message($str, getconstStr('WaitJumpIndex')); | ||||||
|         } |         } | ||||||
|         return message('<pre>' . $tmp['body'] . '</pre>', $tmp['stat']); |         return message('<pre>' . $tmp['body'] . '</pre>', $tmp['stat']); | ||||||
|         //return message('<pre>' . json_encode($ret, JSON_PRETTY_PRINT) . '</pre>', 500);
 |         //return message('<pre>' . json_encode($ret, JSON_PRETTY_PRINT) . '</pre>', 500);
 | ||||||
|     } |     } | ||||||
|     if ($_GET['install3']) { |     if ($_GET['install1']) { | ||||||
|  |         $_SERVER['disk_oprating'] = $_COOKIE['disktag']; | ||||||
|  |         $_SERVER['disktag'] = $_COOKIE['disktag']; | ||||||
|  |         config_oauth(); | ||||||
|         if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') { |         if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') { | ||||||
|             return message(' |             return message(' | ||||||
|     <a href="" id="a1">'.getconstStr('JumptoOffice').'</a> |     <a href="" id="a1">'.getconstStr('JumptoOffice').'</a> | ||||||
|  | @ -88,17 +168,20 @@ function get_refresh_token() | ||||||
|     ', getconstStr('Wait').' 1s', 201); |     ', getconstStr('Wait').' 1s', 201); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     if ($_GET['install2']) { |     if ($_GET['install0']) { | ||||||
|         // echo $_POST['Onedrive_ver'];
 |         if ($_POST['disktag_add']!='' && ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC')) { | ||||||
|         if ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC') { |             $_SERVER['disktag'] = $_COOKIE['disktag']; | ||||||
|  |             $tmp['disktag_add'] = $_POST['disktag_add']; | ||||||
|  |             $tmp['diskname'] = $_POST['diskname']; | ||||||
|             $tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; |             $tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; | ||||||
|             if ($_POST['Onedrive_ver']=='MSC') { |             if ($_POST['Onedrive_ver']=='MSC') { | ||||||
|                 $tmp['client_id'] = $_POST['client_id']; |                 $tmp['client_id'] = $_POST['client_id']; | ||||||
|                 $tmp['client_secret'] = $_POST['client_secret']; |                 $tmp['client_secret'] = equal_replace(base64_encode($_POST['client_secret'])); | ||||||
|  |                 //$_POST['client_secret'];
 | ||||||
|             } |             } | ||||||
|             $response = setConfig($tmp); |             $response = setConfig($tmp, $_COOKIE['disktag']); | ||||||
|             $title = getconstStr('MayinEnv'); |             $title = getconstStr('MayinEnv'); | ||||||
|             $html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?install3">'; |             $html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?AddDisk&install1">'; | ||||||
|             if (!$response) { |             if (!$response) { | ||||||
|                 $html = $response . '<br> |                 $html = $response . '<br> | ||||||
| Can not write config to file.<br> | Can not write config to file.<br> | ||||||
|  | @ -108,20 +191,17 @@ Can not write config to file.<br> | ||||||
|             return message($html, $title, 201); |             return message($html, $title, 201); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     if ($_GET['install1']) { | 
 | ||||||
|         if ($_POST['admin']!='') { |     if ($constStr['language']!='zh-cn') { | ||||||
|         $tmp['admin'] = $_POST['admin']; |         $linklang='en-us'; | ||||||
|         $tmp['language'] = $_POST['language']; |     } else $linklang='zh-cn'; | ||||||
|         $response = setConfig($tmp); |     $ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php"; | ||||||
|         if ($response) { |     $deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru); | ||||||
|             if ($constStr['language']!='zh-cn') { |     $app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink); | ||||||
|                 $linklang='en-us'; |     $html = ' | ||||||
|             } else $linklang='zh-cn'; |     <form action="?AddDisk&install0" method="post" onsubmit="return notnull(this);"> | ||||||
|             $ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php"; |         '.getconstStr('OnedriveDiskTag').':<input type="text" name="disktag_add"><br> | ||||||
|             $deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru); |         '.getconstStr('OnedriveDiskName').':<input type="text" name="diskname"><br> | ||||||
|             $app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink); |  | ||||||
|             $html = ' |  | ||||||
|     <form action="?install2" method="post"> |  | ||||||
|         Onedrive_Ver:<br> |         Onedrive_Ver:<br> | ||||||
|         <label><input type="radio" name="Onedrive_ver" value="MS" checked>MS: '.getconstStr('OndriveVerMS').'</label><br> |         <label><input type="radio" name="Onedrive_ver" value="MS" checked>MS: '.getconstStr('OndriveVerMS').'</label><br> | ||||||
|         <label><input type="radio" name="Onedrive_ver" value="CN">CN: '.getconstStr('OndriveVerCN').'</label><br> |         <label><input type="radio" name="Onedrive_ver" value="CN">CN: '.getconstStr('OndriveVerCN').'</label><br> | ||||||
|  | @ -133,38 +213,67 @@ Can not write config to file.<br> | ||||||
|             </div> |             </div> | ||||||
|         </label><br> |         </label><br> | ||||||
|         <input type="submit" value="'.getconstStr('Submit').'"> |         <input type="submit" value="'.getconstStr('Submit').'"> | ||||||
|     </form>'; |     </form> | ||||||
|             $title = 'Install'; |     <script> | ||||||
|         } else { |         function notnull(t) | ||||||
|             $html = $response . '<br> |         { | ||||||
|  |             if (t.disktag_add.value==\'\') { | ||||||
|  |                 alert(\'input Disk Tag\'); | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |             var reg = /^[a-zA-Z]([-_a-zA-Z0-9]{1,20})$/; | ||||||
|  |             if (!reg.test(t.disktag_add.value)) { | ||||||
|  |                 alert(\''.getconstStr('TagFormatAlert').'\'); | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |             document.cookie=\'disktag=\'+t.disktag_add.value+\'; path=/\'; | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  |     </script>'; | ||||||
|  |     $title = 'Bind Onedrive'; | ||||||
|  |     return message($html, $title, 201); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function install() | ||||||
|  | { | ||||||
|  |     global $constStr; | ||||||
|  |     if ($_GET['install1']) { | ||||||
|  |         if ($_POST['admin']!='') { | ||||||
|  |             $tmp['admin'] = $_POST['admin']; | ||||||
|  |             $tmp['language'] = $_POST['language']; | ||||||
|  |             $response = setConfig($tmp); | ||||||
|  |             if (!$response) { | ||||||
|  |                 $html = $response . '<br> | ||||||
| Can not write config to file.<br> | Can not write config to file.<br> | ||||||
| <button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>'; | <button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>'; | ||||||
|             $title = 'Error'; |                 $title = 'Error'; | ||||||
|         } |                 return message($html, $title, 201); | ||||||
|         return message($html, $title, 201); |             } else { | ||||||
|  |                 return output('Jump<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     if ($_GET['install0']) { |     if ($_GET['install0']) { | ||||||
|         if (!ConfigWriteable()) { |         if (!ConfigWriteable()) { | ||||||
|             $html .= 'Plase make sure the config.php is writeable. |             $html .= getconstStr('MakesuerWriteable'); | ||||||
| run Writeable.sh.'; |  | ||||||
|             $title = 'Error'; |             $title = 'Error'; | ||||||
|             return message($html, $title, 201); |             return message($html, $title, 201); | ||||||
|         } |         } | ||||||
|         if (!RewriteEngineOn()) { |         if (!RewriteEngineOn()) { | ||||||
|             $html .= 'Plase make sure the RewriteEngine is On.'; |             $html .= getconstStr('MakesuerRewriteOn'); | ||||||
|             $title = 'Error'; |             $title = 'Error'; | ||||||
|             return message($html, $title, 201); |             return message($html, $title, 201); | ||||||
|         } |         } | ||||||
|         $html .= ' |         $html .= ' | ||||||
|     <form action="?install1" method="post" onsubmit="return adminnotnull(this);"> |     <form action="?install1" method="post" onsubmit="return notnull(this);"> | ||||||
| language:<br>'; | language:<br>'; | ||||||
|         foreach ($constStr['languages'] as $key1 => $value1) { |         foreach ($constStr['languages'] as $key1 => $value1) { | ||||||
|             $html .= ' |             $html .= ' | ||||||
|         <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; |         <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; | ||||||
|         } |         } | ||||||
|         $html .= '<br> |         $html .= ' | ||||||
|         <label>admin:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br> |         <label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>'; | ||||||
|  |         $html .= ' | ||||||
|         <input type="submit" value="'.getconstStr('Submit').'"> |         <input type="submit" value="'.getconstStr('Submit').'"> | ||||||
|     </form> |     </form> | ||||||
|     <script> |     <script> | ||||||
|  | @ -173,7 +282,7 @@ language:<br>'; | ||||||
|             document.cookie=\'language=\'+str+\'; path=/\'; |             document.cookie=\'language=\'+str+\'; path=/\'; | ||||||
|             location.href = location.href; |             location.href = location.href; | ||||||
|         } |         } | ||||||
|         function adminnotnull(t) |         function notnull(t) | ||||||
|         { |         { | ||||||
|             if (t.admin.value==\'\') { |             if (t.admin.value==\'\') { | ||||||
|                 alert(\'input admin\'); |                 alert(\'input admin\'); | ||||||
|  | @ -185,7 +294,7 @@ language:<br>'; | ||||||
|         $title = getconstStr('SelectLanguage'); |         $title = getconstStr('SelectLanguage'); | ||||||
|         return message($html, $title, 201); |         return message($html, $title, 201); | ||||||
|     } |     } | ||||||
|     $html .= 'refresh_token not exist, <a href="?install0">click to install.</a>'; |     $html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind'); | ||||||
|     $title = 'Error'; |     $title = 'Error'; | ||||||
|     return message($html, $title, 201); |     return message($html, $title, 201); | ||||||
| } | } | ||||||
|  | @ -203,8 +312,7 @@ function ConfigWriteable() | ||||||
| function RewriteEngineOn() | function RewriteEngineOn() | ||||||
| { | { | ||||||
|     $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; |     $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; | ||||||
|     $tmpurl = $http_type . $_SERVER['SERVER_NAME']; |     $tmpurl = $http_type . $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT']; | ||||||
|     //if $_SERVER['SERVER_PORT']
 |  | ||||||
|     $tmpurl .= path_format($_SERVER['base_path'] . '/config.php'); |     $tmpurl .= path_format($_SERVER['base_path'] . '/config.php'); | ||||||
|     $tmp = curl_request($tmpurl); |     $tmp = curl_request($tmpurl); | ||||||
|     if ($tmp['stat']==200) return false; |     if ($tmp['stat']==200) return false; | ||||||
|  | @ -212,75 +320,14 @@ function RewriteEngineOn() | ||||||
|     return false; |     return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getConfig($str) |  | ||||||
| { |  | ||||||
|     //include 'config.php';
 |  | ||||||
|     $s = file_get_contents('config.php'); |  | ||||||
|     $configs = substr($s, 18, -2); |  | ||||||
|     if ($configs!='') { |  | ||||||
|         $envs = json_decode($configs, true); |  | ||||||
|         if (isset($envs[$str])) return $envs[$str]; |  | ||||||
|     } |  | ||||||
|     return ''; |  | ||||||
|     /* |  | ||||||
|     if (!class_exists('mydbreader')) { |  | ||||||
|         class mydbreader extends SQLite3 |  | ||||||
|         { |  | ||||||
|             function __construct() |  | ||||||
|             { |  | ||||||
|                 $this->open( __DIR__ .'/.ht.db'); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     $db = new mydbreader(); |  | ||||||
|     if(!$db){ |  | ||||||
|         echo $db->lastErrorMsg(); |  | ||||||
|     } else { |  | ||||||
|         //echo "Opened database successfully<br>\n";
 |  | ||||||
|         $id=rand(1,309); |  | ||||||
|         $sql="select * from config where id=".$str.";"; |  | ||||||
|         $ret = $db->query($sql); |  | ||||||
|         if(!$ret){ |  | ||||||
|             echo $db->lastErrorMsg(); |  | ||||||
|         } else { |  | ||||||
|             $row = $ret->fetchArray(SQLITE3_ASSOC); |  | ||||||
|             $value1 = $row['value']; |  | ||||||
|         } |  | ||||||
|         $db->close(); |  | ||||||
|     } |  | ||||||
|     return $value1; |  | ||||||
|     */ |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| function setConfig($arr) |  | ||||||
| { |  | ||||||
|     //include 'config.php';
 |  | ||||||
|     $s = file_get_contents('config.php'); |  | ||||||
|     $configs = substr($s, 18, -2); |  | ||||||
|     if ($configs!='') $envs = json_decode($configs, true); |  | ||||||
|     foreach ($arr as $k1 => $v1) { |  | ||||||
|         $envs[$k1] = $v1; |  | ||||||
|     } |  | ||||||
|     $envs = array_filter($envs, 'array_value_isnot_null'); |  | ||||||
|     ksort($envs); |  | ||||||
|     //echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
 |  | ||||||
|     $prestr = '<?php $configs = \' |  | ||||||
| '; |  | ||||||
|     $aftstr = ' |  | ||||||
| \';'; |  | ||||||
|     return file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| function EnvOpt($function_name, $needUpdate = 0) | function EnvOpt($function_name, $needUpdate = 0) | ||||||
| { | { | ||||||
|     global $constStr; |     global $constStr; | ||||||
|     $constEnv = [ |     global $commonEnv; | ||||||
|         //'admin',
 |     global $innerEnv; | ||||||
|         'adminloginpage', 'domain_path', 'guestup_path', 'passfile', |     global $ShowedinnerEnv; | ||||||
|         //'private_path', 
 |     asort($commonEnv); | ||||||
|         'public_path', 'sitename', 'language', 'theme' |     asort($ShowedinnerEnv); | ||||||
|     ]; |  | ||||||
|     asort($constEnv); |  | ||||||
|     $html = '<title>OneManager '.getconstStr('Setup').'</title>'; |     $html = '<title>OneManager '.getconstStr('Setup').'</title>'; | ||||||
|     /*if ($_POST['updateProgram']==getconstStr('updateProgram')) { |     /*if ($_POST['updateProgram']==getconstStr('updateProgram')) { | ||||||
|         $response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response']; |         $response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response']; | ||||||
|  | @ -300,13 +347,14 @@ namespace:' . $namespace . '<br> | ||||||
|         return message($html, $title); |         return message($html, $title); | ||||||
|     }*/ |     }*/ | ||||||
|     if ($_POST['submit1']) { |     if ($_POST['submit1']) { | ||||||
|  |         $_SERVER['disk_oprating'] = ''; | ||||||
|         foreach ($_POST as $k => $v) { |         foreach ($_POST as $k => $v) { | ||||||
|             if (in_array($k, $constEnv)) { |             if (in_array($k, $commonEnv)||in_array($k, $innerEnv)||$k=='disktag_del' || $k=='disktag_add') { | ||||||
|                 //if (!(getConfig($k)==''&&$v=='')) 
 |  | ||||||
|                 $tmp[$k] = $v; |                 $tmp[$k] = $v; | ||||||
|             } |             } | ||||||
|  |             if ($k == 'disk') $_SERVER['disk_oprating'] = $v; | ||||||
|         } |         } | ||||||
|         if ($tmp['domain_path']!='') { |         /*if ($tmp['domain_path']!='') { | ||||||
|             $tmp1 = explode("|",$tmp['domain_path']); |             $tmp1 = explode("|",$tmp['domain_path']); | ||||||
|             $tmparr = []; |             $tmparr = []; | ||||||
|             foreach ($tmp1 as $multidomain_paths){ |             foreach ($tmp1 as $multidomain_paths){ | ||||||
|  | @ -314,8 +362,8 @@ namespace:' . $namespace . '<br> | ||||||
|                 if ($pos>0) $tmparr[substr($multidomain_paths, 0, $pos)] = path_format(substr($multidomain_paths, $pos+1)); |                 if ($pos>0) $tmparr[substr($multidomain_paths, 0, $pos)] = path_format(substr($multidomain_paths, $pos+1)); | ||||||
|             } |             } | ||||||
|             $tmp['domain_path'] = $tmparr; |             $tmp['domain_path'] = $tmparr; | ||||||
|         } |         }*/ | ||||||
|         $response = setConfig($tmp); |         $response = setConfig($tmp, $_SERVER['disk_oprating']); | ||||||
|         if (!$response) { |         if (!$response) { | ||||||
|             $html = $response . '<br> |             $html = $response . '<br> | ||||||
| <button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>'; | <button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>'; | ||||||
|  | @ -330,7 +378,7 @@ namespace:' . $namespace . '<br> | ||||||
|         $preurl = path_format($_SERVER['PHP_SELF'] . '/'); |         $preurl = path_format($_SERVER['PHP_SELF'] . '/'); | ||||||
|     } |     } | ||||||
|     $html .= ' |     $html .= ' | ||||||
|         <a href="'.$preurl.'">'.getconstStr('Back').'</a>    |         <a href="'.$preurl.'">'.getconstStr('Back').'</a>   <a href="'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><br> | ||||||
|         <a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>'; |         <a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>'; | ||||||
|     /*if ($needUpdate) { |     /*if ($needUpdate) { | ||||||
|         $html .= '<pre>' . $_SERVER['github_version'] . '</pre> |         $html .= '<pre>' . $_SERVER['github_version'] . '</pre> | ||||||
|  | @ -340,10 +388,13 @@ namespace:' . $namespace . '<br> | ||||||
|     } else { |     } else { | ||||||
|         $html .= getconstStr('NotNeedUpdate'); |         $html .= getconstStr('NotNeedUpdate'); | ||||||
|     }*/ |     }*/ | ||||||
|     $html .= ' |     $html .= '<br> | ||||||
|     <form action="" method="post"> |     <table border=1 width=100%> | ||||||
|     <table border=1 width=100%>'; |     <form name="common" action="" method="post"> | ||||||
|     foreach ($constEnv as $key) { |         <tr> | ||||||
|  |             <td colspan="2">'.getconstStr('PlatformConfig').'</td> | ||||||
|  |         </tr>'; | ||||||
|  |     foreach ($commonEnv as $key) { | ||||||
|         if ($key=='language') { |         if ($key=='language') { | ||||||
|             $html .= ' |             $html .= ' | ||||||
|         <tr> |         <tr> | ||||||
|  | @ -392,8 +443,42 @@ namespace:' . $namespace . '<br> | ||||||
|             <td width=100%><input type="text" name="' . $key .'" value="' . getConfig($key) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td> |             <td width=100%><input type="text" name="' . $key .'" value="' . getConfig($key) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td> | ||||||
|         </tr>'; |         </tr>'; | ||||||
|     } |     } | ||||||
|     $html .= '</table> |     $html .= ' | ||||||
|     <input type="submit" name="submit1" value="'.getconstStr('Setup').'"> |         <tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr> | ||||||
|     </form>'; |     </form> | ||||||
|  |     </table><br>'; | ||||||
|  |     foreach (explode("|",getConfig('disktag')) as $disktag) { | ||||||
|  |         if ($disktag!='') { | ||||||
|  |             $html .= ' | ||||||
|  |     <table border=1 width=100%> | ||||||
|  |         <form action="" method="post"> | ||||||
|  |         <tr> | ||||||
|  |             <td colspan="2">'.$disktag.': | ||||||
|  |             <input type="hidden" name="disktag_del" value="'.$disktag.'"> | ||||||
|  |             <input type="submit" name="submit1" value="'.getconstStr('DelDisk').'"> | ||||||
|  |             </td> | ||||||
|  |         </tr> | ||||||
|  |         </form>'; | ||||||
|  |             if (getConfig('refresh_token', $disktag)!='') { | ||||||
|  |                 $html .= ' | ||||||
|  |         <form name="'.$disktag.'" action="" method="post"> | ||||||
|  |         <input type="hidden" name="disk" value="'.$disktag.'">'; | ||||||
|  |                 foreach ($ShowedinnerEnv as $key) { | ||||||
|  |                     $html .= ' | ||||||
|  |         <tr> | ||||||
|  |             <td><label>' . $key . '</label></td> | ||||||
|  |             <td width=100%><input type="text" name="' . $key .'" value="' . getConfig($key, $disktag) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td> | ||||||
|  |         </tr>'; | ||||||
|  |                 } | ||||||
|  |                 $html .= ' | ||||||
|  |         <tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr> | ||||||
|  |         </form>'; | ||||||
|  |             } | ||||||
|  |             $html .= ' | ||||||
|  |     </table><br>'; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     $html .= ' | ||||||
|  |     <a href="?AddDisk">'.getconstStr('AddDisk').'</a>'; | ||||||
|     return message($html, getconstStr('Setup')); |     return message($html, getconstStr('Setup')); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 qkqpttgf
						qkqpttgf