找回密码
 立即注册
搜索
热搜: 活动 交友 discuz

可道云自动登录

[复制链接]
邱双仪 发表于 2025-9-21 17:11:02 | 显示全部楼层 |阅读模式
开启可道云的guest用户后,访问域名会跳转到登录页面,还需要点以下才能登录 ,以下代码是让guset用户自动登录

先备份根目录的index.php,然后修改index.php.的内容未:
  1. <?php
  2. // #################### 新增:根路径登录判断逻辑 ####################
  3. // 1. 仅匹配「根路径」(k.2pxx.com 或 / 或 /index.php),其他路径不执行
  4. $currentUri = $_SERVER['REQUEST_URI'];
  5. $isRootPath = ($currentUri === '/' || $currentUri === '/');

  6. if ($isRootPath) {
  7.     // 2. 获取 kodUserID Cookie(管理员=1,guest=2,未登录=空)
  8.     $loginUserID = isset($_COOKIE['kodUserID']) ? $_COOKIE['kodUserID'] : '';
  9.    
  10.     // 3. 未登录(无 kodUserID)→ 自动跳 guest 登录
  11.     if (empty($loginUserID)) {
  12.         $guestLoginUrl = '/index.php?user/index/loginSubmit&name=guest&password=guest&auto=1';
  13.         header('Location: ' . $guestLoginUrl);
  14.         exit; // 跳转后立即终止,避免重复加载
  15.     }
  16.     // 已登录(管理员1/guest2)→ 跳过判断,执行原逻辑
  17. }
  18. // #################### 新增逻辑结束 ####################

  19. // #################### 可道云原始代码(未修改) ####################
  20. ob_start();
  21. include(dirname(__FILE__).'/config/config.php');
  22. $app = new Application();
  23. $app->setDefault('user.index.index');
  24. $app->run();
  25. ?>
复制代码
可道云用户登录的链接是:
  1. /index.php?user/index/loginSubmit&name=guest&password=guest&auto=1
复制代码
获取可道云静态文件CDN链接
通过F12+演示站获取,获取到的链接如下
  1. https://static.kodcloud.com/kod/static/last/
复制代码
修改可道云配置文件
配置文件路径./config/setting_user.php
打开文件,在文件末尾添加如下内容:
  1. $GLOBALS['config']['settings']['staticPath'] = "https://static.kodcloud.com/kod/static/last/";
复制代码


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

Archiver|小黑屋|私人领地

GMT+8, 2025-12-7 02:45 , Processed in 0.046122 second(s), 2 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表