/* FILE tConfiguration 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 tconfigurationfunc.h while RAD is still to be used. */ #include "mysqlrad.h" //Table Variables //Table Variables //uConfiguration: Primary Key static unsigned uConfiguration=0; //cLabel: Short label static char cLabel[101]={""}; //cValue: Value of name(cLabel)/value pair static char cValue[256]={""}; //cComment: Comment about this configuration name/value pair static char *cComment={""}; //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_tConfiguration "tConfiguration.uConfiguration,tConfiguration.cLabel,tConfiguration.cValue,tConfiguration.cComment,tConfiguration.uOwner,tConfiguration.uCreatedBy,tConfiguration.uCreatedDate,tConfiguration.uModBy,tConfiguration.uModDate" //Local only void Insert_tConfiguration(void); void Update_tConfiguration(char *cRowid); void ProcesstConfigurationListVars(pentry entries[], int x); //In tConfigurationfunc.h file included below void ExtProcesstConfigurationVars(pentry entries[], int x); void ExttConfigurationCommands(pentry entries[], int x); void ExttConfigurationButtons(void); void ExttConfigurationNavBar(void); void ExttConfigurationGetHook(entry gentries[], int x); void ExttConfigurationSelect(void); void ExttConfigurationSelectRow(void); void ExttConfigurationListSelect(void); void ExttConfigurationListFilter(void); void ExttConfigurationAuxTable(void); #include "tconfigurationfunc.h" //Table Variables Assignment Function void ProcesstConfigurationVars(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(""); ExttConfigurationButtons(); printf(""); // OpenFieldSet("tConfiguration Record Data",100); if(guMode==2000 || guMode==2002) tConfigurationInput(1); else tConfigurationInput(0); // CloseFieldSet(); //Bottom table printf(""); ExttConfigurationAuxTable(); Footer_ism3(); }//end of tConfiguration(); void tConfigurationInput(unsigned uMode) { //uConfiguration OpenRow(LANG_FL_tConfiguration_uConfiguration,"black"); printf("=20 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",uConfiguration); } //cLabel OpenRow(LANG_FL_tConfiguration_cLabel,"black"); printf("=8 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cLabel)); } //cValue OpenRow(LANG_FL_tConfiguration_cValue,"black"); printf("=8 && uMode) { printf(">\n"); } else { printf("disabled>\n"); printf("\n",EncodeDoubleQuotes(cValue)); } //cComment OpenRow(LANG_FL_tConfiguration_cComment,"black"); printf("\n",cComment); } else { printf("disabled>%s\n",cComment); printf("\n",EncodeDoubleQuotes(cComment)); } //uOwner OpenRow(LANG_FL_tConfiguration_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_tConfiguration_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_tConfiguration_uCreatedDate,"black"); if(uCreatedDate) printf("%s\n\n",ctime(&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); //uModBy OpenRow(LANG_FL_tConfiguration_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_tConfiguration_uModDate,"black"); if(uModDate) printf("%s\n\n",ctime(&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tConfigurationInput(unsigned uMode) void NewtConfiguration(unsigned uMode) { register int i=0; MYSQL_RES *res; sprintf(gcQuery,"SELECT uConfiguration FROM tConfiguration\ WHERE uConfiguration=%u" ,uConfiguration); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); i=mysql_num_rows(res); if(i) //tConfiguration("Record already exists"); tConfiguration(LANG_NBR_RECEXISTS); //insert query Insert_tConfiguration(); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //sprintf(gcQuery,"New record %u added"); uConfiguration=mysql_insert_id(&gMysql); #ifdef ISM3FIELDS uCreatedDate=luGetCreatedDate("tConfiguration",uConfiguration); iDNSLog(uConfiguration,"tConfiguration","New"); #endif if(!uMode) { sprintf(gcQuery,LANG_NBR_NEWRECADDED,uConfiguration); tConfiguration(gcQuery); } }//NewtConfiguration(unsigned uMode) void DeletetConfiguration(void) { #ifdef ISM3FIELDS sprintf(gcQuery,"DELETE FROM tConfiguration WHERE uConfiguration=%u AND ( uOwner=%u OR %u>9 )" ,uConfiguration,guLoginClient,guPermLevel); #else sprintf(gcQuery,"DELETE FROM tConfiguration WHERE uConfiguration=%u" ,uConfiguration); #endif mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); //tConfiguration("Record Deleted"); if(mysql_affected_rows(&gMysql)>0) { #ifdef ISM3FIELDS iDNSLog(uConfiguration,"tConfiguration","Del"); #endif tConfiguration(LANG_NBR_RECDELETED); } else { #ifdef ISM3FIELDS iDNSLog(uConfiguration,"tConfiguration","DelError"); #endif tConfiguration(LANG_NBR_RECNOTDELETED); } }//void DeletetConfiguration(void) void Insert_tConfiguration(void) { //insert query sprintf(gcQuery,"INSERT INTO tConfiguration SET uConfiguration=%u,cLabel='%s',cValue='%s',cComment='%s',uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", uConfiguration ,TextAreaSave(cLabel) ,TextAreaSave(cValue) ,TextAreaSave(cComment) ,uOwner ,uCreatedBy ); mysql_query(&gMysql,gcQuery); }//void Insert_tConfiguration(void) void Update_tConfiguration(char *cRowid) { //update query sprintf(gcQuery,"UPDATE tConfiguration SET uConfiguration=%u,cLabel='%s',cValue='%s',cComment='%s',uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", uConfiguration ,TextAreaSave(cLabel) ,TextAreaSave(cValue) ,TextAreaSave(cComment) ,uModBy ,cRowid); mysql_query(&gMysql,gcQuery); }//void Update_tConfiguration(void) void ModtConfiguration(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; #ifdef ISM3FIELDS unsigned uPreModDate=0; sprintf(gcQuery,"SELECT uConfiguration,uModDate FROM tConfiguration WHERE uConfiguration=%u" ,uConfiguration); #else sprintf(gcQuery,"SELECT uConfiguration FROM tConfiguration WHERE uConfiguration=%u" ,uConfiguration); #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) tConfiguration("Record does not exist"); if(i<1) tConfiguration(LANG_NBR_RECNOTEXIST); //if(i>1) tConfiguration("Multiple rows!"); if(i>1) tConfiguration(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); #ifdef ISM3FIELDS sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tConfiguration(LANG_NBR_EXTMOD); #endif Update_tConfiguration(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("tConfiguration",uConfiguration); iDNSLog(uConfiguration,"tConfiguration","Mod"); #endif tConfiguration(gcQuery); }//ModtConfiguration(void) void tConfigurationList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttConfigurationListSelect(); mysql_query(&gMysql,gcQuery); if(mysql_error(&gMysql)[0]) htmlPlainTextError(mysql_error(&gMysql)); res=mysql_store_result(&gMysql); guI=mysql_num_rows(res); PageMachine("tConfigurationList",1,"");//1 is auto header list guMode. Opens table! //Filter select drop down ExttConfigurationListFilter(); 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("
uConfigurationcLabelcValuecCommentuOwneruCreatedByuCreatedDateuModByuModDate
End of data
"); Footer_ism3(); } if(guN % 2) printf(""); else printf(""); long luTime6=strtoul(field[6],NULL,10); char cBuf6[32]; if(luTime6) ctime_r(&luTime6,cBuf6); else sprintf(cBuf6,"---"); long luTime8=strtoul(field[8],NULL,10); char cBuf8[32]; if(luTime8) ctime_r(&luTime8,cBuf8); else sprintf(cBuf8,"---"); printf(" %s%s%s%s%s%s%s%s" ,field[0] ,field[0] ,field[1] ,field[2] ,field[3] ,ForeignKey(TCLIENT,"cLabel",strtoul(field[4],NULL,10)) ,ForeignKey(TCLIENT,"cLabel",strtoul(field[5],NULL,10)) ,cBuf6 ,ForeignKey(TCLIENT,"cLabel",strtoul(field[7],NULL,10)) ,cBuf8 ); } printf("\n"); Footer_ism3(); }//tConfigurationList() void CreatetConfiguration(void) { sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tConfiguration ( uModBy INT UNSIGNED NOT NULL DEFAULT 0, uCreatedDate INT UNSIGNED NOT NULL DEFAULT 0, uCreatedBy INT UNSIGNED NOT NULL DEFAULT 0, cLabel VARCHAR(100) NOT NULL DEFAULT '', UNIQUE (cLabel), uConfiguration INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, cComment TEXT NOT NULL DEFAULT '', uOwner INT UNSIGNED NOT NULL DEFAULT 0,index (uOwner), uModDate INT UNSIGNED NOT NULL DEFAULT 0, cValue VARCHAR(255) NOT NULL DEFAULT '' )"); mysql_query(&gMysql,gcQuery); if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); }//CreatetConfiguration()