Changeset 7410
- Timestamp:
- 09/10/12 20:51:02 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-webif.c
r7409 r7410 207 207 } 208 208 209 static void webif_save_config(char *section, struct templatevars *vars, struct uriparams *params) { 210 if (!streq(getParam(params, "action"), "execute")) 211 return; 212 if (cfg.http_readonly) { 213 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 214 return; 215 } 216 int i; 217 int cnt = (*params).paramcount; 218 for (i = 0; i < cnt; i++) { 219 char *token = (*params).params[i]; 220 char *value = (*params).values[i]; 221 if (!streq(token, "part") && !streq(token, "action")) 222 config_set(section, token, value); 223 } 224 if (write_config() == 0) { 225 tpl_addMsg(vars, "Configuration was saved. You should restart OSCam now."); 226 enum refreshtypes ref_type = REFR_SERVER; 227 if (streq(getParam(params, "part"), "anticasc")) 228 ref_type = REFR_ANTICASC; 229 refresh_oscam(ref_type); 230 } else { 231 tpl_addMsg(vars, "ERROR: Failed to write config file!!!"); 232 } 233 } 234 209 235 static char *send_oscam_config_global(struct templatevars *vars, struct uriparams *params) { 210 int32_t i;211 212 236 setActiveSubMenu(vars, MNU_CFG_GLOBAL); 213 237 214 if (strcmp(getParam(params, "action"), "execute") == 0) { 215 if(cfg.http_readonly) { 216 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 217 } else { 218 for(i = 0; i < (*params).paramcount; ++i) { 219 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 220 //we use the same function as used for parsing the config tokens 221 config_set("global", (*params).params[i], (*params).values[i]); 222 } 223 } 224 tpl_addMsg(vars, "Configuration Global done. You should restart OSCam now."); 225 if(write_config()==0) refresh_oscam(REFR_SERVER); 226 else tpl_addMsg(vars, "Write Config failed!"); 227 } 228 } 238 webif_save_config("global", vars, params); 239 229 240 if (IP_ISSET(cfg.srvip)) 230 241 tpl_addVar(vars, TPLADD, "SERVERIP", cs_inet_ntoa(cfg.srvip)); … … 315 326 #ifdef WITH_LB 316 327 static char *send_oscam_config_loadbalancer(struct templatevars *vars, struct uriparams *params) { 317 int32_t i;318 319 328 setActiveSubMenu(vars, MNU_CFG_LOADBAL); 320 329 … … 351 360 } 352 361 353 if (strcmp(getParam(params, "action"),"execute") == 0) { 354 if(cfg.http_readonly) { 355 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 356 } else { 357 for(i = 0; i < (*params).paramcount; ++i) { 358 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 359 //we use the same function as used for parsing the config tokens 360 config_set("global", (*params).params[i], (*params).values[i]); 361 } 362 } 363 tpl_addMsg(vars, "Configuration Loadbalancer done."); 364 if(write_config()==0) refresh_oscam(REFR_SERVER); 365 else tpl_addMsg(vars, "Write Config failed!"); 366 } 367 } 362 webif_save_config("global", vars, params); 368 363 369 364 tpl_printf(vars, TPLADD, "TMP", "LBMODE%d", cfg.lb_mode); … … 408 403 setActiveSubMenu(vars, MNU_CFG_CAMD33); 409 404 410 if (strcmp(getParam(params, "action"), "execute") == 0) { 411 if(cfg.http_readonly) { 412 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 413 } else { 414 for(i = 0; i < (*params).paramcount; ++i) { 415 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 416 //we use the same function as used for parsing the config tokens 417 config_set("camd33", (*params).params[i], (*params).values[i]); 418 } 419 } 420 tpl_addMsg(vars, "Configuration camd33 done. You should restart OSCam now."); 421 if(write_config()==0) refresh_oscam(REFR_SERVER); 422 else tpl_addMsg(vars, "Write Config failed!"); 423 } 424 } 405 webif_save_config("camd33", vars, params); 425 406 426 407 if (cfg.c33_port) { … … 441 422 #ifdef MODULE_CAMD35 442 423 static char *send_oscam_config_camd35(struct templatevars *vars, struct uriparams *params) { 443 int32_t i;444 445 424 setActiveSubMenu(vars, MNU_CFG_CAMD35); 446 425 447 if (streq(getParam(params, "action"),"execute")) { 448 if(cfg.http_readonly) { 449 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 450 } else { 451 for(i = 0; i < (*params).paramcount; ++i) { 452 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 453 //we use the same function as used for parsing the config tokens 454 config_set("cs357x", (*params).params[i], (*params).values[i]); 455 } 456 } 457 tpl_addMsg(vars, "Configuration camd35 done. You should restart OSCam now."); 458 if(write_config()==0) refresh_oscam(REFR_SERVER); 459 else tpl_addMsg(vars, "Write Config failed!"); 460 } 461 } 426 webif_save_config("cs357x", vars, params); 462 427 463 428 if (cfg.c35_port) { … … 476 441 #ifdef MODULE_CAMD35_TCP 477 442 static char *send_oscam_config_camd35tcp(struct templatevars *vars, struct uriparams *params) { 478 int32_t i;479 480 443 setActiveSubMenu(vars, MNU_CFG_CAMD35TCP); 481 444 482 if (streq(getParam(params, "action"),"execute")) { 483 if(cfg.http_readonly) { 484 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 485 } else { 486 for(i = 0; i < (*params).paramcount; ++i) { 487 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 488 //we use the same function as used for parsing the config tokens 489 config_set("cs378x", (*params).params[i], (*params).values[i]); 490 } 491 } 492 tpl_addMsg(vars, "Configuration camd35 TCP done. You should restart OSCam now."); 493 if(write_config()==0) refresh_oscam(REFR_SERVER); 494 else tpl_addMsg(vars, "Write Config failed!"); 495 } 496 } 445 webif_save_config("cs378x", vars, params); 497 446 498 447 if ((cfg.c35_tcp_ptab.nports > 0) && (cfg.c35_tcp_ptab.ports[0].s_port > 0)) { … … 514 463 #ifdef CS_CACHEEX 515 464 static char *send_oscam_config_csp(struct templatevars *vars, struct uriparams *params) { 516 int32_t i;517 518 465 setActiveSubMenu(vars, MNU_CFG_CSP); 519 466 520 if (streq(getParam(params, "action"),"execute")) { 521 if(cfg.http_readonly) { 522 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 523 } else { 524 for(i = 0; i < (*params).paramcount; ++i) { 525 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 526 //we use the same function as used for parsing the config tokens 527 config_set("csp", (*params).params[i], (*params).values[i]); 528 } 529 } 530 tpl_addMsg(vars, "Configuration CSP done. You should restart OSCam now."); 531 if(write_config()==0) refresh_oscam(REFR_SERVER); 532 else tpl_addMsg(vars, "Write Config failed!"); 533 } 534 } 467 webif_save_config("csp", vars, params); 535 468 536 469 if (IP_ISSET(cfg.csp_srvip)) … … 553 486 setActiveSubMenu(vars, MNU_CFG_NEWCAMD); 554 487 555 if (strcmp(getParam(params, "action"),"execute") == 0) { 556 if(cfg.http_readonly) { 557 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 558 } else { 559 for(i = 0; i < (*params).paramcount; ++i) { 560 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 561 //we use the same function as used for parsing the config tokens 562 config_set("newcamd", (*params).params[i], (*params).values[i]); 563 } 564 } 565 tpl_addMsg(vars, "Configuration Newcamd done. You should restart OSCam now."); 566 if(write_config()==0) refresh_oscam(REFR_SERVER); 567 else tpl_addMsg(vars, "Write Config failed!"); 568 } 569 } 488 webif_save_config("newcamd", vars, params); 570 489 571 490 if ((cfg.ncd_ptab.nports > 0) && (cfg.ncd_ptab.ports[0].s_port > 0)) { … … 595 514 #ifdef MODULE_RADEGAST 596 515 static char *send_oscam_config_radegast(struct templatevars *vars, struct uriparams *params) { 597 int32_t i;598 599 516 setActiveSubMenu(vars, MNU_CFG_RADEGAST); 600 517 601 if (strcmp(getParam(params, "action"),"execute") == 0) { 602 if(cfg.http_readonly) { 603 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 604 } else { 605 for(i = 0; i < (*params).paramcount; ++i) { 606 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 607 //we use the same function as used for parsing the config tokens 608 config_set("radegast", (*params).params[i], (*params).values[i]); 609 } 610 } 611 tpl_addMsg(vars, "Configuration Radegast done. You should restart OSCam now."); 612 if(write_config()==0) refresh_oscam(REFR_SERVER); 613 else tpl_addMsg(vars, "Write Config failed!"); 614 } 615 } 518 webif_save_config("radegast", vars, params); 519 616 520 tpl_printf(vars, TPLADD, "PORT", "%d", cfg.rad_port); 617 521 if (IP_ISSET(cfg.rad_srvip)) … … 641 545 } 642 546 643 int32_t i; 644 if (strcmp(getParam(params, "action"),"execute") == 0) { 645 if(cfg.http_readonly) { 646 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 647 } else { 648 for(i = 0; i < (*params).paramcount; ++i) { 649 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 650 //we use the same function as used for parsing the config tokens 651 config_set("cccam", (*params).params[i], (*params).values[i]); 652 } 653 } 654 tpl_addMsg(vars, "Configuration CCCam done. You should restart OSCam now."); 655 if(write_config()==0) refresh_oscam(REFR_SERVER); 656 else tpl_addMsg(vars, "Write Config failed!"); 657 cc_update_nodeid(); 658 } 659 } 547 webif_save_config("cccam", vars, params); 548 549 if (streq(getParam(params, "action"), "execute") && !cfg.http_readonly) 550 cc_update_nodeid(); 660 551 661 552 char *value = mk_t_cccam_port(); … … 850 741 #ifdef MODULE_SERIAL 851 742 static char *send_oscam_config_serial(struct templatevars *vars, struct uriparams *params) { 852 int32_t i;853 854 743 setActiveSubMenu(vars, MNU_CFG_SERIAL); 855 744 856 char *saveptr1 = NULL; 857 if (strcmp(getParam(params, "action"),"execute") == 0) { 858 if(cfg.http_readonly) { 859 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 860 } else { 861 for(i = 0; i < (*params).paramcount; ++i) { 862 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 863 //we use the same function as used for parsing the config tokens 864 config_set("serial", (*params).params[i], (*params).values[i]); 865 } 866 } 867 tpl_addMsg(vars, "Configuration Serial done. You should restart OSCam now."); 868 if(write_config()==0) refresh_oscam(REFR_SERVER); 869 else tpl_addMsg(vars, "Write Config failed!"); 870 } 871 } 745 webif_save_config("serial", vars, params); 872 746 873 747 if (cfg.ser_device) { 874 748 char sdevice[strlen(cfg.ser_device)]; 875 749 cs_strncpy(sdevice, cfg.ser_device, sizeof(sdevice)); 876 char *ptr ;750 char *ptr, *saveptr1 = NULL; 877 751 char delimiter[2]; delimiter[0] = 1; delimiter[1] = '\0'; 878 752 for(ptr = strtok_r(sdevice, delimiter, &saveptr1); ptr; ptr = strtok_r(NULL, delimiter, &saveptr1)){ … … 895 769 setActiveSubMenu(vars, MNU_CFG_DVBAPI); 896 770 897 if (strcmp(getParam(params, "action"),"execute") == 0) { 898 if(cfg.http_readonly) { 899 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 900 } else { 901 for(i = 0; i < (*params).paramcount; ++i) { 902 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 903 //we use the same function as used for parsing the config tokens 904 config_set("dvbapi", (*params).params[i], (*params).values[i]); 905 } 906 } 907 tpl_addMsg(vars, "Configuration DVB Api done. You should restart OSCam now."); 908 if(write_config()==0) refresh_oscam(REFR_SERVER); 909 else tpl_addMsg(vars, "Write Config failed!"); 910 } 911 } 771 webif_save_config("dvbapi", vars, params); 912 772 913 773 if (cfg.dvbapi_enabled > 0) … … 944 804 #ifdef CS_ANTICASC 945 805 static char *send_oscam_config_anticasc(struct templatevars *vars, struct uriparams *params) { 946 int32_t i;947 948 806 setActiveSubMenu(vars, MNU_CFG_ANTICASC); 949 807 950 if (strcmp(getParam(params, "action"),"execute") == 0) { 951 if(cfg.http_readonly) { 952 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 953 } else { 954 for(i = 0; i < (*params).paramcount; ++i) { 955 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 956 //we use the same function as used for parsing the config tokens 957 config_set("anticasc", (*params).params[i], (*params).values[i]); 958 } 959 } 960 tpl_addMsg(vars, "Configuration Anticascading done."); 961 refresh_oscam(REFR_ANTICASC); 962 if(write_config()!=0) tpl_addMsg(vars, "Write Config failed!"); 963 } 964 } 808 webif_save_config("anticasc", vars, params); 809 965 810 if (cfg.ac_enabled > 0) tpl_addVar(vars, TPLADD, "CHECKED", "checked"); 966 811 tpl_printf(vars, TPLADD, "NUMUSERS", "%d", cfg.ac_users);
Note:
See TracChangeset
for help on using the changeset viewer.