/* template.c */ #include #include #include #include #include #include #include #include "cgivars.h" #include "htmllib.h" #include #define DEBUG 0 #define DELIM "|" #define DELIM_COMMA "," #define SHMSZ 5 void print_tree(); void Reload_tree(); // void stripnl(char *str); int paging_ctl_template_page(char **postvars, int form_method) { int i,j=0; int fd,num; FILE *fp,*fp1; size_t length; char *line,*mode,*type,*eu_list,*warnmsg_type,*submit_status; int shmid; key_t key; char *shm, *s; // void *shm1 // shm = malloc(5 * sizeof(char)); key = 8888; if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) { perror("shmget"); exit(1); } if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) { perror("shmat"); exit(1); } fflush(stdin); warnmsg_type = (char *)ConfigParser_Warnmsg("warnmsg"); num = atoi(warnmsg_type); submit_status = (char *)ConfigParser_Warnmsg("submit_status"); // mode = (char *)ConfigParser_FD("mode"); mode = (char *)ConfigParser_FD(3); type = (char *)ConfigParser_Paging("type_txt"); if(form_method == POST) { // printf("
  • DEBUG: [%s] = [%s]\n", postvars[i], postvars[i+1]); int pid; #if 1 //for (i=0; postvars[i]; i+= 2) { fp1=fopen ("/etc/config/warnmsg","w"); for (i=0;postvars[i];i++) { if(!strcmp(postvars[i],"temp")) { break; } if(!strcmp(postvars[i],"EULIST")) { fp=fopen ("/etc/config/SelectedEntity","w"); fprintf(fp,"Paging List\n"); i++; char temp[512]; char *sep = (char *)strtok(postvars[i], DELIM); while (sep != NULL) { fprintf(fp,"%s\n",sep); sep = (char *)strtok(NULL, DELIM); } fclose(fp); continue; } if(!strcmp(postvars[i],"ITEM_CHECKED")) { i++; if(!strcmp(postvars[i],"0")) continue; fp=fopen ("/etc/config/checked","w"); fprintf(fp,"Checked Items\n"); char *sep = (char *)strtok(postvars[i], DELIM); while (sep != NULL) { fprintf(fp,"%s\n",sep); sep = (char *)strtok(NULL, DELIM); } fclose(fp); continue; } // line=strdup(postvars[i]); // i++; // strcat(line,"="); // fprintf(fp,"%s",line); // fprintf(fp,"%s\n",postvars[i]); if(!strcmp(postvars[i],"submit_status")) { // mode = (char *)ConfigParser_Paging("operation"); fprintf(fp1,"%s",postvars[i]); fprintf(fp1,"="); i++; fprintf(fp1,"%s\n",postvars[i]); continue; } if(!strcmp(postvars[i],"warnmsg")) { fprintf(fp1,"%s",postvars[i]); fprintf(fp1,"="); i++; fprintf(fp1,"%s\n",postvars[i]); continue; } fflush(stdin); } fclose(fp1); warnmsg_type = (char *)ConfigParser_Warnmsg("warnmsg"); num = atoi(warnmsg_type); submit_status = (char *)ConfigParser_Warnmsg("submit_status"); // mode = (char *)ConfigParser_FD("mode"); mode = (char *)ConfigParser_FD(3); type = (char *)ConfigParser_Paging("type_txt"); if(!strcmp(submit_status,"startpaging")) { //START PAGING // printf("%d \n",num); char msg[4]; strcpy(msg,"4"); strcat(msg,warnmsg_type); // printf("%s \n",msg); strcpy(shm,msg); // strcpy(shm,"1"); // if(!strcmp(warnmsg_type,"warnmsg1")) // strcpy(shm,"41"); // else if(!strcmp(warnmsg_type,"warnmsg2")) // strcpy(shm,"42"); // else if(!strcmp(warnmsg_type,"warnmsg3")) // strcpy(shm,"43"); // else if(!strcmp(warnmsg_type,"warnmsg4")) // strcpy(shm,"44"); // else if(!strcmp(warnmsg_type,"warnmsg5")) // strcpy(shm,"45"); // else if(!strcmp(warnmsg_type,"warnmsg6")) // strcpy(shm,"46"); // else if(!strcmp(warnmsg_type,"warnmsg7")) // strcpy(shm,"47"); // else if(!strcmp(warnmsg_type,"warnmsg8")) // strcpy(shm,"48"); // printf("shared value: %c\n",*shm); } if(!strcmp(submit_status,"stoppaging")) { //STOP PAGING strcpy(shm,"50"); system("rm /etc/config/checked"); // printf("shared value: %c\n",*shm); } if(!strcmp(submit_status,"startrecord")) { char msg[4]; strcpy(msg,"1"); strcat(msg,warnmsg_type); // printf("%s \n",msg); strcpy(shm,msg); /* if(!strcmp(warnmsg_type,"warnmsg1")) strcpy(shm,"11"); else if(!strcmp(warnmsg_type,"warnmsg2")) strcpy(shm,"12"); else if(!strcmp(warnmsg_type,"warnmsg3")) strcpy(shm,"13"); else if(!strcmp(warnmsg_type,"warnmsg4")) strcpy(shm,"14"); else if(!strcmp(warnmsg_type,"warnmsg5")) strcpy(shm,"15"); else if(!strcmp(warnmsg_type,"warnmsg6")) strcpy(shm,"16"); else if(!strcmp(warnmsg_type,"warnmsg7")) strcpy(shm,"17"); else if(!strcmp(warnmsg_type,"warnmsg8")) strcpy(shm,"18");*/ } if(!strcmp(submit_status,"stoprecord")) { char msg[4]; strcpy(msg,"2"); strcat(msg,warnmsg_type); // printf("%s \n",msg); strcpy(shm,msg); /* if(!strcmp(warnmsg_type,"warnmsg1")) strcpy(shm,"21"); else if(!strcmp(warnmsg_type,"warnmsg2")) strcpy(shm,"22"); else if(!strcmp(warnmsg_type,"warnmsg3")) strcpy(shm,"23"); else if(!strcmp(warnmsg_type,"warnmsg4")) strcpy(shm,"24"); else if(!strcmp(warnmsg_type,"warnmsg5")) strcpy(shm,"25"); else if(!strcmp(warnmsg_type,"warnmsg6")) strcpy(shm,"26"); else if(!strcmp(warnmsg_type,"warnmsg7")) strcpy(shm,"27"); else if(!strcmp(warnmsg_type,"warnmsg8")) strcpy(shm,"28");*/ } if(!strcmp(submit_status,"play")) { // printf("%d \n",num); char msg[4]; strcpy(msg,"3"); strcat(msg,warnmsg_type); // printf("%s \n",msg); strcpy(shm,msg); /* if(!strcmp(warnmsg_type,"warnmsg1")) strcpy(shm,"31"); else if(!strcmp(warnmsg_type,"warnmsg2")) strcpy(shm,"32"); else if(!strcmp(warnmsg_type,"warnmsg3")) strcpy(shm,"33"); else if(!strcmp(warnmsg_type,"warnmsg4")) strcpy(shm,"34"); else if(!strcmp(warnmsg_type,"warnmsg5")) strcpy(shm,"35"); else if(!strcmp(warnmsg_type,"warnmsg6")) strcpy(shm,"36"); else if(!strcmp(warnmsg_type,"warnmsg7")) strcpy(shm,"37"); else if(!strcmp(warnmsg_type,"warnmsg8")) strcpy(shm,"38");*/ } #endif } /* printf("
    "); printf(" \n"); printf(" \n",eulist); printf(""); printf("
    "); printf(""); printf("
    "); */ // eu_list = (char *)ConfigParser("EULIST"); #if 1 if(!strcmp(mode,"MasterGuard")) printf("Paging Control Panel : Talk-A-Phone Co.",atoi((char *)ConfigParser_Paging("Master_PL_Time"))); if(!strcmp(mode,"ZoneGuard") && (!strcmp(type,"Small"))) printf("Paging Control Panel : Talk-A-Phone Co.",atoi((char *)ConfigParser_Paging("Zone_PL_Time"))); printf(""); printf("
    ","/cgi-bin/paging_ctl.cgi"); printf("\n"); // printf("\n"); printf(" \n"); printf(" \n"); // printf(" \n",num); printf(" \n",num); printf(" \n",'%','%'); // printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n",'%'); printf(" \n"); printf(" \n"); printf(" \n"); /* if(*shm == '1') printf(" \n",'%'); else printf(" \n",'%');*/ // printf(" \n"); // printf(" \n"); // printf(" \n"); // printf(" \n"); printf("
    Paging Control Panel
    Select Message Type: "); printf("
        "); printf(" \n"); // if(!strcmp(type,"Small")) // printf(" \n"); if(!strcmp(submit_status,"startrecord")) printf(" "); else printf(" "); if(!strcmp(submit_status,"startrecord")) printf("          "); else printf("          "); printf("
    Select Paging Entities: "); printf("
    \n"); printf("
    \n"); printf("
    \n"); printf("
    \n"); if(!strcmp(submit_status,"startrecord")) printf("          "); else { if (!strcmp(submit_status,"startpaging")) printf("          "); else printf("          "); } printf("
             
    \n"); printf("
    "); printf("
    \n"); printf("\n"); printf("\n"); #endif return 0; } void print_tree() { printf("function Pager()\n"); printf("{\n"); printf(" if(!(document.getElementById(\"tree_table\"))) \n"); printf(" {\n"); printf(" Initialise();\n"); printf(" l0 = CreateTreeItem( rootCell, \"Paging Entities\",\"joinmiddle.gif\", \"0\" );\n"); Generate_tree(); // if (Generate_tree() == 1) // printf("alert(\"Problem Occured. Please contact Administrator.\");\n"); printf(" }\n"); printf(" else\n"); printf(" {\n"); printf(" document.getElementById(\"tree_id\").style.display = 'block'; \n"); printf(" }\n"); // printf(" var div_c=document.getElementById(\"CHost1\"); \n"); // printf(" div_c.checked = true; \n"); // printf(" Parent_PerfomRecursive(\"Host1\"); \n"); // printf(" var div_c=document.getElementById(\"CHost2\"); \n"); // printf(" div_c.checked = true; \n"); // printf(" Parent_PerfomRecursive(\"Host2\"); \n"); Reload_tree(); // printf(" Toggle(\"Paging Entities\");\n"); printf("}\n"); } void Reload_tree() { char line[1024]; FILE *infile; if((infile = fopen("/etc/config/checked", "r")) == NULL) { return; } fgets(line, 1024, infile); printf(" var div; \n"); while(fgets(line, 1024, infile) != NULL) { char *sep = (char *)strtok(line, DELIM_COMMA); stripnl(sep); printf(" flag_reload = 1; \n"); printf(" div=document.getElementById(\"C%s\"); \n",sep); printf(" div.checked = true; \n"); printf(" Parent_PerfomRecursive(\"%s\"); \n",sep); } } // void stripnl(char *str) // { // while(strlen(str) && ( (str[strlen(str) - 1] == 13) || ( str[strlen(str) - 1] == 10 ))) // { // str[strlen(str) - 1] = 0; // } // }