/* FILE tLog 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 tlogfunc.h while RAD is still to be used. */ #include "mysqlrad.h" //Table Variables //Table Variables //uLog: Primary Key static unsigned uLog=0; //cLabel: Short label static char cLabel[65]={""}; //uLogType: Log Type static unsigned uLogType=0; static char cuLogTypePullDown[256]={""}; //cHash: Security hash to complicate tampering static char cHash[33]={""}; //uPermLevel: User Perm Level static unsigned uPermLevel=0; //uLoginClient: Client Number static unsigned uLoginClient=0; //cLogin: Login name static char cLogin[33]={""}; //cHost: Ip Address static char cHost[33]={""}; //uTablePK: Primar Key of the Table static char uTablePK[33]={""}; //cTableName: Name of the Table static char cTableName[33]={""}; //cMessage: Message text static char cMessage[256]={""}; //cServer: Server name static char cServer[65]={""}; //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_tLog "tLog.uLog,tLog.cLabel,tLog.uLogType,tLog.cHash,tLog.uPermLevel,tLog.uLoginClient,tLog.cLogin,tLog.cHost,tLog.uTablePK,tLog.cTableName,tLog.cMessage,tLog.cServer,tLog.uOwner,tLog.uCreatedBy,tLog.uCreatedDate,tLog.uModBy,tLog.uModDate" //Local only void Insert_tLog(void); void Update_tLog(char *cRowid); void ProcesstLogListVars(pentry entries[], int x); //In tLogfunc.h file included below void ExtProcesstLogVars(pentry entries[], int x); void ExttLogCommands(pentry entries[], int x); void ExttLogButtons(void); void ExttLogNavBar(void); void ExttLogGetHook(entry gentries[], int x); void ExttLogSelect(void); void ExttLogSelectRow(void); void ExttLogListSelect(void); void ExttLogListFilter(void); void ExttLogAuxTable(void); #include "tlogfunc.h" //Table Variables Assignment Function void ProcesstLogVars(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(""); ExttLogButtons(); printf(""); // OpenFieldSet("tLog Record Data",100); if(guMode==2000 || guMode==2002) tLogInput(1); else tLogInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttLogAuxTable(); Footer_ism3(); }//end of tLog(); void tLogInput(unsigned uMode) { //uLog OpenRow(LANG_FL_tLog_uLog,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uLog); } //cLabel OpenRow(LANG_FL_tLog_cLabel,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cLabel)); } //uLogType OpenRow(LANG_FL_tLog_uLogType,"black"); if(guPermLevel>=7 && uMode) tTablePullDown("tLogType;cuLogTypePullDown","cLabel","cLabel",uLogType,1); else tTablePullDown("tLogType;cuLogTypePullDown","cLabel","cLabel",uLogType,0); //cHash OpenRow(LANG_FL_tLog_cHash,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cHash)); } //uPermLevel OpenRow(LANG_FL_tLog_uPermLevel,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uPermLevel); } //uLoginClient OpenRow(LANG_FL_tLog_uLoginClient,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uLoginClient); } //cLogin OpenRow(LANG_FL_tLog_cLogin,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cLogin)); } //cHost OpenRow(LANG_FL_tLog_cHost,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cHost)); } //uTablePK OpenRow(LANG_FL_tLog_uTablePK,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(uTablePK)); } //cTableName OpenRow(LANG_FL_tLog_cTableName,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cTableName)); } //cMessage OpenRow(LANG_FL_tLog_cMessage,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cMessage)); } //cServer OpenRow(LANG_FL_tLog_cServer,"black"); printf("=7 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cServer)); } //uOwner OpenRow(LANG_FL_tLog_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_tLog_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_tLog_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tLog_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_tLog_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tLogInput(unsigned uMode) void NewtLog(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uLog FROM tLog\ WHERE uLog=%u" ,uLog); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); i=mysql_num_rows(res); if(i) //tLog("Record already exists"); tLog(LANG_NBR_RECEXISTS); //insert query Insert_tLog(); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(gcQuery,"New record %u added"); uLog=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tLog",uLog); iDNSLog(uLog,"tLog","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uLog); tLog(gcQuery); } }//NewtLog(unsigned uMode) void DeletetLog(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tLog WHERE uLog=%u AND ( uOwner=%u OR %u>9 )" ,uLog,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tLog WHERE uLog=%u" ,uLog); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //tLog("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uLog,"tLog","Del"); #endif tLog(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uLog,"tLog","DelError"); #endif tLog(LANG_NBR_RECNOTDELETED); } }//void DeletetLog(void) void Insert_tLog(void) { //insert query sprintf(gcQuery,"INSERT INTO tLog SET uLog=%u,cLabel='%s',uLogType=%u,cHash='%s',uPermLevel=%u,uLoginClient=%u,cLogin='%s',cHost='%s',uTablePK='%s',cTableName='%s',cMessage='%s',cServer='%s',uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", uLog ,TextAreaSave(cLabel) ,uLogType ,TextAreaSave(cHash) ,uPermLevel ,uLoginClient ,TextAreaSave(cLogin) ,TextAreaSave(cHost) ,TextAreaSave(uTablePK) ,TextAreaSave(cTableName) ,TextAreaSave(cMessage) ,TextAreaSave(cServer) ,uOwner ,uCreatedBy ); mysql_query(&gMysql,gcQuery); }//void Insert_tLog(void) void Update_tLog(char *cRowid) { //update query sprintf(gcQuery,"UPDATE tLog SET uLog=%u,cLabel='%s',uLogType=%u,cHash='%s',uPermLevel=%u,uLoginClient=%u,cLogin='%s',cHost='%s',uTablePK='%s',cTableName='%s',cMessage='%s',cServer='%s',uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", uLog ,TextAreaSave(cLabel) ,uLogType ,TextAreaSave(cHash) ,uPermLevel ,uLoginClient ,TextAreaSave(cLogin) ,TextAreaSave(cHost) ,TextAreaSave(uTablePK) ,TextAreaSave(cTableName) ,TextAreaSave(cMessage) ,TextAreaSave(cServer) ,uModBy ,cRowid); mysql_query(&gMysql,gcQuery); }//void Update_tLog(void) void ModtLog(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; #ifdef ISM3FIELDS unsigned uPreModDate=0; sprintf(gcQuery,"SELECT uLog,uModDate FROM tLog WHERE uLog=%u" ,uLog); #else sprintf(gcQuery,"SELECT uLog FROM tLog WHERE uLog=%u" ,uLog); #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) tLog("Record does not exist"); if(i<1) tLog(LANG_NBR_RECNOTEXIST); //if(i>1) tLog("Multiple rows!"); if(i>1) tLog(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tLog(LANG_NBR_EXTMOD); #endif Update_tLog(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("tLog",uLog); iDNSLog(uLog,"tLog","Mod"); #endif tLog(gcQuery); }//ModtLog(void) void tLogList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttLogListSelect(); mysql_query(&gMysql,gcQuery); if(mysql_error(&gMysql)[0]) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); guI=mysql_num_rows(res); PageMachine("tLogList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttLogListFilter(); 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("
uLogcLabeluLogTypecHashuPermLeveluLoginClientcLogincHostuTablePKcTableNamecMessagecServeruOwneruCreatedByuCreatedDateuModByuModDate
End of data
"); Footer_ism3(); } if(guN % 2) printf(""); else printf(""); long luTime14=strtoul(field[14],NULL,10); char cBuf14[32]; if(luTime14) ctime_r(&luTime14,cBuf14); else sprintf(cBuf14,"---"); long luTime16=strtoul(field[16],NULL,10); char cBuf16[32]; if(luTime16) ctime_r(&luTime16,cBuf16); else sprintf(cBuf16,"---"); printf(" %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s" ,field[0] ,field[0] ,field[1] ,ForeignKey("tLogType","cLabel",strtoul(field[2],NULL,10)) ,field[3] ,field[4] ,field[5] ,field[6] ,field[7] ,field[8] ,field[9] ,field[10] ,field[11] ,ForeignKey(TCLIENT,"cLabel",strtoul(field[12],NULL,10)) ,ForeignKey(TCLIENT,"cLabel",strtoul(field[13],NULL,10)) ,cBuf14 ,ForeignKey(TCLIENT,"cLabel",strtoul(field[15],NULL,10)) ,cBuf16 ); } printf("\n"); Footer_ism3(); }//tLogList() void CreatetLog(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tLog ( uTablePK VARCHAR(32) NOT NULL DEFAULT '', cHost VARCHAR(32) NOT NULL DEFAULT '', uLoginClient INT UNSIGNED NOT NULL DEFAULT 0, cLogin VARCHAR(32) NOT NULL DEFAULT '', uPermLevel INT UNSIGNED NOT NULL DEFAULT 0, cTableName VARCHAR(32) NOT NULL DEFAULT '', uLog INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, cLabel VARCHAR(64) 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, cHash VARCHAR(32) NOT NULL DEFAULT '', uLogType INT UNSIGNED NOT NULL DEFAULT 0,index (uLogType), cMessage VARCHAR(255) NOT NULL DEFAULT '', cServer VARCHAR(64) NOT NULL DEFAULT '' )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetLog()