summaryrefslogtreecommitdiffstats
path: root/util/birth.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
commitae31e19f92e717919ac8e3db9039eb38d2b89aae (patch)
treec70164d6a1852344f44b04a653ae2815043512af /util/birth.c
downloadpttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.gz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.bz2
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.lz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.xz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.zst
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.zip
Initial revision
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/birth.c')
-rw-r--r--util/birth.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/util/birth.c b/util/birth.c
new file mode 100644
index 00000000..899bf9ee
--- /dev/null
+++ b/util/birth.c
@@ -0,0 +1,99 @@
+/* 壽星程式 96 10/11 */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+#include "config.h"
+#include "pttstruct.h"
+#include "util.h"
+#include "common.h"
+
+#define OUTFILE BBSHOME "/etc/birth.today"
+
+struct userec_t cuser;
+
+int bad_user_id() {
+ register char ch;
+ int j;
+ if (strlen(cuser.userid) < 2 || !isalpha(cuser.userid[0]))
+ return 1;
+ if (cuser.numlogins == 0 || cuser.numlogins > 15000)
+ return 1;
+ if (cuser.numposts > 15000)
+ return 1;
+ for (j = 1; (ch = cuser.userid[j]); j++)
+ {
+ if (!isalnum(ch))
+ return 1;
+ }
+ return 0;
+}
+
+int Link(char *src, char *dst) {
+ char cmd[200];
+
+ if (link(src, dst) == 0)
+ return 0;
+
+ sprintf(cmd, "/bin/cp -R %s %s", src, dst);
+ return system(cmd);
+}
+
+int main(argc, argv)
+ int argc;
+ char **argv;
+{
+ FILE *fp1;
+ fileheader_t mymail;
+ int i, day = 0;
+ time_t now;
+ struct tm *ptime;
+ int j;
+
+ now = time(NULL); /* back to ancent */
+ ptime = localtime(&now);
+
+ if(passwd_mmap())
+ exit(1);
+
+ printf("*製表\n");
+ fp1 = fopen(OUTFILE, "w");
+
+ fprintf(fp1, "\n "
+ "★★★★★★ 壽星大觀 "
+ "★★★★★★ \n\n");
+ fprintf(fp1, "【本日壽星】 \n");
+ for(j = 1; j <= MAX_USERS; j++) {
+ passwd_query(j, &cuser);
+ if (bad_user_id())
+ continue;
+ if (cuser.month == ptime->tm_mon + 1)
+ {
+ if (cuser.day == ptime->tm_mday)
+ {
+ char genbuf[200];
+ sprintf(genbuf, BBSHOME "/home/%c/%s", cuser.userid[0], cuser.userid);
+ stampfile(genbuf, &mymail);
+ strcpy(mymail.owner, BBSNAME);
+ strcpy(mymail.title, "!! 生日快樂 !!");
+ mymail.savemode = 0;
+ unlink(genbuf);
+ Link(BBSHOME "/etc/Welcome_birth", genbuf);
+ sprintf(genbuf, BBSHOME "/home/%c/%s/.DIR", cuser.userid[0], cuser.userid);
+ append_record(genbuf, &mymail, sizeof(mymail));
+ if ((cuser.numlogins + cuser.numposts) < 20)
+ continue;
+
+ fprintf(fp1,
+ " [%2d/%-2d] %-14s %-24s login:%-5d post:%-5d\n",
+ ptime->tm_mon + 1, ptime->tm_mday, cuser.userid,
+ cuser.username, cuser.numlogins, cuser.numposts);
+ }
+ }
+ }
+ fclose(fp1);
+ return 0;
+}