镜像自地址
https://github.com/JGZYES/ParlzPackageManger.git
已同步 2026-09-11 05:42:44 +08:00
git.php: store local repo clone in web/git (live: /www/sites/ParlzPackageManger/index/web/git); PMM_SRC_DIR override; permission hint
这个提交包含在:
+1
-1
@@ -30,4 +30,4 @@
|
||||
|
||||
# source browser cache clone
|
||||
web/.src/
|
||||
web/repo/
|
||||
web/git/
|
||||
|
||||
+6
-14
@@ -7,18 +7,9 @@ define('PMM_SITE', 1);
|
||||
require __DIR__ . '/_common.php';
|
||||
|
||||
$REPO_URL = 'https://github.com/JGZYES/ParlzPackageManger.git';
|
||||
/* Choose a PHP-writable location for the local repo clone (the web root may be
|
||||
* owned by root, so PHP/php-fpm often can't create web/repo). */
|
||||
function pick_repo_dir(): string {
|
||||
$env = getenv('PMM_SRC_DIR');
|
||||
if ($env && (is_dir($env) || @mkdir($env, 0775, true))) return $env;
|
||||
$local = __DIR__ . '/repo';
|
||||
if (is_dir($local) || @mkdir($local, 0775, true)) return $local;
|
||||
$tmp = sys_get_temp_dir() . '/pmm-src';
|
||||
@mkdir($tmp, 0775, true);
|
||||
return $tmp;
|
||||
}
|
||||
$REPO_DIR = pick_repo_dir();
|
||||
/* Local repo clone lives in web/git (i.e. /www/sites/ParlzPackageManger/index/web/git
|
||||
* on the live host). PMM_SRC_DIR may override it. PHP needs write access there. */
|
||||
$REPO_DIR = getenv('PMM_SRC_DIR') ?: (__DIR__ . '/git');
|
||||
|
||||
/* handle the one-click clone/pull early (no page output yet) */
|
||||
if (isset($_GET['action']) && $_GET['action'] === 'init') {
|
||||
@@ -28,7 +19,7 @@ if (isset($_GET['action']) && $_GET['action'] === 'init') {
|
||||
$cmd = 'git clone --depth 1 ' . escapeshellarg($REPO_URL) . ' ' . escapeshellarg($REPO_DIR) . ' 2>&1';
|
||||
$out = (string)@shell_exec($cmd);
|
||||
if (is_dir($REPO_DIR . '/.git')) echo 'OK';
|
||||
else echo '克隆失败:' . substr($out, 0, 220) . "\n(已尝试写入 " . $REPO_DIR . ')';
|
||||
else echo '克隆失败:' . substr($out, 0, 220) . "\n(请确保 PHP 对 ' . $REPO_DIR . ' 可写:chmod -R 775 ' . $REPO_DIR . ' 或其父目录;或设 PMM_SRC_DIR)';
|
||||
} else {
|
||||
$out = (string)@shell_exec('git -C ' . escapeshellarg($REPO_DIR) . ' pull --depth 1 2>&1');
|
||||
echo 'OK (pull: ' . substr(trim($out), 0, 80) . ')';
|
||||
@@ -91,7 +82,8 @@ pmm_header('source', '源码浏览');
|
||||
<?php if (!$repo_ok): ?>
|
||||
<div class="gh-card">
|
||||
<div class="gh-repo">初始化本地源码仓库</div>
|
||||
<p class="src-clone-note">页面用 PHP 可写目录 <code><?php echo esc($REPO_DIR); ?></code> 存放仓库副本。若服务器 web 根对 PHP 不可写,会在 <code>/tmp</code> 类的临时目录存一份(重启可能失效)。可改用环境变量 <code>PMM_SRC_DIR</code> 指定持久可写目录;或 <code>chmod 775</code> 仓库目录。初始化命令:</p>
|
||||
<p class="src-clone-note">页面将 PMM 仓库副本存入 <code><?php echo esc($REPO_DIR); ?></code>。若 PHP 无写权限(web 根归 root),先
|
||||
<code>chmod -R 775 <?php echo esc($REPO_DIR); ?></code> 或其父目录;或用环境变量 <code>PMM_SRC_DIR</code> 指定持久目录。初始化命令:</p>
|
||||
<pre class="gh-code"><code>git clone --depth 1 <?php echo esc($REPO_URL); ?> <?php echo esc($REPO_DIR); ?></code></pre>
|
||||
<div style="margin-top:12px">
|
||||
<button class="btn btn-sm" id="git-now" type="button">在线初始化 / 更新</button>
|
||||
|
||||
在新工单中引用
屏蔽一个用户