123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185 |
- <?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;
- }
- }
|