int main(void) { cgi_init(); cgi_session_start(); cgi_process_form(); // Is to destroy the session? if (cgi_param("confirm") && !strcmp(cgi_param("confirm"), "yes")) { cgi_session_destroy(); cgi_end(); cgi_redirect("session.cgi"); return 0; } cgi_init_headers(); puts("" "<html>" "<head><title>LibCGI session examples - Destroy session</title>" "</head>" "<body>" ""); cgi_include("session_ex1_desc.html"); puts("" "<table width='70%%' align='center'>" "<tr>" "<td>" ""); if (!cgi_session_var_exists("logged")) { puts("<font face='arial, verdana' size='2'>You are not logged yet</font>"); } else { puts("" "<font face='arial, verdana' size='2'>If you are sure to unregister the session, " "<a href='destroy.cgi?confirm=yes'>click here</a></font>" ""); } puts("</td></tr>"); cgi_include("topbar.htm"); puts("" "</table>" "</body>" "</html>" ""); cgi_end(); return 0; }
int main(int argc, char *argv[]) { struct sockaddr_in servaddr; char buf[MAXLINE]; int sockfd, n; cgi_init(); cgi_process_form(); cgi_init_headers(); if (cgi_param("action") && cgi_param("message") && cgi_param("ip")) { sockfd = Socket(AF_INET, SOCK_STREAM, 0); bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; inet_pton(AF_INET, cgi_param("ip"), &servaddr.sin_addr); servaddr.sin_port = htons(SERV_PORT); Connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); strcpy(buf, cgi_param("message")); Write(sockfd, buf, strlen(buf) + 1); Close(sockfd); } cgi_end(); return 0; }
int main(void) { //Redirect before initializing headers mysqlpp::Connection c(false); if (!c.connect("okzoniom", "localhost", "okzoniom", getDBIdent().c_str())) { cgi_redirect("./error.okz?state=err_db"); return 0; } else { //Set UTF8 mysqlpp::Query q = c.query("SET NAMES utf8"); q.exec(); } cgi_init(); cgi_session_save_path("sessions/"); cgi_session_start(); cgi_process_form(); cgi_init_headers(); header("sidebar_player_list"); menu(); sidebar(); body(c); footer(); cgi_end(); return 0; }
int main( int argc, char **argv ) { char *param; int sensornum; int subaddr; int days; int type; cgi_init(); cgi_process_form(); param = cgi_param("sensor"); sensornum = param ? atoi(param) : 255; param = cgi_param("type"); type = param ? atoi(param) : S_RECEIVER; param = cgi_param("subaddr"); subaddr = param ? atoi(param) : 1; param = cgi_param("days"); days = param ? atoi(param) : 1; load_data(sensornum, subaddr, type, days ); create_graph(); cgi_redirect(graphuri); cgi_end(); return( 0 ); }
int main(void) { sqlite3 *db; char *err = NULL; int ret = 0; int empty = 1; char *sql = NULL; char *data; cgi_init(); cgi_process_form(); cgi_init_headers(); //printf("Content-Type:text/html\r\n\r\n"); puts("<html><head><title>login</title><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\"></head><body>"); if ((cgi_param("Name") == NULL) || (cgi_param("Password") == NULL)) { puts("用户名或密码不正确,登录失败!"); exit(1); } #if 0 printf("Name=%s\t", cgi_param("Name")); printf("Password=%s\t", cgi_param("Password")); #endif ret = sqlite3_open("usr.db", &db); if (ret != SQLITE_OK) { puts(sqlite3_errmsg(db)); puts("\n"); exit(1); } sql = sqlite3_mprintf("select * from usr where name=%Q and password=%Q;", cgi_param("Name"), cgi_param("Password")); ret = sqlite3_exec(db, sql, rscallback, &empty, &err); if (ret != SQLITE_OK) { puts(err); puts("\n"); sqlite3_close(db); exit(1); } sqlite3_free(sql); if (empty != 0) { puts("用户名或密码不正确,登录失败!"); } else { puts("登录成功!"); } puts("</body></html>"); cgi_end(); sqlite3_close(db); return 0; }
void usualFreeMemory (xmlDocPtr doc) { cgi_end(); if (doc) xmlFreeDoc(doc); xmlCleanupParser(); xmlMemoryDump(); }
int main (int argc, char **argv) { char *username; //CGI process cgi_init(); cgi_process_form(); username = cgi_param("uid"); cgi_init_headers(); /************** pagina html busca ********************/ printf("<html>\n"); printf("<head>\n"); printf(" <title>Neural TB - Lista de Pacientes</title>\n"); printf(" <link rel=\"stylesheet\" type=\"text/css\" href=\"css/main.css\" />\n"); printf(" <link rel=\"stylesheet\" type=\"text/css\" href=\"css/menu.css\" />\n"); printf(" <link rel=\"stylesheet\" type=\"text/css\" href=\"css/form.css\" />\n"); printf(" <script language=javascript src=\"js/funcoes.js\"></script>\n"); printf("\n"); printf(" <style>\n"); printf(" iframe {width: 100%%; min-width: 800px; height:500px}\n"); printf(" </style>\n"); printf("</head>\n"); printf("\n"); printf("<body>\n"); printf("\n"); showMenu("listar",username); printf("\n"); printf("<table border=\"0\">\n"); printf("<tr>\n"); printf(" <td class=\"under_menu\">\n"); printf(" <div align=\"center\">\n"); printf(" <table border=\"0\" style=\"width: 100%%\" cellspacing=\"0\" cellpadding=\"0\"> \n"); printf("\n"); printf(" <tr>\n"); printf(" <td><iframe src=\"listPatients.cgi?uid=%s\" frameborder=\"0\" name=\"resultado\" marginwidth=\"0\" marginheight=\"0\" style=\"width: 100%%\"></iframe></td>\n",username); printf(" </tr>\n"); printf("\n"); printf(" </table>\n"); printf(" </div>\n"); printf(" </td>\n"); printf("</tr>\n"); printf("</table>\n"); printf("</body>\n"); printf("</html>\n"); /*****************************************************/ cgi_end(); return 0; }
int main(int argc, char *argv[]) { cgi_init(); cgi_session_start(); cgi_process_form(); cgi_init_headers(); sqlite3 *db; char *err = 0; char *sql = NULL; char **result=NULL; int row=0,col=0; int ret = 0; ret = sqlite3_open(DATEBASE,&db); if(ret != SQLITE_OK) { fputs(sqlite3_errmsg(db),stderr); fputs("\n",stderr); exit(1); } sql = sqlite3_mprintf("select U_prim from UserInfo where U_id='%s' and U_pwd='%s'", cgi_param("user"),cgi_param("password")); ret = sqlite3_get_table(db,sql,&result,&row,&col,&err); if(ret != SQLITE_OK) { fputs(err,stderr); fputs("\n",stderr); sqlite3_close(db); exit(1); } if(col == 0 && row == 0) { /* 修改路径 */ printf("bad input"); printf("%s ",cgi_param("user")); cgi_include ("../htdocs/login.html"); } else { cgi_session_register_var("logged",result[1]); /* 修改系统用户跳转页面地址 */ cgi_include("../htdocs/main.html"); } sqlite3_free_table(result); sqlite3_close(db); cgi_end(); return 0; }
int main(void) { cgi_init(); cgi_session_start(); cgi_init_headers(); puts("<html><body>"); cgi_include("session_ex1_desc.html"); puts("" "<table width='70%%' align='center'>" "<tr>" "<td align='center'>" "<font face='arial, verdana' size='4' color='orange'>Main page" ""); // The user is logged? if (cgi_session_var_exists("logged")) puts(" - logged"); else puts(" - not logged yet"); puts("" "</font>" "</td>" "</tr>" " " "<tr>" "<td><font face='arial, verdana' size='2' color='#0000ff'>" "This is the main page of LibCGI session suport test. Please choose one of the options" "in the navigation bar.</font>" "</td>" "</tr>" ""); // include the navigation bar cgi_include("topbar.htm"); puts("" "</table>" "</body>" "</html>" ""); cgi_end(); return 0; }
int main() { char *str, *delim, **e; unsigned int total, i; cgi_init(); cgi_process_form(); cgi_init_headers(); // The form was submited?? if (cgi_param("action")) { str = cgi_param("str"); delim = cgi_param("delim"); e = explode(str, delim, &total); if (total < 1) puts("explode() returned 0 items."); else { for (i = 0; i < total; i++) printf("Item offset [%d]: %s<br>", i, e[i]); } free(str); free(delim); } else { printf("" "<html><head><title>LibCGI examples - explode()</title></head>" "<body>" "%s<br><br>" "<form action='explode.cgi' method='post'>" "String: <input type='text' name='str' value='this,is,a,test'><br>" "Delimitator: <input type='text' name='delim' value=',' maxlength='1' size='2'><br>" "<input type='submit' value='explode() the string!!!' name='action'>" "</form>" "</body>" "</html>" "", example_description()); } cgi_end(); return 0; }
void libcgi_error(int error_code, const char *msg, ...) { va_list arguments; if (!cgi_display_errors) return; cgi_init_headers(); va_start(arguments, msg); printf("<b>%s</b>: ", libcgi_error_type[error_code]); vprintf(msg, arguments); puts("<br>"); va_end(arguments); if ((error_code == E_FATAL) || (error_code == E_MEMORY)) { cgi_end(); exit(EXIT_FAILURE); } }
int main (int argc, char **argv) { char *username; //CGI process cgi_init(); cgi_process_form(); username = cgi_param("uid"); cgi_init_headers(); //HTML printf("\r\n"); printf("<html>\n"); printf("<!-- Arquivo para o projeto NeuralTB -->\n"); printf("<!-- Universidade Federal do Rio de Janeiro\n"); printf(" Escola Politecnica\n"); printf(" Departamento de Engenharia Eletronica e de Computacao\n"); printf(" \n"); printf(" Laboratorio de Processamento de Sinais\n"); printf(" \n"); printf(" Autor: Luiz Evora\n"); printf(" Atualizacao: Laura de Oliveira Fernandes Moraes\n"); printf(" Ultima atualizacao: 29/07/2008 -->\n"); printf("\n"); printf(" <head>\n"); printf("\n"); printf(" <meta http-equiv=content-type content=\"text/html; charset=UTF-8\">\n"); printf("\n"); printf(" <title>.:. Neural TB .:. Busca de pacientes</title>\n"); printf("\n"); printf(" <link rel=\"stylesheet\" type=\"text/css\" href=\"../css/standart.css\"/>\n"); printf("\n"); printf(" <script language=\"javascript\" src=\"../js/xml.js\"></script>\n"); printf(" <script language=\"javascript\" src=\"../js/busca.js\"></script>\n"); printf("\n"); printf("<script>\n"); printf("\n"); printf(" var linha=0;\n"); printf("\n"); printf(" function contaLinhas()\n"); printf("\n"); printf(" {\n"); printf("\n"); printf(" linha+=1;\n"); printf("\n"); printf(" }\n"); printf("\n"); printf(" </script>\n"); printf("\n"); printf("\n"); printf("\n"); printf(" </head>\n"); printf("\n"); printf("\n"); printf("\n"); printf("<!-- <body onLoad=\"displayResult('xml','../xml/pacientes.xml','../xml/nomes.xsl');\" class=\"style1\">-->\n"); printf("\n"); printf("<body class=\"style1\">\n"); printf("\n"); printf(" <table height=\"120\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id= \"d\">\n"); printf("\n"); printf(" <tr bgcolor=\"#CCCCCC\">\n"); printf("\n"); printf(" <td> </td>\n"); printf("\n"); printf(" <td><b><u><font size=\"5\">Menu</font></u></b></td>\n"); printf("\n"); printf(" <td> </td>\n"); printf("\n"); printf(" </tr>\n"); printf("\n"); printf(" <tr bgcolor=\"#CCCCCC\">\n"); printf("\n"); printf(" <td> </td>\n"); printf("\n"); printf(" <td width=\"100%%\">\n"); printf("\n"); printf(" <a href=\"formulario.cgi?uid=%s\">Adicionar Paciente</a> \n", username); printf("\n"); printf(" <a href=\"busca.cgi?uid=%s\"> Buscar/Editar/Remover</a> \n", username); printf("\n"); printf(" <a href=\"backup.cgi\"> Back-up</a> \n"); printf("\n"); printf(" \n"); printf("\n"); printf(" \n"); printf("\n"); printf(" \n"); printf("\n"); printf(" \n"); printf("\n"); printf(" <a href=\"principal.cgi?uid=%s\">Página principal</a>\n", username); printf("\n"); printf(" </td>\n"); printf("\n"); printf(" <td></td>\n"); printf("\n"); printf(" </tr>\n"); printf("\n"); printf(" <tr bgcolor=\"#CCCCCC\">\n"); printf("\n"); printf(" <td> </td>\n"); printf("\n"); printf(" <td>\n"); printf("\n"); printf(" <a href=\"exibirPacientes.cgi?uid=%s\">Exibir questionários</a> \n", username); printf("\n"); printf(" <a href=\"exibirRecusa.cgi?uid=%s\">Exibir recusas</a>\n", username); printf("\n"); printf(" </td>\n"); printf("\n"); printf(" <td></td>\n"); printf("\n"); printf(" </tr>\n"); printf("\n"); printf(" </table>\n"); printf("\n"); printf(" <a id=\"xml1\" href=\"\"></a>\n"); printf(" \n"); printf(" <form action=\"searchPatient.cgi?uid=%s\" method=\"post\" name=\"check\" id=\"searchForm\" onSubmit=\"return validarBusca(this);\" />\n", username); printf("<input type=\"HIDDEN\" name=\"uid\" value=\"%s\">\n",username); printf(" <table width=\"70%%%%\" border=\"0\" cellpadding=\"1\" cellspacing=\"2\" bordercolor=\"#999999\" id=\"tabela\" align=center>\n"); printf(" <tr class=\"styleBusca1\">\n"); printf(" <td width=\"30%%%%\" title=\"Atributo através do qual será realizada a busca\">\n"); printf(" <div class=\"styleBusca2\"> Busca por</div>\n"); printf(" </td>\n"); printf(" <td width=\"20%%%%\" id=\"operador_0\"> </td>\n"); printf(" <td id=\"VALORES_TITULO\" width=\"40%%%%\">\n"); printf(" <div class=\"styleBusca2\"> </div>\n"); printf(" </td>\n"); /*printf(" <td id=\"ORDENA_TITULO\" width=\"10%%%%\" title=\"Ordena os pacientes buscados de acordo com o atributo selecionado\">\n"); printf(" <div class=\"styleBusca2\"> Ordenar por</div>\n"); printf(" </td>\n");*/ printf(" </tr>\n"); printf(" <tr class=\"fundoTabela\">\n"); printf(" <td title=\"Atributo através do qual será realizada a busca\">\n"); printf(" <div align=\"center\"><strong><font color=\"#003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">\n"); printf(" <!-- select da celula [1][0] -->\n"); printf(" <select name=\"select\" onChange=\"_options(this);\" onKeyUp=\"_options(this.form);\">\n"); printf(" <option value=\"1\" selected> Selecione</option>\n"); printf(" <option value=\"2.nome\">Nome</option>\n"); //Opcao 2 para nomes printf(" <option value=\"3.diaNasc\">Data de nascimento</option>\n"); //Opcao 3 para datas printf(" <option value=\"4.cidade\">Cidade de estudo</option>\n"); //Opcao 4 para escolhas restritas (com opcoes) printf(" <option value=\"3.diaEntr\">Data da entrevista</option>\n"); //Opcao 3 para datas printf(" </select>\n"); printf(" </font></strong></div>\n"); printf(" </td>\n"); printf(" <td id=\"operadores\"> </td>\n"); printf(" <td id=\"valores\"> </td>\n"); /*printf(" <td id=\"ordena\" title=\"Ordena os pacientes buscados de acordo com o atributo selecionado\">\n"); printf(" <!-- select da celula [1][3] -->\n"); printf(" <select name=\"selectOrdena\">\n"); printf(" <option value=\"id\" selected>Nº de identificação</option>\n"); printf(" <option value=\"nome\">Nome</option>\n"); printf(" <option value=\"diaNasc\">Data de Nascimento</option>\n"); printf(" <option value=\"cidade\">Cidade de estudo</option>\n"); printf(" </select>\n"); printf(" </td> \n");*/ printf(" </tr>\n"); printf(" </table>\n"); printf("<p align=center> <input type=\"submit\" name=\"Submit\" value=\"Pesquisar\"> </p>\n"); printf("</form>\n"); printf("\n"); printf("<div align=center><h3> Pacientes Inseridos</h3></div>\n"); printf("\n"); printf("<div id=\"xml\">\n"); printf("\n"); printf("</div>\n"); printf("\n"); printf("<table width=\"600\" align=\"center\" cellspacing=\"1\" cellpadding=\"0\" id=\"xml1\">\n"); printf("<tr class=\"nome\" align=\"center\">\n"); printf("<td><h4>Número</h4></td>"); printf("<td><h4>Nome</h4></td>"); printf("<td><h4>Data de nascimento</h4></td>"); printf("<td><h4>Data da entrevista</h4></td>"); printf("<td><h4>Remover</h4></td>"); printf("<td><h4> Editar </h4></td></tr>"); printf("\n"); printf(" <script>\n"); printf("\n"); printf("\n"); printf("\n"); printf(" var xmlDoc=null;\n"); printf("\n"); printf(" if (window.ActiveXObject)\n"); printf("\n"); printf(" {// code for IE\n"); printf("\n"); printf(" xmlDoc=new ActiveXObject(\"Microsoft.XMLDOM\");\n"); printf("\n"); printf(" }\n"); printf("\n"); printf(" else if (document.implementation.createDocument)\n"); printf("\n"); printf(" {// code for Mozilla, Firefox, Opera, etc.\n"); printf("\n"); printf(" xmlDoc=document.implementation.createDocument(\"\",\"\",null);\n"); /*printf(" document.write(\"<td></td>\");"); printf(" document.write(\"<td><h4>Número</h4></td>\");"); printf(" document.write(\"<td><h4>Nome</h4></td>\");"); printf(" document.write(\"<td><h4>Data de nascimento</h4></td>\");"); printf(" document.write(\"<td><h4>Remover</h4></td>\");"); printf(" document.write(\"<td><h4> Editar </h4></td>\");");*/ printf("\n"); printf(" }\n"); printf("\n"); printf(" else\n"); printf("\n"); printf(" {\n"); printf("\n"); printf(" alert('Your browser cannot handle this script');\n"); printf("\n"); printf(" }\n"); printf("\n"); printf(" if (xmlDoc!=null)\n"); printf("\n"); printf(" {\n"); printf("\n"); printf(" xmlDoc.async=false;\n"); printf("\n"); printf(" xmlDoc.load(\"../xml/pacientes.xml\");\n"); printf(" var fname = 0;\n"); printf("\n"); printf("\n"); printf("\n"); printf(" var x=xmlDoc.getElementsByTagName(\"paciente\");\n"); //printf("document.write('</tr>');"); printf("\n"); printf(" for (i=0;i<x.length;i++)\n"); printf("\n"); printf(" { \n"); printf("\n"); printf(" contaLinhas();\n"); printf("\n"); printf("if (!(i %% 2))\n"); printf(" document.write(\"<tr class='par'>\");\n"); printf(" else\n"); printf(" document.write(\"<tr class='impar'>\");\n"); printf("\n"); //printf(" document.write(\"<td></td>\");\n"); printf("\n"); printf(" document.write(\"<td width='50' align='center'>\" + linha + \".</td>\");\n"); printf("\n"); printf(" document.write(\"<td class='link' onClick='showXSL(\" + x[i].getElementsByTagName(\"id\")[0].childNodes[0].nodeValue + \",\" + fname + \")'>\");\n"); printf("\n"); printf(" document.write(x[i].getElementsByTagName(\"nome\")[0].childNodes[0].nodeValue);\n"); printf("\n"); printf(" document.write(\"</td>\");\n"); printf(" document.write(\"<td class='link' align='center' onClick='showXSL(\" + x[i].getElementsByTagName(\"id\")[0].childNodes[0].nodeValue + \",\" + fname + \")'>\");\n"); printf("\n"); printf(" document.write(x[i].getElementsByTagName(\"diaNasc\")[0].childNodes[0].nodeValue + \"/\" + x[i].getElementsByTagName(\"mesNasc\")[0].childNodes[0].nodeValue + \"/\" + x[i].getElementsByTagName(\"anoNasc\")[0].childNodes[0].nodeValue);\n"); printf("\n"); printf(" document.write(\"</td>\");\n"); printf("\n"); printf(" document.write(\"<td class='link' align='center' onClick='showXSL(\" + x[i].getElementsByTagName(\"id\")[0].childNodes[0].nodeValue + \",\" + fname + \")'>\");\n"); printf("\n"); printf(" document.write(x[i].getElementsByTagName(\"diaEntr\")[0].childNodes[0].nodeValue + \"/\" + x[i].getElementsByTagName(\"mesEntr\")[0].childNodes[0].nodeValue + \"/\" + x[i].getElementsByTagName(\"anoEntr\")[0].childNodes[0].nodeValue);\n"); printf("\n"); printf(" document.write(\"</td>\");\n"); printf("\n"); printf(" document.write(\"<td class='link' align='center'>\");\n"); //printf(" var endereco = \"remover.cgi?paciente=\" + (i+1) + \"&uid=%s>\"\n",username); printf(" var endereco = \"remover.cgi?paciente=\" + x[i].getElementsByTagName(\"id\")[0].childNodes[0].nodeValue + \"&uid=%s>\"\n",username); printf(" document.write(\"<a href=\" + endereco + \"Remover\" + \"</a>\");\n"); printf(" document.write(\"</td>\");\n"); printf(" document.write(\"<td class='link' align='center'>\");\n"); //printf(" endereco = \"editar.cgi?paciente=\" + (i+1) + \"&uid=%s>\"\n",username); printf(" endereco = \"editar.cgi?paciente=\" + x[i].getElementsByTagName(\"id\")[0].childNodes[0].nodeValue + \"&uid=%s>\"\n",username); printf(" document.write(\"<a href=\" + endereco + \"Editar\" + \"</a>\");\n"); printf(" document.write(\"</td>\");\n"); printf("\n"); printf("\n"); printf(" document.write(\"</tr>\");\n"); printf("\n"); printf(" }\n"); printf("\n"); printf(" //document.write(\"</table>\");\n"); printf("\n"); printf(" }\n"); printf("\n"); printf("\n"); printf("\n"); printf(" </script>\n"); printf("\n"); printf("</table>\n"); printf("\n"); printf(" </body>\n"); printf("\n"); printf("</html>\n"); printf("\n"); printf("\n"); cgi_end(); return 0; }
int main (void) { //modificaçoes xsltproc char tempname [L_tmpnam]; char comando[100]; char address[100]; //2 de 6 FILE *xsl; //size_t len; //char xmlSearchResultFilePath[FILE_NAME_MAX]; //char healthCenter[HEALTH_CENTER_NAME_MAX]; formvars *first; char *pid; cgi_init(); //modificações xsltproc cgi_init_headers(); fflush(stdout); //3de 6 /****************************************************************************** * READ CONTENT STRING FROM SERVER. * * PROCESS DATA. * * CREATE A LINKED LIST. * ******************************************************************************/ first = cgi_process_form(); /****************************************************************************** * ACQUIRE VALUES CHOSEN BY USER * ******************************************************************************/ pid = cgi_param("pid"); /****************************************************************************** * CREATE XSL SEARCH FILE * ******************************************************************************/ //modificações xsltproc if (tmpnam(tempname) != NULL) { xsl = fopen(tempname, "w"); // 4 de 6 fprintf(xsl,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"); fprintf(xsl,"\r\n"); fprintf(xsl,"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\r\n"); // fprintf(xsl," xmlns:fo=\"http://www.w3.org/1999/XSL/Format\"\r\n"); // fprintf(xsl," xmlns=\"http://www.w3.org/1999/xhtml\">\r\n"); fprintf(xsl,"<xsl:output omit-xml-declaration=\"yes\" encoding=\"ISO-8859-1\" method=\"xml\"/>\r\n"); fprintf(xsl,"\r\n"); getUserPublicPath(address); fprintf(xsl,"<xsl:include href=\"%s/xml/xsl/fullPatientDetails2.xsl\" />\r\n",address); // 5... fprintf(xsl,"\r\n"); fprintf(xsl,"<xsl:template match=\"/\">\r\n"); fprintf(xsl,"\r\n"); fprintf(xsl," \r\n"); fprintf(xsl," <xsl:apply-templates select=\"pacientes\" />\r\n"); fprintf(xsl," \r\n"); fprintf(xsl,"</xsl:template>\r\n"); fprintf(xsl,"\r\n"); fprintf(xsl,"\r\n"); fprintf(xsl,"<xsl:template match=\"pacientes\">\r\n"); fprintf(xsl," <!-- Tags' values -->\r\n"); fprintf(xsl," <xsl:for-each select=\"paciente[@removido = 'nao']\">\r\n"); fprintf(xsl," <xsl:sort select=\"descendant::nomeCompleto\" />\r\n"); fprintf(xsl," <xsl:if test=\"triagem/numeroGeral = '%s'\">\r\n", pid); fprintf(xsl," <table>\r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <th colspan=\"2\">Critério Inicial de Triagem para TB</th>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," <xsl:apply-templates select=\"triagem\" />\r\n"); /* fprintf(xsl," <tr>\r\n"); fprintf(xsl," <td colspan=\"2\" height=\"10\"></td>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," \r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <th colspan=\"2\">Questionário de Custos - Parte A</th>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," <xsl:apply-templates select=\"custosA\" />\r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <td colspan=\"2\" height=\"10\"></td>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," \r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <th colspan=\"2\">Consulta Médica</th>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," <xsl:apply-templates select=\"consultaMedica\" />\r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <td class=\"title3\" colspan=\"2\" height=\"10\"></td>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," \r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <th class=\"title3\" colspan=\"2\">Questionário de Custos - Partes B e C</th>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," <xsl:apply-templates select=\"custosBeC\" />\r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <td class=\"title3\" colspan=\"2\" height=\"10\"></td>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," \r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <th colspan=\"2\">Follow Up - 90 dias</th>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," <xsl:apply-templates select=\"followUp\" />\r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <td colspan=\"2\" height=\"10\"></td>\r\n"); fprintf(xsl," </tr>\r\n"); fprintf(xsl," \r\n"); fprintf(xsl," <tr>\r\n"); fprintf(xsl," <th class=\"title3\">Gráfico de Grupo</th>\r\n"); fprintf(xsl," <td><!--<a href=\"{concat(graficoGrupo, triagem/numeroGeral)}\" target=\"_blank\">Visualizar</a>--></td>\r\n"); fprintf(xsl," </tr>\r\n"); */ fprintf(xsl," </table>\r\n"); fprintf(xsl," <br /><br />\r\n"); fprintf(xsl," </xsl:if>\r\n"); fprintf(xsl," </xsl:for-each>\r\n"); fprintf(xsl," \r\n"); fprintf(xsl,"</xsl:template>\r\n"); fprintf(xsl,"\r\n"); fprintf(xsl,"</xsl:stylesheet>\r\n"); fclose(xsl); //Modificações xsltproc } else printError("Erro ao criar arquivo temporário!\n"); // 5 de 6 /****************************************************************************** * PRINTING RESULT * ******************************************************************************/ //Modificações xsltproc printf("<html>\n"); printf("<head>\n"); printf("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/imprimir.css\" />\n"); printf("\t<title>Versão de Impressão</title>\n"); printf("</head>\n"); printf("<body id=\"result\" onLoad=\"window.print()\">\n"); sprintf(comando,"xsltproc %s xml/pacientesGuadalupe.xml 2>&1",tempname); fflush(stdout); system(comando); sprintf(comando,"rm %s 2>&1",tempname); system(comando); printf("</body>\n"); printf("</html>"); // 6 de 6 /****************************************************************************** * FREE MEMORY AND EXIT * ******************************************************************************/ cgi_end(); return (ok); }
int main(int argc, char *argv[]) { cgi_init(); cgi_process_form(); struct sockaddr_in servaddr, cliaddr; char buf[MAXSIZE]; int sockfd, n; char flush[BUFSIZE]; char str[BUFSIZE]; char local_dir[BUFSIZE] = "/home/xwp/upload/"; int fd; char flag_n; struct stat f_stat; char filename[BUFSIZE]; char scces = 'n'; bzero(flush, sizeof(flush)); bzero(str, sizeof(str)); bzero(filename, sizeof(filename)); if(cgi_param("msg")){ strcpy(str,cgi_param("msg"));} if(cgi_param("video")){ strcpy(filename,cgi_param("video"));} if(cgi_param("Flush")){ strcpy(flush,cgi_param("Flush"));} sockfd = socket(AF_INET, SOCK_STREAM, 0); bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; inet_pton(AF_INET, "127.0.0.1", &servaddr.sin_addr); servaddr.sin_port = htons(SERV_PORT); bzero(&cliaddr, sizeof(cliaddr)); cliaddr.sin_family = AF_INET; cliaddr.sin_addr.s_addr = htonl(INADDR_ANY); cliaddr.sin_port = htons(SERV_PORT + 1); bind(sockfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr)); connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); if(strlen(str) != 0) { flag_n = '1'; write(sockfd, &flag_n, sizeof(flag_n)); read(sockfd, &flag_n, sizeof(flag_n)); if((n = write(sockfd, str, strlen(str))) > 0) { cgi_redirect("../word.html"); cgi_end(); close(sockfd); return 0; } } else if(strlen(filename) != 0) { { flag_n = '2'; write(sockfd, &flag_n, sizeof(flag_n)); read(sockfd, &flag_n, sizeof(flag_n)); strcat(local_dir, filename); write(sockfd, filename, strlen(filename) + 1); read(sockfd, &scces, 1); if(scces != 'y'){ } if(stat(local_dir,&f_stat) == -1){ } write(sockfd, &f_stat.st_size, sizeof(f_stat.st_size)); read(sockfd, &scces, 1); if(scces != 'y'){ } if((fd = open(local_dir, O_RDONLY)) == -1){ } while((n = read(fd, buf, MAXSIZE))){ write(sockfd, buf, n); } cgi_redirect("../upload.html"); } close(fd); cgi_end(); close(sockfd); return 0; } else if(strlen(flush) != 0) { flag_n = '0'; write(sockfd, &flag_n, sizeof(flag_n)); //read(sockfd, &flag_n, sizeof(flag_n)); //if((n = write(sockfd, flush, strlen(flush))) > 0) //{ cgi_redirect("../flash.html"); cgi_end(); close(sockfd); return 0; //} } }
int main(int argc, char **argv) { // FCGI_middle fcgi_middle = FCGI_middle(); int action; int rmID, transID, cmd,get_time; int ret,nums; //nums 总数 int rdroom,rdtransmiter,rdscens; //readroom char rmname[20],transname[20],workday[20]; char rmimage[20],transimage[20]; char newname[20],newimage[20]; char scensname[20]; int state,rdchannel; //state 遥控器状态,rdchannel(0~15) 遥控器通道 char hour[4],min[4]; //hour minute 遥控器设定时间 char *pOutput = NULL; char *timestr; //localtime 时间信息 char *bufstr; //bufstr 情景组中特定房间遥控器信息 char data[20]; char transdata[100]; int times; //查询次数 int count = 0; int exetime; //情景组延时执行时间 /*room's linklist init*/ if((rmhead = Initroom()) == NULL) { //printf("Init error\n"); exit(1); } /*scenraios's linklist init*/ if((scenshead = InitScenarios()) == NULL) { //printf("Init error\n"); exit(1); } //demoHome();//init room while(FCGI_Accept() >= 0) { //cgi init cgi_init(); cgi_process_form(); if((cgi_param("action") == NULL) || (sscanf(cgi_param("action"), "%d", &action) != 1)) { puts("0"); cgi_end(); continue; } printf("Content_type:text/html\r\n"); //头一定要加 printf("\r\n"); //printf("action=%d",action); //printf("rmhead %x\n",rmhead); count++; //0-99调试 switch(action) { case 0: printf("FastCGI hello!"); printf("count=%d ",count); printf("rmhead:%x",rmhead); break; case 100: //delete room if((cgi_param("roomname") != NULL) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) ) { //printf("action=%d,roomname=%s ",action,rmname); //printf("rmhead:%x count=%d ",rmhead,count); ret = Delroom(rmname); if(ret == -1) { pOutput = "0"; } else { pOutput = "1"; } } puts(pOutput); break; case 101://add room if((cgi_param("roomname") != NULL) && (cgi_param("roomimage") != NULL) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("roomimage"), "%s", rmimage) == 1) ) { ret = Addroom(rmname,rmimage); if(ret == -1) // fail to add room { pOutput = "0"; } else if(ret == 1) //the name room is already exist { pOutput = "2"; } else //ret == 0 add room sucess { pOutput = "1"; } } puts(pOutput); break; case 110: //read all rooms num if((cgi_param("readroom") != NULL) && (sscanf(cgi_param("readroom"), "%d", &rdroom) == 1)) { if(rdroom == 1) { nums = Searchroomnums(); sprintf(data,"number=%d",nums); puts(data); nums = 0; } else { puts("0"); } } break; case 111: //read all room's simple information if((cgi_param("readroom") != NULL) && (cgi_param("time") != NULL) && (sscanf(cgi_param("readroom"), "%d", &rdroom) == 1) && (sscanf(cgi_param("time"), "%d", ×) == 1)) { if(rdroom == 0) { struct room *temp; temp = Searchroom(NULL,times); if(temp != NULL) { sprintf(data,"roomname=%s&roomimage=%s", temp->name,temp->image); puts(data); } else { puts("0"); } } else { puts("0"); //printf("rdroom one room's information error"); } } break; case 120://change room's information(newrmname and newrmimage) if((cgi_param("roomname") != NULL) && (cgi_param("newroomname") != NULL) && (cgi_param("newroomimage") != NULL) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("newroomname"), "%s", newname) == 1) && (sscanf(cgi_param("newroomimage"), "%s", newimage) == 1) ) { ret = Changeroominfo(rmname, newname, newimage); if(ret == -1) { pOutput = "0"; //fail to change room's information } else if(ret == 1) { pOutput = "2"; //the newroomname is already exist } else //ret == 0 { pOutput = "1"; //change room's info success } } puts(pOutput); strzero(newname); strzero(newimage); break; case 200: //delete transmiter if((cgi_param("trasname") != NULL) && (cgi_param("roomname") != NULL) && (sscanf(cgi_param("trasname"), "%s", transname) == 1) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) ) { ret = Deltransmiter(rmname,transname); if(ret == -1) { pOutput = "0"; } else { pOutput = "1"; } } puts(pOutput); break; case 201: //add transmiter if((cgi_param("roomname") != NULL) && (cgi_param("trasname") != NULL) && (cgi_param("trasimage") != NULL) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("trasname"), "%s", transname) == 1) && (sscanf(cgi_param("trasimage"), "%s", transimage) == 1)) { ret = Addtransmiter(rmname,transname,transimage); if(ret == -1) { pOutput = "0"; //fail to add transmitter } else if(ret == 1) { pOutput = "2"; //the name transmitter is already exist } else //ret == 0 { pOutput = "1";//add sucess } } puts(pOutput); break; case 202: //save transmitter's channel value if((cgi_param("roomname") != NULL) && (cgi_param("trasname") != NULL) && (cgi_param("channel") != NULL) && (cgi_param("hour") != NULL) && (cgi_param("minute") != NULL) && (cgi_param("workday") != NULL) && (cgi_param("state") != NULL) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("trasname"), "%s", transname) == 1) && (sscanf(cgi_param("channel"), "%d", &rdchannel) == 1) && (sscanf(cgi_param("hour"), "%s", hour) == 1) && (sscanf(cgi_param("minute"), "%s", min) == 1) && (sscanf(cgi_param("workday"), "%s", workday) == 1) && (sscanf(cgi_param("state"), "%d", &state) == 1)) { struct transvalues temp; strzero(&temp); //init temp; strncpy(temp.hour,hour,4); strncpy(temp.minute,min,4); strncpy(temp.workday,workday,20); temp.state = state; ret = Savetransvalue(rmname,transname,rdchannel,&temp); if(ret == -1) { pOutput = "0"; //fail to save channel's value } else //ret == 0 { pOutput = "1";//save success } } puts(pOutput); break; case 210:// 查询单个房间遥控器总数 if((cgi_param("readtransmitter") != NULL) && (cgi_param("roomname") != NULL) && (sscanf(cgi_param("readtransmitter"), "%d", &rdtransmiter) == 1) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1)) { //printf("readroom=%d",rdroom); if(rdtransmiter == 1) { nums = Searchtransnums(rmname); sprintf(data,"number=%d",nums); puts(data); nums = 0; } else { //printf("rdroom all room's num error\n"); puts("0"); } } break; case 211: //read one room's transmiter's simple information if((cgi_param("readtransmitter") != NULL) && (cgi_param("roomname") != NULL) && (cgi_param("time") != NULL) && (sscanf(cgi_param("readtransmitter"), "%d", &rdtransmiter) == 1) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("time"), "%d", ×) == 1)) { if(rdtransmiter == 0) { struct transmiter *temp; if((temp = Searchtransmiter(rmname, NULL,times)) != NULL) { sprintf(data,"trasname=%s&trasimage=%s", temp->name,temp->image); puts(data); } else { puts("0"); } } else { puts("0"); } } break; case 212: //read one transmiter's all information if((cgi_param("readtransmitter") != NULL) && (cgi_param("roomname") != NULL) && (cgi_param("trasname") != NULL) && (cgi_param("channel") != NULL) && (sscanf(cgi_param("readtransmitter"), "%d", &rdtransmiter) == 1) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("trasname"), "%s", transname) == 1) && (sscanf(cgi_param("channel"), "%d", &rdchannel) == 1)) { //printf("roomname=%s transname=%s channel=%d", //rmname,transname,rdchannel); if(rdtransmiter == 2) { struct transvalues *temp; temp = Searchtransvalue(rmname,transname,rdchannel); if(temp != NULL) { strzero(transdata); sprintf(transdata,"hour=%s&minute=%s&workday=%s&state=%d", temp->hour,temp->minute,temp->workday,temp->state); puts(transdata); } else { puts("3"); } } else { puts("0"); } } break; case 220://change transmiter's information(newtransname and newtransimage) if((cgi_param("roomname") != NULL) && (cgi_param("trasname") != NULL) && (cgi_param("newtrasname") != NULL) && (cgi_param("newtrasimage") != NULL) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("trasname"), "%s", transname) == 1) && (sscanf(cgi_param("newtrasname"), "%s", newname) == 1) && (sscanf(cgi_param("newtrasimage"), "%s", newimage) == 1) ) { ret = Changetransmiterinfo(rmname, transname,newname,newimage); //printf("transname=%s&transimage=%s",newtransname,newtransimage); if(ret == -1) { pOutput = "0"; //fail to change information } else if(ret == 1) { pOutput = "2"; //the new name transmitter is already exist } else //ret == 0 { pOutput = "1"; //sucess } } puts(pOutput); strzero(newname); strzero(newimage); break; case 500: //get system's time if((cgi_param("get_time") != NULL) && (sscanf(cgi_param("get_time"), "%d", &get_time) == 1)) { if(get_time == 1) { timestr = getTime(); puts(timestr); } else { puts("0"); } } break; case 600: //delete scenraios if((cgi_param("groupname") != NULL) && (sscanf(cgi_param("groupname"), "%s", scensname) == 1)) { //printf("action=%d,roomname=%s ",action,rmname); //printf("rmhead:%x count=%d ",rmhead,count); ret = DelScenarios(scensname); if(ret == -1) { pOutput = "0"; } else { pOutput = "1"; } } puts(pOutput); break; case 601://add scenraios if((cgi_param("groupname") != NULL) && (sscanf(cgi_param("groupname"), "%s", scensname) == 1)) { ret = AddScenarios(scensname); if(ret == -1) // fail to add scenraios { pOutput = "0"; } else if(ret == 1) //the name scenraios is already exist { pOutput = "2"; } else //ret == 0 add scenraios sucess { pOutput = "1"; } } puts(pOutput); break; case 610: //read all scenraios's num if((cgi_param("read_group") != NULL) && (sscanf(cgi_param("read_group"), "%d", &rdscens) == 1)) { if(rdscens == 0) { nums = Searchscensnums(); sprintf(data,"number=%d",nums); puts(data); nums = 0; } else { puts("0"); } } break; case 611: //read all scensraios's simple information if((cgi_param("read_group") != NULL) && (cgi_param("time") != NULL) && (sscanf(cgi_param("read_group"), "%d", &rdscens) == 1) && (sscanf(cgi_param("time"), "%d", ×) == 1)) { if(rdscens == 1) { struct Scenarios *temp; temp = Searchscens(NULL,times); if(temp != NULL) { sprintf(data,"groupname=%s",temp->name); puts(data); } else { puts("0"); } } else { puts("0"); //printf("rdscens one scenraios's information error"); } } break; case 620://change scenraios's information(newscensname) if((cgi_param("groupname") != NULL) && (cgi_param("newgroupname") != NULL) && (sscanf(cgi_param("groupname"), "%s", scensname) == 1) && (sscanf(cgi_param("newgroupname"), "%s", newname) == 1)) { ret = Changescensinfo(scensname,newname); //printf("rooname=%s&roomimage=%s",newrmname,newrmimage); if(ret == -1) { pOutput = "0"; //fail to change scenraios's information } else if(ret == 1) { pOutput = "2"; //the newname is already exist } else //ret == 0 { pOutput = "1"; //change scenraios's info success } } puts(pOutput); strzero(newname); break; case 700: //delete dev in the scenraios if((cgi_param("trasname") != NULL) && (cgi_param("roomname") != NULL) && (cgi_param("groupname") != NULL) && (sscanf(cgi_param("trasname"), "%s", transname) == 1) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("groupname"), "%s", scensname) == 1)) { ret = Deldevinscens(scensname,rmname,transname); // printf("rooname=%s&roomimage=%s",rmname,rmimage); if(ret == -1) { pOutput = "0"; } else { pOutput = "1"; } } puts(pOutput); break; case 701: //add dev in the scenraios if((cgi_param("trasname") != NULL) && (cgi_param("trasimage") != NULL) && (cgi_param("roomname") != NULL) && (cgi_param("groupname") != NULL) && (sscanf(cgi_param("trasname"), "%s", transname) == 1) && (sscanf(cgi_param("trasimage"), "%s", transimage) == 1) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("groupname"), "%s", scensname) == 1)) { // sprintf(sdata,"roomname=%s&trasname=%s",rmname,transname); ret = ADDdevinscens(scensname,rmname,transname,transimage); if(ret == -1) { pOutput = "0"; //fail to add transmitter } else if(ret == 1) { pOutput = "2"; //the name transmitter is already exist } else //ret == 0 { pOutput = "1";//add sucess } } puts(pOutput); break; case 730: //search room's devs that have been in the scenraios if((cgi_param("roomname") != NULL) && (cgi_param("groupname") != NULL) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("groupname"), "%s", scensname) == 1)) { bufstr = Searchdevinscens(scensname,rmname,1); puts(bufstr); //bufstr=NULL 表示空字符串 //printf("rmname=%s groupname=%s",rmname,scensname); } //puts("1"); break; case 731: //search room's devs that are not in the scenraios if((cgi_param("roomname") != NULL) && (cgi_param("groupname") != NULL) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("groupname"), "%s", scensname) == 1)) { bufstr = Searchdevinscens(scensname,rmname,0); puts(bufstr); //bufstr=NULL 表示空字符串 } break; case 740: //search room's devs that are not in the scenraios if((cgi_param("groupname") != NULL) && (cgi_param("time") != NULL) && (sscanf(cgi_param("groupname"), "%s", scensname) == 1) && (sscanf(cgi_param("time"), "%d", &exetime) == 1)) { struct Scenarios *temp; temp = Searchscens(scensname, 0); if(temp == NULL) { pOutput = "0"; } else { temp->exetime = exetime; //保存前端发送的情景组延时执行时间 pOutput = "1"; } } puts(pOutput); break; /* case 800://单个设备发送命令 if((cgi_param("roomname") != NULL) && (cgi_param("trasname") != NULL) && (cgi_param("cmd") != NULL) && (sscanf(cgi_param("roomname"), "%s", rmname) == 1) && (sscanf(cgi_param("trasname"), "%s", transname) == 1) && (sscanf(cgi_param("cmd"), "%d", &cmd) == 1)) { struct room *rmtemp; struct transmiter * transtemp; //get rmID and transID rmtemp = Searchroom(rmname); transtemp = Searchtransmiter(rmname,transname); rmID = rmtemp->ID; transID = transtemp->ID; printf("rmid:%d,transId:%d\n",rmID,transID); pOutput = fcgi_middle.SendCmd(rmID,transID,cmd); puts(pOutput); } break;*/ default: break; } cgi_end(); } free(rmhead); free(scenshead); return 0; }
int main (void) { char *username; char *password; unsigned returnCode, group; //incluir aceitacao SOMENTE para metodo POST. LibCGI identifica e aceita qualquer metodo cgi_init(); cgi_process_form(); username = cgi_param("username"); password = cgi_param("password"); //se cgi_end viesse aqui teria problema com o username? //a cgi_end libera a memoria alocada, e username eh um ponteiro para uma regiao alocada //porem em uma outra cgi, ao usar cgi_end antes de usar username, o valor de username permaneceu //pq? printf ("Content-type: text/html\r\n"); if (!(returnCode = authenticateUser(username,password,&group))) { /*strncpy(ip,getenv("REMOTE_ADDR"),15); //Creating cookie createCookie(username,cookie,ip); printf("Set-Cookie: %s=%s; path=/",username,cookie);*/ printf("Location: principal.cgi?uid=%s\r\n", username); printf("\r\n"); } /* Mensagem de username ou senha invalido */ else if ((returnCode==WRONG_PASSWORD) || (returnCode==USER_NOT_FOUND) || (returnCode==NULL_POINTER)) { printf("\r\n"); printf ("<html>\n"); printf ("<head>\n"); printf (" <title>Neural TB - Entrar</title>\n"); printf (" <!--<link rel=\"stylesheet\" type=\"text/css\" href=\"css/main.css\">-->\n"); printf (" <link rel=\"stylesheet\" type=\"text/css\" href=\"css/login.css\">\n"); printf (" <script language=javascript src=\"../js/funcoes.js\"></script>\n"); printf (" </head>\n"); printf ("\n"); printf (" <body onLoad=\"login.username.focus()\">\n"); printf (" <div align=\"center\">\n"); printf ("\n"); printf (" <img src=\"../imagens/NeuralTB3.jpg\">\n"); printf (" <br /><br />\n"); printf (" <div class=\"\">\n"); printf (" <table>\n"); printf (" <tr>\n"); printf (" <td style=\"vertical-align:top; padding-top:8px\">\n"); printf (" <form name=\"login\" action=\"login.cgi\" method=\"post\">\n"); printf (" <table border=\"0\">\n"); printf (" <tr>\n"); printf (" <td style=\"text-align:right\">Usuário:</td>\n"); printf (" <td><input name=\"username\" type=\"text\" maxlength=18 ></td>\n"); printf (" </tr>\n"); printf (" <tr>\n"); printf (" <td style=\"text-align:right\">Senha:</td>\n"); printf (" <td><input name=\"password\" type=\"password\" maxlength=18 ></td>\n"); printf (" </tr>\n"); printf (" <tr>\n"); printf (" <td colspan=\"2\" height=\"15\"></td>\n"); printf (" </tr>\n"); printf (" <tr>\n"); printf (" <td></td>\n"); printf (" <td style=\"text-align:right\"><input type=\"submit\" value=\"Entrar\"></td>\n"); printf (" </tr>\n"); if (!(username)||(!password)) { printf (" <tr>\n"); printf (" <td colspan=\"2\" style=\"color:red\">Preencha todos os campos</td>\n"); printf (" </tr>\n"); } else { printf (" <tr>\n"); printf (" <td colspan=\"2\" style=\"color:red\">Usuário e senha nao correspondem</td>\n"); printf (" </tr>\n"); } printf (" </table>\n"); printf (" </form>\n"); printf (" </td>\n"); printf (" <td style=\"padding-left:20px\"><img src=\"../imagens/humanSmallest.jpg\" style=\"z-index:-1\"></td>\n"); printf (" </tr>\n"); printf (" </table>\n"); printf (" </div>\n"); printf ("\n"); printf ("</div>\n"); printf ("</body>\n"); printf ("</html>"); } else { printf("\r\n"); printf("Erro %u", returnCode); } cgi_end(); return 0; }
int main (void) { sqlite3 *db; //char *err = 0; int ret = 0; char **datatable1; char **datatable3; int nRow; int nColumn; char *sql; int i; char *zErrMsg = 0; cgi_init(); cgi_init_headers(); cgi_process_form(); puts("<html><head><title>chaxun</title>"); puts("<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />"); //puts("<link href=\"/Style.css\" rel=\"stylesheet\" type=\"text/css\" />"); puts("</head>"); puts("<body bgColor=#fffff0>"); db = open_db("OAK.db"); sql = sqlite3_mprintf("select * from IpInfo"); ret = sqlite3_get_table(db, sql, &datatable1, &nRow, &nColumn, &zErrMsg); if (ret != SQLITE_OK) { fprintf(stderr, "SQL error: %s\n", zErrMsg); exit(1); } puts("<form action=\"load.cgi\">"); puts("<table width='70%' align='left' border=1 border-coer=#000066>"); puts("<tr><td width='20%'>"); puts("<select NAME = \"ip\">"); puts("<option value = \"\"> 选择IP</option> "); if (!(0 == nRow && 0 == nColumn)) { for (i = 1; i <= nRow*nColumn ; i += nColumn ) { printf("<option value = \"%s\"", datatable1[i]); if (cgi_param("company")) { if (0 == strncmp(cgi_param("ip"), datatable1[i],strlen(datatable1[i]))) printf("SELECTED"); } printf("> %s </option> ", datatable1[i]); } } puts("</select>"); puts("</td>"); puts("<td>"); puts("<input type=\"submit\" value=\"上传\" name=\"action\" >"); puts("</td></tr></table>"); sql = sqlite3_mprintf("select R.R_id,R.R_name,R.R_flag,C.C_name from ResInfo R left join CompanyInfo C on R.C_id = C.C_id;"); puts("<br />"); puts("<br />"); ret = sqlite3_get_table(db, sql, &datatable3, &nRow, &nColumn, &zErrMsg); if (ret != SQLITE_OK) { fprintf(stderr, "SQL error: %s\n", zErrMsg); exit(1); } puts("<table width='70%' align='left' border=1>"); puts("<tr><td style=\"width:50px\" align=center>选择</td>"); puts("<td style=\"width:150px\" align=center>媒体名称</td>"); puts("<td style=\"width:120px\" align=center>媒体类型</td>"); puts("<td style=\"width:170px\" align=center>所属公司</td>"); puts("</tr>"); if (!(0 == nRow && 0 == nColumn)) { for (i = 4; i <= nRow*nColumn ; i += nColumn ) { puts("<tr><td align='center'><input type = 'checkbox' name='xuanqu' "); printf(" value=%s />", datatable3[i+0]); puts("</td>"); printf("<td>%s</td>", datatable3[i+1]); if(atoi(datatable3[i+2]) == 0){ printf("<td>视频文件</td>"); } else { printf("<td>图片文件</td>"); } printf("<td>%s</td></tr>",datatable3[i+3]); } } puts("</table>"); puts("</form>"); puts("</body></html>"); cgi_end(); return 0; }