summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-06-10 10:13:36 +0800
committerwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-06-10 10:13:36 +0800
commit02c21a1fa3b9d2f93e59c7e399f0ad1d49241e74 (patch)
tree4e299f2e888f26f8af8a92903a35d5822e2d5be3 /mbbsd
parent90a92cc9ad9a39a8f4af5394f103c9017ddd1b1d (diff)
downloadpttbbs-02c21a1fa3b9d2f93e59c7e399f0ad1d49241e74.tar
pttbbs-02c21a1fa3b9d2f93e59c7e399f0ad1d49241e74.tar.gz
pttbbs-02c21a1fa3b9d2f93e59c7e399f0ad1d49241e74.tar.bz2
pttbbs-02c21a1fa3b9d2f93e59c7e399f0ad1d49241e74.tar.lz
pttbbs-02c21a1fa3b9d2f93e59c7e399f0ad1d49241e74.tar.xz
pttbbs-02c21a1fa3b9d2f93e59c7e399f0ad1d49241e74.tar.zst
pttbbs-02c21a1fa3b9d2f93e59c7e399f0ad1d49241e74.zip
add limits to voting
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2816 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/vote.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/mbbsd/vote.c b/mbbsd/vote.c
index 036ac327..c5e7bd6a 100644
--- a/mbbsd/vote.c
+++ b/mbbsd/vote.c
@@ -10,6 +10,7 @@ const char * const STR_bv_ballots = "ballots"; /* щ布 (per byte) */
const char * const STR_bv_flags = "flags";
const char * const STR_bv_comments = "comments"; /* щ布某 */
const char * const STR_bv_limited = "limited"; /* ╬щ布 */
+const char * const STR_bv_limits = "limits"; /* щ布戈 */
const char * const STR_bv_title = "vtitle";
const char * const STR_bv_results = "results";
@@ -21,6 +22,7 @@ typedef struct {
char flags[sizeof("flagsXX\0")];
char comments[sizeof("commentsXX\0")];
char limited[sizeof("limitedXX\0")];
+ char limits[sizeof("limitsXX\0")];
char title[sizeof("vtitleXX\0")];
} vote_buffer_t;
@@ -241,6 +243,7 @@ b_result_one(vote_buffer_t *vbuf, boardheader_t * fh, int ind, int *total)
snprintf(vbuf->flags, sizeof(vbuf->flags), "%s%d", STR_bv_flags, ind);
snprintf(vbuf->comments, sizeof(vbuf->comments), "%s%d", STR_bv_comments, ind);
snprintf(vbuf->limited, sizeof(vbuf->limited), "%s%d", STR_bv_limited, ind);
+ snprintf(vbuf->limits, sizeof(vbuf->limits), "%s%d", STR_bv_limits, ind);
snprintf(vbuf->title, sizeof(vbuf->title), "%s%d", STR_bv_title, ind);
bname = fh->brdname;
@@ -449,6 +452,7 @@ vote_view(vote_buffer_t *vbuf, const char *bname, int vote_index)
snprintf(vbuf->flags, sizeof(vbuf->flags), "%s%d", STR_bv_flags, vote_index);
snprintf(vbuf->comments, sizeof(vbuf->comments), "%s%d", STR_bv_comments, vote_index);
snprintf(vbuf->limited, sizeof(vbuf->limited), "%s%d", STR_bv_limited, vote_index);
+ snprintf(vbuf->limits, sizeof(vbuf->limits), "%s%d", STR_bv_limits, vote_index);
snprintf(vbuf->title, sizeof(vbuf->title), "%s%d", STR_bv_title, vote_index);
setbfile(buf, bname, vbuf->ballots);
@@ -525,6 +529,8 @@ vote_view(vote_buffer_t *vbuf, const char *bname, int vote_index)
unlink(buf);
setbfile(buf, bname, vbuf->limited);
unlink(buf);
+ setbfile(buf, bname, vbuf->limits);
+ unlink(buf);
setbfile(buf, bname, vbuf->title);
unlink(buf);
@@ -628,8 +634,8 @@ vote_maintain(const char *bname)
char buf2[64];
const char *filename[] = {
STR_bv_ballots, STR_bv_control, STR_bv_desc, STR_bv_desc,
- STR_bv_flags, STR_bv_comments, STR_bv_limited, STR_bv_title,
- NULL
+ STR_bv_flags, STR_bv_comments, STR_bv_limited, STR_bv_limits,
+ STR_bv_title, NULL
};
for (j = 0; filename[j] != NULL; j++) {
snprintf(buf2, sizeof(buf2), "%s%d", filename[j], i);
@@ -665,6 +671,7 @@ vote_maintain(const char *bname)
snprintf(vbuf.flags, sizeof(vbuf.flags), "%s%d", STR_bv_flags, x);
snprintf(vbuf.comments, sizeof(vbuf.comments), "%s%d", STR_bv_comments, x);
snprintf(vbuf.limited, sizeof(vbuf.limited), "%s%d", STR_bv_limited, x);
+ snprintf(vbuf.limits, sizeof(vbuf.limits), "%s%d", STR_bv_limits, x);
snprintf(vbuf.title, sizeof(vbuf.title), "%s%d", STR_bv_title, x);
clear();
@@ -704,6 +711,33 @@ vote_maintain(const char *bname)
if (dashf(buf))
unlink(buf);
}
+ getdata(5, 0,
+ "琌﹚щ布戈(y)щ布戈[n]ぃ砞:[N]",
+ inbuf, 2, LCECHO);
+ setbfile(buf, bname, vbuf.limits);
+ if (inbuf[0] == 'y') {
+ fp = fopen(buf, "w");
+ assert(fp);
+ do {
+ getdata(6, 0, "爹丁 ('る'虫0~120)", inbuf, 4, DOECHO);
+ closetime = atoi(inbuf); // borrow variable
+ } while (closetime < 0 || closetime > 120);
+ fprintf(fp, "%d\n", now - (2592000 * closetime));
+ do {
+ getdata(6, 0, "Ω计", inbuf, 6, DOECHO);
+ closetime = atoi(inbuf); // borrow variable
+ } while (closetime < 0);
+ fprintf(fp, "%d\n", closetime);
+ do {
+ getdata(6, 0, "ゅ彻絞计", inbuf, 6, DOECHO);
+ closetime = atoi(inbuf); // borrow variable
+ } while (closetime < 0);
+ fprintf(fp, "%d\n", closetime);
+ fclose(fp);
+ } else {
+ if (dashf(buf))
+ unlink(buf);
+ }
clear();
getdata(0, 0, "Ωщ布秈︽碭ぱ (ぱ)", inbuf, 4, DOECHO);
@@ -811,6 +845,7 @@ user_vote_one(vote_buffer_t *vbuf, const char *bname, int ind)
snprintf(vbuf->flags, sizeof(vbuf->flags),"%s%d", STR_bv_flags, ind);
snprintf(vbuf->comments, sizeof(vbuf->comments), "%s%d", STR_bv_comments, ind);
snprintf(vbuf->limited, sizeof(vbuf->limited), "%s%d", STR_bv_limited, ind);
+ snprintf(vbuf->limits, sizeof(vbuf->limits), "%s%d", STR_bv_limits, ind);
setbfile(buf, bname, vbuf->control);
cfp = fopen(buf, "r");
@@ -829,6 +864,21 @@ user_vote_one(vote_buffer_t *vbuf, const char *bname, int ind)
more(buf, YEA);
}
}
+ setbfile(buf, bname, vbuf->limits);
+ if (dashf(buf)) {
+ int limits_logins, limits_posts;
+ cfp = fopen(buf, "r");
+ assert(cfp);
+ fscanf(cfp, "%d", &closetime);
+ fscanf(cfp, "%d", &limits_logins);
+ fscanf(cfp, "%d", &limits_posts);
+ fclose(cfp);
+ if (cuser.numlogins > closetime || cuser.numposts < limits_posts ||
+ cuser.firstlogin > limits_logins) {
+ vmsg("ぃ镑戈瞏翅");
+ return FULLUPDATE;
+ }
+ }
if (vote_flag(vbuf, bname, ind, '\0')) {
vmsg("Ωщ布щ筁");
return FULLUPDATE;