summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-04-23 00:04:12 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-04-23 00:04:12 +0800
commit945cf121ce0dfea9c37183eff0b05760bdef3a1d (patch)
treede9d25b806121418f14f7b07aeb2136497da6b36
parent68a75abe1e5568bbac2dbcca6ccad8aca6a1708c (diff)
downloadpttbbs-945cf121ce0dfea9c37183eff0b05760bdef3a1d.tar
pttbbs-945cf121ce0dfea9c37183eff0b05760bdef3a1d.tar.gz
pttbbs-945cf121ce0dfea9c37183eff0b05760bdef3a1d.tar.bz2
pttbbs-945cf121ce0dfea9c37183eff0b05760bdef3a1d.tar.lz
pttbbs-945cf121ce0dfea9c37183eff0b05760bdef3a1d.tar.xz
pttbbs-945cf121ce0dfea9c37183eff0b05760bdef3a1d.tar.zst
pttbbs-945cf121ce0dfea9c37183eff0b05760bdef3a1d.zip
give a warning if too many subscribed favorites is added at the same time
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2711 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/fav.h1
-rw-r--r--include/proto.h2
-rw-r--r--mbbsd/fav.c20
-rw-r--r--mbbsd/mbbsd.c12
4 files changed, 26 insertions, 9 deletions
diff --git a/include/fav.h b/include/fav.h
index fc719c71..3500b45f 100644
--- a/include/fav.h
+++ b/include/fav.h
@@ -19,6 +19,7 @@
#define MAX_FAV 1024
#define MAX_LINE 64
#define MAX_FOLDER 64
+#define NEW_FAV_THRESHOLD 50
#define FAV3 ".fav3"
#define FAV4 ".fav4"
diff --git a/include/proto.h b/include/proto.h
index 8d358443..ca3391a4 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -255,7 +255,7 @@ void fav_cleanup(void);
void fav_clean_invisible(void);
fav_t *get_fav_folder(fav_type_t *ft);
fav_t *get_fav_root(void);
-void updatenewfav(int mode);
+int updatenewfav(int mode);
void subscribe_newfav(void);
/* file */
diff --git a/mbbsd/fav.c b/mbbsd/fav.c
index 9829f55a..6476ab85 100644
--- a/mbbsd/fav.c
+++ b/mbbsd/fav.c
@@ -1081,15 +1081,19 @@ void fav_set_folder_title(fav_type_t *ft, char *title)
* 狦 user 秨币 FAVNEW_FLAG :
* mode == 1: update 狾盢穝狾и程稲
* mode == 0: update 戈癟ぃ
+ *
+ * @return 狾计
+ * PS. count 碞琵ウ计Чぃ穦Ω login 眖秨﹍计
*/
-void updatenewfav(int mode)
+int updatenewfav(int mode)
{
/* mode: 0: don't write to fav 1: write to fav */
int i, fd, brdnum;
+ int count = 0;
char fname[80], *brd;
if(!(cuser.uflag2 & FAVNEW_FLAG))
- return;
+ return 0;
setuserfile(fname, FAVNB);
@@ -1106,7 +1110,7 @@ void updatenewfav(int mode)
free(brd);
close(fd);
vmsg("favorite subscription error");
- return;
+ return -1;
}
/* if it's a new file, no BRD_END is in it. */
@@ -1116,8 +1120,10 @@ void updatenewfav(int mode)
if(brd[i] == BRD_NEW){
/* check the permission if the board exsits */
if(bcache[i].brdname[0] && HasPerm(&bcache[i])){
- if(mode && !(bcache[i].brdattr & BRD_SYMBOLIC))
+ if(mode && !(bcache[i].brdattr & BRD_SYMBOLIC)) {
fav_add_board(i + 1);
+ count++;
+ }
brd[i] = BRD_OLD;
}
}
@@ -1130,8 +1136,10 @@ void updatenewfav(int mode)
if( i < brdnum) { // the board number may change
for(; i < brdnum; ++i){
if(bcache[i].brdname[0] && HasPerm(&bcache[i])){
- if(mode && !(bcache[i].brdattr & BRD_SYMBOLIC))
+ if(mode && !(bcache[i].brdattr & BRD_SYMBOLIC)) {
fav_add_board(i + 1);
+ count++;
+ }
brd[i] = BRD_OLD;
}
else
@@ -1147,6 +1155,8 @@ void updatenewfav(int mode)
free(brd);
close(fd);
}
+
+ return count;
}
void subscribe_newfav(void)
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 92377e37..2d71bbd6 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -1024,9 +1024,15 @@ user_login(void)
if(cuser.uflag2 & FAVNEW_FLAG) {
fav_load();
- /* subscribe new fav (deprecated) */
- if (get_fav_root() != NULL)
- updatenewfav(1);
+ if (get_fav_root() != NULL) {
+ int num;
+ num = updatenewfav(1);
+ if (num > NEW_FAV_THRESHOLD &&
+ getans("盢穝и程稲狾计笷 %d 絋﹚璶[N/y]", num) != 'y') {
+ fav_free();
+ fav_load();
+ }
+ }
}
for (i = 0; i < NUMVIEWFILE; i++)