/* FILE tLogType 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 tlogtypefunc.h while RAD is still to be used. */ #include "mysqlrad.h" //Table Variables //Table Variables //uLogType: Primary Key static unsigned uLogType=0; //cLabel: Short label static char cLabel[33]={""}; //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_tLogType "tLogType.uLogType,tLogType.cLabel,tLogType.uOwner,tLogType.uCreatedBy,tLogType.uCreatedDate,tLogType.uModBy,tLogType.uModDate" //Local only void Insert_tLogType(void); void Update_tLogType(char *cRowid); void ProcesstLogTypeListVars(pentry entries[], int x); //In tLogTypefunc.h file included below void ExtProcesstLogTypeVars(pentry entries[], int x); void ExttLogTypeCommands(pentry entries[], int x); void ExttLogTypeButtons(void); void ExttLogTypeNavBar(void); void ExttLogTypeGetHook(entry gentries[], int x); void ExttLogTypeSelect(void); void ExttLogTypeSelectRow(void); void ExttLogTypeListSelect(void); void ExttLogTypeListFilter(void); void ExttLogTypeAuxTable(void); #include "tlogtypefunc.h" //Table Variables Assignment Function void ProcesstLogTypeVars(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(""); ExttLogTypeButtons(); printf(""); // OpenFieldSet("tLogType Record Data",100); if(guMode==2000 || guMode==2002) tLogTypeInput(1); else tLogTypeInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttLogTypeAuxTable(); Footer_ism3(); }//end of tLogType(); void tLogTypeInput(unsigned uMode) { //uLogType OpenRow(LANG_FL_tLogType_uLogType,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uLogType); } //cLabel OpenRow(LANG_FL_tLogType_cLabel,"black"); printf("=0 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cLabel)); } //uOwner OpenRow(LANG_FL_tLogType_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_tLogType_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_tLogType_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tLogType_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_tLogType_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tLogTypeInput(unsigned uMode) void NewtLogType(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uLogType FROM tLogType\ WHERE uLogType=%u" ,uLogType); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); i=mysql_num_rows(res); if(i) //tLogType("Record already exists"); tLogType(LANG_NBR_RECEXISTS); //insert query Insert_tLogType(); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(gcQuery,"New record %u added"); uLogType=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tLogType",uLogType); iDNSLog(uLogType,"tLogType","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uLogType); tLogType(gcQuery); } }//NewtLogType(unsigned uMode) void DeletetLogType(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tLogType WHERE uLogType=%u AND ( uOwner=%u OR %u>9 )" ,uLogType,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tLogType WHERE uLogType=%u" ,uLogType); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //tLogType("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uLogType,"tLogType","Del"); #endif tLogType(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uLogType,"tLogType","DelError"); #endif tLogType(LANG_NBR_RECNOTDELETED); } }//void DeletetLogType(void) void Insert_tLogType(void) { //insert query sprintf(gcQuery,"INSERT INTO tLogType SET uLogType=%u,cLabel='%s',uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", uLogType ,TextAreaSave(cLabel) ,uOwner ,uCreatedBy ); mysql_query(&gMysql,gcQuery); }//void Insert_tLogType(void) void Update_tLogType(char *cRowid) { //update query sprintf(gcQuery,"UPDATE tLogType SET uLogType=%u,cLabel='%s',uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", uLogType ,TextAreaSave(cLabel) ,uModBy ,cRowid); mysql_query(&gMysql,gcQuery); }//void Update_tLogType(void) void ModtLogType(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; #ifdef ISM3FIELDS unsigned uPreModDate=0; sprintf(gcQuery,"SELECT uLogType,uModDate FROM tLogType WHERE uLogType=%u" ,uLogType); #else sprintf(gcQuery,"SELECT uLogType FROM tLogType WHERE uLogType=%u" ,uLogType); #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) tLogType("Record does not exist"); if(i<1) tLogType(LANG_NBR_RECNOTEXIST); //if(i>1) tLogType("Multiple rows!"); if(i>1) tLogType(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tLogType(LANG_NBR_EXTMOD); #endif Update_tLogType(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("tLogType",uLogType); iDNSLog(uLogType,"tLogType","Mod"); #endif tLogType(gcQuery); }//ModtLogType(void) void tLogTypeList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttLogTypeListSelect(); mysql_query(&gMysql,gcQuery); if(mysql_error(&gMysql)[0]) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); guI=mysql_num_rows(res); PageMachine("tLogTypeList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttLogTypeListFilter(); 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("
uLogTypecLabeluOwneruCreatedByuCreatedDateuModByuModDate
End of data
"); Footer_ism3(); } if(guN % 2) printf(""); else printf(""); long luTime4=strtoul(field[4],NULL,10); char cBuf4[32]; if(luTime4) ctime_r(&luTime4,cBuf4); else sprintf(cBuf4,"---"); long luTime6=strtoul(field[6],NULL,10); char cBuf6[32]; if(luTime6) ctime_r(&luTime6,cBuf6); else sprintf(cBuf6,"---"); printf(" %s%s%s%s%s%s%s" ,field[0] ,field[0] ,field[1] ,ForeignKey(TCLIENT,"cLabel",strtoul(field[2],NULL,10)) ,ForeignKey(TCLIENT,"cLabel",strtoul(field[3],NULL,10)) ,cBuf4 ,ForeignKey(TCLIENT,"cLabel",strtoul(field[5],NULL,10)) ,cBuf6 ); } printf("\n"); Footer_ism3(); }//tLogTypeList() void CreatetLogType(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tLogType ( uModDate INT UNSIGNED NOT NULL DEFAULT 0, uModBy INT UNSIGNED NOT NULL DEFAULT 0, uOwner INT UNSIGNED NOT NULL DEFAULT 0,index (uOwner), uCreatedBy INT UNSIGNED NOT NULL DEFAULT 0, uCreatedDate INT UNSIGNED NOT NULL DEFAULT 0, uLogType INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, cLabel VARCHAR(32) NOT NULL DEFAULT '' )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetLogType()