Changeset 1019


Ignore:
Timestamp:
01/01/10 13:39:54 (12 years ago)
Author:
alno
Message:

WebIf:
Changelog:

  • userconfig, reader config and service display now running with templates
  • completely new logic for userconfig
  • fixed errors in saving/displaying Ident, Betatunnel and CAID
  • entitlements and readers merged. From now on you can see the entitlements from the readers section if you click the corresponding links
  • refresh in status page fixed
  • headers added to prevent browsers from caching
  • many small fixes
Location:
branches/monitor-improvement
Files:
6 edited

Legend:

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

    r981 r1019  
    658658extern int x2i(int i);
    659659extern void urldecode(char *s);
     660extern char to_hex(char code);
     661extern char *urlencode(char *str);
    660662extern void long2bitchar(long value, char *result);
    661663extern char *char_to_hex(const unsigned char* p_array, unsigned int p_array_len, char hex2ascii[256][2]);
  • branches/monitor-improvement/oscam-config.c

    r994 r1019  
    882882                fprintf(f, "%s%04X", dot, ctab->caid[i]);
    883883                    if(ctab->mask[i])   fprintf(f, "&%04X", ctab->mask[i]);
     884                if(ctab->cmap[i])   fprintf(f, ":%04X", ctab->cmap[i]);
    884885                i++; dot = ",";
    885886            }
     
    893894            while(ttab->bt_caidfrom[i]) {
    894895                fprintf(f, "%s%04X", dot, ttab->bt_caidfrom[i]);
    895                 if(ttab->bt_caidto[i]) fprintf(f, ".%04X", ttab->bt_caidto[i]);
    896                 if(ttab->bt_srvid[i])   fprintf(f, ":%04X", ttab->bt_srvid[i]);
     896                if(ttab->bt_caidto[i]) fprintf(f, ".%04X", ttab->bt_srvid[i]);
     897                if(ttab->bt_srvid[i])   fprintf(f, ":%04X", ttab->bt_caidto[i]);
    897898                i++; dot = ",";
    898899            }
     
    906907        for (i=0;i<ftab->nfilts;i++){
    907908            fprintf(f, "%s%04X", dot, ftab->filts[i].caid);
    908             for (j=0;j<ftab->filts[i].nprids;j++)
    909                 fprintf(f, ":%06lX", ftab->filts[i].prids[j]);
     909            dot=":";
     910            for (j=0;j<ftab->filts[i].nprids;j++){
     911                fprintf(f, "%s%06lX", dot, ftab->filts[i].prids[j]);
     912                dot=",";
     913            }
    910914            dot=";";
    911915        }
  • branches/monitor-improvement/oscam-http-helpers.c

    r999 r1019  
    136136        "REFRESH",
    137137        "STATUS",
    138         "CLIENTSTATUSBIT"
     138        "CLIENTSTATUSBIT",
     139        "USERCONFIGLIST",
     140        "USERCONFIGLISTBIT",
     141        "SIDTAB",
     142        "SIDTABBIT",
     143        "READERS",
     144        "READERSBIT",
     145        "ENTITLEMENTS",
     146        "READERCONFIG",
     147        "READERCONFIGSIDOKBIT",
     148        "READERCONFIGSIDNOBIT",
     149        "USEREDIT",
     150        "USEREDITRDRSELECTED",
     151        "USEREDITSIDOKBIT",
     152        "USEREDITSIDNOBIT"
     153#ifdef CS_ANTICASC
     154        ,"USEREDITANTICASC"
     155#endif     
    139156    };
    140157  int i, tplcnt = sizeof(tpl)/sizeof(char *);
     
    149166        case  4: return TPLSTATUS;
    150167        case  5: return TPLCLIENTSTATUSBIT;
     168        case  6: return TPLUSERCONFIGLIST;
     169        case  7: return TPLUSERCONFIGLISTBIT;
     170        case  8: return TPLSIDTAB;
     171        case  9: return TPLSIDTABBIT;
     172        case 10: return TPLREADERS;
     173        case 11: return TPLREADERSBIT;
     174        case 12: return TPLENTITLEMENTS;
     175        case 13: return TPLREADERCONFIG;
     176        case 14: return TPLREADERCONFIGSIDOKBIT;
     177        case 15: return TPLREADERCONFIGSIDNOBIT;
     178        case 16: return TPLUSEREDIT;
     179        case 17: return TPLUSEREDITRDRSELECTED;
     180        case 18: return TPLUSEREDITSIDOKBIT;
     181        case 19: return TPLUSEREDITSIDNOBIT;
     182#ifdef CS_ANTICASC
     183        case 20: return TPLUSEREDITANTICASC;
     184#endif
    151185        default: return "";
    152186  }
     
    166200   
    167201    while(tpl < tplend){
    168         if(tpl[0] == '#' && tpl[1] == '#'){         
     202        if(tpl[0] == '#' && tpl[1] == '#' && tpl[2] != '#'){           
    169203            pch2 = tpl;
    170204            pch = tpl + 2;
     
    268302    }
    269303    if(strncmp(uri, path, strlen(path)) == 0) uriok = 1;
    270     else if(strncmp(uri, "http://", 7) == 0){
    271         char *tmpuri = uri;
    272         tmpuri += 7;
    273         while(tmpuri[0] != '\0' && tmpuri[0] != '/') ++tmpuri;
    274         if(strncmp(tmpuri, path, strlen(path)) == 0) uriok = 1;
     304    else {
     305        pch2 = uri;
     306        for(pch = uri; pch[0] != '\0'; ++pch) {
     307            if(pch[0] == '/') pch2 = pch;           
     308        }
     309        if(strncmp(pch2, path, strlen(path)) == 0) uriok = 1;
    275310    }
    276311    if(uriok == 1){
     
    331366
    332367    strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&now));
     368    fprintf(f, "Cache-Control: no-store, no-cache, must-revalidate\r\n");
     369    fprintf(f, "Expires: Sat, 26 Jul 1997 05:00:00 GMT\r\n");
    333370    fprintf(f, "Last-Modified: %s\r\n", timebuf);
    334371  fprintf(f, "Connection: close\r\n");
     
    389426    fprintf(f, "        <TD CLASS=\"menu\"><A HREF=\"./readers.html\">READERS</TD>\r\n");
    390427    fprintf(f, "        <TD CLASS=\"menu\"><A HREF=\"./userconfig.html\">USERS</TD>\r\n");
    391     fprintf(f, "        <TD CLASS=\"menu\"><A HREF=\"./entitlements.html\">ENTITLEMENTS</TD>\r\n");
    392428    fprintf(f, "        <TD CLASS=\"menu\"><A HREF=\"./services.html\">SERVICES</TD>\r\n");
    393429    fprintf(f, "    </TR>\r\n");
  • branches/monitor-improvement/oscam-http.c

    r999 r1019  
    1414            "2 = all procs, but viewing only, default",
    1515            "3 = all procs, reload of oscam.user possible",
    16             "4 = complete access"};
    17 
    18 static char* uniq[] = {
    19             "0 = none",
    20             "1 = strict",
    21             "2 = per IP"};
    22 
     16            "4 = complete access"
     17            };
    2318
    2419void refresh_oscam(enum refreshtypes refreshtype){
     
    623618}
    624619
    625 void send_oscam_reader(FILE *f) {
     620void send_oscam_reader(struct templatevars *vars, FILE *f) {
    626621    int ridx;
    627622    char *ctyp;
    628623
    629     fprintf(f,"<BR><BR><TABLE cellspacing=\"0\" cellpadding=\"10\">\r\n");
    630     fprintf(f,"<TR><TH>Label</TH><TH>Protocol</TH><TH>Action</TH></TR>");
    631 
    632624    for(ridx=0;ridx<CS_MAXREADER;ridx++){
    633625        if(!reader[ridx].device[0]) break;
    634 
    635         switch(reader[ridx].typ)
    636             {
     626        switch(reader[ridx].typ){
    637627                case R_MOUSE   : ctyp="mouse";    break;
    638628                case R_INTERNAL: ctyp="intern";   break;
     
    651641                default        : ctyp="unknown";  break;
    652642            }
    653 
    654         fprintf(f,"\t<TR><TD>%s</TD><TD>%s</TD><TD><A HREF=\"readerconfig.html?user=%s\">Edit Settings</A></TD></TR>",reader[ridx].label, ctyp, reader[ridx].label);
    655     }
    656     fprintf(f,"</TABLE>\r\n");
    657     //kill(client[0].pid, SIGUSR1);
    658 }
    659 
    660 void send_oscam_reader_config(FILE *f, struct uriparams *params) {
    661     int i,ridx;
    662 
    663     fprintf(f,"<BR><BR>\r\n");
     643        tpl_addVar(vars, 0, "CTYP", ctyp);
     644        tpl_addVar(vars, 0, "READERNAME", reader[ridx].label);
     645        tpl_addVar(vars, 0, "READERNAMEENC", tpl_addTmp(vars, urlencode(reader[ridx].label)));
     646        tpl_addVar(vars, 1, "READERLIST", tpl_getTpl(vars, "READERSBIT"));
     647    }
     648    fputs(tpl_getTpl(vars, "READERS"), f);
     649}
     650
     651void send_oscam_reader_config(struct templatevars *vars, FILE *f, struct uriparams *params) {
     652    int ridx;
    664653    char *reader_ = getParam(params, "reader");
    665 
    666     for(ridx=0;ridx<CS_MAXREADER;ridx++){
    667         if (!reader[ridx].device[0]){
    668             fprintf(f,"Reader %s not found", reader_);
    669             return ;
    670         }
    671         if (!strcmp(reader_,reader[ridx].label)) break;
    672     }
    673 
    674     /*build form head*/
    675     fprintf(f,"<form action=\"/readerconfig_do.html\" method=\"get\"><input name=\"reader\" type=\"hidden\" value=\"%s\">\r\n", reader[ridx].label);
    676     fprintf(f,"<TABLE cellspacing=\"0\">");
    677     fprintf(f,"<TH>&nbsp;</TH><TH>Edit Reader %s </TH>", reader[ridx].label);
    678 
    679     /*build form fields*/
    680     fprintf(f,"<TR><TD>Device:</TD><TD><input name=\"device\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%s", reader[ridx].device);
    681     if(reader[ridx].r_port) fprintf(f,",%d",reader[ridx].r_port);
    682     if(reader[ridx].l_port) fprintf(f,",%d",reader[ridx].l_port);
    683     fprintf(f,"\"></TD></TR>\r\n");
     654    for(ridx = 0; ridx < CS_MAXREADER && strcmp(reader_, reader[ridx].label) != 0; ++ridx);
     655    if(ridx == CS_MAXREADER){
     656        tpl_addVar(vars, 0, "MESSAGE", "<BR><BR>Reader not found<BR><BR>");
     657    } else if(strcmp(getParam(params, "action"), "execute") == 0){
     658        tpl_addVar(vars, 0, "MESSAGE", "<BR><BR>Saving not yet implemented<BR><BR>");
     659        refresh_oscam(REFR_READERS);
     660    }
     661    int i;
     662    tpl_addVar(vars, 0, "READERNAME", reader[ridx].label);
     663    tpl_addVar(vars, 0, "DEVICE", reader[ridx].device);
     664    tpl_addVar(vars, 0, "NCD_KEY", (char *)reader[ridx].ncd_key);
     665    tpl_addVar(vars, 0, "PINCODE", reader[ridx].pincode);
     666    tpl_addVar(vars, 0, "EMMFILE", (char *)reader[ridx].emmfile);
     667    tpl_addVar(vars, 0, "GBOXPWD", (char *)reader[ridx].gbox_pwd);
     668    tpl_printf(vars, 0, "INACTIVITYTIMEOUT", "%d", reader[ridx].tcp_ito);
     669    tpl_printf(vars, 0, "RECEIVETIMEOUT", "%d", reader[ridx].tcp_rto);
     670    tpl_printf(vars, 0, "DISABLESERVERFILTER", "%d", reader[ridx].ncd_disable_server_filt);
     671    tpl_printf(vars, 0, "FALLBACK", "%d", reader[ridx].fallback);
     672    tpl_printf(vars, 0, "LOGPORT", "%d", reader[ridx].log_port);
     673    tpl_printf(vars, 0, "BOXID", "%ld", reader[ridx].boxid);
     674
     675    if(reader[ridx].r_port) tpl_printf(vars, 0, "R_PORT", "%d", reader[ridx].r_port);
     676    if(reader[ridx].l_port) tpl_printf(vars, 0, "L_PORT", "%d", reader[ridx].l_port);
     677
    684678    //Group
    685     fprintf(f,"<TR><TD>Group:</TD><TD><input name=\"grp\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
    686679    /*restore the settings format of group from long over bitarray*/
    687680    char *dot = ""; //flag for comma
     
    690683    for(i = 0; i < 32; i++){
    691684        if (grpbit[i] == '1'){
    692                 fprintf(f, "%s%d", dot, i+1);
     685            tpl_printf(vars, 1, "GRP", "%s%d", dot, i+1);
    693686                dot = ",";
    694687            }
    695688        }
    696     fprintf(f,"\"></TD></TR>\r\n");
    697     fprintf(f,"<TR><TD>Key:</TD><TD><input name=\"key\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%s\"></TD></TR>\r\n", reader[ridx].ncd_key);
    698     //fprintf(f,"<TR><TD>Password:</TD><TD><input name=\"password\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%s\"></TD></TR>\r\n", reader[ridx].gbox_pwd);
    699     fprintf(f,"<TR><TD>Pincode:</TD><TD><input name=\"pincode\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%s\"></TD></TR>\r\n", reader[ridx].pincode);
    700     fprintf(f,"<TR><TD>Readnano:</TD><TD><input name=\"readnano\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%s\"></TD></TR>\r\n", reader[ridx].emmfile);
    701689
    702690    //services
     
    706694    long2bitchar(reader[ridx].sidtabno,sidno);
    707695    struct s_sidtab *sidtab = cfg->sidtab;
    708     fprintf(f,"<TR><TD>Services:</TD><TD><TABLE cellspacing=\"0\" class=\"invisible\">");
    709     int pos=0;
    710     char *chk;
    711696    //build matrix
    712     for (; sidtab; sidtab=sidtab->next){
    713         chk="";
    714         if(sidok[pos]=='1') chk="checked";
    715         fprintf(f,"<TR><TD><INPUT NAME=\"services\" TYPE=\"CHECKBOX\" VALUE=\"%s\" %s> %s</TD>", sidtab->label, chk, sidtab->label);
    716         chk="";
    717         if(sidno[pos]=='1') chk="checked";
    718         fprintf(f,"<TD><INPUT NAME=\"services\" TYPE=\"CHECKBOX\" VALUE=\"!%s\" %s> !%s</TD></TR>\r\n", sidtab->label, chk, sidtab->label);
    719         pos++;
    720     }
    721     fprintf(f,"</TD></TR></TABLE>\r\n");
    722 
    723 
    724     fprintf(f,"<TR><TD>Inactivitytimeout:</TD><TD><input name=\"inactivitytimeout\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%d\"></TD></TR>\r\n", reader[ridx].tcp_ito);
    725     fprintf(f,"<TR><TD>Reconnecttimeout:</TD><TD><input name=\"reconnecttimeout\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%d\"></TD></TR>\r\n", reader[ridx].tcp_rto);
    726     fprintf(f,"<TR><TD>Disableserverfilter:</TD><TD><input name=\"disableserverfilter\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%d\"></TD></TR>\r\n", reader[ridx].ncd_disable_server_filt);
    727     fprintf(f,"<TR><TD>Fallback:</TD><TD><input name=\"fallback\" type=\"text\" size=\"3\" maxlength=\"3\" value=\"%d\"></TD></TR>\r\n", reader[ridx].fallback);
    728     //fprintf(f,"<TR><TD>Logport:</TD><TD><input name=\"logport\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%d\"></TD></TR>\r\n", reader[ridx].log_port);
    729     //fprintf(f,"<TR><TD>Caid:</TD><TD><input name=\"caid\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%s\"></TD></TR>\r\n", reader[ridx].log_port);
    730     /*---------------------CAID-----------------------------
    731     -------------------------------------------------------*/
     697    while(sidtab != NULL){
     698        tpl_addVar(vars, 0, "SIDLABEL", sidtab->label);
     699        if(sidok[i]=='1') tpl_addVar(vars, 0, "CHECKED", "checked");
     700        else tpl_addVar(vars, 0, "CHECKED", "");
     701        tpl_addVar(vars, 1, "SIDS", tpl_getTpl(vars, "READERCONFIGSIDOKBIT"));
     702        if(sidno[i]=='1') tpl_addVar(vars, 0, "CHECKED", "checked");
     703        else tpl_addVar(vars, 0, "CHECKED", "");
     704        tpl_addVar(vars, 1, "SIDS", tpl_getTpl(vars, "READERCONFIGSIDNOBIT"));
     705        sidtab=sidtab->next;
     706    }
     707
     708    // CAID
    732709    i = 0;
    733710    CAIDTAB *ctab = &reader[ridx].ctab;
    734 
    735     fprintf(f,"<TR><TD>CAID:</TD><TD><input name=\"caid\" type=\"text\" size=\"50\" maxlength=\"50\" value=\"");
    736     /*make string from caidtab*/
    737     if (ctab->caid[i]){
    738711        while(ctab->caid[i]) {
    739             if (i==0)   fprintf(f, "%04X", ctab->caid[i]);
    740             else fprintf(f, ",%04X", ctab->caid[i]);
    741             if(ctab->mask[i])   fprintf(f, "&%04X", ctab->mask[i]);
     712        if (i == 0) tpl_printf(vars, 1, "CAIDS", "%04X", ctab->caid[i]);
     713        else tpl_printf(vars, 1, "CAIDS", ",%04X", ctab->caid[i]);;
     714        if(ctab->mask[i])   tpl_printf(vars, 1, "CAIDS", "&%04X", ctab->mask[i]);
    742715            i++;
    743716        }
    744     }
    745     fprintf(f,"\"></TD></TR>\r\n");
    746 
    747 
    748     fprintf(f,"<TR><TD>Boxid:</TD><TD><input name=\"boxid\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"%ld\"></TD></TR>\r\n", reader[ridx].boxid);
    749 
    750 
    751 
    752     /*build form foot*/
    753     fprintf(f,"</TABLE>\r\n");
    754     fprintf(f,"<input type=\"submit\" value=\"OK\"></form>\r\n");
    755 
    756     fprintf(f,"<BR><BR>Reader not yet implemented - Nothing changes on click<BR><BR>");
    757 }
    758 
    759 void send_oscam_reader_config_do(FILE *f, struct uriparams *params) {
    760     int ridx;
    761 
    762     fprintf(f,"<BR><BR>\r\n");
    763     char *reader_ = getParam(params, "reader");
    764 
    765     for(ridx=0;ridx<CS_MAXREADER;ridx++){
    766         if (!reader[ridx].device[0]){
    767             fprintf(f,"Reader %s not found", reader_);
    768             return ;
    769         }
    770         if (!strcmp(reader_,reader[ridx].label)) break;
    771     }
    772 
    773     fprintf(f,"Reader: %s - Nothing changed", reader[ridx].label);
    774     fprintf(f,"<BR><BR>Reader not yet implemented<BR><BR>");
    775     refresh_oscam(REFR_READERS);
    776 }
    777 
    778 void send_oscam_user_config_add(FILE *f, struct uriparams *params) {
    779         struct s_auth *ptr;
    780         struct s_auth *account;
    781         int i, accidx=0;
    782 
    783         char *newuser = getParam(params, "user");
    784 
    785         if (strlen(newuser) > 0) {
    786 
    787             for (account=cfg->account; (account) ; account=account->next){
    788                 //account already exist - show config for this account
    789                 if(!strcmp(newuser, account->usr)){
    790                     (*params).params[0] = "user";
    791                     (*params).values[0] = newuser;
    792                     (*params).paramcount = 1;
    793                     send_oscam_user_config(f, params);
    794                     return;
    795                 }
    796                 //last account reached
    797                 if(!account->next) break;
    798                 accidx++;
    799             }
    800 
    801       if (!(ptr=malloc(sizeof(struct s_auth))))
    802       {
     717    fputs(tpl_getTpl(vars, "READERCONFIG"), f);
     718    }
     719
     720void send_oscam_user_config_edit(struct templatevars *vars, FILE *f, struct uriparams *params){
     721    struct s_auth *account, *ptr;
     722    char *user = getParam(params, "user");
     723    int i, j;
     724
     725    for (account = cfg->account; account != NULL && strcmp(user, account->usr) != 0; account = account->next);
     726
     727    // Create a new user if it doesn't yet
     728    if (account == NULL){
     729      if (!(account=malloc(sizeof(struct s_auth)))){
    803730        cs_log("Error allocating memory (errno=%d)", errno);
    804731        return;
    805732      }
    806       if (account)
    807         account->next=ptr;
    808       else
    809         cfg->account=ptr;
    810       account=ptr;
     733      if(cfg->account == NULL) cfg->account = account;
     734      else {
     735        for (ptr = cfg->account; ptr != NULL && ptr->next != NULL; ptr = ptr->next);
     736        ptr->next = account;
     737      }
    811738      memset(account, 0, sizeof(struct s_auth));
    812       strncpy((char *)account->usr, newuser, sizeof(account->usr)-1);
     739      strncpy((char *)account->usr, user, sizeof(account->usr)-1);
    813740      account->au=(-1);
    814741      account->monlvl=cfg->mon_level;
     
    816743      for (i=1; i<CS_MAXCAIDTAB; account->ctab.mask[i++]=0xffff);
    817744      for (i=1; i<CS_MAXTUNTAB; account->ttab.bt_srvid[i++]=0x0000);
    818             accidx++;
    819745#ifdef CS_ANTICASC
    820746      account->ac_users=cfg->ac_users;
    821747      account->ac_penalty=cfg->ac_penalty;
    822       account->ac_idx = accidx;
     748      account->ac_idx = account->ac_idx + 1;
    823749#endif
     750        tpl_addVar(vars, 1, "MESSAGE", "<b>New user has been added with default settings</b><BR>");
     751        if (write_userdb()==0) refresh_oscam(REFR_ACCOUNTS);
     752        else tpl_addVar(vars, 1, "MESSAGE", "<b>Writing configuration to disk failed!</b><BR>");
     753        // need to reget account as writing to disk changes account!
     754        for (account = cfg->account; account != NULL && strcmp(user, account->usr) != 0; account = account->next);
    824755    }
    825     (*params).params[0] = "user";
    826     (*params).values[0] = newuser;
    827     (*params).paramcount = 1;
    828     send_oscam_user_config(f, params);
    829 
    830 }
    831 
    832 void send_oscam_user_config_delete(FILE *f, struct uriparams *params) {
    833 
    834     int found = 0;
    835     struct s_auth *account, *account2;
    836 
    837     char *user = getParam(params, "user");
    838    
    839     account=cfg->account;
    840     if(strcmp(account->usr, user) == 0){
    841         cfg->account = account->next;
    842         free(account);
    843         found = 1;
    844     } else if (account->next != NULL){
    845         do{
    846             if(strcmp(account->next->usr, user) == 0){
    847                 account2 = account->next;
    848                 account->next = account2->next;
    849                 free(account2);
    850                 found = 1;
    851                 break;
    852             }
    853         } while ((account = account->next) && (account->next != NULL));
    854     }
    855 
    856     if (found>0){
    857         if (write_userdb()==0)
    858             refresh_oscam(REFR_ACCOUNTS);
    859         else
    860             fprintf(f,"<B>Write Config failed</B><BR><BR>\r\n");
    861     }
    862     else
    863         fprintf(f,"<B>User not found</B><BR><BR>\r\n");
    864     (*params).paramcount = 0;
    865     send_oscam_user_config(f, params);
    866 }
    867 
    868 void send_oscam_user_config_do(FILE *f, struct uriparams *params) {
    869 
    870     struct s_auth *account;
    871     int i;
     756
     757    if(strcmp(getParam(params, "action"), "execute") == 0){
    872758    char servicelabels[255]="";
    873 
    874     //find username within params
    875     char *user = getParam(params, "user");
    876 
    877     //identfy useraccount
    878     for (account=cfg->account; (account) ; account=account->next){
    879         if(!strcmp(user, account->usr))
    880             break;
    881     }
    882 
    883759    //clear group
    884760    account->grp = 0;
    885761
    886     //fprintf(f,"<BR><BR>\r\n");
    887 
    888762    for(i=0;i<(*params).paramcount;i++){
    889763        if ((strcmp((*params).params[i], "action")) && (strcmp((*params).params[i], "user"))){
    890             //fprintf(f,"%s = %s<BR>\r\n", (*params).params[i], (*params).values[i]);
    891764            if (!strcmp((*params).params[i], "services"))
    892765                sprintf(servicelabels + strlen(servicelabels), "%s,", (*params).values[i]);
     
    894767                chk_account((*params).params[i], (*params).values[i], account);
    895768        }
    896     //  else if (!strcmp((*params).params[i], "user"))
    897     //      fprintf(f,"<B>User %s is reconfigured as follow</B><BR><BR>\r\n", (*params).values[i]);
    898     }
    899 
     769    }
    900770    chk_account("services", servicelabels, account);
    901 
    902     if (write_userdb()==0)
    903         refresh_oscam(REFR_ACCOUNTS);
    904     else
    905         fprintf(f,"<B>Write Config failed</B><BR><BR>\r\n");
    906     (*params).paramcount = 0;
    907     send_oscam_user_config(f, params);
    908 }
    909 
    910 void send_oscam_user_config(FILE *f, struct uriparams *params) {
    911 
    912     int i;
    913     struct s_auth *account;
    914     char *action = getParam(params, "action");
    915     if ((*params).paramcount>0){
    916         if (!strcmp(action, "execute")) {
    917             send_oscam_user_config_do(f, params);
    918             return;
    919         }   else if (!strcmp(action, "adduser")) {
    920             send_oscam_user_config_add(f, params);
    921             return;
    922         }   else if (!strcmp(action, "delete")) {
    923             send_oscam_user_config_delete(f, params);
    924             return;
    925         }
    926     }   else {
    927         /* No Parameters given --> list accounts*/
    928         char *status = "offline";
    929         char *expired = "";
    930         char *classname="offline";
    931         char *lastchan="&nbsp;";
    932         time_t now = time((time_t)0);
    933         int isec=0;
    934 
    935         fprintf(f,"<BR><BR><TABLE cellspacing=\"0\" cellpadding=\"10\">\r\n");
    936         fprintf(f,"<TR><TH>Label</TH>\r\n\t<TH>Status</TH>\r\n\t<TH>Last Channel</TH>\r\n\t<TH>Idle (Sec)</TH>\r\n\t<TH colspan=\"2\" align=\"center\">Action</TH>\r\n</TR>");
    937         for (account=cfg->account; (account) ; account=account->next){
    938             expired = ""; classname="offline";
    939             if(account->expirationdate && account->expirationdate<time(NULL)){
    940                 expired = " (expired)";
    941                 classname = "expired";
    942             }
    943             status="offline";
    944 
    945             //search account in active clients
    946             for (i=0; i<CS_MAXPID; i++)
    947                 if (!strcmp(client[i].usr, account->usr)){
    948                     //30 secs without ecm is offline
    949                     if ((now - client[i].lastecm) < 30){
    950                         status = "<b>online</b>";classname="online";
    951                         lastchan = monitor_get_srvname(client[i].last_srvid);
    952                         isec = now - client[i].last;
    953                     }
    954                 }
    955             fprintf(f,"<TR class=\"%s\">\r\n", classname);
    956             fprintf(f,"\t<TD>%s</TD>\r\n\t<TD>%s%s</TD>\r\n\t<TD>%s</TD>\r\n\t<TD>%d</TD>\r\n\t<TD><A HREF=\"userconfig.html?user=%s\">Edit Settings</A></TD>\r\n",account->usr, status, expired, lastchan, isec, account->usr);
    957             fprintf(f,"\t<TD><A HREF=\"userconfig.html?user=%s&action=delete\">Delete User</A></TD>\r\n",account->usr);
    958             fprintf(f,"</TR>\r\n");
    959             isec = 0;
    960             lastchan = "&nbsp;";
    961         }
    962         fprintf(f,"<TR>\r\n");
    963         fprintf(f,"\t<FORM action=\"/userconfig.html\" method=\"get\">\r\n");
    964         fprintf(f,"\t<TD>New User:</TD>\r\n");
    965         fprintf(f,"\t<TD colspan=\"2\"><input name=\"user\" type=\"text\"></TD>\r\n");
    966         fprintf(f,"\t<input name=\"action\" type=\"hidden\" value=\"adduser\">\r\n");
    967         fprintf(f,"\t<TD colspan=\"3\" align=\"center\"><input type=\"submit\" value=\"Add User\"></TD>\r\n");
    968         fprintf(f,"\t</FORM>\r\n");
    969         fprintf(f,"<TR>\r\n");
    970         fprintf(f,"</TABLE>\r\n");
    971 
    972         return;
    973     }
    974 
    975     fprintf(f,"<BR><BR>\r\n");
    976    
    977     char *user = getParam(params, "user");
    978 
    979     /*identfy useraccount*/
    980     for (account=cfg->account; (account) ; account=account->next){
    981         if(!strcmp(user, account->usr))
    982             break;
    983     }
    984 
    985     fprintf(f,"<form action=\"/userconfig.html\" method=\"get\">");
    986     fprintf(f,"<input name=\"user\" type=\"hidden\" value=\"%s\">\r\n", account->usr);
    987     fprintf(f,"<input name=\"action\" type=\"hidden\" value=\"execute\">\r\n");
    988     fprintf(f,"<TABLE cellspacing=\"0\">");
    989     fprintf(f,"<TH>&nbsp;</TH><TH>Edit User %s </TH>", account->usr);
    990     //Password
    991     fprintf(f,"<TR><TD>Password:</TD><TD><input name=\"pwd\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"%s\"></TD></TR>\r\n", account->pwd);
     771        tpl_addVar(vars, 1, "MESSAGE", "<B>Settings updated</B><BR><BR>"); 
     772        if (write_userdb()==0) refresh_oscam(REFR_ACCOUNTS);
     773        else tpl_addVar(vars, 1, "MESSAGE", "<B>Write Config failed</B><BR><BR>");
     774    }
     775
     776    tpl_addVar(vars, 0, "USERNAME", account->usr);
     777    tpl_addVar(vars, 0, "PASSWORD", account->pwd); 
     778
    992779    //Expirationdate
    993780    struct tm * timeinfo = localtime (&account->expirationdate);
    994781    char buf [80];
    995782    strftime (buf,80,"%Y-%m-%d",timeinfo);
    996     if(strcmp(buf,"1970-01-01"))
    997         fprintf(f,"<TR><TD>Exp. Date:</TD><TD><input name=\"expdate\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"%s\"></TD></TR>\r\n",buf);
    998     else
    999         fprintf(f,"<TR><TD>Exp. Date:</TD><TD><input name=\"expdate\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"\"></TD></TR>\r\n");
     783    if(strcmp(buf,"1970-01-01")) tpl_addVar(vars, 0, "EXPDATE", buf);
    1000784    //Group
    1001     fprintf(f,"<TR><TD>Group:</TD><TD><input name=\"group\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
    1002785    /*restore the settings format of group from long over bitarray*/
    1003786    char *dot = ""; //flag for comma
     
    1006789    for(i = 0; i < 32; i++){
    1007790        if (grpbit[i] == '1'){
    1008                 fprintf(f, "%s%d", dot, i+1);
     791                tpl_printf(vars, 1, "GROUPS", "%s%d", dot, i+1);
    1009792                dot = ",";
    1010793            }
    1011794    }
    1012     fprintf(f,"\"></TD></TR>\r\n");
    1013795    //Hostname
    1014     if (strlen((char *)account->dyndns)>0)
    1015         fprintf(f,"<TR><TD>Hostname:</TD><TD><input name=\"hostname\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"%s\"></TD></TR>\r\n", account->dyndns);
     796    tpl_addVar(vars, 0, "DYNDNS", (char *)account->dyndns);
     797   
    1016798    //Uniq
    1017     fprintf(f,"<TR><TD>Uniq:</TD><TD><select name=\"uniq\" >\r\n");
    1018         for(i = 0; i < 3; i++){
    1019         if(i == account->uniq)
    1020             fprintf(f,"\t<option value=\"%d\" selected>%s</option>\r\n", i, uniq[i]);
    1021         else
    1022             fprintf(f,"\t<option value=\"%d\">%s</option>\r\n", i, uniq[i]);
    1023         }
    1024     fprintf(f,"</SELECT></TD></TR>\r\n");
     799    tpl_printf(vars, 0, "TMP", "UNIQSELECTED%d", account->uniq);
     800    tpl_addVar(vars, 0, tpl_getVar(vars, "TMP"), "selected");
     801   
    1025802    //Sleep
    1026     if(!account->tosleep)
    1027         fprintf(f,"<TR><TD>Sleep:</TD><TD><input name=\"sleep\" type=\"text\" size=\"4\" maxlength=\"4\" value=\"0\"></TD></TR>\r\n");
    1028     else
    1029         fprintf(f,"<TR><TD>Sleep:</TD><TD><input name=\"sleep\" type=\"text\" size=\"4\" maxlength=\"4\" value=\"%d\"></TD></TR>\r\n", account->tosleep);
     803    if(!account->tosleep) tpl_addVar(vars, 0, "SLEEP", "0");
     804    else tpl_printf(vars, 0, "SLEEP", "%d", account->tosleep);
    1030805    //Monlevel selector
    1031     fprintf(f,"<TR><TD>Monlevel:</TD><TD><select name=\"monlevel\" >\r\n");
    1032     for(i = 0; i < 5; i++){
    1033         if(i == account->monlvl)
    1034             fprintf(f,"\t<option value=\"%d\" selected>%s</option>\r\n", i, monlevel[i]);
    1035         else
    1036             fprintf(f,"\t<option value=\"%d\">%s</option>\r\n", i, monlevel[i]);
    1037     }
    1038     fprintf(f,"</select></TD></TR>\r\n");
     806    tpl_printf(vars, 0, "TMP", "MONSELECTED%d", account->monlvl);
     807    tpl_addVar(vars, 0, tpl_getVar(vars, "TMP"), "selected");
     808
    1039809    //AU Selector
    1040     fprintf(f,"<TR><TD>AU:</TD><TD><select name=\"au\" >\r\n");
    1041     if (!account->au)
    1042         fprintf(f,"\t<option value=\" \" selected>none</option>\r\n");
    1043     else
    1044         fprintf(f,"\t<option value=\" \">none</option>\r\n");
    1045 
    1046     if (account->autoau == 1)
    1047         fprintf(f,"\t<option value=\"1\" selected>auto</option>\r\n");
    1048     else
    1049         fprintf(f,"\t<option value=\"1\">auto</option>\r\n");
    1050 
     810    if (!account->au) tpl_addVar(vars, 0, "AUSELECTED", "selected");
     811    if (account->autoau == 1) tpl_addVar(vars, 0, "AUTOAUSELECTED", "selected");
    1051812    int ridx;
    1052813    for (ridx=0; ridx<CS_MAXREADER; ridx++){
    1053814        if(!reader[ridx].device[0]) break;
    1054 
    1055         if (account->au == ridx)
    1056             fprintf(f,"\t<option value=\"%s\" selected>%s</option>\r\n", reader[ridx].label, reader[ridx].label);
    1057         else
    1058             fprintf(f,"\t<option value=\"%s\">%s</option>\r\n", reader[ridx].label, reader[ridx].label);
    1059     }
    1060     fprintf(f,"</select></TD></TR>\r\n");
    1061 
    1062     /*---------------------SERVICES-------------------------
    1063     -------------------------------------------------------*/
     815        tpl_addVar(vars, 0, "READERNAME", reader[ridx].label);
     816        if (account->au == ridx) tpl_addVar(vars, 0, "SELECTED", "selected");
     817        else tpl_addVar(vars, 0, "SELECTED", "");
     818        tpl_addVar(vars, 1, "RDROPTION", tpl_getTpl(vars, "USEREDITRDRSELECTED"));
     819    }
     820
     821    /* SERVICES */
    1064822    //services - first we have to move the long sidtabok/sidtabno to a binary array
    1065823    char sidok[33];
     
    1068826    long2bitchar(account->sidtabno,sidno);
    1069827    struct s_sidtab *sidtab = cfg->sidtab;
    1070     fprintf(f,"<TR><TD>Services:</TD><TD><TABLE cellspacing=\"0\" class=\"invisible\">");
    1071     int pos=0;
    1072     char *chk;
    1073828    //build matrix
    1074     for (; sidtab; sidtab=sidtab->next){
    1075         chk="";
    1076         if(sidok[pos]=='1') chk="checked";
    1077         fprintf(f,"<TR><TD><INPUT NAME=\"services\" TYPE=\"CHECKBOX\" VALUE=\"%s\" %s> %s</TD>", sidtab->label, chk, sidtab->label);
    1078         chk="";
    1079         if(sidno[pos]=='1') chk="checked";
    1080         fprintf(f,"<TD><INPUT NAME=\"services\" TYPE=\"CHECKBOX\" VALUE=\"!%s\" %s> !%s</TD></TR>\r\n", sidtab->label, chk, sidtab->label);
    1081         pos++;
    1082     }
    1083     fprintf(f,"</TD></TR></TABLE>\r\n");
    1084 
    1085     /*---------------------CAID-----------------------------
    1086     -------------------------------------------------------*/
     829    while(sidtab != NULL){
     830        tpl_addVar(vars, 0, "SIDLABEL", sidtab->label);
     831        if(sidok[i]=='1') tpl_addVar(vars, 0, "CHECKED", "checked");
     832        else tpl_addVar(vars, 0, "CHECKED", "");
     833        tpl_addVar(vars, 1, "SIDS", tpl_getTpl(vars, "USEREDITSIDOKBIT"));
     834        if(sidno[i]=='1') tpl_addVar(vars, 0, "CHECKED", "checked");
     835        else tpl_addVar(vars, 0, "CHECKED", "");
     836        tpl_addVar(vars, 1, "SIDS", tpl_getTpl(vars, "USEREDITSIDNOBIT"));
     837        sidtab=sidtab->next;
     838    }
     839    /* CAID */
     840    dot="";
    1087841    i = 0;
    1088842    CAIDTAB *ctab = &account->ctab;
    1089 
    1090     fprintf(f,"<TR><TD>CAID:</TD><TD><input name=\"caid\" type=\"text\" size=\"50\" maxlength=\"50\" value=\"");
    1091     /*make string from caidtab*/
    1092     if (ctab->caid[i]){
    1093843        while(ctab->caid[i]) {
    1094             if (i==0)   fprintf(f, "%04X", ctab->caid[i]);
    1095             else fprintf(f, ",%04X", ctab->caid[i]);
    1096             if(ctab->mask[i])   fprintf(f, "&%04X", ctab->mask[i]);
    1097             i++;
    1098         }
    1099     }
    1100     fprintf(f,"\"></TD></TR>\r\n");
     844        tpl_printf(vars, 1, "CAIDS", "%s%04X", dot, ctab->caid[i]);
     845        if(ctab->mask[i])   tpl_printf(vars, 1, "CAIDS", "&%04X", ctab->mask[i]);
     846        if(ctab->cmap[i])   tpl_printf(vars, 1, "CAIDS", ":%04X", ctab->cmap[i]);
     847        dot=",";
     848        ++i;
     849    }
    1101850
    1102851    /*IDENT*/
    1103     fprintf(f,"<TR><TD>Ident:</TD><TD><input name=\"ident\" type=\"text\" size=\"50\" maxlength=\"50\" value=\"");
    1104 
    1105     int j;
    1106852    dot="";
    1107853    FTAB *ftab = &account->ftab;
    1108     for (i=0;i<ftab->nfilts;i++){
    1109         fprintf(f, "%s%04X", dot, ftab->filts[i].caid);
    1110 
    1111         for (j=0;j<ftab->filts[i].nprids;j++)
    1112             fprintf(f, ":%06lX", ftab->filts[i].prids[j]);
    1113 
     854    for (i = 0; i < ftab->nfilts; ++i){
     855        tpl_printf(vars, 1, "IDENTS", "%s%04X", dot, ftab->filts[i].caid);
     856        dot=":";
     857        for (j = 0; j < ftab->filts[i].nprids; ++j) {
     858            tpl_printf(vars, 1, "IDENTS", "%s%06lX", dot, ftab->filts[i].prids[j]);
     859            dot=",";
     860        }
    1114861        dot=";";
    1115862    }
    1116     fprintf(f,"\"></TD></TR>\r\n");
    1117863
    1118864    /*Betatunnel*/
     865    dot="";
    1119866    i = 0;
    1120867    TUNTAB *ttab = &account->ttab;
    1121 
    1122     fprintf(f,"<TR><TD>Betatunnel:</TD><TD><input name=\"betatunnel\" type=\"text\" size=\"50\" maxlength=\"50\" value=\"");
    1123     /*make string from Betatunneltab*/
    1124     if (ttab->bt_caidfrom[i]) {
    1125868        while(ttab->bt_caidfrom[i]) {
    1126             if (i==0)   fprintf(f, "%04X", ttab->bt_caidfrom[i]);
    1127             else fprintf(f, ",%04X", ttab->bt_caidfrom[i]);
    1128             if(ttab->bt_caidto[i]) fprintf(f, ".%04X", ttab->bt_caidto[i]);
    1129             if(ttab->bt_srvid[i])   fprintf(f, ":%04X", ttab->bt_srvid[i]);
    1130             i++;
    1131         }
    1132     }
    1133     fprintf(f,"\"></TD></TR>\r\n");
     869        tpl_printf(vars, 1, "BETATUNNELS", "%s%04X", dot, ttab->bt_caidfrom[i]);
     870        if(ttab->bt_srvid[i])   tpl_printf(vars, 1, "BETATUNNELS", ".%04X", ttab->bt_srvid[i]);
     871        if(ttab->bt_caidto[i]) tpl_printf(vars, 1, "BETATUNNELS", ":%04X", ttab->bt_caidto[i]);
     872        dot=",";
     873        ++i;
     874    }
    1134875
    1135876#ifdef CS_ANTICASC
    1136     fprintf(f,"<TR><TD>Anticascading numusers:</TD><TD><input name=\"numusers\" type=\"text\" size=\"3\" maxlength=\"3\" value=\"%d\"></TD></TR>\r\n", account->ac_users);
    1137     fprintf(f,"<TR><TD>Anticascading penalty:</TD><TD><input name=\"penalty\" type=\"text\" size=\"3\" maxlength=\"3\" value=\"%d\"></TD></TR>\r\n", account->ac_penalty);
     877    tpl_printf(vars, 0, "AC_USERS", "%d", account->ac_users);
     878    tpl_printf(vars, 0, "AC_PENALTY", "%d", account->ac_penalty);
    1138879#endif
    1139     fprintf(f,"<TR><TD>&nbsp;</TD><TD align=\"right\"><input type=\"submit\" value=\"Save Settings\" title=\"Save settings and reload users\"></TD></TR>\r\n");
    1140     fprintf(f,"</TABLE>\r\n");
    1141     fprintf(f,"</form>\r\n");
    1142 }
    1143 
    1144 void send_oscam_entitlement(FILE *f, struct uriparams *params) {
    1145 
    1146   /*build entitlements from reader init history*/
     880    fputs(tpl_getTpl(vars, "USEREDIT"), f);
     881}
     882
     883void send_oscam_user_config(struct templatevars *vars, FILE *f, struct uriparams *params) {
     884    struct s_auth *account, *account2; 
     885    char *user = getParam(params, "user");
     886    int i, found = 0;
     887
     888    if (strcmp(getParam(params, "action"), "delete") == 0){
     889        account=cfg->account;
     890        if(strcmp(account->usr, user) == 0){
     891            cfg->account = account->next;
     892            free(account);
     893            found = 1;
     894        } else if (account->next != NULL){
     895            do{
     896                if(strcmp(account->next->usr, user) == 0){
     897                    account2 = account->next;
     898                    account->next = account2->next;
     899                    free(account2);
     900                    found = 1;
     901                    break;
     902                }
     903            } while ((account = account->next) && (account->next != NULL));
     904        }
     905
     906        if (found > 0){
     907            tpl_addVar(vars, 1, "MESSAGE", "<b>Account has been deleted!</b><BR>");
     908            if (write_userdb()==0) refresh_oscam(REFR_ACCOUNTS);
     909            else tpl_addVar(vars, 1, "MESSAGE", "<b>Writing configuration to disk failed!</b><BR>");
     910        } else tpl_addVar(vars, 1, "MESSAGE", "<b>Sorry but the specified user doesn't exist. No deletion will be made!</b><BR>");
     911    }
     912    /* List accounts*/
     913    char *status = "offline";
     914    char *expired = "";
     915    char *classname="offline";
     916    char *lastchan="&nbsp;";
     917    time_t now = time((time_t)0);
     918    int isec=0;
     919
     920    for (account=cfg->account; (account) ; account=account->next){
     921        expired = ""; classname="offline";
     922        if(account->expirationdate && account->expirationdate<time(NULL)){
     923            expired = " (expired)";
     924            classname = "expired";
     925            }
     926        status="offline";
     927
     928        //search account in active clients
     929        for (i=0; i<CS_MAXPID; i++)
     930            if (!strcmp(client[i].usr, account->usr)){
     931                //30 secs without ecm is offline
     932                if ((now - client[i].lastecm) < 30){
     933                    status = "<b>online</b>";classname="online";
     934                    lastchan = monitor_get_srvname(client[i].last_srvid);
     935                    isec = now - client[i].last;
     936        }
     937    }
     938        tpl_addVar(vars, 0, "CLASSNAME", classname);
     939        tpl_addVar(vars, 0, "USER", account->usr);
     940        tpl_addVar(vars, 0, "USERENC", tpl_addTmp(vars, urlencode(account->usr)));
     941        tpl_addVar(vars, 0, "STATUS", status);
     942        tpl_addVar(vars, 0, "EXPIRED", expired);
     943        tpl_addVar(vars, 0, "LASTCHANNEL", lastchan);
     944        tpl_printf(vars, 0, "IDLESECS", "%d", isec);
     945        tpl_addVar(vars, 1, "USERCONFIGS", tpl_getTpl(vars, "USERCONFIGLISTBIT"));
     946        isec = 0;
     947        lastchan = "&nbsp;";
     948    }
     949    fputs(tpl_getTpl(vars, "USERCONFIGLIST"), f);
     950}
     951
     952void send_oscam_entitlement(struct templatevars *vars, FILE *f, struct uriparams *params) {
     953  /* build entitlements from reader init history */
    1147954    int ridx;
    1148     char *p, *ctyp;
    1149 
    1150     if((*params).paramcount==0){
    1151         fprintf(f, "<BR><BR>\r\n");
    1152         fprintf(f,"<TABLE cellspacing=\"0\">");
    1153         fprintf(f,"<TR><TH>Reader</TH><TH>Protocol</TH><TH>&nbsp;</TH></TR>");
    1154 
    1155         for (ridx=0; ridx<CS_MAXREADER; ridx++){
    1156 
    1157             switch(reader[ridx].typ)
    1158             {
    1159                 case R_MOUSE   : ctyp="mouse";    break;
    1160                 case R_INTERNAL: ctyp="intern";   break;
    1161                 case R_SMART   : ctyp="smartreader";    break;
    1162                 case R_CAMD35  : ctyp="camd 3.5x";break;
    1163                 case R_CAMD33  : ctyp="camd 3.3x";break;
    1164                 case R_NEWCAMD : ctyp="newcamd";  break;
    1165                 case R_RADEGAST: ctyp="radegast"; break;
    1166                 case R_SERIAL  : ctyp="serial";   break;
    1167                 case R_GBOX    : ctyp="gbox";     break;
    1168 #ifdef HAVE_PCSC
    1169                 case R_PCSC    : ctyp="pcsc";     break;
     955    char *p;
     956    char *reader_ = getParam(params, "reader");
     957    if(strlen(reader_) > 0){   
     958#ifdef CS_RDR_INIT_HIST
     959        for (ridx=0; ridx<CS_MAXREADER && strcmp(reader_, reader[ridx].label) != 0; ridx++);
     960        if(ridx<CS_MAXREADER){
     961            for (p=(char *)reader[ridx].init_history; *p; p+=strlen(p)+1){
     962                tpl_printf(vars, 1, "LOGHISTORY", "%s<BR>\n", p);
     963            }
     964        }
     965#else
     966        tpl_addVar(vars, 0, "LOGHISTORY", "The flag CS_RDR_INIT_HIST is not set in your binary<BR>\n");
    1170967#endif
    1171                 case R_CCCAM   : ctyp="cccam";    break;
    1172                 case R_CS378X  : ctyp="cs378x";   break;
    1173                 default        : ctyp="unknown";  break;
    1174             }
    1175 
    1176             if(!reader[ridx].device[0]) break;
    1177             fprintf(f, "\t<TR><TD>%s</TD><TD>%s</TD><TD><A HREF=\"entitlements.html?user=%s\">Check</A></TD></TR>\r\n", reader[ridx].label, ctyp, reader[ridx].label);
    1178         }
    1179         fprintf(f, "</TABLE>\r\n");
    1180     }
    1181     else {
    1182 
    1183         char *user = getParam(params, "user");
    1184 
    1185         fprintf(f, "<BR><BR>Entitlement for %s<BR><BR>\r\n", user);
    1186 
    1187         for (ridx=0; ridx<CS_MAXREADER; ridx++)
    1188             if (!strcmp(user, reader[ridx].label)) break;
    1189 
    1190         fprintf(f, "<DIV class=\"log\">");
    1191 #ifdef CS_RDR_INIT_HIST
    1192 
    1193         for (p=(char *)reader[ridx].init_history; *p; p+=strlen(p)+1)
    1194             fprintf(f, "%s<BR>\n",p);
    1195 
    1196 #else
    1197 
    1198         fprintf(f, "the flag CS_RDR_INIT_HIST is not set in your binary<BR>\n");
    1199 
    1200 #endif
    1201 
    1202         fprintf(f, "</DIV>");
    1203     }
    1204 
    1205 }
    1206 
    1207 void monitor_client_status(struct templatevars *vars, char id, int i){
    1208     if (client[i].pid) {
     968        tpl_addVar(vars, 0, "READERNAME", reader_);
     969    }
     970    fputs(tpl_getTpl(vars, "ENTITLEMENTS"), f);
     971}
     972
     973void send_oscam_status(struct templatevars *vars, FILE *f) {
     974    int i;
    1209975        char *usr;
    1210976        int lsec, isec, cnr, con, cau;
    1211977        time_t now = time((time_t)0);
    1212978        struct tm *lt;
    1213        
     979    for (i=0; i<CS_MAXPID; i++) {
     980        if (client[i].pid) {           
    1214981        if ((cfg->mon_hideclient_to <= 0) ||    (((now-client[i].lastecm)/60)<cfg->mon_hideclient_to) ||
    1215982        (((now-client[i].lastemm)/60)<cfg->mon_hideclient_to) || (client[i].typ!='c')){
     
    1221988           
    1222989            if (client[i].dup) con=2;
    1223             else {
    1224                 if ((client[i].tosleep) && (now-client[i].lastswitch>client[i].tosleep)) con=1;
     990                else if ((client[i].tosleep) && (now-client[i].lastswitch>client[i].tosleep)) con=1;
    1225991                else con=0;
    1226             }
    1227992           
    1228993            if (i-cdiff>0) cnr=i-cdiff;
     
    12551020}
    12561021
    1257 void send_oscam_status(struct templatevars *vars, FILE *f) {
    1258     int i; 
    1259     for (i=0; i<CS_MAXPID; i++) monitor_client_status(vars, client[i].pid, i);
    1260    
    12611022#ifdef CS_LOGHISTORY
    12621023    for (i=(*loghistidx+3) % CS_MAXLOGHIST; i!=*loghistidx; i=(i+1) % CS_MAXLOGHIST){
     
    12731034}
    12741035
    1275 void send_oscam_sidtab(FILE *f) {
     1036void send_oscam_services(struct templatevars *vars, FILE *f) {
    12761037  struct s_sidtab *sidtab = cfg->sidtab;
    1277 
    1278     fprintf(f,"<BR><BR><DIV class=\"log\">");
    1279 
    1280   for (; sidtab; sidtab=sidtab->next)
    1281   {
    1282     int i, comma;
    1283     char buf[1024];
    1284     fprintf(f,"label=%s<BR>\r\n", sidtab->label);
    1285     sprintf(buf, "caid(%d)=", sidtab->num_caid);
    1286     comma=0;
     1038    int i; 
     1039
     1040    while(sidtab != NULL){ 
    12871041    for (i=0; i<sidtab->num_caid; i++){
    1288             if (comma==0){
    1289                 sprintf(buf+strlen(buf), "%04X",sidtab->caid[i]);
    1290                 comma++;
    1291             }
    1292             else
    1293                 sprintf(buf+strlen(buf), ",%04X",sidtab->caid[i]);
     1042            if (i==0) tpl_printf(vars, 0, "CAIDS", "%04X", sidtab->caid[i]);
     1043            else tpl_printf(vars, 1, "CAIDS", ",%04X", sidtab->caid[i]);
    12941044    }
    12951045
    1296     fprintf(f,"%s<BR>\r\n", buf);
    1297     sprintf(buf, "provider(%d)=", sidtab->num_provid);
    1298     comma=0;
    12991046    for (i=0; i<sidtab->num_provid; i++){
    1300             if (comma==0){
    1301                 sprintf(buf+strlen(buf), "%ld08X", sidtab->provid[i]);
    1302                 comma++;
    1303             }
    1304             else
    1305                 sprintf(buf+strlen(buf), ",%ld08X", sidtab->provid[i]);
     1047            if (i==0) tpl_printf(vars, 0, "PROVIDS", "%ld08X", sidtab->provid[i]);
     1048            else tpl_printf(vars, 1, "PROVIDS", ",%ld08X", sidtab->provid[i]);
    13061049    }
    13071050
    1308     fprintf(f,"%s<BR>\r\n", buf);
    1309     sprintf(buf, "services(%d)=", sidtab->num_srvid);
    1310     comma=0;
    13111051    for (i=0; i<sidtab->num_srvid; i++){
    1312         if (comma==0){
    1313                 sprintf(buf+strlen(buf), "%04X", sidtab->srvid[i]);
    1314                 comma++;
    1315             }
    1316             else
    1317                 sprintf(buf+strlen(buf), ",%04X", sidtab->srvid[i]);
    1318         }
    1319     fprintf(f,"%s<BR><BR>\r\n", buf);
     1052            if (i==0) tpl_printf(vars, 0, "SRVIDS", "%04X", sidtab->srvid[i]);
     1053            else tpl_printf(vars, 1, "SRVIDS", ",%04X", sidtab->srvid[i]);
     1054        }
     1055        tpl_addVar(vars, 0, "LABEL", sidtab->label);
     1056        tpl_printf(vars, 0, "CAIDNUM", "%d", sidtab->num_caid);
     1057        tpl_printf(vars, 0, "PROVIDNUM", "%d",sidtab->num_provid);
     1058        tpl_printf(vars, 0, "SRVIDNUM", "%d", sidtab->num_srvid);
     1059        tpl_addVar(vars, 1, "SIDTABS", tpl_getTpl(vars, "SIDTABBIT"));
     1060        sidtab=sidtab->next;
    13201061  }
    1321   fprintf(f,"</DIV>");
     1062    fputs(tpl_getTpl(vars, "SIDTAB"), f);
    13221063}
    13231064
     
    13341075  char *pch;
    13351076  char *pch2;
    1336   /*list of possible pages*/
     1077  /* List of possible pages */
    13371078  char *pages[]={   "/config.html",
    13381079            "/readers.html",
     
    13411082            "/userconfig.html",
    13421083            "/readerconfig.html",
    1343             "/readerconfig_do.html",
    13441084            "/services.html",
     1085            "/user_edit.html",
    13451086            "/site.css"};
    13461087  int pagescnt = sizeof(pages)/sizeof(char *);  // Calculate the amount of items in array
     
    13571098  path = strtok(NULL, " ");
    13581099  protocol = strtok(NULL, "\r");
    1359   /* Throw away references to anchors (these are dealt with by the browser and not the server!) */
    1360   path = strtok(path, "#");
    13611100  if(method == NULL || path == NULL || protocol == NULL) return -1;
    13621101
     
    13951134  /* last value wasn't processed in the loop yet... */
    13961135  if(parsemode == -1 && params.paramcount <= MAXGETPARAMS){
     1136      urldecode(pch2);
    13971137      params.values[params.paramcount-1] = pch2;
    13981138  }
     
    14221162    if(authok == 2) strcat(tmp, ", stale=true");
    14231163      send_headers(f, 401, "Unauthorized", tmp, "text/html");
    1424       return -1;
     1164      return 0;
    14251165    }
    14261166
    14271167    /*build page*/
    14281168  send_headers(f, 200, "OK", NULL, "text/html");
    1429     if(pgidx == -1 || pgidx == 3){
     1169  if(pgidx == 8) send_css(f);
     1170    else if(pgidx != 0){
    14301171        time_t t;
    14311172        struct templatevars *vars = tpl_create();
     
    14361177        tpl_addVar(vars, 0, "CS_VERSION", CS_VERSION);
    14371178        tpl_addVar(vars, 0, "CS_SVN_VERSION", CS_SVN_VERSION);
     1179        if(cfg->http_refresh > 0 && (pgidx == 3 || pgidx == -1)){
    14381180        tpl_printf(vars, 0, "REFRESHTIME", "%d", cfg->http_refresh);
     1181            tpl_addVar(vars, 0, "REFRESH", tpl_getTpl(vars, "REFRESH"));
     1182        }
    14391183        tpl_printf(vars, 0, "CURDATE", "%02d.%02d.%02d", lt->tm_mday, lt->tm_mon+1, lt->tm_year%100);
    14401184        tpl_printf(vars, 0, "CURTIME", "%02d:%02d:%02d", lt->tm_hour, lt->tm_min, lt->tm_sec);
    1441         send_oscam_status(vars, f);
     1185        switch(pgidx){
     1186        case  0: break;
     1187        case  1: send_oscam_reader(vars, f); break;
     1188        case  2: send_oscam_entitlement(vars, f, &params); break;
     1189        case  3: send_oscam_status(vars, f); break;
     1190        case  4: send_oscam_user_config(vars, f, &params); break;
     1191        case  5: send_oscam_reader_config(vars, f, &params); break;
     1192        case    6: send_oscam_services(vars, f); break;
     1193        case  7: send_oscam_user_config_edit(vars, f, &params); break;
     1194        default: send_oscam_status(vars, f); break;
     1195      }
    14421196        tpl_clear(vars);
    14431197    } else {
    1444   if(pgidx == 8) send_css(f);
    1445     else {
    1446 
    1447         if (pgidx == 3) send_htmlhead(f, cfg->http_refresh); //status
    1448         else send_htmlhead(f,0);
    1449 
     1198        send_htmlhead(f,0);
    14501199  send_oscam_menu(f);
    1451   switch(pgidx){
    1452     case  0: send_oscam_config(f, &params); break;
    1453     case  1: send_oscam_reader(f); break;
    1454     case  2: send_oscam_entitlement(f, &params); break;
    1455     case  3: break;
    1456     case  4: send_oscam_user_config(f, &params); break;
    1457     case  5: send_oscam_reader_config(f, &params); break;
    1458     case  6: send_oscam_reader_config_do(f, &params); break;
    1459     case    7: send_oscam_sidtab(f); break;
    1460     default: break;
    1461   }
    1462 
     1200      send_oscam_config(f, &params);
    14631201  send_footer(f);
    14641202  fprintf(f, "</BODY></HTML>\r\n");
    14651203        }
    1466     }
    14671204  return 0;
    14681205}
  • branches/monitor-improvement/oscam-http.h

    r999 r1019  
    55#define RFC1123FMT "%a, %d %b %Y %H:%M:%S GMT"
    66#define AUTHREALM "OScam"
    7 #define AUTHNONCEVALIDSECS 60
     7#define AUTHNONCEVALIDSECS 15
    88#define MAXGETPARAMS 100
    99
     
    3434#define TPLHEADER "<HTML>\n\
    3535<HEAD>\n\
    36 <TITLE>OSCAM ##CS_VERSION## build ##CS_SVN_VERSION##</TITLE>\n\
     36<TITLE>OSCAM ##CS_VERSION## build ###CS_SVN_VERSION##</TITLE>\n\
    3737<link rel=\"stylesheet\" type=\"text/css\" href=\"site.css\">\n\
    38 ##REF##\
     38##REFRESH##\
    3939</HEAD>\n\
    4040<BODY>\n\
    41 <H2>OSCAM ##CS_VERSION## build ##CS_SVN_VERSION##</H2>"
     41<H2>OSCAM ##CS_VERSION## build ###CS_SVN_VERSION##</H2>"
    4242#define TPLFOOTER "<HR/><H4>OSCAM Webinterface - ##CURDATE## ##CURTIME##</H4></BODY></HTML>"
    43 #define TPLREF "<meta http-equiv=\"refresh\" content=\"##REFRESHTIME##\"; URL=/status.html\" />\n"
     43#define TPLREFRESH "<meta http-equiv=\"refresh\" content=\"##REFRESHTIME##\"; URL=/status.html\" />\n"
    4444#define TPLMENU "<TABLE border=0 class=\"menu\">\n\
    4545<TR>\n\
     
    4848<TD CLASS=\"menu\"><A HREF=\"readers.html\">READERS</TD>\n\
    4949<TD CLASS=\"menu\"><A HREF=\"userconfig.html\">USERS</TD>\n\
    50 <TD CLASS=\"menu\"><A HREF=\"entitlements.html\">ENTITLEMENTS</TD>\n\
    5150<TD CLASS=\"menu\"><A HREF=\"services.html\">SERVICES</TD>\n\
    5251</TR>\n\
    5352</TABLE>"
    54 #define TPLREFRESH "<meta http-equiv=\"refresh\" content=\"##REFRESHTIME##\"; URL=\"/status.html\" />"
    5553#define TPLSTATUS "##TPLHEADER##\
    5654##TPLMENU##\n\
    5755<BR><BR><TABLE WIDTH=\"100%\" cellspacing=\"0\" class=\"status\">\n\
    58 <TR><TH>PID</TH><TH>Typ</TH><TH>ID</TH><TH>Label</TH><TH>AU</TH><TH>0</TH><TH>Address</TH><TH>Port</TH><TH>Protocol</TH><TH>Login</TH><TH>Login</TH><TH>Time</TH><TH>caid:srvid</TH><TH>&nbsp;</TH><TH>Idle</TH><TH>0</TH>\n\
    59 ##CLIENTSTATUS##\n\
     56<TR><TH>PID</TH><TH>Typ</TH><TH>ID</TH><TH>Label</TH><TH>AU</TH><TH>0</TH><TH>Address</TH><TH>Port</TH><TH>Protocol</TH><TH>Login</TH><TH>Login</TH><TH>Time</TH><TH>caid:srvid</TH><TH>Last Channel</TH><TH>Idle</TH><TH>0</TH>\n\
     57##CLIENTSTATUS##\
    6058</TABLE><BR>\n\
    6159<DIV class=\"log\">\n\
    62 ##LOGHISTORY##\n\
     60##LOGHISTORY##\
    6361</DIV>\n\
    6462##TPLFOOTER##"
    6563#define TPLCLIENTSTATUSBIT "<TR class=\"##CLIENTTYPE##\"><TD>##CLIENTPID##</TD><TD>##CLIENTTYPE##</TD><TD>##CLIENTCNR##</TD><TD>##CLIENTUSER##</TD><TD>##CLIENTCAU##</TD><TD>##CLIENTCRYPTED##</TD><TD>##CLIENTIP##</TD><TD>##CLIENTPORT##</TD><TD>##CLIENTPROTO##</TD><TD>##CLIENTLOGINDATE##</TD><TD>##CLIENTLOGINTIME##</TD><TD>##CLIENTLOGINSECS##</TD><TD>##CLIENTCAID##:##CLIENTSRVID##</TD><TD>##CLIENTSRVNAME##</TD><TD>##CLIENTIDLESECS##</TD><TD>##CLIENTCON##</TD></TR>"
     64#define TPLUSERCONFIGLIST "##TPLHEADER##\
     65##TPLMENU##\n\
     66##MESSAGE##\
     67<BR><BR><TABLE cellspacing=\"0\" cellpadding=\"10\">\n\
     68<TR><TH>Label</TH>\r\n\t<TH>Status</TH>\r\n\t<TH>Last Channel</TH>\r\n\t<TH>Idle (Sec)</TH>\r\n\t<TH colspan=\"2\" align=\"center\">Action</TH>\r\n</TR>\
     69##USERCONFIGS##\
     70<TR>\n\
     71\t<FORM action=\"/user_edit.html\" method=\"get\">\n\
     72\t<TD>New User:</TD>\n\
     73\t<TD colspan=\"2\"><input name=\"user\" type=\"text\"></TD>\n\
     74\t<TD colspan=\"3\" align=\"center\"><input type=\"submit\" value=\"Add User\"></TD>\n\
     75\t</FORM>\n\
     76<TR>\n\
     77</TABLE>\n\
     78##TPLFOOTER##"
     79#define TPLUSERCONFIGLISTBIT "<TR class=\"##CLASSNAME##\">\n\
     80\t<TD>##USER##</TD>\n\t<TD>##STATUS####EXPIRED##</TD>\n\t<TD>##LASTCHANNEL##</TD>\r\n\t<TD>##IDLESECS##</TD>\n\t<TD><A HREF=\"user_edit.html?user=##USERENC##\">Edit Settings</A></TD>\n\
     81\t<TD><A HREF=\"userconfig.html?user=##USERENC##&action=delete\">Delete User</A></TD>\n\
     82</TR>\n"
     83#define TPLUSEREDIT "##TPLHEADER##\
     84##TPLMENU##\n\
     85##MESSAGE##\
     86<BR><BR>\n\
     87<form action=\"/user_edit.html\" method=\"get\">\n\
     88<input name=\"user\" type=\"hidden\" value=\"##USERNAME##\">\n\
     89<input name=\"action\" type=\"hidden\" value=\"execute\">\n\
     90<TABLE cellspacing=\"0\">\n\
     91<TH>&nbsp;</TH><TH>Edit User ##USERNAME##</TH>\n\
     92<TR><TD>Password:</TD><TD><input name=\"pwd\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"##PASSWORD##\"></TD></TR>\n\
     93<TR><TD>Exp. Date:</TD><TD><input name=\"expdate\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"##EXPDATE##\"></TD></TR>\n\
     94<TR><TD>Group:</TD><TD><input name=\"group\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"##GROUPS##\"></TD></TR>\n\
     95<TR><TD>Hostname:</TD><TD><input name=\"hostname\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"##DYNDNS##\"></TD></TR>\n\
     96<TR><TD>Uniq:</TD><TD><select name=\"uniq\">\n\
     97\t<option value=\"0\" ##UNIQSELECTED0##>none</option>\n\
     98\t<option value=\"1\" ##UNIQSELECTED1##>strict</option>\n\
     99\t<option value=\"2\" ##UNIQSELECTED2##>per IP</option>\n\
     100</SELECT></TD></TR>\n\
     101<TR><TD>Sleep:</TD><TD><input name=\"sleep\" type=\"text\" size=\"4\" maxlength=\"4\" value=\"0\"></TD></TR>\n\
     102<TR><TD>Monlevel:</TD><TD><select name=\"monlevel\">\n\
     103\t<option value=\"0\" ##MONSELECTED0##>no access to monitor</option>\n\
     104\t<option value=\"1\" ##MONSELECTED1##>only server and own procs</option>\n\
     105\t<option value=\"2\" ##MONSELECTED2##>all procs, but viewing only, default</option>\n\
     106\t<option value=\"3\" ##MONSELECTED3##>all procs, reload of oscam.user possible</option>\n\
     107\t<option value=\"4\" ##MONSELECTED4##>complete access</option>\n\
     108</select></TD></TR>\n\
     109<TR><TD>AU:</TD><TD><select name=\"au\">\n\
     110\t<option value=\" \" ##AUSELECTED##>none</option>\n\
     111\t<option value=\"1\" ##AUTOAUSELECTED##>auto</option>\n\
     112##RDROPTION##\
     113</select></TD></TR>\n\
     114<TR><TD>Services:</TD><TD><TABLE cellspacing=\"0\" class=\"invisible\">##SIDS##</TD></TR></TABLE>\n\
     115<TR><TD>CAID:</TD><TD><input name=\"caid\" type=\"text\" size=\"50\" maxlength=\"50\" value=\"##CAIDS##\"></TD></TR>\n\
     116<TR><TD>Ident:</TD><TD><input name=\"ident\" type=\"text\" size=\"50\" maxlength=\"50\" value=\"##IDENTS##\"></TD></TR>\n\
     117<TR><TD>Betatunnel:</TD><TD><input name=\"betatunnel\" type=\"text\" size=\"50\" maxlength=\"50\" value=\"##BETATUNNELS##\"></TD></TR>\n\
     118##TPLUSEREDITANTICASC##\
     119<TR><TD>&nbsp;</TD><TD align=\"right\"><input type=\"submit\" value=\"Save Settings\" title=\"Save settings and reload users\"></TD></TR>\n\
     120</TABLE>\n\
     121</form>\n\
     122##TPLFOOTER##"
     123#define TPLUSEREDITRDRSELECTED "\t<option value=\"##READERNAME##\" ##SELECTED##>##READERNAME##</option>"
     124#define TPLUSEREDITSIDOKBIT "<TR><TD><INPUT NAME=\"services\" TYPE=\"CHECKBOX\" VALUE=\"##SIDLABEL##\" ##CHECKED##> ##SIDLABEL##</TD>"
     125#define TPLUSEREDITSIDNOBIT "<TD><INPUT NAME=\"services\" TYPE=\"CHECKBOX\" VALUE=\"!##SIDLABEL##\" ##CHECKED##> !##SIDLABEL##</TD></TR>"
     126#ifdef CS_ANTICASC
     127#define TPLUSEREDITANTICASC "<TR><TD>Anticascading numusers:</TD><TD><input name=\"numusers\" type=\"text\" size=\"3\" maxlength=\"3\" value=\"##AC_USERS##\"></TD></TR>\n\
     128<TR><TD>Anticascading penalty:</TD><TD><input name=\"penalty\" type=\"text\" size=\"3\" maxlength=\"3\" value=\"##AC_PENALTY##\"></TD></TR>"
     129#endif
     130#define TPLSIDTAB "##TPLHEADER##\
     131##TPLMENU##\n\
     132<BR><BR><DIV class=\"log\">\n\
     133##SIDTABS##\
     134</DIV>\n\
     135##TPLFOOTER##"
     136#define TPLSIDTABBIT "label=##LABEL##<BR>\n\
     137caid(##CAIDNUM##)=##CAIDS##<BR>\n\
     138provider(##PROVIDNUM##)=##PROVIDS##<BR>\n\
     139services(##SRVIDNUM##)=##SRVIDS##<BR><BR>\n"
     140#define TPLREADERS "##TPLHEADER##\
     141##TPLMENU##\n\
     142<BR><BR><TABLE cellspacing=\"0\" cellpadding=\"10\">\n\
     143<TR><TH>Reader</TH><TH>Protocol</TH><TH>Action</TH></TR>\n\
     144##READERLIST##\
     145</TABLE>\n\
     146##TPLFOOTER##"
     147#define TPLREADERSBIT "\t<TR><TD>##READERNAME##</TD><TD>##CTYP##</TD><TD><A HREF=\"readerconfig.html?reader=##READERNAMEENC##\">Edit Settings</A> &nbsp; <A HREF=\"entitlements.html?reader=##READERNAME##\">Show Entitlements</A></TD></TR>\n"
     148#define TPLENTITLEMENTS "##TPLHEADER##\
     149##TPLMENU##\n\
     150<BR><BR>Entitlements for ##READERNAME##<BR><BR>\r\n\n\
     151<DIV class=\"log\">\n\
     152##LOGHISTORY##\
     153</DIV>\n\
     154##TPLFOOTER##"
     155#define TPLREADERCONFIG "##TPLHEADER##\
     156##TPLMENU##\n\
     157<BR><BR>\n\
     158##MESSAGE##\
     159<form action=\"/readerconfig.html?action=execute\" method=\"get\"><input name=\"reader\" type=\"hidden\" value=\"##READERNAME##\">\n\
     160<TABLE cellspacing=\"0\">\n\
     161<TH>&nbsp;</TH><TH>Edit Reader ##READERNAME##</TH>\n\
     162<TR><TD>Device:</TD><TD><input name=\"device\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"##DEVICE####R_PORT####L_PORT##\"></TD></TR>\n\
     163<TR><TD>Group:</TD><TD><input name=\"grp\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"##GRP##\"></TD></TR>\n\
     164<TR><TD>Key:</TD><TD><input name=\"key\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"##NCD_KEY##\"></TD></TR>\n\
     165<TR><TD>Pincode:</TD><TD><input name=\"pincode\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"##PINCODE##\"></TD></TR>\n\
     166<TR><TD>Readnano:</TD><TD><input name=\"readnano\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"##EMMFILE##\"></TD></TR>\n\
     167<TR><TD>Services:</TD><TD><TABLE cellspacing=\"0\" class=\"invisible\">\n\
     168##SIDS##\
     169</TD></TR></TABLE>\n\
     170<TR><TD>Inactivitytimeout:</TD><TD><input name=\"inactivitytimeout\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"##INACTIVITYTIMEOUT##\"></TD></TR>\n\
     171<TR><TD>Reconnecttimeout:</TD><TD><input name=\"reconnecttimeout\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"##RECEIVETIMEOUT##\"></TD></TR>\n\
     172<TR><TD>Disableserverfilter:</TD><TD><input name=\"disableserverfilter\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"##DISABLESERVERFILTER##\"></TD></TR>\n\
     173<TR><TD>Fallback:</TD><TD><input name=\"fallback\" type=\"text\" size=\"3\" maxlength=\"3\" value=\"##FALLBACK##\"></TD></TR>\n\
     174<TR><TD>CAID:</TD><TD><input name=\"caid\" type=\"text\" size=\"50\" maxlength=\"50\" value=\"##CAIDS##\"></TD></TR>\n\
     175<TR><TD>Boxid:</TD><TD><input name=\"boxid\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"##BOXID##\"></TD></TR>\n\
     176</TABLE>\n\
     177<input type=\"submit\" value=\"OK\"></form>\n\
     178<BR><BR>Saving not yet implemented - Nothing changes on click<BR><BR>\n\
     179##TPLFOOTER##"
     180#define TPLREADERCONFIGSIDOKBIT "<TR><TD><INPUT NAME=\"services\" TYPE=\"CHECKBOX\" VALUE=\"##SIDLABEL##\" ##CHECKED##> ##SIDLABEL##</TD>"
     181#define TPLREADERCONFIGSIDNOBIT "<TD><INPUT NAME=\"services\" TYPE=\"CHECKBOX\" VALUE=\"!##SIDLABEL##\" ##CHECKED##> !##SIDLABEL##</TD></TR>"
    66182
    67183enum refreshtypes {REFR_ACCOUNTS, REFR_READERS, REFR_SERVER, REFR_ANTICASC};
     
    103219void send_footer(FILE *f);
    104220void send_oscam_menu(FILE *f);
    105 void send_oscam_user_config(FILE *f, struct uriparams *params);
     221void send_oscam_user_config(struct templatevars *vars, FILE *f, struct uriparams *params);
    106222char *getParam(struct uriparams *params, char *name);
  • branches/monitor-improvement/oscam-simples.c

    r965 r1019  
    389389}
    390390
     391/* Helper function for urlencode.*/
     392char to_hex(char code){
     393    static char hex[] = "0123456789abcdef";
     394    return hex[code & 15];
     395}
     396
     397/* Encode values in a http url. Note: Be sure to free() the returned string after use */
     398char *urlencode(char *str){
     399    char *pstr = str, *buf = malloc(strlen(str) * 3 + 1), *pbuf = buf;
     400    while (*pstr) {
     401        if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~') *pbuf++ = *pstr;
     402        else if (*pstr == ' ') *pbuf++ = '+';
     403        else {
     404            *pbuf++ = '%';
     405            *pbuf++ = to_hex(*pstr >> 4);
     406            *pbuf++ = to_hex(*pstr & 15);
     407        }
     408        ++pstr;
     409    }
     410    *pbuf = '\0';
     411    return buf;
     412}
     413
     414
    391415/* Converts a long value to a char array in bitwise representation.
    392416   Note that the result array MUST be at least 33 bit large and that
Note: See TracChangeset for help on using the changeset viewer.