Compare commits
43
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdbe65292e | ||
|
|
61df78a005 | ||
|
|
95b43461e8 | ||
|
|
d99ee1dadc | ||
|
|
544035b07a | ||
|
|
4db307d6fe | ||
|
|
8c70f8ad91 | ||
|
|
e828fe0a2b | ||
|
|
6cbeaa4a09 | ||
|
|
0843eb7955 | ||
|
|
36d493a1d2 | ||
|
|
50492f77e1 | ||
|
|
606d2d2c05 | ||
|
|
9139fbda53 | ||
|
|
459b23b284 | ||
|
|
4cfe38c388 | ||
|
|
68c07943e6 | ||
|
|
e10a613044 | ||
|
|
b91245904c | ||
|
|
e9681f5595 | ||
|
|
eddc938bdd | ||
|
|
5515b5bc9a | ||
|
|
3504685172 | ||
|
|
65d57a5d24 | ||
|
|
faf5027f04 | ||
|
|
06c7efe513 | ||
|
|
16dec5d4cd | ||
|
|
341124e5b0 | ||
|
|
270c73afb5 | ||
|
|
f3391cd132 | ||
|
|
c85898fd98 | ||
|
|
801a9168e2 | ||
|
|
1580671b5e | ||
|
|
0ab59926f6 | ||
|
|
bdd76ca567 | ||
|
|
d10e99a8ff | ||
|
|
7f0e1d96ce | ||
|
|
dd8c56179f | ||
|
|
6e76d23051 | ||
|
|
5281adca5b | ||
|
|
f909372a96 | ||
|
|
2e9ce0bbb4 | ||
|
|
108b14261c |
@@ -0,0 +1,3 @@
|
|||||||
|
language = "php74"
|
||||||
|
run = "php -S 0.0.0.0:8000 index.php"
|
||||||
|
entrypoint = "index.php"
|
||||||
+100
-15
@@ -352,7 +352,7 @@ function main($path)
|
|||||||
$files = json_decode('{"type":"folder"}', true);
|
$files = json_decode('{"type":"folder"}', true);
|
||||||
} elseif ($_SERVER['ishidden']==4) {
|
} elseif ($_SERVER['ishidden']==4) {
|
||||||
if (!getConfig('downloadencrypt', $_SERVER['disktag'])) {
|
if (!getConfig('downloadencrypt', $_SERVER['disktag'])) {
|
||||||
$files = json_decode('{"type":"folder"}', true);
|
$files = json_decode('{"type":"file"}', true);
|
||||||
} else {
|
} else {
|
||||||
$files = $drive->list_files($path1);
|
$files = $drive->list_files($path1);
|
||||||
if ($files['type']=='folder') $files = json_decode('{"type":"folder"}', true);
|
if ($files['type']=='folder') $files = json_decode('{"type":"folder"}', true);
|
||||||
@@ -555,7 +555,7 @@ function compareadminsha1($adminsha1, $timestamp, $pass)
|
|||||||
if (!is_numeric($timestamp)) return 'Timestamp not Number';
|
if (!is_numeric($timestamp)) return 'Timestamp not Number';
|
||||||
if (abs(time()-$timestamp) > 5*60) {
|
if (abs(time()-$timestamp) > 5*60) {
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
return 'The timestamp in server is ' . time() . ' (' . date("Y-m-d H:i:s") . ' UTC),<br>and your posted timestamp is ' . $timestamp . ' (' . date("Y-m-d H:i:s", $timestamp) . ' UTC)';
|
return 'The time in server is ' . time() . ' (' . date("Y-m-d H:i:s") . ' UTC),<br>and your time is ' . $timestamp . ' (' . date("Y-m-d H:i:s", $timestamp) . ' UTC)';
|
||||||
}
|
}
|
||||||
if ($adminsha1 == sha1($timestamp . $pass)) return '';
|
if ($adminsha1 == sha1($timestamp . $pass)) return '';
|
||||||
else return 'Error password';
|
else return 'Error password';
|
||||||
@@ -616,12 +616,12 @@ function filecache($disktag)
|
|||||||
{
|
{
|
||||||
$dir = sys_get_temp_dir();
|
$dir = sys_get_temp_dir();
|
||||||
if (!is_writable($dir)) {
|
if (!is_writable($dir)) {
|
||||||
$tmp = $_SERVER['HTTP_HOST'] . '/tmp/';
|
$tmp = __DIR__ . '/tmp/';
|
||||||
if (file_exists($tmp)) {
|
if (file_exists($tmp)) {
|
||||||
if ( is_writable($tmp) ) $dir = $tmp;
|
if ( is_writable($tmp) ) $dir = $tmp;
|
||||||
} elseif ( mkdir($tmp) ) $dir = $tmp;
|
} elseif ( mkdir($tmp) ) $dir = $tmp;
|
||||||
}
|
}
|
||||||
$tag = __DIR__ . '/OneManager/' . $disktag;
|
$tag = $_SERVER['HTTP_HOST'] . '/OneManager/' . $disktag;
|
||||||
while (strpos($tag, '/')>-1) $tag = str_replace('/', '_', $tag);
|
while (strpos($tag, '/')>-1) $tag = str_replace('/', '_', $tag);
|
||||||
if (strpos($tag, ':')>-1) {
|
if (strpos($tag, ':')>-1) {
|
||||||
$tag = str_replace(':', '_', $tag);
|
$tag = str_replace(':', '_', $tag);
|
||||||
@@ -632,6 +632,27 @@ function filecache($disktag)
|
|||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findIndexPath($rootpath, $path = '')
|
||||||
|
{// find the path of the first 'index.php' that not in rootpath.
|
||||||
|
global $slash;
|
||||||
|
if (substr($rootpath,-1)==$slash) $rootpath = substr($rootpath, 0, -1);
|
||||||
|
if (substr($path,0,1)==$slash) $path = substr($path, 1);
|
||||||
|
$handler=opendir(path_format($rootpath.$slash.$path)); //打开当前文件夹
|
||||||
|
while($filename=readdir($handler)){
|
||||||
|
if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
|
||||||
|
$nowname = path_format($rootpath.$slash.$path.$slash.$filename);
|
||||||
|
if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
|
||||||
|
$res = findIndexPath($rootpath, $path.$slash.$filename);
|
||||||
|
if ($res!=='') return $res;
|
||||||
|
}else{
|
||||||
|
if ($filename==='index.php') if ($path!='') return $rootpath.$slash.$path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@closedir($handler);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
function sortConfig(&$arr)
|
function sortConfig(&$arr)
|
||||||
{
|
{
|
||||||
ksort($arr);
|
ksort($arr);
|
||||||
@@ -952,7 +973,8 @@ function needUpdate()
|
|||||||
$current_ver = explode(urldecode('%0D'),$current_ver)[0];
|
$current_ver = explode(urldecode('%0D'),$current_ver)[0];
|
||||||
$split = splitfirst($current_version, '.' . $current_ver)[0] . '.' . $current_ver;
|
$split = splitfirst($current_version, '.' . $current_ver)[0] . '.' . $current_ver;
|
||||||
if (!($github_version = getcache('github_version'))) {
|
if (!($github_version = getcache('github_version'))) {
|
||||||
$tmp = curl('GET', 'https://raw.githubusercontent.com/qkqpttgf/OneManager-php/master/version');
|
//$tmp = curl('GET', 'https://raw.githubusercontent.com/qkqpttgf/OneManager-php/master/version');
|
||||||
|
$tmp = curl('GET', 'https://git.hit.edu.cn/ysun/OneManager-php/-/raw/master/version');
|
||||||
if ($tmp['stat']==0) return 0;
|
if ($tmp['stat']==0) return 0;
|
||||||
$github_version = $tmp['body'];
|
$github_version = $tmp['body'];
|
||||||
savecache('github_version', $github_version);
|
savecache('github_version', $github_version);
|
||||||
@@ -1085,7 +1107,7 @@ function adminform($name = '', $pass = '', $storage = '', $path = '')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script>';
|
<script src="https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js"></script>';
|
||||||
$html .= '</html>';
|
$html .= '</html>';
|
||||||
return output($html, $statusCode);
|
return output($html, $statusCode);
|
||||||
}
|
}
|
||||||
@@ -1256,7 +1278,7 @@ function EnvOpt($needUpdate = 0)
|
|||||||
|
|
||||||
$html = '<title>OneManager '.getconstStr('Setup').'</title>';
|
$html = '<title>OneManager '.getconstStr('Setup').'</title>';
|
||||||
if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) {
|
if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) {
|
||||||
$response = setConfigResponse(OnekeyUpate($_POST['auth'], $_POST['project'], $_POST['branch']));
|
$response = setConfigResponse(OnekeyUpate($_POST['GitSource'], $_POST['auth'], $_POST['project'], $_POST['branch']));
|
||||||
if (api_error($response)) {
|
if (api_error($response)) {
|
||||||
$html = api_error_msg($response);
|
$html = api_error_msg($response);
|
||||||
$title = 'Error';
|
$title = 'Error';
|
||||||
@@ -1723,7 +1745,10 @@ output:
|
|||||||
$canOneKeyUpate = 1;
|
$canOneKeyUpate = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$frame .= '<a href="https://github.com/qkqpttgf/OneManager-php" target="_blank">Github</a>';
|
$frame .= '
|
||||||
|
<a href="https://github.com/qkqpttgf/OneManager-php" target="_blank">Github</a>
|
||||||
|
<a href="https://git.hit.edu.cn/ysun/OneManager-php" target="_blank">HIT Gitlab</a><br><br>
|
||||||
|
';
|
||||||
if (!$canOneKeyUpate) {
|
if (!$canOneKeyUpate) {
|
||||||
$frame .= '
|
$frame .= '
|
||||||
' . getconstStr('CannotOneKeyUpate') . '<br>';
|
' . getconstStr('CannotOneKeyUpate') . '<br>';
|
||||||
@@ -1731,17 +1756,33 @@ output:
|
|||||||
$frame .= '
|
$frame .= '
|
||||||
<form name="updateform" action="" method="post">
|
<form name="updateform" action="" method="post">
|
||||||
<input name="_admin" type="hidden" value="">
|
<input name="_admin" type="hidden" value="">
|
||||||
|
Update from
|
||||||
|
<select name="GitSource" onchange="changeGitSource(this)">
|
||||||
|
<option value="Github" selected>Github</option>
|
||||||
|
<option value="HITGitlab">HIT Gitlab</option>
|
||||||
|
</select>
|
||||||
<input type="text" name="auth" size="6" placeholder="auth" value="qkqpttgf">
|
<input type="text" name="auth" size="6" placeholder="auth" value="qkqpttgf">
|
||||||
<input type="text" name="project" size="12" placeholder="project" value="OneManager-php">
|
<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(this);return false;">' . getconstStr('QueryBranchs') . '</button>
|
||||||
<select name="branch">
|
<select name="branch">
|
||||||
<option value="master">master</option>
|
<option value="master">master</option>
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" name="updateProgram" value="' . getconstStr('updateProgram') . '">
|
<input type="submit" name="updateProgram" value="' . getconstStr('updateProgram') . '">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function querybranchs()
|
function changeGitSource(d) {
|
||||||
{
|
if (d.options[d.options.selectedIndex].value=="Github") document.updateform.auth.value = "qkqpttgf";
|
||||||
|
if (d.options[d.options.selectedIndex].value=="HITGitlab") document.updateform.auth.value = "ysun";
|
||||||
|
document.updateform.QueryBranchs.style.display = null;
|
||||||
|
document.updateform.branch.options.length = 0;
|
||||||
|
document.updateform.branch.options.add(new Option("master", "master"));
|
||||||
|
}
|
||||||
|
function querybranchs(b) {
|
||||||
|
if (document.updateform.GitSource.options[document.updateform.GitSource.options.selectedIndex].value=="Github") return Githubquerybranchs(b);
|
||||||
|
if (document.updateform.GitSource.options[document.updateform.GitSource.options.selectedIndex].value=="HITGitlab") return HITquerybranchs(b);
|
||||||
|
}
|
||||||
|
function Githubquerybranchs(b) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", "https://api.github.com/repos/"+document.updateform.auth.value+"/"+document.updateform.project.value+"/branches");
|
xhr.open("GET", "https://api.github.com/repos/"+document.updateform.auth.value+"/"+document.updateform.project.value+"/branches");
|
||||||
//xhr.setRequestHeader("User-Agent","qkqpttgf/OneManager");
|
//xhr.setRequestHeader("User-Agent","qkqpttgf/OneManager");
|
||||||
@@ -1753,7 +1794,50 @@ output:
|
|||||||
document.updateform.branch.options.add(new Option(e.name,e.name));
|
document.updateform.branch.options.add(new Option(e.name,e.name));
|
||||||
if ("master"==e.name) document.updateform.branch.options[document.updateform.branch.options.length-1].selected = true;
|
if ("master"==e.name) document.updateform.branch.options[document.updateform.branch.options.length-1].selected = true;
|
||||||
});
|
});
|
||||||
document.updateform.QueryBranchs.style.display="none";
|
//document.updateform.QueryBranchs.style.display="none";
|
||||||
|
b.style.display="none";
|
||||||
|
} else {
|
||||||
|
alert(xhr.responseText+"\n"+xhr.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.onerror = function(e){
|
||||||
|
alert("Network Error "+xhr.status);
|
||||||
|
}
|
||||||
|
xhr.send(null);
|
||||||
|
}
|
||||||
|
function HITquerybranchs(b) {
|
||||||
|
// https://git.hit.edu.cn/api/v4/projects/383/repository/branches/
|
||||||
|
var pro_id;
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", "https://git.hit.edu.cn/api/v4/projects");
|
||||||
|
//xhr.setRequestHeader("User-Agent","qkqpttgf/OneManager");
|
||||||
|
xhr.onload = function(e){
|
||||||
|
//console.log(xhr.responseText+","+xhr.status);
|
||||||
|
if (xhr.status==200) {
|
||||||
|
//document.updateform.branch.options.length=0;
|
||||||
|
JSON.parse(xhr.responseText).forEach( function (e) {
|
||||||
|
if (e.name===document.updateform.project.value && e.namespace.path===document.updateform.auth.value) {
|
||||||
|
//console.log(e.id);
|
||||||
|
pro_id = e.id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//console.log(pro_id);
|
||||||
|
var xhr1 = new XMLHttpRequest();
|
||||||
|
xhr1.open("GET", "https://git.hit.edu.cn/api/v4/projects/"+pro_id+"/repository/branches");
|
||||||
|
xhr1.onload = function(e){
|
||||||
|
if (xhr1.status==200) {
|
||||||
|
document.updateform.branch.options.length=0;
|
||||||
|
JSON.parse(xhr1.responseText).forEach( function (e) {
|
||||||
|
document.updateform.branch.options.add(new Option(e.name,e.name));
|
||||||
|
if ("master"==e.name) document.updateform.branch.options[document.updateform.branch.options.length-1].selected = true;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert(xhr1.responseText+"\n"+xhr1.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr1.send(null);
|
||||||
|
//document.updateform.QueryBranchs.style.display="none";
|
||||||
|
b.style.display="none";
|
||||||
} else {
|
} else {
|
||||||
alert(xhr.responseText+"\n"+xhr.status);
|
alert(xhr.responseText+"\n"+xhr.status);
|
||||||
}
|
}
|
||||||
@@ -1768,17 +1852,17 @@ output:
|
|||||||
}
|
}
|
||||||
if ($needUpdate) {
|
if ($needUpdate) {
|
||||||
$frame .= '<div style="position: relative; word-wrap: break-word;">
|
$frame .= '<div style="position: relative; word-wrap: break-word;">
|
||||||
' . str_replace("\r", '<br>', $_SERVER['github_ver_new']) . '
|
' . str_replace("\n", '<br>', $_SERVER['github_ver_new']) . '
|
||||||
</div>
|
</div>
|
||||||
<button onclick="document.getElementById(\'github_ver_old\').style.display=(document.getElementById(\'github_ver_old\').style.display==\'none\'?\'\':\'none\');">More...</button>
|
<button onclick="document.getElementById(\'github_ver_old\').style.display=(document.getElementById(\'github_ver_old\').style.display==\'none\'?\'\':\'none\');">More...</button>
|
||||||
<div id="github_ver_old" style="position: relative; word-wrap: break-word; display: none">
|
<div id="github_ver_old" style="position: relative; word-wrap: break-word; display: none">
|
||||||
' . str_replace("\r", '<br>', $_SERVER['github_ver_old']) . '
|
' . str_replace("\n", '<br>', $_SERVER['github_ver_old']) . '
|
||||||
</div>';
|
</div>';
|
||||||
}/* else {
|
}/* else {
|
||||||
$frame .= getconstStr('NotNeedUpdate');
|
$frame .= getconstStr('NotNeedUpdate');
|
||||||
}*/
|
}*/
|
||||||
$frame .= '<br><br>
|
$frame .= '<br><br>
|
||||||
<script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js"></script>
|
||||||
<table>
|
<table>
|
||||||
<form id="change_pass" name="change_pass" action="" method="POST" onsubmit="return changePassword(this);">
|
<form id="change_pass" name="change_pass" action="" method="POST" onsubmit="return changePassword(this);">
|
||||||
<input name="_admin" type="hidden" value="">
|
<input name="_admin" type="hidden" value="">
|
||||||
@@ -2002,6 +2086,7 @@ function render_list($path = '', $files = [])
|
|||||||
$authinfo = '
|
$authinfo = '
|
||||||
<!--
|
<!--
|
||||||
OneManager: An index & manager of Onedrive auth by ysun.
|
OneManager: An index & manager of Onedrive auth by ysun.
|
||||||
|
HIT Gitlab: https://git.hit.edu.cn/ysun/OneManager-php
|
||||||
Github: https://github.com/qkqpttgf/OneManager-php
|
Github: https://github.com/qkqpttgf/OneManager-php
|
||||||
-->';
|
-->';
|
||||||
//$authinfo = $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
|
//$authinfo = $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
|
||||||
|
|||||||
@@ -39,6 +39,22 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
|||||||
//echo 'path:'. $path;
|
//echo 'path:'. $path;
|
||||||
$_GET = getGET();
|
$_GET = getGET();
|
||||||
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
|
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
|
||||||
|
$re = main($path);
|
||||||
|
$sendHeaders = array();
|
||||||
|
foreach ($re['headers'] as $headerName => $headerVal) {
|
||||||
|
header($headerName . ': ' . $headerVal, true);
|
||||||
|
}
|
||||||
|
http_response_code($re['statusCode']);
|
||||||
|
if ($re['isBase64Encoded']) echo base64_decode($re['body']);
|
||||||
|
else echo $re['body'];
|
||||||
|
} elseif (isset($_SERVER['DOCUMENT_ROOT'])&&substr($_SERVER['DOCUMENT_ROOT'], 0, 13)==='/home/runner/') {
|
||||||
|
include 'platform/Replit.php';
|
||||||
|
|
||||||
|
$path = getpath();
|
||||||
|
//echo 'path:'. $path;
|
||||||
|
$_GET = getGET();
|
||||||
|
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
|
||||||
|
|
||||||
$re = main($path);
|
$re = main($path);
|
||||||
$sendHeaders = array();
|
$sendHeaders = array();
|
||||||
foreach ($re['headers'] as $headerName => $headerVal) {
|
foreach ($re['headers'] as $headerName => $headerVal) {
|
||||||
@@ -56,7 +72,6 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
|||||||
//echo 'path:'. $path;
|
//echo 'path:'. $path;
|
||||||
$_GET = getGET();
|
$_GET = getGET();
|
||||||
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
|
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
|
||||||
|
|
||||||
$re = main($path);
|
$re = main($path);
|
||||||
$sendHeaders = array();
|
$sendHeaders = array();
|
||||||
foreach ($re['headers'] as $headerName => $headerVal) {
|
foreach ($re['headers'] as $headerName => $headerVal) {
|
||||||
|
|||||||
+10
-25
@@ -421,42 +421,27 @@ function setConfigResponse($response)
|
|||||||
return json_decode($response, true);
|
return json_decode($response, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$source = '/tmp/code.zip';
|
$source = '/tmp/code.zip';
|
||||||
$outPath = '/tmp/';
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['ErrorMessage'=>'Git Source input Error!']);
|
||||||
$tarfile = '/tmp/github.tar.gz';
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
file_put_contents($tarfile, file_get_contents($url));
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
$phar = new PharData($tarfile);
|
$phar = new PharData($tarfile);
|
||||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
// 获取解压出的目录名
|
// 获取解压出的目录名
|
||||||
/*
|
$outPath = findIndexPath($outPath);
|
||||||
@ob_start();
|
|
||||||
passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
|
|
||||||
$html.='状态:' . $stat . '
|
|
||||||
结果:
|
|
||||||
';
|
|
||||||
$archivefolder = ob_get_clean();
|
|
||||||
if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
|
|
||||||
$outPath .= $archivefolder;
|
|
||||||
$html.=htmlspecialchars($archivefolder);
|
|
||||||
//return $html;
|
|
||||||
*/
|
|
||||||
$tmp = scandir($outPath);
|
|
||||||
$name = $auth.'-'.$project;
|
|
||||||
foreach ($tmp as $f) {
|
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
|
||||||
$outPath .= $f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将目录中文件打包成zip
|
// 将目录中文件打包成zip
|
||||||
$zip=new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
if($zip->open($source, ZipArchive::CREATE)){
|
if($zip->open($source, ZipArchive::CREATE)){
|
||||||
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||||
$zip->close(); //关闭处理的zip文件
|
$zip->close(); //关闭处理的zip文件
|
||||||
@@ -483,7 +468,7 @@ function addFileToZip($zip, $rootpath, $path = '')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@closedir($path);
|
@closedir($handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function myErrorHandler($errno, $errstr, $errfile, $errline) {
|
function myErrorHandler($errno, $errstr, $errfile, $errline) {
|
||||||
|
|||||||
+10
-15
@@ -378,29 +378,24 @@ function setConfigResponse($response)
|
|||||||
return json_decode( $response, true );
|
return json_decode( $response, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$source = '/tmp/code.zip';
|
$source = '/tmp/code.zip';
|
||||||
$outPath = '/tmp/';
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['FunctionBrn'=>$_SERVER['functionBrn'], 'code'=>'Git Source input Error!']);
|
||||||
$tarfile = '/tmp/github.tar.gz';
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
file_put_contents($tarfile, file_get_contents($url));
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
$phar = new PharData($tarfile);
|
$phar = new PharData($tarfile);
|
||||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
// 获取包中目录名
|
// 获取解压出的目录名
|
||||||
$tmp = scandir('phar://'.$tarfile);
|
$outPath = findIndexPath($outPath);
|
||||||
$name = $auth.'-'.$project;
|
|
||||||
foreach ($tmp as $f) {
|
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
|
||||||
$outPath .= $f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 放入配置文件
|
|
||||||
//file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
|
|
||||||
|
|
||||||
// 将目录中文件打包成zip
|
// 将目录中文件打包成zip
|
||||||
//$zip=new ZipArchive();
|
//$zip=new ZipArchive();
|
||||||
@@ -432,7 +427,7 @@ function addFileToZip($zip, $rootpath, $path = '')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@closedir($path);
|
@closedir($handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function WaitFunction() {
|
function WaitFunction() {
|
||||||
|
|||||||
+8
-3
@@ -340,10 +340,15 @@ function_name:' . $_SERVER['function_name'] . '<br>
|
|||||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
//'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
|
if ($GitSource=='Github') {
|
||||||
$source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
//'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
|
||||||
|
$source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$source = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return ['stat'=>403, 'body'=>json_encode(['id'=>'Error', 'message'=>'Git Source input Error!'])];
|
||||||
|
|
||||||
return updateHerokuapp(getConfig('HerokuappId'), getConfig('APIKey'), $source);
|
return updateHerokuapp(getConfig('HerokuappId'), getConfig('APIKey'), $source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -429,27 +429,24 @@ function setConfigResponse($response)
|
|||||||
return json_decode( $response, true );
|
return json_decode( $response, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$source = '/tmp/code.zip';
|
$source = '/tmp/code.zip';
|
||||||
$outPath = '/tmp/';
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['error_code'=>'Error', 'error_msg'=>'Git Source input Error!']);
|
||||||
$tarfile = '/tmp/github.tar.gz';
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
file_put_contents($tarfile, file_get_contents($url));
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
$phar = new PharData($tarfile);
|
$phar = new PharData($tarfile);
|
||||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
// 获取解压出的目录名
|
// 获取解压出的目录名
|
||||||
$tmp = scandir($outPath);
|
$outPath = findIndexPath($outPath);
|
||||||
$name = $auth.'-'.$project;
|
|
||||||
foreach ($tmp as $f) {
|
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
|
||||||
$outPath .= $f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将目录中文件打包成zip
|
// 将目录中文件打包成zip
|
||||||
//$zip=new ZipArchive();
|
//$zip=new ZipArchive();
|
||||||
@@ -481,7 +478,7 @@ function addFileToZip($zip, $rootpath, $path = '')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@closedir($path);
|
@closedir($handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function WaitFunction() {
|
function WaitFunction() {
|
||||||
|
|||||||
+16
-34
@@ -80,10 +80,8 @@ function GetPathSetting($event, $context)
|
|||||||
|
|
||||||
function getConfig($str, $disktag = '')
|
function getConfig($str, $disktag = '')
|
||||||
{
|
{
|
||||||
|
$projectPath = splitlast(__DIR__, '/')[0];
|
||||||
global $slash;
|
$configPath = $projectPath . '/.data/config.php';
|
||||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
|
||||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
|
||||||
$s = file_get_contents($configPath);
|
$s = file_get_contents($configPath);
|
||||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
if ($configs!='') {
|
if ($configs!='') {
|
||||||
@@ -108,9 +106,8 @@ function setConfig($arr, $disktag = '')
|
|||||||
{
|
{
|
||||||
|
|
||||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
global $slash;
|
$projectPath = splitlast(__DIR__, '/')[0];
|
||||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
$configPath = $projectPath . '/.data/config.php';
|
||||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
|
||||||
$s = file_get_contents($configPath);
|
$s = file_get_contents($configPath);
|
||||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
if ($configs!='') $envs = json_decode($configs, true);
|
if ($configs!='') $envs = json_decode($configs, true);
|
||||||
@@ -422,7 +419,6 @@ function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
|||||||
|
|
||||||
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||||
{
|
{
|
||||||
global $slash;
|
|
||||||
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||||
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||||
else {
|
else {
|
||||||
@@ -465,8 +461,8 @@ function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
$projectPath = splitlast(__DIR__, '/')[0];
|
||||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
$configPath = $projectPath . '/.data/config.php';
|
||||||
$s = file_get_contents($configPath);
|
$s = file_get_contents($configPath);
|
||||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||||
if ($configs!='') $tmp_env = json_decode($configs, true);
|
if ($configs!='') $tmp_env = json_decode($configs, true);
|
||||||
@@ -521,39 +517,24 @@ function setConfigResponse($response)
|
|||||||
return json_decode( $response, true );
|
return json_decode( $response, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$source = '/tmp/code.zip';
|
$source = '/tmp/code.zip';
|
||||||
$outPath = '/tmp/';
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['error_code'=>'Error', 'error_msg'=>'Git Source input Error!']);
|
||||||
$tarfile = '/tmp/github.tar.gz';
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
file_put_contents($tarfile, file_get_contents($url));
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
$phar = new PharData($tarfile);
|
$phar = new PharData($tarfile);
|
||||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
// 获取解压出的目录名
|
// 获取解压出的目录名
|
||||||
/*
|
$outPath = findIndexPath($outPath);
|
||||||
@ob_start();
|
|
||||||
passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
|
|
||||||
$html.='状态:' . $stat . '
|
|
||||||
结果:
|
|
||||||
';
|
|
||||||
$archivefolder = ob_get_clean();
|
|
||||||
if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
|
|
||||||
$outPath .= $archivefolder;
|
|
||||||
$html.=htmlspecialchars($archivefolder);
|
|
||||||
//return $html;
|
|
||||||
*/
|
|
||||||
$tmp = scandir($outPath);
|
|
||||||
$name = $auth.'-'.$project;
|
|
||||||
foreach ($tmp as $f) {
|
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
|
||||||
$outPath .= $f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 放入配置文件
|
// 放入配置文件
|
||||||
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
|
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
|
||||||
@@ -588,7 +569,7 @@ function addFileToZip($zip, $rootpath, $path = '')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@closedir($path);
|
@closedir($handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -598,6 +579,7 @@ function addFileToZip($zip, $rootpath, $path = '')
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
define("BasicDateFormat", "Ymd\THis\Z");
|
define("BasicDateFormat", "Ymd\THis\Z");
|
||||||
define("Algorithm", "SDK-HMAC-SHA256");
|
define("Algorithm", "SDK-HMAC-SHA256");
|
||||||
define("HeaderXDate", "X-Sdk-Date");
|
define("HeaderXDate", "X-Sdk-Date");
|
||||||
|
|||||||
+14
-16
@@ -312,19 +312,23 @@ function setConfigResponse($response)
|
|||||||
return json_decode($response, true);
|
return json_decode($response, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$slash = '/';
|
global $slash;
|
||||||
if (strpos(__DIR__, ':')) $slash = '\\';
|
|
||||||
// __DIR__ is xxx/platform
|
// __DIR__ is xxx/platform
|
||||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return 0;
|
||||||
$tarfile = $projectPath . $slash .'github.tar.gz';
|
$tarfile = $projectPath . $slash .'github.tar.gz';
|
||||||
$githubfile = file_get_contents($url);
|
$githubfile = file_get_contents($url);
|
||||||
if (!$githubfile) return 0;
|
if (!$githubfile) return 0;
|
||||||
file_put_contents($tarfile, $githubfile);
|
file_put_contents($tarfile, $githubfile);
|
||||||
|
|
||||||
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
|
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
|
||||||
$phar = new PharData($tarfile); // need php5.3, 7, 8
|
$phar = new PharData($tarfile); // need php5.3, 7, 8
|
||||||
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
|
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
@@ -336,14 +340,7 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
|
|||||||
unlink($tarfile);
|
unlink($tarfile);
|
||||||
|
|
||||||
$outPath = '';
|
$outPath = '';
|
||||||
$tmp = scandir($projectPath);
|
$outPath = findIndexPath($projectPath);
|
||||||
$name = $auth . '-' . $project;
|
|
||||||
foreach ($tmp as $f) {
|
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
|
||||||
$outPath = $projectPath . $slash . $f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//error_log1($outPath);
|
//error_log1($outPath);
|
||||||
if ($outPath=='') return 0;
|
if ($outPath=='') return 0;
|
||||||
|
|
||||||
@@ -354,11 +351,12 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
|
|||||||
$tmp1['message'] = "Can not move " . $projectPath . $slash . '.data' . $slash . 'config.php' . " to " . $outPath . $slash . '.data' . $slash . 'config.php';
|
$tmp1['message'] = "Can not move " . $projectPath . $slash . '.data' . $slash . 'config.php' . " to " . $outPath . $slash . '.data' . $slash . 'config.php';
|
||||||
return json_encode($tmp1);
|
return json_encode($tmp1);
|
||||||
}
|
}
|
||||||
return moveFolder($outPath, $projectPath, $slash);
|
return moveFolder($outPath, $projectPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveFolder($from, $to, $slash)
|
function moveFolder($from, $to)
|
||||||
{
|
{
|
||||||
|
global $slash;
|
||||||
if (substr($from, -1)==$slash) $from = substr($from, 0, -1);
|
if (substr($from, -1)==$slash) $from = substr($from, 0, -1);
|
||||||
if (substr($to, -1)==$slash) $to = substr($to, 0, -1);
|
if (substr($to, -1)==$slash) $to = substr($to, 0, -1);
|
||||||
if (!file_exists($to)) mkdir($to, 0777);
|
if (!file_exists($to)) mkdir($to, 0777);
|
||||||
@@ -368,7 +366,7 @@ function moveFolder($from, $to, $slash)
|
|||||||
$fromfile = $from . $slash . $filename;
|
$fromfile = $from . $slash . $filename;
|
||||||
$tofile = $to . $slash . $filename;
|
$tofile = $to . $slash . $filename;
|
||||||
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
|
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
|
||||||
$response = moveFolder($fromfile, $tofile, $slash);
|
$response = moveFolder($fromfile, $tofile);
|
||||||
if (api_error(setConfigResponse($response))) return $response;
|
if (api_error(setConfigResponse($response))) return $response;
|
||||||
}else{
|
}else{
|
||||||
//if (file_exists($tofile)) unlink($tofile);
|
//if (file_exists($tofile)) unlink($tofile);
|
||||||
|
|||||||
@@ -0,0 +1,357 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function getpath()
|
||||||
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
|
||||||
|
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
|
if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') {
|
||||||
|
if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') {
|
||||||
|
$tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0];
|
||||||
|
if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp;
|
||||||
|
}
|
||||||
|
if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
|
||||||
|
}
|
||||||
|
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||||
|
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
|
||||||
|
$_SERVER['base_path'] = '/';
|
||||||
|
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||||
|
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||||
|
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
||||||
|
else $path = $_SERVER['REQUEST_URI'];
|
||||||
|
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGET()
|
||||||
|
{
|
||||||
|
if (!$_POST) {
|
||||||
|
if (!!$HTTP_RAW_POST_DATA) {
|
||||||
|
$tmpdata = $HTTP_RAW_POST_DATA;
|
||||||
|
} else {
|
||||||
|
$tmpdata = file_get_contents('php://input');
|
||||||
|
}
|
||||||
|
if (!!$tmpdata) {
|
||||||
|
$postbody = explode("&", $tmpdata);
|
||||||
|
foreach ($postbody as $postvalues) {
|
||||||
|
$pos = strpos($postvalues,"=");
|
||||||
|
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||||
|
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||||
|
if ($p>0) {
|
||||||
|
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
|
||||||
|
$getstrarr = explode("&",$getstr);
|
||||||
|
foreach ($getstrarr as $getvalues) {
|
||||||
|
if ($getvalues != '') {
|
||||||
|
$pos = strpos($getvalues, "=");
|
||||||
|
//echo $pos;
|
||||||
|
if ($pos > 0) {
|
||||||
|
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
|
||||||
|
} else {
|
||||||
|
$getarry[urldecode($getvalues)] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($getarry)) {
|
||||||
|
return $getarry;
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ReplitAPI($op, $key, $value = '') {
|
||||||
|
//error_log1($op . '_' . $key . '_' . $value);
|
||||||
|
$apiurl = getenv('REPLIT_DB_URL');
|
||||||
|
//foreach (explode("\n", curl('GET', $apiurl . '?prefix')['body']) as $a) curl('DELETE', $apiurl . '/' . $a);
|
||||||
|
if ($op === 'r') {
|
||||||
|
if (!($config = getcache('REPLIT_CONFIG'))) {
|
||||||
|
$config = json_decode(curl('GET', $apiurl . '/REPLIT_CONFIG')['body'], true);
|
||||||
|
savecache('REPLIT_CONFIG', $config);
|
||||||
|
}
|
||||||
|
return ['stat'=>200, 'body'=>(is_array($config[$key])?json_encode($config[$key]):$config[$key])];
|
||||||
|
} elseif ($op === 'w') {
|
||||||
|
return curl('POST', $apiurl, 'REPLIT_CONFIG=' . $value, ["Content-Type"=>"application/x-www-form-urlencoded"]);
|
||||||
|
} elseif ($op === 'd') {
|
||||||
|
// not use
|
||||||
|
return curl('DELETE', $apiurl . '/' . $key);
|
||||||
|
} else {
|
||||||
|
return ['stat'=>500, 'body'=>'error option input to function ReplitAPI().'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig($str, $disktag = '')
|
||||||
|
{
|
||||||
|
if (isInnerEnv($str)) {
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$env = json_decode(ReplitAPI('r', $disktag)['body'], true);
|
||||||
|
if (isset($env[$str])) {
|
||||||
|
if (isBase64Env($str)) return base64y_decode($env[$str]);
|
||||||
|
else return $env[$str];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isBase64Env($str)) return base64y_decode(ReplitAPI('r', $str)['body']);
|
||||||
|
else return ReplitAPI('r', $str)['body'];
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfig($arr, $disktag = '')
|
||||||
|
{
|
||||||
|
if (!($envs = getcache('REPLIT_CONFIG'))) {
|
||||||
|
$envs = json_decode(curl('GET', getenv('REPLIT_DB_URL') . '/REPLIT_CONFIG')['body'], true);
|
||||||
|
savecache('REPLIT_CONFIG', $envs);
|
||||||
|
}
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$disktags = explode("|", getConfig('disktag'));
|
||||||
|
$indisk = 0;
|
||||||
|
$operatedisk = 0;
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
if (isCommonEnv($k)) {
|
||||||
|
if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
|
||||||
|
else $envs[$k] = $v;
|
||||||
|
} elseif (isInnerEnv($k)) {
|
||||||
|
if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v);
|
||||||
|
else $envs[$disktag][$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;
|
||||||
|
} elseif ($k=='disktag_copy') {
|
||||||
|
$newtag = $v . '_' . date("Ymd_His");
|
||||||
|
$envs[$newtag] = $envs[$v];
|
||||||
|
array_push($disktags, $newtag);
|
||||||
|
$operatedisk = 1;
|
||||||
|
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||||
|
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||||
|
} else {
|
||||||
|
$envs[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($indisk) {
|
||||||
|
$diskconfig = $envs[$disktag];
|
||||||
|
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||||
|
ksort($diskconfig);
|
||||||
|
$envs[$disktag] = $diskconfig;
|
||||||
|
}
|
||||||
|
if ($operatedisk) {
|
||||||
|
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||||
|
$tags = [];
|
||||||
|
foreach ($disktags as $tag) {
|
||||||
|
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||||
|
else array_push($tags, $tag);
|
||||||
|
}
|
||||||
|
$envs['disktag'] = implode('|', $tags);
|
||||||
|
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
|
||||||
|
unset($envs[$arr['disktag_rename']]);
|
||||||
|
} else {
|
||||||
|
$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');
|
||||||
|
sortConfig($envs);
|
||||||
|
$response = ReplitAPI('w', 'REPLIT_CONFIG', json_encode($envs));
|
||||||
|
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($envs, JSON_PRETTY_PRINT));
|
||||||
|
savecache('REPLIT_CONFIG', null, '', 0);
|
||||||
|
if (api_error($response)) return ['stat'=>$response['stat'], 'body'=>$response['body'] . "<br>\nError in writting " . $key . "=" . $val];
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function install()
|
||||||
|
{
|
||||||
|
global $constStr;
|
||||||
|
if ($_GET['install2']) {
|
||||||
|
if ($_POST['admin']!='') {
|
||||||
|
$tmp['admin'] = $_POST['admin'];
|
||||||
|
//$tmp['language'] = $_COOKIE['language'];
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
|
$response = setConfigResponse( setConfig($tmp) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
} else {
|
||||||
|
return output('Jump
|
||||||
|
<script>
|
||||||
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie=\'language=; path=/; \'+expires;
|
||||||
|
</script>
|
||||||
|
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($_GET['install1']) {
|
||||||
|
/*if (!ConfigWriteable()) {
|
||||||
|
$html .= getconstStr('MakesuerWriteable');
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
if (!RewriteEngineOn()) {
|
||||||
|
$html .= getconstStr('MakesuerRewriteOn');
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}*/
|
||||||
|
$html .= '
|
||||||
|
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||||
|
<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"><br>
|
||||||
|
<input id="submitbtn" type="submit" value="'.getconstStr('Submit').'">
|
||||||
|
</form>
|
||||||
|
<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)
|
||||||
|
{
|
||||||
|
if (t.admin.value==\'\') {
|
||||||
|
alert(\''.getconstStr('SetAdminPassword').'\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
$title = getconstStr('SetAdminPassword');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
if ($_GET['install0']) {
|
||||||
|
$html .= '
|
||||||
|
<form action="?install1" method="post">
|
||||||
|
language:<br>';
|
||||||
|
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||||
|
$html .= '
|
||||||
|
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||||
|
}
|
||||||
|
$html .= '
|
||||||
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
function changelanguage(str)
|
||||||
|
{
|
||||||
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||||
|
location.href = location.href;
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
$title = getconstStr('SelectLanguage');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = 'Install';
|
||||||
|
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ConfigWriteable()
|
||||||
|
{
|
||||||
|
$t = md5( md5(time()).rand(1000,9999) );
|
||||||
|
$r = setConfig([ 'tmp' => $t ]);
|
||||||
|
$tmp = getConfig('tmp');
|
||||||
|
setConfig([ 'tmp' => '' ]);
|
||||||
|
if ($tmp == $t) return true;
|
||||||
|
if ($r) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error($response)
|
||||||
|
{
|
||||||
|
return !($response['stat']==200||$response['stat']==204||$response['stat']==404);
|
||||||
|
//return isset($response['message']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error_msg($response)
|
||||||
|
{
|
||||||
|
return '<pre>'. json_encode($response, JSON_PRETTY_PRINT).'</pre>' . '<br>
|
||||||
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfigResponse($response)
|
||||||
|
{
|
||||||
|
return $response;
|
||||||
|
//return json_decode($response, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
|
{
|
||||||
|
// __DIR__ is xxx/platform
|
||||||
|
$projectPath = splitlast(__DIR__, '/')[0];
|
||||||
|
|
||||||
|
if ($GitSource=='Github') {
|
||||||
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return ['stat'=>500, 'body'=>'Git Source input Error!'];
|
||||||
|
$tarfile = $projectPath . '/github.tar.gz';
|
||||||
|
$githubfile = file_get_contents($url);
|
||||||
|
if (!$githubfile) return ['stat'=>500, 'body'=>'download error from github.'];
|
||||||
|
file_put_contents($tarfile, $githubfile);
|
||||||
|
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
|
||||||
|
$phar = new PharData($tarfile); // need php5.3, 7, 8
|
||||||
|
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
} else {
|
||||||
|
ob_start();
|
||||||
|
passthru('tar -xzvf ' . $tarfile, $stat);
|
||||||
|
ob_get_clean();
|
||||||
|
}
|
||||||
|
unlink($tarfile);
|
||||||
|
|
||||||
|
$outPath = '';
|
||||||
|
$outPath = findIndexPath($projectPath);
|
||||||
|
//error_log1($outPath);
|
||||||
|
if ($outPath=='') return ['stat'=>500, 'body'=>'can\'t find folder after download from github.'];
|
||||||
|
|
||||||
|
return moveFolder($outPath, $projectPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveFolder($from, $to)
|
||||||
|
{
|
||||||
|
if (substr($from, -1)=='/') $from = substr($from, 0, -1);
|
||||||
|
if (substr($to, -1)=='/') $to = substr($to, 0, -1);
|
||||||
|
if (!file_exists($to)) mkdir($to, 0777);
|
||||||
|
$handler=opendir($from);
|
||||||
|
while($filename=readdir($handler)) {
|
||||||
|
if($filename != '.' && $filename != '..'){
|
||||||
|
$fromfile = $from . '/' . $filename;
|
||||||
|
$tofile = $to . '/' . $filename;
|
||||||
|
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
|
||||||
|
$response = moveFolder($fromfile, $tofile);
|
||||||
|
if (api_error(setConfigResponse($response))) return $response;
|
||||||
|
}else{
|
||||||
|
if (file_exists($tofile)) unlink($tofile);
|
||||||
|
$response = rename($fromfile, $tofile);
|
||||||
|
if (!$response) {
|
||||||
|
$tmp['code'] = "Move Failed";
|
||||||
|
$tmp['message'] = "Can not move " . $fromfile . " to " . $tofile;
|
||||||
|
return ['stat'=>500, 'body'=>json_encode($tmp)];
|
||||||
|
}
|
||||||
|
if (file_exists($fromfile)) unlink($fromfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handler);
|
||||||
|
rmdir($from);
|
||||||
|
return ['stat'=>200, 'body'=>'success.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function WaitFunction() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeAuthKey() {
|
||||||
|
return message("Not need.", 'Change platform Auth token or key', 404);
|
||||||
|
}
|
||||||
@@ -0,0 +1,379 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function getpath()
|
||||||
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
|
||||||
|
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
|
if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') {
|
||||||
|
if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') {
|
||||||
|
$tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0];
|
||||||
|
if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp;
|
||||||
|
}
|
||||||
|
if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
|
||||||
|
}
|
||||||
|
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
||||||
|
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
|
||||||
|
$_SERVER['base_path'] = '/';
|
||||||
|
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||||
|
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||||
|
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
||||||
|
else $path = $_SERVER['REQUEST_URI'];
|
||||||
|
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGET()
|
||||||
|
{
|
||||||
|
if (!$_POST) {
|
||||||
|
if (!!$HTTP_RAW_POST_DATA) {
|
||||||
|
$tmpdata = $HTTP_RAW_POST_DATA;
|
||||||
|
} else {
|
||||||
|
$tmpdata = file_get_contents('php://input');
|
||||||
|
}
|
||||||
|
if (!!$tmpdata) {
|
||||||
|
$postbody = explode("&", $tmpdata);
|
||||||
|
foreach ($postbody as $postvalues) {
|
||||||
|
$pos = strpos($postvalues,"=");
|
||||||
|
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||||
|
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||||
|
if ($p>0) {
|
||||||
|
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
|
||||||
|
$getstrarr = explode("&",$getstr);
|
||||||
|
foreach ($getstrarr as $getvalues) {
|
||||||
|
if ($getvalues != '') {
|
||||||
|
$pos = strpos($getvalues, "=");
|
||||||
|
//echo $pos;
|
||||||
|
if ($pos > 0) {
|
||||||
|
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
|
||||||
|
} else {
|
||||||
|
$getarry[urldecode($getvalues)] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($getarry)) {
|
||||||
|
return $getarry;
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ReplitAPI($op, $key, $value = '') {
|
||||||
|
//error_log1($op . '_' . $key . '_' . $value);
|
||||||
|
$apiurl = getenv('REPLIT_DB_URL');
|
||||||
|
if ($op === 'r') {
|
||||||
|
return curl('GET', $apiurl . '/' . $key);
|
||||||
|
} elseif ($op === 'w') {
|
||||||
|
return curl('POST', $apiurl, $key . '=' . $value, ["Content-Type"=>"application/x-www-form-urlencoded"]);
|
||||||
|
} elseif ($op === 'd') {
|
||||||
|
return curl('DELETE', $apiurl . '/' . $key);
|
||||||
|
} else {
|
||||||
|
return ['stat'=>500, 'body'=>'error option input to function ReplitAPI().'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig($str, $disktag = '')
|
||||||
|
{
|
||||||
|
if (isInnerEnv($str)) {
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$env = json_decode(ReplitAPI('r', $disktag)['body'], true);
|
||||||
|
if (isset($env[$str])) {
|
||||||
|
if (isBase64Env($str)) return base64y_decode($env[$str]);
|
||||||
|
else return $env[$str];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isBase64Env($str)) return base64y_decode(ReplitAPI('r', $str)['body']);
|
||||||
|
else return ReplitAPI('r', $str)['body'];
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfig($arr, $disktag = '')
|
||||||
|
{
|
||||||
|
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||||
|
$disktags = explode("|", getConfig('disktag'));
|
||||||
|
if ($disktag!='') $diskconfig = json_decode(ReplitAPI('r', $disktag)['body'], true);
|
||||||
|
$tmp = [];
|
||||||
|
$indisk = 0;
|
||||||
|
$operatedisk = 0;
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
if (isCommonEnv($k)) {
|
||||||
|
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
|
||||||
|
else $tmp[$k] = $v;
|
||||||
|
} elseif (isInnerEnv($k)) {
|
||||||
|
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v);
|
||||||
|
else $diskconfig[$k] = $v;
|
||||||
|
$indisk = 1;
|
||||||
|
} elseif ($k=='disktag_add') {
|
||||||
|
array_push($disktags, $v);
|
||||||
|
$operatedisk = 1;
|
||||||
|
} elseif ($k=='disktag_del') {
|
||||||
|
$disktags = array_diff($disktags, [ $v ]);
|
||||||
|
$tmp[$v] = '';
|
||||||
|
$operatedisk = 1;
|
||||||
|
} elseif ($k=='disktag_copy') {
|
||||||
|
$newtag = $v . '_' . date("Ymd_His");
|
||||||
|
$tmp[$newtag] = getConfig($v);
|
||||||
|
array_push($disktags, $newtag);
|
||||||
|
$operatedisk = 1;
|
||||||
|
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||||
|
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||||
|
} else {
|
||||||
|
$tmp[$k] = json_encode($v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($indisk) {
|
||||||
|
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||||
|
ksort($diskconfig);
|
||||||
|
$tmp[$disktag] = json_encode($diskconfig);
|
||||||
|
}
|
||||||
|
if ($operatedisk) {
|
||||||
|
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||||
|
$tags = [];
|
||||||
|
foreach ($disktags as $tag) {
|
||||||
|
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
|
||||||
|
else array_push($tags, $tag);
|
||||||
|
}
|
||||||
|
$tmp['disktag'] = implode('|', $tags);
|
||||||
|
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||||
|
$tmp[$arr['disktag_rename']] = null;
|
||||||
|
} else {
|
||||||
|
$disktags = array_unique($disktags);
|
||||||
|
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||||
|
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||||
|
else $tmp['disktag'] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$response = null;
|
||||||
|
foreach ($tmp as $key => $val) {
|
||||||
|
if (!!$val) $response = ReplitAPI('w', $key, $val);
|
||||||
|
else $response = ReplitAPI('d', $key);
|
||||||
|
if (api_error($response)) return ['stat'=>$response['stat'], 'body'=>$response['body'] . "<br>\nError in writting " . $key . "=" . $val];
|
||||||
|
}
|
||||||
|
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($tmp, JSON_PRETTY_PRINT));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function install()
|
||||||
|
{
|
||||||
|
global $constStr;
|
||||||
|
if ($_GET['install2']) {
|
||||||
|
if ($_POST['admin']!='') {
|
||||||
|
$tmp['admin'] = $_POST['admin'];
|
||||||
|
//$tmp['language'] = $_COOKIE['language'];
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
|
$response = setConfigResponse( setConfig($tmp) );
|
||||||
|
if (api_error($response)) {
|
||||||
|
$html = api_error_msg($response);
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
} else {
|
||||||
|
return output('Jump
|
||||||
|
<script>
|
||||||
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie=\'language=; path=/; \'+expires;
|
||||||
|
</script>
|
||||||
|
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($_GET['install1']) {
|
||||||
|
if (!ConfigWriteable()) {
|
||||||
|
$html .= getconstStr('MakesuerWriteable');
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
/*if (!RewriteEngineOn()) {
|
||||||
|
$html .= getconstStr('MakesuerRewriteOn');
|
||||||
|
$title = 'Error';
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}*/
|
||||||
|
$html .= '<button id="checkrewritebtn" onclick="checkrewrite();">'.getconstStr('MakesuerRewriteOn').'</button>
|
||||||
|
<div id="formdiv" style="display: none">
|
||||||
|
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||||
|
<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"><br>
|
||||||
|
<input id="submitbtn" type="submit" value="'.getconstStr('Submit').'" disabled>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<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)
|
||||||
|
{
|
||||||
|
if (t.admin.value==\'\') {
|
||||||
|
alert(\''.getconstStr('SetAdminPassword').'\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function checkrewrite()
|
||||||
|
{
|
||||||
|
url=location.protocol + "//" + location.host;
|
||||||
|
//if (location.port!="") url += ":" + location.port;
|
||||||
|
url += location.pathname;
|
||||||
|
if (url.substr(-1)!="/") url += "/";
|
||||||
|
url += "app.json";
|
||||||
|
url += "?" + Date.now();
|
||||||
|
var xhr4 = new XMLHttpRequest();
|
||||||
|
xhr4.open("GET", url);
|
||||||
|
xhr4.setRequestHeader("x-requested-with","XMLHttpRequest");
|
||||||
|
xhr4.send(null);
|
||||||
|
xhr4.onload = function(e){
|
||||||
|
console.log(xhr4.responseText+","+xhr4.status);
|
||||||
|
if (xhr4.status==201) {
|
||||||
|
document.getElementById("checkrewritebtn").style.display = "none";
|
||||||
|
document.getElementById("submitbtn").disabled = false;
|
||||||
|
document.getElementById("formdiv").style.display = "";
|
||||||
|
} else {
|
||||||
|
alert("' . getconstStr('MakesuerRewriteOn') . '?\nfalse\n\nUrl: " + url + "\nExpect http code 201, but received " + xhr4.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
$title = getconstStr('SetAdminPassword');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
if ($_GET['install0']) {
|
||||||
|
$html .= '
|
||||||
|
<form action="?install1" method="post">
|
||||||
|
language:<br>';
|
||||||
|
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||||
|
$html .= '
|
||||||
|
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||||
|
}
|
||||||
|
$html .= '
|
||||||
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
function changelanguage(str)
|
||||||
|
{
|
||||||
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||||
|
location.href = location.href;
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
|
$title = getconstStr('SelectLanguage');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = 'Install';
|
||||||
|
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
|
||||||
|
return message($html, $title, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ConfigWriteable()
|
||||||
|
{
|
||||||
|
$t = md5( md5(time()).rand(1000,9999) );
|
||||||
|
$r = setConfig([ 'tmp' => $t ]);
|
||||||
|
$tmp = getConfig('tmp');
|
||||||
|
setConfig([ 'tmp' => '' ]);
|
||||||
|
if ($tmp == $t) return true;
|
||||||
|
if ($r) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error($response)
|
||||||
|
{
|
||||||
|
return !($response['stat']==200||$response['stat']==204||$response['stat']==404);
|
||||||
|
//return isset($response['message']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_error_msg($response)
|
||||||
|
{
|
||||||
|
return '<pre>'. json_encode($response, JSON_PRETTY_PRINT).'</pre>' . '<br>
|
||||||
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConfigResponse($response)
|
||||||
|
{
|
||||||
|
return $response;
|
||||||
|
//return json_decode($response, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
|
{
|
||||||
|
$slash = '/';
|
||||||
|
if (strpos(__DIR__, ':')) $slash = '\\';
|
||||||
|
// __DIR__ is xxx/platform
|
||||||
|
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||||
|
|
||||||
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
$tarfile = $projectPath . $slash .'github.tar.gz';
|
||||||
|
$githubfile = file_get_contents($url);
|
||||||
|
if (!$githubfile) return ['stat'=>500, 'body'=>'download error from github.'];
|
||||||
|
file_put_contents($tarfile, $githubfile);
|
||||||
|
if (splitfirst(PHP_VERSION, '.')[0] > '5') {
|
||||||
|
$phar = new PharData($tarfile); // need php5.3, 7, 8
|
||||||
|
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
} else {
|
||||||
|
ob_start();
|
||||||
|
passthru('tar -xzvf ' . $tarfile, $stat);
|
||||||
|
ob_get_clean();
|
||||||
|
}
|
||||||
|
unlink($tarfile);
|
||||||
|
|
||||||
|
$outPath = '';
|
||||||
|
$tmp = scandir($projectPath);
|
||||||
|
$name = $auth . '-' . $project;
|
||||||
|
foreach ($tmp as $f) {
|
||||||
|
if ( substr($f, 0, strlen($name)) == $name) {
|
||||||
|
$outPath = $projectPath . $slash . $f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//error_log1($outPath);
|
||||||
|
if ($outPath=='') return ['stat'=>500, 'body'=>'can\'t find folder after download from github.'];
|
||||||
|
|
||||||
|
return moveFolder($outPath, $projectPath, $slash);
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveFolder($from, $to, $slash)
|
||||||
|
{
|
||||||
|
if (substr($from, -1)==$slash) $from = substr($from, 0, -1);
|
||||||
|
if (substr($to, -1)==$slash) $to = substr($to, 0, -1);
|
||||||
|
if (!file_exists($to)) mkdir($to, 0777);
|
||||||
|
$handler=opendir($from);
|
||||||
|
while($filename=readdir($handler)) {
|
||||||
|
if($filename != '.' && $filename != '..'){
|
||||||
|
$fromfile = $from . $slash . $filename;
|
||||||
|
$tofile = $to . $slash . $filename;
|
||||||
|
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
|
||||||
|
$response = moveFolder($fromfile, $tofile, $slash);
|
||||||
|
if (api_error(setConfigResponse($response))) return $response;
|
||||||
|
}else{
|
||||||
|
if (file_exists($tofile)) unlink($tofile);
|
||||||
|
$response = rename($fromfile, $tofile);
|
||||||
|
if (!$response) {
|
||||||
|
$tmp['code'] = "Move Failed";
|
||||||
|
$tmp['message'] = "Can not move " . $fromfile . " to " . $tofile;
|
||||||
|
return ['stat'=>500, 'body'=>json_encode($tmp)];
|
||||||
|
}
|
||||||
|
if (file_exists($fromfile)) unlink($fromfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handler);
|
||||||
|
rmdir($from);
|
||||||
|
return ['stat'=>200, 'body'=>'success.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function WaitFunction() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeAuthKey() {
|
||||||
|
return message("Not need.", 'Change platform Auth token or key', 404);
|
||||||
|
}
|
||||||
+10
-15
@@ -560,29 +560,24 @@ function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKe
|
|||||||
return curl('POST', 'https://'.$host, $payload, $headers)['body'];
|
return curl('POST', 'https://'.$host, $payload, $headers)['body'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$source = '/tmp/code.zip';
|
$source = '/tmp/code.zip';
|
||||||
$outPath = '/tmp/';
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['Response'=>['Error'=>['code'=>'Git Source input Error!']]]);
|
||||||
$tarfile = '/tmp/github.tar.gz';
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
file_put_contents($tarfile, file_get_contents($url));
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
$phar = new PharData($tarfile);
|
$phar = new PharData($tarfile);
|
||||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
// 获取包中目录名
|
// 获取解压出的目录名
|
||||||
$tmp = scandir('phar://'.$tarfile);
|
$outPath = findIndexPath($outPath);
|
||||||
$name = $auth.'-'.$project;
|
|
||||||
foreach ($tmp as $f) {
|
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
|
||||||
$outPath .= $f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 放入配置文件
|
|
||||||
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
|
|
||||||
|
|
||||||
// 将目录中文件打包成zip
|
// 将目录中文件打包成zip
|
||||||
//$zip=new ZipArchive();
|
//$zip=new ZipArchive();
|
||||||
@@ -614,7 +609,7 @@ function addFileToZip($zip, $rootpath, $path = '')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@closedir($path);
|
@closedir($handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeAuthKey() {
|
function changeAuthKey() {
|
||||||
|
|||||||
@@ -595,27 +595,25 @@ function setConfigResponse($response)
|
|||||||
return json_decode( $response, true )['Response'];
|
return json_decode( $response, true )['Response'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$source = '/tmp/code.zip';
|
$source = '/tmp/code.zip';
|
||||||
$outPath = '/tmp/';
|
$outPath = '/tmp/';
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['Response'=>['Error'=>['code'=>'Git Source input Error!']]]);
|
||||||
$tarfile = '/tmp/github.tar.gz';
|
$tarfile = '/tmp/github.tar.gz';
|
||||||
file_put_contents($tarfile, file_get_contents($url));
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
$phar = new PharData($tarfile);
|
$phar = new PharData($tarfile);
|
||||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
|
|
||||||
// 获取包中目录名
|
// 获取解压出的目录名
|
||||||
$tmp = scandir('phar://'.$tarfile);
|
$outPath = findIndexPath($outPath);
|
||||||
$name = $auth.'-'.$project;
|
|
||||||
foreach ($tmp as $f) {
|
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
|
||||||
$outPath .= $f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 放入配置文件
|
// 放入配置文件
|
||||||
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
|
file_put_contents($outPath . '/.data/config.php', file_get_contents(__DIR__ . '/../.data/config.php'));
|
||||||
|
|
||||||
@@ -649,7 +647,7 @@ function addFileToZip($zip, $rootpath, $path = '')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@closedir($path);
|
@closedir($handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function WaitFunction() {
|
function WaitFunction() {
|
||||||
|
|||||||
+18
-19
@@ -388,34 +388,33 @@ function setConfigResponse($response)
|
|||||||
return json_decode($response, true);
|
return json_decode($response, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$tmppath = '/tmp';
|
$tmppath = '/tmp';
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['error'=>['code'=>'Git Source input Error!']]);
|
||||||
|
|
||||||
$tarfile = $tmppath . '/github.tar.gz';
|
$tarfile = $tmppath . '/github.tar.gz';
|
||||||
$githubfile = file_get_contents($url);
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
if (!$githubfile) return '{"error":{"message":"fail to download from github"}}';
|
$phar = new PharData($tarfile);
|
||||||
file_put_contents($tarfile, $githubfile);
|
$html = $phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
$phar = new PharData($tarfile); // need php5.3, 7, 8
|
|
||||||
$phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
|
|
||||||
unlink($tarfile);
|
unlink($tarfile);
|
||||||
|
|
||||||
$outPath = '';
|
// 获取解压出的目录名
|
||||||
$tmp = scandir($tmppath);
|
$outPath = findIndexPath($tmppath);
|
||||||
$name = $auth . '-' . $project;
|
|
||||||
|
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
|
||||||
|
$name = $project . 'CODE';
|
||||||
mkdir($tmppath . "/" . $name, 0777, 1);
|
mkdir($tmppath . "/" . $name, 0777, 1);
|
||||||
foreach ($tmp as $f) {
|
rename($outPath, $tmppath . "/" . $name . '/api');
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
$outPath = $tmppath . "/" . $name;
|
||||||
rename($tmppath . '/' . $f, $tmppath . "/" . $name . '/api');
|
|
||||||
$outPath = $tmppath . "/" . $name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//echo $outPath . "<br>";
|
//echo $outPath . "<br>";
|
||||||
//error_log1($outPath);
|
//error_log1($outPath);
|
||||||
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
|
|
||||||
|
|
||||||
// put in config
|
// put in config
|
||||||
$coderoot = __DIR__;
|
$coderoot = __DIR__;
|
||||||
|
|||||||
+19
-20
@@ -375,34 +375,33 @@ function setConfigResponse($response)
|
|||||||
return json_decode($response, true);
|
return json_decode($response, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$tmppath = '/tmp';
|
$tmppath = '/tmp';
|
||||||
|
|
||||||
// 从github下载对应tar.gz,并解压
|
if ($GitSource=='Github') {
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
// 从github下载对应tar.gz,并解压
|
||||||
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['error'=>['code'=>'Git Source input Error!']]);
|
||||||
|
|
||||||
$tarfile = $tmppath . '/github.tar.gz';
|
$tarfile = $tmppath . '/github.tar.gz';
|
||||||
$githubfile = file_get_contents($url);
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
if (!$githubfile) return '{"error":{"message":"fail to download from github"}}';
|
$phar = new PharData($tarfile);
|
||||||
file_put_contents($tarfile, $githubfile);
|
$html = $phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
$phar = new PharData($tarfile); // need php5.3, 7, 8
|
|
||||||
$phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
|
|
||||||
unlink($tarfile);
|
unlink($tarfile);
|
||||||
|
|
||||||
$outPath = '';
|
// 获取解压出的目录名
|
||||||
$tmp = scandir($tmppath);
|
$outPath = findIndexPath($tmppath);
|
||||||
$name = $auth . '-' . $project;
|
|
||||||
mkdir($tmppath . "/" . $name, 0777);
|
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
|
||||||
foreach ($tmp as $f) {
|
$name = $project . 'CODE';
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
mkdir($tmppath . "/" . $name, 0777, 1);
|
||||||
rename($tmppath . '/' . $f, $tmppath . "/" . $name . '/api');
|
rename($outPath, $tmppath . "/" . $name . '/api');
|
||||||
$outPath = $tmppath . "/" . $name;
|
$outPath = $tmppath . "/" . $name;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//echo $outPath . "<br>";
|
//echo $outPath . "<br>";
|
||||||
//error_log1($outPath);
|
//error_log1($outPath);
|
||||||
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
|
|
||||||
|
|
||||||
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
|
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,40 +8,6 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Deploy to Heroku
|
|
||||||
|
|
||||||
### Official
|
|
||||||
|
|
||||||
https://heroku.com
|
|
||||||
|
|
||||||
### Demo
|
|
||||||
|
|
||||||
https://herooneindex.herokuapp.com/
|
|
||||||
|
|
||||||
### How to Install
|
|
||||||
|
|
||||||
> ~~Click the button [](https://heroku.com/deploy) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`)
|
|
||||||
>
|
|
||||||
> Star this project, then Fork, create a app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Deploy to Glitch
|
|
||||||
|
|
||||||
### Official
|
|
||||||
|
|
||||||
https://glitch.com/
|
|
||||||
|
|
||||||
### Demo
|
|
||||||
|
|
||||||
https://onemanager.glitch.me/
|
|
||||||
|
|
||||||
### How to Install
|
|
||||||
|
|
||||||
[New Project] -> [Import form Github] -> paste "https://github.com/qkqpttgf/OneManager-php" , after done, [Show] -> [In a New Window].
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Deploy to Vercel
|
# Deploy to Vercel
|
||||||
|
|
||||||
### Official
|
### Official
|
||||||
@@ -60,7 +26,64 @@
|
|||||||
|
|
||||||
### How to Install
|
### How to Install
|
||||||
|
|
||||||
https://scfonedrive.github.io/Vercel/Deploy.html .
|
> https://scfonedrive.github.io/Vercel/Deploy.html .
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Deploy to Replit
|
||||||
|
|
||||||
|
### Official
|
||||||
|
|
||||||
|
https://repl.it/
|
||||||
|
https://replit.com/
|
||||||
|
|
||||||
|
### Demo
|
||||||
|
|
||||||
|
https://onemanager.qkqpttgf.repl.co/
|
||||||
|
|
||||||
|
### Notice
|
||||||
|
|
||||||
|
> `Import from Github` useing the `.replit` file in code files will cause an empty web page, may someone help me?
|
||||||
|
|
||||||
|
### How to Install
|
||||||
|
|
||||||
|
> 1. Click the "+" or "Create Repl", find template "PHP Web Server" (via input "php"), input a name for your project in "Title" or left it default, Click the "+ Create Repl".
|
||||||
|
> 2. After done, input `git clone https://github.com/qkqpttgf/OneManager-php && mv -b OneManager-php/* ./ && mv -b OneManager-php/.[^.]* ./ && rm -rf *~ && rm -rf OneManager-php` to Console or Shell on the right, press "Enter" to run it.
|
||||||
|
> 3. Click the green button "Run", it will show the web page on the right, you can open it in a new tab or window.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Deploy to Heroku
|
||||||
|
|
||||||
|
### Official
|
||||||
|
|
||||||
|
https://heroku.com
|
||||||
|
|
||||||
|
### Demo
|
||||||
|
|
||||||
|
https://herooneindex.herokuapp.com/
|
||||||
|
|
||||||
|
### How to Install
|
||||||
|
|
||||||
|
> ~~Click the button [](https://heroku.com/deploy) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`)
|
||||||
|
>
|
||||||
|
> Star this project, then Fork, create an app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Deploy to Glitch
|
||||||
|
|
||||||
|
### Official
|
||||||
|
|
||||||
|
https://glitch.com/
|
||||||
|
|
||||||
|
### Demo
|
||||||
|
|
||||||
|
https://onemanager.glitch.me/
|
||||||
|
|
||||||
|
### How to Install
|
||||||
|
|
||||||
|
[New Project] -> [Import form Github] -> paste "https://github.com/qkqpttgf/OneManager-php" , after done, [Show] -> [In a New Window].
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+47
-22
@@ -2,12 +2,59 @@
|
|||||||
|
|
||||||
# 注意:
|
# 注意:
|
||||||
|
|
||||||
|
请关掉浏览器的翻译。
|
||||||
|
|
||||||
Releases只是当存档在用的,并不是最新代码。
|
Releases只是当存档在用的,并不是最新代码。
|
||||||
|
|
||||||
请将设置中所有的设置项的说明都读一遍,有些问题就不用问了。
|
请将设置中所有的设置项的说明都读一遍,有些问题就不用问了。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
# 部署到 Vercel
|
||||||
|
|
||||||
|
### 官网
|
||||||
|
|
||||||
|
https://vercel.com/
|
||||||
|
|
||||||
|
### Demo
|
||||||
|
|
||||||
|
https://onemanager-php.vercel.app/
|
||||||
|
|
||||||
|
### 注意
|
||||||
|
|
||||||
|
> 1. 每次更改配置后都要等 30-50s 来确保部署成功;
|
||||||
|
>
|
||||||
|
> 2. Vercel 每天限制 100 次部署。
|
||||||
|
|
||||||
|
### 安装(英文)
|
||||||
|
|
||||||
|
https://scfonedrive.github.io/Vercel/Deploy.html
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 部署到 Replit
|
||||||
|
|
||||||
|
### 官网
|
||||||
|
|
||||||
|
https://repl.it/
|
||||||
|
https://replit.com/
|
||||||
|
|
||||||
|
### Demo
|
||||||
|
|
||||||
|
https://onemanager.qkqpttgf.repl.co/
|
||||||
|
|
||||||
|
### 注意
|
||||||
|
|
||||||
|
> 直接`Import from Github`通过`.replit`文件指定php时,网页会空白,有人帮忙解决吗?
|
||||||
|
|
||||||
|
### 安装
|
||||||
|
|
||||||
|
> 1. 点右上的 "+" 或左上的 "+ Create Repl",template中输入php,点选"PHP Web Server",在"Title"里输入你想要的名称或者让它默认, 点下面的"+ Create Repl"。
|
||||||
|
> 2. 结束后,在右边的Console或Shell里输入 `git clone https://github.com/qkqpttgf/OneManager-php && mv -b OneManager-php/* ./ && mv -b OneManager-php/.[^.]* ./ && rm -rf *~ && rm -rf OneManager-php` 敲回车运行。
|
||||||
|
> 3. 点上方的绿色 "Run" 按钮,右边会显示一个网页,你要在新窗口打开它来安装,不然不能登录。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# 部署到 Heroku
|
# 部署到 Heroku
|
||||||
|
|
||||||
### 官网
|
### 官网
|
||||||
@@ -40,28 +87,6 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# 部署到 Vercel
|
|
||||||
|
|
||||||
### 官网
|
|
||||||
|
|
||||||
https://vercel.com/
|
|
||||||
|
|
||||||
### Demo
|
|
||||||
|
|
||||||
https://onemanager-php.vercel.app/
|
|
||||||
|
|
||||||
### 注意
|
|
||||||
|
|
||||||
> 1. 每次更改配置后都要等 30-50s 来确保部署成功;
|
|
||||||
>
|
|
||||||
> 2. Vercel 每天限制 100 次部署。
|
|
||||||
|
|
||||||
### 安装(英文)
|
|
||||||
|
|
||||||
https://scfonedrive.github.io/Vercel/Deploy.html
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 部署到腾讯无服务器云函数 Serverless Cloud Function (SCF)
|
# 部署到腾讯无服务器云函数 Serverless Cloud Function (SCF)
|
||||||
|
|
||||||
### 官网
|
### 官网
|
||||||
|
|||||||
@@ -305,7 +305,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div style="margin: 24px">
|
<div style="margin: 24px">
|
||||||
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
|
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
|
||||||
<a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <!--constStr@Download--></a>
|
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <!--constStr@Download--></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -396,6 +396,7 @@
|
|||||||
<!--LoginEnd-->
|
<!--LoginEnd-->
|
||||||
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
|
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
<!--AdminStart-->
|
||||||
window.onload = function ()
|
window.onload = function ()
|
||||||
{
|
{
|
||||||
// 获取所有radios元素
|
// 获取所有radios元素
|
||||||
@@ -448,6 +449,7 @@
|
|||||||
radios[i].setAttribute("currStatus", false);
|
radios[i].setAttribute("currStatus", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
<!--AdminEnd-->
|
||||||
function changelanguage(str)
|
function changelanguage(str)
|
||||||
{
|
{
|
||||||
if (str=='Language') str = '';
|
if (str=='Language') str = '';
|
||||||
@@ -479,7 +481,10 @@
|
|||||||
<!--IsFileStart-->
|
<!--IsFileStart-->
|
||||||
var $url = document.getElementById('url');
|
var $url = document.getElementById('url');
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
||||||
|
let url = location.href;
|
||||||
|
url = url.substr(0, url.length-8);
|
||||||
|
$url.innerHTML = url.replace(/&/g, '&amp;');
|
||||||
$url.style.height = $url.scrollHeight + 'px';
|
$url.style.height = $url.scrollHeight + 'px';
|
||||||
}
|
}
|
||||||
<!--IsvideoFileStart-->
|
<!--IsvideoFileStart-->
|
||||||
|
|||||||
+136
-67
@@ -187,7 +187,10 @@
|
|||||||
<img src="<!--FileEncodeUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';if (this.offsetHeight>document.documentElement.clientHeight) this.style.height=document.documentElement.clientHeight + 'px';" />
|
<img src="<!--FileEncodeUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';if (this.offsetHeight>document.documentElement.clientHeight) this.style.height=document.documentElement.clientHeight + 'px';" />
|
||||||
<!--IsimgFileEnd-->
|
<!--IsimgFileEnd-->
|
||||||
<!--IsvideoFileStart-->
|
<!--IsvideoFileStart-->
|
||||||
<div id="video-a0"></div>
|
<div id="video-a0" class="artplayerdiv"></div>
|
||||||
|
<!--<script src="https://artplayer.org/uncompiled/artplayer.js"></script>-->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/artplayer@4.1.0/dist/artplayer.min.js"></script>
|
||||||
|
<!--<script src="https://unpkg.com/artplayer@4.1.0/dist/artplayer.js"></script>-->
|
||||||
<!--IsvideoFileEnd-->
|
<!--IsvideoFileEnd-->
|
||||||
<!--IsmusicFileStart-->
|
<!--IsmusicFileStart-->
|
||||||
<audio src="<!--FileDownUrl-->" controls="controls" style="width: 100%"></audio>
|
<audio src="<!--FileDownUrl-->" controls="controls" style="width: 100%"></audio>
|
||||||
@@ -487,7 +490,7 @@
|
|||||||
<!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
|
<!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
|
||||||
<script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
|
<script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
|
||||||
<!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
|
<!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
|
||||||
<!--AliyundriveUploadJsStart--><script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
|
<!--AliyundriveUploadJsStart--><script src="https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
|
||||||
<!--IsFileStart--><!--IspdfFileStart--><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
|
<!--IsFileStart--><!--IspdfFileStart--><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
|
||||||
<!--ListEnd-->
|
<!--ListEnd-->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -548,70 +551,136 @@
|
|||||||
}
|
}
|
||||||
<!--IstxtFileEnd-->
|
<!--IstxtFileEnd-->
|
||||||
<!--IsvideoFileStart-->
|
<!--IsvideoFileStart-->
|
||||||
function loadResources(type, src, callback) {
|
//document.getElementById('video-a0').style.height = window.innerHeight + 'px';
|
||||||
let script = document.createElement(type);
|
var fileurl = "<!--FileEncodeUrl-->";
|
||||||
let loaded = false;
|
var filename1 = fileurl.substr(0, fileurl.lastIndexOf('.'));
|
||||||
if (typeof callback === 'function') {
|
var art = new Artplayer({
|
||||||
script.onload = script.onreadystatechange = () => {
|
//container: '#video-a0',
|
||||||
if (!loaded && (!script.readyState || /loaded|complete/.test(script.readyState))) {
|
container: '.artplayerdiv',
|
||||||
script.onload = script.onreadystatechange = null;
|
url: fileurl,
|
||||||
loaded = true;
|
title: fileurl,
|
||||||
callback();
|
autoHeight: true,
|
||||||
}
|
//autoplay: true,
|
||||||
}
|
pip: true,
|
||||||
}
|
autoSize: true,
|
||||||
if (type === 'link') {
|
autoMini: true,
|
||||||
script.href = src;
|
//loop: true,
|
||||||
script.rel = 'stylesheet';
|
fullscreen: true,
|
||||||
} else {
|
fullscreenWeb: true,
|
||||||
script.src = src;
|
subtitleOffset: true,
|
||||||
}
|
miniProgressBar: true,
|
||||||
document.getElementsByTagName('head')[0].appendChild(script);
|
//localVideo: true,
|
||||||
}
|
//localSubtitle: true,
|
||||||
function addVideos(videos) {
|
mutex: true,
|
||||||
let host = 'https://s0.pstatp.com/cdn/expire-1-M';
|
//backdrop: true,
|
||||||
let unloadedResourceCount = 4;
|
theme: '#23ade5',
|
||||||
let callback = (() => {
|
lang: navigator.language.toLowerCase(),
|
||||||
return () => {
|
/*moreVideoAttr: {
|
||||||
if (!--unloadedResourceCount) {
|
crossOrigin: 'anonymous',
|
||||||
createDplayers(videos);
|
},
|
||||||
}
|
settings: [
|
||||||
};
|
{
|
||||||
})(unloadedResourceCount, videos);
|
index: 1,
|
||||||
loadResources(
|
html: 'Custom setting',
|
||||||
'link',
|
click: function (setting) {
|
||||||
host + '/dplayer/1.25.0/DPlayer.min.css',
|
console.info('You clicked on the custom setting');
|
||||||
callback
|
setting.show = false;
|
||||||
);
|
},
|
||||||
loadResources(
|
},
|
||||||
'script',
|
],
|
||||||
host + '/dplayer/1.25.0/DPlayer.min.js',
|
contextmenu: [
|
||||||
callback
|
{
|
||||||
);
|
html: 'Custom menu',
|
||||||
loadResources(
|
click: function (contextmenu) {
|
||||||
'script',
|
console.info('You clicked on the custom menu');
|
||||||
host + '/hls.js/0.12.4/hls.light.min.js',
|
contextmenu.show = false;
|
||||||
callback
|
},
|
||||||
);
|
},
|
||||||
loadResources(
|
],
|
||||||
'script',
|
layers: [
|
||||||
host + '/flv.js/1.5.0/flv.min.js',
|
{
|
||||||
callback
|
html: '<img style="width: 100px" src="/assets/sample/layer.png">',
|
||||||
);
|
click: function () {
|
||||||
}
|
console.info('You clicked on the custom layer');
|
||||||
function createDplayers(videos) {
|
},
|
||||||
for (i = 0; i < videos.length; i++) {
|
style: {
|
||||||
console.log(videos[i]);
|
position: 'absolute',
|
||||||
new DPlayer({
|
top: '20px',
|
||||||
container: document.getElementById('video-a' + i),
|
right: '20px',
|
||||||
screenshot: true,
|
opacity: '.9',
|
||||||
video: {
|
},
|
||||||
url: videos[i]
|
},
|
||||||
}
|
],
|
||||||
});
|
quality: [
|
||||||
}
|
{
|
||||||
}
|
default: true,
|
||||||
addVideos(["<!--FileEncodeUrl-->"]);
|
html: 'SD 480P',
|
||||||
|
url: '/assets/sample/video.mp4',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
html: 'HD 720P',
|
||||||
|
url: '/assets/sample/video.mp4',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
thumbnails: {
|
||||||
|
url: '/assets/sample/thumbnails.png',
|
||||||
|
number: 100,
|
||||||
|
width: 160,
|
||||||
|
height: 90,
|
||||||
|
column: 10,
|
||||||
|
},*/
|
||||||
|
subtitle: {
|
||||||
|
url: filename1+'.srt',
|
||||||
|
type: 'srt',
|
||||||
|
style: {
|
||||||
|
color: '#03A9F4',
|
||||||
|
},
|
||||||
|
encoding: 'utf-8',
|
||||||
|
bilingual: true,
|
||||||
|
},/*
|
||||||
|
highlight: [
|
||||||
|
{
|
||||||
|
time: 60,
|
||||||
|
text: 'One more chance',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
time: 120,
|
||||||
|
text: '谁でもいいはずなのに',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
time: 180,
|
||||||
|
text: '夏の想い出がまわる',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
time: 240,
|
||||||
|
text: 'こんなとこにあるはずもないのに',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
time: 300,
|
||||||
|
text: '终わり',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
controls: [
|
||||||
|
{
|
||||||
|
position: 'right',
|
||||||
|
html: 'localsubtitle',
|
||||||
|
mounted: ($preview) => {
|
||||||
|
art.plugins.localSubtitle.attach($preview);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
icons: {
|
||||||
|
indicator: '<img width="16" heigth="16" src="/assets/img/indicator.svg">',
|
||||||
|
loading: '<img src="/assets/img/ploading.gif">',
|
||||||
|
state: '<img width="150" heigth="150" src="/assets/img/state.svg">',
|
||||||
|
},*/
|
||||||
|
});
|
||||||
|
art.on('ready', (...agrs) => {
|
||||||
|
console.log(document.getElementById('video-a0').style.height);
|
||||||
|
//if (document.getElementById('video-a0').style.height == window.innerHeight+'px') document.getElementById('video-a0').style.height = (art.rect.height+3) + 'px';
|
||||||
|
//console.log(document.getElementById('video-a0').style.height);
|
||||||
|
//art.play();
|
||||||
|
})
|
||||||
<!--IsvideoFileEnd-->
|
<!--IsvideoFileEnd-->
|
||||||
<!--IspdfFileStart-->
|
<!--IspdfFileStart-->
|
||||||
pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
|
pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
|
||||||
@@ -1647,6 +1716,6 @@
|
|||||||
<!--EncryptedEnd-->
|
<!--EncryptedEnd-->
|
||||||
</script>
|
</script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
|
||||||
<!--LoginStart--><script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script><!--LoginEnd-->
|
<!--LoginStart--><script src="https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js"></script><!--LoginEnd-->
|
||||||
<!--customScript-->
|
<!--customScript-->
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+3
-1
@@ -558,7 +558,9 @@
|
|||||||
<!--IsFileStart-->
|
<!--IsFileStart-->
|
||||||
var $url = document.getElementById('url');
|
var $url = document.getElementById('url');
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
let url = location.href;
|
||||||
|
url = url.substr(0, url.length-8);
|
||||||
|
$url.innerHTML = url.replace(/&/g, '&amp;');
|
||||||
$url.style.height = $url.scrollHeight + 'px';
|
$url.style.height = $url.scrollHeight + 'px';
|
||||||
}
|
}
|
||||||
<!--IsofficeFileStart-->
|
<!--IsofficeFileStart-->
|
||||||
|
|||||||
@@ -222,7 +222,7 @@
|
|||||||
<div style="margin: 12px 4px 4px; text-align: center">
|
<div style="margin: 12px 4px 4px; text-align: center">
|
||||||
<div style="margin: 24px">
|
<div style="margin: 24px">
|
||||||
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
|
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
|
||||||
<a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <!--constStr@Download--></a>
|
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <!--constStr@Download--></a>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin: 24px">
|
<div style="margin: 24px">
|
||||||
<!--IsimgFileStart-->
|
<!--IsimgFileStart-->
|
||||||
@@ -717,7 +717,10 @@ return false;
|
|||||||
<!--IsFileStart-->
|
<!--IsFileStart-->
|
||||||
var $url = document.getElementById('url');
|
var $url = document.getElementById('url');
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
||||||
|
let url = location.href;
|
||||||
|
url = url.substr(0, url.length-8);
|
||||||
|
$url.innerHTML = url.replace(/&/g, '&amp;');
|
||||||
$url.style.height = $url.scrollHeight + 'px';
|
$url.style.height = $url.scrollHeight + 'px';
|
||||||
}
|
}
|
||||||
<!--IsofficeFileStart-->
|
<!--IsofficeFileStart-->
|
||||||
|
|||||||
+4
-1
@@ -479,7 +479,10 @@
|
|||||||
<!--IsFileStart-->
|
<!--IsFileStart-->
|
||||||
var $url = document.getElementById('url');
|
var $url = document.getElementById('url');
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
||||||
|
let url = location.href;
|
||||||
|
url = url.substr(0, url.length-8);
|
||||||
|
$url.innerHTML = url.replace(/&/g, '&amp;');
|
||||||
$url.style.height = $url.scrollHeight + 'px';
|
$url.style.height = $url.scrollHeight + 'px';
|
||||||
}
|
}
|
||||||
<!--IsofficeFileStart-->
|
<!--IsofficeFileStart-->
|
||||||
|
|||||||
+5
-2
@@ -179,7 +179,7 @@
|
|||||||
<div style="margin: 12px 4px 4px; text-align: center">
|
<div style="margin: 12px 4px 4px; text-align: center">
|
||||||
<div style="margin: 24px">
|
<div style="margin: 24px">
|
||||||
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
|
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
|
||||||
<a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <!--constStr@Download--></a>
|
<a href="<!--FileEncodeUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <!--constStr@Download--></a>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin: 24px">
|
<div style="margin: 24px">
|
||||||
<!--IsimgFileStart-->
|
<!--IsimgFileStart-->
|
||||||
@@ -509,7 +509,10 @@
|
|||||||
<!--IsFileStart-->
|
<!--IsFileStart-->
|
||||||
var $url = document.getElementById('url');
|
var $url = document.getElementById('url');
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
//$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
||||||
|
let url = location.href;
|
||||||
|
url = url.substr(0, url.length-8);
|
||||||
|
$url.innerHTML = url.replace(/&/g, '&amp;');
|
||||||
$url.style.height = $url.scrollHeight + 'px';
|
$url.style.height = $url.scrollHeight + 'px';
|
||||||
}
|
}
|
||||||
<!--IsofficeFileStart-->
|
<!--IsofficeFileStart-->
|
||||||
|
|||||||
+7
-10
@@ -187,10 +187,10 @@
|
|||||||
</path></svg></div>
|
</path></svg></div>
|
||||||
<div style="padding:1px" id="top-div">
|
<div style="padding:1px" id="top-div">
|
||||||
<!--LoginStart-->
|
<!--LoginStart-->
|
||||||
<a class="login" href="?admin"><ion-icon name="ban-outline"></ion-icon></a><!--onclick="login();"-->
|
<a class="login" href="?admin"><ion-icon name="add-circle-outline"></ion-icon></a><!--onclick="login();"-->
|
||||||
<!--LoginEnd-->
|
<!--LoginEnd-->
|
||||||
<!--AdminStart-->
|
<!--AdminStart-->
|
||||||
<li class="operate" id="opflow"><ion-icon name="ban-outline"></ion-icon><ul>
|
<li class="operate" id="opflow"><ion-icon name="add-circle-outline"></ion-icon><ul>
|
||||||
<!--IsFolderStart-->
|
<!--IsFolderStart-->
|
||||||
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle-outline"></ion-icon><!--constStr@Create--></a></li>
|
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle-outline"></ion-icon><!--constStr@Create--></a></li>
|
||||||
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock-closed-outline"></ion-icon><!--constStr@Encrypt--></a></li>
|
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock-closed-outline"></ion-icon><!--constStr@Encrypt--></a></li>
|
||||||
@@ -300,7 +300,9 @@
|
|||||||
var prePath = strFullPath.substring(0, pos);
|
var prePath = strFullPath.substring(0, pos);
|
||||||
var width = window.innerWidth;
|
var width = window.innerWidth;
|
||||||
// var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
|
// var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
|
||||||
document.getElementById("url").value= prePath + "<!--FileEncodeUrl-->";
|
let url = location.href;
|
||||||
|
url = url.substr(0, url.length-8);
|
||||||
|
document.getElementById("url").value= url;
|
||||||
// document.getElementById("url").value= prePath + postPath + "<!--FileEncodeUrl-->";
|
// document.getElementById("url").value= prePath + postPath + "<!--FileEncodeUrl-->";
|
||||||
if(width < 495) {
|
if(width < 495) {
|
||||||
if(document.getElementById("office-a")) {
|
if(document.getElementById("office-a")) {
|
||||||
@@ -603,7 +605,7 @@
|
|||||||
<!--MdRequireStart--><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css">
|
<!--MdRequireStart--><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css">
|
||||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/marked@2.0.0/lib/marked.min.js"></script><!--MdRequireEnd-->
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/marked@2.0.0/lib/marked.min.js"></script><!--MdRequireEnd-->
|
||||||
<!--GuestUploadStart--><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/spark-md5@3.0.1/spark-md5.min.js"></script><!--GuestUploadEnd-->
|
<!--GuestUploadStart--><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/spark-md5@3.0.1/spark-md5.min.js"></script><!--GuestUploadEnd-->
|
||||||
<!--AliyundriveUploadJsStart--><script src="https://cdn.jsdelivr.net/npm/sha1@1.1.1/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
|
<!--AliyundriveUploadJsStart--><script src="https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js"></script><!--AliyundriveUploadJsEnd-->
|
||||||
<!--IsFileStart--><!--IspdfFileStart--><script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@2.8.335/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
|
<!--IsFileStart--><!--IspdfFileStart--><script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@2.8.335/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
|
||||||
<!--ListEnd-->
|
<!--ListEnd-->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -642,11 +644,6 @@
|
|||||||
<!--LoginEnd-->
|
<!--LoginEnd-->
|
||||||
<!--ListStart-->
|
<!--ListStart-->
|
||||||
<!--IsFileStart-->
|
<!--IsFileStart-->
|
||||||
var $url = document.getElementById('url').value;
|
|
||||||
if ($url) {
|
|
||||||
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
|
||||||
$url.style.height = $url.scrollHeight + 'px';
|
|
||||||
}
|
|
||||||
<!--IsofficeFileStart-->
|
<!--IsofficeFileStart-->
|
||||||
var $officearea=document.getElementById('office-a');
|
var $officearea=document.getElementById('office-a');
|
||||||
if ($officearea) {
|
if ($officearea) {
|
||||||
@@ -1807,6 +1804,6 @@ function size_format(num) {
|
|||||||
document.getElementById('password1').focus();
|
document.getElementById('password1').focus();
|
||||||
<!--EncryptedEnd-->
|
<!--EncryptedEnd-->
|
||||||
</script>
|
</script>
|
||||||
<!--LoginStart--><script src="https://cdn.jsdelivr.net/npm/sha1@1.1.1/sha1.min.js"></script><!--LoginEnd-->
|
<!--LoginStart--><script src="https://cdn.jsdelivr.net/npm/js-sha1@0.6.0/src/sha1.min.js"></script><!--LoginEnd-->
|
||||||
<!--customScript-->
|
<!--customScript-->
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
20211220-1100.42
|
||||||
|
Add new platform Replit. Add a git source for update. sha1.js use jsdelivr cdn. fix some bugs.
|
||||||
|
新增Replit平台。新增国内git源,以后国内可以选择从HIT源更新。sha1.js换成jsdelivr CDN。修复bug。
|
||||||
|
|
||||||
20211201-1602.41
|
20211201-1602.41
|
||||||
add a latent function, you can edit platform token(or API key) via '?setup=auth' when the token invalid, not need edit it in Environment(or Config Var) manually, (even in Vercel, config saved in file, and can't modiy it manually).
|
add a latent function, you can edit platform token(or API key) via '?setup=auth' when the token invalid, not need edit it in Environment(or Config Var) manually, (even in Vercel, config saved in file, and can't modiy it manually).
|
||||||
新增隐藏功能,在平台操作代码的token或API key失效时,可以在 '?setup=auth' 修改它,不用去环境变量修改了(特别地,Vercel保存在代码中时都改不到)。
|
新增隐藏功能,在平台操作代码的token或API key失效时,可以在 '?setup=auth' 修改它,不用去环境变量修改了(特别地,Vercel保存在代码中时都改不到)。
|
||||||
@@ -19,7 +23,6 @@ add fileConduitSize&fileConduitCacheTime, little files can stream from program,
|
|||||||
20210903
|
20210903
|
||||||
add a latent function, you can run some command by '?setup=cmd', be care, please dont try "top", and set times by "ping -c 4".
|
add a latent function, you can run some command by '?setup=cmd', be care, please dont try "top", and set times by "ping -c 4".
|
||||||
新增隐藏功能,你可以通过'?setup=cmd'来跑一些命令,注意不要试图跑top,另外ping请-c设置次数。
|
新增隐藏功能,你可以通过'?setup=cmd'来跑一些命令,注意不要试图跑top,另外ping请-c设置次数。
|
||||||
|
|
||||||
20210820-1810.40
|
20210820-1810.40
|
||||||
because Vercel must redeploy after change Environment Variables, and it must <4k, so decide that, save config in code file. <font color=red>in Vercel, after update, please install again. if you want continue use Environment, please add a ( name: "ONEMANAGER_CONFIG_SAVE", value: "env" ) in Environment Variables in Project Settings before update.</font>
|
because Vercel must redeploy after change Environment Variables, and it must <4k, so decide that, save config in code file. <font color=red>in Vercel, after update, please install again. if you want continue use Environment, please add a ( name: "ONEMANAGER_CONFIG_SAVE", value: "env" ) in Environment Variables in Project Settings before update.</font>
|
||||||
因为Vercel修改环境变量也必须重新部署才生效,而且环境变量只能小于4k,所以决定将配置保存在代码文件中。<font color=red>升级更新后,用Vercel的请重新安装。如果还想继续使用环境变量,请在更新前,在Project Settings的Environment Variables中,新增一个( name: "ONEMANAGER_CONFIG_SAVE", value: "env" )的环境变量。</font>
|
因为Vercel修改环境变量也必须重新部署才生效,而且环境变量只能小于4k,所以决定将配置保存在代码文件中。<font color=red>升级更新后,用Vercel的请重新安装。如果还想继续使用环境变量,请在更新前,在Project Settings的Environment Variables中,新增一个( name: "ONEMANAGER_CONFIG_SAVE", value: "env" )的环境变量。</font>
|
||||||
|
|||||||
Reference in New Issue
Block a user