美化-GO跳转页v2.0版本

可添加白名单,不是白名单链接显示未知,链接超出盒子长度自动显示省略号

效果图:

教程开始

1.在根目录新建demo文件夹 里面上传下面图片

美化-GO跳转页v2.0版本

2.将下面源码替换zibll文件夹中的go.php文件即可

判断是否安全链接,若主域名是安全链接,则子域名同样安全链接

<?php
/*
 * @Author        : Denver 墨星科技
 * @Url           : moxingbk.com
 * @Date          : 2024-11-24 15:57:21
 * @Email         : 3125591974@qq.com
 * @Project       : 墨星科技GO跳转页
 */
if (
    strlen($_SERVER['REQUEST_URI']) > 384 ||
    strpos($_SERVER['REQUEST_URI'], "||") !== false ||
    strpos($_SERVER['REQUEST_URI'], "base64") !== false
) {
    @header("HTTP/1.1 414 Request-URI Too Long");
    @header("Status: 414 Request-URI Too Long");
    @header("Connection: Close");
    @exit;
}

// 通过QUERY_STRING取得完整的传入数据,然后取得url=之后的所有值,兼容性更好
@session_start();
$t_url = !empty($_SESSION['GOLINK']) ? $_SESSION['GOLINK'] : preg_replace('/^url=(.*)$/i', '$1', $_SERVER["QUERY_STRING"]);

// 数据处理
if (!empty($t_url)) {
    // 判断取值是否加密
    if ($t_url == base64_encode(base64_decode($t_url))) {
        $t_url = base64_decode($t_url);
    }
    // 防止xss
    $t_url = htmlspecialchars($t_url);
    // 对取值进行网址校验和判断
    preg_match('/^(http|https|thunder|qqdl|ed2k|Flashget|qbrowser):\\/\\//i', $t_url, $matches);
    $wiiui_title = get_bloginfo('name');
    $title = $wiiui_title . ' - 安全中心';
    if ($matches) {
        $url = $t_url;
    } else {
        preg_match('/\\./i', $t_url, $matche);
        if ($matche) {
            $url = 'http://' . $t_url;
        } else {
            $url = 'http://' . $_SERVER['HTTP_HOST'];
            $title = '参数错误,正在返回首页...';
        }
    }
} else {
    $title = '参数缺失,正在返回首页...';
    $url = 'http://' . $_SERVER['HTTP_HOST'];
}
$url = str_replace('&', '&amp;', $url);
?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $title; ?></title>
    </script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-image: url(/demo/bg.jpg);
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }
        .container {
            background-color: rgba(255, 255, 255, 0.9);
            border-radius: 8px;
            padding: 20px;
            width: 300px;
            text-align: center;
        }
        .logo {
            width: 260px;
            height: 80px;
            margin-bottom: 20px;
        }
        .status {
            font-size: 14px;
            color: #777;
            margin-top: 5px;
        }
        .buttons {
            margin-top: 20px;
        }
        .button {
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
            margin: 5px;
            text-decoration: none;
        }
        .jb-pink{
            background:linear-gradient(135deg, #ff5e7f 30%, #ff967e 100%);
        }
        .jb-cyan{
            background:linear-gradient(140deg, #039ab3 10%, #58dbcf 90%);
        }
.moxing_link {
    width: 95%;
    background-color: #e0e0e0;
    padding: 10px;
    border-radius: 25px;
    font-weight: bold;
    display: flex; /* 修改为flex布局 */
    align-items: center; /* 垂直居中对齐 */
    justify-content: flex-start; /* 水平起始对齐 */
}

.moxing_link .text {
    white-space: nowrap; /* 防止文本换行 */
    overflow: hidden; /* 隐藏超出部分 */
    text-overflow: ellipsis; /* 使用省略号表示超出的文本 */
    max-width: 100%; /* 设置最大宽度为100% */
}
                #icon-container {
            display: inline-block;
            vertical-align: middle;
            margin-right: 5px;
           
        }
    </style>
</head>
<body>
    <div class="container">
        <img src="https://moxingbk.com/wp-content/uploads/2024/10/墨星博客日间logo.png" alt="Logo" class="logo">
        <p class="moxing_link">
            <span id="icon-container"></span>
            <span class="text"><?php echo $url; ?></span>
        </p>
        <p id="link-status" class="status"></p>
        <div class="buttons">
            <button onclick="location.replace('<?php echo $url; ?>')" class="button jb-pink" id="continue-button">继续前往</button>
            <button onclick="setTimeout(function() { location.replace('//<?php echo $_SERVER['HTTP_HOST']; ?>'); }, 1000)" class="button jb-cyan" id="home-button">回到主页</button>
        </div>
    </div>

    <script>
        // 初始化白名单数组
        const whitelist = [
            "zibll.com",
            "moxingbk.com",
            "baidu.com",
            "qq.com",
            "weixin.com"
        ];

        // 获取链接并检测是否在白名单内
        const linkStatus = document.getElementById('link-status');
        const continueButton = document.getElementById('continue-button');
const iconContainer = document.getElementById('icon-container');
        const targetLink = '<?php echo $url; ?>';
        const parsedLink = new URL(targetLink);

        function isSubdomainSafe(url) {
            const hostname = parsedLink.hostname;
            const domainParts = hostname.split('.');
            const topLevelDomain = domainParts.slice(-2).join('.');
            return whitelist.includes(topLevelDomain);
        }

        if (isSubdomainSafe(targetLink)) {
            linkStatus.textContent = '该链接安全,请点击继续前往';
            continueButton.style.display = 'inline-block';
            iconContainer.innerHTML = '<svg t="1732432429874" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2886" width="30" height="30"><path d="M651.636 325.818a139.636 139.636 0 1 0-279.272 0v93.091h279.272v-93.09z m69.819 93.091A93.09 93.09 0 0 1 814.545 512v279.273a93.09 93.09 0 0 1-93.09 93.09h-418.91a93.09 93.09 0 0 1-93.09-93.09V512a93.09 93.09 0 0 1 93.09-93.09h23.273v-93.092a186.182 186.182 0 1 1 372.364 0v93.091h23.273zM768 791.273V512a46.545 46.545 0 0 0-46.545-46.545h-418.91A46.545 46.545 0 0 0 256 512v279.273a46.545 46.545 0 0 0 46.545 46.545h418.91A46.545 46.545 0 0 0 768 791.273z" fill="#21A3DD" p-id="2887"></path><path d="M488.727 645.353v76.102a23.273 23.273 0 0 0 46.546 0v-76.102a46.545 46.545 0 1 0-46.546 0z" fill="#21A3DD" p-id="2888"></path></svg>';
        } else {
            linkStatus.textContent = '该链接安全性未知,请保护好个人信息';
            continueButton.style.display = 'inline-block';
            iconContainer.innerHTML = '<svg t="1732433495577" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6123" width="20" height="20"><path d="M512 93.090909a232.727273 232.727273 0 0 1 232.727273 232.727273h93.090909A325.818182 325.818182 0 0 0 186.181818 325.818182v93.090909H93.090909v605.090909h837.818182V418.909091H279.272727V325.818182a232.727273 232.727273 0 0 1 232.727273-232.727273z m325.818182 837.818182H186.181818v-418.909091h651.636364z" fill="#757575" p-id="6124"></path><path d="M465.454545 651.636364h93.09091v139.636363H465.454545z" fill="#757575" p-id="6125"></path></svg>';        
            }
    </script>
</body>
</html>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
wordpress技巧

教你如何实现WordPress网站实时显示在线人数功能

2024-11-24 17:04:27

wordpress技巧

SVGA动态资源分享

2024-11-27 15:21:41

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索