/* FILE tHit 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 thitfunc.h while RAD is still to be used. */ #include "mysqlrad.h" //Table Variables //Table Variables //uHit: Primary Key static unsigned uHit=0; //cZone: Zone name static char cZone[101]={""}; static char cHost[101]={""}; //uHitCount: Hit Counter static long unsigned uHitCount=0; //New fields via direct edit not RAD tool static long unsigned uSuccess=0; static long unsigned uReferral=0; static long unsigned uNxrrset=0; static long unsigned uNxdomain=0; static long unsigned uRecursion=0; static long unsigned uFailure=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_tHit "tHit.uHit,tHit.cZone,tHit.cHost,tHit.uHitCount,tHit.uSuccess,tHit.uReferral,tHit.uNxrrset,tHit.uNxdomain,tHit.uRecursion,tHit.uFailure,tHit.uOwner,tHit.uCreatedBy,tHit.uCreatedDate,tHit.uModBy,tHit.uModDate" //Local only void Insert_tHit(void); void Update_tHit(char *cRowid); void ProcesstHitListVars(pentry entries[], int x); //In tHitfunc.h file included below void ExtProcesstHitVars(pentry entries[], int x); void ExttHitCommands(pentry entries[], int x); void ExttHitButtons(void); void ExttHitNavBar(void); void ExttHitGetHook(entry gentries[], int x); void ExttHitSelect(void); void ExttHitSelectRow(void); void ExttHitListSelect(void); void ExttHitListFilter(void); void ExttHitAuxTable(void); #include "thitfunc.h" //Table Variables Assignment Function void ProcesstHitVars(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(""); ExttHitButtons(); printf(""); // OpenFieldSet("tHit Record Data",100); if(guMode==2000 || guMode==2002) tHitInput(1); else tHitInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttHitAuxTable(); Footer_ism3(); }//end of tHit(); void tHitInput(unsigned uMode) { //uHit OpenRow(LANG_FL_tHit_uHit,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uHit); } //cZone OpenRow(LANG_FL_tHit_cZone,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cZone)); } //cHost OpenRow("cHost","black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cHost)); } //uHitCount OpenRow(LANG_FL_tHit_uHitCount,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uHitCount); } //uSuccess OpenRow("uSuccess","black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uSuccess); } //uReferral OpenRow("uReferral","black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uReferral); } //uNxrrset OpenRow("uNxrrset","black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uNxrrset); } //uNxdomain OpenRow("uNxdomain","black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uNxdomain); } //uRecursion OpenRow("uRecursion","black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uRecursion); } //uFailure OpenRow("uFailure","black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uFailure); } //uOwner OpenRow(LANG_FL_tHit_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_tHit_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_tHit_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tHit_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_tHit_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tHitInput(unsigned uMode) void NewtHit(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uHit FROM tHit\ WHERE uHit=%u" ,uHit); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); i=mysql_num_rows(res); if(i) //tHit("Record already exists"); tHit(LANG_NBR_RECEXISTS); //insert query Insert_tHit(); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(gcQuery,"New record %u added"); uHit=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tHit",uHit); iDNSLog(uHit,"tHit","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uHit); tHit(gcQuery); } }//NewtHit(unsigned uMode) void DeletetHit(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tHit WHERE uHit=%u AND ( uOwner=%u OR %u>9 )" ,uHit,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tHit WHERE uHit=%u" ,uHit); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //tHit("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uHit,"tHit","Del"); #endif tHit(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uHit,"tHit","DelError"); #endif tHit(LANG_NBR_RECNOTDELETED); } }//void DeletetHit(void) void Insert_tHit(void) { sprintf(gcQuery,"INSERT INTO tHit SET uHit=%u,cZone='%s',cHost='%s',uHitCount=%lu,uSuccess=%lu,uReferral=%lu,uNxrrset=%lu,uNxdomain=%lu,uRecursion=%lu,uFailure=%lu,uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", uHit ,TextAreaSave(cZone) ,TextAreaSave(cHost) ,uHitCount ,uSuccess,uReferral,uNxrrset,uNxdomain,uRecursion,uFailure ,uOwner ,uCreatedBy ); mysql_query(&gMysql,gcQuery); }//void Insert_tHit(void) void Update_tHit(char *cRowid) { sprintf(gcQuery,"UPDATE tHit SET uHit=%u,cZone='%s',cHost='%s',uHitCount=%lu,uSuccess=%lu,uReferral=%lu,uNxrrset=%lu,uNxdomain=%lu,uRecursion=%lu,uFailure=%lu,uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", uHit ,TextAreaSave(cZone) ,TextAreaSave(cHost) ,uHitCount ,uSuccess,uReferral,uNxrrset,uNxdomain,uRecursion,uFailure ,uModBy ,cRowid); mysql_query(&gMysql,gcQuery); }//void Update_tHit(void) void ModtHit(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 tHit.uHit,\ tHit.uModDate\ FROM tHit,tClient\ WHERE tHit.uHit=%u\ AND tHit.uOwner=tClient.uClient\ AND (tClient.uOwner=%u OR tClient.uClient=%u)" ,uHit,guLoginClient,guLoginClient); else sprintf(gcQuery,"SELECT uHit,uModDate FROM tHit\ WHERE uHit=%u" ,uHit); #else sprintf(gcQuery,"SELECT uHit FROM tHit\ WHERE uHit=%u" ,uHit); #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) tHit("Record does not exist"); if(i<1) tHit(LANG_NBR_RECNOTEXIST); //if(i>1) tHit("Multiple rows!"); if(i>1) tHit(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tHit(LANG_NBR_EXTMOD); #endif Update_tHit(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("tHit",uHit); iDNSLog(uHit,"tHit","Mod"); #endif tHit(gcQuery); }//ModtHit(void) void tHitList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttHitListSelect(); mysql_query(&gMysql,gcQuery); if(mysql_error(&gMysql)[0]) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); guI=mysql_num_rows(res); PageMachine("tHitList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttHitListFilter(); 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("
uHitcZonecHostuHitCountuSuccessuReferraluNxrrsetuNxdomainuRecursionuFailureuOwneruCreatedByuCreatedDateuModByuModDate
End of data
"); Footer_ism3(); } if(guN % 2) printf(""); else printf(""); long luTime5=strtoul(field[12],NULL,10); char cBuf5[32]; if(luTime5) ctime_r(&luTime5,cBuf5); else sprintf(cBuf5,"---"); long luTime7=strtoul(field[14],NULL,10); char cBuf7[32]; if(luTime7) ctime_r(&luTime7,cBuf7); else sprintf(cBuf7,"---"); printf(" %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s" ,field[0] ,field[0] ,field[1] ,field[2] ,field[3] ,field[4] ,field[5] ,field[6] ,field[7] ,field[8] ,field[9] ,ForeignKey("tClient","cLabel",strtoul(field[10],NULL,10)) ,ForeignKey("tClient","cLabel",strtoul(field[11],NULL,10)) ,cBuf5 ,ForeignKey("tClient","cLabel",strtoul(field[13],NULL,10)) ,cBuf7 ); } printf("\n"); Footer_ism3(); }//tHitList() void CreatetHit(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tHit ( uHit INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, cZone VARCHAR(255) NOT NULL DEFAULT '',INDEX (cZone), 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, uHitCount BIGINT UNSIGNED NOT NULL DEFAULT 0, uSuccess BIGINT UNSIGNED NOT NULL DEFAULT 0, uReferral BIGINT UNSIGNED NOT NULL DEFAULT 0, uNxrrset BIGINT UNSIGNED NOT NULL DEFAULT 0, uNxdomain BIGINT UNSIGNED NOT NULL DEFAULT 0, uRecursion BIGINT UNSIGNED NOT NULL DEFAULT 0, uFailure BIGINT UNSIGNED NOT NULL DEFAULT 0, cHost VARCHAR(255) NOT NULL DEFAULT '',INDEX (cHost) )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetHit()