diff --git a/www/html/Admin/api/justice-push.php b/www/html/Admin/api/justice-push.php new file mode 100644 index 0000000..149cc6e --- /dev/null +++ b/www/html/Admin/api/justice-push.php @@ -0,0 +1,40 @@ + false, 'error' => 'ใช้ POST เท่านั้น'], 405); +} + +$body = require_json_body(); +$raw = isset($body['message']) ? trim((string) $body['message']) : ''; +if (strlen($raw) > 180) { + json_response(['ok' => false, 'error' => 'ข้อความ commit ยาวเกิน 180 ตัวอักษร'], 400); +} +// กันทำลาย shell / git -m +$safe = str_replace(["\n", "\r", "\0", '"', "'", '`', '$', '\\'], '', $raw); +$msg = $safe !== '' ? $safe : ('Admin: Gitea justice ' . gmdate('Y-m-d H:i:s') . ' UTC'); + +$cmd = 'sudo /usr/local/sbin/justice-gitea-sync.sh ' . escapeshellarg($msg) . ' 2>&1'; +$output = []; +$code = 0; +exec($cmd, $output, $code); +$log = implode("\n", $output); + +if ($code !== 0) { + json_response([ + 'ok' => false, + 'error' => 'ซิงค์หรือ push ไม่สำเร็จ', + 'exitCode' => $code, + 'log' => $log, + ], 500); +} + +json_response([ + 'ok' => true, + 'message' => $msg, + 'log' => $log, +]); diff --git a/www/html/Admin/justice-git.html b/www/html/Admin/justice-git.html new file mode 100644 index 0000000..29e3eff --- /dev/null +++ b/www/html/Admin/justice-git.html @@ -0,0 +1,111 @@ + + +
+ + + + +ซิงค์ /var/www/html/ + ไฟล์ Nginx หลัก เข้า repo แล้ว git push (ต้องล็อกอิน Admin ก่อน)
ยังไม่ได้เข้า Admin — ไปที่หน้า Admin แล้วล็อกอินก่อน
+ +รีโป: giteaadmin/justice
+ + +จะรันสคริปต์ save-www-from-etc.sh แล้ว save-from-etc.sh ตามลำดับ — ถ้าไม่มี diff จะขึ้น “No changes to commit.”