Ver Mensaje Individual
  #21 (permalink)  
Antiguo 29/11/2013, 09:26
xoceunder
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 759
Antigüedad: 11 años, 10 meses
Puntos: 10
Respuesta: duda en buscar, editar y eliminar en archivo .user

mira este es el archivo que utiliza la aplicacion que quiero poder hacer en php

Código Java:
Ver original
  1. #include "globals.h"
  2. #include "module-anticasc.h"
  3. #include "oscam-client.h"
  4. #include "oscam-conf.h"
  5. #include "oscam-conf-chk.h"
  6. #include "oscam-conf-mk.h"
  7. #include "oscam-config.h"
  8. #include "oscam-garbage.h"
  9. #include "oscam-lock.h"
  10. #include "oscam-string.h"
  11.  
  12. #define cs_user "oscam.user"
  13.  
  14. static void account_tosleep_fn(const char *token, char *value, void *setting, FILE *f)
  15. {
  16.     int32_t *tosleep = setting;
  17.     if(value)
  18.     {
  19.         *tosleep = strToIntVal(value, cfg.tosleep);
  20.         return;
  21.     }
  22.     if(*tosleep != cfg.tosleep || cfg.http_full_cfg)
  23.         { fprintf_conf(f, token, "%d\n", *tosleep); }
  24. }
  25.  
  26.  
  27.  
  28.  
  29. static void account_c35_suppresscmd08_fn(const char *token, char *value, void *setting, FILE *f)
  30. {
  31.     int8_t *c35_suppresscmd08 = setting;
  32.     if(value)
  33.     {
  34.         *c35_suppresscmd08 = (int8_t)strToIntVal(value, cfg.c35_suppresscmd08);
  35.         return;
  36.     }
  37.     if(*c35_suppresscmd08 != cfg.c35_suppresscmd08 || cfg.http_full_cfg)
  38.         { fprintf_conf(f, token, "%d\n", *c35_suppresscmd08); }
  39. }
  40.  
  41. static void account_umaxidle_fn(const char *token, char *value, void *setting, FILE *f)
  42. {
  43.     uint32_t *umaxidle = setting;
  44.     if(value)
  45.     {
  46.         *umaxidle = (uint32_t)strToIntVal(value, cfg.umaxidle);
  47.         return;
  48.     }
  49.     if(*umaxidle != cfg.umaxidle || cfg.http_full_cfg)
  50.         { fprintf_conf(f, token, "%u\n", *umaxidle); }
  51. }
  52.  
  53.  
  54.  
  55.  
  56. static void account_ncd_keepalive_fn(const char *token, char *value, void *setting, FILE *f)
  57. {
  58.     int8_t *ncd_keepalive = setting;
  59.     int8_t def_value = 0;
  60. #ifdef MODULE_NEWCAMD
  61.     def_value = cfg.ncd_keepalive;
  62. #endif
  63.     if(value)
  64.     {
  65.         *ncd_keepalive = (int8_t)strToIntVal(value, def_value);
  66.         return;
  67.     }
  68.     if(*ncd_keepalive != def_value || cfg.http_full_cfg)
  69.         { fprintf_conf(f, token, "%d\n", *ncd_keepalive); }
  70. }
  71.  
  72. static void account_allowedprotocols_fn(const char *token, char *value, void *setting, FILE *f)
  73. {
  74.     struct s_auth *account = setting;
  75.     if(value)
  76.     {
  77.         account->allowedprotocols = 0;
  78.         if(strlen(value) > 3)
  79.         {
  80.             int i;
  81.             char *ptr, *saveptr1 = NULL;
  82.             for(i = 0, ptr = strtok_r(value, ",", &saveptr1); ptr; ptr = strtok_r(NULL, ",", &saveptr1), i++)
  83.             {
  84.                 if(streq(ptr, "camd33"))   { account->allowedprotocols |= LIS_CAMD33TCP; }
  85.                 else if(streq(ptr, "camd35"))   { account->allowedprotocols |= LIS_CAMD35UDP; }
  86.                 else if(streq(ptr, "cs357x"))   { account->allowedprotocols |= LIS_CAMD35UDP; }
  87.                 else if(streq(ptr, "cs378x"))   { account->allowedprotocols |= LIS_CAMD35TCP; }
  88.                 else if(streq(ptr, "newcamd"))  { account->allowedprotocols |= LIS_NEWCAMD; }
  89.                 else if(streq(ptr, "cccam"))    { account->allowedprotocols |= LIS_CCCAM; }
  90.                 else if(streq(ptr, "csp"))      { account->allowedprotocols |= LIS_CSPUDP; }
  91.                 else if(streq(ptr, "gbox"))     { account->allowedprotocols |= LIS_GBOX; }
  92.                 else if(streq(ptr, "radegast")) { account->allowedprotocols |= LIS_RADEGAST; }
  93.                 // these have no listener ports so it doesn't make sense
  94.                 else if(streq(ptr, "dvbapi"))   { account->allowedprotocols |= LIS_DVBAPI; }
  95.                 else if(streq(ptr, "constcw"))  { account->allowedprotocols |= LIS_CONSTCW; }
  96.                 else if(streq(ptr, "serial"))   { account->allowedprotocols |= LIS_SERIAL; }
  97.             }
  98.         }
  99.         return;
  100.     }
  101.     if(account->allowedprotocols || cfg.http_full_cfg)
  102.     {
  103.         value = mk_t_allowedprotocols(account);
  104.         fprintf_conf(f, token, "%s\n", value);
  105.         free_mk_t(value);
  106.     }
  107. }
  108.  
  109. #ifdef WITH_LB
  110. static void caidvaluetab_fn(const char *token, char *value, void *setting, FILE *f)
  111. {
  112.     CAIDVALUETAB *caid_value_table = setting;
  113.     int limit = streq(token, "lb_retrylimits") ? 50 : 1;
  114.     if(value)
  115.     {
  116.         chk_caidvaluetab(value, caid_value_table, limit);
  117.         return;
  118.     }
  119.     if(caid_value_table->n > 0 || cfg.http_full_cfg)
  120.     {
  121.         value = mk_t_caidvaluetab(caid_value_table);
  122.         fprintf_conf(f, token, "%s\n", value);
  123.         free_mk_t(value);
  124.     }
  125. }
  126. #endif
  127.  
  128.  
  129. static void account_au_fn(const char *token, char *value, void *setting, FILE *f)
  130. {
  131.     struct s_auth *account = setting;
  132.     if(value)
  133.     {
  134.         // set default values for usage during runtime from Webif
  135.         account->autoau = 0;
  136.         if(!account->aureader_list)
  137.             { account->aureader_list = ll_create("aureader_list"); }
  138.         if(streq(value, "1"))
  139.             { account->autoau = 1; }
  140.         ll_clear(account->aureader_list);
  141.         LL_ITER itr = ll_iter_create(configured_readers);
  142.         struct s_reader *rdr;
  143.         char *pch, *saveptr1 = NULL;
  144.         for(pch = strtok_r(value, ",", &saveptr1); pch != NULL; pch = strtok_r(NULL, ",", &saveptr1))
  145.         {
  146.             ll_iter_reset(&itr);
  147.             while((rdr = ll_iter_next(&itr)))
  148.             {
  149.                 if(streq(rdr->label, pch) || account->autoau)
  150.                 {
  151.                     ll_append(account->aureader_list, rdr);
  152.                 }
  153.             }
  154.         }
  155.         return;
  156.     }
  157.     if(account->autoau == 1)
  158.     {
  159.         fprintf_conf(f, token, "%d\n", account->autoau);
  160.     }
  161.     else if(account->aureader_list)
  162.     {
  163.         value = mk_t_aureader(account);
  164.         if(strlen(value) > 0)
  165.             { fprintf_conf(f, token, "%s\n", value); }
  166.         free_mk_t(value);
  167.     }
  168.     else if(cfg.http_full_cfg)
  169.     {
  170.         fprintf_conf(f, token, "%s\n", "");
  171.     }
  172. }
  173.  
  174. static void account_expdate_fn(const char *token, char *value, void *setting, FILE *f)
  175. {
  176.     struct s_auth *account = setting;
  177.     if(value)
  178.     {
  179.         if(!value[0])
  180.         {
  181.             account->expirationdate = (time_t)NULL;
  182.             return;
  183.         }
  184.         int i;
  185.         struct tm cstime;
  186.         char *ptr1, *saveptr1 = NULL;
  187.         memset(&cstime, 0, sizeof(cstime));
  188.         for(i = 0, ptr1 = strtok_r(value, "-/", &saveptr1); i < 3 && ptr1; ptr1 = strtok_r(NULL, "-/", &saveptr1), i++)
  189.         {
  190.             switch(i)
  191.             {
  192.             case 0:
  193.                 cstime.tm_year = atoi(ptr1) - 1900;
  194.                 break;
  195.             case 1:
  196.                 cstime.tm_mon  = atoi(ptr1) - 1;
  197.                 break;
  198.             case 2:
  199.                 cstime.tm_mday = atoi(ptr1);
  200.                 break;
  201.             }
  202.         }
  203.         cstime.tm_hour  = 23;
  204.         cstime.tm_min   = 59;
  205.         cstime.tm_sec   = 59;
  206.         cstime.tm_isdst = -1;
  207.         account->expirationdate = mktime(&cstime);
  208.         return;
  209.     }
  210.     if(account->expirationdate || cfg.http_full_cfg)
  211.     {
  212.         char buf[16];
  213.         struct tm timeinfo;
  214.         localtime_r(&account->expirationdate, &timeinfo);
  215.         strftime(buf, 16, "%Y-%m-%d", &timeinfo);
  216.         fprintf_conf(f, token, "%s\n", streq(buf, "1970-01-01") ? "" : buf);
  217.     }
  218. }
  219.  
  220. static void account_allowedtimeframe_fn(const char *token, char *value, void *setting, FILE *f)
  221. {
  222.     struct s_auth *account = setting;
  223.     if(value)
  224.     {
  225.         account->allowedtimeframe[0] = 0;
  226.         account->allowedtimeframe[1] = 0;
  227.         if(strlen(value))
  228.         {
  229.             int32_t allowed[4];
  230.             if(sscanf(value, "%2d:%2d-%2d:%2d", &allowed[0], &allowed[1], &allowed[2], &allowed[3]) == 4)
  231.             {
  232.                 account->allowedtimeframe[0] = allowed[0] * 60 + allowed[1];
  233.                 account->allowedtimeframe[1] = allowed[2] * 60 + allowed[3];
  234.             }
  235.             else
  236.             {
  237.                 fprintf(stderr, "WARNING: Value '%s' is not valid for allowedtimeframe (hh:mm-hh:mm)\n", value);
  238.             }
  239.         }
  240.         return;
  241.     }
  242.     if(account->allowedtimeframe[0] && account->allowedtimeframe[1])
  243.     {
  244.         fprintf_conf(f, token, "%02d:%02d-%02d:%02d\n",
  245.                      account->allowedtimeframe[0] / 60, account->allowedtimeframe[0] % 60,
  246.                      account->allowedtimeframe[1] / 60, account->allowedtimeframe[1] % 60);
  247.     }
  248.     else if(cfg.http_full_cfg)
  249.     {
  250.         fprintf_conf(f, token, "%s\n", "");
  251.     }
  252. }
  253.  
  254. static void account_tuntab_fn(const char *token, char *value, void *setting, FILE *f)
  255. {
  256.     TUNTAB *ttab = setting;
  257.     if(value)
  258.     {
  259.         if(strlen(value) == 0)
  260.         {
  261.             clear_tuntab(ttab);
  262.         }
  263.         else
  264.         {
  265.             chk_tuntab(value, ttab);
  266.         }
  267.         return;
  268.     }
  269.     if(ttab->bt_caidfrom[0] || cfg.http_full_cfg)
  270.     {
  271.         value = mk_t_tuntab(ttab);
  272.         fprintf_conf(f, token, "%s\n", value);
  273.         free_mk_t(value);
  274.     }
  275. }
  276.  
  277. void group_fn(const char *token, char *value, void *setting, FILE *f)
  278. {
  279.     uint64_t *grp = setting;
  280.     if(value)
  281.     {
  282.         char *ptr1, *saveptr1 = NULL;
  283.         *grp = 0;
  284.         for(ptr1 = strtok_r(value, ",", &saveptr1); ptr1; ptr1 = strtok_r(NULL, ",", &saveptr1))
  285.         {
  286.             int32_t g;
  287.             g = atoi(ptr1);
  288.             if(g > 0 && g < 65)
  289.                 { *grp |= (((uint64_t)1) << (g - 1)); }
  290.         }
  291.         return;
  292.     }
  293.     if(*grp || cfg.http_full_cfg)
  294.     {
  295.         value = mk_t_group(*grp);
  296.         fprintf_conf(f, token, "%s\n", value);
  297.         free_mk_t(value);
  298.     }
  299. }
  300.  
  301. void services_fn(const char *token, char *value, void *setting, FILE *f)
  302. {
  303.     SIDTABS *sidtabs = setting;
  304.     if(value)
  305.     {
  306.         strtolower(value);
  307.         chk_services(value, sidtabs);
  308.         return;
  309.     }
  310.     value = mk_t_service(sidtabs);
  311.     if(strlen(value) > 0 || cfg.http_full_cfg)
  312.         { fprintf_conf(f, token, "%s\n", value); }
  313.     free_mk_t(value);
  314. }
  315.  
  316. void class_fn(const char *token, char *value, void *setting, FILE *f)
  317. {
  318.     CLASSTAB *cltab = setting;
  319.     if(value)
  320.     {
  321.         strtolower(value);
  322.         chk_cltab(value, cltab);
  323.         return;
  324.     }
  325.     value = mk_t_cltab(cltab);
  326.     if(strlen(value) > 0 || cfg.http_full_cfg)
  327.     {
  328.         fprintf_conf(f, token, "%s\n", value);
  329.         free_mk_t(value);
  330.     }
  331. }