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

📄 editsoft.cpp

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

void EditSoft_InputID()
{
	if(Get_Check_Pass_Power(EditSoft_Power) !=1) return;
	char *html[]={
	"<html>",
	"<head>",
	"<title>编辑软件</title>",
	"</head>",
	"<body bgcolor=\"#99CCCC\">",
	"<p> </p>",
	"<p> </p>",
	"<p> </p>",
	"<p> </p>",
	"<form method=\"POST\" action>",
	"<input type=hidden name=job value=\"EditSoftHtml\">",
	"  <p><font face=\"楷体_GB2312\" size=\"5\" color=\"#0000FF\">请输入你要进行编辑的软件ID号:</font><input",
	"  type=\"text\" name=\"SoftID\" size=\"6\"> <input type=\"submit\" value=\"提交\" name=\"B1\"",
	"  style=\"font-size: 16\"></p>",
	"</form>",
	"</body>",
	"</html>",
	"end_html"
	};
  	cgiHeaderContentType("text/html");
	Print_Html(html);
}

void Edit_Soft_Html()
{
	if(Get_Check_Pass_Power(EditSoft_Power) !=1) return;
	int sid;
	cgiFormInteger("SoftID",&sid, 0);

	if(sid<=0 || db_read(DataFile,DataBZ,DataIndex,sid,
		sizeof(Soft_Info),&MySoft.Type,999,Soft_Remark)==0)
	{
		Print_Error("没有这个软件ID号,请重新输入!");
		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.size.value==\"\") {",
		"		alert(\"软件大小不能为空!\");",
		"		form.size.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=\"71%%\" height=\"210\">",
	"  <tr>",
	"    <td width=\"100%%\" height=\"204\"><form method=\"POST\" action>",
	"end_html"
	};
	char *html3[]={
	"      <p>     <input type=\"checkbox\" name=\"C1\" value=\"ON\">更新软件日期 <input",
	"type=\"submit\" value=\"提交软件修改\" onclick=\"return mypost(this.form)\"",
	"      name=\"B1\" style=\"font-size: 12\"> <input type=\"reset\" value=\"复原\" name=\"B2\"",
	"      style=\"font-size: 12\"></p>",
	"    </form>",
	"    </td>",
	"  </tr>",
	"</table>",
	"</center></div>",
	"</body>",
	"</html>",
	"end_html"
	};

	cgiHeaderContentType("text/html");
	Print_Html(html1);
	fprintf(cgiOut,"form.down1.value=\"%s",SoftHand);
	fprintf(cgiOut,"\"+mypath+\"/\";\n");
	Print_Html(html2);

	fprintf(cgiOut,"<input type=hidden name=\"SoftID\" value=\"%u\">\n",sid);
	fprintf(cgiOut,"<input type=hidden name=\"job\" value=\"EditSoft\"><p>软件名称:<input type=\"text\"\n");
	fprintf(cgiOut,"name=\"name\" size=\"31\" style=\"font-size: 12\"");
	fprintf(cgiOut,"value=\"%s\"> 版本:<input type=\"text\"\n",MySoft.Name);
	fprintf(cgiOut,"name=\"ver\" size=\"9\" value=\"%s\"><br>\n",MySoft.Ver);
	fprintf(cgiOut,"软件作者:<input type=text name=zz size=13 style=\"font-size: 12\" value=\"%s\"> 作者链接:<input\n",MySoft.ZZ);
	fprintf(cgiOut,"type=\"text\" name=\"zzlink\" size=24 style=\"font-size: 12\" value=\"%s\"><br>\n",MySoft.ZZLink);
	fprintf(cgiOut,"软件分类:<select name=\"type\" size=\"1\" style=\"font-size: 12\"\n");
	fprintf(cgiOut,"onChange=\"path(this.form)\">\n");
	int i=0;
	char SStr[20];

	char TempStr[20],TempStr1[20],TempStr2[20];
	while (strcmp(soft_type[i+1],"END") !=0) {
		strcpy(TempStr,soft_type[i++]);
		strcpy(TempStr1,soft_type[i++]);
		if(strcmp(TempStr1,MySoft.Type)==0)
		{
			strcpy(SStr,"selected");
		}
		else
		{
			strcpy(SStr,"");
		}
		if(strstr(TempStr1,"MAIN")){
			strcpy(TempStr2,"==");
			strcat(TempStr2,TempStr);
			strcat(TempStr2,"==");
			strcpy(TempStr,TempStr2);
			strcpy(TempStr1,"");
		}
		fprintf(cgiOut,"<option %s value=\"%s\">%s",SStr,TempStr1,TempStr);
		fprintf(cgiOut,"</option>\n");
	}
	fprintf(cgiOut,	"</select>平台:<select name=\"system\" size=\"1\" style=\"font-size: 12\">\n");
	i=0;
	while(strcmp(sys_type[i],"TypeEnd") !=0) {
		if(strcmp(sys_type[i],MySoft.System)==0)
		{
			strcpy(SStr,"selected");
		}
		else
		{
			strcpy(SStr,"");
		}
		fprintf(cgiOut,"<option %s value=\"",SStr);
		fprintf(cgiOut,sys_type[i]);
		fprintf(cgiOut,"\">");
		fprintf(cgiOut,sys_type[i++]);
		fprintf(cgiOut,"</option>\n");
	}
	fprintf(cgiOut,"</select>大小:<input type=\"text\" name=\"size\" size=6 value=\"%d\">KB<br>\n",MySoft.Size);
	fprintf(cgiOut,"软件简介:<textarea rows=6 name=\"S1\" cols=49 style=\"font-size: 12\">%s</textarea><br>\n",Soft_Remark);
	fprintf(cgiOut,"本站下载:<input type=\"text\" name=\"down1\" size=\"43\" value=\"%s\"><br>\n",MySoft.Down1);
	fprintf(cgiOut,"原始下载:<input type=\"text\" name=\"down2\" size=\"43\" value=\"%s\"><br>\n",MySoft.Down2);
	fprintf(cgiOut,"其他下载:<input type=\"text\" name=\"down3\" size=\"43\" value=\"%s\"></p>\n",MySoft.Down3);

	Print_Html(html3);
}

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

	int sid; //软件ID号
	struct Soft_Info tmp;
	
	cgiFormInteger("SoftID", &sid, 0);
	if(db_read(DataFile,NULL,DataIndex,sid,
		sizeof(Soft_Info),&tmp,0,NULL)==0)
	{
		Print_Error_NoLink("操作失败,可能软件已被删除!");
		return;
	}
	strcpy(MySoft.User,UserInfo.Name);  //拷贝操作用户名到结构
	MySoft.count=tmp.count;

	if (cgiFormCheckboxSingle("C1") == cgiFormSuccess) { //更新操作
		time(&MySoft.Date); //设置新日期
	}
	else
	{
		MySoft.Date=tmp.Date;
	}
	if(db_edit(DataFile,DataBZ,DataIndex,sid,sizeof(Soft_Info),
		&MySoft.Type,Soft_Remark)==0)
	{
		Print_Error_NoLink("写文件出错,请立刻通知梦晖!");
		return;
	}
	EditSoft_InputID();
}

⌨️ 快捷键说明

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