⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addsoft.cpp

📁 管理系统
💻 CPP
字号:
#include "cgic.h"
#include "config.h"
#include "mydblib.h"
#include <malloc.h>
#include <time.h>

void Add_Soft_Html()
{
	if(Get_Check_Pass_Power(AddSoft_Power) !=1) return;
	char *html1[]= {
		"<html>",
		"<head>",
		"<title>增加新软件</title>",
		"<style>",
		"<!--",
		"p {font-size: 9pt}",
		"table {font-size: 9pt}",
		"-->",
		"</style>",
		"</head>",
		"<script language=\"JavaScript\">",
		"function path(form){",
		"	var str=form.type.value;",
		"	var strl=str.length;",
		"	var mypath=\"\";",
		"	if (str==\"\"){",
		"		alert(\"你不能选择这一项呀!\");",
		"		return;",
		"	}",
		"	for (i=0;i<strl;i++) {",
		"		temp_char=str.charAt(i);",
		"		if(temp_char != '-') {",
		"			mypath=mypath+temp_char;",
		"	 	} else {",
		"			mypath=mypath+\"/\";",
		"		}",
		"   }",
		"end_html"
	};
//	form.down1.value="/longsun/"+mypath+"/";
	char *html2[]={
		"	}",
		"function mypost(form)",
		"{",
		"	if(form.name.value==\"\") {",
		"		alert(\"软件名不能为空!\");",
		"		form.name.focus();",
		"		return false;",
		"	}",
		"	if(form.type.value==\"\") {",
		"		alert(\"软件类型选择错误!\");",
		"		form.type.focus();",
		"		return false;",
		"	}",
		"	if(form.S1.value==\"\") {",
		"		alert(\"软件简介不能为空!\");",
		"		form.S1.focus();",
		"		return false;",
		"	}",
		"	return true;",
		"}",
		"</script>",
		"<body bgcolor=#99CCCC>",
		"<p> </p>",
		"<p align=\"center\"><font face=\"楷体_GB2312\" size=\"6\" color=\"#0000FF\">增加新软件</font></p>",
		"<div align=\"center\"><center>",
		"<table border=\"0\" width=\"80%%\" height=\"210\">",
		"  <tr>",
		"    <td width='100%%' height=204><form method=\"POST\" action>",
		"      <input type=\"hidden\" name=\"job\" value=\"AddSoft\"><p>软件名称:<input type=\"text\"",
		"      name=\"name\" size=\"31\" style=\"font-size: 12\"> 版本:<input type=\"text\" name=\"ver\"",
		"      size=\"9\"><br>",
		"      软件作者:<input type=\"text\" name=\"zz\" size=\"13\" style=\"font-size: 12\"> 作者链接:<input",
		"      type=\"text\" name=\"zzlink\" size=\"24\" style=\"font-size: 12\"><br>",
		"		软件分类:<select name=\"type\" size=\"1\" style=\"font-size: 12\"",
		"      onChange=\"path(this.form)\">",
		"end_html"
	};

	char *html3[]={
	"	</select>大小:<input type=\"text\" name=\"size\" size=\"6\"><br>",
	"      软件简介:<textarea rows=\"6\" name=\"S1\" cols=\"49\" style=\"font-size: 12\"></textarea><br>",
	"      本站下载:<input type=\"text\" name=\"down1\" size=\"43\"",
	"      value=\"/longsun/\"><br>",
	"      原始下载:<input type=\"text\" name=\"down2\" size=\"43\"><br>",
	"      其他下载:<input type=\"text\" name=\"down3\" size=\"43\"></p>",
	"      <p><input type=\"submit\" value=\"提交软件\" name=\"B1\" style=\"font-size: 14\"",
	"      onclick=\"return mypost(this.form)\"> <input type=\"reset\" value=\"复原\" name=\"B2\"",
	"      style=\"font-size: 12\"></p>",
	"    </form>",
	"    </td>",
	"  </tr>",
	"</table>",
	"</center></div>",
	"</body>",
	"</html>",
	"end_html"
	};

	Set_Cookie("PostCount","0");
	cgiHeaderContentType("text/html");
	Print_Html(html1);
	fprintf(cgiOut,"form.down1.value=\"%s",SoftHand);
	fprintf(cgiOut,"\"+mypath+\"/\";\n");
	Print_Html(html2);
	int i=0;
	while (strcmp(soft_type[i+1],"END") !=0) {
		char TempStr[20],TempStr1[20],TempStr2[20];
		strcpy(TempStr,soft_type[i++]);
		strcpy(TempStr1,soft_type[i++]);
		if(strstr(TempStr1,"MAIN")){
			strcpy(TempStr2,"==");
			strcat(TempStr2,TempStr);
			strcat(TempStr2,"==");
			strcpy(TempStr,TempStr2);
			strcpy(TempStr1,"");
		}
		fprintf(cgiOut,"<option value=\"%s\">%s",TempStr1,TempStr);
		fprintf(cgiOut,"</option>\n");
	}
	fprintf(cgiOut,"</select>平台:<select");
	fprintf(cgiOut," name=\"system\" size=\"1\" style=\"font-size: 12\">");
	i=0;
	while(strcmp(sys_type[i],"TypeEnd") !=0) {
		fprintf(cgiOut,"<option value=\"");
		fprintf(cgiOut,sys_type[i]);
		fprintf(cgiOut,"\">");
		fprintf(cgiOut,sys_type[i++]);
		fprintf(cgiOut,"</option>\n");
	}
	Print_Html(html3);
}

void Add_Soft()
{
	if(Get_Check_Pass_Power(AddSoft_Power) !=1) return;
	char PostCount[5];  //提交次数
	Get_Cookie(PostCount,"PostCount",5);
	if(strcmp(PostCount,"1")==0) {
		Print_Error_NoLink("资料已提交,如有错误请用编辑功能!");
		return;
	}
	Set_Cookie("PostCount","1");

	strcpy(MySoft.User,UserInfo.Name);  //设置操作用户名
	
	time(&MySoft.Date); //设置日期

	MySoft.count=0;  //设置初始计数器

	if(Read_Info_Form()==1) {
		Print_Error("读入的数据有误!");
		return;
	}

	if(db_add(DataFile,DataBZ,DataIndex,sizeof(Soft_Info),
		&MySoft.Type,Soft_Remark) ==0)
	{
		Print_Error("增加软件时出错,请立刻通知梦晖!");
		return;
	}
	cgiHeaderLocation("?job=AddSoftHtml");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -