/* FILE tZone 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 tzonefunc.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]={""}; //cOptions: slave.zones and master.zones zone options static char *cOptions={""}; //Resource owner, i.e. end user uClient that has the resource deployed for static unsigned uClient=0; //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_tZone "tZone.uZone,tZone.cZone,tZone.uNSSet,tZone.cHostmaster,tZone.uSerial,tZone.uExpire,tZone.uRefresh,tZone.uTTL,tZone.uRetry,tZone.uZoneTTL,tZone.uMailServers,tZone.uView,tZone.cMainAddress,tZone.uRegistrar,tZone.uSecondaryOnly,tZone.cOptions,tZone.uClient,tZone.uOwner,tZone.uCreatedBy,tZone.uCreatedDate,tZone.uModBy,tZone.uModDate" //Local only void Insert_tZone(void); void Update_tZone(char *cRowid); void ProcesstZoneListVars(pentry entries[], int x); //In tZonefunc.h file included below void ExtProcesstZoneVars(pentry entries[], int x); void ExttZoneCommands(pentry entries[], int x); void ExttZoneButtons(void); void ExttZoneNavBar(void); void ExttZoneGetHook(entry gentries[], int x); void ExttZoneSelect(void); void ExttZoneSelectRow(void); void ExttZoneListSelect(void); void ExttZoneListFilter(void); void ExttZoneAuxTable(void); #include "tzonefunc.h" //Table Variables Assignment Function void ProcesstZoneVars(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(""); ExttZoneButtons(); printf(""); // OpenFieldSet("tZone Record Data",100); if(guMode==2000 || guMode==2002) tZoneInput(1); else tZoneInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttZoneAuxTable(); Footer_ism3(); }//end of tZone(); void tZoneInput(unsigned uMode) { //cZone optional graph if(cZone[0]) { char cConfigBuffer[256]={""}; GetConfiguration(cZone,cConfigBuffer,0); if(cConfigBuffer[0]) { OpenRow("Optional Graph","black"); printf("\n"); printf("" "\n", cConfigBuffer); } } //uZone OpenRow(LANG_FL_tZone_uZone,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uZone); } //cZone OpenRow(LANG_FL_tZone_cZone,EmptyString(cZone)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cZone)); } //uNSSet OpenRow(LANG_FL_tZone_uNSSet,"black"); if(guPermLevel>=0 && uMode) tTablePullDown("tNSSet;cuNSSetPullDown","cLabel","cLabel",uNSSet,1); else tTablePullDown("tNSSet;cuNSSetPullDown","cLabel","cLabel",uNSSet,0); //cHostmaster OpenRow(LANG_FL_tZone_cHostmaster,EmptyString(cHostmaster)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cHostmaster)); } //uSerial OpenRow(LANG_FL_tZone_uSerial,IsZero(uSerial)); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uSerial); } //uExpire OpenRow(LANG_FL_tZone_uExpire,IsZero(uExpire)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uExpire); } //uRefresh OpenRow(LANG_FL_tZone_uRefresh,IsZero(uRefresh)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uRefresh); } //uTTL OpenRow(LANG_FL_tZone_uTTL,IsZero(uTTL)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uTTL); } //uRetry OpenRow(LANG_FL_tZone_uRetry,IsZero(uRetry)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uRetry); } //uZoneTTL OpenRow(LANG_FL_tZone_uZoneTTL,IsZero(uZoneTTL)); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uZoneTTL); } //uMailServers OpenRow(LANG_FL_tZone_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_tZone_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_tZone_cMainAddress,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cMainAddress)); } //uRegistrar OpenRow(LANG_FL_tZone_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_tZone_uSecondaryOnly,"black"); if(guPermLevel>=0 && uMode) YesNoPullDown("uSecondaryOnly",uSecondaryOnly,1); else YesNoPullDown("uSecondaryOnly",uSecondaryOnly,0); //cMasterIPs OpenRow(LANG_FL_tZone_cMasterIPs,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cMasterIPs)); } //cOptions OpenRow(LANG_FL_tZone_cOptions,"black"); printf("\n",cOptions); } else { printf("disabled>%s\n",cOptions); printf("\n",EncodeDoubleQuotes(cOptions)); } //uClient OpenRow(LANG_FL_tZone_uClient,"black"); if(guPermLevel>=20 && uMode) { printf("%s\n",ForeignKey(TCLIENT,"cLabel",uClient),uClient); } else { printf("%s\n",ForeignKey(TCLIENT,"cLabel",uClient),uClient); } //uOwner OpenRow(LANG_FL_tZone_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_tZone_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_tZone_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tZone_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_tZone_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tZoneInput(unsigned uMode) void NewtZone(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uZone FROM tZone\ 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) //tZone("Record already exists"); tZone(LANG_NBR_RECEXISTS); //insert query Insert_tZone(); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(gcQuery,"New record %u added"); uZone=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tZone",uZone); iDNSLog(uZone,"tZone","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uZone); tZone(gcQuery); } }//NewtZone(unsigned uMode) void DeletetZone(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tZone WHERE uZone=%u AND ( uOwner=%u OR %u>9 )" ,uZone,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tZone WHERE uZone=%u" ,uZone); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //tZone("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uZone,"tZone","Del"); #endif tZone(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uZone,"tZone","DelError"); #endif tZone(LANG_NBR_RECNOTDELETED); } }//void DeletetZone(void) void Insert_tZone(void) { //insert query sprintf(gcQuery,"INSERT INTO tZone 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,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(cOptions) ,uOwner ,uCreatedBy ); mysql_query(&gMysql,gcQuery); }//void Insert_tZone(void) void Update_tZone(char *cRowid) { //update query sprintf(gcQuery,"UPDATE tZone 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,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(cOptions) ,uModBy ,cRowid); mysql_query(&gMysql,gcQuery); }//void Update_tZone(void) void ModtZone(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; #ifdef ISM3FIELDS unsigned uPreModDate=0; sprintf(gcQuery,"SELECT uZone,uModDate FROM tZone WHERE uZone=%u" ,uZone); #else sprintf(gcQuery,"SELECT uZone FROM tZone 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) tZone("Record does not exist"); if(i<1) tZone(LANG_NBR_RECNOTEXIST); //if(i>1) tZone("Multiple rows!"); if(i>1) tZone(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tZone(LANG_NBR_EXTMOD); #endif Update_tZone(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("tZone",uZone); iDNSLog(uZone,"tZone","Mod"); #endif tZone(gcQuery); }//ModtZone(void) void tZoneList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttZoneListSelect(); mysql_query(&gMysql,gcQuery); if(mysql_error(&gMysql)[0]) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); guI=mysql_num_rows(res); PageMachine("tZoneList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttZoneListFilter(); 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("
uZonecZoneuNSSetcHostmasteruSerialuExpireuRefreshuTTLuRetryuZoneTTLuMailServersuViewcMainAddressuRegistraruSecondaryOnlycMasterIPsuClientuOwneruCreatedByuCreatedDateuModByuModDate
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%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)) ,ForeignKey(TCLIENT,"cLabel",strtoul(field[16],NULL,10)) ,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(); }//tZoneList() void CreatetZone(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tZone ( 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, uRegistrar INT UNSIGNED NOT NULL DEFAULT 0, cOptions TEXT NOT NULL DEFAULT '', uSecondaryOnly INT UNSIGNED NOT NULL DEFAULT 0, uClient INT UNSIGNED NOT NULL DEFAULT 0 )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetZone()