From 73049b71b6a595dc58fb9501b87d566cfb769e61 Mon Sep 17 00:00:00 2001 From: klarkxy <278370456@qq.com> Date: Fri, 13 Mar 2026 15:32:53 +0800 Subject: [PATCH] feat: add admin-only git pull interface and remove auto-pull - Add new `gitpull.php` page for manual git pull execution by administrators - Remove automatic git pull on homepage visit to prevent unintended updates - Include git pull link in admin navigation menu for easy access - Secure interface with admin-only access and sudo credentials configuration --- web/gitpull.php | 57 +++++++++++++++++++++++++++++++++++ web/index.php | 8 ----- web/template/syzoj/header.php | 3 ++ 3 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 web/gitpull.php diff --git a/web/gitpull.php b/web/gitpull.php new file mode 100644 index 0000000..95d551a --- /dev/null +++ b/web/gitpull.php @@ -0,0 +1,57 @@ +&1"; + exec($cmd, $output, $return_code); +} + +$show_title = "Git Pull - " . $OJ_NAME; +require("template/".$OJ_TEMPLATE."/header.php"); +?> + +
+

+ +
服务器更新 (git pull )
+

+ + +
+
+
+
+ + +
+ + 返回 +
+
+ + diff --git a/web/index.php b/web/index.php index a1f5ccf..1189e1e 100644 --- a/web/index.php +++ b/web/index.php @@ -3,14 +3,6 @@ $cache_time = 30; $OJ_CACHE_SHARE = false; -// Auto git pull on homepage visit (at most once per 60 seconds) -$git_pull_lock = '/tmp/hustoj_git_pull.lock'; -if (!file_exists($git_pull_lock) || (time() - filemtime($git_pull_lock)) > 60) { - touch($git_pull_lock); - $repo_dir = dirname(__DIR__); - exec("cd " . escapeshellarg($repo_dir) . " && git pull > /tmp/hustoj_git_pull.log 2>&1 &"); -} - require_once( './include/cache_start.php' ); require_once( './include/db_info.inc.php' ); require_once( './include/memcache.php' ); diff --git a/web/template/syzoj/header.php b/web/template/syzoj/header.php index ded757b..ad946e1 100644 --- a/web/template/syzoj/header.php +++ b/web/template/syzoj/header.php @@ -210,6 +210,9 @@ + + + 更新系统 $MSG_BALLOON";