Poder editar, eliminar y agregar en archivo

tengo una aplicación para linux donde hace un funcionamiento de registrar usuarios para editarlo y eliminarlo pero quiero poder hacer esto posible en php este es el contenido de que hace esto posible

#include "globals.h"
#include "module-anticasc.h"
#include "oscam-client.h"
#include "oscam-conf.h"
#include "oscam-conf-chk.h"
#include "oscam-conf-mk.h"
#include "oscam-config.h"
#include "oscam-garbage.h"
#include "oscam-lock.h"
#include "oscam-string.h"
#define cs_user "oscam.user"
static void account_tosleep_fn(const char *token, char *value, void *setting, FILE *f)
{
int32_t *tosleep = setting;
if(value)
{
*tosleep = strToIntVal(value, cfg.tosleep);
return;
}
if(*tosleep != cfg.tosleep || cfg.http_full_cfg)
{ fprintf_conf(f, token, "%d\n", *tosleep); }
}
static void account_c35_suppresscmd08_fn(const char *token, char *value, void *setting, FILE *f)
{
int8_t *c35_suppresscmd08 = setting;
if(value)
{
*c35_suppresscmd08 = (int8_t)strToIntVal(value, cfg.c35_suppresscmd08);
return;
}
if(*c35_suppresscmd08 != cfg.c35_suppresscmd08 || cfg.http_full_cfg)
{ fprintf_conf(f, token, "%d\n", *c35_suppresscmd08); }
}
static void account_umaxidle_fn(const char *token, char *value, void *setting, FILE *f)
{
uint32_t *umaxidle = setting;
if(value)
{
*umaxidle = (uint32_t)strToIntVal(value, cfg.umaxidle);
return;
}
if(*umaxidle != cfg.umaxidle || cfg.http_full_cfg)
{ fprintf_conf(f, token, "%u\n", *umaxidle); }
}
static void account_ncd_keepalive_fn(const char *token, char *value, void *setting, FILE *f)
{
int8_t *ncd_keepalive = setting;
int8_t def_value = 0;
#ifdef MODULE_NEWCAMD
def_value = cfg.ncd_keepalive;
#endif
if(value)
{
*ncd_keepalive = (int8_t)strToIntVal(value, def_value);
return;
}
if(*ncd_keepalive != def_value || cfg.http_full_cfg)
{ fprintf_conf(f, token, "%d\n", *ncd_keepalive); }
}
static void account_allowedprotocols_fn(const char *token, char *value, void *setting, FILE *f)
{
struct s_auth *account = setting;
if(value)
{
account->allowedprotocols = 0;
if(strlen(value) > 3)
{
int i;
char *ptr, *saveptr1 = NULL;
for(i = 0, ptr = strtok_r(value, ",", &saveptr1); ptr; ptr = strtok_r(NULL, ",", &saveptr1), i++)
{
if(streq(ptr, "camd33")) { account->allowedprotocols |= LIS_CAMD33TCP; }
else if(streq(ptr, "camd35")) { account->allowedprotocols |= LIS_CAMD35UDP; }
else if(streq(ptr, "cs357x")) { account->allowedprotocols |= LIS_CAMD35UDP; }
else if(streq(ptr, "cs378x")) { account->allowedprotocols |= LIS_CAMD35TCP; }
else if(streq(ptr, "newcamd")) { account->allowedprotocols |= LIS_NEWCAMD; }
else if(streq(ptr, "cccam")) { account->allowedprotocols |= LIS_CCCAM; }
else if(streq(ptr, "csp")) { account->allowedprotocols |= LIS_CSPUDP; }
else if(streq(ptr, "gbox")) { account->allowedprotocols |= LIS_GBOX; }
else if(streq(ptr, "radegast")) { account->allowedprotocols |= LIS_RADEGAST; }
// these have no listener ports so it doesn't make sense
else if(streq(ptr, "dvbapi")) { account->allowedprotocols |= LIS_DVBAPI; }
else if(streq(ptr, "constcw")) { account->allowedprotocols |= LIS_CONSTCW; }
else if(streq(ptr, "serial")) { account->allowedprotocols |= LIS_SERIAL; }
}
}
return;
}
if(account->allowedprotocols || cfg.http_full_cfg)
{
value = mk_t_allowedprotocols(account);
fprintf_conf(f, token, "%s\n", value);
free_mk_t(value);
}
}
#ifdef WITH_LB
static void caidvaluetab_fn(const char *token, char *value, void *setting, FILE *f)
{
CAIDVALUETAB *caid_value_table = setting;
int limit = streq(token, "lb_retrylimits") ? 50 : 1;
if(value)
{
chk_caidvaluetab(value, caid_value_table, limit);
return;
}
if(caid_value_table->n > 0 || cfg.http_full_cfg)
{
value = mk_t_caidvaluetab(caid_value_table);
fprintf_conf(f, token, "%s\n", value);
free_mk_t(value);
}
}
#endif
static void account_au_fn(const char *token, char *value, void *setting, FILE *f)
{
struct s_auth *account = setting;
if(value)
{
// set default values for usage during runtime from Webif
account->autoau = 0;
if(!account->aureader_list)
{ account->aureader_list = ll_create("aureader_list"); }
if(streq(value, "1"))
{ account->autoau = 1; }
ll_clear(account->aureader_list);
LL_ITER itr = ll_iter_create(configured_readers);
struct s_reader *rdr;
char *pch, *saveptr1 = NULL;
for(pch = strtok_r(value, ",", &saveptr1); pch != NULL; pch = strtok_r(NULL, ",", &saveptr1))
{
ll_iter_reset(&itr);
while((rdr = ll_iter_next(&itr)))
{
if(streq(rdr->label, pch) || account->autoau)
{
ll_append(account->aureader_list, rdr);
}
}
}
return;
}
if(account->autoau == 1)
{
fprintf_conf(f, token, "%d\n", account->autoau);
}
else if(account->aureader_list)
{
value = mk_t_aureader(account);
if(strlen(value) > 0)
{ fprintf_conf(f, token, "%s\n", value); }
free_mk_t(value);
}
else if(cfg.http_full_cfg)
{
fprintf_conf(f, token, "%s\n", "");
}
}
static void account_expdate_fn(const char *token, char *value, void *setting, FILE *f)
{
struct s_auth *account = setting;
if(value)
{
if(!value[0])
{
account->expirationdate = (time_t)NULL;
return;
}
int i;
struct tm cstime;
char *ptr1, *saveptr1 = NULL;
memset(&cstime, 0, sizeof(cstime));
for(i = 0, ptr1 = strtok_r(value, "-/", &saveptr1); i < 3 && ptr1; ptr1 = strtok_r(NULL, "-/", &saveptr1), i++)
{
switch(i)
{
case 0:
cstime.tm_year = atoi(ptr1) - 1900;
break;
case 1:
cstime.tm_mon = atoi(ptr1) - 1;
break;
case 2:
cstime.tm_mday = atoi(ptr1);
break;
}
}
cstime.tm_hour = 23;
cstime.tm_min = 59;
cstime.tm_sec = 59;
cstime.tm_isdst = -1;
account->expirationdate = mktime(&cstime);
return;
}
if(account->expirationdate || cfg.http_full_cfg)
{
char buf[16];
struct tm timeinfo;
localtime_r(&account->expirationdate, &timeinfo);
strftime(buf, 16, "%Y-%m-%d", &timeinfo);
fprintf_conf(f, token, "%s\n", streq(buf, "1970-01-01") ? "" : buf);
}
}
static void account_allowedtimeframe_fn(const char *token, char *value, void *setting, FILE *f)
{
struct s_auth *account = setting;
if(value)
{
account->allowedtimeframe[0] = 0;
account->allowedtimeframe[1] = 0;
if(strlen(value))
{
int32_t allowed[4];
if(sscanf(value, "%2d:%2d-%2d:%2d", &allowed[0], &allowed[1], &allowed[2], &allowed[3]) == 4)
{
account->allowedtimeframe[0] = allowed[0] * 60 + allowed[1];
account->allowedtimeframe[1] = allowed[2] * 60 + allowed[3];
}
else
{
fprintf(stderr,...

Añade tu respuesta

Haz clic para o