Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bed18136f | ||
|
|
e0030cc390 | ||
|
|
885ab4502e | ||
|
|
8c630f2b63 | ||
|
|
d2be68899d | ||
|
|
90b7fb8679 | ||
|
|
972aebc0be | ||
|
|
3ee857c50a | ||
|
|
0d60a63308 | ||
|
|
e1ee13d2d9 | ||
|
|
711e951ddd | ||
|
|
3a50184bb8 | ||
|
|
b341ed376c | ||
|
|
2d106cf5fe | ||
|
|
b7f62fd70a | ||
|
|
4bfa257b02 | ||
|
|
0b4ef0e333 | ||
|
|
0a8b35d528 | ||
|
|
09052ec21d | ||
|
|
100a0cb9be | ||
|
|
fd07bae0bc | ||
|
|
a501219eee | ||
|
|
fbb0cb0149 | ||
|
|
9240d2e328 | ||
|
|
1b54cc1c43 | ||
|
|
b42e2ad627 | ||
|
|
1c11f0c2df |
@@ -1,3 +1,4 @@
|
||||
/hook/gogs_key.php
|
||||
/hook/logs.txt
|
||||
/hook/list.json
|
||||
/hook/HashKey.php
|
||||
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 9.9 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 648 KiB |
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\img_service;
|
||||
|
||||
class HashKey{
|
||||
const KEY = '=HashKey=';
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace sammo\img_service;
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
|
||||
$json_response = [
|
||||
'result'=>false,
|
||||
'reason'=>'Unknown',
|
||||
];
|
||||
|
||||
$key = $_REQUEST['key']??'';
|
||||
|
||||
if (!$key) {
|
||||
$json_response['reason'] = 'no key';
|
||||
die(json_encode($json_response));
|
||||
}
|
||||
|
||||
if (strlen($key)<16) {
|
||||
$json_response['reason'] = 'key is too short';
|
||||
die(json_encode($json_response));
|
||||
}
|
||||
|
||||
$keyExists = file_exists(__DIR__.'/HashKey.php');
|
||||
if($keyExists){
|
||||
$json_response['reason'] = 'already exists';
|
||||
die(json_encode($json_response));
|
||||
}
|
||||
|
||||
$keyTemplate = file_get_contents(__DIR__.'/HashKey.orig.php');
|
||||
$keyFile = str_replace('=HashKey=', $key, $keyTemplate);
|
||||
file_put_contents(__DIR__.'/HashKey.php', $keyFile);
|
||||
|
||||
$json_response['result'] = true;
|
||||
$json_response['reason'] = 'success';
|
||||
die(json_encode($json_response));
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
namespace sammo\img_service;
|
||||
|
||||
include(__DIR__.'/HashKey.php');
|
||||
|
||||
function hashPassword($salt, $password)
|
||||
{
|
||||
return hash('sha512', $salt.$password.$salt);
|
||||
}
|
||||
|
||||
|
||||
function getVersion($target=null){
|
||||
if($target){
|
||||
$command = sprintf('git describe %s --long --tags', escapeshellarg($target));
|
||||
}
|
||||
else{
|
||||
$command = 'git describe --long --tags';
|
||||
}
|
||||
exec($command, $output);
|
||||
if(is_array($output)){
|
||||
$output = join('', $output);
|
||||
}
|
||||
return trim($output);
|
||||
|
||||
}
|
||||
|
||||
function isCommandLineInterface()
|
||||
{
|
||||
return (php_sapi_name() === 'cli');
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
|
||||
|
||||
$json_response = [
|
||||
'result'=>false,
|
||||
'reason'=>'Unknown',
|
||||
'version'=>null,
|
||||
];
|
||||
|
||||
if (!isCommandLineInterface()) {
|
||||
$req_hash = $_REQUEST['req']??'';
|
||||
$req_time = $_REQUEST['time']??0;
|
||||
|
||||
if (!$req_hash) {
|
||||
$json_response['reason'] = 'no req';
|
||||
die(json_encode($json_response));
|
||||
}
|
||||
if (!$req_time || !is_numeric($req_time)) {
|
||||
$json_response['reason'] = 'invalid time';
|
||||
die(json_encode($json_response));
|
||||
}
|
||||
|
||||
$key = HashKey::KEY;
|
||||
if (strlen($key)<16) {
|
||||
$json_response['reason'] = 'key is too short';
|
||||
die(json_encode($json_response));
|
||||
}
|
||||
|
||||
$timestamp = time();
|
||||
|
||||
if (abs($timestamp - $req_time) > 300) {
|
||||
$json_response['reason'] = 'time difference';
|
||||
die(json_encode($json_response));
|
||||
}
|
||||
|
||||
$ans_hash = hashPassword(sprintf("%016x", $req_time), $key);
|
||||
|
||||
if ($ans_hash != $req_hash) {
|
||||
$json_response['reason'] = 'hash mismatch';
|
||||
die(json_encode($json_response));
|
||||
}
|
||||
}
|
||||
|
||||
exec("git pull -q 2>&1", $output);
|
||||
|
||||
exec("git ls-files -z ../icons", $raw_img_list);
|
||||
$raw_img_list = explode("\x00", $raw_img_list[0]);
|
||||
$img_list = [];
|
||||
|
||||
foreach ($raw_img_list as $path) {
|
||||
$pos = strpos($path, '../icons/');
|
||||
if($pos === false){
|
||||
continue;
|
||||
}
|
||||
$path = substr($path, $pos + 9);
|
||||
|
||||
|
||||
$pathinfo = pathinfo($path);
|
||||
$dpath = $pathinfo['dirname'];
|
||||
$basename = $pathinfo['basename'];
|
||||
$filename = $pathinfo['filename'];
|
||||
|
||||
if(!\key_exists($dpath, $img_list)){
|
||||
$img_list[$dpath] = [];
|
||||
}
|
||||
$img_list[$dpath][$filename] = $basename;
|
||||
|
||||
}
|
||||
|
||||
file_put_contents('list.json', json_encode($img_list));
|
||||
|
||||
|
||||
|
||||
$json_response['result'] = true;
|
||||
$json_response['reason'] = 'success';
|
||||
$json_response['version'] = getVersion();
|
||||
die(json_encode($json_response));
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 6.4 KiB |