/* FILE tJob 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 tjobfunc.h while RAD is still to be used. */ #include "mysqlrad.h" //Table Variables //Table Variables //uJob: Unique job ID static unsigned uJob=0; //uMasterJob: Unique group job ID static unsigned uMasterJob=0; //cJob: Job description static char cJob[101]={""}; //cZone: Zone to be operated on static char cZone[101]={""}; //uNSSet: Key into tNSSet static unsigned uNSSet=0; static char cuNSSetPullDown[256]={""}; //cTargetServer: Name of server that should process this job static char cTargetServer[101]={""}; //uPriority: Job priority static unsigned uPriority=0; //uTime: Unix seconds threshold static long uTime=0; //cJobData: Aux job data static char cJobData[101]={""}; //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_tJob "tJob.uJob,tJob.uMasterJob,tJob.cJob,tJob.cZone,tJob.uNSSet,tJob.cTargetServer,tJob.uPriority,tJob.uTime,tJob.cJobData,tJob.uOwner,tJob.uCreatedBy,tJob.uCreatedDate,tJob.uModBy,tJob.uModDate" //Local only void Insert_tJob(void); void Update_tJob(char *cRowid); void ProcesstJobListVars(pentry entries[], int x); //In tJobfunc.h file included below void ExtProcesstJobVars(pentry entries[], int x); void ExttJobCommands(pentry entries[], int x); void ExttJobButtons(void); void ExttJobNavBar(void); void ExttJobGetHook(entry gentries[], int x); void ExttJobSelect(void); void ExttJobSelectRow(void); void ExttJobListSelect(void); void ExttJobListFilter(void); void ExttJobAuxTable(void); #include "tjobfunc.h" //Table Variables Assignment Function void ProcesstJobVars(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(""); ExttJobButtons(); printf(""); // OpenFieldSet("tJob Record Data",100); if(guMode==2000 || guMode==2002) tJobInput(1); else tJobInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttJobAuxTable(); Footer_ism3(); }//end of tJob(); void tJobInput(unsigned uMode) { //uJob OpenRow(LANG_FL_tJob_uJob,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uJob); } //uMasterJob OpenRow(LANG_FL_tJob_uMasterJob,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uMasterJob); } //cJob OpenRow(LANG_FL_tJob_cJob,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cJob)); } //cZone OpenRow(LANG_FL_tJob_cZone,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cZone)); } //uNSSet OpenRow(LANG_FL_tJob_uNSSet,"black"); if(guPermLevel>=0 && uMode) tTablePullDown("tNSSet;cuNSSetPullDown","cLabel","cLabel",uNSSet,1); else tTablePullDown("tNSSet;cuNSSetPullDown","cLabel","cLabel",uNSSet,0); //cTargetServer OpenRow(LANG_FL_tJob_cTargetServer,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cTargetServer)); } //uPriority OpenRow(LANG_FL_tJob_uPriority,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uPriority); } //uTime OpenRow(LANG_FL_tJob_uTime,"black"); if(uTime) printf("\n",ctime(&uTime)); else printf("\n"); printf("\n",uTime); //cJobData OpenRow(LANG_FL_tJob_cJobData,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cJobData)); } //uOwner OpenRow(LANG_FL_tJob_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_tJob_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_tJob_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tJob_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_tJob_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tJobInput(unsigned uMode) void NewtJob(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uJob FROM tJob\ WHERE uJob=%u" ,uJob); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); i=mysql_num_rows(res); if(i) //tJob("Record already exists"); tJob(LANG_NBR_RECEXISTS); //insert query Insert_tJob(); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(gcQuery,"New record %u added"); uJob=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tJob",uJob); iDNSLog(uJob,"tJob","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uJob); tJob(gcQuery); } }//NewtJob(unsigned uMode) void DeletetJob(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tJob WHERE uJob=%u AND ( uOwner=%u OR %u>9 )" ,uJob,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tJob WHERE uJob=%u" ,uJob); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //tJob("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uJob,"tJob","Del"); #endif tJob(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uJob,"tJob","DelError"); #endif tJob(LANG_NBR_RECNOTDELETED); } }//void DeletetJob(void) void Insert_tJob(void) { if(uTime) sprintf(gcQuery,"INSERT INTO tJob SET uJob=%u,uMasterJob=%u,cJob='%s',cZone='%s',uNSSet=%u," "cTargetServer='%s',uPriority=%u,uTime=%lu,cJobData='%s',uOwner=%u,uCreatedBy=%u," "uCreatedDate=UNIX_TIMESTAMP(NOW())", uJob ,uMasterJob ,TextAreaSave(cJob) ,TextAreaSave(cZone) ,uNSSet ,TextAreaSave(cTargetServer) ,uPriority ,uTime ,TextAreaSave(cJobData) ,uOwner ,uCreatedBy ); else sprintf(gcQuery,"INSERT INTO tJob SET uJob=%u,uMasterJob=%u,cJob='%s',cZone='%s',uNSSet=%u," "cTargetServer='%s',uPriority=%u,uTime=UNIX_TIMESTAMP(NOW()),cJobData='%s'," "uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", uJob ,uMasterJob ,TextAreaSave(cJob) ,TextAreaSave(cZone) ,uNSSet ,TextAreaSave(cTargetServer) ,uPriority ,TextAreaSave(cJobData) ,uOwner ,uCreatedBy ); mysql_query(&gMysql,gcQuery); }//void Insert_tJob(void) void Update_tJob(char *cRowid) { //update query sprintf(gcQuery,"UPDATE tJob SET uJob=%u,uMasterJob=%u,cJob='%s',cZone='%s',uNSSet=%u,cTargetServer='%s',uPriority=%u,uTime=%lu,cJobData='%s',uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", uJob ,uMasterJob ,TextAreaSave(cJob) ,TextAreaSave(cZone) ,uNSSet ,TextAreaSave(cTargetServer) ,uPriority ,uTime ,TextAreaSave(cJobData) ,uModBy ,cRowid); mysql_query(&gMysql,gcQuery); }//void Update_tJob(void) void ModtJob(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; #ifdef ISM3FIELDS unsigned uPreModDate=0; sprintf(gcQuery,"SELECT uJob,uModDate FROM tJob WHERE uJob=%u" ,uJob); #else sprintf(gcQuery,"SELECT uJob FROM tJob WHERE uJob=%u" ,uJob); #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) tJob("Record does not exist"); if(i<1) tJob(LANG_NBR_RECNOTEXIST); //if(i>1) tJob("Multiple rows!"); if(i>1) tJob(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tJob(LANG_NBR_EXTMOD); #endif Update_tJob(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("tJob",uJob); iDNSLog(uJob,"tJob","Mod"); #endif tJob(gcQuery); }//ModtJob(void) void tJobList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttJobListSelect(); mysql_query(&gMysql,gcQuery); if(mysql_error(&gMysql)[0]) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); guI=mysql_num_rows(res); PageMachine("tJobList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttJobListFilter(); 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("
uJobuMasterJobcJobcZoneuNSSetcTargetServeruPriorityuTimecJobDatauOwneruCreatedByuCreatedDateuModByuModDate
End of data
"); Footer_ism3(); } if(guN % 2) printf(""); else printf(""); long luTime7=strtoul(field[7],NULL,10); char cBuf7[32]; if(luTime7) ctime_r(&luTime7,cBuf7); else sprintf(cBuf7,"---"); long luTime11=strtoul(field[11],NULL,10); char cBuf11[32]; if(luTime11) ctime_r(&luTime11,cBuf11); else sprintf(cBuf11,"---"); long luTime13=strtoul(field[13],NULL,10); char cBuf13[32]; if(luTime13) ctime_r(&luTime13,cBuf13); else sprintf(cBuf13,"---"); printf(" %s%s%s%s%s%s%s%s%s%s%s%s%s%s" ,field[0] ,field[0] ,field[1] ,field[2] ,field[3] ,ForeignKey("tNSSet","cLabel",strtoul(field[4],NULL,10)) ,field[5] ,field[6] ,cBuf7 ,field[8] ,ForeignKey(TCLIENT,"cLabel",strtoul(field[9],NULL,10)) ,ForeignKey(TCLIENT,"cLabel",strtoul(field[10],NULL,10)) ,cBuf11 ,ForeignKey(TCLIENT,"cLabel",strtoul(field[12],NULL,10)) ,cBuf13 ); } printf("\n"); Footer_ism3(); }//tJobList() void CreatetJob(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tJob ( uPriority INT UNSIGNED NOT NULL DEFAULT 0, uTime INT UNSIGNED NOT NULL DEFAULT 0, cZone VARCHAR(100) NOT NULL DEFAULT '', uNSSet INT UNSIGNED NOT NULL DEFAULT 0,INDEX (uNSSet), uModDate INT UNSIGNED NOT NULL DEFAULT 0, uJob INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, cJob VARCHAR(100) NOT NULL DEFAULT '', uCreatedBy INT UNSIGNED NOT NULL DEFAULT 0, uCreatedDate INT UNSIGNED NOT NULL DEFAULT 0, uModBy INT UNSIGNED NOT NULL DEFAULT 0, uOwner INT UNSIGNED NOT NULL DEFAULT 0,INDEX (uOwner), cTargetServer VARCHAR(100) NOT NULL DEFAULT '', uMasterJob INT UNSIGNED NOT NULL DEFAULT 0, cJobData VARCHAR(100) NOT NULL DEFAULT '' )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetJob()