Changeset 1298


Ignore:
Timestamp:
01/19/10 23:41:08 (11 years ago)
Author:
alno
Message:

WebIf:

  • functionality added to start a script which is defined in oscam.conf [monitor] as "httpscript=<path>"
Location:
branches/monitor-improvement
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/monitor-improvement/globals.h

    r1274 r1298  
    554554  char      http_css[128];
    555555  char      http_tpl[128];
    556   int               http_refresh;
    557   int               http_hide_idle_clients;
     556  char      http_script[128];
     557  int       http_refresh;
     558  int       http_hide_idle_clients;
    558559  int       c33_port;
    559560  in_addr_t c33_srvip;
  • branches/monitor-improvement/oscam-config.c

    r1270 r1298  
    445445  if (!strcmp(token, "httppwd")) { cs_strncpy(cfg->http_pwd, value, sizeof(cfg->http_pwd)); return; }
    446446  if (!strcmp(token, "httpcss")) { cs_strncpy(cfg->http_css, value, sizeof(cfg->http_css)); return; }
     447  if (!strcmp(token, "httpscript")) { cs_strncpy(cfg->http_script, value, sizeof(cfg->http_script)); return; }
    447448  if (!strcmp(token, "httptpl")) {     
    448449    cs_strncpy(cfg->http_tpl, value, sizeof(cfg->http_tpl));
     
    981982    fprintf_conf(f, CONFVARWIDTH, "httppwd", "%s\n", cfg->http_pwd);
    982983    fprintf_conf(f, CONFVARWIDTH, "httpcss", "%s\n", cfg->http_css);
     984    fprintf_conf(f, CONFVARWIDTH, "httpscript", "%s\n", cfg->http_script);
    983985    fprintf_conf(f, CONFVARWIDTH, "httprefresh", "%d\n", cfg->http_refresh);
    984986    fprintf_conf(f, CONFVARWIDTH, "httphideidleclients", "%d\n", cfg->http_hide_idle_clients);
  • branches/monitor-improvement/oscam-http.c

    r1293 r1298  
    323323    tpl_printf(vars, 0, "HTTPREFRESH", "%d", cfg->http_refresh);
    324324    tpl_addVar(vars, 0, "HTTPTPL", cfg->http_tpl);
     325    tpl_addVar(vars, 0, "HTTPSCRIPT", cfg->http_script);
    325326    if (cfg->http_hide_idle_clients > 0) tpl_addVar(vars, 0, "CHECKED", "checked");
    326327
     
    12131214}
    12141215
     1216void send_oscam_script(struct templatevars *vars, FILE *f){
     1217    char *result = "not found";
     1218    int rc = 0;
     1219    if(cfg->http_script[0]){
     1220        tpl_addVar(vars, 0, "SCRIPTNAME",cfg->http_script);
     1221        rc = system(cfg->http_script);
     1222        if(rc == -1){
     1223            result = "done";
     1224        }else{
     1225            result = "failed";
     1226        }
     1227    }else{
     1228        tpl_addVar(vars, 0, "SCRIPTNAME", "no script defined");
     1229    }
     1230    tpl_addVar(vars, 0, "SCRIPTRESULT", result);
     1231    tpl_printf(vars, 0, "CODE", "%d", rc);
     1232    fputs(tpl_getTpl(vars, "SCRIPT"), f);
     1233}
     1234
    12151235int process_request(FILE *f, struct in_addr in) {
    12161236  char buf[4096];
     
    12381258            "/services_edit.html",
    12391259            "/savetemplates.html",
    1240             "/shutdown.html"};
     1260            "/shutdown.html",
     1261            "/script.html"};
    12411262  int pagescnt = sizeof(pages)/sizeof(char *);  // Calculate the amount of items in array
    12421263
     
    13501371        case  10: send_oscam_savetpls(vars, f); break;
    13511372        case  11: send_oscam_shutdown(vars, f, &params); break;
     1373        case  12: send_oscam_script(vars, f); break;
    13521374        default: send_oscam_status(vars, f, &params, in); break;
    13531375      }
  • branches/monitor-improvement/oscam-http.h

    r1292 r1298  
    3434TABLE.menu TD{border:2px outset lightgrey; background-color:silver; font-color:black; font-family: Arial;}\n\
    3535TABLE.menu TD.shutdown{border:2px outset lightgrey; background-color:orange; font-color:black; font-family: Arial;}\n\
     36TABLE.menu TD.script{border:2px outset lightgrey; background-color:yellow; font-color:black; font-family: Arial;}\n\
    3637TD.menu {border:2px outset lightgrey; background-color:silver; font-color:black; font-family: Arial; font-size:11px;}\n\
    3738TABLE.configmenu{background-color:black; align:center; font-size: 10px;}\n\
     
    6970      <TD CLASS=\"menu\"><A HREF=\"userconfig.html\">USERS</TD>\n\
    7071      <TD CLASS=\"menu\"><A HREF=\"services.html\">SERVICES</TD>\n\
     72      <TD CLASS=\"script\"><A HREF=\"script.html\">SCRIPT</TD>\n\
    7173      <TD CLASS=\"shutdown\"><A HREF=\"shutdown.html\">SHUTDOWN</TD>\n\
    7274    </TR>\n\
     
    629631        <TR><TD>Httpcss:</TD><TD><input name=\"httpcss\" type=\"text\" size=\"50\" maxlength=\"50\" value=\"##HTTPCSS##\"></TD></TR>\n\
    630632        <TR><TD>Httprefresh:</TD><TD><input name=\"httprefresh\" type=\"text\" size=\"5\" maxlength=\"5\" value=\"##HTTPREFRESH##\"> s</TD></TR>\n\
    631         <TR><TD>Httptpl:</TD><TD><input name=\"httptpl\" type=\"text\" size=\"50\" maxlength=\"100\" value=\"##HTTPTPL##\"></TD></TR>\n\
    632     <TR><TD>HttpHideIdleClients:</TD><TD><input name=\"httphideidleclients\" type=\"checkbox\" value=\"1\" ##CHECKED##>\n\
     633        <TR><TD>Httptpl:</TD><TD><input name=\"httptpl\" type=\"text\" size=\"50\" maxlength=\"128\" value=\"##HTTPTPL##\"></TD></TR>\n\
     634        <TR><TD>Httpscript:</TD><TD><input name=\"httpscript\" type=\"text\" size=\"50\" maxlength=\"128\" value=\"##HTTPSCRIPT##\"></TD></TR>\n\
     635        <TR><TD>HttpHideIdleClients:</TD><TD><input name=\"httphideidleclients\" type=\"checkbox\" value=\"1\" ##CHECKED##>\n\
    633636    <TR><TD colspan=\"2\" align=\"right\"><input type=\"submit\" value=\"OK\">\n</TD></TR>\n\
    634637    </TABLE>\n\
     
    880883##TPLMENU##\n\
    881884<br><b>Oscam Shutdown - Try Reconnect in ##SECONDS## Seconds</b><br>\n\
     885##TPLFOOTER##"
     886
     887#define TPLSCRIPT "\
     888##TPLHEADER##\
     889##TPLMENU##\n\
     890<br><br><b>Oscam execute script: ##SCRIPTNAME## --> Status: ##SCRIPTRESULT## --> Returncode: ##CODE##</b><br>\n\
    882891##TPLFOOTER##"
    883892
     
    931940    "SERVICEEDIT",
    932941    "PRESHUTDOWN",
    933     "SHUTDOWN"
     942    "SHUTDOWN",
     943    "SCRIPT"
    934944#ifdef HAVE_DVBAPI
    935945    ,"CONFIGDVBAPI"
     
    9971007    TPLSERVICEEDIT,
    9981008    TPLPRESHUTDOWN,
    999     TPLSHUTDOWN
     1009    TPLSHUTDOWN,
     1010    TPLSCRIPT
    10001011#ifdef HAVE_DVBAPI
    10011012    ,TPLCONFIGDVBAPI
Note: See TracChangeset for help on using the changeset viewer.