1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186 |
- <?php
- namespace app\index;
- class combine extends BaseUser
- {
- function initialize()
- {
- parent::initialize();
- }
-
- function index()
- {ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
-
- // 获取页码参数
- $page = SafeRequest("page", "get");
- if (empty($page)) {
- $page = 1;
- }
-
- // 使用分页查询
- $result = db("combine")->where("userid", $this->userid)->order("id desc")->paginate(["page" => $page, 'list_rows' => 5]);
- $count = $result->total();
- ?>
- <!DOCTYPE html>
- <html lang="zh-cn">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0" />
- <meta name="keywords" content="<?php echo IN_KEYWORDS; ?>" />
- <meta name="description" content="<?php echo IN_DESCRIPTION; ?>" />
- <title>外部链接合并 - <?php echo IN_NAME; ?> - 免费应用内测托管平台|iOS应用Beta测试分发|Android应用内测分发</title>
- <?php $this->static_(); ?>
- </head>
- <body>
- <?php $this->header(); ?>
- <style>
- .details-top {
- padding: 39px 30px;
- }
- .details-top .p1{
- color: rgba(21, 21, 21, 1);
- font-family: Source Han Sans SC;
- font-weight: 500;
- font-size: 16px;
- line-height: 20px;
- }
- #hotApp_box {
- display: flex;
- justify-content: space-between;
- align-items: start;
- margin: 0;
- }
- .download-details {
- padding: 10px 30px 72px;
- }
- .flex-left {
- width: calc(100% - 303px);
- }
- .flex-right {
- width: 303px;
- }
- .qrcode_img {
- width: 235px;
- height: 235px;
- object-fit: cover;
- border: 1px solid rgba(232, 234, 236, 1);
- }
- .qrcode_img::placeholder {
- color: rgba(143, 149, 159, 1);
- font-size: 16px;
- line-height: 22px;
- }
- .qrcode_url_tips {
- font-size: 13px;
- line-height: 17px;
- margin: 10px 0;
- }
- .qrcode_url_input_box {
- margin-bottom: 30px;
- }
- .qrcode_url_input_box input {
- border: 1px solid rgba(232, 234, 236, 1);
- /* width: 711px; */
- height: 52px;
- line-height: 52px;
- border-width: 1px;
- padding: 0 20px;
- box-sizing: border-box;
- font-size: 14px;
- color: rgba(21, 21, 21, 1);
- }
- .qrcode_url_input_box input::placeholder {
- font-size: 14px;
- color: rgba(143, 149, 159, 1);
- }
- .generate_btn_box {
- margin-top: 50px;
- }
- .generate_qrcode_btn {
- background: rgba(33, 104, 251, 1);
- width: 120px;
- height: 34px;
- border-radius: 4px;
- padding-top: 7px;
- padding-right: 20px;
- padding-bottom: 7px;
- padding-left: 20px;
- color: rgba(255, 255, 255, 1);
- font-family: Source Han Sans SC;
- font-weight: 500;
- font-style: Medium;
- font-size: 16px;
- line-height: 20px;
- }
- #hotApp-qrcode-downBtn:active:focus,
- #hotApp-qrcode-downBtn:hover,
- .generate_qrcode_btn:active:focus,
- .generate_qrcode_btn:hover {
- background: rgba(33, 104, 251, 1);
- color: rgba(255, 255, 255, 1);
- border: unset;
- outline: none;
- }
- .qrcode_show_box {
- text-align: right;
- margin-bottom: 12px;
- margin-top: 10px;
- }
- .qrcode_url_box { margin-bottom: 20px; }
- .qrcode_url_tips { margin-bottom: 10px; }
- .os_name { font-weight: bold; color: #333; }
- .qrcode_url_input { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; }
- /* .qrcode_function {
- text-align: center;
- }
- .down_btnbox {
- text-align: center;
- } */
- .qrcode_function {
- margin: 0 auto;
- }
- .down_btnbox {
- padding-left: 126px;
- }
- #hotApp-qrcode-downBtn {
- border: 1px solid rgba(33, 104, 251, 1);
- width: 120px;
- height: 34px;
- border-radius: 4px;
- padding: 0 20px;
- background: rgba(255, 255, 255, 1);
- color: rgba(33, 104, 251, 1);
- font-size: 16px;
- line-height: 34px;
- float: unset;
- margin: 0 auto;
- }
- .tab-content {
- display: none;
- }
- .tab-content.active {
- display: block;
- }
-
- /* 标签页样式 */
- .tabs {
- margin: 12px 0 0 0;
- padding: 10px 30px;
- }
- .tabs .nav-tabs {
- border-bottom: 0 solid #e5e5e5;
- /* 添加横向滚动支持 */
- overflow-x: auto;
- overflow-y: hidden;
- white-space: nowrap;
- display: flex;
- flex-wrap: nowrap;
- -webkit-overflow-scrolling: touch;
- /* iOS滚动优化 */
- scrollbar-width: none;
- /* Firefox隐藏滚动条 */
- -ms-overflow-style: none;
- /* IE隐藏滚动条 */
- }
- /* 隐藏Webkit浏览器的滚动条 */
- .tabs .nav-tabs::-webkit-scrollbar {
- display: none;
- }
- .tabs .nav-tabs>li>a {
- border: none;
- padding: 12px 2px;
- margin-right: 24px;
- border-radius: 0;
- color: rgba(143, 149, 159, 1);
- font-family: Source Han Sans SC;
- font-weight: 500;
- font-size: 15px;
- line-height: 20px;
- }
- .tabs .nav-tabs>li>a:hover {
- border: none;
- background-color: #ffffff;
- color: rgba(75, 132, 255, 1);
- }
- .tabs .nav-tabs>li.active>a,
- .tabs .nav-tabs>li.active>a:hover,
- .tabs .nav-tabs>li.active>a:focus {
- border: none;
- border-bottom: 2px solid rgba(75, 132, 255, 1);
- color: rgba(75, 132, 255, 1);
- font-weight: 700;
- }
- /* 记录 */
- .table-responsive {
- overflow-x: auto;
- border: 1px solid rgba(232, 234, 236, 1);
- }
- /* 通用表格设置 */
- .table {
- border: 1px solid #e5e5e5;
- margin-bottom: 0;
- }
- .table>tbody>tr>th {
- background: rgba(245, 246, 247, 1);
- height: 36px;
- color: rgba(143, 149, 159, 1);
- font-family: Source Han Sans SC;
- font-weight: 500;
- font-size: 14px;
- line-height: 18px;
- text-align: center;
- vertical-align: middle !important;
- }
- .table>tbody>tr>td {
- color: rgba(0, 0, 0, 1);
- box-sizing: border-box;
- padding: 0 15px !important;
- height: 68px;
- text-align: center;
- font-family: Source Han Sans SC;
- font-weight: 400;
- font-size: 14px;
- line-height: 13px;
- border-top: unset;
- border-bottom: 1px solid rgba(232, 234, 236, 1);
- vertical-align: middle !important;
- }
- .table>tfoot>tr>td {
- padding: 0 15px !important;
- vertical-align: middle !important;
- text-align: center;
- }
- .table>tbody>tr:hover>td {
- background-color: #ebf7ff;
- }
- .table>tbody>tr>td.angle-parent {
- color: rgba(75, 132, 255, 1);
- }
- .table>tbody>tr>td>a {
- color: rgba(33, 104, 251, 1);
- font-weight: 500;
- font-size: 14px;
- }
- .table>tbody>tr>td>a+a {
- margin-left: 14px;
- }
- /* 操作按钮 */
- .table .btn-detail {
- height: 30px;
- border-width: 1px;
- border-radius: 4px;
- padding-top: 5px;
- padding-right: 8px;
- padding-bottom: 5px;
- padding-left: 8px;
- color: rgba(255, 116, 41, 1);
- border: 1px solid rgba(255, 116, 41, 1);
- font-family: Source Han Sans SC;
- font-weight: 500;
- font-size: 14px;
- line-height: 20px;
- }
- /* 翻页 */
- .pagination-box {
- /* text-align: right; */
- }
- .pagination {
- margin: 10px auto 10px;
- }
- .pagination>li>a,
- .pagination>li>span {
- color: rgba(33, 104, 251, 1);
- }
- .pagination>.active>a,
- .pagination>.active>a:focus,
- .pagination>.active>a:hover,
- .pagination>.active>span,
- .pagination>.active>span:focus,
- .pagination>.active>span:hover {
- background-color: rgba(33, 104, 251, 1);
- border-color: rgba(33, 104, 251, 1);
- }
- .pagination>li:first-child {
- display: inline-block;
- padding: 7px 0 7px 12px;
- background-color: transparent !important;
- border: unset;
- color: rgba(33, 104, 251, 1);
- pointer-events: none;
- }
- /* 底部 */
- .tips {
- margin: 12px auto 57px;
- color: rgba(143, 149, 159, 1);
- font-size: 13px;
- line-height: 20px;
- }
- @media (max-width: 768px) {
- .release-app2>.row {
- margin: 0;
- }
- .app-details .details-top {
- padding: 0.32rem;
- }
- .details-top .p1{
- font-size: 0.28rem;
- line-height: 0.40rem;
- }
- #hotApp_box {
- margin: 0;
- display: block;
- }
- .download-details {
- padding: 0.20rem 0.32rem 0.60rem;
- }
- .flex-left {
- width: 100%;
- }
- .flex-right {
- width: 100%;
- }
- .qrcode_img {
- width: 2.66rem;
- height: 2.66rem;
- margin: 0 auto;
- }
- .qrcode_url_tips {
- font-size: 0.28rem;
- line-height: 0.34rem;
- margin: 0.20rem 0;
- }
- .qrcode_url_input_box {
- margin-bottom: 0.4rem;
- }
- .qrcode_url_input_box input {
- height: 0.64rem;
- line-height: 0.64rem;
- padding: 0 0.24rem;
- font-size: 0.28rem;
- }
- .qrcode_url_input_box input::placeholder {
- font-size: 0.28rem;
- }
- .generate_btn_box {
- margin-top: 0;
- }
- .generate_qrcode_btn {
- width: 100%;
- height: 0.68rem;
- border-radius: 0.08rem;
- font-size: 0.32rem;
- line-height: 0.68rem;
- padding: 0;
- }
- #hotApp-qrcode-downBtn:active:focus,
- #hotApp-qrcode-downBtn:hover,
- .generate_qrcode_btn:active:focus,
- .generate_qrcode_btn:hover {
- background: rgba(33, 104, 251, 1);
- color: rgba(255, 255, 255, 1);
- }
- .qrcode_show_box {
- margin-bottom: 0.2rem;
- margin-top: 0.48rem;
- text-align: center;
- }
- .qrcode_url_box { margin-bottom: 20px; }
- .qrcode_url_tips {margin-bottom: 0.20rem;}
- .qrcode_url_input {
- width: 100%;
- padding: 10px;
- border-radius: 4px;
- }
- .qrcode_function {
- margin: 0 auto;
- }
- .down_btnbox {
- padding-left: 0;
- }
- #hotApp-qrcode-downBtn {
- width: 100%;
- height: 0.68rem;
- border-radius: 0.08rem;
- font-size: 0.32rem;
- line-height: 0.68rem;
- }
- .down_qrcode_box {
- width: 100%;
- }
- /* 标签页样式 */
- .tabs {
- margin: 0;
- padding: 0 0.32rem;
- }
- .tabs .nav-tabs>li>a {
- padding: 0.24rem 0.04rem;
- margin-right: 0.48rem;
- font-size: 0.30rem;
- line-height: 0.40rem;
- }
- /* 通用表格设置 */
- .table {
- margin-bottom: 0;
- }
- .table>tbody>tr>th {
- height: 0.72rem;
- font-size: 0.28rem;
- line-height: 0.36rem;
- }
- .table>tbody>tr>td {
- padding: 0.2rem 0.30rem!important;
- height: 1.36rem;
- font-size: 0.28rem;
- line-height: 0.32rem;
- }
- .table>tfoot>tr>td {
- padding: 0 0.30rem !important;
- }
- .table>tbody>tr>td>a {
- font-size: 0.28rem;
- }
- .table>tbody>tr>td>a+a {
- margin-left: 0.28rem;
- }
- /* 操作按钮 */
- .table .btn-detail {
- height: 0.60rem;
- border-radius: 0.08rem;
- padding-top: 0.10rem;
- padding-right: 0.16rem;
- padding-bottom: 0.10rem;
- padding-left: 0.16rem;
- font-size: 0.28rem;
- line-height: 0.40rem;
- }
- /* 翻页 */
- .pagination {
- margin: 0.20rem auto 0.20rem;
- }
- .pagination>li:first-child {
- padding: 0.14rem 0 0.14rem 0.24rem;
- }
- /* 底部 */
- .release-app2 .warn-prompt-wrap {
- padding-bottom: unset;
- margin-top: 0;
- margin-bottom: 1.46rem;
- }
- .tips {
- margin: 0.24rem auto 0.48rem;
- color: rgba(143, 149, 159, 1);
- font-weight: 400;
- font-size: 0.24rem;
- line-height: 0.40rem;
- }
- }
- </style>
-
- <div class="release-app-wrap">
- <div class="container">
- <div class="release-app2">
- <div class="crumbs">
- <a href="/index/apps">我的应用</a>
- <span>/</span>
- <a href="/index/apps">应用列表</a>
- <span>/</span>
- 外部链接合并
- </div>
- <div class="row clearfix">
- <div class="col-sm-2">
- <aside class="aside-left">
- <ul>
- <li title="上传应用" class="<?php echo ($this->module == 'publish' || $this->module == 'publish_update') ? 'active' : '' ?>">
- <a href="/index/publish/<?php echo $this->action ?>"> <span class="iconfont icon-upload1"></span>上传应用</a>
- </li>
- <li title="应用列表" class="<?php echo $this->module == 'apps' ? 'active' : '' ?>">
- <a href="/index/apps/<?php echo $this->action ?>"><span class="iconfont icon-41"></span>应用列表</a>
- </li>
- <li title="绑定域名" class="<?php echo $this->module == 'domain' ? 'active' : '' ?>">
- <a href="/index/domain/<?php echo $this->action ?>"><span class="iconfont icon-liulanqi"></span>绑定域名</a>
- </li>
- <li title="外部链接合并" class="<?php echo $this->module == 'combine' ? 'active' : '' ?>">
- <a href="/index/combine/<?php echo $this->action ?>"><span class="iconfont icon-erweima"></span>外部链接合并</a>
- </li>
- <!-- <li title="合并记录" class="<?php echo $this->module == 'jilu' ? 'active' : '' ?>">
- <a href="/index/jilu/<?php echo $this->action ?>"><span class="iconfont icon-jilu"></span>合并记录</a>
- </li> -->
- </ul>
- </aside>
- </div>
- <div class="col-sm-10">
- <div class="aside-right">
- <div class="app-details app-details2">
- <div class="details-top clearfix">
- <b class="p1">外部链接合并</b>
- <div class="p1">
- 设置提示:本功能可将外部的ios链接或安卓链接,来和本站的链接进行合并到一起使用,
- <br class="hidden-xs">
- 以便更好的管理不同平台链接的使用,可生成二维码和短链接。
- </div>
- </div>
- <div style="height: 10px; background: rgb(242, 242, 245)"></div>
- <div class="tabs">
- <ul class="nav nav-tabs" role="tablist">
- <li role="presentation" class="active">
- <a href="?tab=combine" aria-controls="tab-combine" role="tab">链接合并</a>
- </li>
- <li role="presentation" class="">
- <a href="?tab=record" aria-controls="tab-record" role="tab">合并记录</a>
- </li>
- </ul>
- </div>
- <div class="download-details">
- <!-- 链接合并表单 -->
- <div id="tab-combine" class="generate_qrcode_box tab-content <?php echo (SafeRequest("tab", "get") != 'record') ? 'active' : ''; ?>">
- <div class="row" id="hotApp_box">
- <div class="flex-left">
- <div class="qrcode_url_box">
- <div class="qrcode_url_tips">
- <b class="os_name">iOS系统</b>
- </div>
- <div class="qrcode_url_input_box">
- <input type="text" placeholder="请输入苹果应用下载地址" id="ios_url" class="form-control qrcode_url_input">
- </div>
- </div>
- <div class="qrcode_url_box">
- <div class="qrcode_url_tips">
- <b class="os_name">安卓系统</b>
- </div>
- <div class="qrcode_url_input_box">
- <input type="text" id="android_url" class="form-control qrcode_url_input" placeholder="请输入安卓系统应用下载地址">
- </div>
- </div>
- <div class="qrcode_url_box" id="shortUrlha" style="display:none">
- <div class="qrcode_url_tips">
- <b class="os_name">短连接地址</b>
- </div>
- <div class="qrcode_url_input_box">
- <input type="text" id="shortUrlh" class="form-control qrcode_url_input" placeholder="">
- </div>
- </div>
- <div class="alert alert-success" style="display: none;">
- <span class="txt"></span>
- </div>
- <div class="alert alert-danger" style="display: none;">
- <span class="txt"></span>
- </div>
- <div class="generate_btn_box">
- <a class="btn generate_qrcode_btn">
- 生成二维码
- </a>
- </div>
- </div>
- <div class="flex-right">
- <div class="qrcode_show_box">
- <img class="qrcode_img hidden-xs" src="/img/qrcode_no.png">
- <img class="qrcode_img visible-xs" src="/img/qrcode_no_m.png">
- </div>
- <div class="qrcode_function clearfix row">
- <input type="hidden" name="" class="qrcode_key" value="">
- <input type="hidden" name="" class="shortUrl" value="">
- <input type="hidden" name="download_url" id="download_url" value="<?php echo $_SERVER['HTTP_HOST']; ?>/index/combine/download?qrcode_path=">
- <input type="hidden" name="more_down_url" id="more_down_url" value="<?php echo $_SERVER['HTTP_HOST']; ?>/index/combine/downloadQrCode?qrcode_path=">
- <input type="hidden" name="" class="qrcode_path" value="">
- <div class="down_btnbox">
- <div class="btn-group down_qrcode_box">
- <a href="javascript:qrcodeDown();" style="width:100%" class="btn btn-default down_qrcode_btn" id="hotApp-qrcode-downBtn" data-downurl="" >下载二维码</a>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 合并记录表格 -->
- <div id="tab-record" class="tab-content <?php echo (SafeRequest("tab", "get") == 'record') ? 'active' : ''; ?>">
- <div class="table-responsive">
- <table class="table">
- <tbody>
- <tr>
- <th>ID</th>
- <th>安卓地址</th>
- <th>IOS地址</th>
- <th>短链接</th>
- <th>添加时间</th>
- <th>操作</th>
- </tr>
- <?php if(!empty($result) && $count > 0): ?>
- <?php foreach($result as $item): ?>
- <tr>
- <td><div><?php echo $item['id']; ?></div></td>
- <td><div><?php echo htmlspecialchars($item['android']); ?></div></td>
- <td><div><?php echo htmlspecialchars($item['ios']); ?></div></td>
- <td><div><?php echo htmlspecialchars($item['link']); ?></div></td>
- <td><div style="min-width: 135px;"><?php echo date('Y-m-d H:i:s', $item['ctime']); ?></div></td>
- <td><div><a href="<?php echo $item['link']; ?>" target="_blank" class="btn-detail">查看</a></div></td>
- </tr>
- <?php endforeach; ?>
- <?php else: ?>
- <tr>
- <td colspan="6" class="text-center">暂无记录</td>
- </tr>
- <?php endif; ?>
- </tbody>
- </table>
- <?php
- if ($count == 0) {
- ?>
- <div class="text-center no-content">
- <img src="/static/index/image/invoice-1.png" alt="">
- <p class="color-333 mt10">
- 暂无任何数据
- </p>
- </div>
- <?php
- }
- ?>
- </div>
- <div class="pagination-box">
- <?php echo getRender($result, $page); ?>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div class="warn-prompt-wrap clearfix">
- <dl class="clearfix fr warn-prompt-1 tips">
- <!-- <dd> -->
- 提示:请您确认您合并的二维码,符合
- 《<a href="/index/about/specification" target="_blank" class="color-hover">审核规范</a>》,如违反规范,APP将做删除处理,屡次合并二维码将被封禁账号。
- <br>根据最新审核规范,不接受如下APP在平台进行合并二维码:色情类、直播类、金融类、区块链虚拟币等。如已合并,将做删除处理。
- <!-- </dd> -->
- </dl>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <script>
- // 页面加载时清理不必要的cookie
- $(document).ready(function() {
- console.log('页面加载完成!');
- cleanUnnecessaryCookies();
-
- // 检查jQuery是否加载
- if (typeof $ !== 'undefined') {
- console.log('jQuery已加载');
- } else {
- console.log('jQuery未加载!');
- }
-
- // 检查按钮是否存在
- if ($('#hotApp_box .generate_qrcode_btn').length > 0) {
- console.log('生成二维码按钮已找到');
- } else {
- console.log('生成二维码按钮未找到!');
- }
-
- // Tab切换功能
- $('.nav-tabs a').on('click', function(e) {
- e.preventDefault();
- var target = $(this).attr('href').replace('?tab=', '');
-
- // 获取当前URL参数
- var currentUrl = new URL(window.location);
- var currentPage = currentUrl.searchParams.get('page');
-
- // 构建新的URL
- var newUrl = '/index/combine/index';
- if (target === 'record') {
- newUrl += '?tab=record';
- if (currentPage) {
- newUrl += '&page=' + currentPage;
- }
- } else {
- newUrl += '?tab=combine';
- }
-
- // 跳转到新URL
- window.location.href = newUrl;
- });
-
- // 根据URL参数设置初始tab状态
- var urlParams = new URLSearchParams(window.location.search);
- var tabParam = urlParams.get('tab');
-
- if (tabParam === 'record') {
- $('.nav-tabs li').removeClass('active');
- $('.nav-tabs a[href="?tab=record"]').parent().addClass('active');
- $('.tab-content').removeClass('active');
- $('#tab-record').addClass('active');
- } else {
- $('.nav-tabs li').removeClass('active');
- $('.nav-tabs a[href="?tab=combine"]').parent().addClass('active');
- $('.tab-content').removeClass('active');
- $('#tab-combine').addClass('active');
- }
- });
-
- function qrcodeDown() {
- var qrcode_path = $('.qrcode_path').val();
- if (qrcode_path == '') {
- alert("请先生成二维码!");
- return false;
- } else {
- window.open(qrcode_path);
- }
- }
-
- // 绑定生成二维码按钮事件
- $('#hotApp_box .generate_qrcode_btn').on('click', function() {
- console.log('按钮被点击了!');
- var $btn = $(this);
- var ios_url = $('#ios_url').val();
- var android_url = $('#android_url').val();
-
- console.log('iOS URL:', ios_url);
- console.log('Android URL:', android_url);
-
- $btn.button('loading');
-
- if(!ios_url){
- alert('请输入IOS地址');
- $btn.button('reset');
- return false;
- }
- if(!android_url){
- alert('请输入安卓地址');
- $btn.button('reset');
- return false;
- }
-
- // 清理不必要的cookie
- cleanUnnecessaryCookies();
-
- console.log('开始发送AJAX请求...');
- $.ajax({
- type: "POST",
- url: "/index/combine/down",
- data: "ios_url=" + encodeURIComponent(ios_url) + "&android_url=" + encodeURIComponent(android_url),
- contentType: "application/x-www-form-urlencoded; charset=UTF-8",
- headers: {
- "X-Requested-With": "XMLHttpRequest",
- "Accept": "application/json, text/javascript, */*; q=0.01"
- },
- success: function(ret) {
- console.log('AJAX成功响应:', ret);
- $btn.button('reset');
- if (ret.status == 1) {
- $('.qrcode_img').attr("src", ret.qrcode_path);
- $('#shortUrlh').val(ret.shortUrl);
- $('#shortUrlha').show();
- $('.qrcode_path').val(ret.qrcode_path);
- $('.shortUrl').val(ret.shortUrl);
- } else {
- alert(ret.msg || '生成失败!');
- }
- },
- error: function(err) {
- console.log('AJAX错误:', err);
- $btn.button('reset');
- alert('请求失败,请重试!');
- }
- });
- });
-
- function cleanUnnecessaryCookies() {
- // 定义需要保留的cookie
- var keepCookies = ['PHPSESSID', 'in_userid', 'in_username', 'in_userpassword'];
-
- // 获取所有cookie
- var cookies = document.cookie.split(';');
-
- // 清理不必要的cookie
- for (var i = 0; i < cookies.length; i++) {
- var cookie = cookies[i].trim();
- var cookieName = cookie.split('=')[0];
-
- // 如果cookie不在保留列表中,则删除
- if (keepCookies.indexOf(cookieName) === -1) {
- document.cookie = cookieName + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
- console.log('已删除cookie: ' + cookieName);
- }
- }
- }
- </script>
-
- <?php $this->footer(); ?>
- </body>
- </html>
- <?php
- }
-
- function down()
- {
- // 生产环境应该关闭错误显示
- if (defined('ENVIRONMENT') && ENVIRONMENT === 'production') {
- ini_set('display_errors', 0);
- ini_set('display_startup_errors', 0);
- error_reporting(0);
- } else {
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- }
-
- error_log("=== down() 方法开始执行 ===");
-
- // 设置session配置
- if (!session_id()) {
- session_set_cookie_params(0, '/', '', false, true);
- session_start();
- }
-
- // 设置AJAX响应头
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Cache-Control: no-store, no-cache, must-revalidate");
- header("Pragma: no-cache");
- header("Content-type: application/json; charset=utf-8");
-
- error_log("响应头已设置");
-
- // 检查用户登录状态
- error_log("检查用户登录状态: " . ($this->userlogined ? "已登录" : "未登录"));
- if (!$this->userlogined) {
- error_log("用户未登录,返回错误");
- $response = [
- "qrcode_path" => "",
- "status" => 0,
- "msg" => "请先登录后再操作!",
- "shortUrl" => ""
- ];
- echo json_encode($response);
- exit;
- }
-
- $_var_3 = SafeRequest("ios_url");
- $_var_4 = SafeRequest("android_url");
- error_log("接收到的参数 - ios_url: " . $_var_3 . ", android_url: " . $_var_4);
-
- if (!$_var_3) {
- $response = [
- "qrcode_path" => "",
- "status" => 0,
- "msg" => "请输入iOS地址!",
- "shortUrl" => ""
- ];
- echo json_encode($response);
- exit;
- }
- if (!$_var_4) {
- $response = [
- "qrcode_path" => "",
- "status" => 0,
- "msg" => "请输入Android地址!",
- "shortUrl" => ""
- ];
- echo json_encode($response);
- exit;
- }
-
- // 验证URL格式和安全性
- if (!$this->isValidUrl($_var_3)) {
- $response = [
- "qrcode_path" => "",
- "status" => 0,
- "msg" => "iOS地址格式无效!",
- "shortUrl" => ""
- ];
- echo json_encode($response);
- exit;
- }
-
- if (!$this->isValidUrl($_var_4)) {
- $response = [
- "qrcode_path" => "",
- "status" => 0,
- "msg" => "Android地址格式无效!",
- "shortUrl" => ""
- ];
- echo json_encode($response);
- exit;
- }
-
- // 生成短链接
- $_var_5 = $this->generateShortUrl();
- error_log("生成的短链接: " . $_var_5);
-
- // 生成短链接URL
- $short_url = "http://" . $_SERVER['HTTP_HOST'] . "/" . $_var_5;
- error_log("生成的短链接URL: " . $short_url);
-
- // 生成二维码图片路径
- $qrcode_url = "http://" . $_SERVER['HTTP_HOST'] . "/qrcode?link=" . urlencode($short_url);
- error_log("生成的二维码URL: " . $qrcode_url);
-
- // 保存到数据库 - 按照指定格式
- $insert_data = [
- "userid" => $this->userid,
- "username" => $this->username,
- "android" => $_var_4, // android字段存储android_url
- "ios" => $_var_3, // ios字段存储ios_url
- "link" => $short_url, // link字段存储短链接URL
- "short" => $_var_5, // short字段存储短链接标识符
- "ctime" => time()
- ];
- error_log("插入数据: " . json_encode($insert_data));
-
- try {
- $_var_7 = db("combine")->insertGetId($insert_data);
- error_log("数据库插入结果: " . $_var_7);
- } catch (Exception $e) {
- error_log("数据库错误: " . $e->getMessage());
- $response = [
- "qrcode_path" => "",
- "status" => 0,
- "msg" => "数据库操作失败,请稍后重试!",
- "shortUrl" => ""
- ];
- echo json_encode($response);
- exit;
- }
-
- if ($_var_7) {
- // 使用新的返回格式
- $response = [
- "qrcode_path" => $qrcode_url,
- "status" => 1,
- "msg" => "success",
- "shortUrl" => $short_url // 返回完整的短链接URL
- ];
- error_log("成功响应: " . json_encode($response));
- echo json_encode($response);
- } else {
- $response = [
- "qrcode_path" => "",
- "status" => 0,
- "msg" => "生成失败!",
- "shortUrl" => ""
- ];
- error_log("失败响应: " . json_encode($response));
- echo json_encode($response);
- }
- error_log("=== down() 方法执行完成 ===");
- exit;
- }
-
- function download()
- {
- $_var_8 = SafeRequest("qrcode_path");
- if (!$_var_8) {
- reJSON("参数错误!", 404);
- }
-
- // 修复路径遍历漏洞
- $qrcode_path = $_var_8;
-
- // 验证路径格式,只允许字母数字和基本符号
- if (!preg_match('/^[a-zA-Z0-9\/\-_\.]+$/', $qrcode_path)) {
- reJSON("无效的文件路径!", 403);
- }
-
- // 确保路径在允许的目录内
- $allowed_dirs = ['/uploads/qrcode/', '/qrcode/'];
- $is_allowed = false;
- foreach ($allowed_dirs as $dir) {
- if (strpos($qrcode_path, $dir) === 0) {
- $is_allowed = true;
- break;
- }
- }
-
- if (!$is_allowed) {
- reJSON("访问被拒绝!", 403);
- }
-
- $file_path = $_SERVER['DOCUMENT_ROOT'] . $qrcode_path;
-
- // 防止目录遍历
- $real_path = realpath($file_path);
- $doc_root = realpath($_SERVER['DOCUMENT_ROOT']);
-
- if ($real_path === false || strpos($real_path, $doc_root) !== 0) {
- reJSON("文件不存在!", 404);
- }
-
- if (file_exists($file_path)) {
- // 验证文件类型
- $finfo = finfo_open(FILEINFO_MIME_TYPE);
- $mime_type = finfo_file($finfo, $file_path);
- finfo_close($finfo);
-
- if ($mime_type !== 'image/png' && $mime_type !== 'image/jpeg' && $mime_type !== 'image/gif') {
- reJSON("不支持的文件类型!", 403);
- }
-
- header('Content-Type: ' . $mime_type);
- header('Content-Disposition: attachment; filename="qrcode.png"');
- readfile($file_path);
- exit;
- } else {
- reJSON("文件不存在!", 404);
- }
- }
-
- private function generateShortUrl()
- {
- $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
- $short_url = '';
-
- // 使用更安全的随机数生成方法
- if (function_exists('random_bytes')) {
- $random_bytes = random_bytes(6);
- for ($i = 0; $i < 6; $i++) {
- $short_url .= $chars[ord($random_bytes[$i]) % strlen($chars)];
- }
- } elseif (function_exists('openssl_random_pseudo_bytes')) {
- $random_bytes = openssl_random_pseudo_bytes(6);
- for ($i = 0; $i < 6; $i++) {
- $short_url .= $chars[ord($random_bytes[$i]) % strlen($chars)];
- }
- } else {
- // 降级到rand(),但增加熵
- for ($i = 0; $i < 6; $i++) {
- $short_url .= $chars[rand(0, strlen($chars) - 1)];
- }
- }
-
- return $short_url; // 只返回短链接标识符,不包含域名
- }
-
- private function generateQrcodeImage($url)
- {
- $qrcode_path = '/uploads/qrcode/' . md5($url) . '.png';
- return $qrcode_path;
- }
- private function isValidUrl($url)
- {
- // 基本URL格式验证
- if (!filter_var($url, FILTER_VALIDATE_URL)) {
- return false;
- }
-
- // 解析URL
- $parsed_url = parse_url($url);
- if (!$parsed_url || !isset($parsed_url['scheme']) || !isset($parsed_url['host'])) {
- return false;
- }
-
- // 只允许HTTP和HTTPS协议
- if (!in_array($parsed_url['scheme'], ['http', 'https'])) {
- return false;
- }
-
- // 检查是否为私有IP地址(防止SSRF)
- $host = $parsed_url['host'];
- $ip = gethostbyname($host);
-
- if ($ip && $ip !== $host) {
- // 检查是否为私有IP
- if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
- // 这是公网IP,允许
- } else {
- // 这是私有IP或保留IP,拒绝
- return false;
- }
- }
-
- // 检查URL长度限制
- if (strlen($url) > 2048) {
- return false;
- }
-
- return true;
- }
- }
|