Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
1.4.5赞助版源码
Browse files Browse the repository at this point in the history
1.4.5赞助版源码
  • Loading branch information
yuantuo666 authored Jan 25, 2021
1 parent 277383a commit a2f76c9
Show file tree
Hide file tree
Showing 7 changed files with 1,169 additions and 62 deletions.
118 changes: 118 additions & 0 deletions api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php

/**
* PanDownload 网页复刻版,PHP 语言版API文件
*
* 提供一些接口服务
*
* @version 1.4.5
*
* @author Yuan_Tuo <yuantuo666@gmail.com>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
*
*/
session_start();
define('init', true);
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
http_response_code(503);
header('Content-Type: text/plain; charset=utf-8');
header('Refresh: 5;url=https://www.php.net/downloads.php');
die("HTTP 503 服务不可用!\r\nPHP 版本过低!无法正常运行程序!\r\n请安装 7.0.0 或以上版本的 PHP!\r\n将在五秒内跳转到 PHP 官方下载页面!");
}
if (!(file_exists('config.php') && file_exists('functions.php'))) {
http_response_code(503);
header('Content-Type: text/plain; charset=utf-8');
header('Refresh: 5;url=https://github.com/yuantuo666/baiduwp-php');
die("HTTP 503 服务不可用!\r\n缺少相关配置和定义文件!无法正常运行程序!\r\n请重新 Clone 项目并配置!\r\n将在五秒内跳转到 GitHub 储存库!");
}
// 导入配置和函数
require('config.php');
require('functions.php');
// 通用响应头
header('Content-Type: text/html; charset=utf-8');
header('X-UA-Compatible: IE=edge,chrome=1');
//隐藏错误代码,保护信息安全
if (DEBUG) {
error_reporting(E_ALL);
} else {
error_reporting(0); //关闭错误报告
}

$method = (!empty($_GET["m"])) ? $_GET["m"] : "";
switch ($method) {
case 'LastParse':
//返回数据库中上一次解析的时间,及SVIP状态
if (USING_DB) {
//开启了数据库
connectdb(true);

$sql = "SELECT * FROM `$dbtable` WHERE `size`>=52428800 ORDER BY `ptime` DESC LIMIT 0,1"; //时间倒序输出第一项
$mysql_query = mysqli_query($conn, $sql);
if ($Result = mysqli_fetch_assoc($mysql_query)) {
//存在数据
$Time = $Result["ptime"];
$realLink = $Result["realLink"];
$SvipState = (strstr('https://' . $realLink, "//qdall")) ? 0 : 1; //1:正常 0:限速
$SvipStateMsg = ($SvipState) ? "状态正常" : "已被限速";
$SvipTips = ($SvipState) ? "正常" : "限速";
EchoInfo(0, array(
"msg" => "SVIP账号状态<br /><div align='left'>上次解析时间:" . $Time . "<br />上次解析状态:" . $SvipStateMsg . "</div>",
"svipstate" => $SvipState,
"sviptips" => $SvipTips
));
} else {
EchoInfo(0, array("msg" => "数据库中没有数据"));
}
} else {
//未开启数据库
EchoInfo(-1, array("msg" => "未开启数据库功能", "sviptips" => "Unknown"));
}
break;

case "ParseCount":
//返回数据库中所有的解析总数和文件总大小
if (USING_DB) {
//开启了数据库
connectdb(true);

$sql = "SELECT count(`id`) as AllCount,sum(`size`) as AllSize FROM `$dbtable`";
$mysql_query = mysqli_query($conn, $sql);
if ($Result = mysqli_fetch_assoc($mysql_query)) {
//存在数据
$AllCount = $Result["AllCount"];
$AllSize = formatSize((int)$Result["AllSize"]); //格式化获取到的文件大小
$ParseCountMsg = "累计解析 $AllCount 个,共 $AllSize";
} else {
EchoInfo(0, array("msg" => "当前数据库版本不支持此统计操作"));
exit;
}

$sql = "SELECT count(`id`) as AllCount,sum(`size`) as AllSize FROM `$dbtable` WHERE date(`ptime`)=date(now());"; //获取今天的解析量
$mysql_query = mysqli_query($conn, $sql);
if ($Result = mysqli_fetch_assoc($mysql_query)) {
//存在数据
$AllCount = $Result["AllCount"];
$AllSize = formatSize((int)$Result["AllSize"]); //格式化获取到的文件大小
$TodayParseCountMsg = "今日解析 $AllCount 个,共 $AllSize";
} else {
EchoInfo(0, array("msg" => "当前数据库版本不支持此统计操作"));
exit;
}
EchoInfo(0, array("msg" => "系统使用统计<br /><div align='left'>$ParseCountMsg<br />$TodayParseCountMsg</div>"));
} else {
//未开启数据库
EchoInfo(-1, array("msg" => "未开启数据库功能"));
}
break;
default:
EchoInfo(-1, array("msg" => "无传入数据"));
break;
}

function EchoInfo(int $error, array $Result)
{
$ReturnArray = array("error" => $error);
$ReturnArray += $Result;
echo json_encode($ReturnArray);
}
86 changes: 86 additions & 0 deletions bdwp.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
-- MySQL dump 10.13 Distrib 5.6.47, for Linux (x86_64)
--
-- Host: localhost Database: bdwp
-- ------------------------------------------------------
-- Server version 5.6.47-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `bdwp`
--

DROP TABLE IF EXISTS `bdwp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bdwp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userip` text NOT NULL COMMENT '用户ip',
`filename` text NOT NULL COMMENT '文件名',
`size` text NOT NULL COMMENT '文件大小',
`md5` text NOT NULL COMMENT '文件效验码',
`path` text NOT NULL COMMENT '文件路径',
`server_ctime` text NOT NULL COMMENT '文件创建时间',
`realLink` text NOT NULL COMMENT '文件下载地址',
`ptime` datetime NOT NULL COMMENT '解析时间',
`paccount` int(11) NOT NULL COMMENT '解析账号id',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5050 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bdwp_ip`
--

DROP TABLE IF EXISTS `bdwp_ip`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bdwp_ip` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` text NOT NULL COMMENT 'ip地址',
`remark` text NOT NULL COMMENT '备注',
`add_time` datetime NOT NULL COMMENT '白黑名单添加时间',
`type` tinyint(4) NOT NULL COMMENT '状态(0:允许,-1:禁止)',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bdwp_svip`
--

DROP TABLE IF EXISTS `bdwp_svip`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bdwp_svip` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text NOT NULL COMMENT '账号名称',
`svip_bduss` text NOT NULL COMMENT '会员bduss',
`svip_stoken` text NOT NULL COMMENT '会员stoken',
`add_time` datetime NOT NULL COMMENT '会员账号加入时间',
`state` tinyint(4) NOT NULL COMMENT '会员状态(0:正常,-1:限速)',
`is_using` datetime NOT NULL COMMENT '是否正在使用(非零表示真)',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=255 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2020-10-20 23:21:53
38 changes: 23 additions & 15 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,45 @@
* 请不要使用弱密码!否则后果自负!
* 若只在局域网开放,则可根据个人喜好开启或关闭密码。
*
* @version 1.4.3
* @version 1.4.5
*
* @author Yuan_Tuo <yuantuo666@gmail.com>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
*
*/
define('programVersion', '1.4.3');
define('programVersion', '1.4.5');
if (!defined('init')) { // 直接访问处理程序
http_response_code(403);
header('Content-Type: text/plain; charset=utf-8');
header('Refresh: 3;url=./');
die("HTTP 403 禁止访问!\r\n此文件是 PanDownload 网页复刻版 PHP 语言版项目版本 " . programVersion . " 的配置文件!\r\n禁止直接访问!");
http_response_code(403);
header('Content-Type: text/plain; charset=utf-8');
header('Refresh: 3;url=./');
die("HTTP 403 禁止访问!\r\n此文件是 PanDownload 网页复刻版 PHP 语言版项目版本 " . programVersion . " 的配置文件!\r\n禁止直接访问!");
}

define('BDUSS', ''); // 你的 BDUSS
define('STOKEN', ''); // 你的 STOKEN
define('SVIP_BDUSS', ''); // 你的 SVIP BDUSS

define('IsCheckPassword', true); // 设为 true 则要求密码为变量 Password 的值,否则提示密码错误;设为 false 则不需要密码。
define('Password', '请在这里填写密码'); // 在下载器首页需要输入的密码,如果将 IsCheckPassWord 设为 false 则无论设置什么都会失效。
define('Password', ''); // 在下载器首页需要输入的密码,如果将 IsCheckPassWord 设为 false 则无论设置什么都会失效。
define('Footer', ''); // 页脚统计代码放置处

define('APP_ID', '250528'); // 推荐应用ID:498065、309847、778750(油猴脚本默认)、250528(官方)、265486、266719;
define('DEBUG', false);//WARNING! 请勿随意打开此模式,可能造成你的信息泄露。 打开此模式前请先修改密码。

define('DEBUG', false); //WARNING! 请勿随意打开此模式,可能造成你的信息泄露。 打开此模式前请先修改密码。

define('USING_DB', false); //是否开启数据库功能
//连接数据库
define('USING_DB', true);
define('DbConfig', array(
"servername" => "localhost",
"username" => "",
"password" => "",
"dbname" => "",
"dbtable" => "bdwp"
"servername" => "localhost",
"username" => "root",
"password" => "root",
"dbname" => "test",
"dbtable" => "bdwp"
));

define('ADMIN_PASSWORD', ' '); //管理员密码 登录地址/setting.php

// 请勿修改下方内容,如果手动修改后再在后台设置,可能导致config.php文件被清空
// $DownloadTimes=... 为后台判断依据请勿修改。
$DownloadTimes=5;
define('DownloadTimes', $DownloadTimes);
4 changes: 2 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* 请勿随意修改此文件!如需更改相关配置请到 config.php !
*
* @version 1.4.3
* @version 1.4.5
*
* @author Yuan_Tuo <yuantuo666@gmail.com>
* @link https://imwcr.cn/
Expand Down Expand Up @@ -296,4 +296,4 @@ function connectdb(bool $isAPI = false)
mysqli_query($conn, "set sql_mode = ''");
mysqli_query($conn, "set character set 'utf8'");
mysqli_query($conn, "set names 'utf8'");
}
}
Loading

0 comments on commit a2f76c9

Please sign in to comment.