/* FILE tZoneImport 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 tzoneimportfunc.h while RAD is still to be used. */ #include "mysqlrad.h" //Table Variables //Table Variables //uZone: Primary Key static unsigned uZone=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_tZoneImport "tZoneImport.uZone,tZoneImport.cZone,tZoneImport.uNSSet,tZoneImport.cHostmaster,tZoneImport.uSerial,tZoneImport.uExpire,tZoneImport.uRefresh,tZoneImport.uTTL,tZoneImport.uRetry,tZoneImport.uZoneTTL,tZoneImport.uMailServers,tZoneImport.uView,tZoneImport.cMainAddress,tZoneImport.uRegistrar,tZoneImport.uSecondaryOnly,tZoneImport.cAllowTransfer,tZoneImport.cOptions,tZoneImport.uOwner,tZoneImport.uCreatedBy,tZoneImport.uCreatedDate,tZoneImport.uModBy,tZoneImport.uModDate" //Local only void Insert_tZoneImport(void); void Update_tZoneImport(char *cRowid); void ProcesstZoneImportListVars(pentry entries[], int x); //In tZoneImportfunc.h file included below void ExtProcesstZoneImportVars(pentry entries[], int x); void ExttZoneImportCommands(pentry entries[], int x); void ExttZoneImportButtons(void); void ExttZoneImportNavBar(void); void ExttZoneImportGetHook(entry gentries[], int x); void ExttZoneImportSelect(void); void ExttZoneImportSelectRow(void); void ExttZoneImportListSelect(void); void ExttZoneImportListFilter(void); void ExttZoneImportAuxTable(void); #include "tzoneimportfunc.h" //Table Variables Assignment Function void ProcesstZoneImportVars(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(""); ExttZoneImportButtons(); printf(""); // OpenFieldSet("tZoneImport Record Data",100); if(guMode==2000 || guMode==2002) tZoneImportInput(1); else tZoneImportInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttZoneImportAuxTable(); Footer_ism3(); }//end of tZoneImport(); void tZoneImportInput(unsigned uMode) { //uZone OpenRow(LANG_FL_tZoneImport_uZone,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uZone); } //cZone OpenRow(LANG_FL_tZoneImport_cZone,EmptyString(cZone)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cZone)); } //uNSSet OpenRow(LANG_FL_tZoneImport_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_tZoneImport_cHostmaster,EmptyString(cHostmaster)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cHostmaster)); } //uSerial OpenRow(LANG_FL_tZoneImport_uSerial,IsZero(uSerial)); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uSerial); } //uExpire OpenRow(LANG_FL_tZoneImport_uExpire,IsZero(uExpire)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uExpire); } //uRefresh OpenRow(LANG_FL_tZoneImport_uRefresh,IsZero(uRefresh)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uRefresh); } //uTTL OpenRow(LANG_FL_tZoneImport_uTTL,IsZero(uTTL)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uTTL); } //uRetry OpenRow(LANG_FL_tZoneImport_uRetry,IsZero(uRetry)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uRetry); } //uZoneTTL OpenRow(LANG_FL_tZoneImport_uZoneTTL,IsZero(uZoneTTL)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uZoneTTL); } //uMailServers OpenRow(LANG_FL_tZoneImport_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_tZoneImport_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_tZoneImport_cMainAddress,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cMainAddress)); } //uRegistrar OpenRow(LANG_FL_tZoneImport_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_tZoneImport_uSecondaryOnly,"black"); if(guPermLevel>=0 && uMode) YesNoPullDown("uSecondaryOnly",uSecondaryOnly,1); else YesNoPullDown("uSecondaryOnly",uSecondaryOnly,0); //cMasterIPs OpenRow(LANG_FL_tZoneImport_cMasterIPs,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cMasterIPs)); } //cAllowTransfer OpenRow(LANG_FL_tZoneImport_cAllowTransfer,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cAllowTransfer)); } //cOptions OpenRow(LANG_FL_tZoneImport_cOptions,"black"); printf("\n",cOptions); } else { printf("disabled>%s\n",cOptions); printf("\n",EncodeDoubleQuotes(cOptions)); } //uOwner OpenRow(LANG_FL_tZoneImport_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_tZoneImport_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_tZoneImport_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tZoneImport_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_tZoneImport_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tZoneImportInput(unsigned uMode) void NewtZoneImport(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uZone FROM tZoneImport\ WHERE uZone=%u" ,uZone); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); i=mysql_num_rows(res); if(i) //tZoneImport("Record already exists"); tZoneImport(LANG_NBR_RECEXISTS); //insert query Insert_tZoneImport(); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(gcQuery,"New record %u added"); uZone=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tZoneImport",uZone); iDNSLog(uZone,"tZoneImport","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uZone); tZoneImport(gcQuery); } }//NewtZoneImport(unsigned uMode) void DeletetZoneImport(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tZoneImport WHERE uZone=%u AND ( uOwner=%u OR %u>9 )" ,uZone,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tZoneImport WHERE uZone=%u" ,uZone); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //tZoneImport("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uZone,"tZoneImport","Del"); #endif tZoneImport(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uZone,"tZoneImport","DelError"); #endif tZoneImport(LANG_NBR_RECNOTDELETED); } }//void DeletetZoneImport(void) void Insert_tZoneImport(void) { //insert query sprintf(gcQuery,"INSERT INTO tZoneImport SET uZone=%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())", uZone ,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_tZoneImport(void) void Update_tZoneImport(char *cRowid) { //update query sprintf(gcQuery,"UPDATE tZoneImport SET uZone=%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", uZone ,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_tZoneImport(void) void ModtZoneImport(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; #ifdef ISM3FIELDS unsigned uPreModDate=0; sprintf(gcQuery,"SELECT uZone,uModDate FROM tZoneImport WHERE uZone=%u" ,uZone); #else sprintf(gcQuery,"SELECT uZone FROM tZoneImport WHERE uZone=%u" ,uZone); #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) tZoneImport("Record does not exist"); if(i<1) tZoneImport(LANG_NBR_RECNOTEXIST); //if(i>1) tZoneImport("Multiple rows!"); if(i>1) tZoneImport(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tZoneImport(LANG_NBR_EXTMOD); #endif Update_tZoneImport(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("tZoneImport",uZone); iDNSLog(uZone,"tZoneImport","Mod"); #endif tZoneImport(gcQuery); }//ModtZoneImport(void) void tZoneImportList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttZoneImportListSelect(); mysql_query(&gMysql,gcQuery); if(mysql_error(&gMysql)[0]) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); guI=mysql_num_rows(res); PageMachine("tZoneImportList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttZoneImportListFilter(); 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("
uZonecZoneuNSSetcHostmasteruSerialuExpireuRefreshuTTLuRetryuZoneTTLuMailServersuViewcMainAddressuRegistraruSecondaryOnlycMasterIPscAllowTransfercOptionsuOwneruCreatedByuCreatedDateuModByuModDate
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 luTime20=strtoul(field[19],NULL,10); char cBuf20[32]; if(luTime20) ctime_r(&luTime20,cBuf20); else sprintf(cBuf20,"---"); long luTime22=strtoul(field[21],NULL,10); char cBuf22[32]; if(luTime22) ctime_r(&luTime22,cBuf22); else sprintf(cBuf22,"---"); printf(" %s%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[15] ,field[16] ,ForeignKey(TCLIENT,"cLabel",strtoul(field[17],NULL,10)) ,ForeignKey(TCLIENT,"cLabel",strtoul(field[18],NULL,10)) ,cBuf20 ,ForeignKey(TCLIENT,"cLabel",strtoul(field[20],NULL,10)) ,cBuf22 ); } printf("\n"); Footer_ism3(); }//tZoneImportList() void CreatetZoneImport(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tZoneImport ( uZone INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, cZone VARCHAR(100) NOT NULL DEFAULT '',UNIQUE (cZone,uView), 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 '',uClient INT UNSIGNED NOT NULL DEFAULT 0 )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetZoneImport()