/* FILE tUser source code of mysqlSendmail.cgi (built by mysqlRAD2.cgi (c) Gary Wallis 2001,2002 GPL Licensed) $Id: tuser.c 6 2005-11-24 00:02:59Z ggw $ (tAuthorize.cPasswd template set member) PURPOSE */ #include "mysqlrad.h" //Table Variables //uUser: Primary Key static unsigned uUser=0; //cLogin: Pop3 user login static char cLogin[33]={""}; //cEnterPasswd: New pop3 user password static char cEnterPasswd[17]={""}; //cPasswd: Pop3 user password unix encrypted NEW md5 or DES static char cPasswd[65]={""}; //uServer: Server account is on static unsigned uServer=0; static char cuServerPullDown[256]={""}; //uAPop: Allow APOP static unsigned uAPop=0; static char cYesNouAPop[32]={""}; //uHDQuota: HD quota preset static unsigned uHDQuota=0; static char cuHDQuotaPullDown[256]={""}; //uTrafficQuota: Traffic quota preset static unsigned uTrafficQuota=0; static char cuTrafficQuotaPullDown[256]={""}; //uMailFilter: Mail filter static unsigned uMailFilter=0; static char cuMailFilterPullDown[256]={""}; //uStatus: Status of user static unsigned uStatus=0; static char cuStatusPullDown[256]={""}; //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 unsigned uCreatedDate=0; //uModBy: uClient for last update static unsigned uModBy=0; //uModDate: Unix seconds date last update static long unsigned uModDate=0; #define VAR_LIST_tUser "tUser.uUser,tUser.cLogin,tUser.cEnterPasswd,tUser.cPasswd,tUser.uServer,tUser.uAPop,tUser.uHDQuota,tUser.uTrafficQuota,tUser.uMailFilter,tUser.uStatus,tUser.uOwner,tUser.uCreatedBy,tUser.uCreatedDate,tUser.uModBy,tUser.uModDate" //Local only void Insert_tUser(void); void Update_tUser(char *rowid); int InsertUpdate_tUser(char *cKey); void ProcesstUserListVars(pentry entries[], int x); //In tUserfunc.h file included below void ExtProcesstUserVars(pentry entries[], int x); void ExttUserCommands(pentry entries[], int x); void ExttUserButtons(void); void ExttUserNavBar(void); void ExttUserGetHook(entry gentries[], int x); void ExttUserSelect(void); void ExttUserSelectRow(void); void ExttUserListSelect(void); void ExttUserListFilter(void); void ExttUserAuxTable(void); #include "tuserfunc.h" //Table Variables Assignment Function void ProcesstUserVars(pentry entries[], int x) { register int i; for(i=0;i\n"); printf("\n"); printf(""); printf("
"); ExttUserNavBar(); printf(""); printf("",rowid); if(i) { printf(" "); if(mode==6) //printf(" Found"); printf(LANG_NBR_FOUND); else if(mode==5) //printf(" Modified"); printf(LANG_NBR_MODIFIED); else if(mode==4) //printf(" New"); printf(LANG_NBR_NEW); printf(LANG_NBRF_SHOWING,rowid,i); } else { if(!result[0]) //printf(" No records found"); printf(LANG_NBR_NORECS); } if(result[0]) printf(" %s",result); printf("
"); ExttUserButtons(); printf(""); printf("\n"); if(mode==2000 || mode==2002) tUserInputContent(); else tUserContent(); printf("
\n"); printf("
\n"); //Bottom table ExttUserAuxTable(); printf("\n"); Footer_ism3(); }//end of tUser(); void tUserContent(void) { OpenRow(LANG_FL_tUser_uUser,"white"); printf("%u\n",uUser,uUser); printf("  "); OpenRow(LANG_FL_tUser_cLogin,EmptyString(cLogin)); printf("%s",cLogin,EncodeDoubleQuotes(cLogin)); printf("  "); OpenRow(LANG_FL_tUser_cEnterPasswd,"white"); printf("%s",cEnterPasswd,EncodeDoubleQuotes(cEnterPasswd)); printf("  "); OpenRow(LANG_FL_tUser_cPasswd,"white"); printf("%s",cPasswd,EncodeDoubleQuotes(cPasswd)); printf("  "); OpenRow(LANG_FL_tUser_uServer,IsZero(uServer)); tTablePullDownReadOnly("tServer;cuServerPullDown","cLabel","cLabel",uServer); printf("  "); OpenRow(LANG_FL_tUser_uAPop,"white"); YesNo(uAPop); printf("",uAPop); printf("  "); OpenRow(LANG_FL_tUser_uHDQuota,"white"); tTablePullDownReadOnly("tHDQuota;cuHDQuotaPullDown","cLabel","cLabel",uHDQuota); printf("  "); OpenRow(LANG_FL_tUser_uTrafficQuota,"white"); tTablePullDownReadOnly("tTrafficQuota;cuTrafficQuotaPullDown","cLabel","cLabel",uTrafficQuota); printf("  "); OpenRow(LANG_FL_tUser_uMailFilter,"white"); tTablePullDownReadOnly("tMailFilter;cuMailFilterPullDown","cLabel","cLabel",uMailFilter); printf("  "); OpenRow(LANG_FL_tUser_uStatus,IsZero(uStatus)); tTablePullDownReadOnly("tStatus;cuStatusPullDown","cLabel","cLabel",uStatus); printf("  "); OpenRow(LANG_FL_tUser_uOwner,"white"); printf("%s\n",ForeignKey("tClient","cLabel",uOwner),uOwner); printf("  "); OpenRow(LANG_FL_tUser_uCreatedBy,"white"); printf("%s\n",ForeignKey("tClient","cLabel",uCreatedBy),uCreatedBy); printf("  "); OpenRow(LANG_FL_tUser_uCreatedDate,"white"); if(uCreatedDate) printf("%s\n\n",ctime((time_t *)&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); printf("  "); OpenRow(LANG_FL_tUser_uModBy,"white"); printf("%s\n",ForeignKey("tClient","cLabel",uModBy),uModBy); printf("  "); OpenRow(LANG_FL_tUser_uModDate,"white"); if(uModDate) printf("%s\n\n",ctime((time_t *)&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("  "); printf("\n"); }//tUserContent() void tUserInputContent(void) { OpenRow(LANG_FL_tUser_uUser,"white"); if(uPermLevel>=20) printf("\n",LANG_FT_tUser_uUser,uUser); else printf("%u\n",uUser,uUser); OpenRow(LANG_FL_tUser_cLogin,EmptyString(cLogin)); if(uPermLevel>9 || (mode==2000 && uPermLevel>6) ) printf("\n",LANG_FT_tUser_cLogin,EncodeDoubleQuotes(cLogin)); else printf("%s",cLogin,EncodeDoubleQuotes(cLogin)); OpenRow(LANG_FL_tUser_cEnterPasswd,"white"); if(uPermLevel>=5) printf("\n",LANG_FT_tUser_cEnterPasswd,EncodeDoubleQuotes(cEnterPasswd)); else printf("%s",cEnterPasswd,EncodeDoubleQuotes(cEnterPasswd)); OpenRow(LANG_FL_tUser_cPasswd,"white"); if(uPermLevel>=12) printf("\n",LANG_FT_tUser_cPasswd,EncodeDoubleQuotes(cPasswd)); else printf("%s",cPasswd,EncodeDoubleQuotes(cPasswd)); OpenRow(LANG_FL_tUser_uServer,IsZero(uServer)); if(uPermLevel>=8) tTablePullDown("tServer;cuServerPullDown","cLabel","cLabel",uServer); else { tTablePullDownReadOnly("tServer;cuServerPullDown","cLabel","cLabel",uServer); } OpenRow(LANG_FL_tUser_uAPop,"white"); if(uPermLevel>=8) YesNoPullDown("uAPop",uAPop); else { YesNo(uAPop); printf("",uAPop); } OpenRow(LANG_FL_tUser_uHDQuota,"white"); if(uPermLevel>=8) tTablePullDown("tHDQuota;cuHDQuotaPullDown","cLabel","cLabel",uHDQuota); else { tTablePullDownReadOnly("tHDQuota;cuHDQuotaPullDown","cLabel","cLabel",uHDQuota); } OpenRow(LANG_FL_tUser_uTrafficQuota,"white"); if(uPermLevel>=8) tTablePullDown("tTrafficQuota;cuTrafficQuotaPullDown","cLabel","cLabel",uTrafficQuota); else { tTablePullDownReadOnly("tTrafficQuota;cuTrafficQuotaPullDown","cLabel","cLabel",uTrafficQuota); } OpenRow(LANG_FL_tUser_uMailFilter,"white"); if(uPermLevel>=8) tTablePullDown("tMailFilter;cuMailFilterPullDown","cLabel","cLabel",uMailFilter); else { tTablePullDownReadOnly("tMailFilter;cuMailFilterPullDown","cLabel","cLabel",uMailFilter); } OpenRow(LANG_FL_tUser_uStatus,IsZero(uStatus)); if(uPermLevel>=12) tTablePullDown("tStatus;cuStatusPullDown","cLabel","cLabel",uStatus); else { tTablePullDownReadOnly("tStatus;cuStatusPullDown","cLabel","cLabel",uStatus); } OpenRow(LANG_FL_tUser_uOwner,"white"); printf("%s\n",ForeignKey("tClient","cLabel",uOwner),uOwner); OpenRow(LANG_FL_tUser_uCreatedBy,"white"); printf("%s\n",ForeignKey("tClient","cLabel",uCreatedBy),uCreatedBy); OpenRow(LANG_FL_tUser_uCreatedDate,"white"); if(uCreatedDate) printf("%s\n\n",ctime((time_t *)&uCreatedDate)); else printf("---\n\n"); printf("\n",uCreatedDate); OpenRow(LANG_FL_tUser_uModBy,"white"); printf("%s\n",ForeignKey("tClient","cLabel",uModBy),uModBy); OpenRow(LANG_FL_tUser_uModDate,"white"); if(uModDate) printf("%s\n\n",ctime((time_t *)&uModDate)); else printf("---\n\n"); printf("\n",uModDate); printf("\n"); }//void tUserInputContent(void) void NewtUser(unsigned uMode) { register int i=0; MYSQL_RES *res; //New select sprintf(query,"SELECT uUser FROM tUser\ WHERE uUser=%u" ,uUser); mysql_query(&mysql,query); if(mysql_errno(&mysql)) mysqlSendmail(mysql_error(&mysql)); res=mysql_store_result(&mysql); i=mysql_num_rows(res); if(i) //tUser("Record already exists"); tUser(LANG_NBR_RECEXISTS); //insert query Insert_tUser(); if(mysql_errno(&mysql)) mysqlSendmail(mysql_error(&mysql)); //sprintf(query,"New record %u added"); uUser=mysql_insert_id(&mysql); if(!uMode) { sprintf(query,LANG_NBR_NEWRECADDED,uUser); tUser(query); } }//NewtUser(unsigned uMode) void DeletetUser(void) { #ifdef ISM3FIELDS sprintf(query,"DELETE FROM tUser WHERE uUser=%u AND ( uOwner=%u OR %u>9 )" ,uUser,uLoginClient,uPermLevel); #else sprintf(query,"DELETE FROM tUser WHERE uUser=%u" ,uUser); #endif mysql_query(&mysql,query); if(mysql_errno(&mysql)) mysqlSendmail(mysql_error(&mysql)); //tUser("Record Deleted"); if(mysql_affected_rows(&mysql)>0) tUser(LANG_NBR_RECDELETED); else tUser(LANG_NBR_RECNOTDELETED); }//void DeletetUser(void) void Insert_tUser(void) { #ifdef ISM3FIELDS time_t clock; time(&clock); #endif //insert query //insert query sprintf(query,"INSERT INTO tUser SET uUser=%u, cLogin='%s', cEnterPasswd='%s', cPasswd='%s', uServer=%u, uAPop=%u, uHDQuota=%u, uTrafficQuota=%u, uMailFilter=%u, uStatus=%u, uOwner=%u, uCreatedBy=%u, uCreatedDate=%lu, uModBy=%u, uModDate=0", uUser ,TextAreaSave(cLogin) ,TextAreaSave(cEnterPasswd) ,TextAreaSave(cPasswd) ,uServer ,uAPop ,uHDQuota ,uTrafficQuota ,uMailFilter ,uStatus ,uOwner ,uCreatedBy ,(long unsigned)clock ,uModBy ); mysql_query(&mysql,query); #ifdef ISM3FIELDS uCreatedDate=clock; #endif }//void Insert_tUser(void) void Update_tUser(char *rowid) { #ifdef ISM3FIELDS time_t clock; time(&clock); #endif //update query //update query sprintf(query,"UPDATE tUser SET uUser=%u,cLogin='%s',cEnterPasswd='%s',cPasswd='%s',uServer=%u,uAPop=%u,uHDQuota=%u,uTrafficQuota=%u,uMailFilter=%u,uStatus=%u,uModBy=%u,uModDate=%lu WHERE _rowid=%s", uUser ,TextAreaSave(cLogin) ,TextAreaSave(cEnterPasswd) ,TextAreaSave(cPasswd) ,uServer ,uAPop ,uHDQuota ,uTrafficQuota ,uMailFilter ,uStatus ,uModBy ,(long unsigned)clock ,rowid); mysql_query(&mysql,query); #ifdef ISM3FIELDS uModDate=clock; #endif }//void Update_tUser(void) void ModtUser(void) { register int i=0; MYSQL_RES *res; MYSQL_ROW field; unsigned uPreModDate=0; //Mod select query if(uPermLevel==5) sprintf(query,"SELECT uUser,uModDate FROM tUser WHERE cLogin='%s'",cUser); else if(uPermLevel<10) sprintf(query,"SELECT tUser.uUser,\ tUser.uModDate\ FROM tUser,tClient\ WHERE tUser.uUser=%u\ AND tUser.uOwner=tClient.uClient\ AND (tClient.uOwner=%u OR tClient.uClient=%u)" ,uUser,uLoginClient,uLoginClient); else if(1) sprintf(query,"SELECT uUser,uModDate FROM tUser WHERE uUser=%u",uUser); mysql_query(&mysql,query); if(mysql_errno(&mysql)) mysqlSendmail(mysql_error(&mysql)); res=mysql_store_result(&mysql); i=mysql_num_rows(res); //if(i<1) tUser("Record does not exist"); if(i<1) tUser(LANG_NBR_RECNOTEXIST); //if(i>1) tUser("Multiple rows!"); if(i>1) tUser(LANG_NBR_MULTRECS); field=mysql_fetch_row(res); sscanf(field[1],"%u",&uPreModDate); if(uPreModDate!=uModDate) tUser(LANG_NBR_EXTMOD); Update_tUser(field[0]); if(mysql_errno(&mysql)) mysqlSendmail(mysql_error(&mysql)); //sprintf(query,"record %s modified",field[0]); sprintf(query,LANG_NBRF_REC_MODIFIED,field[0]); tUser(query); }//ModtUser(void) void tUserList(void) { MYSQL_RES *res; MYSQL_ROW field; ExttUserListSelect(); mysql_query(&mysql,query); if(mysql_error(&mysql)[0]) mysqlSendmail(mysql_error(&mysql)); res=mysql_store_result(&mysql); i=mysql_num_rows(res); PageMachine("tUserList",1,"");//1 is auto header list mode. Opens table! //Filter select drop down ExttUserListFilter(); printf("",command); printf("\n"); printf("\n"); printf(""); mysql_data_seek(res,start-1); for(n=0;n<(end-start+1);n++) { field=mysql_fetch_row(res); if(!field) { printf("
uUsercLogincEnterPasswdcPasswduServeruAPopuHDQuotauTrafficQuotauMailFilteruStatusuOwneruCreatedByuCreatedDateuModByuModDate
End of data
"); Footer_ism3(); } if(n % 2) printf(""); else printf(""); 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] ,field[10] ,field[11] ,field[12] ,field[13] ,field[14] ); } printf("\n"); Footer_ism3(); }//tUserList() void CreatetUser(void) { sprintf(query,"CREATE TABLE tUser ( uUser int unsigned PRIMARY KEY AUTO_INCREMENT, cLogin varchar(32) NOT NULL DEFAULT '',unique (cLogin,uServer), 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, cPasswd varchar(64) NOT NULL DEFAULT '', uAPop int unsigned NOT NULL DEFAULT 0, uServer int unsigned NOT NULL DEFAULT 0,index (uServer), uHDQuota int unsigned NOT NULL DEFAULT 0, uTrafficQuota int unsigned NOT NULL DEFAULT 0, uMailFilter int unsigned NOT NULL DEFAULT 0, uStatus int unsigned NOT NULL DEFAULT 0, cEnterPasswd varchar(16) NOT NULL DEFAULT '' )"); mysql_query(&mysql,qstr); if(mysql_errno(&mysql)) mysqlSendmail(mysql_error(&mysql)); }//CreatetUser() //sedall patch1