summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/assess.h6
-rw-r--r--include/bbs.h1
-rw-r--r--include/proto.h7
-rw-r--r--include/pttstruct.h19
-rw-r--r--mbbsd/Makefile4
-rw-r--r--mbbsd/assess.c55
-rw-r--r--mbbsd/bbs.c50
-rw-r--r--util/cleanshm.c25
8 files changed, 147 insertions, 20 deletions
diff --git a/include/assess.h b/include/assess.h
new file mode 100644
index 00000000..f6963370
--- /dev/null
+++ b/include/assess.h
@@ -0,0 +1,6 @@
+#define SALE_MAXVALUE 255
+
+#define GOODPOST 1
+#define BADPOST 2
+#define GOODSALE 3
+#define BADSALE 4
diff --git a/include/bbs.h b/include/bbs.h
index 666d30c7..55291091 100644
--- a/include/bbs.h
+++ b/include/bbs.h
@@ -63,6 +63,7 @@
#include "chc.h"
#include "proto.h"
#include "gomo.h"
+#include "assess.h"
#ifdef _UTIL_C_
#include "util.h"
diff --git a/include/proto.h b/include/proto.h
index 41fa2a7f..1ca98489 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -34,6 +34,13 @@ void BlogMain(int);
void initsetproctitle(int argc, char **argv, char **envp);
void setproctitle(const char* format, ...) GCC_CHECK_FORMAT(1,2);
+/* assess */
+void inc_goodpost(int uid);
+void inc_badpost(int uid);
+void inc_goodsale(int uid);
+void inc_badsale(int uid);
+void set_assess(int uid, unsigned char num, int type);
+
/* bbcall */
int main_bbcall();
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 5ec26a57..45cf1aab 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -3,6 +3,9 @@
#define INCLUDE_STRUCT_H
#define IDLEN 12 /* Length of bid/uid */
+
+/* 競標資訊 */
+#define SALE_COMMENTED 0x1
typedef struct bid_t {
int high;
int buyitnow;
@@ -10,7 +13,9 @@ typedef struct bid_t {
int increment;
char userid[IDLEN + 1];
time_t enddate;
- int payby; /* 1 cash 2 check or mail 4 wire 8 credit 16 postoffice */
+ char payby; /* 1 cash 2 check or mail 4 wire 8 credit 16 postoffice */
+ char flag;
+ char pad[2];
int shipping;
}bid_t;
@@ -87,7 +92,13 @@ typedef struct userec_t {
char ident[11];
unsigned int uflag2;
unsigned char signature;
- char pad[71];
+
+ unsigned char goodpost; /* 評價為好文章數 */
+ unsigned char badpost; /* 評價為壞文章數 */
+ unsigned char goodsale; /* 競標 好的評價 */
+ unsigned char badsale; /* 競標 壞的評價 */
+
+ char pad[67];
} userec_t;
/* these are flags in userec_t.uflag */
#define PAGER_FLAG 0x4 /* true if pager was OFF last session */
@@ -244,11 +255,15 @@ typedef struct userinfo_t {
int friend_online[MAX_FRIEND];/* point到線上好友 utmpshm的位置 */
/* 好友比較的cache 前兩個bit是狀態 */
int reject[MAX_REJECT];
+
int idoffset; /* shm id上的 offset */
+ /* idoffset 好像沒用到 */
+
int lock;
int friendtotal; /* 好友比較的cache 大小 */
unsigned char msgcount;
msgque_t msgs[MAX_MSGS];
+ // uptime 好像沒用到
time_t uptime;
time_t lastact; /* 上次使用者動的時間 */
unsigned int brc_id;
diff --git a/mbbsd/Makefile b/mbbsd/Makefile
index e6a9adbd..b1bb69d6 100644
--- a/mbbsd/Makefile
+++ b/mbbsd/Makefile
@@ -8,8 +8,8 @@ LDFLAGS+= -L/usr/local/lib/mysql -lmysqlclient
.endif
PROG= mbbsd
-OBJS= admin.o announce.o args.o bbs.o board.o cache.o cal.o card.o\
- chat.o chc.o chicken.o dark.o\
+OBJS= admin.o announce.o args.o assess.o bbs.o board.o cache.o cal.o\
+ card.o chat.o chc.o chicken.o dark.o\
edit.o friend.o gamble.o gomo.o guess.o indict.o io.o\
kaede.o lovepaper.o mail.o mbbsd.o menu.o more.o name.o osdep.o\
othello.o page.o read.o record.o register.o screen.o stuff.o\
diff --git a/mbbsd/assess.c b/mbbsd/assess.c
new file mode 100644
index 00000000..cc5e84b1
--- /dev/null
+++ b/mbbsd/assess.c
@@ -0,0 +1,55 @@
+#include "bbs.h"
+
+inline static void inc(unsigned char *num)
+{
+ if (*num < SALE_MAXVALUE)
+ (*num)++;
+}
+
+void inc_goodpost(int uid)
+{
+ passwd_query(uid, &xuser);
+ inc(&xuser.goodpost);
+ passwd_update(uid, &xuser);
+}
+
+void inc_badpost(int uid)
+{
+ passwd_query(uid, &xuser);
+ inc(&xuser.badpost);
+ passwd_update(uid, &xuser);
+}
+
+void inc_goodsale(int uid)
+{
+ passwd_query(uid, &xuser);
+ inc(&xuser.goodsale);
+ passwd_update(uid, &xuser);
+}
+
+void inc_badsale(int uid)
+{
+ passwd_query(uid, &xuser);
+ inc(&xuser.badsale);
+ passwd_update(uid, &xuser);
+}
+
+void set_assess(int uid, unsigned char num, int type)
+{
+ passwd_query(uid, &xuser);
+ switch (type){
+ case GOODPOST:
+ xuser.goodpost = num;
+ break;
+ case BADPOST:
+ xuser.badpost = num;
+ break;
+ case GOODSALE:
+ xuser.goodsale = num;
+ break;
+ case BADSALE:
+ xuser.badsale = num;
+ break;
+ }
+ passwd_update(uid, &xuser);
+}
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index d8289d7f..fa78a7d6 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1404,19 +1404,33 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
print_bidinfo(0, bidinfo);
if(!bidinfo.payby) money="Ptt$ "; else money=" NT$ ";
if(now>bidinfo.enddate || bidinfo.high==bidinfo.buyitnow)
- {
- prints("此競標已經結束,");
- if( bidinfo.userid[0])
- {
- /*if(!payby && bidinfo.usermax!=-1)
- {以Ptt幣自動扣款
- }*/
- prints("恭喜 %s 以 %d 得標!", bidinfo.userid,
- bidinfo.high);
- }
- else prints("無人得標!");
- pressanykey();
- return FULLUPDATE;
+ {
+ prints("此競標已經結束,");
+ if( bidinfo.userid[0]) {
+ /*if(!payby && bidinfo.usermax!=-1)
+ {以Ptt幣自動扣款
+ }*/
+ prints("恭喜 %s 以 %d 得標!", bidinfo.userid,
+ bidinfo.high);
+ if (!(bidinfo.flag & SALE_COMMENTED) && strcmp(bidinfo.userid, currutmp->userid)){
+ char tmp = getans("您對於這次交易的評價如何? 1:佳 2:欠佳 3:普通[Q]");
+ if ('1' <= tmp && tmp <= '3'){
+ switch(tmp){
+ case 1:
+ inc_goodsale(currutmp->uid);
+ break;
+ case 2:
+ inc_badpost(currutmp->uid);
+ break;
+ }
+ bidinfo.flag |= SALE_COMMENTED;
+ substitute_record(fpath, &bidinfo, sizeof(bidinfo), 1);
+ }
+ }
+ }
+ else prints("無人得標!");
+ pressanykey();
+ return FULLUPDATE;
}
if(bidinfo.userid[0])
{
@@ -1531,9 +1545,9 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
return FULLUPDATE;
}
- if( fhdr->filemode & FILE_BID)
- return do_bid(ent, fhdr, bp, direct, ptime);
-
+ if( fhdr->filemode & FILE_BID){
+ return do_bid(ent, fhdr, bp, direct, ptime);
+ }
setdirpath(path, direct, fhdr->filename);
@@ -1565,6 +1579,9 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
51 - strlen(cuser.userid) - strlen(path), " ", fromhost,
ptime->tm_mon + 1, ptime->tm_mday);
do_add_recommend(direct, fhdr, ent, buf);
+ /* 每 10 次推文 加一次 goodpost */
+ if ((fhdr->filemode & FILE_MARKED) && fhdr->recommend % 10 == 0)
+ inc_goodpost(searchuser(fhdr->owner));
lastrecommend = now;
return FULLUPDATE;
}
@@ -1708,6 +1725,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
fhdr->money = hdr.money;
delete_file(genbuf, sizeof(fileheader_t), num, cmpfilename);
}
+ inc_badpost(searchuser(fhdr->owner));
cancelpost(fhdr, not_owned);
setbtotal(currbid);
diff --git a/util/cleanshm.c b/util/cleanshm.c
new file mode 100644
index 00000000..37eb4018
--- /dev/null
+++ b/util/cleanshm.c
@@ -0,0 +1,25 @@
+/* $Id: toplazyBM.c 1096 2003-08-15 06:13:29Z victor $ */
+#define _UTIL_C_
+#include "bbs.h"
+
+extern userec_t xuser;
+
+/* 當資料欄位有異動 例如用了舊的欄位 可用這個程式清除舊值 */
+int clean_unused_var(userec_t *rec)
+{
+ rec->goodpost = 0;
+ rec->badpost = 0;
+ rec->goodsale = 0;
+ rec->badsale = 0;
+ memset(pad, 0, sizeof(pad));
+}
+
+int main(int argc, char *argv[])
+{
+ attach_SHM();
+ if(passwd_init())
+ exit(1);
+ if (passwd_apply(clean_unused_var) == 0)
+ printf("ERROR\n");
+ return 0;
+}