Skip to content

Commit

Permalink
feat: 支持安装程序到虚拟主机的子路径,自动移除URL中的子路径
Browse files Browse the repository at this point in the history
  • Loading branch information
jksdou committed Sep 10, 2024
1 parent d6e49a6 commit 57100e0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
17 changes: 11 additions & 6 deletions src/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<table class="table table-bordered table-striped">
<tbody>
<tr>
<th>系统程序</th>
<th>程序名称</th>
<td><?php echo $lang->app->name; ?></td>
<th>程序版本</th>
<td>v<?php echo APP_VERSION; ?> <button class="btn btn-success btn-xs" onclick="appCheckUpdate();">检查更新</button></td>
Expand All @@ -151,9 +151,17 @@
<tr>
<th>程序最大运行时间</th>
<td><?php echo ini_get('max_execution_time') ?>s</td>
<th>网站路径</th>
<th>程序安装路径</th>
<td><?php echo ROOT; ?>/</td>
</tr>
<?php if (isset($app_config['subpath']) && !empty($app_config['subpath'])) { ?>
<tr>
<th>程序安装在主站子目录</th>
<td>是</td>
<th>子目录位置</th>
<td><?php echo $app_config['subpath']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
Expand All @@ -176,10 +184,7 @@
<th>联系QQ</th><td>350430869</td>
</tr>
<tr>
<th>Copyright</th>
<td colspan="3">
<strong>Copyright &copy; <?php echo date('Y'); ?> <a target="_blank" href="https://crogram.org">CROGRAM</a>.</strong> All Rights Reserved.
</td>
<td colspan="4">Copyright &copy; <?php echo date('Y');?> <?php echo $lang->app->name; ?>. All Rights Reserved.</td>
</tr>
</tbody>
</table>
Expand Down
5 changes: 5 additions & 0 deletions src/config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
// 程序配置
$app_config = array(
'subpath' => ''
);

/* 数据库配置 */
$dbconfig = array(
'host' => '127.0.0.1', // 数据库服务器
Expand Down
12 changes: 9 additions & 3 deletions src/includes/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
error_reporting(0);
define('IN_CRONLITE', true);
define('VERSION', '1002');
define('APP_VERSION', '1.0.3');
define('APP_VERSION', '1.0.4');
define('SYSTEM_ROOT', dirname(__FILE__));
define('ROOT', dirname(SYSTEM_ROOT));
// define('CC_Defender', 1);
Expand All @@ -21,9 +21,8 @@

include_once(SYSTEM_ROOT . '/functions.php');
$scriptpath = str_replace('\\', '/', $_SERVER['SCRIPT_NAME']);
$site_path = substr($scriptpath, 0, strrpos($scriptpath, '/'));
$site_http = (is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'];
$site_url = $site_http . $site_path;
$site_path = substr($scriptpath, 0, strrpos($scriptpath, '/'));

if (file_exists(ROOT . '/install/index.php') && !file_exists(ROOT . '/install/install.lock')) {
// 有安装脚本却没有锁定文件
Expand All @@ -38,6 +37,13 @@

// 配置文件
require ROOT . '/config.php';
if (isset($app_config['subpath']) && !empty($app_config['subpath'])) {
// 程序安装在子路径,移除URL中的子路径
$site_path = str_replace($app_config['subpath'], '', $site_path);
}

$site_url = $site_http . $site_path;

if (!isset($dbconfig) || !$dbconfig['user'] || !$dbconfig['pwd'] || !$dbconfig['dbname']) // 检测安装1
{
sysmsg('<h2>系统配置文件 config.php 异常!</h2><a href="' . $site_http . '/install/">点击此处</a> 运行安装程序。', '站点提示信息', 1);
Expand Down

0 comments on commit 57100e0

Please sign in to comment.