Changeset 7225
- Timestamp:
- 07/30/12 22:37:42 (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-webif-lib.c
r7224 r7225 60 60 } 61 61 return tmp; 62 } 63 64 /* Adds a message to be output on the page using the TPLMESSAGE template. */ 65 char *tpl_addMsg(struct templatevars *vars, char *value){ 66 tpl_addVar(vars, TPLADDONCE, "MESSAGE", value); 67 (*vars).messages++; 68 return tpl_addVar(vars, TPLAPPEND, "MESSAGES", tpl_getTpl(vars, "MESSAGEBIT")); 62 69 } 63 70 … … 339 346 varname[pch - pch2 - 2] = '\0'; 340 347 if(strncmp(varname, "TPL", 3) == 0){ 341 pch2 = tpl_getTpl(vars, varname + 3); 348 if((*vars).messages > 0 || strncmp(varname, "TPLMESSAGE", 10) != 0) 349 pch2 = tpl_getTpl(vars, varname + 3); 350 else pch2 = ""; 342 351 } else { 343 352 pch2 = tpl_getVar(vars, varname); -
trunk/module-webif-pages.c
r7221 r7225 99 99 "DIV.log {border:1px dotted #AAAAAA; background-color: #FAFAFA; padding:10px; font-family:\"Courier New\", monospace; color:#666666; font-size: 11px; word-wrap:break-word; text-align:left; }\n" 100 100 "DIV.sidlist {border:1px dotted #AAAAAA; background-color: #fffdf5; padding:2px; font-family:\"Courier New\", monospace ; color:#666666; font-size: 11px; word-wrap:break-word; text-align:left;}\n" 101 "DIV.message { position:absolute;right:0;font-family: Arial; font-size: 12px;font-weight:bold;}\n"101 "DIV.message {font-family: Arial; font-size: 12px;font-weight:bold;}\n" 102 102 "DIV.div_notifier {height:14px;width:14px;border-radius:7px;-webkit-border-radius:7px;background-color:red;margin-left:4px;text-align:center;float:right;}\n" 103 103 "DIV.debugmenu {line-height: 20px;}\n" … … 410 410 ##TPLMENU##\ 411 411 ##TPLFILEMENU##\n\ 412 ##TPLMESSAGE##\ 412 413 <DIV CLASS=\"debugmenu\">##SDEBUG##</DIV>\ 413 414 <DIV CLASS=\"logmenu\">##LOGMENU##</DIV>\ … … 448 449 ##TPLHEADER##\ 449 450 ##TPLMENU##\ 451 ##TPLMESSAGE##\ 450 452 <TABLE border=0 class=\"configmenu\">\n\ 451 453 <TR>\n\ … … 684 686 ##TPLHEADER##\ 685 687 ##TPLMENU##\ 686 ## MESSAGE##\688 ##TPLMESSAGE##\ 687 689 <TABLE CLASS=\"configmenu\">\n\ 688 690 <TR>\n\ … … 825 827 ##TPLHEADER##\ 826 828 ##TPLMENU##\ 827 <DIV CLASS=\"message\">##MESSAGE##</DIV>\829 ##TPLMESSAGE##\ 828 830 <BR><BR>\n\ 829 831 <form action=\"user_edit.html\" method=\"get\">\n\ … … 982 984 ##TPLHEADER##\ 983 985 ##TPLMENU##\ 986 ##TPLMESSAGE##\ 984 987 <TABLE CLASS=\"configmenu\"><TR><TD CLASS=\"configmenu\"><A HREF=\"scanusb.html\">Scan USB</A></TD><TD CLASS=\"configmenu\"><A TARGET=\"_blank\" HREF=\"graph.svg?type=servers\">Show Graphs</A></TD></TR></TABLE>\n\ 985 988 <form action=\"readerconfig.html\" method=\"get\">\n\ … … 1055 1058 ##TPLHEADER##\ 1056 1059 ##TPLMENU##\ 1057 <DIV CLASS=\"message\">##MESSAGE##</DIV>\1060 ##TPLMESSAGE##\ 1058 1061 <TABLE border=0 class=\"configmenu\">\n\ 1059 1062 <TR>\n\ … … 1091 1094 ##TPLHEADER##\ 1092 1095 ##TPLMENU##\ 1093 <DIV CLASS=\"message\">##MESSAGE##</DIV>\1096 ##TPLMESSAGE##\ 1094 1097 <BR><BR>\n\ 1095 1098 <TABLE cellpadding=\"10\">\n\ … … 1104 1107 ##TPLHEADER##\ 1105 1108 ##TPLMENU##\ 1106 <DIV CLASS=\"message\">##MESSAGE##</DIV>\1109 ##TPLMESSAGE##\ 1107 1110 <BR><BR>Entitlements for ##READERNAME##<BR><BR>\n\ 1108 1111 ##ENTITLEMENTCONTENT##\ … … 1186 1189 ##TPLHEADER##\ 1187 1190 ##TPLMENU##\ 1188 <BR><BR>\n\ 1189 ##MESSAGE##\n\ 1191 ##TPLMESSAGE##\n\ 1190 1192 <form action=\"readerconfig.html?action=execute\" method=\"get\">\n\ 1191 1193 <input name=\"label\" type=\"hidden\" value=\"##READERNAME##\">\n\ … … 1386 1388 ##TPLMENU##\ 1387 1389 ##TPLCONFIGMENU##\ 1388 <DIV CLASS=\"message\">##MESSAGE##</DIV>\1390 ##TPLMESSAGE##\ 1389 1391 <form action=\"config.html\" method=\"get\">\n\ 1390 1392 <input name=\"part\" type=\"hidden\" value=\"gbox\">\n\ … … 1408 1410 ##TPLMENU##\ 1409 1411 ##TPLCONFIGMENU##\ 1410 ## MESSAGE##\1412 ##TPLMESSAGE##\ 1411 1413 <form action=\"config.html\" method=\"get\">\n\ 1412 1414 <input name=\"part\" type=\"hidden\" value=\"anticasc\">\n\ … … 1442 1444 ##TPLMENU##\ 1443 1445 ##TPLCONFIGMENU##\ 1444 ## MESSAGE##\1446 ##TPLMESSAGE##\ 1445 1447 <form action=\"config.html\" method=\"get\">\n\ 1446 1448 <input name=\"part\" type=\"hidden\" value=\"cccam\">\n\ … … 1520 1522 ##TPLMENU##\ 1521 1523 ##TPLCONFIGMENU##\ 1522 ## MESSAGE##\1524 ##TPLMESSAGE##\ 1523 1525 <form action=\"config.html\" method=\"get\">\n\ 1524 1526 <input name=\"part\" type=\"hidden\" value=\"monitor\">\n\ … … 1596 1598 ##TPLMENU##\ 1597 1599 ##TPLCONFIGMENU##\ 1598 ## MESSAGE##\1600 ##TPLMESSAGE##\ 1599 1601 <form action=\"config.html\" method=\"get\">\n\ 1600 1602 <input name=\"part\" type=\"hidden\" value=\"radegast\">\n\ … … 1617 1619 ##TPLMENU##\ 1618 1620 ##TPLCONFIGMENU##\ 1619 ## MESSAGE##\1621 ##TPLMESSAGE##\ 1620 1622 <form action=\"config.html\" method=\"get\">\n\ 1621 1623 <input name=\"part\" type=\"hidden\" value=\"newcamd\">\n\ … … 1641 1643 ##TPLMENU##\ 1642 1644 ##TPLCONFIGMENU##\ 1643 ## MESSAGE##\1645 ##TPLMESSAGE##\ 1644 1646 <form action=\"config.html\" method=\"get\">\n\ 1645 1647 <input name=\"part\" type=\"hidden\" value=\"global\">\n\ … … 1729 1731 ##TPLMENU##\ 1730 1732 ##TPLCONFIGMENU##\ 1731 ## MESSAGE##\1733 ##TPLMESSAGE##\ 1732 1734 <form action=\"config.html\" method=\"get\">\n\ 1733 1735 <input name=\"part\" type=\"hidden\" value=\"loadbalancer\">\n\ … … 1787 1789 ##TPLMENU##\ 1788 1790 ##TPLCONFIGMENU##\ 1789 ## MESSAGE##\1791 ##TPLMESSAGE##\ 1790 1792 <form action=\"config.html\" method=\"get\">\n\ 1791 1793 <input name=\"part\" type=\"hidden\" value=\"camd33\">\n\ … … 1809 1811 ##TPLMENU##\ 1810 1812 ##TPLCONFIGMENU##\ 1811 ## MESSAGE##\1813 ##TPLMESSAGE##\ 1812 1814 <form action=\"config.html\" method=\"get\">\n\ 1813 1815 <input name=\"part\" type=\"hidden\" value=\"camd35\">\n\ … … 1830 1832 ##TPLMENU##\ 1831 1833 ##TPLCONFIGMENU##\ 1832 ## MESSAGE##\1834 ##TPLMESSAGE##\ 1833 1835 <form action=\"config.html\" method=\"get\">\n\ 1834 1836 <input name=\"part\" type=\"hidden\" value=\"camd35tcp\">\n\ … … 1851 1853 ##TPLMENU##\ 1852 1854 ##TPLCONFIGMENU##\ 1853 ## MESSAGE##\1855 ##TPLMESSAGE##\ 1854 1856 <form action=\"config.html\" method=\"get\">\n\ 1855 1857 <input name=\"part\" type=\"hidden\" value=\"csp\">\n\ … … 1871 1873 ##TPLMENU##\ 1872 1874 ##TPLCONFIGMENU##\ 1873 ## MESSAGE##\1875 ##TPLMESSAGE##\ 1874 1876 <form action=\"config.html\" method=\"get\">\n\ 1875 1877 <input name=\"part\" type=\"hidden\" value=\"serial\">\n\ … … 1893 1895 ##TPLMENU##\ 1894 1896 ##TPLCONFIGMENU##\ 1895 ## MESSAGE##\1897 ##TPLMESSAGE##\ 1896 1898 <form action=\"config.html\" method=\"get\">\n\ 1897 1899 <input name=\"part\" type=\"hidden\" value=\"dvbapi\">\n\ … … 1929 1931 ##TPLHEADER##\ 1930 1932 ##TPLMENU##\ 1931 ## MESSAGE##\1933 ##TPLMESSAGE##\ 1932 1934 <FORM action=\"services_edit.html\" method=\"get\"><INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"add\">\n\ 1933 1935 <TABLE CLASS=\"stats\">\n\ … … 1961 1963 ##TPLHEADER##\ 1962 1964 ##TPLMENU##\ 1963 ## MESSAGE##\1965 ##TPLMESSAGE##\ 1964 1966 <BR><BR>\n\ 1965 1967 <form action=\"services_edit.html\" method=\"get\">\n\ … … 2007 2009 ##TPLFOOTER##" 2008 2010 2011 #define TPLWRITEPROTECTION "You cannot change the content of this file!" 2012 2013 #define TPLMESSAGEBIT "##MESSAGE##<BR>" 2014 2015 #define TPLMESSAGE "<DIV CLASS=\"message\">##MESSAGES##</DIV>\n" 2016 2009 2017 #define TPLSCRIPT "\ 2010 2018 ##TPLHEADER##\ 2011 2019 ##TPLMENU##\ 2012 ## MESSAGE##\2020 ##TPLMESSAGE##\ 2013 2021 <br><br><b>OSCam execute script: ##SCRIPTNAME## --> Status: ##SCRIPTRESULT## --> Returncode: ##CODE##</b><br>\n\ 2014 2022 ##TPLFOOTER##" … … 2273 2281 ##TPLHEADER##\ 2274 2282 ##TPLMENU##\ 2275 ## MESSAGE##\2283 ##TPLMESSAGE##\ 2276 2284 <BR><BR>\n\ 2277 2285 <TABLE CLASS=\"stats\">\n\ … … 2377 2385 ,{"PRESHUTDOWN", TPLPRESHUTDOWN, ""} 2378 2386 ,{"SHUTDOWN", TPLSHUTDOWN, ""} 2387 ,{"WRITEPROTECTION", TPLWRITEPROTECTION, ""} 2388 ,{"MESSAGE", TPLMESSAGE, ""} 2389 ,{"MESSAGEBIT", TPLMESSAGEBIT, ""} 2379 2390 ,{"SCRIPT", TPLSCRIPT, ""} 2380 2391 ,{"GRAPH", TPLGRAPH, ""} -
trunk/module-webif.c
r7224 r7225 241 241 242 242 if (strcmp(getParam(params, "action"), "execute") == 0) { 243 for(i = 0; i < (*params).paramcount; ++i) { 244 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 245 //we use the same function as used for parsing the config tokens 246 chk_t_global((*params).params[i], (*params).values[i]); 247 } 248 } 249 if(cfg.usrfile == NULL) cfg.disableuserfile = 1; 250 if(cfg.mailfile == NULL) cfg.disablemail = 1; 251 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration Global done. You should restart OSCam now.</B><BR><BR>"); 252 if(write_config()==0) refresh_oscam(REFR_SERVER); 253 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 243 if(cfg.http_readonly) { 244 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 245 } else { 246 for(i = 0; i < (*params).paramcount; ++i) { 247 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 248 //we use the same function as used for parsing the config tokens 249 chk_t_global((*params).params[i], (*params).values[i]); 250 } 251 } 252 if(cfg.usrfile == NULL) cfg.disableuserfile = 1; 253 if(cfg.mailfile == NULL) cfg.disablemail = 1; 254 tpl_addMsg(vars, "Configuration Global done. You should restart OSCam now."); 255 if(write_config()==0) refresh_oscam(REFR_SERVER); 256 else tpl_addMsg(vars, "Write Config failed!"); 257 } 254 258 } 255 259 if (cfg.srvip != 0) … … 340 344 341 345 setActiveSubMenu(vars, MNU_CFG_LOADBAL); 342 343 if (strcmp(getParam(params, "button"), "Load Stats") == 0) { 344 clear_all_stat(); 345 load_stat_from_file(); 346 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Stats loades from file</B><BR><BR>"); 347 } 348 349 if (strcmp(getParam(params, "button"), "Save Stats") == 0) { 350 save_stat_to_file(1); 351 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Stats saved to file</B><BR><BR>"); 352 } 353 354 if (strcmp(getParam(params, "button"), "Clear Stats") == 0) { 355 clear_all_stat(); 356 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Stats cleared completly</B><BR><BR>"); 357 } 358 359 if (strcmp(getParam(params, "button"), "Clear Timeouts") == 0) { 360 clean_all_stats_by_rc(E_TIMEOUT, 0); 361 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Stats cleared Timeouts</B><BR><BR>"); 362 } 363 364 if (strcmp(getParam(params, "button"), "Clear Not Founds") == 0) { 365 clean_all_stats_by_rc(E_NOTFOUND, 0); 366 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Stats cleared Not Founds</B><BR><BR>"); 346 347 if(strlen(getParam(params, "button")) > 0){ 348 if(cfg.http_readonly) { 349 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 350 } else { 351 if (strcmp(getParam(params, "button"), "Load Stats") == 0) { 352 clear_all_stat(); 353 load_stat_from_file(); 354 tpl_addMsg(vars, "Stats loaded from file"); 355 } 356 357 if (strcmp(getParam(params, "button"), "Save Stats") == 0) { 358 save_stat_to_file(1); 359 tpl_addMsg(vars, "Stats saved to file"); 360 } 361 362 if (strcmp(getParam(params, "button"), "Clear Stats") == 0) { 363 clear_all_stat(); 364 tpl_addMsg(vars, "Stats cleared completly"); 365 } 366 367 if (strcmp(getParam(params, "button"), "Clear Timeouts") == 0) { 368 clean_all_stats_by_rc(E_TIMEOUT, 0); 369 tpl_addMsg(vars, "Stats cleared Timeouts"); 370 } 371 372 if (strcmp(getParam(params, "button"), "Clear Not Founds") == 0) { 373 clean_all_stats_by_rc(E_NOTFOUND, 0); 374 tpl_addMsg(vars, "Stats cleared Not Founds"); 375 } 376 } 367 377 } 368 378 369 379 if (strcmp(getParam(params, "action"),"execute") == 0) { 370 for(i = 0; i < (*params).paramcount; ++i) { 371 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 372 //we use the same function as used for parsing the config tokens 373 chk_t_global((*params).params[i], (*params).values[i]); 374 } 375 } 376 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration Loadbalancer done.</B><BR><BR>"); 377 if(write_config()==0) refresh_oscam(REFR_SERVER); 378 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 380 if(cfg.http_readonly) { 381 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 382 } else { 383 for(i = 0; i < (*params).paramcount; ++i) { 384 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 385 //we use the same function as used for parsing the config tokens 386 chk_t_global((*params).params[i], (*params).values[i]); 387 } 388 } 389 tpl_addMsg(vars, "Configuration Loadbalancer done."); 390 if(write_config()==0) refresh_oscam(REFR_SERVER); 391 else tpl_addMsg(vars, "Write Config failed!"); 392 } 379 393 } 380 394 … … 421 435 422 436 if (strcmp(getParam(params, "action"), "execute") == 0) { 423 for(i = 0; i < (*params).paramcount; ++i) { 424 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 425 //we use the same function as used for parsing the config tokens 426 chk_t_camd33((*params).params[i], (*params).values[i]); 427 } 428 } 429 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration camd33 done. You should restart OSCam now.</B><BR><BR>"); 430 if(write_config()==0) refresh_oscam(REFR_SERVER); 431 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 437 if(cfg.http_readonly) { 438 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 439 } else { 440 for(i = 0; i < (*params).paramcount; ++i) { 441 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 442 //we use the same function as used for parsing the config tokens 443 chk_t_camd33((*params).params[i], (*params).values[i]); 444 } 445 } 446 tpl_addMsg(vars, "Configuration camd33 done. You should restart OSCam now."); 447 if(write_config()==0) refresh_oscam(REFR_SERVER); 448 else tpl_addMsg(vars, "Write Config failed!"); 449 } 432 450 } 433 451 … … 454 472 455 473 if ((strcmp(getParam(params, "action"),"execute") == 0) && (getParam(params, "port"))[0]) { 456 for(i = 0; i < (*params).paramcount; ++i) { 457 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 458 //we use the same function as used for parsing the config tokens 459 chk_t_camd35((*params).params[i], (*params).values[i]); 460 } 461 } 462 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration camd35 done. You should restart OSCam now.</B><BR><BR>"); 463 if(write_config()==0) refresh_oscam(REFR_SERVER); 464 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 474 if(cfg.http_readonly) { 475 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 476 } else { 477 for(i = 0; i < (*params).paramcount; ++i) { 478 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 479 //we use the same function as used for parsing the config tokens 480 chk_t_camd35((*params).params[i], (*params).values[i]); 481 } 482 } 483 tpl_addMsg(vars, "Configuration camd35 done. You should restart OSCam now."); 484 if(write_config()==0) refresh_oscam(REFR_SERVER); 485 else tpl_addMsg(vars, "Write Config failed!"); 486 } 465 487 } 466 488 … … 485 507 486 508 if ((strcmp(getParam(params, "action"),"execute") == 0) && (getParam(params, "port"))[0]) { 487 for(i = 0; i < (*params).paramcount; ++i) { 488 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 489 //we use the same function as used for parsing the config tokens 490 chk_t_camd35_tcp((*params).params[i], (*params).values[i]); 491 } 492 } 493 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration camd35 TCP done. You should restart OSCam now.</B><BR><BR>"); 494 if(write_config()==0) refresh_oscam(REFR_SERVER); 495 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 509 if(cfg.http_readonly) { 510 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 511 } else { 512 for(i = 0; i < (*params).paramcount; ++i) { 513 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 514 //we use the same function as used for parsing the config tokens 515 chk_t_camd35_tcp((*params).params[i], (*params).values[i]); 516 } 517 } 518 tpl_addMsg(vars, "Configuration camd35 TCP done. You should restart OSCam now."); 519 if(write_config()==0) refresh_oscam(REFR_SERVER); 520 else tpl_addMsg(vars, "Write Config failed!"); 521 } 496 522 } 497 523 … … 519 545 520 546 if ((strcmp(getParam(params, "action"),"execute") == 0) && (getParam(params, "port"))[0]) { 521 for(i = 0; i < (*params).paramcount; ++i) { 522 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 523 //we use the same function as used for parsing the config tokens 524 chk_t_csp((*params).params[i], (*params).values[i]); 525 } 526 } 527 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration CSP done. You should restart OSCam now.</B><BR><BR>"); 528 if(write_config()==0) refresh_oscam(REFR_SERVER); 529 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 547 if(cfg.http_readonly) { 548 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 549 } else { 550 for(i = 0; i < (*params).paramcount; ++i) { 551 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 552 //we use the same function as used for parsing the config tokens 553 chk_t_csp((*params).params[i], (*params).values[i]); 554 } 555 } 556 tpl_addMsg(vars, "Configuration CSP done. You should restart OSCam now."); 557 if(write_config()==0) refresh_oscam(REFR_SERVER); 558 else tpl_addMsg(vars, "Write Config failed!"); 559 } 530 560 } 531 561 … … 550 580 551 581 if (strcmp(getParam(params, "action"),"execute") == 0) { 552 for(i = 0; i < (*params).paramcount; ++i) { 553 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 554 //we use the same function as used for parsing the config tokens 555 chk_t_newcamd((*params).params[i], (*params).values[i]); 556 } 557 } 558 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration Newcamd done. You should restart OSCam now.</B><BR><BR>"); 559 if(write_config()==0) refresh_oscam(REFR_SERVER); 560 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 582 if(cfg.http_readonly) { 583 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 584 } else { 585 for(i = 0; i < (*params).paramcount; ++i) { 586 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 587 //we use the same function as used for parsing the config tokens 588 chk_t_newcamd((*params).params[i], (*params).values[i]); 589 } 590 } 591 tpl_addMsg(vars, "Configuration Newcamd done. You should restart OSCam now."); 592 if(write_config()==0) refresh_oscam(REFR_SERVER); 593 else tpl_addMsg(vars, "Write Config failed!"); 594 } 561 595 } 562 596 … … 592 626 593 627 if (strcmp(getParam(params, "action"),"execute") == 0) { 594 for(i = 0; i < (*params).paramcount; ++i) { 595 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 596 //we use the same function as used for parsing the config tokens 597 chk_t_radegast((*params).params[i], (*params).values[i]); 598 } 599 } 600 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration Radegast done. You should restart OSCam now.</B><BR><BR>"); 601 if(write_config()==0) refresh_oscam(REFR_SERVER); 602 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 628 if(cfg.http_readonly) { 629 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 630 } else { 631 for(i = 0; i < (*params).paramcount; ++i) { 632 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 633 //we use the same function as used for parsing the config tokens 634 chk_t_radegast((*params).params[i], (*params).values[i]); 635 } 636 } 637 tpl_addMsg(vars, "Configuration Radegast done. You should restart OSCam now."); 638 if(write_config()==0) refresh_oscam(REFR_SERVER); 639 else tpl_addMsg(vars, "Write Config failed!"); 640 } 603 641 } 604 642 tpl_printf(vars, TPLADD, "PORT", "%d", cfg.rad_port); … … 626 664 #endif 627 665 cs_debug_mask(D_TRACE, "Entitlements: Refresh Shares finished"); 628 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<B>Refresh Shares started</B><BR><BR>");666 tpl_addMsg(vars, "Refresh Shares started"); 629 667 } 630 668 631 669 int32_t i; 632 670 if (strcmp(getParam(params, "action"),"execute") == 0) { 633 for(i = 0; i < (*params).paramcount; ++i) { 634 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 635 //we use the same function as used for parsing the config tokens 636 chk_t_cccam((*params).params[i], (*params).values[i]); 637 } 638 } 639 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration CCCam done. You should restart OSCam now.</B><BR><BR>"); 640 if(write_config()==0) refresh_oscam(REFR_SERVER); 641 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 642 cc_update_nodeid(); 671 if(cfg.http_readonly) { 672 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 673 } else { 674 for(i = 0; i < (*params).paramcount; ++i) { 675 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 676 //we use the same function as used for parsing the config tokens 677 chk_t_cccam((*params).params[i], (*params).values[i]); 678 } 679 } 680 tpl_addMsg(vars, "Configuration CCCam done. You should restart OSCam now."); 681 if(write_config()==0) refresh_oscam(REFR_SERVER); 682 else tpl_addMsg(vars, "Write Config failed!"); 683 cc_update_nodeid(); 684 } 643 685 } 644 686 … … 701 743 702 744 if (strcmp(getParam(params, "action"),"execute") == 0) { 703 for(i = 0; i < (*params).paramcount; ++i) { 704 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 705 //we use the same function as used for parsing the config tokens 706 if (strstr((*params).params[i], "http")) { 707 chk_t_webif((*params).params[i], (*params).values[i]); 708 } 745 if(cfg.http_readonly) { 746 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 747 } else { 748 for(i = 0; i < (*params).paramcount; ++i) { 749 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 750 //we use the same function as used for parsing the config tokens 751 if (strstr((*params).params[i], "http")) { 752 chk_t_webif((*params).params[i], (*params).values[i]); 753 } 709 754 #ifdef LCDSUPPORT 710 else if (strstr((*params).params[i], "lcd")) { 711 chk_t_lcd((*params).params[i], (*params).values[i]); 712 } 713 #endif 714 else { 715 chk_t_monitor((*params).params[i], (*params).values[i]); 716 } 717 } 718 } 719 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration Monitor done. You should restart OSCam now.</B><BR><BR>"); 720 if(write_config()==0) refresh_oscam(REFR_SERVER); 721 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 755 else if (strstr((*params).params[i], "lcd")) { 756 chk_t_lcd((*params).params[i], (*params).values[i]); 757 } 758 #endif 759 else { 760 chk_t_monitor((*params).params[i], (*params).values[i]); 761 } 762 } 763 } 764 tpl_addMsg(vars, "Configuration Monitor done. You should restart OSCam now."); 765 if(write_config()==0) refresh_oscam(REFR_SERVER); 766 else tpl_addMsg(vars, "Write Config failed!"); 767 } 722 768 } 723 769 tpl_printf(vars, TPLADD, "MONPORT", "%d", cfg.mon_port); … … 829 875 char *saveptr1 = NULL; 830 876 if (strcmp(getParam(params, "action"),"execute") == 0) { 831 for(i = 0; i < (*params).paramcount; ++i) { 832 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 833 //we use the same function as used for parsing the config tokens 834 chk_t_serial((*params).params[i], (*params).values[i]); 835 } 836 } 837 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration Serial done. You should restart OSCam now.</B><BR><BR>"); 838 if(write_config()==0) refresh_oscam(REFR_SERVER); 839 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 877 if(cfg.http_readonly) { 878 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 879 } else { 880 for(i = 0; i < (*params).paramcount; ++i) { 881 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 882 //we use the same function as used for parsing the config tokens 883 chk_t_serial((*params).params[i], (*params).values[i]); 884 } 885 } 886 tpl_addMsg(vars, "Configuration Serial done. You should restart OSCam now."); 887 if(write_config()==0) refresh_oscam(REFR_SERVER); 888 else tpl_addMsg(vars, "Write Config failed!"); 889 } 840 890 } 841 891 … … 865 915 866 916 if (strcmp(getParam(params, "action"),"execute") == 0) { 867 for(i = 0; i < (*params).paramcount; ++i) { 868 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 869 //we use the same function as used for parsing the config tokens 870 chk_t_dvbapi((*params).params[i], (*params).values[i]); 871 } 872 } 873 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration DVB Api done. You should restart OSCam now.</B><BR><BR>"); 874 if(write_config()==0) refresh_oscam(REFR_SERVER); 875 else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 917 if(cfg.http_readonly) { 918 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 919 } else { 920 for(i = 0; i < (*params).paramcount; ++i) { 921 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 922 //we use the same function as used for parsing the config tokens 923 chk_t_dvbapi((*params).params[i], (*params).values[i]); 924 } 925 } 926 tpl_addMsg(vars, "Configuration DVB Api done. You should restart OSCam now."); 927 if(write_config()==0) refresh_oscam(REFR_SERVER); 928 else tpl_addMsg(vars, "Write Config failed!"); 929 } 876 930 } 877 931 … … 915 969 916 970 if (strcmp(getParam(params, "action"),"execute") == 0) { 917 for(i = 0; i < (*params).paramcount; ++i) { 918 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 919 //we use the same function as used for parsing the config tokens 920 chk_t_ac((*params).params[i], (*params).values[i]); 921 } 922 } 923 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<BR><BR><B>Configuration Anticascading done.</B><BR><BR>"); 924 refresh_oscam(REFR_ANTICASC); 925 if(write_config()!=0) 926 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 971 if(cfg.http_readonly) { 972 tpl_addMsg(vars, "WebIf is in readonly mode. No changes are possible!"); 973 } else { 974 for(i = 0; i < (*params).paramcount; ++i) { 975 if ((strcmp((*params).params[i], "part")) && (strcmp((*params).params[i], "action"))) { 976 //we use the same function as used for parsing the config tokens 977 chk_t_ac((*params).params[i], (*params).values[i]); 978 } 979 } 980 tpl_addMsg(vars, "Configuration Anticascading done."); 981 refresh_oscam(REFR_ANTICASC); 982 if(write_config()!=0) tpl_addMsg(vars, "Write Config failed!"); 983 } 927 984 } 928 985 if (cfg.ac_enabled > 0) tpl_addVar(vars, TPLADD, "CHECKED", "checked"); … … 998 1055 if ((strcmp(getParam(params, "action"), "disable") == 0) || (strcmp(getParam(params, "action"), "enable") == 0)) { 999 1056 if(cfg.http_readonly) { 1000 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<b>Webif is in readonly mode. Enabling or disabling readers is not possible!</b><BR>");1057 tpl_addMsg(vars, "WebIf is in readonly mode. Enabling or disabling readers is not possible!"); 1001 1058 } else { 1002 1059 rdr = get_reader_by_label(getParam(params, "label")); … … 1012 1069 } 1013 1070 restart_cardreader(rdr, 1); 1014 if(write_server() != 0) 1015 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 1071 if(write_server() != 0) tpl_addMsg(vars, "Write Config failed!"); 1016 1072 } 1017 1073 } … … 1020 1076 if (strcmp(getParam(params, "action"), "delete") == 0) { 1021 1077 if(cfg.http_readonly) { 1022 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<b>Webif is in readonly mode. No deletion will be made!</b><BR>");1078 tpl_addMsg(vars, "WebIf is in readonly mode. No deletion will be made!"); 1023 1079 } else { 1024 1080 rdr = get_reader_by_label(getParam(params, "label")); … … 1029 1085 free_reader(rdr); 1030 1086 1031 if(write_server()!=0) 1032 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 1087 if(write_server()!=0) tpl_addMsg(vars, "Write Config failed!"); 1033 1088 } 1034 1089 } … … 1247 1302 } 1248 1303 1249 if(write_server()!=0) 1250 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 1304 if(write_server()!=0) tpl_addMsg(vars, "Write Config failed!"); 1251 1305 } 1252 1306 … … 1673 1727 #endif 1674 1728 default : 1675 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<b>Error: protocol not resolvable</b><BR>");1676 tpl_ printf(vars, TPLAPPEND, "MESSAGE", "<b>Error: protocol number: %d readername: %s</b><BR>", rdr->typ, xml_encode(vars, rdr->label));1729 tpl_addMsg(vars, "Error: protocol not resolvable"); 1730 tpl_addMsg(vars, tpl_printf(vars, TPLADD, "TMP", "Error: protocol number: %d readername: %s", rdr->typ, xml_encode(vars, rdr->label))); 1677 1731 break; 1678 1732 … … 1998 2052 account->ac_penalty = DEFAULT_AC_PENALTY; // by default create the new user with global penality value 1999 2053 #endif 2000 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<b>New user has been added with default settings</b><BR>"); 2001 2002 if (write_userdb()!=0) 2003 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 2054 tpl_addMsg(vars, "New user has been added with default settings"); 2055 2056 if (write_userdb()!=0) tpl_addMsg(vars, "Write Config failed!"); 2004 2057 // no need to refresh anything here as the account is disabled by default and there's no client with this new account anyway! 2005 2058 } … … 2021 2074 } 2022 2075 chk_account("services", servicelabels, account); 2023 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<B>Account updated</B><BR><BR>");2076 tpl_addMsg(vars, "Account updated"); 2024 2077 2025 2078 refresh_oscam(REFR_CLIENTS); 2026 2079 2027 if (write_userdb()!=0) 2028 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 2080 if (write_userdb()!=0) tpl_addMsg(vars, "Write Config failed!"); 2029 2081 } 2030 2082 … … 2242 2294 if (strcmp(getParam(params, "action"), "delete") == 0) { 2243 2295 if(cfg.http_readonly) { 2244 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<b>Webif is in readonly mode. No deletion will be made!</b><BR>");2296 tpl_addMsg(vars, "WebIf is in readonly mode. No deletion will be made!"); 2245 2297 } else { 2246 2298 struct s_auth *account_prev = NULL; … … 2269 2321 } 2270 2322 if (found > 0) { 2271 if (write_userdb()!=0) 2272 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 2273 } else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<b>Sorry but the specified user doesn't exist. No deletion will be made!</b><BR>"); 2323 if (write_userdb()!=0) tpl_addMsg(vars, "Write Config failed!"); 2324 } else tpl_addMsg(vars, "Sorry but the specified user doesn't exist. No deletion will be made!"); 2274 2325 } 2275 2326 } … … 2291 2342 } else 2292 2343 account->disabled = 0; 2293 if (write_userdb() != 0) 2294 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 2344 if (write_userdb() != 0) tpl_addMsg(vars, "Write Config failed!"); 2295 2345 } else { 2296 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<b>Sorry but the specified user doesn't exist. No deletion will be made!</b><BR>");2346 tpl_addMsg(vars, "Sorry but the specified user doesn't exist. No deletion will be made!"); 2297 2347 } 2298 2348 } … … 2904 2954 2905 2955 } else { 2906 tpl_add Var(vars, TPLADD, "MESSAGE", "Reader does not exist or is not started");2956 tpl_addMsg(vars, "Reader does not exist or is not started!"); 2907 2957 } 2908 2958 } … … 3475 3525 cs_strncpy((char *)sidtab->label, label, sizeof(sidtab->label)); 3476 3526 ++cfg_sidtab_generation; 3477 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<b>New service has been added</b><BR>");3527 tpl_addMsg(vars, "New service has been added"); 3478 3528 // Adding is uncritical as the new service is appended to sidtabok/sidtabno and accounts/clients/readers have zeros there 3479 if (write_services()!=0) 3480 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<b>Writing services to disk failed!</b><BR>"); 3529 if (write_services()!=0) tpl_addMsg(vars, "Writing services to disk failed!"); 3481 3530 } 3482 3531 … … 3488 3537 } 3489 3538 ++cfg_sidtab_generation; 3490 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<B>Services updated</B><BR><BR>");3539 tpl_addMsg(vars, "Services updated"); 3491 3540 // We don't need any refresh here as accounts/clients/readers sidtabok/sidtabno are unaffected! 3492 if (write_services()!=0) 3493 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<B>Write Config failed</B><BR><BR>"); 3541 if (write_services()!=0) tpl_addMsg(vars, "Write Config failed!"); 3494 3542 3495 3543 for (sidtab = cfg.sidtab; sidtab != NULL && strcmp(label, sidtab->label) != 0; sidtab=sidtab->next); … … 3541 3589 if (strcmp(getParam(params, "action"), "delete") == 0) { 3542 3590 if(cfg.http_readonly) { 3543 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<b>Sorry, Webif is in readonly mode. No deletion will be made!</b><BR>");3591 tpl_addMsg(vars, "Sorry, Webif is in readonly mode. No deletion will be made!"); 3544 3592 } else { 3545 3593 struct s_sidtab *sidtab_prev = NULL; … … 3589 3637 if (counter > 0) { 3590 3638 ++cfg_sidtab_generation; 3591 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<b>Service has been deleted!</b><BR>"); 3592 if (write_services() != 0) 3593 tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<b>Writing services to disk failed!</b><BR>"); 3594 } else tpl_addVar(vars, TPLAPPEND, "MESSAGE", "<b>Sorry but the specified service doesn't exist. No deletion will be made!</b><BR>"); 3639 tpl_addMsg(vars, "Service has been deleted!"); 3640 if (write_services() != 0) tpl_addMsg(vars, "Writing services to disk failed!"); 3641 } else tpl_addMsg(vars, "Sorry but the specified service doesn't exist. No deletion will be made!"); 3595 3642 } 3596 3643 } … … 3621 3668 if(counter >= MAX_SIDBITS) { 3622 3669 tpl_addVar(vars, TPLADD, "BTNDISABLED", "DISABLED"); 3623 tpl_add Var(vars, TPLADD, "MESSAGE", "Maximum Number of Services is reached");3670 tpl_addMsg(vars, "Maximum Number of Services is reached"); 3624 3671 } 3625 3672 return tpl_getTpl(vars, "SERVICECONFIGLIST"); … … 3711 3758 tpl_printf(vars, TPLADD, "CODE", "%d", rc); 3712 3759 } else { 3713 tpl_add Var(vars, TPLAPPEND, "MESSAGE", "<b>Sorry, Webif is in readonly mode. No script execution possible!</b><BR>");3760 tpl_addMsg(vars, "Sorry, Webif is in readonly mode. No script execution possible!"); 3714 3761 } 3715 3762 return tpl_getTpl(vars, "SCRIPT"); … … 3746 3793 pclose(fp); 3747 3794 #else 3748 tpl_add Var(vars, TPLADD, "MESSAGE", "Function not supported in CYGWIN environment");3795 tpl_addMsg(vars, "Function not supported in CYGWIN environment"); 3749 3796 #endif 3750 3797 return tpl_getTpl(vars, "SCANUSB"); … … 4004 4051 4005 4052 if (!writable) { 4006 tpl_addVar(vars, TPLADD, "WRITEPROTECTION", "You cannot change the content of this file!");4053 tpl_addVar(vars, TPLADD, "WRITEPROTECTION", tpl_getTpl(vars, "WRITEPROTECTION")); 4007 4054 tpl_addVar(vars, TPLADD, "BTNDISABLED", "DISABLED"); 4008 4055 } -
trunk/module-webif.h
r7224 r7225 56 56 uint8_t *vartypes; 57 57 char **tmp; 58 uint8_t messages; 58 59 }; 59 60 … … 65 66 66 67 extern char *tpl_addVar(struct templatevars *vars, uint8_t addmode, char *name, char *value); 68 extern char *tpl_addMsg(struct templatevars *vars, char *value); 67 69 extern char *tpl_addTmp(struct templatevars *vars, char *value); 68 70 extern char *tpl_printf(struct templatevars *vars, uint8_t addmode, char *varname, char *fmtstring, ...);
Note:
See TracChangeset
for help on using the changeset viewer.