refer
This commit is contained in:
+58
-87
@@ -36,6 +36,7 @@ $EnvConfigs = [
|
||||
'customTheme' => 0b011,
|
||||
'theme' => 0b010,
|
||||
'dontBasicAuth' => 0b010,
|
||||
'referrer' => 0b011,
|
||||
|
||||
'Driver' => 0b100,
|
||||
'client_id' => 0b100,
|
||||
@@ -254,6 +255,8 @@ function main($path)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isreferhost()) return message('Must visit from designated host', 'NOT_ALLOWED', 403);
|
||||
|
||||
// Show disks in root
|
||||
if ($files['showname'] == 'root') return render_list($path, $files);
|
||||
|
||||
@@ -419,6 +422,19 @@ function extendShow_diskenv($drive)
|
||||
return $drive->ext_show_innerenv();
|
||||
}
|
||||
|
||||
function isreferhost() {
|
||||
$referer = $_SERVER['referhost'];
|
||||
if ($referer=='') return true;
|
||||
if ($referer==$_SERVER['HTTP_HOST']) return true;
|
||||
$referrer = getConfig('referrer');
|
||||
if ($referrer=='') return true;
|
||||
$arr = explode('|', $referrer);
|
||||
foreach ($arr as $host) {
|
||||
if ($host == $referer) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function pass2cookie($name, $pass)
|
||||
{
|
||||
return md5($name . ':' . md5($pass));
|
||||
@@ -533,7 +549,7 @@ function getListpath($domain)
|
||||
}
|
||||
}
|
||||
if (isset($domain_path[$domain])) return spurlencode($domain_path[$domain],'/');
|
||||
return spurlencode($public_path,'/');
|
||||
return spurlencode($public_path, '/');
|
||||
}
|
||||
|
||||
function path_format($path)
|
||||
@@ -639,44 +655,6 @@ function curl($method, $url, $data = '', $headers = [], $returnheader = 0)
|
||||
return $response;
|
||||
}
|
||||
|
||||
function curl_request($url, $data = false, $headers = [], $returnheader = 0)
|
||||
{
|
||||
if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
|
||||
//if (!isset($headers['Referer'])) $headers['Referer'] = $url;
|
||||
//if (!isset($headers['Content-Type'])) $headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
$sendHeaders = array();
|
||||
foreach ($headers as $headerName => $headerVal) {
|
||||
$sendHeaders[] = $headerName . ': ' . $headerVal;
|
||||
}
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if ($data !== false) {
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, $returnheader);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
|
||||
//$response['body'] = curl_exec($ch);
|
||||
if ($returnheader) {
|
||||
list($returnhead, $response['body']) = explode("\r\n\r\n", curl_exec($ch));
|
||||
foreach (explode("\r\n", $returnhead) as $head) {
|
||||
$tmp = explode(': ', $head);
|
||||
$heads[$tmp[0]] = $tmp[1];
|
||||
}
|
||||
$response['returnhead'] = $heads;
|
||||
} else {
|
||||
$response['body'] = curl_exec($ch);
|
||||
}
|
||||
$response['stat'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function clearbehindvalue($path,$page1,$maxpage,$pageinfocache)
|
||||
{
|
||||
for ($page=$page1+1;$page<$maxpage;$page++) {
|
||||
@@ -776,6 +754,7 @@ function message($message, $title = 'Message', $statusCode = 200)
|
||||
<meta name=viewport content="width=device-width,initial-scale=1">
|
||||
<body>
|
||||
<h1>' . $title . '</h1>
|
||||
<a href="' . $_SERVER['base_path'] . '">' . getconstStr('Back') . getconstStr('Home') . '</a>
|
||||
<p>
|
||||
|
||||
' . $message . '
|
||||
@@ -814,8 +793,9 @@ function needUpdate()
|
||||
|
||||
function output($body, $statusCode = 200, $headers = ['Content-Type' => 'text/html'], $isBase64Encoded = false)
|
||||
{
|
||||
//$headers['Referrer-Policy'] = 'same-origin';
|
||||
$headers['Referrer-Policy'] = 'no-referrer';
|
||||
if (isset($_SERVER['Set-Cookie'])) $headers['Set-Cookie'] = $_SERVER['Set-Cookie'];
|
||||
$headers['Referrer-Policy'] = 'no-referrer'; //$headers['Referrer-Policy'] = 'same-origin';
|
||||
$headers['X-Frame-Options'] = 'sameorigin';
|
||||
return [
|
||||
'isBase64Encoded' => $isBase64Encoded,
|
||||
'statusCode' => $statusCode,
|
||||
@@ -874,12 +854,8 @@ function adminform($name = '', $pass = '', $path = '')
|
||||
<body>' . getconstStr('LoginSuccess') . '</body></html>';
|
||||
$statusCode = 201;
|
||||
date_default_timezone_set('UTC');
|
||||
$header = [
|
||||
'Set-Cookie' => $name . '=' . $pass . '; path=/; expires=' . date(DATE_COOKIE, strtotime('+7day')),
|
||||
//'Location' => $path,
|
||||
'Content-Type' => 'text/html'
|
||||
];
|
||||
return output($html, $statusCode, $header);
|
||||
$_SERVER['Set-Cookie'] = $name . '=' . $pass . '; path=/; expires=' . date(DATE_COOKIE, strtotime('+7day'));
|
||||
return output($html, $statusCode);
|
||||
}
|
||||
$statusCode = 401;
|
||||
$html .= '
|
||||
@@ -1059,7 +1035,8 @@ function EnvOpt($needUpdate = 0)
|
||||
global $drive;
|
||||
ksort($EnvConfigs);
|
||||
$envs = '';
|
||||
foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', ';
|
||||
//foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', ';
|
||||
$envs = substr(json_encode(array_keys ($EnvConfigs)), 1, -1);
|
||||
|
||||
$html = '<title>OneManager '.getconstStr('Setup').'</title>';
|
||||
if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) {
|
||||
@@ -1127,7 +1104,7 @@ function EnvOpt($needUpdate = 0)
|
||||
$preurl = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
}
|
||||
$html .= '
|
||||
<a href="'.$preurl.'">'.getconstStr('Back').'</a> <a href="'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><br>
|
||||
<a href="'.$preurl.'">'.getconstStr('Back').'</a><br>
|
||||
<a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>';
|
||||
|
||||
$html .= '
|
||||
@@ -1137,11 +1114,12 @@ function EnvOpt($needUpdate = 0)
|
||||
<td colspan="2">'.getconstStr('PlatformConfig').'</td>
|
||||
</tr>';
|
||||
foreach ($EnvConfigs as $key => $val) if (isCommonEnv($key) && isShowedEnv($key)) {
|
||||
if ($key=='timezone') {
|
||||
$html .= '
|
||||
$html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%>
|
||||
<td width=100%>';
|
||||
if ($key=='timezone') {
|
||||
$html .= '
|
||||
<select name="' . $key .'">';
|
||||
foreach (array_keys($timezones) as $zone) {
|
||||
$html .= '
|
||||
@@ -1149,15 +1127,10 @@ function EnvOpt($needUpdate = 0)
|
||||
}
|
||||
$html .= '
|
||||
</select>
|
||||
'.getconstStr('EnvironmentsDescription')[$key].'
|
||||
</td>
|
||||
</tr>';
|
||||
' . getconstStr('EnvironmentsDescription')[$key];
|
||||
} elseif ($key=='theme') {
|
||||
$theme_arr = scandir(__DIR__ . $slash . 'theme');
|
||||
$html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%>
|
||||
<select name="' . $key .'">
|
||||
<option value=""></option>';
|
||||
foreach ($theme_arr as $v1) {
|
||||
@@ -1166,9 +1139,7 @@ function EnvOpt($needUpdate = 0)
|
||||
}
|
||||
$html .= '
|
||||
</select>
|
||||
'.getconstStr('EnvironmentsDescription')[$key].'
|
||||
</td>
|
||||
</tr>';
|
||||
' . getconstStr('EnvironmentsDescription')[$key];
|
||||
} /*elseif ($key=='domain_path') {
|
||||
$tmp = getConfig($key);
|
||||
$domain_path = '';
|
||||
@@ -1182,13 +1153,13 @@ function EnvOpt($needUpdate = 0)
|
||||
<td width=100%><input type="text" name="' . $key .'" value="' . $domain_path . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
|
||||
</tr>';
|
||||
}*/ else $html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%><input type="text" name="' . $key .'" value="' . htmlspecialchars(getConfig($key)) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
|
||||
<input type="text" name="' . $key . '" value="' . htmlspecialchars(getConfig($key)) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%">';
|
||||
$html .= '
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
$html .= '
|
||||
<tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr>
|
||||
<tr><td><input type="submit" name="submit1" value="' . getconstStr('Setup') . '"></td></tr>
|
||||
</form>
|
||||
</table><br>';
|
||||
$disktags = explode('|', getConfig('disktag'));
|
||||
@@ -1249,7 +1220,7 @@ function EnvOpt($needUpdate = 0)
|
||||
}
|
||||
envs = [' . $envs . '];
|
||||
if (envs.indexOf(t.disktag_sort.value)>-1) {
|
||||
alert("Do not input ' . $envs . '");
|
||||
alert(\'Do not input ' . $envs . '\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1276,21 +1247,21 @@ function EnvOpt($needUpdate = 0)
|
||||
<tr>
|
||||
<td>
|
||||
<form action="" method="post" style="margin: 0" onsubmit="return deldiskconfirm(this);">
|
||||
<input type="hidden" name="disktag_del" value="'.$disktag.'">
|
||||
<input type="submit" name="submit1" value="'.getconstStr('DelDisk').'">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="" method="post" style="margin: 0" onsubmit="return renametag(this);">
|
||||
<input type="hidden" name="disktag_rename" value="'.$disktag.'">
|
||||
<input type="text" name="disktag_newname" value="'.$disktag.'" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '">
|
||||
<input type="submit" name="submit1" value="'.getconstStr('RenameDisk').'">
|
||||
<input type="hidden" name="disktag_del" value="' . $disktag . '">
|
||||
<input type="submit" name="submit1" value="' . getconstStr('DelDisk') . '">
|
||||
</form>
|
||||
<form action="" method="post" style="margin: 0">
|
||||
<input type="hidden" name="disktag_copy" value="' . $disktag . '">
|
||||
<input type="submit" name="submit1" value="' . getconstStr('CopyDisk') . '">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="" method="post" style="margin: 0" onsubmit="return renametag(this);">
|
||||
<input type="hidden" name="disktag_rename" value="' . $disktag . '">
|
||||
<input type="text" name="disktag_newname" value="' . $disktag . '" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '">
|
||||
<input type="submit" name="submit1" value="' . getconstStr('RenameDisk') . '">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Driver</td>
|
||||
@@ -1306,13 +1277,13 @@ function EnvOpt($needUpdate = 0)
|
||||
|
||||
if ($diskok) {
|
||||
$html .= '
|
||||
<form name="'.$disktag.'" action="" method="post">
|
||||
<input type="hidden" name="disk" value="'.$disktag.'">';
|
||||
<form name="' . $disktag . '" action="" method="post">
|
||||
<input type="hidden" name="disk" value="' . $disktag . '">';
|
||||
foreach ($EnvConfigs as $key => $val) if (isInnerEnv($key) && isShowedEnv($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>
|
||||
<td width=100%><input type="text" name="' . $key . '" value="' . getConfig($key, $disktag) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
|
||||
</tr>';
|
||||
}
|
||||
$html .= '
|
||||
@@ -1321,7 +1292,7 @@ function EnvOpt($needUpdate = 0)
|
||||
} else {
|
||||
$html .= '
|
||||
<tr>
|
||||
<td colspan="2">Please add this disk again.</td>
|
||||
<td colspan="2">' . $disk_tmp->error['body'] . '</td>
|
||||
</tr>';
|
||||
}
|
||||
$html .= '
|
||||
@@ -1369,17 +1340,17 @@ function EnvOpt($needUpdate = 0)
|
||||
}
|
||||
if (!$canOneKeyUpate) {
|
||||
$html .= '
|
||||
'.getconstStr('CannotOneKeyUpate').'<br>';
|
||||
' . getconstStr('CannotOneKeyUpate') . '<br>';
|
||||
} else {
|
||||
$html .= '
|
||||
<form name="updateform" action="" method="post">
|
||||
<input type="text" name="auth" size="6" placeholder="auth" value="qkqpttgf">
|
||||
<input type="text" name="project" size="12" placeholder="project" value="OneManager-php">
|
||||
<button name="QueryBranchs" onclick="querybranchs();return false;">'.getconstStr('QueryBranchs').'</button>
|
||||
<button name="QueryBranchs" onclick="querybranchs();return false;">' . getconstStr('QueryBranchs') . '</button>
|
||||
<select name="branch">
|
||||
<option value="master">master</option>
|
||||
</select>
|
||||
<input type="submit" name="updateProgram" value="'.getconstStr('updateProgram').'">
|
||||
<input type="submit" name="updateProgram" value="' . getconstStr('updateProgram') . '">
|
||||
</form>
|
||||
<script>
|
||||
function deldiskconfirm(t) {
|
||||
@@ -1389,7 +1360,7 @@ function EnvOpt($needUpdate = 0)
|
||||
}
|
||||
function renametag(t) {
|
||||
if (t.disktag_newname.value==\'\') {
|
||||
alert(\''.getconstStr('DiskTag').'\');
|
||||
alert(\'' . getconstStr('DiskTag') . '\');
|
||||
return false;
|
||||
}
|
||||
if (t.disktag_newname.value==t.disktag_rename.value) {
|
||||
@@ -1397,12 +1368,12 @@ function EnvOpt($needUpdate = 0)
|
||||
}
|
||||
envs = [' . $envs . '];
|
||||
if (envs.indexOf(t.disktag_newname.value)>-1) {
|
||||
alert("Do not input ' . $envs . '");
|
||||
alert(\'Do not input ' . $envs . '\');
|
||||
return false;
|
||||
}
|
||||
var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
|
||||
if (!reg.test(t.disktag_newname.value)) {
|
||||
alert(\''.getconstStr('TagFormatAlert').'\');
|
||||
alert(\'' . getconstStr('TagFormatAlert') . '\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1413,7 +1384,6 @@ function EnvOpt($needUpdate = 0)
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "https://api.github.com/repos/"+document.updateform.auth.value+"/"+document.updateform.project.value+"/branches");
|
||||
//xhr.setRequestHeader("User-Agent","qkqpttgf/OneManager");
|
||||
xhr.send(null);
|
||||
xhr.onload = function(e){
|
||||
console.log(xhr.responseText+","+xhr.status);
|
||||
if (xhr.status==200) {
|
||||
@@ -1430,6 +1400,7 @@ function EnvOpt($needUpdate = 0)
|
||||
xhr.onerror = function(e){
|
||||
alert("Network Error "+xhr.status);
|
||||
}
|
||||
xhr.send(null);
|
||||
}
|
||||
</script>
|
||||
';
|
||||
@@ -2426,6 +2397,6 @@ function render_list($path = '', $files = [])
|
||||
|
||||
$tmp = splitfirst($html, '</title>');
|
||||
$html = $tmp[0] . '</title>' . $authinfo . $tmp[1];
|
||||
if (isset($_SERVER['Set-Cookie'])) return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]);
|
||||
//if (isset($_SERVER['Set-Cookie'])) return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]);
|
||||
return output($html, $statusCode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user