#include "../lib/slas_common.h"
#include "../lib/log_defines.h"
#include "../lib/slas_paths.h"
#include "../lib/slas_defines.h"
#include "../lib/slas_structs.h"
#include "../lib/slas.h"
#include "../lib/utils.h"
#include "../lib/cgi.h"
#include "../lib/libpq-fe.h"
#include "../libso/sessplan.h"
#include "../libso/session.h"
#include "../libso/logs.h"
//#define PULIC_KTY "/storage/etc/ssh_public/"
#define PULIC_KTY "/etc/ssh_public/"
int CheckXm(char *);
int CheckRecord(char *);
int CheckB64(char *);
void changejh(char *);
typedef struct _ManagementList{
char key[1024];
char name[256];
struct _ManagementList *next;
}ManagementList;
int KeySet(char *user, int tasktype, u_int64 session){
char *keyName = NULL, *keyName_old = NULL, *keyContent = NULL, *keyContent_old = NULL;
char *keyNamebuf = NULL, *keyContentbuf = NULL;
char sql[512];
int iii = 0;
PGconn *conn = NULL;
PGresult *res = NULL;
while(1){
conn = PQconnectdb(CONNDB);
if (PQstatus(conn) != CONNECTION_OK){
if(iii>=5){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('conn failed',function(){history.back();});</script></body></html>");
return 1;
}
iii++;
sleep(1);
}
else break;
}
if(conn == NULL){
PQclear(res);
res = NULL;
PQfinish(conn);
return __LINE__;
}
memset(sql, 0, sizeof(sql));
sprintf(sql, "SELECT \"PubkeyName\",\"PubkeyContent\" FROM public.\"User\" WHERE \"UserName\"='%s'", user);
res = PQexec(conn, sql);
if (PQresultStatus(res) != PGRES_TUPLES_OK){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('result error1',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>", session);
PQclear(res);
PQfinish(conn);
res = NULL;
return __LINE__;
}
if(!PQntuples(res)){
printf( "<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('KEYGET失败!',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>", session);
PQclear(res);
PQfinish(conn);
res = NULL;
return __LINE__;
}
if (PQgetvalue(res, 0, 0) != NULL){
keyName_old = (char*) malloc(sizeof(char)*3960);
sprintf(keyName_old, "%s", PQgetvalue(res, 0, 0));
}
if (PQgetvalue(res, 0, 1) != NULL){
keyContent_old = (char*) malloc(sizeof(char)*39600);
sprintf(keyContent_old, "%s", PQgetvalue(res, 0,1 ));
}
if (CGIArgLoad("ss", "keyname", &keyName, "description", &keyContent)){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('getkey失败');</script>");
PQclear(res);
PQfinish(conn);
return 1;
}
if(tasktype == 2){//add
keyNamebuf = (char*) malloc(sizeof(char)*4096);
if(!keyName_old)
sprintf(keyNamebuf, "%s", keyName);
else
sprintf(keyNamebuf, "%s%s", keyName_old, keyName);
keyContentbuf = (char*) malloc(sizeof(char)*40960);
if(!keyContent_old)
sprintf(keyContentbuf, "%s", keyContent);
else
sprintf(keyContentbuf, "%s%s", keyContent_old, keyContent);
}
if(tasktype == 3) {//del
keyNamebuf = (char*) malloc(sizeof(char)*4096);
if(keyName)
sprintf(keyNamebuf, "%s", keyName);
keyContentbuf = (char*) malloc(sizeof(char)*40960);
if(keyContent)
sprintf(keyContentbuf, "%s", keyContent);
}
PQclear(res);
if(keyNamebuf!=NULL && keyContentbuf != NULL )
sprintf(sql, "UPDATE PUBLIC.\"User\" SET \"PubkeyName\"=E'%s',\"PubkeyContent\"=E'%s' WHERE \"UserName\"='%s';", keyNamebuf, keyContentbuf, user);
else
sprintf(sql, "UPDATE PUBLIC.\"User\" SET \"PubkeyName\"=E'',\"PubkeyContent\"=E'' WHERE \"UserName\"='%s';", user);
res = PQexec(conn, sql);
if (PQresultStatus(res) != PGRES_COMMAND_OK){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('result error2',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>", session);
PQclear(res);
res = NULL;
PQfinish(conn);
return __LINE__;
}
if(keyName_old)
free(keyName_old);
if(keyContent_old)
free(keyContent_old);
if(keyNamebuf)
free(keyNamebuf);
if(keyContentbuf)
free(keyContentbuf);
PQclear(res);
PQfinish(conn);
res = NULL;
return 0;
}
/*
int KeyGet(int *count, char *user, ManagementList *head, ManagementList *node){
char sql[512], keyName[4096], keyContent[35575];
int iii = 1;
PGconn *conn = NULL;
PGresult *res = NULL;
// ManagementList *head = NULL;
// ManagementList *node = NULL;
head = (ManagementList *)malloc(sizeof(ManagementList));
head->next = NULL;
memset(head,0,sizeof(ManagementList));
while(1){
conn = PQconnectdb(CONNDB);
if (PQstatus(conn) != CONNECTION_OK){
if(iii>=5){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('conn failed',function(){history.back();});</script></body></html>");
return 1;
}
iii++;
sleep(1);
}
else break;
}
if(conn == NULL) return -1;
memset(sql, 0, sizeof(sql));
sprintf(sql, "SELECT \"PubkeyName\",\"PubkeyContent\" FROM public.\"public.User\" WHERE \"UserName\"='%s'", user);
res = PQexec(conn, sql);
if (PQresultStatus(res) != PGRES_TUPLES_OK){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('result error',function(){history.back();});</script></body></html>");
PQclear(res);
PQfinish(conn);
res = NULL;
return 2;
}
if(!PQntuples(res)){
printf( "<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('RADGET失败!',function(){history.back();});</script></body></html>");
PQclear(res);
PQfinish(conn);
res = NULL;
return 3;
}
// *pointlogin = atoi(PQgetvalue(res,0,0));
if (PQgetvalue(res, 0, 1) != NULL)
sprintf(keyName, "%s", PQgetvalue(res, 0, 1));
if (PQgetvalue(res, 0, 2) != NULL)
sprintf(keyContent, "%s", PQgetvalue(res, 0,2 ));
for(str_name = strtok_r(keyName, ",", &tok_name), str_key = strtok_r(keyName, ",", &tok_key); NULL != str_name, NULL != str_key; str_name = strtok_r(NULL, ",", &tok_name), str_key = strtok_r(NULL, ",", &tok_key)){
ManagementList *newnode = (ManagementList *)malloc(sizeof(ManagementList));
strcpy(newnode->key, str_key);
strcpy(newnode->name, str_name);
newnode->next = NULL;
if(head->next == NULL){
head->next = newnode;
node = head->next;
}else {
node->next = newnode;
node = node->next;
}
count++;
}
PQclear(res);
PQfinish(conn);
res = NULL;
return 0;
}
*/
void showhtml(u_int64 session, char *user){
int count = 0, i = 0;
char sql[512], keyName[4096], keyContent[35575], *str_name = NULL, *tok_name = NULL , *str_key = NULL, * tok_key = NULL;
int iii = 1;
PGconn *conn = NULL;
PGresult *res = NULL;
ManagementList *head = NULL;
ManagementList *node = NULL;
head = (ManagementList *)malloc(sizeof(ManagementList));
head->next = NULL;
memset(head,0,sizeof(ManagementList));
while(1){
conn = PQconnectdb(CONNDB);
if (PQstatus(conn) != CONNECTION_OK){
if(iii>=5){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('conn failed',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>", session);
return;
}
iii++;
sleep(1);
}
else break;
}
if(conn == NULL) return;
memset(sql, 0, sizeof(sql));
sprintf(sql, "SELECT \"PubkeyName\",\"PubkeyContent\" FROM public.\"User\" WHERE \"UserName\"='%s';", user);
res = PQexec(conn, sql);
if (PQresultStatus(res) != PGRES_TUPLES_OK){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('result error3',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>", session);
PQclear(res);
PQfinish(conn);
res = NULL;
return;
}
if(!PQntuples(res)){
printf( "<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('KEYGET失败!',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>", session);
PQclear(res);
PQfinish(conn);
res = NULL;
return;
}
// *pointlogin = atoi(PQgetvalue(res,0,0));
if (PQgetvalue(res, 0, 0) != NULL)
sprintf(keyName, "%s", PQgetvalue(res, 0, 0));
if (PQgetvalue(res, 0, 1) != NULL)
sprintf(keyContent, "%s", PQgetvalue(res, 0,1));
/* for(str_name = strtok_r(keyName, "\r", &tok_name); NULL != str_name; str_name = strtok_r(NULL, "\r", &tok_name)){
ManagementList *newnode = (ManagementList *)malloc(sizeof(ManagementList));
for(str_key = strtok_r(keyContent, "\r", &tok_key); NULL != str_key; str_key = strtok_r(NULL, "\r", &tok_key)){
strcpy(newnode->name, str_name);
strcpy(newnode->key, str_key);
newnode->next = NULL;
if(head->next == NULL){
head->next = newnode;
node = head->next;
}else {
node->next = newnode;
node = node->next;
}
strcpy(keyContent, tok_key);
count++;
break;
}
}*/
for( ((str_name = strtok_r(keyName, "\r", &tok_name)), (str_key = strtok_r(keyContent, "\r", &tok_key))); ((NULL != str_name)&&(NULL != str_key)); ((str_name = strtok_r(NULL, "\r", &tok_name)), (str_key = strtok_r(NULL, "\r", &tok_key))) ){
ManagementList *newnode = (ManagementList *)malloc(sizeof(ManagementList));
strcpy(newnode->name, str_name);
strcpy(newnode->key, str_key);
newnode->next = NULL;
if(head->next == NULL){
head->next = newnode;
node = head->next;
}else {
node->next = newnode;
node = node->next;
}
count++;
}
node = head->next;
printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
printf("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
printf("<head>\n");
printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />\n");
printf("<link href=\"/bh/style/middle_style.css\" rel=\"stylesheet\" type=\"text/css\"/>\n");
printf("<script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script>\n");
printf("<script src=\"/bh/pjs/jquery.wresize.js\" type=\"text/javascript\"></script>\n");
printf("<script src=\"/bh/pjs/contentboxdivresiez.js\" type=\"text/javascript\"></script>\n");
printf("<script src=\"/bh/pjs/tab_style.js\" type=\"text/javascript\"></script>\n");
printf("<script src=\"/bh/pjs/table_litmenu_100.js\" type=\"text/javascript\"></script>\n");
printf("<script src=\"/bh/pjs/bindpage.js\" type=\"text/javascript\"></script>\n");
printf("<script src=\"/bh/pjs/common.js\" language=\"javascript\" type=\"text/javascript\"></script>\n");
printf("<script src=\"/bh/pjs/bh_user.js\" language=\"javascript\" type=\"text/javascript\"></script>");
printf("<script type=\"text/javascript\"> \n");
printf("$(function(){\n");
printf(" tabEvent(\"#tabledivbox\");\n");
printf(" litmenu(\"#tabledivbox\");\n");
printf(" wwinsize(0,180);//传入合适高度\n");
printf(" \n");
printf(" //阻止冒泡\n");
printf(" $(\"#content tbody tr td:first input:checkbox\").click(function(event){\n");
printf(" event.stopPropagation();\n");
printf(" });\n");
/* if(public_key == 1){
printf(" $(\"#public_key\").prop(\"checked\",true); \n");
}else
printf(" $(\"#public_key\").prop(\"checked\",false); \n");*/
printf("})\n");
printf("</script>\n");
printf("</head>\n");
printf("<body>\n");
printf("<form action=\"\" method=\"post\" name=\"frm\">\n");
printf("<input type=\"hidden\" name=\"tasktype\" id=\"tasktype\" value=\"\">\n");
printf("<input type=\"hidden\" name=\"session\" id=\"session\" value=\"%llu\">\n",session);
printf("<input type=\"hidden\" name=\"keyname\" id=\"keyname\" value=\"\">\n");
printf("<input type=\"hidden\" name=\"description\" id=\"description\" value=\"\">\n");
printf("<div class=\"head-box\" style=\"width:auto;border-left:1px solid #d8d8d8;border-right:1px solid #d8d8d8\">\n");
printf(" <h3 class=\"now\">ssh public key</h3>\n");
/* printf(" <div class=\"guolvbox divrightbox\">\n");
printf(" <span _style=\"margin-top:2px\"><label><input type=\"checkbox\" name=\"public_key\" id=\"public_key\" value=\"1\">是否开启公钥</label></span>\n");
printf(" </div>");*/
printf("</div>\n");
printf("<div id=\"tabledivbox\" >\n");
printf("<!--此div为小菜单--><div id=\"poslitmenubox\"><div id=\"poslitmenu\"></div></div>\n");
printf("<!--表头-->\n");
printf("<div style=\"border:1px solid #ccc;border-top:none;width:100%%;position:absolute;height:29px;z-index:0;margin-left:-1px;\">\n");
printf("</div>\n");
printf("<div class=\"faux-head\">\n");
printf("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:100%%;\" id=\"tab-head\">\n");
printf("<thead>\n");
printf("<tr>\n");
printf("<th style=\"width:50px;\"><input type=\"checkbox\" name=\"d_all\" id=\"d_all\" value=\"CheckAll\" onClick=\"checkall(this,%d, 'd');\"/></th>\n", count);
printf("<th style=\"width:320px\">公钥名称</th>\n");
printf("<th style=\"background-image:none\">公钥内容</th>\n");
printf("<th style=\"width:120px\" class=\"mangerlei\">管理</th>\n");
printf("</tr>\n");
printf("</thead>\n");
printf("</table>\n");
printf("</div>\n");
printf("<div style=\"height:29px;width:100%%;background:#f2f2f2;\"></div>\n");
printf("<!--此div包含作用为出滚动条-->\n");
printf("<div class=\"tableboabox\">\n");
printf("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:100%%;\" id=\"content\">\n");
printf("<!--此处为表格实际宽度,如果表格不需要出现小菜单则把表格宽度设为100%%-->\n");
printf("<tbody>\n");
while (node){
printf(" <tr>\n");
printf(" <td style=\"width:50px\"><input type=\"checkbox\" name=\"d_%d\" id=\"d_%d\" onclick=\"checkqs(this,%d);\" value=\"%s,%s\"/></td>\n",i,i,i,node->name, node->key);
printf(" <td style=\"width:320px\">%s</td>\n", node->name);
printf(" <td><span class=\"kill\" style=\"width:300px\">%s</span></td>\n", node->key);
printf(" <td class=\"mangerlei\" style=\"width:120px\"><a href=\"#@\" onclick=\"key_del('%s','%s', %d, %d);\">删除</a></td>\n", node->name, node->key, i, count);
printf(" </tr>\n");
i++;
node = node->next;
}
printf("</tbody>\n");
printf("</table>\n");
printf("</div>\n");
printf("</div>\n");
printf(" <div class=\"diag\" id=\"Dialog01\">\n");
printf(" <div class=\"diag1\">\n");
printf(" <div class=\"head-box-main diagh\">\n");
printf(" <h3 class=\"now diagh3\">公钥列表</h3>\n");
printf(" <a class=\"dialog-close\" onclick=\"closeDialog('#Dialog01')\" href=\"javascript:void(0)\"></a>\n");
printf(" </div>\n");
printf(" <!-- head-box-main end -->\n");
printf(" <div class=\"diag_main\">\n");
printf(" <div class=\"diag_main_c\">\n");
printf(" <ul id=\"TypeList\" class=\"TypeList\">\n");
printf(" <li>\n");
printf(" <span style=\"float:right;\"></span>公钥名称:<input name=\"keyname1\" id=\"keyname1\" type=\"text\" maxlength=\"32\" class=\"textbox\" value=\"\" style=\"margin-right:20px;\" > \n");
printf(" </li>\n");
printf(" <li>\n");
printf(" <span style=\"float:right;\"></span>公钥内容:\n");
printf(" </li>\n");
printf(" <li>\n");
printf(" <td><textarea name=\"description1\" id=\"description1\" cols=\"60\" rows=\"5\" onpropertychange=\"if(document.frm.description1.value.length>1023) {value=value.substr(0,1023);alert('输入字符已达到最大值!');}\"></textarea></td> \n");
printf(" </li>\n");
printf(" </ul>\n");
printf(" <!-- TypeList end -->\n");
printf(" <div class=\"diag_btn\">\n");
printf(" <a class=\"btn_four_grly\" id=\"save\" onclick=\"Remark_Save();\" href=\"javascript:void(0);\">确定</a>\n");
printf(" <a class=\"btn_four_grly\" id=\"cancel\" onclick=\"Cancel();\" href=\"javascript:void(0);\">返回</a>\n");
printf(" </div>\n");
printf(" <!-- diag_btn -->\n");
printf(" </div>\n");
printf(" <!-- diag_main_c end -->\n");
printf(" </div>\n");
printf(" <!-- diag_main end -->\n");
printf(" <div class=\"diag_footer\"></div>\n");
printf(" \n");
printf(" </div>\n");
printf(" <!-- diag1 end -->\n");
printf(" </div>\n");
printf("<div class=\"fenyelistbox\">\n");
printf("<div class=\"ctrl-btn\" style=\"padding:0;margin-left:-10px;_margin-left:-5px\">");
printf("<a class=\"btn_four_blue\" href=\"#@\" onclick=\"getkeyplanTotalStr('%d');\">批量删除</a>", count);
printf(" <a href=\"#@\" class=\"btn_four_grly\" id=\"add\" onclick=\"__getDialog('#Dialog01');\">添加</a></div>\n");
// printf(" <a href=\"#@\" class=\"btn_four_grly\" id=\"baocun\" onclick=\"Save();\">保存</a></div>\n");
printf(" </div>\n");
printf("</form>\n");
printf("</body>\n");
printf("<script>\n");
printf("function gettype() {\n");
printf(" var reg_ip = /^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$/;\n");
printf(" var reg_ip = /^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$/;\n");
printf(" if(!reg_ip.test(document.frm.ip.value)) document.frm.type.value = 1;\n");
printf(" else document.frm.type.value = 0;\n");
printf("}\n");
//保存
printf("function Save(){\n ");
printf(" document.frm.tasktype.value = 2;\n");
printf(" document.frm.submit(); \n");
printf("}\n");
printf("function __getDialog(obj){\n");
printf(" var ww = $(window).width(), wh = $(window).height();\n");
printf(" var ow = $(obj).width(), oh = $(obj).height();\n");
printf(" var p = document.documentElement.scrollTop || document.body.scrollTop;\n");
printf(" $(obj).css({\n");
printf(" \"top\":(wh - oh)/2+p > 0 ? (wh - oh)/2+p : 0,\n");
printf(" \"left\":(ww - ow)/2 > 0 ? (ww - ow)/2 :0\n");
printf(" }).fadeIn(\"fast\");\n");
printf(" $(window).wresize(function(){\n");
printf(" var ww = $(window).width(), wh = $(window).height();\n");
printf(" var ow = $(obj).width(), oh = $(obj).height();\n");
printf(" var p = document.documentElement.scrollTop || document.body.scrollTop;\n");
printf(" $(obj).css({\n");
printf(" \"top\":(wh - oh)/2+p > 0 ? (wh - oh)/2+p : 0,\n");
printf(" \"left\":(ww - ow)/2 > 0 ? (ww - ow)/2 :0\n");
printf(" });\n");
printf(" })\n");
printf("} \n");
printf("function Cancel(){\n");
printf(" closeDialog('#Dialog01');\n");
printf(" $(\"#description1\").val(\"\");\n");
printf(" $(\"#keyname1\").val(\"\");\n");
printf("}\n");
printf("function key_del(key, name, ii, count){\n");
printf(" confirm(\"确定删除吗?\",function(){\n");
printf(" var i;\n");
printf(" var objd;\n");
printf(" for(i=0;i<count;i++){\n");
printf(" objd = document.getElementById(\"d_\"+i).value.split(\",\");;\n");
printf(" if( i != ii){\n");
printf(" document.frm.keyname.value += objd[0] + \"\\\\r\";\n");
printf(" document.frm.description.value += objd[1] + \"\\\\r\";\n");
printf(" }\n");
printf(" }\n");
printf(" document.frm.tasktype.value = 3;\n");
printf(" document.frm.submit();\n");
printf(" });\n");
printf("}\n");
printf("function getkeyplanTotalStr(count){\n");
printf(" var i;\n");
printf(" var objd;\n");
printf(" var objd1;\n");
printf(" for(i=0;i<count;i++){\n");
printf(" objd = document.getElementById(\"d_\"+i).value.split(\",\");\n");
printf(" objd1 = document.getElementById(\"d_\"+i);\n");
printf(" console.log(objd);");
printf(" if(objd1.checked != true){\n");
printf(" document.frm.keyname.value += objd[0] + \"\\\\r\";\n");
printf(" document.frm.description.value += objd[1]+ \"\\\\r\";\n");
printf(" }\n");
printf(" }\n");
printf(" document.frm.tasktype.value = 3;\n");
printf(" document.frm.submit();\n");
printf("}\n");
//备注保存检查
printf("function Remark_Save(){\n");
printf(" if($(\"#keyname1\").val()==\"\"){\n");
printf(" alert('请填写公钥名称!');\n");
printf(" return false;\n");
printf(" }\n");
printf(" if($(\"#description1\").val()==\"\"){\n");
printf(" alert('请填写操作内容!');\n");
printf(" return false;\n");
printf(" }\n");
printf("\n");
printf(" if($(\"#keyname1\").val().length>64) {\n");
printf(" alert('公钥名称已达到最大值!');\n");
printf(" return false;\n");
printf(" }\n");
printf(" if($(\"#description1\").val().length>1023) {\n");
printf(" //value=value.substr(0,255);\n");
printf(" alert('输入字符已达到最大值!');\n");
printf(" return false;\n");
printf(" }\n");
printf(" var Cts = $(\"#description1\").val();\n");
printf(" if(Cts.indexOf(\"\\n\") >= 0 ) {\n");
printf(" alert('公钥名称('+$(\"#keyname1\").val()+')输入字符有特殊符号换行符!');\n");
printf(" return false;\n");
printf(" }\n");
printf(" var Cts = $(\"#keyname1\").val();\n");
printf(" if(Cts.indexOf(\"\\\\r\") >= 0 ) {\n");
printf(" alert('公钥名称输入字符有特殊符号换行符!');\n");
printf(" return false;\n");
printf(" }\n");
printf(" document.frm.tasktype.value = 2;\n");
printf(" document.frm.description.value=$(\"#description1\").val() + \"\\\\r\";\n");
printf(" document.frm.keyname.value=$(\"#keyname1\").val() +\"\\\\r\";\n");
printf(" document.frm.submit(); \n");
printf("}\n");
printf("function closeDialog(obj){\n");
printf("$(obj).hide();\n");
printf("}\n");
printf("</script>\n");
printf("</html>\n");
printf("<style type='text/css'> \n");
printf("#ConnectHTML select{margin:4px 0 0 0;}\n");
printf("span.kill{word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:inline-block}\n");
printf(".fdialog{width:820px;height:280px;overflow:hidden;border-radius:5px;}\n");
printf(".fdialog .dialog-bg{width:2000px;height:2000px;background:#036;opacity:0.8;filter:alpha(opacity=80);}\n");
printf(".fdialog .dialog-cont{width:800px;height:auto;overflow:hidden;margin:10px;padding:0;}\n");
printf(".fdialog .dialog-title,.fdialog .dialog-content{width:100%%;}\n");
printf(".fdialog .dialog-content{height:auto;border:0;padding:0;}\n");
printf(".diag{position:absolute; top:50%%; left:50%%; width:585px; margin-left:-29px; margin-top:-145px;z-index:100; display:none;}\n");
printf(".diag1{background:url(/bh/images/dialog_bg01.gif) 0 0 no-repeat; padding-top:10px;float:left;}\n");
printf(".diagh{border-left: #d8d8d8 1px solid; width: auto; border-right: #d8d8d8 1px solid; margin:0 12px 0 11px; width:560px; float:left;}\n");
printf(".diag_main{background:url(/bh/images/dialog_bg01_h.gif) 0 0 repeat-y;overflow:hidden;float:left;width:585px; }\n");
printf(".diag_main_c{margin:0 12px 0 11px; height:200px;overflow:hidden; overflow-y:auto; float:left; width:560px;}\n");
printf(".TypeList{overflow-y:auto; padding: 5px 10px;}\n");
printf(".TypeList li{ line-height:26px;}\n");
printf(".diag_btn{width:100%%; text-align:center;}\n");
printf(".diag_footer{background:url(/bh/images/dialog_bg01.gif) 0 -179px no-repeat; height:10px; float:left; width:585px;}\n");
printf(".baobiaoremove{ margin-top:5px;}\n");
printf("#zhezhao{position:absolute;top:0;left:0;width:100%%;height:100%%;overflow:hidden;background:#FFF;z-index:98;filter:alpha(opacity=30);-moz-opacity:0.3; -khtml-opacity: 0.3; opacity:0.3; display:none;}\n");
printf("</style>\n");
node = head;
while (node){
ManagementList *tmp;
if(node->name) free(node->name);
tmp = node;
node = node->next;
free(tmp);
}
PQclear(res);
PQfinish(conn);
res = NULL;
return;
}
int main(){
int ret, tasktype = 0, public_key = 0, d_all = 0;
u_int64 session;
char *description = NULL, *keyname = NULL, *delstr = NULL;
char sql[256] ,cuser[256];
memset(cuser,0,sizeof(char)*256);
memset(sql,0,sizeof(char)*256);
printf("Content-type:text/html\n\n");
if ((ret = CGIArgLoad("Ldssdds","session", &session, "tasktype", &tasktype, "description", &description, "keyname", &keyname, "d_all", &d_all, "public_key", &public_key, "delstr", &delstr))){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('服务器错误(%d)',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>", ret, session);
return 0;
}
if (CommandSessionCheck(session, cuser, NULL)){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('系统超时',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>", session);
goto _END_;
}
if (!cuser){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('get user error',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>", session);
goto _END_;
}
if(tasktype == 2 || tasktype == 3){ // add || del
if((ret = KeySet(cuser, tasktype, session))!=0){
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('操作失败(%d)',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>\n", ret, session);
goto _END_;
}else{
printf("<html><head><link href=\"/bh/style/stystem.css\" rel=\"stylesheet\" type=\"text/css\"/></head><body><script src=\"/bh/pjs/jquery-1.4.2.min.js\" type=\"text/javascript\"></script><script>alert('操作成功',function(){location.href='key_management.cgi?session=%llu';});</script></body></html>\n", session);
goto _END_;
}
}
showhtml(session,cuser);
_END_:
CGIArgFree();
return 0;
}
分享到:
相关推荐
4. 密钥管理:加密的强度和安全性取决于密钥的安全存储和管理。程序可能涉及密钥的生成、存储、备份和撤销。 5. 用户界面:为了方便用户使用,程序可能会有一个友好的图形用户界面(GUI),允许用户选择要加密的...
- **DBMS内核层加密**:直接在数据库管理系统内部实现,数据在物理存取前加密,优点是加密效果好,不影响数据库功能,但会增加服务器负担。 - **DBMS外层加密**:通过外部工具实现,加解密在客户端进行,减轻...
选择哪种加密方式取决于安全性需求、性能要求以及密钥管理等因素。 对称加密,如AES(Advanced Encryption Standard),速度快,适合大量数据的加密,但密钥分发是个问题,需要确保密钥的安全传输。非对称加密则...
然而,为了确保全面的数据安全,企业还需要关注密钥管理,结合其他安全措施,如访问控制、防火墙和物理安全,来构建多层次的安全防护体系。同时,定期评估和更新加密策略也是确保数据安全的关键步骤,因为网络安全...
在IT行业中,Spring Boot是一个非常流行的微服务框架,它简化了Spring应用的初始搭建以及开发过程。...在实际开发过程中,记得遵循最佳实践,如定期更新密钥,使用安全的加密算法,以及对敏感数据进行严格的访问控制。
为了确保脚本的安全性,密码不应直接写入脚本,而是通过环境变量或者密钥管理工具(如ssh-keygen)来提供。同时,备份脚本应具备错误处理机制,如异常捕获和通知功能,以便在备份失败时及时通知管理员。 在实际应用...
7. **空间效率**:SQLite数据库文件大小取决于数据量,且其内部结构设计能够高效地存储和检索数据。 在Android开发中,SQLite通常作为应用程序的本地数据库,用于存储应用数据。开发者可以通过Android提供的...
从给定的信息来看,主要涉及的是使用SQL Server的批处理工具BCP(Bulk Copy Program)来从数据库...了解其工作原理、命令参数以及执行流程对于有效管理和维护数据库至关重要。希望以上内容能帮助你更好地掌握这一技能。
同时,外键管理和第三方密钥管理支持,为数据中心的信息安全提供了更全面的解决方案。审查功能的增强则有助于满足合规性要求,允许审查数据操作,包括读取和修改记录。 数据库镜像是SQL Server 2008提升业务连续性...
总之,Java提供了丰富的加密工具,使得开发者能够方便地生成和管理密钥对,从而确保数据的安全传输和存储。通过理解并掌握这些概念和技术,我们可以创建出强大的安全应用。在处理给定的实例"基于java的生成密钥的...
PK利剑:14kb大小、单文件、纯缓存、无需任何数据库、实现踢人、审核发言、普通/VIP1/VIP2/管理员等多角色发言功能,支持框架入任何网页中操作。 测试体验步骤: 1、解压缩系统压缩包,得到Default.asp文件; 2...
- **常见方法**:信息认证主要包括身份识别、数字签名、消息认证等方法,而不包括密钥管理(选择题第五题)。密钥管理是加密解密过程中的一个重要组成部分,但它不是一种信息认证方法。 ##### 6. 电子邮件传输协议 ...
3. **密钥管理**:密钥用于解密数据库,因此其安全性和管理至关重要。密钥可以存储在操作系统安全存储区域,或者通过用户输入来动态提供。密钥丢失可能导致数据无法恢复,而密钥泄露则会使数据暴露。 4. **加密模式...
6. 密钥管理:密钥管理是密码学的重要环节,主要处理密钥的产生、存储、分配、保护、丢失、销毁以及保密等问题,其中最关键和最困难的是解决密钥的保护和保密。 7. 数据结构研究内容:数据结构主要研究数据的逻辑...
6. 密钥管理:密钥的分配和存储是密钥管理中最关键和最困难的问题,因为这涉及到密钥的安全性和可用性,答案是B。 7. 数据结构研究内容:数据结构主要关注数据的逻辑组织和检索,而不包括数据的采集和清洗、数据的...
- **密钥管理**:采用Diffie-Hellman公共密钥交换机制进行自动密钥管理。 - **认证**:支持X.509v3证书进行认证。 #### 四、客户支持和服务 - **保修期**:30天软件保修期。 - **支持与维护**:提供延期的支持和...
请注意,解密操作可能需要一段时间,取决于数据库的大小。 7. **管理密钥** 必须定期备份和恢复主密钥和证书,以防止因系统故障导致无法访问加密数据。使用`BACKUP CERTIFICATE`和`RESTORE CERTIFICATE`命令进行...