返回列表 发布新帖
查看: 8|回复: 0

最新图片阅后自焚源码下载

<
灌水成绩
1998
30
30
主题
帖子
回贴

等级头衔
UID : 1
组图 :
用户组 :
星级 :

积分成就 威望 : 3 个
贡献 : 57 点
星源币 : 12260916 元
违规 : 0
在线时间 : 310 小时
注册时间 : 2025-2-17
最后登录 : 2025-6-11

荣誉勋章

最佳新人活跃会员热心会员推广达人宣传达人灌水之王优秀版主荣誉管理精华达人金牌管理创始人男员勋章歌唱达人音乐达人交友达人

联系方式

QQ

发表于 前天 19:06 | 查看全部 |阅读模式 来自 中国–广东–湛江–遂溪县 电信
最新图片阅后自焚源码

使用教程:直接上传php给写入权限即可,无需数据库!
7.png
  1. <?PHP
  2. // 配置区域
  3. define('STORAGE_DIR', __DIR__ . '/storage/');
  4. define('DB_FILE', __DIR__ . '/database.json');
  5. define('MAX_VIEWS_MIN', 1);
  6. define('MAX_VIEWS_MAX', 999);

  7. // 创建必要目录
  8. if (!file_exists(STORAGE_DIR)) {
  9.     mkdir(STORAGE_DIR, 0700, true);
  10. }

  11. // 处理文件查看
  12. if (isset($_GET['token'])) {
  13.     $token = $_GET['token'];
  14.     $db = loadDatabase();
  15.    
  16.     if (isset($db[$token])) {
  17.         $entry = &$db[$token];
  18.         $filePath = STORAGE_DIR . $entry['filename'];
  19.         
  20.         // 检查访问次数
  21.         if ($entry['views'] >= $entry['max_views']) {
  22.             // 删除文件并移除记录
  23.             @unlink($filePath);
  24.             unset($db[$token]);
  25.             saveDatabase($db);
  26.             renderExpiredPage();
  27.             exit;
  28.         }
  29.         
  30.         // 增加访问计数
  31.         $entry['views']++;
  32.         saveDatabase($db);
  33.         
  34.         // 输出文件
  35.         header('Content-Type: ' . mime_content_type($filePath));
  36.         readfile($filePath);
  37.         
  38.         // 检查是否需要销毁
  39.         if ($entry['views'] >= $entry['max_views']) {
  40.             @unlink($filePath);
  41.             unset($db[$token]);
  42.             saveDatabase($db);
  43.         }
  44.         exit;
  45.     } else {
  46.         renderInvalidLinkPage();
  47.         exit;
  48.     }
  49. }

  50. // 处理文件上传
  51. $error = '';
  52. $link = '';
  53. if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
  54.     $file = $_FILES['file'];
  55.     $maxViews = isset($_POST['views']) ? max(MAX_VIEWS_MIN, min(MAX_VIEWS_MAX, (int)$_POST['views'])) : MAX_VIEWS_MIN;
  56.    
  57.     // 验证文件类型
  58.     $allowedTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'];
  59.     if (!in_array($file['type'], $allowedTypes)) {
  60.         $error = '只允许上传JPG、PNG、GIF或WEBP图片';
  61.     } else if ($file['error'] !== UPLOAD_ERR_OK) {
  62.         $error = '文件上传错误: ' . $file['error'];
  63.     } else {
  64.         // 生成唯一标识
  65.         $token = bin2hex(random_bytes(16));
  66.         $filename = $token . '_' . basename($file['name']);
  67.         $filePath = STORAGE_DIR . $filename;
  68.         
  69.         // 保存文件
  70.         if (move_uploaded_file($file['tmp_name'], $filePath)) {
  71.             // 保存到数据库
  72.             $db = loadDatabase();
  73.             $db[$token] = [
  74.                 'filename' => $filename,
  75.                 'max_views' => $maxViews,
  76.                 'views' => 0,
  77.                 'created' => time()
  78.             ];
  79.             saveDatabase($db);
  80.             
  81.             // 生成访问链接
  82.             $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
  83.             $host = $_SERVER['HTTP_HOST'];
  84.             $script = $_SERVER['SCRIPT_NAME'];
  85.             $link = "$protocol://$host$script?token=$token";
  86.         } else {
  87.             $error = '文件保存失败,请检查目录权限';
  88.         }
  89.     }
  90. }

  91. // 辅助函数:加载数据库
  92. function loadDatabase() {
  93.     if (file_exists(DB_FILE)) {
  94.         return json_decode(file_get_contents(DB_FILE), true) ?: [];
  95.     }
  96.     return [];
  97. }

  98. // 辅助函数:保存数据库
  99. function saveDatabase($data) {
  100.     file_put_contents(DB_FILE, json_encode($data, JSON_PRETTY_PRINT));
  101. }

  102. // 渲染过期页面
  103. function renderExpiredPage() {
  104.     header("Content-Type: text/HTML");
  105.     echo <<<HTML
  106.     <!DOCTYPE html>
  107.     <html lang="zh-CN">
  108.     <head>
  109.         <meta charset="UTF-8">
  110.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  111.         <title>文件已销毁</title>
  112.         <style>
  113.             * {
  114.                 margin: 0;
  115.                 padding: 0;
  116.                 box-sizing: border-box;
  117.                 -webkit-tap-highlight-color: transparent;
  118.             }
  119.             body {
  120.                 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  121.                 background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  122.                 min-height: 100vh;
  123.                 display: flex;
  124.                 justify-content: center;
  125.                 align-items: center;
  126.                 color: #fff;
  127.                 padding: 20px;
  128.                 line-height: 1.5;
  129.             }
  130.             .container {
  131.                 background: rgba(255, 255, 255, 0.1);
  132.                 backdrop-filter: blur(10px);
  133.                 -webkit-backdrop-filter: blur(10px);
  134.                 border-radius: 16px;
  135.                 padding: 30px 25px;
  136.                 width: 100%;
  137.                 max-width: 400px;
  138.                 text-align: center;
  139.                 box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  140.                 border: 1px solid rgba(255, 255, 255, 0.2);
  141.                 margin: 20px;
  142.             }
  143.             h1 {
  144.                 font-size: 1.8rem;
  145.                 margin-bottom: 15px;
  146.                 font-weight: 600;
  147.                 text-shadow: 0 2px 10px rgba(0,0,0,0.2);
  148.             }
  149.             p {
  150.                 font-size: 1rem;
  151.                 margin-bottom: 25px;
  152.                 opacity: 0.9;
  153.             }
  154.             .icon {
  155.                 font-size: 3.5rem;
  156.                 margin-bottom: 20px;
  157.                 color: #ff6b6b;
  158.                 text-shadow: 0 0 15px rgba(255, 107, 107, 0.7);
  159.             }
  160.             .btn {
  161.                 display: inline-block;
  162.                 background: #fff;
  163.                 color: #2575fc;
  164.                 padding: 12px 28px;
  165.                 border-radius: 50px;
  166.                 text-decoration: none;
  167.                 font-weight: 600;
  168.                 font-size: 1rem;
  169.                 transition: all 0.2s ease;
  170.                 box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  171.                 border: none;
  172.                 cursor: pointer;
  173.                 width: 100%;
  174.                 max-width: 200px;
  175.             }
  176.             .btn:active {
  177.                 transform: scale(0.98);
  178.             }
  179.             @media (max-width: 480px) {
  180.                 .container {
  181.                     padding: 25px 20px;
  182.                     border-radius: 14px;
  183.                 }
  184.                 h1 {
  185.                     font-size: 1.6rem;
  186.                 }
  187.             }
  188.         </style>
  189.     </head>
  190.     <body>
  191.         <div class="container">
  192.             <div class="icon">🔥</div>
  193.             <h1>文件已自毁</h1>
  194.             <p>此文件已达到最大访问次数限制,系统已自动销毁。</p>
  195.             <a href="./" class="btn">返回首页</a>
  196.         </div>
  197.     </body>
  198.     </html>
  199. HTML;
  200. }

  201. // 渲染无效链接页面
  202. function renderInvalidLinkPage() {
  203.     header("Content-Type: text/html");
  204.     echo <<<HTML
  205.     <!DOCTYPE html>
  206.     <html lang="zh-CN">
  207.     <head>
  208.         <meta charset="UTF-8">
  209.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  210.         <title>链接无效</title>
  211.         <style>
  212.             * {
  213.                 margin: 0;
  214.                 padding: 0;
  215.                 box-sizing: border-box;
  216.                 -webkit-tap-highlight-color: transparent;
  217.             }
  218.             body {
  219.                 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  220.                 background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
  221.                 min-height: 100vh;
  222.                 display: flex;
  223.                 justify-content: center;
  224.                 align-items: center;
  225.                 color: #333;
  226.                 padding: 20px;
  227.                 line-height: 1.5;
  228.             }
  229.             .container {
  230.                 background: rgba(255, 255, 255, 0.2);
  231.                 backdrop-filter: blur(10px);
  232.                 -webkit-backdrop-filter: blur(10px);
  233.                 border-radius: 16px;
  234.                 padding: 30px 25px;
  235.                 width: 100%;
  236.                 max-width: 400px;
  237.                 text-align: center;
  238.                 box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  239.                 border: 1px solid rgba(255, 255, 255, 0.3);
  240.                 margin: 20px;
  241.             }
  242.             h1 {
  243.                 font-size: 1.8rem;
  244.                 margin-bottom: 15px;
  245.                 color: #d63031;
  246.                 font-weight: 600;
  247.             }
  248.             p {
  249.                 font-size: 1rem;
  250.                 margin-bottom: 25px;
  251.                 opacity: 0.9;
  252.             }
  253.             .icon {
  254.                 font-size: 3.5rem;
  255.                 margin-bottom: 20px;
  256.                 color: #d63031;
  257.             }
  258.             .btn {
  259.                 display: inline-block;
  260.                 background: #d63031;
  261.                 color: white;
  262.                 padding: 12px 28px;
  263.                 border-radius: 50px;
  264.                 text-decoration: none;
  265.                 font-weight: 600;
  266.                 font-size: 1rem;
  267.                 transition: all 0.2s ease;
  268.                 box-shadow: 0 4px 12px rgba(214, 48, 49, 0.3);
  269.                 border: none;
  270.                 cursor: pointer;
  271.                 width: 100%;
  272.                 max-width: 200px;
  273.             }
  274.             .btn:active {
  275.                 transform: scale(0.98);
  276.             }
  277.             @media (max-width: 480px) {
  278.                 .container {
  279.                     padding: 25px 20px;
  280.                     border-radius: 14px;
  281.                 }
  282.                 h1 {
  283.                     font-size: 1.6rem;
  284.                 }
  285.             }
  286.         </style>
  287.     </head>
  288.     <body>
  289.         <div class="container">
  290.             <div class="icon">⚠️</div>
  291.             <h1>链接无效或已过期</h1>
  292.             <p>您访问的链接可能已失效、过期或被销毁。</p>
  293.             <a href="./" class="btn">返回首页</a>
  294.         </div>
  295.     </body>
  296.     </html>
  297. HTML;
  298. }
  299. ?>

  300. <!DOCTYPE html>
  301. <html lang="zh-CN">
  302. <head>
  303.     <meta charset="UTF-8">
  304.     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  305.     <title>阅后自焚图片分享 - 刀客源码网</title>
  306.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  307.     <style>
  308.         :root {
  309.             --primary-color: #1a2a6c;
  310.             --secondary-color: #b21f1f;
  311.             --text-color: #333;
  312.             --light-text: #666;
  313.             --bg-color: #f8f9fa;
  314.             --card-bg: #fff;
  315.             --border-color: #e0e0e0;
  316.             --error-color: #e53e3e;
  317.             --success-color: #48bb78;
  318.         }
  319.         
  320.         * {
  321.             margin: 0;
  322.             padding: 0;
  323.             box-sizing: border-box;
  324.             -webkit-tap-highlight-color: transparent;
  325.         }
  326.         
  327.         body {
  328.             font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  329.             background: var(--bg-color);
  330.             color: var(--text-color);
  331.             line-height: 1.5;
  332.             min-height: 100vh;
  333.             padding: 0;
  334.             margin: 0;
  335.         }
  336.         
  337.         .app-container {
  338.             max-width: 100%;
  339.             width: 100%;
  340.             margin: 0 auto;
  341.             background: white;
  342.             min-height: 100vh;
  343.             position: relative;
  344.             overflow-x: hidden;
  345.         }
  346.         
  347.         /* 头部样式 */
  348.         .app-header {
  349.             background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  350.             color: white;
  351.             padding: 18px 20px;
  352.             text-align: center;
  353.             position: relative;
  354.         }
  355.         
  356.         .app-header h1 {
  357.             font-size: 1.5rem;
  358.             font-weight: 600;
  359.             margin-bottom: 5px;
  360.         }
  361.         
  362.         .app-header p {
  363.             font-size: 0.9rem;
  364.             opacity: 0.9;
  365.             max-width: 400px;
  366.             margin: 0 auto;
  367.         }
  368.         
  369.         .header-icon {
  370.             position: absolute;
  371.             top: 15px;
  372.             right: 15px;
  373.             font-size: 2rem;
  374.             opacity: 0.2;
  375.         }
  376.         
  377.         /* 主要内容区 */
  378.         .main-content {
  379.             padding: 20px;
  380.             max-width: 500px;
  381.             margin: 0 auto;
  382.         }
  383.         
  384.         /* 上传区域 */
  385.         .upload-section {
  386.             background: var(--card-bg);
  387.             border-radius: 14px;
  388.             padding: 20px;
  389.             margin-bottom: 20px;
  390.             box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  391.             border: 1px solid var(--border-color);
  392.         }
  393.         
  394.         .section-title {
  395.             display: flex;
  396.             align-items: center;
  397.             gap: 10px;
  398.             font-size: 1.2rem;
  399.             margin-bottom: 20px;
  400.             color: var(--primary-color);
  401.             font-weight: 600;
  402.         }
  403.         
  404.         .section-title i {
  405.             background: var(--primary-color);
  406.             color: white;
  407.             width: 36px;
  408.             height: 36px;
  409.             border-radius: 50%;
  410.             display: flex;
  411.             align-items: center;
  412.             justify-content: center;
  413.             font-size: 1rem;
  414.         }
  415.         
  416.         .form-group {
  417.             margin-bottom: 20px;
  418.         }
  419.         
  420.         label {
  421.             display: block;
  422.             margin-bottom: 8px;
  423.             font-weight: 500;
  424.             color: var(--text-color);
  425.             font-size: 0.95rem;
  426.         }
  427.         
  428.         /* 文件上传区域 */
  429.         .file-input {
  430.             position: relative;
  431.             border: 2px dashed var(--border-color);
  432.             border-radius: 12px;
  433.             padding: 30px 15px;
  434.             text-align: center;
  435.             transition: all 0.2s;
  436.             background: #f8fafc;
  437.             cursor: pointer;
  438.             overflow: hidden;
  439.         }
  440.         
  441.         .file-input:hover {
  442.             border-color: var(--primary-color);
  443.         }
  444.         
  445.         .file-input i {
  446.             font-size: 2.2rem;
  447.             color: var(--primary-color);
  448.             margin-bottom: 10px;
  449.         }
  450.         
  451.         .file-input p {
  452.             margin-bottom: 10px;
  453.             color: var(--light-text);
  454.             font-size: 0.9rem;
  455.         }
  456.         
  457.         .file-input .btn {
  458.             display: inline-block;
  459.             background: var(--primary-color);
  460.             color: white;
  461.             padding: 8px 16px;
  462.             border-radius: 8px;
  463.             font-weight: 500;
  464.             transition: all 0.2s;
  465.             font-size: 0.9rem;
  466.         }
  467.         
  468.         input[type="file"] {
  469.             position: absolute;
  470.             top: 0;
  471.             left: 0;
  472.             width: 100%;
  473.             height: 100%;
  474.             opacity: 0;
  475.             cursor: pointer;
  476.         }
  477.         
  478.         /* 计数器样式 */
  479.         .counter-container {
  480.             display: flex;
  481.             flex-direction: column;
  482.             gap: 8px;
  483.         }
  484.         
  485.         .counter-input {
  486.             display: flex;
  487.             align-items: center;
  488.             gap: 10px;
  489.         }
  490.         
  491.         .counter-input input {
  492.             flex: 1;
  493.             padding: 12px;
  494.             border: 2px solid var(--border-color);
  495.             border-radius: 10px;
  496.             font-size: 1rem;
  497.             text-align: center;
  498.             transition: border-color 0.2s;
  499.             -webkit-appearance: none;
  500.         }
  501.         
  502.         .counter-input input:focus {
  503.             border-color: var(--primary-color);
  504.             outline: none;
  505.         }
  506.         
  507.         .counter-btn {
  508.             width: 40px;
  509.             height: 40px;
  510.             border-radius: 50%;
  511.             background: var(--primary-color);
  512.             color: white;
  513.             border: none;
  514.             font-size: 1.1rem;
  515.             cursor: pointer;
  516.             display: flex;
  517.             align-items: center;
  518.             justify-content: center;
  519.             transition: all 0.2s;
  520.         }
  521.         
  522.         .counter-btn:active {
  523.             transform: scale(0.95);
  524.         }
  525.         
  526.         /* 提交按钮 */
  527.         .submit-btn {
  528.             background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  529.             color: white;
  530.             border: none;
  531.             padding: 14px 0;
  532.             border-radius: 12px;
  533.             font-size: 1.1rem;
  534.             font-weight: 600;
  535.             cursor: pointer;
  536.             width: 100%;
  537.             transition: all 0.2s;
  538.             box-shadow: 0 4px 12px rgba(26, 42, 108, 0.2);
  539.             display: flex;
  540.             align-items: center;
  541.             justify-content: center;
  542.             gap: 8px;
  543.         }
  544.         
  545.         .submit-btn:active {
  546.             transform: translateY(1px);
  547.         }
  548.         
  549.         /* 结果区域 */
  550.         .result-section {
  551.             background: var(--card-bg);
  552.             border-radius: 14px;
  553.             padding: 20px;
  554.             margin-bottom: 20px;
  555.             box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  556.             border: 1px solid var(--border-color);
  557.             display: none;
  558.         }
  559.         
  560.         .result-section.active {
  561.             display: block;
  562.         }
  563.         
  564.         .link-box {
  565.             background: #f0f4f8;
  566.             border-radius: 12px;
  567.             padding: 16px;
  568.             margin-top: 15px;
  569.             border: 2px dashed var(--border-color);
  570.         }
  571.         
  572.         .link-box p {
  573.             font-size: 0.95rem;
  574.             margin-bottom: 12px;
  575.             color: var(--primary-color);
  576.             font-weight: 500;
  577.         }
  578.         
  579.         .link-input {
  580.             display: flex;
  581.             flex-direction: column;
  582.             gap: 10px;
  583.         }
  584.         
  585.         .link-input input {
  586.             flex: 1;
  587.             padding: 12px;
  588.             border: 2px solid var(--border-color);
  589.             border-radius: 10px;
  590.             font-size: 0.9rem;
  591.             background: white;
  592.             width: 100%;
  593.         }
  594.         
  595.         .copy-btn {
  596.             background: var(--primary-color);
  597.             color: white;
  598.             border: none;
  599.             padding: 12px;
  600.             border-radius: 8px;
  601.             cursor: pointer;
  602.             transition: all 0.2s;
  603.             font-weight: 500;
  604.             font-size: 0.95rem;
  605.         }
  606.         
  607.         .copy-btn:active {
  608.             transform: scale(0.98);
  609.         }
  610.         
  611.         /* 信息卡片 */
  612.         .info-section {
  613.             background: var(--card-bg);
  614.             border-radius: 14px;
  615.             padding: 20px;
  616.             margin-bottom: 20px;
  617.             box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  618.             border: 1px solid var(--border-color);
  619.         }
  620.         
  621.         .info-grid {
  622.             display: grid;
  623.             grid-template-columns: 1fr 1fr;
  624.             gap: 12px;
  625.             margin-top: 15px;
  626.         }
  627.         
  628.         .info-card {
  629.             background: #f8fafc;
  630.             border-radius: 10px;
  631.             padding: 15px;
  632.             text-align: center;
  633.             border-left: 3px solid var(--primary-color);
  634.         }
  635.         
  636.         .info-card i {
  637.             font-size: 1.8rem;
  638.             color: var(--primary-color);
  639.             margin-bottom: 10px;
  640.         }
  641.         
  642.         .info-card h3 {
  643.             font-size: 0.95rem;
  644.             margin-bottom: 5px;
  645.             color: var(--primary-color);
  646.         }
  647.         
  648.         .info-card p {
  649.             font-size: 0.8rem;
  650.             color: var(--light-text);
  651.         }
  652.         
  653.         /* 错误提示 */
  654.         .error {
  655.             background: #fff5f5;
  656.             color: var(--error-color);
  657.             padding: 12px;
  658.             border-radius: 8px;
  659.             margin-top: 15px;
  660.             border-left: 3px solid var(--error-color);
  661.             display: flex;
  662.             align-items: center;
  663.             gap: 8px;
  664.             font-size: 0.9rem;
  665.         }
  666.         
  667.         /* 页脚 */
  668.         .app-footer {
  669.             text-align: center;
  670.             padding: 15px 20px;
  671.             background: #f8f9fa;
  672.             color: var(--light-text);
  673.             font-size: 0.8rem;
  674.             border-top: 1px solid var(--border-color);
  675.         }
  676.         
  677.         /* 响应式调整 */
  678.         @media (min-width: 500px) {
  679.             .app-container {
  680.                 max-width: 500px;
  681.                 margin: 10px auto;
  682.                 border-radius: 16px;
  683.                 overflow: hidden;
  684.                 box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  685.                 min-height: calc(100vh - 20px);
  686.             }
  687.             
  688.             .link-input {
  689.                 flex-direction: row;
  690.             }
  691.             
  692.             .copy-btn {
  693.                 width: auto;
  694.                 padding: 12px 20px;
  695.             }
  696.         }
  697.         
  698.         /* 动画效果 */
  699.         @keyframes fadeIn {
  700.             from { opacity: 0; transform: translateY(10px); }
  701.             to { opacity: 1; transform: translateY(0); }
  702.         }
  703.         
  704.         .fade-in {
  705.             animation: fadeIn 0.3s ease-out forwards;
  706.         }
  707.     </style>
  708. </head>
  709. <body>
  710.     <div class="app-container">
  711.         <header class="app-header">
  712.             <div class="header-icon">
  713.                 <i class="fas fa-fire"></i>
  714.             </div>
  715.             <h1>阅后自焚图片分享</h1>
  716.             <p>上传图片并设置访问次数,达到次数后自动销毁</p>
  717.         </header>
  718.         
  719.         <main class="main-content">
  720.             <section class="upload-section fade-in">
  721.                 <h2 class="section-title">
  722.                     <i class="fas fa-cloud-upload-alt"></i>
  723.                     <span>上传图片</span>
  724.                 </h2>
  725.                
  726.                 <form method="POST" enctype="multipart/form-data" id="upload-form">
  727.                     <div class="form-group">
  728.                         <label for="file">选择图片文件</label>
  729.                         <div class="file-input" id="file-input-area">
  730.                             <div id="file-initial-view">
  731.                                 <i class="fas fa-file-image"></i>
  732.                                 <p>点击或拖拽文件到此处</p>
  733.                                 <span class="btn">选择文件</span>
  734.                             </div>
  735.                             <div id="file-selected-view" style="display: none;">
  736.                                 <i class="fas fa-check-circle" style="color: var(--success-color);"></i>
  737.                                 <p id="file-name-display"></p>
  738.                                 <span class="btn">重新选择</span>
  739.                             </div>
  740.                             <input type="file" name="file" id="file" required accept="image/*">
  741.                         </div>
  742.                     </div>
  743.                     
  744.                     <div class="form-group">
  745.                         <label for="views">设置最大访问次数 (1-999)</label>
  746.                         <div class="counter-container">
  747.                             <div class="counter-input">
  748.                                 <button type="button" class="counter-btn minus">-</button>
  749.                                 <input type="number" name="views" id="views" value="1" min="1" max="999" required>
  750.                                 <button type="button" class="counter-btn plus">+</button>
  751.                             </div>
  752.                             <small style="color: var(--light-text);">达到设定次数后文件将自动销毁</small>
  753.                         </div>
  754.                     </div>
  755.                     
  756.                     <?php if (!empty($error)): ?>
  757.                         <div class="error">
  758.                             <i class="fas fa-exclamation-circle"></i>
  759.                             <span><?= htmlspecialchars($error) ?></span>
  760.                         </div>
  761.                     <?php endif; ?>
  762.                     
  763.                     <button type="submit" class="submit-btn">
  764.                         <i class="fas fa-fire"></i> 生成自焚链接
  765.                     </button>
  766.                 </form>
  767.             </section>
  768.             
  769.             <section class="result-section <?= !empty($link) ? 'active fade-in' : '' ?>">
  770.                 <h2 class="section-title">
  771.                     <i class="fas fa-link"></i>
  772.                     <span>分享链接</span>
  773.                 </h2>
  774.                
  775.                 <p>您的图片已上传成功!此链接在访问 <strong><?= isset($maxViews) ? $maxViews : 1 ?></strong> 次后将自动销毁。</p>
  776.                
  777.                 <div class="link-box">
  778.                     <p>复制以下链接分享给他人:</p>
  779.                     <div class="link-input">
  780.                         <input type="text" id="generated-link" value="<?= !empty($link) ? htmlspecialchars($link) : '' ?>" readonly>
  781.                         <button class="copy-btn" id="copy-btn">复制链接</button>
  782.                     </div>
  783.                 </div>
  784.             </section>
  785.             
  786.             <section class="info-section fade-in">
  787.                 <h2 class="section-title">
  788.                     <i class="fas fa-info-circle"></i>
  789.                     <span>使用说明</span>
  790.                 </h2>
  791.                
  792.                 <div class="info-grid">
  793.                     <div class="info-card">
  794.                         <i class="fas fa-upload"></i>
  795.                         <h3>上传图片</h3>
  796.                         <p>选择要分享的图片</p>
  797.                     </div>
  798.                     
  799.                     <div class="info-card">
  800.                         <i class="fas fa-cog"></i>
  801.                         <h3>设置次数</h3>
  802.                         <p>设置允许访问次数</p>
  803.                     </div>
  804.                     
  805.                     <div class="info-card">
  806.                         <i class="fas fa-share-alt"></i>
  807.                         <h3>分享链接</h3>
  808.                         <p>复制生成的链接</p>
  809.                     </div>
  810.                     
  811.                     <div class="info-card">
  812.                         <i class="fas fa-fire"></i>
  813.                         <h3>自动销毁</h3>
  814.                         <p>达到次数自动删除</p>
  815.                     </div>
  816.                 </div>
  817.             </section>
  818.         </main>
  819.         
  820.         <footer class="app-footer">
  821.             <p>© <?= date('Y') ?> 阅后自焚图片分享系统 | 所有文件将在达到访问次数后自动销毁</p>
  822.         </footer>
  823.     </div>
  824.    
  825.     <script>
  826.         // 计数器功能
  827.         const minusBtn = document.querySelector('.minus');
  828.         const plusBtn = document.querySelector('.plus');
  829.         const viewsInput = document.getElementById('views');
  830.         
  831.         minusBtn.addEventListener('click', function() {
  832.             let value = parseInt(viewsInput.value) || 1;
  833.             if (value > 1) {
  834.                 viewsInput.value = value - 1;
  835.             }
  836.         });
  837.         
  838.         plusBtn.addEventListener('click', function() {
  839.             let value = parseInt(viewsInput.value) || 1;
  840.             if (value < 999) {
  841.                 viewsInput.value = value + 1;
  842.             }
  843.         });
  844.         
  845.         // 文件上传区域交互
  846.         const fileInput = document.getElementById('file');
  847.         const fileInputArea = document.getElementById('file-input-area');
  848.         const fileInitialView = document.getElementById('file-initial-view');
  849.         const fileSelectedView = document.getElementById('file-selected-view');
  850.         const fileNameDisplay = document.getElementById('file-name-display');
  851.         
  852.         fileInput.addEventListener('change', function() {
  853.             if (this.files.length > 0) {
  854.                 const fileName = this.files[0].name;
  855.                 const displayName = fileName.length > 20
  856.                     ? fileName.substring(0, 17) + '...'
  857.                     : fileName;
  858.                
  859.                 // 显示已选文件视图,隐藏初始视图
  860.                 fileInitialView.style.display = 'none';
  861.                 fileSelectedView.style.display = 'block';
  862.                 fileNameDisplay.textContent = displayName;
  863.                
  864.                 // 更新UI样式
  865.                 fileInputArea.style.borderColor = 'var(--success-color)';
  866.                 fileInputArea.style.backgroundColor = '#f0fff4';
  867.             }
  868.         });
  869.         
  870.         // 重新选择功能
  871.         fileSelectedView.addEventListener('click', function(e) {
  872.             if (e.target.classList.contains('btn')) {
  873.                 // 触发文件选择对话框
  874.                 fileInput.click();
  875.             }
  876.         });
  877.         
  878.         // 拖拽上传功能
  879.         fileInputArea.addEventListener('dragover', (e) => {
  880.             e.preventDefault();
  881.             fileInputArea.style.borderColor = 'var(--primary-color)';
  882.             fileInputArea.style.backgroundColor = '#edf2f7';
  883.         });
  884.         
  885.         fileInputArea.addEventListener('dragleave', () => {
  886.             fileInputArea.style.borderColor = 'var(--border-color)';
  887.             fileInputArea.style.backgroundColor = '#f8fafc';
  888.         });
  889.         
  890.         fileInputArea.addEventListener('drop', (e) => {
  891.             e.preventDefault();
  892.             fileInputArea.style.borderColor = 'var(--border-color)';
  893.             fileInputArea.style.backgroundColor = '#f8fafc';
  894.             
  895.             if (e.dataTransfer.files.length) {
  896.                 fileInput.files = e.dataTransfer.files;
  897.                 const event = new Event('change');
  898.                 fileInput.dispatchEvent(event);
  899.             }
  900.         });
  901.         
  902.         // 复制链接功能
  903.         const copyBtn = document.getElementById('copy-btn');
  904.         if (copyBtn) {
  905.             copyBtn.addEventListener('click', function() {
  906.                 const linkInput = document.getElementById('generated-link');
  907.                 linkInput.select();
  908.                 document.execCommand('copy');
  909.                
  910.                 const originalText = copyBtn.textContent;
  911.                 copyBtn.textContent = '已复制!';
  912.                 copyBtn.style.background = 'var(--success-color)';
  913.                
  914.                 setTimeout(() => {
  915.                     copyBtn.textContent = originalText;
  916.                     copyBtn.style.background = 'var(--primary-color)';
  917.                 }, 2000);
  918.             });
  919.         }
  920.         
  921.         // 如果有链接生成,滚动到结果区域
  922.         <?php if (!empty($link)): ?>
  923.             setTimeout(() => {
  924.                 document.querySelector('.result-section').scrollIntoView({
  925.                     behavior: 'smooth'
  926.                 });
  927.             }, 300);
  928.         <?php endif; ?>
  929.     </script>
  930. </body>
复制代码
MVP星源–发现最有趣的!https://www.mvpxo.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 手机网页版
  • 移动APP端
Copyright © 2001-2025 MVP星源–发现最有趣的! 版权所有 All Rights Reserved. 手机版|小黑屋|站点统计|Archiver|网站地图|闽ICP备12007159号-8|闽公网安备35021202000806号
关灯 在本版发帖
扫一扫访问移动端
QQ客服返回顶部
快速回复 返回顶部 返回列表