/* FILE tView 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 tviewfunc.h while RAD is still to be used. */ #include "mysqlrad.h" //Table Variables //Table Variables //uView: Primary Key static unsigned uView=0; //cLabel: Short label static char cLabel[33]={""}; //uOrder: Order in zone file static unsigned uOrder=0; //uNSSet: Name Server Set static unsigned uNSSet=0; static char cuNSSetPullDown[256]={""}; //cMaster: BIND configuration master.zones view section header static char *cMaster={""}; //cSlave: Bind configuration slave.zones view section header static char *cSlave={""}; //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_tView "tView.uView,tView.cLabel,tView.uOrder,tView.uNSSet,tView.cMaster,tView.cSlave,tView.uOwner,tView.uCreatedBy,tView.uCreatedDate,tView.uModBy,tView.uModDate" //Local only void Insert_tView(void); void Update_tView(char *cRowid); void ProcesstViewListVars(pentry entries[], int x); //In tViewfunc.h file included below void ExtProcesstViewVars(pentry entries[], int x); void ExttViewCommands(pentry entries[], int x); void ExttViewButtons(void); void ExttViewNavBar(void); void ExttViewGetHook(entry gentries[], int x); void ExttViewSelect(void); void ExttViewSelectRow(void); void ExttViewListSelect(void); void ExttViewListFilter(void); void ExttViewAuxTable(void); #include "tviewfunc.h" //Table Variables Assignment Function void ProcesstViewVars(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(""); ExttViewButtons(); printf(""); // OpenFieldSet("tView Record Data",100); if(guMode==2000 || guMode==2002) tViewInput(1); else tViewInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttViewAuxTable(); Footer_ism3(); }//end of tView(); void tViewInput(unsigned uMode) { //uView OpenRow(LANG_FL_tView_uView,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uView); } //cLabel OpenRow(LANG_FL_tView_cLabel,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cLabel)); } //uOrder OpenRow(LANG_FL_tView_uOrder,"black"); printf("=10 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uOrder); } //uNSSet OpenRow(LANG_FL_tView_uNSSet,"black"); if(guPermLevel>=10 && uMode) tTablePullDown("tNSSet;cuNSSetPullDown","cLabel","cLabel",uNSSet,1); else tTablePullDown("tNSSet;cuNSSetPullDown","cLabel","cLabel",uNSSet,0); //cMaster OpenRow(LANG_FL_tView_cMaster,"black"); printf("\n",cMaster); } else { printf("disabled>%s\n",cMaster); printf("\n",EncodeDoubleQuotes(cMaster)); } //cSlave OpenRow(LANG_FL_tView_cSlave,"black"); printf("\n",cSlave); } else { printf("disabled>%s\n",cSlave); printf("\n",EncodeDoubleQuotes(cSlave)); } //uOwner OpenRow(LANG_FL_tView_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_tView_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_tView_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tView_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_tView_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tViewInput(unsigned uMode) void NewtView(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uView FROM tView\ WHERE uView=%u" ,uView); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); i=mysql_num_rows(res); if(i) //tView("Record already exists"); tView(LANG_NBR_RECEXISTS); //insert query Insert_tView(); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(gcQuery,"New record %u added"); uView=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tView",uView); iDNSLog(uView,"tView","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uView); tView(gcQuery); } }//NewtView(unsigned uMode) void DeletetView(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tView WHERE uView=%u AND ( uOwner=%u OR %u>9 )" ,uView,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tView WHERE uView=%u" ,uView); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //tView("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uView,"tView","Del"); #endif tView(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uView,"tView","DelError"); #endif tView(LANG_NBR_RECNOTDELETED); } }//void DeletetView(void) void Insert_tView(void) { //insert query sprintf(gcQuery,"INSERT INTO tView SET uView=%u,cLabel='%s',uOrder=%u,uNSSet=%u,cMaster='%s',cSlave='%s',uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", uView ,TextAreaSave(cLabel) ,uOrder ,uNSSet ,TextAreaSave(cMaster) ,TextAreaSave(cSlave) ,uOwner ,uCreatedBy ); mysql_query(&gMysql,gcQuery); }//void Insert_tView(void) void Update_tView(char *cRowid) { //update query sprintf(gcQuery,"UPDATE tView SET uView=%u,cLabel='%s',uOrder=%u,uNSSet=%u,cMaster='%s',cSlave='%s',uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", uView ,TextAreaSave(cLabel) ,uOrder ,uNSSet ,TextAreaSave(cMaster) ,TextAreaSave(cSlave) ,uModBy ,cRowid); mysql_query(&gMysql,gcQuery); }//void Update_tView(void) void ModtView(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; #ifdef ISM3FIELDS unsigned uPreModDate=0; sprintf(gcQuery,"SELECT uView,uModDate FROM tView WHERE uView=%u" ,uView); #else sprintf(gcQuery,"SELECT uView FROM tView WHERE uView=%u" ,uView); #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) tView("Record does not exist"); if(i<1) tView(LANG_NBR_RECNOTEXIST); //if(i>1) tView("Multiple rows!"); if(i>1) tView(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tView(LANG_NBR_EXTMOD); #endif Update_tView(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("tView",uView); iDNSLog(uView,"tView","Mod"); #endif tView(gcQuery); }//ModtView(void) void tViewList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttViewListSelect(); mysql_query(&gMysql,gcQuery); if(mysql_error(&gMysql)[0]) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); guI=mysql_num_rows(res); PageMachine("tViewList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttViewListFilter(); 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("
uViewcLabeluOrderuNSSetcMastercSlaveuOwneruCreatedByuCreatedDateuModByuModDate
End of data
"); Footer_ism3(); } if(guN % 2) printf(""); else printf(""); long luTime8=strtoul(field[8],NULL,10); char cBuf8[32]; if(luTime8) ctime_r(&luTime8,cBuf8); else sprintf(cBuf8,"---"); long luTime10=strtoul(field[10],NULL,10); char cBuf10[32]; if(luTime10) ctime_r(&luTime10,cBuf10); else sprintf(cBuf10,"---"); printf(" %s%s%s%s%s%s%s%s%s" ,field[0] ,field[0] ,field[1] ,field[2] ,ForeignKey("tNSSet","cLabel",strtoul(field[3],NULL,10)) ,field[4] ,field[5] ,ForeignKey(TCLIENT,"cLabel",strtoul(field[6],NULL,10)) ,ForeignKey(TCLIENT,"cLabel",strtoul(field[7],NULL,10)) ,cBuf8 ,ForeignKey(TCLIENT,"cLabel",strtoul(field[9],NULL,10)) ,cBuf10 ); } printf("\n"); Footer_ism3(); }//tViewList() void CreatetView(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tView ( uView INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, cLabel VARCHAR(32) 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, cMaster TEXT NOT NULL DEFAULT '', cSlave TEXT NOT NULL DEFAULT '', uOrder INT UNSIGNED NOT NULL DEFAULT 0, uNSSet INT UNSIGNED NOT NULL DEFAULT 0,INDEX (uNSSet) )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetView()