forked from devsam/image
git_pull이 CLI에서도 동작하게 변경
This commit is contained in:
+33
-24
@@ -24,10 +24,14 @@ function getVersion($target=null){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isCommandLineInterface()
|
||||||
|
{
|
||||||
|
return (php_sapi_name() === 'cli');
|
||||||
|
}
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$req_hash = $_REQUEST['req']??'';
|
|
||||||
$req_time = $_REQUEST['time']??0;
|
|
||||||
|
|
||||||
$json_response = [
|
$json_response = [
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
@@ -35,33 +39,38 @@ $json_response = [
|
|||||||
'version'=>null,
|
'version'=>null,
|
||||||
];
|
];
|
||||||
|
|
||||||
if(!$req_hash){
|
if (!isCommandLineInterface()) {
|
||||||
$json_response['reason'] = 'no req';
|
$req_hash = $_REQUEST['req']??'';
|
||||||
die(json_encode($json_response));
|
$req_time = $_REQUEST['time']??0;
|
||||||
}
|
|
||||||
if(!$req_time || !is_numeric($req_time)){
|
|
||||||
$json_response['reason'] = 'invalid time';
|
|
||||||
die(json_encode($json_response));
|
|
||||||
}
|
|
||||||
|
|
||||||
$key = HashKey::KEY;
|
if (!$req_hash) {
|
||||||
if(strlen($key)<16){
|
$json_response['reason'] = 'no req';
|
||||||
$json_response['reason'] = 'key is too short';
|
die(json_encode($json_response));
|
||||||
die(json_encode($json_response));
|
}
|
||||||
}
|
if (!$req_time || !is_numeric($req_time)) {
|
||||||
|
$json_response['reason'] = 'invalid time';
|
||||||
|
die(json_encode($json_response));
|
||||||
|
}
|
||||||
|
|
||||||
$timestamp = time();
|
$key = HashKey::KEY;
|
||||||
|
if (strlen($key)<16) {
|
||||||
|
$json_response['reason'] = 'key is too short';
|
||||||
|
die(json_encode($json_response));
|
||||||
|
}
|
||||||
|
|
||||||
if(abs($timestamp - $req_time) > 300){
|
$timestamp = time();
|
||||||
$json_response['reason'] = 'time difference';
|
|
||||||
die(json_encode($json_response));
|
|
||||||
}
|
|
||||||
|
|
||||||
$ans_hash = hashPassword(sprintf("%016x", $req_time), $key);
|
if (abs($timestamp - $req_time) > 300) {
|
||||||
|
$json_response['reason'] = 'time difference';
|
||||||
|
die(json_encode($json_response));
|
||||||
|
}
|
||||||
|
|
||||||
if($ans_hash != $req_hash){
|
$ans_hash = hashPassword(sprintf("%016x", $req_time), $key);
|
||||||
$json_response['reason'] = 'hash mismatch';
|
|
||||||
die(json_encode($json_response));
|
if ($ans_hash != $req_hash) {
|
||||||
|
$json_response['reason'] = 'hash mismatch';
|
||||||
|
die(json_encode($json_response));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exec("git pull -q 2>&1", $output);
|
exec("git pull -q 2>&1", $output);
|
||||||
|
|||||||
Reference in New Issue
Block a user