/* FILE tDeletedZone source code of iDNS.cgi Built by mysqlRAD2.cgi (C) Gary Wallis and Hugo Urquiza 2001-2009 $Id$ PURPOSE Schema dependent RAD generated file. Program app functionality in tdeletedzonefunc.h while RAD is still to be used. */ #include "mysqlrad.h" //Table Variables //Table Variables //uDeletedZone: Primary Key static unsigned uDeletedZone=0; //cZone: Zone name static char cZone[101]={"domain.tld"}; //uNSSet: Pulldown of configured name server groups static unsigned uNSSet=0; static char cuNSSetPullDown[256]={""}; //cHostmaster: eMail address of responsible person static char cHostmaster[101]={""}; //uSerial: Zone serial number static unsigned uSerial=0; //uExpire: Seconds to expire for slave name servers static unsigned uExpire=604800; //uRefresh: How often slaves should contact master static unsigned uRefresh=28800; //uTTL: Default minimum TTL for RRs static unsigned uTTL=86400; //uRetry: Slave server retry interval after uRefresh static unsigned uRetry=7200; //uZoneTTL: Zone TTL static unsigned uZoneTTL=86400; //uMailServers: Pulldown of configured mail server groups static unsigned uMailServers=0; static char cuMailServersPullDown[256]={""}; //uView: Optional tView Group static unsigned uView=1; static char cuViewPullDown[256]={""}; //cMainAddress: Zones main A record static char cMainAddress[17]={""}; //uRegistrar: Registrar of Record for this Zone if Applies static unsigned uRegistrar=0; static char cuRegistrarPullDown[256]={""}; //uSecondaryOnly: Secondary DNS Service Only. cMasterIPs Would be External Customer Provided Master static unsigned uSecondaryOnly=0; static char cYesNouSecondaryOnly[32]={""}; //cMasterIPs: Slave zones master IP source(s) static char cMasterIPs[256]={""}; //cAllowTransfer: IP address(es) that are allowed to copy the zone info from the server (master or slave) static char cAllowTransfer[256]={""}; //cOptions: slave.zones and master.zones zone options static char *cOptions={""}; //uOwner: Record owner static unsigned uOwner=0; //uCreatedBy: uClient for last insert static unsigned uCreatedBy=0; #define ISM3FIELDS //uCreatedDate: Unix seconds date last insert static long uCreatedDate=0; //uModBy: uClient for last update static unsigned uModBy=0; //uModDate: Unix seconds date last update static long uModDate=0; #define VAR_LIST_tDeletedZone "tDeletedZone.uDeletedZone,tDeletedZone.cZone,tDeletedZone.uNSSet,tDeletedZone.cHostmaster,tDeletedZone.uSerial,tDeletedZone.uExpire,tDeletedZone.uRefresh,tDeletedZone.uTTL,tDeletedZone.uRetry,tDeletedZone.uZoneTTL,tDeletedZone.uMailServers,tDeletedZone.uView,tDeletedZone.cMainAddress,tDeletedZone.uRegistrar,tDeletedZone.uSecondaryOnly,tDeletedZone.cAllowTransfer,tDeletedZone.cOptions,tDeletedZone.uOwner,tDeletedZone.uCreatedBy,tDeletedZone.uCreatedDate,tDeletedZone.uModBy,tDeletedZone.uModDate" //Local only void Insert_tDeletedZone(void); void Update_tDeletedZone(char *cRowid); void ProcesstDeletedZoneListVars(pentry entries[], int x); //In tDeletedZonefunc.h file included below void ExtProcesstDeletedZoneVars(pentry entries[], int x); void ExttDeletedZoneCommands(pentry entries[], int x); void ExttDeletedZoneButtons(void); void ExttDeletedZoneNavBar(void); void ExttDeletedZoneGetHook(entry gentries[], int x); void ExttDeletedZoneSelect(void); void ExttDeletedZoneSelectRow(void); void ExttDeletedZoneListSelect(void); void ExttDeletedZoneListFilter(void); void ExttDeletedZoneAuxTable(void); #include "tdeletedzonefunc.h" //Table Variables Assignment Function void ProcesstDeletedZoneVars(pentry entries[], int x) { register int i; for(i=0;i\n"); printf(""); printf(""); printf("",gluRowid); if(guI) { if(guMode==6) //printf(" Found"); printf(LANG_NBR_FOUND); else if(guMode==5) //printf(" Modified"); printf(LANG_NBR_MODIFIED); else if(guMode==4) //printf(" New"); printf(LANG_NBR_NEW); printf(LANG_NBRF_SHOWING,gluRowid,guI); } else { if(!cResult[0]) //printf(" No records found"); printf(LANG_NBR_NORECS); } if(cResult[0]) printf("%s",cResult); printf(""); printf(""); ExttDeletedZoneButtons(); printf(""); // OpenFieldSet("tDeletedZone Record Data",100); if(guMode==2000 || guMode==2002) tDeletedZoneInput(1); else tDeletedZoneInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttDeletedZoneAuxTable(); Footer_ism3(); }//end of tDeletedZone(); void tDeletedZoneInput(unsigned uMode) { //uDeletedZone OpenRow(LANG_FL_tDeletedZone_uDeletedZone,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uDeletedZone); } //cZone OpenRow(LANG_FL_tDeletedZone_cZone,EmptyString(cZone)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cZone)); } //uNSSet OpenRow(LANG_FL_tDeletedZone_uNSSet,IsZero(uNSSet)); if(guPermLevel>=0 && uMode) tTablePullDown("tNSSet;cuNSSetPullDown","cLabel","cLabel",uNSSet,1); else tTablePullDown("tNSSet;cuNSSetPullDown","cLabel","cLabel",uNSSet,0); //cHostmaster OpenRow(LANG_FL_tDeletedZone_cHostmaster,EmptyString(cHostmaster)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cHostmaster)); } //uSerial OpenRow(LANG_FL_tDeletedZone_uSerial,IsZero(uSerial)); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uSerial); } //uExpire OpenRow(LANG_FL_tDeletedZone_uExpire,IsZero(uExpire)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uExpire); } //uRefresh OpenRow(LANG_FL_tDeletedZone_uRefresh,IsZero(uRefresh)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uRefresh); } //uTTL OpenRow(LANG_FL_tDeletedZone_uTTL,IsZero(uTTL)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uTTL); } //uRetry OpenRow(LANG_FL_tDeletedZone_uRetry,IsZero(uRetry)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uRetry); } //uZoneTTL OpenRow(LANG_FL_tDeletedZone_uZoneTTL,IsZero(uZoneTTL)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uZoneTTL); } //uMailServers OpenRow(LANG_FL_tDeletedZone_uMailServers,"black"); if(guPermLevel>=0 && uMode) tTablePullDown("tMailServer;cuMailServersPullDown","cLabel","cLabel",uMailServers,1); else tTablePullDown("tMailServer;cuMailServersPullDown","cLabel","cLabel",uMailServers,0); //uView OpenRow(LANG_FL_tDeletedZone_uView,"black"); if(guPermLevel>=0 && uMode) tTablePullDown("tView;cuViewPullDown","cLabel","cLabel",uView,1); else tTablePullDown("tView;cuViewPullDown","cLabel","cLabel",uView,0); //cMainAddress OpenRow(LANG_FL_tDeletedZone_cMainAddress,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cMainAddress)); } //uRegistrar OpenRow(LANG_FL_tDeletedZone_uRegistrar,"black"); if(guPermLevel>=0 && uMode) tTablePullDown("tRegistrar;cuRegistrarPullDown","cLabel","cLabel",uRegistrar,1); else tTablePullDown("tRegistrar;cuRegistrarPullDown","cLabel","cLabel",uRegistrar,0); //uSecondaryOnly OpenRow(LANG_FL_tDeletedZone_uSecondaryOnly,"black"); if(guPermLevel>=0 && uMode) YesNoPullDown("uSecondaryOnly",uSecondaryOnly,1); else YesNoPullDown("uSecondaryOnly",uSecondaryOnly,0); //cMasterIPs OpenRow(LANG_FL_tDeletedZone_cMasterIPs,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cMasterIPs)); } //cAllowTransfer OpenRow(LANG_FL_tDeletedZone_cAllowTransfer,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cAllowTransfer)); } //cOptions OpenRow(LANG_FL_tDeletedZone_cOptions,"black"); printf("\n",cOptions); } else { printf("disabled>%s\n",cOptions); printf("\n",EncodeDoubleQuotes(cOptions)); } //uOwner OpenRow(LANG_FL_tDeletedZone_uOwner,"black"); if(guPermLevel>=20 && uMode) { printf("%s\n",ForeignKey(TCLIENT,"cLabel",uOwner),uOwner); } else { printf("%s\n",ForeignKey(TCLIENT,"cLabel",uOwner),uOwner); } //uCreatedBy OpenRow(LANG_FL_tDeletedZone_uCreatedBy,"black"); if(guPermLevel>=20 && uMode) { printf("%s\n",ForeignKey(TCLIENT,"cLabel",uCreatedBy),uCreatedBy); } else { printf("%s\n",ForeignKey(TCLIENT,"cLabel",uCreatedBy),uCreatedBy); } //uCreatedDate OpenRow(LANG_FL_tDeletedZone_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tDeletedZone_uModBy,"black"); if(guPermLevel>=20 && uMode) { printf("%s\n",ForeignKey(TCLIENT,"cLabel",uModBy),uModBy); } else { printf("%s\n",ForeignKey(TCLIENT,"cLabel",uModBy),uModBy); } //uModDate OpenRow(LANG_FL_tDeletedZone_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tDeletedZoneInput(unsigned uMode) void NewtDeletedZone(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uDeletedZone FROM tDeletedZone\ WHERE uDeletedZone=%u" ,uDeletedZone); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); i=mysql_num_rows(res); if(i) //tDeletedZone("Record already exists"); tDeletedZone(LANG_NBR_RECEXISTS); //insert query Insert_tDeletedZone(); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(gcQuery,"New record %u added"); uDeletedZone=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tDeletedZone",uDeletedZone); iDNSLog(uDeletedZone,"tDeletedZone","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uDeletedZone); tDeletedZone(gcQuery); } }//NewtDeletedZone(unsigned uMode) void DeletetDeletedZone(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tDeletedZone WHERE uDeletedZone=%u AND ( uOwner=%u OR %u>9 )" ,uDeletedZone,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tDeletedZone WHERE uDeletedZone=%u" ,uDeletedZone); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //tDeletedZone("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uDeletedZone,"tDeletedZone","Del"); #endif tDeletedZone(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uDeletedZone,"tDeletedZone","DelError"); #endif tDeletedZone(LANG_NBR_RECNOTDELETED); } }//void DeletetDeletedZone(void) void Insert_tDeletedZone(void) { //insert query sprintf(gcQuery,"INSERT INTO tDeletedZone SET uDeletedZone=%u,cZone='%s',uNSSet=%u,cHostmaster='%s',uSerial=%u,uExpire=%u,uRefresh=%u,uTTL=%u,uRetry=%u,uZoneTTL=%u,uMailServers=%u,uView=%u,cMainAddress='%s',uRegistrar=%u,uSecondaryOnly=%u,cAllowTransfer='%s',cOptions='%s',uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", uDeletedZone ,TextAreaSave(cZone) ,uNSSet ,TextAreaSave(cHostmaster) ,uSerial ,uExpire ,uRefresh ,uTTL ,uRetry ,uZoneTTL ,uMailServers ,uView ,TextAreaSave(cMainAddress) ,uRegistrar ,uSecondaryOnly ,TextAreaSave(cAllowTransfer) ,TextAreaSave(cOptions) ,uOwner ,uCreatedBy ); mysql_query(&gMysql,gcQuery); }//void Insert_tDeletedZone(void) void Update_tDeletedZone(char *cRowid) { //update query sprintf(gcQuery,"UPDATE tDeletedZone SET uDeletedZone=%u,cZone='%s',uNSSet=%u,cHostmaster='%s',uSerial=%u,uExpire=%u,uRefresh=%u,uTTL=%u,uRetry=%u,uZoneTTL=%u,uMailServers=%u,uView=%u,cMainAddress='%s',uRegistrar=%u,uSecondaryOnly=%u,cAllowTransfer='%s',cOptions='%s',uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", uDeletedZone ,TextAreaSave(cZone) ,uNSSet ,TextAreaSave(cHostmaster) ,uSerial ,uExpire ,uRefresh ,uTTL ,uRetry ,uZoneTTL ,uMailServers ,uView ,TextAreaSave(cMainAddress) ,uRegistrar ,uSecondaryOnly ,TextAreaSave(cAllowTransfer) ,TextAreaSave(cOptions) ,uModBy ,cRowid); mysql_query(&gMysql,gcQuery); }//void Update_tDeletedZone(void) void ModtDeletedZone(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; #ifdef ISM3FIELDS unsigned uPreModDate=0; sprintf(gcQuery,"SELECT uDeletedZone,uModDate FROM tDeletedZone WHERE uDeletedZone=%u" ,uDeletedZone); #else sprintf(gcQuery,"SELECT uDeletedZone FROM tDeletedZone WHERE uDeletedZone=%u" ,uDeletedZone); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); i=mysql_num_rows(res); //if(i<1) tDeletedZone("Record does not exist"); if(i<1) tDeletedZone(LANG_NBR_RECNOTEXIST); //if(i>1) tDeletedZone("Multiple rows!"); if(i>1) tDeletedZone(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tDeletedZone(LANG_NBR_EXTMOD); #endif Update_tDeletedZone(field[0]); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(query,"record %s modified",field[0]); sprintf(gcQuery,LANG_NBRF_REC_MODIFIED,field[0]); #ifdef ISM3FIELDS uModDate=luGetModDate("tDeletedZone",uDeletedZone); iDNSLog(uDeletedZone,"tDeletedZone","Mod"); #endif tDeletedZone(gcQuery); }//ModtDeletedZone(void) void tDeletedZoneList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttDeletedZoneListSelect(); mysql_query(&gMysql,gcQuery); if(mysql_error(&gMysql)[0]) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); guI=mysql_num_rows(res); PageMachine("tDeletedZoneList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttDeletedZoneListFilter(); printf("",gcCommand); printf("\n"); printf("\n"); printf(""); mysql_data_seek(res,guStart-1); for(guN=0;guN<(guEnd-guStart+1);guN++) { field=mysql_fetch_row(res); if(!field) { printf("
uZonecZoneuNSSetcHostmasteruSerialuExpireuRefreshuTTLuRetryuZoneTTLuMailServersuViewcMainAddressuRegistraruSecondaryOnlycMasterIPscOptionsuOwneruCreatedByuCreatedDateuModByuModDate
End of data
"); Footer_ism3(); } if(guN % 2) printf(""); else printf(""); long luYesNo14=strtoul(field[14],NULL,10); char cBuf14[4]; if(luYesNo14) sprintf(cBuf14,"Yes"); else sprintf(cBuf14,"No"); long luTime19=strtoul(field[19],NULL,10); char cBuf19[32]; if(luTime19) ctime_r(&luTime19,cBuf19); else sprintf(cBuf19,"---"); long luTime21=strtoul(field[21],NULL,10); char cBuf21[32]; if(luTime21) ctime_r(&luTime21,cBuf21); else sprintf(cBuf21,"---"); printf(" %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s" ,field[0] ,field[0] ,field[1] ,ForeignKey("tNSSet","cLabel",strtoul(field[2],NULL,10)) ,field[3] ,field[4] ,field[5] ,field[6] ,field[7] ,field[8] ,field[9] ,ForeignKey("tMailServer","cLabel",strtoul(field[10],NULL,10)) ,ForeignKey("tView","cLabel",strtoul(field[11],NULL,10)) ,field[12] ,ForeignKey("tRegistrar","cLabel",strtoul(field[13],NULL,10)) ,cBuf14 ,ForeignKey("tNSSet","cMasterIPs",strtoul(field[2],NULL,10)) ,field[16] ,ForeignKey(TCLIENT,"cLabel",strtoul(field[17],NULL,10)) ,ForeignKey(TCLIENT,"cLabel",strtoul(field[18],NULL,10)) ,cBuf19 ,ForeignKey(TCLIENT,"cLabel",strtoul(field[20],NULL,10)) ,cBuf21 ); } printf("\n"); Footer_ism3(); }//tDeletedZoneList() void CreatetDeletedZone(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tDeletedZone ( uDeletedZone INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, cZone VARCHAR(100) NOT NULL DEFAULT '', uOwner INT UNSIGNED NOT NULL DEFAULT 0,INDEX (uOwner), uCreatedBy INT UNSIGNED NOT NULL DEFAULT 0, uCreatedDate INT UNSIGNED NOT NULL DEFAULT 0, uModBy INT UNSIGNED NOT NULL DEFAULT 0, uModDate INT UNSIGNED NOT NULL DEFAULT 0, uNSSet INT UNSIGNED NOT NULL DEFAULT 0,INDEX (uNSSet), cHostmaster VARCHAR(100) NOT NULL DEFAULT '', uSerial INT UNSIGNED NOT NULL DEFAULT 0, uExpire INT UNSIGNED NOT NULL DEFAULT 0, uRefresh INT UNSIGNED NOT NULL DEFAULT 0, uTTL INT UNSIGNED NOT NULL DEFAULT 0, uRetry INT UNSIGNED NOT NULL DEFAULT 0, uZoneTTL INT UNSIGNED NOT NULL DEFAULT 0, uMailServers INT UNSIGNED NOT NULL DEFAULT 0, cMainAddress VARCHAR(16) NOT NULL DEFAULT '', uView INT UNSIGNED NOT NULL DEFAULT 0, cOptions TEXT NOT NULL DEFAULT '', uSecondaryOnly INT UNSIGNED NOT NULL DEFAULT 0, uRegistrar INT UNSIGNED NOT NULL DEFAULT 0, cAllowTransfer VARCHAR(255) NOT NULL DEFAULT '' )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetDeletedZone()