Merge pull request #66 from qkqpttgf/master

pull/98/head
Mr.Lin 2020-04-05 17:19:55 +08:00 committed by GitHub
commit 2b0b299ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 103 additions and 53 deletions

View File

@ -13,7 +13,7 @@ $Base64Env = [
//'downloadencrypt', //'downloadencrypt',
//'function_name', // used in heroku. //'function_name', // used in heroku.
//'hideFunctionalityFile', //'hideFunctionalityFile',
//'language', //'timezone',
//'passfile', //'passfile',
'sitename', 'sitename',
//'theme', //'theme',
@ -26,7 +26,7 @@ $Base64Env = [
//'usesharepoint', //'usesharepoint',
'sharepointname', 'sharepointname',
'shareurl', 'shareurl',
'sharecookie', //'sharecookie',
'shareapiurl', 'shareapiurl',
//'siteid', //'siteid',
'public_path', 'public_path',
@ -45,7 +45,7 @@ $CommonEnv = [
'disktag', 'disktag',
'function_name', // used in heroku. 'function_name', // used in heroku.
'hideFunctionalityFile', 'hideFunctionalityFile',
//'language', 'timezone',
'passfile', 'passfile',
'sitename', 'sitename',
'theme', 'theme',
@ -62,7 +62,7 @@ $ShowedCommonEnv = [
//'disktag', //'disktag',
//'function_name', // used in heroku. //'function_name', // used in heroku.
'hideFunctionalityFile', 'hideFunctionalityFile',
//'language', 'timezone',
'passfile', 'passfile',
'sitename', 'sitename',
'theme', 'theme',
@ -81,7 +81,7 @@ $InnerEnv = [
'sharepointname', 'sharepointname',
'siteid', 'siteid',
'shareurl', 'shareurl',
'sharecookie', //'sharecookie',
'shareapiurl', 'shareapiurl',
'public_path', 'public_path',
'refresh_token', 'refresh_token',
@ -108,18 +108,65 @@ $ShowedInnerEnv = [
//'token_expires', //'token_expires',
]; ];
$timezones = array(
'-12'=>'Pacific/Kwajalein',
'-11'=>'Pacific/Samoa',
'-10'=>'Pacific/Honolulu',
'-9'=>'America/Anchorage',
'-8'=>'America/Los_Angeles',
'-7'=>'America/Denver',
'-6'=>'America/Mexico_City',
'-5'=>'America/New_York',
'-4'=>'America/Caracas',
'-3.5'=>'America/St_Johns',
'-3'=>'America/Argentina/Buenos_Aires',
'-2'=>'America/Noronha',
'-1'=>'Atlantic/Azores',
'0'=>'UTC',
'1'=>'Europe/Paris',
'2'=>'Europe/Helsinki',
'3'=>'Europe/Moscow',
'3.5'=>'Asia/Tehran',
'4'=>'Asia/Baku',
'4.5'=>'Asia/Kabul',
'5'=>'Asia/Karachi',
'5.5'=>'Asia/Calcutta', //Asia/Colombo
'6'=>'Asia/Dhaka',
'6.5'=>'Asia/Rangoon',
'7'=>'Asia/Bangkok',
'8'=>'Asia/Shanghai',
'9'=>'Asia/Tokyo',
'9.5'=>'Australia/Darwin',
'10'=>'Pacific/Guam',
'11'=>'Asia/Magadan',
'12'=>'Asia/Kamchatka'
);
function main($path) function main($path)
{ {
global $exts; global $exts;
global $constStr; global $constStr;
if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) $constStr['language'] = $_SERVER['firstacceptlanguage']; if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) {
$constStr['language'] = $_SERVER['firstacceptlanguage'];
} else {
$prelang = splitfirst($_SERVER['firstacceptlanguage'], '-')[0];
foreach ( array_keys($constStr['languages']) as $lang) {
if ($prelang == splitfirst($lang, '-')[0]) {
$constStr['language'] = $lang;
break;
}
}
}
if (isset($_COOKIE['language'])&&$_COOKIE['language']!='') $constStr['language'] = $_COOKIE['language']; if (isset($_COOKIE['language'])&&$_COOKIE['language']!='') $constStr['language'] = $_COOKIE['language'];
//if (!$constStr['language']) $constStr['language'] = getConfig('language'); //if (!$constStr['language']) $constStr['language'] = getConfig('language');
/*echo 'firstacceptlanguage:'.$_SERVER['firstacceptlanguage'].' /*echo 'firstacceptlanguage:'.$_SERVER['firstacceptlanguage'].'
'.'lan:'.$constStr['language'];*/ '.'lan:'.$constStr['language'];*/
if ($constStr['language']=='') $constStr['language'] = 'en-us'; if ($constStr['language']=='') $constStr['language'] = 'en-us';
$_SERVER['language'] = $constStr['language']; $_SERVER['language'] = $constStr['language'];
$_SERVER['timezone'] = getConfig('timezone');
if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone'];
if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0;
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
if (getConfig('admin')=='') return install(); if (getConfig('admin')=='') return install();
@ -546,7 +593,7 @@ function comppass($pass)
if ($_POST['password1'] !== '') if (md5($_POST['password1']) === $pass ) { if ($_POST['password1'] !== '') if (md5($_POST['password1']) === $pass ) {
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$_SERVER['Set-Cookie'] = 'password='.$pass.'; expires='.date(DATE_COOKIE,strtotime('+1hour')); $_SERVER['Set-Cookie'] = 'password='.$pass.'; expires='.date(DATE_COOKIE,strtotime('+1hour'));
date_default_timezone_set(get_timezone($_COOKIE['timezone'])); date_default_timezone_set(get_timezone($_SERVER['timezone']));
return 2; return 2;
} }
if ($_COOKIE['password'] !== '') if ($_COOKIE['password'] === $pass ) return 3; if ($_COOKIE['password'] !== '') if ($_COOKIE['password'] === $pass ) return 3;
@ -603,39 +650,7 @@ function gethiddenpass($path,$passfile)
function get_timezone($timezone = '8') function get_timezone($timezone = '8')
{ {
$timezones = array( global $timezones;
'-12'=>'Pacific/Kwajalein',
'-11'=>'Pacific/Samoa',
'-10'=>'Pacific/Honolulu',
'-9'=>'America/Anchorage',
'-8'=>'America/Los_Angeles',
'-7'=>'America/Denver',
'-6'=>'America/Mexico_City',
'-5'=>'America/New_York',
'-4'=>'America/Caracas',
'-3.5'=>'America/St_Johns',
'-3'=>'America/Argentina/Buenos_Aires',
'-2'=>'America/Noronha',
'-1'=>'Atlantic/Azores',
'0'=>'UTC',
'1'=>'Europe/Paris',
'2'=>'Europe/Helsinki',
'3'=>'Europe/Moscow',
'3.5'=>'Asia/Tehran',
'4'=>'Asia/Baku',
'4.5'=>'Asia/Kabul',
'5'=>'Asia/Karachi',
'5.5'=>'Asia/Calcutta', //Asia/Colombo
'6'=>'Asia/Dhaka',
'6.5'=>'Asia/Rangoon',
'7'=>'Asia/Bangkok',
'8'=>'Asia/Shanghai',
'9'=>'Asia/Tokyo',
'9.5'=>'Australia/Darwin',
'10'=>'Pacific/Guam',
'11'=>'Asia/Magadan',
'12'=>'Asia/Kamchatka'
);
if ($timezone=='') $timezone = '8'; if ($timezone=='') $timezone = '8';
return $timezones[$timezone]; return $timezones[$timezone];
} }
@ -1247,15 +1262,28 @@ function render_list($path = '', $files = '')
if ($path !== '/') { if ($path !== '/') {
if (isset($files['file'])) { if (isset($files['file'])) {
$pretitle = str_replace('&','&', $files['name']); $pretitle = str_replace('&','&', $files['name']);
$n_path=$pretitle; $n_path = $pretitle;
$tmp = splitlast(splitlast($path,'/')[0],'/');
if ($tmp[1]=='') {
$p_path = $tmp[0];
} else { } else {
$pretitle = substr($path,-1)=='/'?substr($path,0,-1):$path; $p_path = $tmp[1];
$n_path=substr($pretitle,strrpos($pretitle,'/')+1); }
$pretitle = substr($pretitle,1); } else {
if (substr($path,0,1)=='/') $pretitle = substr($path,1);
if (substr($path,-1)=='/') $pretitle = substr($path,0,-1);
$tmp=splitlast($pretitle,'/');
if ($tmp[1]=='') {
$n_path = $tmp[0];
} else {
$n_path = $tmp[1];
$tmp = splitlast($tmp[0],'/');
if ($tmp[1]=='') {
$p_path = $tmp[0];
} else {
$p_path = $tmp[1];
}
} }
if (strrpos($path,'/')!=0) {
$p_path=substr($path,0,strrpos($path,'/'));
$p_path=substr($p_path,strrpos($p_path,'/')+1);
} }
} else { } else {
$pretitle = getconstStr('Home'); $pretitle = getconstStr('Home');
@ -1265,7 +1293,7 @@ function render_list($path = '', $files = '')
$p_path=str_replace('&','&',$p_path); $p_path=str_replace('&','&',$p_path);
$pretitle = str_replace('%23','#',$pretitle); $pretitle = str_replace('%23','#',$pretitle);
$statusCode=200; $statusCode=200;
date_default_timezone_set(get_timezone($_COOKIE['timezone'])); date_default_timezone_set(get_timezone($_SERVER['timezone']));
@ob_start(); @ob_start();
$theme = getConfig('theme'); $theme = getConfig('theme');
@ -1462,6 +1490,7 @@ function EnvOpt($needUpdate = 0)
global $constStr; global $constStr;
global $ShowedCommonEnv; global $ShowedCommonEnv;
global $ShowedInnerEnv; global $ShowedInnerEnv;
global $timezones;
asort($ShowedCommonEnv); asort($ShowedCommonEnv);
asort($ShowedInnerEnv); asort($ShowedInnerEnv);
$html = '<title>OneManager '.getconstStr('Setup').'</title>'; $html = '<title>OneManager '.getconstStr('Setup').'</title>';
@ -1524,15 +1553,15 @@ function EnvOpt($needUpdate = 0)
<td colspan="2">'.getconstStr('PlatformConfig').'</td> <td colspan="2">'.getconstStr('PlatformConfig').'</td>
</tr>'; </tr>';
foreach ($ShowedCommonEnv as $key) { foreach ($ShowedCommonEnv as $key) {
if ($key=='language') { if ($key=='timezone') {
$html .= ' $html .= '
<tr> <tr>
<td><label>' . $key . '</label></td> <td><label>' . $key . '</label></td>
<td width=100%> <td width=100%>
<select name="' . $key .'">'; <select name="' . $key .'">';
foreach ($constStr['languages'] as $key1 => $value1) { foreach (array_keys($timezones) as $zone) {
$html .= ' $html .= '
<option value="'.$key1.'" '.($key1==getConfig($key)?'selected="selected"':'').'>'.$value1.'</option>'; <option value="'.$zone.'" '.($zone==getConfig($key)?'selected="selected"':'').'>'.$zone.'</option>';
} }
$html .= ' $html .= '
</select> </select>

View File

@ -107,6 +107,7 @@ function install()
if ($_POST['admin']!='') { if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin']; $tmp['admin'] = $_POST['admin'];
$tmp['language'] = $_POST['language']; $tmp['language'] = $_POST['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$APIKey = getConfig('APIKey'); $APIKey = getConfig('APIKey');
if ($APIKey=='') { if ($APIKey=='') {
$APIKey = $_POST['APIKey']; $APIKey = $_POST['APIKey'];
@ -147,6 +148,12 @@ language:<br>';
<input type="submit" value="'.getconstStr('Submit').'"> <input type="submit" value="'.getconstStr('Submit').'">
</form> </form>
<script> <script>
var nowtime= new Date();
var timezone = 0-nowtime.getTimezoneOffset()/60;
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie="timezone="+timezone+"; path=/; "+expires;
function changelanguage(str) function changelanguage(str)
{ {
document.cookie=\'language=\'+str+\'; path=/\'; document.cookie=\'language=\'+str+\'; path=/\';

View File

@ -119,7 +119,8 @@ function install()
if ($_GET['install2']) { if ($_GET['install2']) {
if ($_POST['admin']!='') { if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin']; $tmp['admin'] = $_POST['admin'];
$tmp['language'] = $_POST['language']; $tmp['language'] = $_COOKIE['language'];
$tmp['timezone'] = $_COOKIE['timezone'];
$response = setConfig($tmp); $response = setConfig($tmp);
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
@ -149,6 +150,12 @@ function install()
</form> </form>
</div> </div>
<script> <script>
var nowtime= new Date();
var timezone = 0-nowtime.getTimezoneOffset()/60;
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie="timezone="+timezone+"; path=/; "+expires;
function notnull(t) function notnull(t)
{ {
if (t.admin.value==\'\') { if (t.admin.value==\'\') {

View File

@ -141,6 +141,7 @@ function install()
//if ($_POST['admin']!='') { //if ($_POST['admin']!='') {
$tmp['language'] = $_POST['language']; $tmp['language'] = $_POST['language'];
$tmp['Region'] = $_POST['Region']; $tmp['Region'] = $_POST['Region'];
$tmp['timezone'] = $_COOKIE['timezone'];
$SecretId = getConfig('SecretId'); $SecretId = getConfig('SecretId');
if ($SecretId=='') { if ($SecretId=='') {
$SecretId = $_POST['SecretId']; $SecretId = $_POST['SecretId'];
@ -208,6 +209,12 @@ language:<br>';
<input type="submit" value="'.getconstStr('Submit').'"> <input type="submit" value="'.getconstStr('Submit').'">
</form> </form>
<script> <script>
var nowtime= new Date();
var timezone = 0-nowtime.getTimezoneOffset()/60;
var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString();
document.cookie="timezone="+timezone+"; path=/; "+expires;
function changelanguage(str) function changelanguage(str)
{ {
document.cookie=\'language=\'+str+\'; path=/\'; document.cookie=\'language=\'+str+\'; path=/\';