美化界面,添加合集,修补漏洞

This commit is contained in:
sakitsuki_asahi
2025-09-30 08:17:28 +08:00
parent 4a18433715
commit d0ce236c66
15 changed files with 1775 additions and 248 deletions
-17
View File
@@ -1,17 +0,0 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/include"
],
"defines": [],
"compilerPath": "/usr/bin/clang-15",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
-82
View File
@@ -1,82 +0,0 @@
{
"files.associations": {
"typeindex": "cpp",
"typeinfo": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"slist": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"variant": "cpp",
"regex": "cpp"
}
}
-28
View File
@@ -1,28 +0,0 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ アクティブなファイルのビルド",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "デバッガーによって生成されたタスク。"
}
],
"version": "2.0.0"
}
+99
View File
@@ -0,0 +1,99 @@
#include <mysql.hpp>
#include <database.hpp>
#include <html5.hpp>
#include <string>
#include <cgicc/Cgicc.h>
#include <iostream>
bool login=false;
bool member=false;
int main(){
mysqlpp::Connection database;
userdata user;
cgicc::Cgicc cgi;
std::string s_id = get_cookie(cgi,"id");
std::string s_loginkey = get_cookie(cgi,"loginkey");
if(s_id==""||s_id.find_first_not_of("0123456789")!=std::string::npos||std::stoul(s_id)>UINT64_MAX){
s_id="";
}
if(s_loginkey==""||s_loginkey.find_first_not_of("0123456789")!=std::string::npos||std::stoul(s_loginkey)>UINT64_MAX){
s_loginkey="";
}
if(!connect_mysql(&database)){
std::cout << "Content-type:text/html\r\n\r\n"
<< "<html>\n"
<< "<head>\n"
<< "<meta charset=\"utf-8\">\n"
<< "<title>出现错误!</title>\n"
<< "</head>\n"
<< "<body>\n"
<< "数据库连接失败,请检查服务器状态!\n"
<< "</body>\n"
<< "</html>\n";
return 0;
}
if(s_id!=""&&query_userdata(database,&user,"id = "+s_id)){
if(s_loginkey!=""&&user.loginkey==std::stoul(s_loginkey)){
login=true;
}
if(user.status=='m'){
member=true;
}
if(!login&&member){
member=false;
}
}
if(login&&member){
std::string action = cgi.getElement("action")->getValue();
if(action=="create"){
std::string title = cgi.getElement("title")->getValue();
if(title.size()>255||title.find_first_of("'\\")!=std::string::npos){
std::cout << "Status: 502 Bad request\r\n" << std::endl;
return 0;
}
change_mysql(database,"INSERT INTO collectiondata (title,uploader) VALUE ('"+title+"',"+s_id+")");
change_mysql(database,"CREATE TABLE collection_"+std::to_string(latest_cid(database))+" ( id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, vid BIGINT UNSIGNED NOT NULL ) CHARSET=utf8mb4 ENGINE=InnoDB;");
std::cout << "Status: 200 OK\r\n" << std::endl;
return 0;
}else if(action=="add_video"){
std::string cid = cgi.getElement("collection_id")->getValue();
std::string vid = cgi.getElement("video_id")->getValue();
if(cid.find_first_not_of("0123456789")!=std::string::npos||vid.find_first_not_of("0123456789")!=std::string::npos){
std::cout << "Status: 502 Bad request\r\n" << std::endl;
return 0;
}
change_mysql(database,"UPDATE collectiondata SET videocount = videocount + 1 WHERE id = "+cid);
change_mysql(database,"UPDATE videodata SET collection = "+cid+" WHERE id = "+vid);
change_mysql(database,"INSERT INTO collection_"+cid+" (vid) VALUE ("+vid+")");
std::cout << "Status: 200 OK\r\n" << std::endl;
return 0;
}else if(action=="update"){
std::string title = cgi.getElement("title")->getValue();
std::string cid = cgi.getElement("collection_id")->getValue();
if(title.size()>255||title.find_first_of("'\\")!=std::string::npos||cid.find_first_not_of("0123456789")!=std::string::npos){
std::cout << "Status: 502 Bad request\r\n" << std::endl;
return 0;
}
change_mysql(database,"UPDATE collectiondata SET title = '"+title+"' WHERE id = "+cid);
std::cout << "Status: 200 OK\r\n" << std::endl;
return 0;
}else if(action=="delete"){
std::string cid = cgi.getElement("collection_id")->getValue();
if(cid.find_first_not_of("0123456789")!=std::string::npos){
std::cout << "Status: 502 Bad request\r\n" << std::endl;
return 0;
}
change_mysql(database,"DROP TABLE collection_"+cid);
change_mysql(database,"DELETE FROM collectiondata WHERE id = "+cid);
std::cout << "Status: 200 OK\r\n" << std::endl;
return 0;
}else{
std::cout << "Status: 502 Bad request\r\n" << std::endl;
return 0;
}
}else{
std::cout << "Status: 302 Found\r\n"
<< "Location: /\r\n" << std::endl;
}
}
+19 -16
View File
@@ -80,22 +80,25 @@ int main(){
<< "Location: /\r\n" << std::endl;
}else{
std::string errcode;bool error = false;bool rereg = false;
if(cgi.getElement("cid")->getValue().size()>=16||!regexMatch(cgi.getElement("cid")->getValue(),"[\\w-]+")){
std::string cid = cgi.getElement("cid")->getValue();
std::string name = cgi.getElement("name")->getValue();
std::string email = cgi.getElement("email")->getValue();
if(cid.size()>=16||!regexMatch(cid,"[\\w-]+")){
errcode = "账户名太长了或不符合规则。";error=true;
}
if(cgi.getElement("name")->getValue().size()>=96||!regexMatch(cgi.getElement("name")->getValue(),"[\\S]+")||cgi.getElement("name")->getValue().find_first_of("'\\")!=std::string::npos){
if(name.size()>=96||!regexMatch(name,"[\\S]+")||name.find_first_of("'\\")!=std::string::npos){
errcode = "昵称太长了或不符合规则。";error=true;
}
if(!regexMatch(cgi.getElement("email")->getValue(),"\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}")||cgi.getElement("email")->getValue().size()>=64){
if(!regexMatch(email,"\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}")||email.size()>=64){
errcode = "邮箱太长了或不符合规则。";error=true;
}
if(query_userdata(database,&user,"email = '"+cgi.getElement("email")->getValue()+"'")||query_registerdata(database,&registerdata,"email = '"+cgi.getElement("email")->getValue()+"'")){
if(query_userdata(database,&user,"email = '"+email+"'")||query_registerdata(database,&registerdata,"email = '"+email+"'")){
errcode = "你使用的邮箱已经注册过账号了。";error=true;
}
if(query_userdata(database,&user,"charid = '"+cgi.getElement("cid")->getValue()+"'")||query_registerdata(database,&registerdata,"charid = '"+cgi.getElement("cid")->getValue()+"'")){
if(query_userdata(database,&user,"charid = '"+cid+"'")||query_registerdata(database,&registerdata,"charid = '"+cid+"'")){
errcode = "账户名已经被注册了。";error=true;
}
if(query_registerdata(database,&registerdata,"charid = '"+cgi.getElement("cid")->getValue()+"'")&&strcmp(registerdata.email,cgi.getElement("email")->getValue().c_str())==0){
if(query_registerdata(database,&registerdata,"charid = '"+cid+"'")&&strcmp(registerdata.email,email.c_str())==0){
error=false;rereg = true;
}
if(error){
@@ -115,18 +118,18 @@ int main(){
}
std::string ip = getenv("HTTP_X_FORWARDED_FOR");
unsigned long rn = dis(gen);
unsigned long registerkey = hasher(ip+cgi.getElement("cid")->getValue()+std::to_string(rn));
unsigned long registerkey = hasher(ip+cid+std::to_string(rn));
if(!rereg){
change_mysql(database,"INSERT INTO registerdata (charid,name,email,pswd,registerkey) VALUE ('"+cgi.getElement("cid")->getValue()+"','"+cgi.getElement("name")->getValue()+"','"+cgi.getElement("email")->getValue()+"',"+std::to_string(hasher(cgi.getElement("pswd")->getValue()))+","+std::to_string(rn)+")");
change_mysql(database,"INSERT INTO registerdata (charid,name,email,pswd,registerkey) VALUE ('"+cid+"','"+name+"','"+email+"',"+std::to_string(hasher(cgi.getElement("pswd")->getValue()))+","+std::to_string(rn)+")");
}else{
change_mysql(database,"UPDATE registerdata SET registerkey = "+std::to_string(rn)+" WHERE charid = '"+cgi.getElement("cid")->getValue()+"'");
change_mysql(database,"UPDATE registerdata SET registerkey = "+std::to_string(rn)+" WHERE charid = '"+cid+"'");
std::fstream fio;
fio.open(webroot+"/../videodata/tmp/"+cgi.getElement("cid")->getValue()+"-jobid",std::ios::in);
fio.open(webroot+"/../videodata/tmp/"+cid+"-jobid",std::ios::in);
std::string jobid;
fio >> jobid;
fio.close();
cancelScheduledJob(jobid);
remove((webroot+"/../videodata/tmp/"+cgi.getElement("cid")->getValue()+"-jobid").c_str());
remove((webroot+"/../videodata/tmp/"+cid+"-jobid").c_str());
}
CURL *curl;
CURLcode res = CURLE_OK;
@@ -141,10 +144,10 @@ int main(){
curl_easy_setopt(curl, CURLOPT_USERNAME, "[email protected]");
curl_easy_setopt(curl, CURLOPT_PASSWORD, MAIL_PSWD);
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, "[email protected]");
recipients = curl_slist_append(recipients, cgi.getElement("email")->getValue().c_str());
recipients = curl_slist_append(recipients, email.c_str());
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
std::string email_headers =
"To: "+cgi.getElement("email")->getValue()+"\r\n"
"To: "+email+"\r\n"
"From: [email protected]\r\n"
"Subject: Mail verify link.\r\n"
"Date: " + []() {
@@ -162,7 +165,7 @@ int main(){
return std::string(buf);
}() + ">\r\n"
"\r\n";
std::string email_body = "你的账户验证链接为:https://www.adashima.fun/verify/?account="+cgi.getElement("cid")->getValue()+"&key="+std::to_string(registerkey)+"\r\n链接有效期为10分钟,请尽快点击链接完成注册。\r\n";
std::string email_body = "你的账户验证链接为:https://www.adashima.fun/verify/?account="+cid+"&key="+std::to_string(registerkey)+"\r\n链接有效期为10分钟,请尽快点击链接完成注册。\r\n";
std::string email_content = email_headers + email_body;
UploadData upload_data;
upload_data.data = email_content.c_str();
@@ -172,9 +175,9 @@ int main(){
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_data);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
res = curl_easy_perform(curl);
std::string jobid = scheduleCommand("DELETE FROM registerdata WHERE charid = '"+cgi.getElement("cid")->getValue()+"'");
std::string jobid = scheduleCommand("DELETE FROM registerdata WHERE charid = '"+cid+"'");
std::fstream fio;
fio.open(webroot+"/../videodata/tmp/"+cgi.getElement("cid")->getValue()+"-jobid",std::ios::out);
fio.open(webroot+"/../videodata/tmp/"+cid+"-jobid",std::ios::out);
fio << jobid;
fio.close();
if(res == CURLE_OK) {
+50 -45
View File
@@ -53,6 +53,7 @@ int main(){
}
fio.open(webroot+"/../videodata/tmp/video.lock",std::ios::in);
unsigned long processing_v = 0;
std::string processing_v_s = std::to_string(processing_v);
if(fio.is_open()){
fio >> processing_v;
fio.close();
@@ -78,6 +79,7 @@ int main(){
return 0;
}
if(!cgi.getElement("title")->getValue().empty()){
std::string title = cgi.getElement("title")->getValue();
if(processing_v!=0){
std::cout << "Status: 503 Service Unavailable\r\n" << std::endl;
return 0;
@@ -89,11 +91,15 @@ int main(){
description = cgi.getElement("description")->getValue();
}
size_t pos = 0;
if(title.find_first_of("'\\")!=std::string::npos||description.find_first_of("'\\")!=std::string::npos){
std::cout << "Status: 502 Bad request\r\n" << std::endl;
return 0;
}
while ((pos = description.find("\n", pos)) != std::string::npos) {
description.replace(pos, 1, "<br>");
pos += 4;
}
if(cgi.getElement("title")->getValue().size()>256||description.size()>1024){
if(title.size()>256||description.size()>1024){
std::cout << "Status: 502 Bad request\r\n"
<< "Content-type:text/html\r\n\r\n"
<< "<html>\n"
@@ -109,28 +115,28 @@ int main(){
return 0;
}
unsigned long vid = latest_vid(database)+1;
change_mysql(database,"INSERT INTO processingvideo (title,description,uploader) VALUE ('"+cgi.getElement("title")->getValue()+"','"+description+"',"+s_id+")");
change_mysql(database,"INSERT INTO processingvideo (title,description,uploader) VALUE ('"+title+"','"+description+"',"+s_id+")");
fio.open(webroot+"/../videodata/tmp/video.lock",std::ios::out);
fio << vid;
fio.close();
if(cgi.getElement("totalSize")->getValue().find_first_not_of("0123456789")!=std::string::npos||cgi.getElement("totalChunks")->getValue().find_first_not_of("0123456789")!=std::string::npos){
if(cgi.getElement("videoSize")->getValue().find_first_not_of("0123456789")!=std::string::npos||cgi.getElement("chunkCount")->getValue().find_first_not_of("0123456789")!=std::string::npos){
std::cout << "Status: 403 Forbidden\r\n" << std::endl;
return 0;
}
mkdir((webroot+"/../videodata/tmp/video/"+std::to_string(vid)).c_str(),0744);
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(vid)+"/totalSize",std::ios::out);
fio << cgi.getElement("totalSize")->getValue();
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(vid)+"/videoSize",std::ios::out);
fio << cgi.getElement("videoSize")->getValue();
fio.close();
if(cgi.getElement("totalChunks")->getValue()!="1"){
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(vid)+"/totalChunks",std::ios::out);
fio << cgi.getElement("totalChunks")->getValue();
if(cgi.getElement("chunkCount")->getValue()!="1"){
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(vid)+"/chunkCount",std::ios::out);
fio << cgi.getElement("chunkCount")->getValue();
fio.close();
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(vid)+"/restChunks",std::ios::out);
fio << cgi.getElement("totalChunks")->getValue();
fio << cgi.getElement("chunkCount")->getValue();
fio.close();
}
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(vid)+"/cover-original",std::ios::out);
cgicc::const_file_iterator file = cgi.getFile("thumbnail");
cgicc::const_file_iterator file = cgi.getFile("cover");
file->writeToStream(fio);
fio.close();
system(("ffmpeg -i "+webroot+"/../videodata/tmp/video/"+std::to_string(vid)+"/cover-original -vf \"scale=1920:1080\" "+webroot+"/../videodata/tmp/video/"+std::to_string(vid)+"/cover.jpeg").c_str());
@@ -150,80 +156,79 @@ int main(){
std::cout << "Status: 403 Forbidden\r\n" << std::endl;
return 0;
}
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/totalChunks",std::ios::in);
fio.open(webroot+"/../videodata/tmp/video/"+processing_v_s+"/chunkCount",std::ios::in);
if(fio.is_open()){
unsigned long totalchunks;unsigned long restchunks;
fio >> totalchunks;
unsigned long chunkCount;unsigned long restchunks;
fio >> chunkCount;
fio.close();
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/restChunks",std::ios::in);
fio.open(webroot+"/../videodata/tmp/video/"+processing_v_s+"/restChunks",std::ios::in);
fio >> restchunks;
fio.close();
if(std::stoul(cgi.getElement("chunk")->getValue())!=totalchunks-restchunks){
if(cgi.getElement("chunkIndex")->getValue().find_first_not_of("0123456789")!=std::string::npos||cgi.getElement("chunkIndex")->getValue()==""||std::stoul(cgi.getElement("chunkIndex")->getValue())!=chunkCount-restchunks){
std::cout << "Status: 403 Forbidden\r\n" << std::endl;
return 0;
}else{
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/video-original-"+cgi.getElement("chunk")->getValue(),std::ios::out);
cgicc::const_file_iterator file = cgi.getFile("video");
file->writeToStream(fio);
fio.close();
}
fio.open(webroot+"/../videodata/tmp/video/"+processing_v_s+"/video-original-"+cgi.getElement("chunkIndex")->getValue(),std::ios::out);
cgicc::const_file_iterator file = cgi.getFile("video");
file->writeToStream(fio);
fio.close();
restchunks--;
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/restChunks",std::ios::out);
fio.open(webroot+"/../videodata/tmp/video/"+processing_v_s+"/restChunks",std::ios::out);
fio << restchunks;
fio.close();
if(restchunks!=0){
std::cout << "Status: 200 OK\r\n" << std::endl;
return 0;
}
system(("cd "+webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+" && for i in $(seq 0 "+std::to_string(totalchunks-1)+"); do cat \"video-original-$i\" >> video-original; done").c_str());
system(("rm -rf "+webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/video-original-*").c_str());
system(("cd "+webroot+"/../videodata/tmp/video/"+processing_v_s+" && for i in $(seq 0 "+std::to_string(chunkCount-1)+"); do cat \"video-original-$i\" >> video-original; done").c_str());
system(("rm -rf "+webroot+"/../videodata/tmp/video/"+processing_v_s+"/video-original-*").c_str());
}else{
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/video-original",std::ios::out);
fio.open(webroot+"/../videodata/tmp/video/"+processing_v_s+"/video-original",std::ios::out);
cgicc::const_file_iterator file = cgi.getFile("video");
file->writeToStream(fio);
fio.close();
}
unsigned long totalsize;
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/totalSize",std::ios::in);
fio >> totalsize;
unsigned long videoSize;
fio.open(webroot+"/../videodata/tmp/video/"+processing_v_s+"/videoSize",std::ios::in);
fio >> videoSize;
fio.close();
struct stat stat_buf;
int rc = stat((webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/video-original").c_str(), &stat_buf);
int rc = stat((webroot+"/../videodata/tmp/video/"+processing_v_s+"/video-original").c_str(), &stat_buf);
unsigned long filesize = stat_buf.st_size;
if(filesize!=totalsize){
if(filesize!=videoSize){
std::cout << "Status: 502 Bad request\r\n" << std::endl;
remove((webroot+"/../videodata/tmp/video.lock").c_str());
change_mysql(database,"DELETE FROM processingvideo");
system(("rm -rf "+webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)).c_str());
system(("rm -rf "+webroot+"/../videodata/tmp/video/"+processing_v_s).c_str());
return 0;
}
fio.open(webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/process.sh",std::ios::out);
fio << "cd "+webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"\n";
fio << "ffmpeg -i video-original -filter_complex \"[0:v]split=5[v1][v2][v3][v4][vs];[v1]scale=-2:360[v360];[v2]scale=-2:480[v480];[v3]scale=-2:720[v720];[v4]scale=-2:1080[v1080]\" -map \"[v360]\" -map 0:a -c:v:0 h264_nvenc -crf 22 -b:v:0 800k -maxrate:0 856k -bufsize:0 1200k -c:a:0 aac -b:a:0 32k -map \"[v480]\" -map 0:a -c:v:1 h264_nvenc -crf 21 -b:v:1 1400k -maxrate:1 1498k -bufsize:1 2100k -c:a:1 aac -b:a:1 64k -map \"[v720]\" -map 0:a -c:v:2 h264_nvenc -crf 20 -b:v:2 2800k -maxrate:2 2996k -bufsize:2 4200k -c:a:2 aac -b:a:2 128k -map \"[v1080]\" -map 0:a -c:v:3 h264_nvenc -crf 19 -b:v:3 4000k -maxrate:3 5000k -bufsize:3 6000k -c:a:3 aac -b:a:3 256k -map \"[vs]\" -map 0:a -c:v:4 h264_nvenc -crf 18 -b:v:4 8000k -maxrate:4 10000k -bufsize:4 12000k -c:a:4 aac -b:a:4 320k -f hls -var_stream_map \"v:0,a:0 v:1,a:1 v:2,a:2 v:3,a:3 v:4,a:4\" -master_pl_name master.m3u8 -hls_time 10 -hls_list_size 0 -hls_segment_filename \"output_%v_%06d\\.ts\" output_%v.m3u8\n";
fio << "sed -i 's/output_/\\/API\\/media?v="+std::to_string(processing_v)+"\\&type=m3u8\\&res=/g' master.m3u8\n";
fio.open(webroot+"/../videodata/tmp/video/"+processing_v_s+"/process.sh",std::ios::out);
fio << "cd "+webroot+"/../videodata/tmp/video/"+processing_v_s+"\n";
fio << "ffmpeg -i video-original -filter_complex \"[0:v]split=5[v1][v2][v3][v4][vs];[v1]scale=-2:360[v360];[v2]scale=-2:480[v480];[v3]scale=-2:720[v720];[v4]scale=-2:1080[v1080]\" -map \"[v360]\" -map 0:a -c:v:0 h264_nvenc -crf 22 -b:v:0 800k -maxrate:0 856k -bufsize:0 1200k -c:a:0 aac -b:a:0 32k -map \"[v480]\" -map 0:a -c:v:1 h264_nvenc -crf 21 -b:v:1 1400k -maxrate:1 1498k -bufsize:1 2100k -c:a:1 aac -b:a:1 64k -map \"[v720]\" -map 0:a -c:v:2 h264_nvenc -crf 20 -b:v:2 2800k -maxrate:2 2996k -bufsize:2 4200k -c:a:2 aac -b:a:2 128k -map \"[v1080]\" -map 0:a -c:v:3 h264_nvenc -crf 19 -b:v:3 4000k -maxrate:3 5000k -bufsize:3 6000k -c:a:3 aac -b:a:3 256k -map \"[vs]\" -map 0:a -c:v:4 h264_nvenc -crf 18 -b:v:4 8000k -maxrate:4 10000k -bufsize:4 12000k -c:a:4 aac -b:a:4 320k -f hls -var_stream_map \"v:0,a:0 v:1,a:1 v:2,a:2 v:3,a:3 v:4,a:4\" -master_pl_name master.m3u8 -hls_time 10 -hls_list_size 0 -hls_segment_filename \"output_%v_%06d.ts\" output_%v.m3u8\n";
fio << "sed -i 's/output_/\\/API\\/media\\.cgi?v="+processing_v_s+"\\&type=m3u8\\&res=/g' master.m3u8\n";
fio << "sed -i 's/\\.m3u8//g' master.m3u8\n";
fio << "mv master.m3u8 "+webroot+"/m3u8/"+std::to_string(processing_v)+".m3u8\n";
fio << "sed -i 's/output_0_/\\/API\\/media.cgi?v="+std::to_string(processing_v)+"\\&type=ts\\&res=0\\&id=/g' output_0.m3u8\n";
fio << "mv master.m3u8 "+webroot+"/m3u8/"+processing_v_s+".m3u8\n";
fio << "sed -i 's/output_0_/\\/API\\/media\\.cgi?v="+processing_v_s+"\\&type=ts\\&res=0\\&id=/g' output_0.m3u8\n";
fio << "sed -i 's/\\.ts//g' output_0.m3u8\n";
fio << "sed -i 's/output_1_/\\/API\\/media.cgi?v="+std::to_string(processing_v)+"\\&type=ts\\&res=1\\&id=/g' output_1.m3u8\n";
fio << "sed -i 's/output_1_/\\/API\\/media\\.cgi?v="+processing_v_s+"\\&type=ts\\&res=1\\&id=/g' output_1.m3u8\n";
fio << "sed -i 's/\\.ts//g' output_1.m3u8\n";
fio << "sed -i 's/output_2_/\\/API\\/media.cgi?v="+std::to_string(processing_v)+"\\&type=ts\\&res=2\\&id=/g' output_2.m3u8\n";
fio << "sed -i 's/output_2_/\\/API\\/media\\.cgi?v="+processing_v_s+"\\&type=ts\\&res=2\\&id=/g' output_2.m3u8\n";
fio << "sed -i 's/\\.ts//g' output_2.m3u8\n";
fio << "sed -i 's/output_3_/\\/API\\/media.cgi?v="+std::to_string(processing_v)+"\\&type=ts\\&res=3\\&id=/g' output_3.m3u8\n";
fio << "sed -i 's/output_3_/\\/API\\/media\\.cgi?v="+processing_v_s+"\\&type=ts\\&res=3\\&id=/g' output_3.m3u8\n";
fio << "sed -i 's/\\.ts//g' output_3.m3u8\n";
fio << "sed -i 's/output_4_/\\/API\\/media.cgi?v="+std::to_string(processing_v)+"\\&type=ts\\&res=4\\&id=/g' output_4.m3u8\n";
fio << "sed -i 's/output_4_/\\/API\\/media\\.cgi?v="+processing_v_s+"\\&type=ts\\&res=4\\&id=/g' output_4.m3u8\n";
fio << "sed -i 's/\\.ts//g' output_4.m3u8\n";
fio << "rename 's/output/"+std::to_string(processing_v)+"/' *\n";
fio << "rename 's/output/"+processing_v_s+"/' *\n";
fio << "mv *.m3u8 "+webroot+"/../videodata/m3u8/\n";
fio << "mv *.ts "+webroot+"/../videodata/ts/\n";
fio << "mv cover.jpeg "+webroot+"/../videodata/cover/"+std::to_string(processing_v)+"\n";
fio << "mv cover.jpeg "+webroot+"/../videodata/cover/"+processing_v_s+".jpeg\n";
fio << "rm -f "+webroot+"/../videodata/tmp/video.lock\n";
fio << "rm -rf "+webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"\n";
fio << "rm -rf "+webroot+"/../videodata/tmp/video/"+processing_v_s+"\n";
fio << "mysql --defaults-file=/etc/mysql/www-data.cnf -e 'INSERT INTO videodata (title,description,uploader) SELECT title,description,uploader FROM processingvideo'\n";
fio << "mysql --defaults-file=/etc/mysql/www-data.cnf -e 'DELETE FROM processingvideo;'\n";
fio.close();
system(("chmod +x "+webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/process.sh").c_str());
system(("nohup "+webroot+"/../videodata/tmp/video/"+std::to_string(processing_v)+"/process.sh > /dev/null 2>&1 &").c_str());
system(("chmod +x "+webroot+"/../videodata/tmp/video/"+processing_v_s+"/process.sh").c_str());
system(("nohup "+webroot+"/../videodata/tmp/video/"+processing_v_s+"/process.sh > /dev/null 2>&1 &").c_str());
std::cout << "Status: 200 OK\r\n" << std::endl;
return 0;
}
+12 -10
View File
@@ -1,14 +1,16 @@
all:
g++ -o ../video/index.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ index.cpp -lcgicc -lmysqlpp
g++ -o ../video/login/index.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ login/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/register/index.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ register/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/API/login.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ API/login.cpp -lcgicc -lmysqlpp
g++ -o ../video/API/register.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ API/register.cpp -lcgicc -lmysqlpp -lcurl
g++ -o ../video/verify/index.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ verify/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/upload/index.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ upload/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/API/upload.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ API/upload.cpp -lcgicc -lmysqlpp
g++ -o ../video/API/media.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ API/media.cpp -lcgicc -lmysqlpp
g++ -o ../video/video/index.cgi -I/data-12T/Web/video-cpp/include/ -I/usr/include/mariadb/ video/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/index.cgi -I./include/ -I/usr/include/mariadb/ index.cpp -lcgicc -lmysqlpp
g++ -o ../video/login/index.cgi -I./include/ -I/usr/include/mariadb/ login/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/register/index.cgi -I./include/ -I/usr/include/mariadb/ register/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/API/login.cgi -I./include/ -I/usr/include/mariadb/ API/login.cpp -lcgicc -lmysqlpp
g++ -o ../video/API/register.cgi -I./include/ -I/usr/include/mariadb/ API/register.cpp -lcgicc -lmysqlpp -lcurl
g++ -o ../video/verify/index.cgi -I./include/ -I/usr/include/mariadb/ verify/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/upload/index.cgi -I./include/ -I/usr/include/mariadb/ upload/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/API/upload.cgi -I./include/ -I/usr/include/mariadb/ API/upload.cpp -lcgicc -lmysqlpp
g++ -o ../video/API/media.cgi -I./include/ -I/usr/include/mariadb/ API/media.cpp -lcgicc -lmysqlpp
g++ -o ../video/video/index.cgi -I./include/ -I/usr/include/mariadb/ video/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/collection/index.cgi -I./include/ -I/usr/include/mariadb/ collection/index.cpp -lcgicc -lmysqlpp
g++ -o ../video/API/collection.cgi -I./include/ -I/usr/include/mariadb/ API/collection.cpp -lcgicc -lmysqlpp
chown www-data:www-data -R ../video
chmod 744 -R ../video
chown www-data:www-data -R ../videodata
+454
View File
@@ -0,0 +1,454 @@
#include <mysql.hpp>
#include <database.hpp>
#include <html5.hpp>
#include <string>
#include <cgicc/Cgicc.h>
#include <iostream>
bool login=false;
bool member=false;
int main(){
mysqlpp::Connection database;
userdata user;
cgicc::Cgicc cgi;
std::string s_id = get_cookie(cgi,"id");
std::string s_loginkey = get_cookie(cgi,"loginkey");
if(s_id==""||s_id.find_first_not_of("0123456789")!=std::string::npos||std::stoul(s_id)>UINT64_MAX){
s_id="";
}
if(s_loginkey==""||s_loginkey.find_first_not_of("0123456789")!=std::string::npos||std::stoul(s_loginkey)>UINT64_MAX){
s_loginkey="";
}
if(!connect_mysql(&database)){
std::cout << "Content-type:text/html\r\n\r\n"
<< "<html>\n"
<< "<head>\n"
<< "<meta charset=\"utf-8\">\n"
<< "<title>出现错误!</title>\n"
<< "</head>\n"
<< "<body>\n"
<< "数据库连接失败,请检查服务器状态!\n"
<< "</body>\n"
<< "</html>\n";
return 0;
}
if(s_id!=""&&query_userdata(database,&user,"id = "+s_id)){
if(s_loginkey!=""&&user.loginkey==std::stoul(s_loginkey)){
login=true;
}
if(user.status=='m'){
member=true;
}
if(!login&&member){
member=false;
}
}
if(login&&member){
std::vector<collectiondata> cd;
std::vector<videodata> vd;
get_collections(database,&cd,"uploader = "+s_id);
get_video_list(database,&vd,"uploader = "+s_id);
std::cout << "Content-type:text/html\r\n\r\n"
<< "<!DOCTYPE html>\n"
<< "<html lang=\"zh-CN\">\n"
<< "<head>\n"
<< "<meta charset=\"UTF-8\">\n"
<< "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
<< "<title>合集管理 - 🌸安岛百合视频站🌸</title>\n"
<< "<style>\n"
<< "* { margin: 0; padding: 0; box-sizing: border-box; }\n"
<< "body { \n"
<< " font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; \n"
<< " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n"
<< " min-height: 100vh;\n"
<< " color: #333;\n"
<< " line-height: 1.6;\n"
<< "}\n"
<< ".container { \n"
<< " max-width: 1200px; \n"
<< " margin: 0 auto; \n"
<< " padding: 20px; \n"
<< "}\n"
<< ".header { \n"
<< " text-align: center; \n"
<< " margin-bottom: 40px; \n"
<< " color: white;\n"
<< " text-shadow: 0 2px 4px rgba(0,0,0,0.3);\n"
<< "}\n"
<< ".header h1 { \n"
<< " font-size: 3rem; \n"
<< " margin-bottom: 10px; \n"
<< " font-weight: 300;\n"
<< "}\n"
<< ".card {\n"
<< " background: white;\n"
<< " padding: 30px;\n"
<< " border-radius: 15px;\n"
<< " box-shadow: 0 10px 30px rgba(0,0,0,0.2);\n"
<< " margin-bottom: 30px;\n"
<< "}\n"
<< ".card h2 {\n"
<< " color: #667eea;\n"
<< " font-size: 1.8rem;\n"
<< " margin-bottom: 20px;\n"
<< " font-weight: 500;\n"
<< "}\n"
<< ".form-group {\n"
<< " margin-bottom: 20px;\n"
<< "}\n"
<< ".form-group label {\n"
<< " display: block;\n"
<< " margin-bottom: 8px;\n"
<< " font-weight: 500;\n"
<< " color: #4a5568;\n"
<< "}\n"
<< ".form-input {\n"
<< " width: 100%;\n"
<< " padding: 12px 16px;\n"
<< " border: 2px solid #e2e8f0;\n"
<< " border-radius: 8px;\n"
<< " font-size: 1rem;\n"
<< " transition: all 0.3s ease;\n"
<< "}\n"
<< ".form-input:focus {\n"
<< " outline: none;\n"
<< " border-color: #667eea;\n"
<< " box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);\n"
<< "}\n"
<< ".form-select {\n"
<< " width: 100%;\n"
<< " padding: 12px 16px;\n"
<< " border: 2px solid #e2e8f0;\n"
<< " border-radius: 8px;\n"
<< " font-size: 1rem;\n"
<< " background: white;\n"
<< " cursor: pointer;\n"
<< "}\n"
<< ".form-select:focus {\n"
<< " outline: none;\n"
<< " border-color: #667eea;\n"
<< " box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);\n"
<< "}\n"
<< ".btn {\n"
<< " padding: 12px 24px;\n"
<< " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n"
<< " color: white;\n"
<< " border: none;\n"
<< " border-radius: 8px;\n"
<< " font-size: 1rem;\n"
<< " font-weight: 500;\n"
<< " cursor: pointer;\n"
<< " transition: all 0.3s ease;\n"
<< "}\n"
<< ".btn:hover {\n"
<< " transform: translateY(-2px);\n"
<< " box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);\n"
<< "}\n"
<< ".btn-secondary {\n"
<< " background: #718096;\n"
<< "}\n"
<< ".btn-secondary:hover {\n"
<< " box-shadow: 0 5px 15px rgba(113, 128, 150, 0.4);\n"
<< "}\n"
<< ".btn-group {\n"
<< " display: flex;\n"
<< " gap: 10px;\n"
<< " margin-top: 20px;\n"
<< "}\n"
<< ".collections-grid {\n"
<< " display: grid;\n"
<< " grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));\n"
<< " gap: 20px;\n"
<< " margin-top: 20px;\n"
<< "}\n"
<< ".collection-card {\n"
<< " background: white;\n"
<< " border-radius: 12px;\n"
<< " padding: 20px;\n"
<< " box-shadow: 0 4px 15px rgba(0,0,0,0.1);\n"
<< " transition: all 0.3s ease;\n"
<< " border-left: 4px solid #667eea;\n"
<< "}\n"
<< ".collection-card:hover {\n"
<< " transform: translateY(-3px);\n"
<< " box-shadow: 0 8px 25px rgba(0,0,0,0.15);\n"
<< "}\n"
<< ".collection-title {\n"
<< " font-size: 1.3rem;\n"
<< " font-weight: 600;\n"
<< " color: #2d3748;\n"
<< " margin-bottom: 10px;\n"
<< "}\n"
<< ".collection-info {\n"
<< " color: #718096;\n"
<< " font-size: 0.9rem;\n"
<< " margin-bottom: 15px;\n"
<< "}\n"
<< ".collection-actions {\n"
<< " display: flex;\n"
<< " gap: 10px;\n"
<< "}\n"
<< ".status-message {\n"
<< " padding: 12px 16px;\n"
<< " border-radius: 8px;\n"
<< " margin: 15px 0;\n"
<< " text-align: center;\n"
<< " display: none;\n"
<< "}\n"
<< ".status-success {\n"
<< " background: #c6f6d5;\n"
<< " color: #22543d;\n"
<< " border: 1px solid #9ae6b4;\n"
<< "}\n"
<< ".status-error {\n"
<< " background: #fed7d7;\n"
<< " color: #742a2a;\n"
<< " border: 1px solid #feb2b2;\n"
<< "}\n"
<< ".back-link {\n"
<< " text-align: center;\n"
<< " margin-top: 30px;\n"
<< "}\n"
<< ".back-link a {\n"
<< " color: white;\n"
<< " text-decoration: none;\n"
<< " font-size: 1.1rem;\n"
<< " padding: 10px 20px;\n"
<< " background: rgba(255,255,255,0.2);\n"
<< " border-radius: 25px;\n"
<< " transition: all 0.3s ease;\n"
<< "}\n"
<< ".back-link a:hover {\n"
<< " background: rgba(255,255,255,0.3);\n"
<< " transform: translateY(-2px);\n"
<< "}\n"
<< "@media (max-width: 768px) {\n"
<< " .collections-grid {\n"
<< " grid-template-columns: 1fr;\n"
<< " }\n"
<< " .btn-group {\n"
<< " flex-direction: column;\n"
<< " }\n"
<< "}\n"
<< "</style>\n"
<< "</head>\n"
<< "<body>\n"
<< "<div class=\"container\">\n"
<< " <div class=\"header\">\n"
<< " <h1>🌸合集管理🌸</h1>\n"
<< " <p>创建和管理您的视频合集</p>\n"
<< " </div>\n"
<< " \n"
<< " <div id=\"statusMessage\" class=\"status-message\"></div>\n"
<< " \n"
<< " <!-- 创建新合集表单 -->\n"
<< " <div class=\"card\">\n"
<< " <h2>创建新合集</h2>\n"
<< " <form id=\"createCollectionForm\">\n"
<< " <div class=\"form-group\">\n"
<< " <label for=\"collectionTitle\">合集标题:</label>\n"
<< " <input type=\"text\" id=\"collectionTitle\" name=\"title\" class=\"form-input\" placeholder=\"请输入合集标题\" required>\n"
<< " </div>\n"
<< " <input type=\"hidden\" name=\"action\" value=\"create\">\n"
<< " <button type=\"submit\" class=\"btn\">创建合集</button>\n"
<< " </form>\n"
<< " </div>\n"
<< " \n"
<< " <!-- 添加视频到合集表单 -->\n"
<< " <div class=\"card\">\n"
<< " <h2>添加视频到合集</h2>\n"
<< " <form id=\"addVideoForm\">\n"
<< " <div class=\"form-group\">\n"
<< " <label for=\"targetCollection\">选择合集:</label>\n"
<< " <select id=\"targetCollection\" name=\"collection_id\" class=\"form-select\" required>\n"
<< " <option value=\"\">请选择合集</option>\n";
for (const auto& collection : cd) {
std::cout << "<option value=\"" << collection.id << "\">" << collection.title << "</option>\n";
}
std::cout << " </select>\n"
<< " </div>\n"
<< " <div class=\"form-group\">\n"
<< " <label for=\"targetVideo\">选择视频:</label>\n"
<< " <select id=\"targetVideo\" name=\"video_id\" class=\"form-select\" required>\n"
<< " <option value=\"\">请选择视频</option>\n";
for (const auto& video : vd) {
std::cout << "<option value=\"" << video.id << "\">" << video.title << "</option>\n";
}
std::cout << " </select>\n"
<< " </div>\n"
<< " <input type=\"hidden\" name=\"action\" value=\"add_video\">\n"
<< " <button type=\"submit\" class=\"btn\">添加视频</button>\n"
<< " </form>\n"
<< " </div>\n"
<< " \n"
<< " <!-- 现有合集列表 -->\n"
<< " <div class=\"card\">\n"
<< " <h2>现有合集</h2>\n"
<< " <div class=\"collections-grid\" id=\"collectionsList\">\n";
for (const auto& collection : cd) {
std::cout << "<div class=\"collection-card\">\n"
<< " <h3 class=\"collection-title\">" << collection.title << "</h3>\n"
<< " <div class=\"collection-info\">\n"
<< " 视频数量: " << collection.video_count << "\n"
<< " </div>\n"
<< " <div class=\"collection-actions\">\n"
<< " <button class=\"btn btn-secondary\" onclick=\"viewCollection(" << collection.id << ")\">查看</button>\n"
<< " <button class=\"btn btn-secondary\" onclick=\"editCollection(" << collection.id << ")\">编辑</button>\n"
<< " <button class=\"btn btn-secondary\" onclick=\"deleteCollection(" << collection.id << ")\">删除</button>\n"
<< " </div>\n"
<< "</div>\n";
}
std::cout << " </div>\n"
<< " </div>\n"
<< " \n"
<< " <div class=\"back-link\">\n"
<< " <a href=\"/\">← 返回首页</a>\n"
<< " </div>\n"
<< "</div>\n"
<< "\n"
<< "<script>\n"
<< "// 创建合集表单提交\n"
<< "document.getElementById('createCollectionForm').addEventListener('submit', async function(e) {\n"
<< " e.preventDefault();\n"
<< " \n"
<< " const formData = new FormData(this);\n"
<< " \n"
<< " try {\n"
<< " const response = await fetch('/API/collection.cgi', {\n"
<< " method: 'POST',\n"
<< " body: formData\n"
<< " });\n"
<< " \n"
<< " if (response.ok) {\n"
<< " showStatus('合集创建成功!', 'success');\n"
<< " this.reset();\n"
<< " // 刷新页面以更新合集列表\n"
<< " setTimeout(() => location.reload(), 1500);\n"
<< " } else {\n"
<< " const errorText = await response.text();\n"
<< " showStatus('创建失败: ' + errorText, 'error');\n"
<< " }\n"
<< " } catch (error) {\n"
<< " showStatus('网络错误: ' + error.message, 'error');\n"
<< " }\n"
<< "});\n"
<< "\n"
<< "// 添加视频到合集表单提交\n"
<< "document.getElementById('addVideoForm').addEventListener('submit', async function(e) {\n"
<< " e.preventDefault();\n"
<< " \n"
<< " const collectionId = document.getElementById('targetCollection').value;\n"
<< " const videoId = document.getElementById('targetVideo').value;\n"
<< " \n"
<< " if (!collectionId || !videoId) {\n"
<< " showStatus('请选择合集和视频', 'error');\n"
<< " return;\n"
<< " }\n"
<< " \n"
<< " const formData = new FormData(this);\n"
<< " \n"
<< " try {\n"
<< " const response = await fetch('/API/collection.cgi', {\n"
<< " method: 'POST',\n"
<< " body: formData\n"
<< " });\n"
<< " \n"
<< " if (response.ok) {\n"
<< " showStatus('视频添加成功!', 'success');\n"
<< " this.reset();\n"
<< " } else {\n"
<< " const errorText = await response.text();\n"
<< " showStatus('添加失败: ' + errorText, 'error');\n"
<< " }\n"
<< " } catch (error) {\n"
<< " showStatus('网络错误: ' + error.message, 'error');\n"
<< " }\n"
<< "});\n"
<< "\n"
<< "// 查看合集\n"
<< "function viewCollection(collectionId) {\n"
<< " window.open('/collection/?id=' + collectionId, '_blank');\n"
<< "}\n"
<< "\n"
<< "// 编辑合集\n"
<< "function editCollection(collectionId) {\n"
<< " const newTitle = prompt('请输入新的合集标题:');\n"
<< " if (newTitle && newTitle.trim() !== '') {\n"
<< " updateCollection(collectionId, newTitle.trim());\n"
<< " }\n"
<< "}\n"
<< "\n"
<< "// 删除合集\n"
<< "function deleteCollection(collectionId) {\n"
<< " if (confirm('确定要删除这个合集吗?此操作不可撤销。')) {\n"
<< " const formData = new FormData();\n"
<< " formData.append('action', 'delete');\n"
<< " formData.append('collection_id', collectionId);\n"
<< " \n"
<< " fetch('/API/collection.cgi', {\n"
<< " method: 'POST',\n"
<< " body: formData\n"
<< " })\n"
<< " .then(response => {\n"
<< " if (response.ok) {\n"
<< " showStatus('合集删除成功!', 'success');\n"
<< " setTimeout(() => location.reload(), 1500);\n"
<< " } else {\n"
<< " return response.text().then(errorText => {\n"
<< " showStatus('删除失败: ' + errorText, 'error');\n"
<< " });\n"
<< " }\n"
<< " })\n"
<< " .catch(error => {\n"
<< " showStatus('网络错误: ' + error.message, 'error');\n"
<< " });\n"
<< " }\n"
<< "}\n"
<< "\n"
<< "// 更新合集标题\n"
<< "async function updateCollection(collectionId, newTitle) {\n"
<< " const formData = new FormData();\n"
<< " formData.append('action', 'update');\n"
<< " formData.append('collection_id', collectionId);\n"
<< " formData.append('title', newTitle);\n"
<< " \n"
<< " try {\n"
<< " const response = await fetch('/API/collection.cgi', {\n"
<< " method: 'POST',\n"
<< " body: formData\n"
<< " });\n"
<< " \n"
<< " if (response.ok) {\n"
<< " showStatus('合集更新成功!', 'success');\n"
<< " setTimeout(() => location.reload(), 1500);\n"
<< " } else {\n"
<< " const errorText = await response.text();\n"
<< " showStatus('更新失败: ' + errorText, 'error');\n"
<< " }\n"
<< " } catch (error) {\n"
<< " showStatus('网络错误: ' + error.message, 'error');\n"
<< " }\n"
<< "}\n"
<< "\n"
<< "// 显示状态消息\n"
<< "function showStatus(message, type) {\n"
<< " const statusElement = document.getElementById('statusMessage');\n"
<< " statusElement.textContent = message;\n"
<< " statusElement.className = 'status-message status-' + type;\n"
<< " statusElement.style.display = 'block';\n"
<< " \n"
<< " // 3秒后自动隐藏\n"
<< " setTimeout(() => {\n"
<< " statusElement.style.display = 'none';\n"
<< " }, 3000);\n"
<< "}\n"
<< "</script>\n"
<< "</body>\n"
<< "</html>\n";
}else{
std::cout << "Status: 302 Found\r\n"
<< "Location: /\r\n" << std::endl;
}
return 0;
}
+13
View File
@@ -27,6 +27,7 @@ struct videodata {
unsigned long likes;
char status;
unsigned long uploader;
unsigned long collection;
};
struct processing_videodata {
@@ -36,4 +37,16 @@ struct processing_videodata {
unsigned long uploader;
};
struct collectiondata {
unsigned long id;
char title[256];
unsigned long uploader;
unsigned long video_count;
};
struct collectionlist {
unsigned long id;
unsigned long vid;
};
#endif
+82
View File
@@ -72,6 +72,7 @@ bool query_videodata(mysqlpp::Connection db,videodata* video,std::string mysql_r
video->likes=res[0][3];
strncpy(&video->status,res[0][4], sizeof(video->status));
video->uploader=res[0][5];
video->collection=res[0][6];
return true;
}catch (const mysqlpp::Exception& e) {
std::cerr << "Something wrong haappened.\n";
@@ -111,6 +112,20 @@ unsigned long latest_vid(mysqlpp::Connection db){
}
}
unsigned long latest_cid(mysqlpp::Connection db){
try{
mysqlpp::Query query = db.query("SELECT MAX(id) FROM collectiondata");
mysqlpp::StoreQueryResult res = query.store();
if (res[0][0]=="NULL"){
return 0;
}
return res[0][0];
}catch (const mysqlpp::Exception& e) {
std::cerr << "Something wrong haappened.\n";
return 0;
}
}
bool change_mysql(mysqlpp::Connection db,std::string change_sentence){
mysqlpp::Query query = db.query();
query << change_sentence;
@@ -121,4 +136,71 @@ bool change_mysql(mysqlpp::Connection db,std::string change_sentence){
}
}
bool get_video_list(mysqlpp::Connection db,std::vector<videodata>* vd,std::string mysql_rules){
try{
mysqlpp::Query query = db.query("SELECT * FROM videodata WHERE " + mysql_rules);
mysqlpp::StoreQueryResult res = query.store();
if (!res || res.num_rows() <= 0){
return false;
}
for(int i = 0;i<res.size();i++){
videodata video;
video.id=res[i][0];
strncpy(video.title,res[i][1], sizeof(video.title));
strncpy(video.description,res[i][2], sizeof(video.description));
video.likes=res[i][3];
strncpy(&video.status,res[i][4], sizeof(video.status));
video.uploader=res[i][5];
video.collection=res[i][6];
vd->push_back(video);
}
return true;
}catch (const mysqlpp::Exception& e) {
std::cerr << "Something wrong haappened.\n";
return false;
}
}
bool get_collections(mysqlpp::Connection db,std::vector<collectiondata>* cd,std::string mysql_rules){
try{
mysqlpp::Query query = db.query("SELECT * FROM collectiondata WHERE " + mysql_rules);
mysqlpp::StoreQueryResult res = query.store();
if (!res || res.num_rows() <= 0){
return false;
}
for(int i = 0;i<res.size();i++){
collectiondata c;
c.id=res[i][0];
strncpy(c.title,res[i][1], sizeof(c.title));
c.uploader=res[i][2];
c.video_count=res[i][3];
cd->push_back(c);
}
return true;
}catch (const mysqlpp::Exception& e) {
std::cerr << "Something wrong haappened.\n";
return false;
}
}
bool get_collection_list(mysqlpp::Connection db,std::vector<collectionlist>* cl,unsigned long cid){
try{
mysqlpp::Query query = db.query("SELECT * FROM collection_"+std::to_string(cid));
mysqlpp::StoreQueryResult res = query.store();
if (!res || res.num_rows() <= 0){
return false;
}
for(int i = 0;i<res.size();i++){
collectionlist c;
c.id=res[i][0];
c.vid=res[i][1];
cl->push_back(c);
}
return true;
}catch (const mysqlpp::Exception& e) {
std::cerr << "Something wrong haappened.\n";
return false;
}
}
#endif
+237 -20
View File
@@ -53,50 +53,267 @@ int main(){
}
if(login){
std::cout << "Content-type:text/html\r\n\r\n"
<< "<html>\n"
<< "<!DOCTYPE html>\n"
<< "<html lang=\"zh-CN\">\n"
<< "<head>\n"
<< "<meta charset=\"utf-8\">\n"
<< "<title>安岛百合视频站</title>\n"
<< "<meta charset=\"UTF-8\">\n"
<< "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
<< "<title>🌸安岛百合视频站🌸</title>\n"
<< "<style>\n"
<< "* { margin: 0; padding: 0; box-sizing: border-box; }\n"
<< "body { \n"
<< " font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; \n"
<< " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n"
<< " min-height: 100vh;\n"
<< " color: #333;\n"
<< " line-height: 1.6;\n"
<< "}\n"
<< ".container { \n"
<< " max-width: 1200px; \n"
<< " margin: 0 auto; \n"
<< " padding: 20px; \n"
<< "}\n"
<< ".header { \n"
<< " text-align: center; \n"
<< " margin-bottom: 40px; \n"
<< " color: white;\n"
<< " text-shadow: 0 2px 4px rgba(0,0,0,0.3);\n"
<< "}\n"
<< ".header h1 { \n"
<< " font-size: 3rem; \n"
<< " margin-bottom: 10px; \n"
<< " font-weight: 300;\n"
<< "}\n"
<< ".welcome-text {\n"
<< " font-size: 1.2rem;\n"
<< " opacity: 0.9;\n"
<< "}\n"
<< ".guest-badge {\n"
<< " background: rgba(255,255,255,0.2);\n"
<< " padding: 2px 8px;\n"
<< " border-radius: 12px;\n"
<< " font-size: 0.9rem;\n"
<< " margin-left: 8px;\n"
<< "}\n"
<< ".videos-grid {\n"
<< " display: grid;\n"
<< " grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));\n"
<< " gap: 20px;\n"
<< " margin-top: 30px;\n"
<< "}\n"
<< ".video-card {\n"
<< " background: white;\n"
<< " border-radius: 12px;\n"
<< " overflow: hidden;\n"
<< " box-shadow: 0 4px 15px rgba(0,0,0,0.1);\n"
<< " transition: all 0.3s ease;\n"
<< " cursor: pointer;\n"
<< " display: flex;\n"
<< " height: 140px;\n"
<< "}\n"
<< ".video-card:hover {\n"
<< " transform: translateY(-5px);\n"
<< " box-shadow: 0 8px 25px rgba(0,0,0,0.15);\n"
<< "}\n"
<< ".video-thumbnail {\n"
<< " width: 200px;\n"
<< " height: 140px;\n"
<< " background: #f8f9fa;\n"
<< " display: flex;\n"
<< " align-items: center;\n"
<< " justify-content: center;\n"
<< " flex-shrink: 0;\n"
<< "}\n"
<< ".video-thumbnail img {\n"
<< " width: 192px;\n"
<< " height: 108px;\n"
<< " object-fit: cover;\n"
<< " border-radius: 6px;\n"
<< "}\n"
<< ".video-info {\n"
<< " padding: 16px;\n"
<< " flex: 1;\n"
<< " display: flex;\n"
<< " flex-direction: column;\n"
<< " justify-content: space-between;\n"
<< "}\n"
<< ".video-title {\n"
<< " font-size: 16px;\n"
<< " font-weight: 600;\n"
<< " color: #2d3748;\n"
<< " line-height: 1.4;\n"
<< " margin-bottom: 8px;\n"
<< " display: -webkit-box;\n"
<< " -webkit-line-clamp: 2;\n"
<< " -webkit-box-orient: vertical;\n"
<< " overflow: hidden;\n"
<< "}\n"
<< ".video-description {\n"
<< " font-size: 14px;\n"
<< " color: #718096;\n"
<< " line-height: 1.4;\n"
<< " display: -webkit-box;\n"
<< " -webkit-line-clamp: 2;\n"
<< " -webkit-box-orient: vertical;\n"
<< " overflow: hidden;\n"
<< "}\n"
<< ".no-videos {\n"
<< " text-align: center;\n"
<< " color: white;\n"
<< " font-size: 1.1rem;\n"
<< " margin-top: 50px;\n"
<< "}\n"
<< "@media (max-width: 768px) {\n"
<< " .videos-grid {\n"
<< " grid-template-columns: 1fr;\n"
<< " }\n"
<< " .video-card {\n"
<< " flex-direction: column;\n"
<< " height: auto;\n"
<< " }\n"
<< " .video-thumbnail {\n"
<< " width: 100%;\n"
<< " height: 200px;\n"
<< " }\n"
<< " .video-thumbnail img {\n"
<< " width: 100%;\n"
<< " height: 180px;\n"
<< " }\n"
<< "}\n"
<< "</style>\n"
<< "</head>\n"
<< "<body>\n"
<< "<h1>欢迎来到安岛百合视频站!</h1>\n"
<< "欢迎回来," << user.name;
<< "<div class=\"container\">\n"
<< " <div class=\"header\">\n"
<< " <h1>🌸安岛百合视频站🌸</h1>\n"
<< " <p class=\"welcome-text\">欢迎回来,<strong>" << user.name << "</strong>";
if(!member){
std::cout << "(游客)";
std::cout << "<span class=\"guest-badge\">游客</span>";
}
std::cout << "</p>\n"
<< " </div>\n";
unsigned long latestvid = latest_vid(database);
unsigned short int retry_t = 0;
std::uniform_int_distribution<unsigned long> dis(0,latestvid);
bool hasVideos = false;
std::cout << "<div class=\"videos-grid\">\n";
unsigned long vlist[10];
for(int i = 0 ; i < 10 && i < latestvid ; i++){
retry:
if(retry_t>3){break;}
videodata vd;
unsigned long vid = dis(gen);
if(!query_videodata(database,&vd,"id = "+std::to_string(vid))||vd.status=='w'){
bool v_exist=false;
for(int j = 0;j<i;j++){
if(vlist[j]==vid){
v_exist=true;
}
}
if(!query_videodata(database,&vd,"id = "+std::to_string(vid))||vd.status=='w'||v_exist){
retry_t++;
goto retry;
}
vlist[i]=vid;
retry_t=0;
std::cout << "<div style=\"width: 500px; height: 120px; border: 1px solid #e0e0e0; font-family: Arial, sans-serif; overflow: hidden; display: flex; cursor: pointer;\" onclick=\"window.open('/video/?v="<<vid<<"', '_blank')\">\n"
<< "<div style=\"width: 200px; height: 120px; display: flex; justify-content: center; align-items: center; background: #f5f5f5;\"><img src=\"/API/media.cgi?type=cover&v="<<vid<<"\" style=\"width: 192px; height: 108px; object-fit: cover;\"></div>\n"
<< "<div style=\"flex: 1; padding: 12px; display: flex; flex-direction: column; justify-content: space-between;\"><h3 style=\"margin: 0; font-size: 16px; color: #333; line-height: 1.4; max-height: 2.8em; overflow: hidden;\">\n"
<< vd.title << "\n"
<< "</h3><p style=\"margin: 0; font-size: 14px; color: #666; line-height: 1.4; max-height: 2.8em; overflow: hidden;\">\n"
<< vd.description << "\n"
<< "</p></div></div>\n";
hasVideos = true;
std::cout << "<div class=\"video-card\" onclick=\"window.open('/video/?v="<<vid<<"', '_blank')\">\n"
<< " <div class=\"video-thumbnail\">\n"
<< " <img src=\"/API/media.cgi?type=cover&v="<<vid<<"\" alt=\"" << vd.title << "\">\n"
<< " </div>\n"
<< " <div class=\"video-info\">\n"
<< " <h3 class=\"video-title\">" << vd.title << "</h3>\n"
<< " <p class=\"video-description\">" << vd.description << "</p>\n"
<< " </div>\n"
<< "</div>\n";
}
std::cout << "</body>\n"
std::cout << "</div>\n";
if(!hasVideos){
std::cout << "<div class=\"no-videos\">\n"
<< " <p>暂无视频内容,请稍后再来</p>\n"
<< "</div>\n";
}
std::cout << "</div>\n"
<< "</body>\n"
<< "</html>\n";
}else{
std::cout << "Content-type:text/html\r\n\r\n"
<< "<html>\n"
<< "<!DOCTYPE html>\n"
<< "<html lang=\"zh-CN\">\n"
<< "<head>\n"
<< "<meta charset=\"utf-8\">\n"
<< "<title>安岛百合视频站</title>\n"
<< "<meta charset=\"UTF-8\">\n"
<< "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
<< "<title>🌸安岛百合视频站🌸</title>\n"
<< "<style>\n"
<< "* { margin: 0; padding: 0; box-sizing: border-box; }\n"
<< "body { \n"
<< " font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; \n"
<< " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n"
<< " min-height: 100vh;\n"
<< " display: flex;\n"
<< " align-items: center;\n"
<< " justify-content: center;\n"
<< " color: white;\n"
<< "}\n"
<< ".login-container {\n"
<< " text-align: center;\n"
<< " background: rgba(255,255,255,0.1);\n"
<< " backdrop-filter: blur(10px);\n"
<< " padding: 50px 40px;\n"
<< " border-radius: 20px;\n"
<< " box-shadow: 0 8px 32px rgba(0,0,0,0.2);\n"
<< " border: 1px solid rgba(255,255,255,0.2);\n"
<< "}\n"
<< ".login-container h1 {\n"
<< " font-size: 3rem;\n"
<< " margin-bottom: 20px;\n"
<< " font-weight: 300;\n"
<< "}\n"
<< ".login-container p {\n"
<< " font-size: 1.2rem;\n"
<< " margin-bottom: 30px;\n"
<< " opacity: 0.9;\n"
<< "}\n"
<< ".button-group {\n"
<< " display: flex;\n"
<< " gap: 20px;\n"
<< " justify-content: center;\n"
<< "}\n"
<< ".btn {\n"
<< " padding: 12px 30px;\n"
<< " border: none;\n"
<< " border-radius: 25px;\n"
<< " font-size: 1rem;\n"
<< " font-weight: 500;\n"
<< " cursor: pointer;\n"
<< " transition: all 0.3s ease;\n"
<< " text-decoration: none;\n"
<< " display: inline-block;\n"
<< "}\n"
<< ".btn-primary {\n"
<< " background: white;\n"
<< " color: #667eea;\n"
<< "}\n"
<< ".btn-secondary {\n"
<< " background: transparent;\n"
<< " color: white;\n"
<< " border: 2px solid white;\n"
<< "}\n"
<< ".btn:hover {\n"
<< " transform: translateY(-2px);\n"
<< " box-shadow: 0 5px 15px rgba(0,0,0,0.2);\n"
<< "}\n"
<< "</style>\n"
<< "</head>\n"
<< "<body>\n"
<< "<h1>欢迎来到安岛百合视频站!</h1>\n"
<< "请先登录! <a href=\"/login/\">登录</a> <a href=\"/register/\">注册</a><br>\n"
<< "<div class=\"login-container\">\n"
<< " <h1>🌸安岛百合视频站🌸</h1>\n"
<< " <p>欢迎来到安岛百合视频站</p>\n"
<< " <p>请先登录</p>\n"
<< " <div class=\"button-group\">\n"
<< " <a href=\"/login/\" class=\"btn btn-primary\">登录</a>\n"
<< " <a href=\"/register/\" class=\"btn btn-secondary\">注册</a>\n"
<< " </div>\n"
<< "</div>\n"
<< "</body>\n"
<< "</html>\n";
}
+110 -10
View File
@@ -49,19 +49,119 @@ int main(){
<< "Location: /\r\n" << std::endl;
}else{
std::cout << "Content-type:text/html\r\n\r\n"
<< "<html>\n"
<< "<!DOCTYPE html>\n"
<< "<html lang=\"zh-CN\">\n"
<< "<head>\n"
<< "<meta charset=\"utf-8\">\n"
<< "<title>安岛百合视频站</title>\n"
<< "<meta charset=\"UTF-8\">\n"
<< "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
<< "<title>登录 - 🌸安岛百合视频站🌸</title>\n"
<< "<style>\n"
<< "* { margin: 0; padding: 0; box-sizing: border-box; }\n"
<< "body { \n"
<< " font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; \n"
<< " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n"
<< " min-height: 100vh;\n"
<< " display: flex;\n"
<< " align-items: center;\n"
<< " justify-content: center;\n"
<< " color: #333;\n"
<< "}\n"
<< ".form-container {\n"
<< " background: white;\n"
<< " padding: 40px;\n"
<< " border-radius: 15px;\n"
<< " box-shadow: 0 10px 30px rgba(0,0,0,0.2);\n"
<< " width: 100%;\n"
<< " max-width: 450px;\n"
<< "}\n"
<< ".form-header {\n"
<< " text-align: center;\n"
<< " margin-bottom: 30px;\n"
<< "}\n"
<< ".form-header h1 {\n"
<< " color: #667eea;\n"
<< " font-size: 2.2rem;\n"
<< " font-weight: 300;\n"
<< " margin-bottom: 10px;\n"
<< "}\n"
<< ".form-group {\n"
<< " margin-bottom: 20px;\n"
<< "}\n"
<< ".form-group label {\n"
<< " display: block;\n"
<< " margin-bottom: 8px;\n"
<< " font-weight: 500;\n"
<< " color: #4a5568;\n"
<< "}\n"
<< ".form-input {\n"
<< " width: 100%;\n"
<< " padding: 12px 16px;\n"
<< " border: 2px solid #e2e8f0;\n"
<< " border-radius: 8px;\n"
<< " font-size: 1rem;\n"
<< " transition: all 0.3s ease;\n"
<< "}\n"
<< ".form-input:focus {\n"
<< " outline: none;\n"
<< " border-color: #667eea;\n"
<< " box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);\n"
<< "}\n"
<< ".btn {\n"
<< " width: 100%;\n"
<< " padding: 14px;\n"
<< " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n"
<< " color: white;\n"
<< " border: none;\n"
<< " border-radius: 8px;\n"
<< " font-size: 1.1rem;\n"
<< " font-weight: 500;\n"
<< " cursor: pointer;\n"
<< " transition: all 0.3s ease;\n"
<< "}\n"
<< ".btn:hover {\n"
<< " transform: translateY(-2px);\n"
<< " box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);\n"
<< "}\n"
<< ".form-footer {\n"
<< " text-align: center;\n"
<< " margin-top: 25px;\n"
<< " padding-top: 20px;\n"
<< " border-top: 1px solid #e2e8f0;\n"
<< "}\n"
<< ".form-footer a {\n"
<< " color: #667eea;\n"
<< " text-decoration: none;\n"
<< " margin: 0 10px;\n"
<< " transition: color 0.3s ease;\n"
<< "}\n"
<< ".form-footer a:hover {\n"
<< " color: #764ba2;\n"
<< " text-decoration: underline;\n"
<< "}\n"
<< "</style>\n"
<< "</head>\n"
<< "<body>\n"
<< "<h1>登录</h1>\n"
<< "<form action=\"/API/login.cgi\" method=\"post\">\n"
<< "账户:<input type=\"text\" name=\"cid\"><br/>\n"
<< "密码:<input type=\"password\" name=\"pswd\"/><br/>\n"
<< "<input type=\"submit\" value=\"登录\"/>\n"
<< "</form>\n"
<< "<p>还没有账号?点我注册-><a href=\"/register/\">注册</a><br><a href=\"/\">返回</a></p>\n"
<< "<div class=\"form-container\">\n"
<< " <div class=\"form-header\">\n"
<< " <h1>🌸登录🌸</h1>\n"
<< " <p>欢迎回到安岛百合视频站</p>\n"
<< " </div>\n"
<< " <form action=\"/API/login.cgi\" method=\"post\">\n"
<< " <div class=\"form-group\">\n"
<< " <label for=\"cid\">账户:</label>\n"
<< " <input type=\"text\" id=\"cid\" name=\"cid\" class=\"form-input\" placeholder=\"请输入您的账户\">\n"
<< " </div>\n"
<< " <div class=\"form-group\">\n"
<< " <label for=\"pswd\">密码:</label>\n"
<< " <input type=\"password\" id=\"pswd\" name=\"pswd\" class=\"form-input\" placeholder=\"请输入您的密码\">\n"
<< " </div>\n"
<< " <button type=\"submit\" class=\"btn\">登录</button>\n"
<< " </form>\n"
<< " <div class=\"form-footer\">\n"
<< " <p>还没有账号?<a href=\"/register/\">立即注册</a></p>\n"
<< " <p><a href=\"/\">返回首页</a></p>\n"
<< " </div>\n"
<< "</div>\n"
<< "</body>\n"
<< "</html>\n";
}
+118 -12
View File
@@ -49,21 +49,127 @@ int main(){
<< "Location: /\r\n" << std::endl;
}else{
std::cout << "Content-type:text/html\r\n\r\n"
<< "<html>\n"
<< "<!DOCTYPE html>\n"
<< "<html lang=\"zh-CN\">\n"
<< "<head>\n"
<< "<meta charset=\"utf-8\">\n"
<< "<title>安岛百合视频站</title>\n"
<< "<meta charset=\"UTF-8\">\n"
<< "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
<< "<title>注册 - 🌸安岛百合视频站🌸</title>\n"
<< "<style>\n"
<< "* { margin: 0; padding: 0; box-sizing: border-box; }\n"
<< "body { \n"
<< " font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; \n"
<< " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n"
<< " min-height: 100vh;\n"
<< " display: flex;\n"
<< " align-items: center;\n"
<< " justify-content: center;\n"
<< " color: #333;\n"
<< "}\n"
<< ".form-container {\n"
<< " background: white;\n"
<< " padding: 40px;\n"
<< " border-radius: 15px;\n"
<< " box-shadow: 0 10px 30px rgba(0,0,0,0.2);\n"
<< " width: 100%;\n"
<< " max-width: 450px;\n"
<< "}\n"
<< ".form-header {\n"
<< " text-align: center;\n"
<< " margin-bottom: 30px;\n"
<< "}\n"
<< ".form-header h1 {\n"
<< " color: #667eea;\n"
<< " font-size: 2.2rem;\n"
<< " font-weight: 300;\n"
<< " margin-bottom: 10px;\n"
<< "}\n"
<< ".form-group {\n"
<< " margin-bottom: 20px;\n"
<< "}\n"
<< ".form-group label {\n"
<< " display: block;\n"
<< " margin-bottom: 8px;\n"
<< " font-weight: 500;\n"
<< " color: #4a5568;\n"
<< "}\n"
<< ".form-input {\n"
<< " width: 100%;\n"
<< " padding: 12px 16px;\n"
<< " border: 2px solid #e2e8f0;\n"
<< " border-radius: 8px;\n"
<< " font-size: 1rem;\n"
<< " transition: all 0.3s ease;\n"
<< "}\n"
<< ".form-input:focus {\n"
<< " outline: none;\n"
<< " border-color: #667eea;\n"
<< " box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);\n"
<< "}\n"
<< ".btn {\n"
<< " width: 100%;\n"
<< " padding: 14px;\n"
<< " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n"
<< " color: white;\n"
<< " border: none;\n"
<< " border-radius: 8px;\n"
<< " font-size: 1.1rem;\n"
<< " font-weight: 500;\n"
<< " cursor: pointer;\n"
<< " transition: all 0.3s ease;\n"
<< "}\n"
<< ".btn:hover {\n"
<< " transform: translateY(-2px);\n"
<< " box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);\n"
<< "}\n"
<< ".form-footer {\n"
<< " text-align: center;\n"
<< " margin-top: 25px;\n"
<< " padding-top: 20px;\n"
<< " border-top: 1px solid #e2e8f0;\n"
<< "}\n"
<< ".form-footer a {\n"
<< " color: #667eea;\n"
<< " text-decoration: none;\n"
<< " margin: 0 10px;\n"
<< " transition: color 0.3s ease;\n"
<< "}\n"
<< ".form-footer a:hover {\n"
<< " color: #764ba2;\n"
<< " text-decoration: underline;\n"
<< "}\n"
<< "</style>\n"
<< "</head>\n"
<< "<body>\n"
<< "<h1>注册</h1>\n"
<< "<form action=\"/API/register.cgi\" method=\"post\">\n"
<< "账户:<input type=\"text\" name=\"cid\"><br/>\n"
<< "昵称:<input type=\"text\" name=\"name\"><br/>\n"
<< "密码:<input type=\"password\" name=\"pswd\"/><br/>\n"
<< "邮箱:<input type=\"text\" name=\"email\"/><br/>\n"
<< "<input type=\"submit\" value=\"注册\"/>\n"
<< "</form>\n"
<< "<p>已有账号?点我登录-><a href=\"/login/\">登录</a><br><a href=\"/\">返回</a></p>\n"
<< "<div class=\"form-container\">\n"
<< " <div class=\"form-header\">\n"
<< " <h1>🌸注册🌸</h1>\n"
<< " <p>加入安岛百合视频站</p>\n"
<< " </div>\n"
<< " <form action=\"/API/register.cgi\" method=\"post\">\n"
<< " <div class=\"form-group\">\n"
<< " <label for=\"cid\">账户:</label>\n"
<< " <input type=\"text\" id=\"cid\" name=\"cid\" class=\"form-input\" placeholder=\"请输入账户名\">\n"
<< " </div>\n"
<< " <div class=\"form-group\">\n"
<< " <label for=\"name\">昵称:</label>\n"
<< " <input type=\"text\" id=\"name\" name=\"name\" class=\"form-input\" placeholder=\"请输入昵称\">\n"
<< " </div>\n"
<< " <div class=\"form-group\">\n"
<< " <label for=\"pswd\">密码:</label>\n"
<< " <input type=\"password\" id=\"pswd\" name=\"pswd\" class=\"form-input\" placeholder=\"请输入密码\">\n"
<< " </div>\n"
<< " <div class=\"form-group\">\n"
<< " <label for=\"email\">邮箱:</label>\n"
<< " <input type=\"email\" id=\"email\" name=\"email\" class=\"form-input\" placeholder=\"请输入邮箱地址\">\n"
<< " </div>\n"
<< " <button type=\"submit\" class=\"btn\">注册</button>\n"
<< " </form>\n"
<< " <div class=\"form-footer\">\n"
<< " <p>已有账号?<a href=\"/login/\">立即登录</a></p>\n"
<< " <p><a href=\"/\">返回首页</a></p>\n"
<< " </div>\n"
<< "</div>\n"
<< "</body>\n"
<< "</html>\n";
}
+419 -2
View File
File diff suppressed because one or more lines are too long
+162 -6
View File
@@ -70,15 +70,171 @@ int main(){
return 0;
}
std::cout << "Content-type:text/html\r\n\r\n"
<< "<html>\n"
<< "<!DOCTYPE html>\n"
<< "<html lang=\"zh-CN\">\n"
<< "<head>\n"
<< "<meta charset=\"utf-8\">\n"
<< "<title>安岛百合视频站</title>\n"
<< "<meta charset=\"UTF-8\">\n"
<< "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
<< "<title>"<<vd.title<<" - 🌸安岛百合视频站🌸</title>\n"
<< "<style>\n"
<< "* { margin: 0; padding: 0; box-sizing: border-box; }\n"
<< "body { \n"
<< " font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; \n"
<< " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n"
<< " min-height: 100vh;\n"
<< " color: #333;\n"
<< " line-height: 1.6;\n"
<< "}\n"
<< ".container { \n"
<< " max-width: 1400px; \n"
<< " margin: 0 auto; \n"
<< " padding: 20px; \n"
<< "}\n"
<< ".video-header {\n"
<< " background: white;\n"
<< " padding: 30px;\n"
<< " border-radius: 15px 15px 0 0;\n"
<< " box-shadow: 0 4px 15px rgba(0,0,0,0.1);\n"
<< " margin-bottom: 0;\n"
<< "}\n"
<< ".video-header h1 {\n"
<< " color: #2d3748;\n"
<< " font-size: 2.2rem;\n"
<< " font-weight: 600;\n"
<< " margin-bottom: 15px;\n"
<< "}\n"
<< ".video-header p {\n"
<< " color: #718096;\n"
<< " font-size: 1.1rem;\n"
<< " line-height: 1.6;\n"
<< "}\n"
<< ".video-player {\n"
<< " background: #000;\n"
<< " border-radius: 0 0 15px 15px;\n"
<< " overflow: hidden;\n"
<< " box-shadow: 0 10px 30px rgba(0,0,0,0.3);\n"
<< " margin-bottom: 30px;\n"
<< "}\n"
<< ".video-player iframe {\n"
<< " width: 100%;\n"
<< " height: 720px;\n"
<< " border: none;\n"
<< " display: block;\n"
<< "}\n"
<< "/* 视频列表样式 */\n"
<< ".video-list {\n"
<< " background: white;\n"
<< " border-radius: 15px;\n"
<< " padding: 25px;\n"
<< " margin-bottom: 30px;\n"
<< " box-shadow: 0 4px 15px rgba(0,0,0,0.1);\n"
<< "}\n"
<< ".video-list h2 {\n"
<< " color: #2d3748;\n"
<< " font-size: 1.5rem;\n"
<< " margin-bottom: 20px;\n"
<< " padding-bottom: 10px;\n"
<< " border-bottom: 2px solid #e2e8f0;\n"
<< "}\n"
<< ".video-list ul {\n"
<< " list-style: none;\n"
<< " display: grid;\n"
<< " grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));\n"
<< " gap: 12px;\n"
<< "}\n"
<< ".video-list li {\n"
<< " margin-bottom: 0;\n"
<< "}\n"
<< ".video-list a {\n"
<< " display: block;\n"
<< " padding: 12px 16px;\n"
<< " background: #f7fafc;\n"
<< " border-radius: 8px;\n"
<< " text-decoration: none;\n"
<< " color: #4a5568;\n"
<< " transition: all 0.3s ease;\n"
<< " border-left: 3px solid #667eea;\n"
<< "}\n"
<< ".video-list a:hover {\n"
<< " background: #667eea;\n"
<< " color: white;\n"
<< " transform: translateX(5px);\n"
<< "}\n"
<< ".video-list .current-video {\n"
<< " background: #edf2f7;\n"
<< " color: #2d3748;\n"
<< " border-left: 3px solid #764ba2;\n"
<< " cursor: default;\n"
<< "}\n"
<< ".video-list .current-video:hover {\n"
<< " background: #edf2f7;\n"
<< " color: #2d3748;\n"
<< " transform: none;\n"
<< "}\n"
<< ".back-link {\n"
<< " text-align: center;\n"
<< " margin-top: 20px;\n"
<< "}\n"
<< ".back-link a {\n"
<< " color: white;\n"
<< " text-decoration: none;\n"
<< " font-size: 1.1rem;\n"
<< " padding: 10px 20px;\n"
<< " background: rgba(255,255,255,0.2);\n"
<< " border-radius: 25px;\n"
<< " transition: all 0.3s ease;\n"
<< "}\n"
<< ".back-link a:hover {\n"
<< " background: rgba(255,255,255,0.3);\n"
<< " transform: translateY(-2px);\n"
<< "}\n"
<< "@media (max-width: 768px) {\n"
<< " .video-player iframe {\n"
<< " height: 400px;\n"
<< " }\n"
<< " .video-header h1 {\n"
<< " font-size: 1.8rem;\n"
<< " }\n"
<< " .video-header {\n"
<< " padding: 20px;\n"
<< " }\n"
<< " .video-list ul {\n"
<< " grid-template-columns: 1fr;\n"
<< " }\n"
<< "}\n"
<< "</style>\n"
<< "</head>\n"
<< "<body>\n"
<< "<h1>"<<vd.title<<"</h1>\n"
<< "<p>"<<vd.description<<"</p>\n"
<< "<iframe style=\"width: 1280px; height: 720px;\" src=\"/player.html?url=/m3u8/"<<vid<<".m3u8\"></iframe>\n"
<< "<div class=\"container\">\n"
<< " <div class=\"video-header\">\n"
<< " <h1>"<<vd.title<<"</h1>\n"
<< " <p>"<<vd.description<<"</p>\n"
<< " </div>\n"
<< " <div class=\"video-player\">\n"
<< " <iframe src=\"/player.html?id="<<vid<<"\" allowfullscreen></iframe>\n"
<< " </div>\n";
if(vd.collection!=0) {
std::cout << " <div class=\"video-list\">\n"
<< " <h2>📺 视频列表</h2>\n"
<< " <ul>\n";
std::vector<collectionlist> cl;
get_collection_list(database,&cl,vd.collection);
for(const auto& c : cl) {
videodata video;
query_videodata(database,&video,"id = "+std::to_string(c.vid));
if(video.id==vd.id) {
std::cout << " <li><span class=\"current-video\">▶ " << video.title << " (正在播放)</span></li>\n";
} else {
std::cout << " <li><a href=\"/video/?v=" << video.id << "\">" << video.title << "</a></li>\n";
}
}
std::cout << " </ul>\n"
<< " </div>\n";
}
std::cout << " <div class=\"back-link\">\n"
<< " <a href=\"/\">← 返回首页</a>\n"
<< " </div>\n"
<< "</div>\n"
<< "</body>\n"
<< "</html>\n";
}