<?php
$_t = microtime(true);
$G = new HccTools;
$pfm = array('baidu'=>'百度','qq'=>'QQ','weibo'=>'微博');
$login = $G->get('login');
$_pf = $G->post('pf');
$login = strlen($login) < 1 ? $_pf : $login;
$id = $G->get('id');
switch($login){
case 'baidu':$G->login($login);break;
case 'qq':$G->login($login);break;
case 'weibo':$G->login($login);break;
case 'false':$G->cookie('oauthUser', true);
header('location:'. $G->url);break;
default:$user = json_decode($G->cookie('oauthUser'), true);
}
$preview = '';
$msg = '';
// 请修改为您的Mysql数据库
$G->pdo('127.0.0.1', 3306, '您的Mysql登入用户名称', '您的Mysql登入密码', '您的Mysql数据库');
// 首次请执行以下SQL语句,执行完成请注释或删除
//$G->pdo_execute("CREATE TABLE IF NOT EXISTS `$G->dbname`.`list`(`id` int(255) NOT NULL AUTO_INCREMENT COMMENT '索引ID',`pf` text NOT NULL COMMENT '授权平台',`uid` text NOT NULL COMMENT '用户标识',`utk` text NOT NULL COMMENT '用户密匙',`nickname` text NOT NULL COMMENT '用户昵称',`avarat` text NOT NULL COMMENT '用户头像',`filename` text NOT NULL COMMENT '文件名称',`type` text NOT NULL COMMENT '文件类型',`size` int(255) NOT NULL COMMENT '文件大小',`ext` text NOT NULL COMMENT '文件后缀',`date` text NOT NULL COMMENT '文件上传日期',`hash` text NOT NULL COMMENT '文件哈希',PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文件表' AUTO_INCREMENT=5;");
if(isset($_FILES['b5bfa8e03bd71c8562041dfebdf59559'])){
$res = $G->upload('b5bfa8e03bd71c8562041dfebdf59559');
if(isset($res['msg']))$msg .= '<div class="sue">'. $res['msg'] .'</div><script>alert("'. $res['msg'] .'");</script>';
if(!empty($res['id']) && strlen($res['hash']) === 32 ){
header('location:?id='. $res['id']);
exit;
}
}
if(!empty($id) && !preg_match('/^\d+$/i', $id)){
$id = preg_replace('/[^\d]+/i','', $id);
header('location:?id='. $id);
exit;
}
if(!empty($id)){
$res = $G->pdo_execute("select * from `$G->dbname`.`list` where id='$id'")->fetch();
$subd = $res['type'] .'/'. substr($res['hash'], 0, 3) .'/'. $G->prefix . $res['hash'] .'.'. $res['ext'];
if($res !== false && file_exists($subd)){
$fileurl = $G->sheme . $_SERVER['HTTP_HOST'] . $G->subd . $subd;
$msg .= '文件“'. $res['filename'] .'”('. $G->cov($res['size']) .')已由'. $pfm[$res['pf']] .'用户'. ($user['appid'] === $res['uid'] ? '<a href="?auther='. $user['appid'] .'">您('. $res['nickname'] .')</a>' : '<strong>'. $res['nickname'] .'</strong>') .'在'. date('Y年m月d日H时i分s秒', $res['date']) .'上传,您可通过以下地址访问:<br /><textarea onclick="select()" onfoucs="select()" spellcheck="false" x-webkit-speech>'. $fileurl .'</textarea>';
$ogName = $res['filename'];
$ogImg = $fileurl;
$ogDesc = '您的'. $pfm[$res['pf']] .'好友'. $res['nickname'] .'给您分享了'. $res['filename'];
if(in_array($res['type'], array('png','gif','jpg','jpeg','bmp'))){
$preview .= '<a target="_blank" href="'. $fileurl .'"><img src="'. $fileurl .'" /></a>';
$ogName = '[图]'. $res['filename'];
$ogImg = $fileurl;
$ogDesc = '您的'. $pfm[$res['pf']] .'好友'. $res['nickname'] .'给您分享了'. $res['filename'];
}
if(in_array($res['type'], array('mp4'))){
$preview .= '<video preload="auto" autoplay="autoplay" controls="controls" name="media"><source src="'. $fileurl .'" type="video/'. $res['type'] .'"></video>';
$ogName = '[视频]'. $res['filename'];
$ogImg = $fileurl;
$ogDesc = '您的'. $pfm[$res['pf']] .'好友'. $res['nickname'] .'给您分享了'. $res['filename'];
}
$title = $res['nickname'] . $res['filename'] .'('. $G->cov($res['size']) .')';
}else{
header('HTTP/1.1 404 Not Found');
$title = '404 - Not Found';
$msg = '<div style="font-size:3em;font-weight:bold;line-height:normal;color:#ed2224;margin:1rem auto;text-shadow:3px 3px 5px #bbb;text-align:center">404</div>请求的文件不存在或者违规被删除!';
}
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo empty($title) ? '' : $title .' - ';?>文件上传</title>
<meta name="theme-color" content="#efefef">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta property="og:locale" content="zh_CN">
<meta name='document-state' content='static' />
<meta http-equiv="cache-control" content="public">
<meta itemprop="name" content="<?php echo empty($ogName) ? '文件分享上传' : $ogName;?>" />
<meta itemprop="image" content="<?php echo empty($ogImg) ? 'https://ssl.xn--vqq79r59m.eu.org/favicon.ico' : $ogImg;?>" />
<meta itemprop="description" content="<?php echo empty($ogDesc) ? '在遵守中国当地法律法规的前提下可上传分享您的文件!' : $ogDesc;?>" />
<link rel="shortcut icon" href="https://ssl.xn--vqq79r59m.eu.org/favicon.ico" />
<link rel="bookmark" href="https://ssl.hechaocheng.eu.org/favicon.ico" />
<link rel="canonical" href="<?php echo $G->url . (empty($id) ? '' : '?id='. $id);?>" />
<style type="text/css">
*{margin:0;padding:0;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:16px;}
a{text-decoration:none}
img,video{display:block;margin:0 auto;}
img{width:auto;height:auto;max-width:100%;max-height:100%;}
textarea{width:100%;outline:none;color:blue;border:none;resize:none}
center{color:#999;}
<?php
$border = '#cfd8dc';
if(!empty($user) && isset($user['platf']))switch($user['platf']){
case 'qq':$border = '#0aa858';break;
case 'weibo':$border = '#f4433c';break;
case 'baidu':$border = '#2d85f0';break;
}
?>
ul{list-style-type:none;}
ul li{float:left;}
ul.platform{margin-bottom:.3em;background-color:#eee;border-bottom:1px solid <?php echo $border;?>;}
ul.platform li{line-height:2.5em;width:25%;text-align:center;}
ul.platform li a{display:block;color:unset;}
ul.platform li:hover,ul.platform li a:hover{color:#eee}
ul.platform li act{}
li.qq{color:#0aa858;}
li.sina{color:#f4433c;}
li.baidu{color:#2d85f0;}
li.siguout{color:#353535}
li.qq:hover{background-color:#0aa858;}
li.sina:hover{background-color:#f4433c;}
li.baidu:hover{background-color:#2d85f0;}
li.siguout:hover{background-color:#353535}
div.msg{display:block;margin:1em 0;padding:.625em;position:relative;box-sizing:border-box;line-height:inherit;vertical-align:middle;border:.0625em solid #a5d5ff;background-color:#e6f7ff;background-image:none;color:#dd191d;font-size:75%;}
div.sue{display:block;margin:1em 0;padding:.625em;position:relative;box-sizing:border-box;line-height:inherit;vertical-align:middle;border:.0625em solid #9ce4bc;background-color:#e6f8ee;background-image:none;color:#007e3b}
</style>
</head>
<body>
<div style="margin:0 auto;overflow:hidden;max-width:45.375em;width:100%;background-color:#fff;">
<ul class="platform">
<li class="qq"<?php echo !empty($user) && $user['platf'] === 'qq' ? ' style="background-color:#0aa858;color:#eee"': '';?>><?php echo !empty($user) && $user['platf'] === 'qq' ? 'QQ': '<a href="?login=qq">QQ</a>';?></li>
<li class="sina"<?php echo !empty($user) && $user['platf'] === 'weibo' ? ' style="background-color:#f4433c;color:#eee"': '';?>><?php echo !empty($user) && $user['platf'] === 'weibo' ? '微博': '<a href="?login=weibo">微博</a>';?></li>
<li class="baidu"<?php echo !empty($user) && $user['platf'] === 'baidu' ? ' style="background-color:#2d85f0;color:#eee"': '';?>><?php echo !empty($user) && $user['platf'] === 'baidu' ? '百度': '<a href="?login=baidu">百度</a>';?></li>
<li class="siguout"<?php echo empty($user) ? ' style="background-color:#cfd8dc;color:#444"': '';?>><?php echo empty($user) ? '未登入': '<a onClick="if(confirm(\'注销