<?php
#############引入文件###############
include('./data/config.php');
include('./core/up.fun.php');
include('./core/db.fun.php');
#############判断有效###############
if(empty($_FILES['file'])){die('error 1');}
if($_FILES['file']['size'] == 0){die('error 2');}
if(!is_uploaded_file($_FILES['file']['tmp_name'])){die('error3');}
#############组装数据###############
$file['name'] = get_name($_FILES['file']['name']);
$file['type'] = get_ext($_FILES['file']['name']);
$file['size'] = $_FILES['file']['size'];
$file['up']   = time();
$file['dt']   = $file['up'];
$file['des']  = '暂无描述';
$file['id']   = make_id(2).$file['up'];
$file['pass'] = make_pass(6);
$file['down'] = 1;
$file['pro']  = 0;
$file['po']   = 'null';
#############组装路径###############
$file['save'] = make_save_path($file['id'],$file['up']);
#############写入数据###############
save_to_db($file);
#############保存文件###############
move_uploaded_file($_FILES['file']['tmp_name'],$file['save']);
#############预置输出###############
$change['<#copy#>']      =  time();
$con = '
<div id="pw_box<#id#>" class="pw_box">
        <h2><span onclick="closepw_box(\'pw_box<#id#>\')">关闭</span>上传成功</h2>
        <ul>
          <li><span>文件名：</span><#name#></li>
          <li><span>文件类型：</span><#type#></li>
          <li><span>文件大小：</span><#size#></li>
          <li><span>上传时间：</span><#up#></li>
          <li><span>文件ID：</span><#id#></li>
          <li><span>管理密码：</span><#pass#></li>
          <input type="hidden" name="<#id#>" value="文件名：<#name#> 文件类型：<#type#> 文件大小：<#size#> 上传时间：<#up#> 文件ID：<#id#> 管理密码:<#pass#>" id="<#id#>" />
          <form action="g.php" method="post" name="go_g<#id#>" target="_blank">
          <input type="hidden" name="id" value="<#id#>" />
          <input type="hidden" name="pass" value="<#pass#>" />
          </form>
        </ul>
        <p><a href="javascript::" title="复制文件信息到粘贴板" onclick="copyToClipboard(\'<#id#>\');">复制</a><a href="javascript::" title="进入管理页面" onclick="document.go_g<#id#>.submit();">管理</a><a href="<#link#>" title="进入下载页面" target="_blank" >下载</a></p>
      </div>';
#############替换变量设置#############
$change['<#id#>'] = $file['id'];
$change['<#name#>'] = $file['name'];
$change['<#pass#>'] = $file['pass'];
$change['<#type#>'] = $file['type'];
$change['<#up#>']   = date('Y-m-d',$file['up']);
$change['<#size#>'] = size_info($file['size']);
$change['<#link#>'] = $config['url'].'/t.php/'.$file['id'].'.html';
############模板切换##################
$html = strtr($con,$change);
############输出内容##################
echo $html;
?>
