/* FILE tNSSet source code of iDNS.cgi Built by mysqlRAD2.cgi (C) Gary Wallis 2001-2009 for Unixservice $Id$ PURPOSE Schema dependent RAD generated file. Program app functionality in tnssetfunc.h while RAD is still to be used. */ #include "mysqlrad.h" //Table Variables //Table Variables //uNSSet: Primary Key static unsigned uNSSet=0; //cLabel: Short label static char cLabel[33]={""}; //cMasterIPs: Master IPs of a given set static char cMasterIPs[256]={""}; //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 time_t uCreatedDate=0; //uModBy: uClient for last update static unsigned uModBy=0; //uModDate: Unix seconds date last update static time_t uModDate=0; #define VAR_LIST_tNSSet "tNSSet.uNSSet,tNSSet.cLabel,tNSSet.cMasterIPs,tNSSet.uOwner,tNSSet.uCreatedBy,tNSSet.uCreatedDate,tNSSet.uModBy,tNSSet.uModDate" //Local only void Insert_tNSSet(void); void Update_tNSSet(char *cRowid); void ProcesstNSSetListVars(pentry entries[], int x); //In tNSSetfunc.h file included below void ExtProcesstNSSetVars(pentry entries[], int x); void ExttNSSetCommands(pentry entries[], int x); void ExttNSSetButtons(void); void ExttNSSetNavBar(void); void ExttNSSetGetHook(entry gentries[], int x); void ExttNSSetSelect(void); void ExttNSSetSelectRow(void); void ExttNSSetListSelect(void); void ExttNSSetListFilter(void); void ExttNSSetAuxTable(void); #include "tnssetfunc.h" //Table Variables Assignment Function void ProcesstNSSetVars(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(""); ExttNSSetButtons(); printf(""); // OpenFieldSet("tNSSet Record Data",100); if(guMode==2000 || guMode==2002) tNSSetInput(1); else tNSSetInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttNSSetAuxTable(); Footer_ism3(); }//end of tNSSet(); void tNSSetInput(unsigned uMode) { //uNSSet OpenRow(LANG_FL_tNSSet_uNSSet,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uNSSet); } //cLabel OpenRow(LANG_FL_tNSSet_cLabel,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cLabel)); } //cMasterIPs OpenRow(LANG_FL_tNSSet_cMasterIPs,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cMasterIPs)); } //uOwner OpenRow(LANG_FL_tNSSet_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_tNSSet_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_tNSSet_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tNSSet_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_tNSSet_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tNSSetInput(unsigned uMode) void NewtNSSet(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uNSSet FROM tNSSet\ WHERE uNSSet=%u" ,uNSSet); macro_mySQLRunAndStore(res); i=mysql_num_rows(res); if(i) //tNSSet("Record already exists"); tNSSet(LANG_NBR_RECEXISTS); //insert query Insert_tNSSet(); //sprintf(gcQuery,"New record %u added"); uNSSet=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tNSSet",uNSSet); iDNSLog(uNSSet,"tNSSet","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uNSSet); tNSSet(gcQuery); } }//NewtNSSet(unsigned uMode) void DeletetNSSet(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tNSSet WHERE uNSSet=%u AND ( uOwner=%u OR %u>9 )" ,uNSSet,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tNSSet WHERE uNSSet=%u" ,uNSSet); #endif macro_mySQLQueryHTMLError; //tNSSet("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uNSSet,"tNSSet","Del"); #endif tNSSet(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uNSSet,"tNSSet","DelError"); #endif tNSSet(LANG_NBR_RECNOTDELETED); } }//void DeletetNSSet(void) void Insert_tNSSet(void) { //insert query sprintf(gcQuery,"INSERT INTO tNSSet SET uNSSet=%u,cLabel='%s',cMasterIPs='%s',uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", uNSSet ,TextAreaSave(cLabel) ,TextAreaSave(cMasterIPs) ,uOwner ,uCreatedBy ); macro_mySQLQueryHTMLError; }//void Insert_tNSSet(void) void Update_tNSSet(char *cRowid) { //update query sprintf(gcQuery,"UPDATE tNSSet SET uNSSet=%u,cLabel='%s',cMasterIPs='%s',uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", uNSSet ,TextAreaSave(cLabel) ,TextAreaSave(cMasterIPs) ,uModBy ,cRowid); macro_mySQLQueryHTMLError; }//void Update_tNSSet(void) void ModtNSSet(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; #ifdef ISM3FIELDS unsigned uPreModDate=0; //Mod select gcQuery if(guPermLevel<10) sprintf(gcQuery,"SELECT tNSSet.uNSSet,\ tNSSet.uModDate\ FROM tNSSet,tClient\ WHERE tNSSet.uNSSet=%u\ AND tNSSet.uOwner=tClient.uClient\ AND (tClient.uOwner=%u OR tClient.uClient=%u)" ,uNSSet,guLoginClient,guLoginClient); else sprintf(gcQuery,"SELECT uNSSet,uModDate FROM tNSSet\ WHERE uNSSet=%u" ,uNSSet); #else sprintf(gcQuery,"SELECT uNSSet FROM tNSSet\ WHERE uNSSet=%u" ,uNSSet); #endif macro_mySQLRunAndStore(res); i=mysql_num_rows(res); //if(i<1) tNSSet("Record does not exist"); if(i<1) tNSSet(LANG_NBR_RECNOTEXIST); //if(i>1) tNSSet("Multiple rows!"); if(i>1) tNSSet(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tNSSet(LANG_NBR_EXTMOD); #endif Update_tNSSet(field[0]); //sprintf(query,"record %s modified",field[0]); sprintf(gcQuery,LANG_NBRF_REC_MODIFIED,field[0]); #ifdef ISM3FIELDS uModDate=luGetModDate("tNSSet",uNSSet); iDNSLog(uNSSet,"tNSSet","Mod"); #endif tNSSet(gcQuery); }//ModtNSSet(void) void tNSSetList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttNSSetListSelect(); macro_mySQLRunAndStore(res); guI=mysql_num_rows(res); PageMachine("tNSSetList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttNSSetListFilter(); 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("
uNSSetcLabelcMasterIPsuOwneruCreatedByuCreatedDateuModByuModDate
End of data
"); Footer_ism3(); } if(guN % 2) printf(""); else printf(""); time_t luTime5=strtoul(field[5],NULL,10); char cBuf5[32]; if(luTime5) ctime_r(&luTime5,cBuf5); else sprintf(cBuf5,"---"); time_t luTime7=strtoul(field[7],NULL,10); char cBuf7[32]; if(luTime7) ctime_r(&luTime7,cBuf7); else sprintf(cBuf7,"---"); printf(" %s%s%s%s%s%s%s%s" ,field[0] ,field[0] ,field[1] ,field[2] ,ForeignKey(TCLIENT,"cLabel",strtoul(field[3],NULL,10)) ,ForeignKey(TCLIENT,"cLabel",strtoul(field[4],NULL,10)) ,cBuf5 ,ForeignKey(TCLIENT,"cLabel",strtoul(field[6],NULL,10)) ,cBuf7 ); } printf("\n"); Footer_ism3(); }//tNSSetList() void CreatetNSSet(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tNSSet ( uNSSet 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, cMasterIPs VARCHAR(255) NOT NULL DEFAULT '' )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetNSSet()