珞珈山水BBS电脑网络BBS安装与维护 → 单文区文章阅读

单文区文章阅读 [返回]
发信人: halcyonfish (拟南芥), 信区: BBSDev
标  题: 倒计时程序代码][
发信站: 珞珈山水 (2003年06月19日20:52:18 星期四), 站内信件

1. 在 goodbye.c 中添加一个函数:
/* Added by deardragon 1999.11.26 计算特定时间距今的天数 */
int countdays(year,month,day,now)
int year,month,day;
time_t now;
{
        struct tm *GoodTime;
        time_t tmptime;
        GoodTime = localtime(&now);
        GoodTime->tm_year = year - 1900;
        GoodTime->tm_mon = month-1;
        GoodTime->tm_mday = day;
        tmptime = mktime(GoodTime);
        return ((tmptime-now)/86400);
}
/* Added End. */
这个函数就可以计算出从给出的 year,month,day 和现在的 now,
算出距今天的天数。
2. 在进站时显示澳门回归还需的天数:
在 main.c 中的 login_query() 中添加一个 变量:
         int     tmpnum;
         time_t now;
然后在合适的地方显示信息,这里是在进站时显示:
/* Added by deardragon 1999.11.26 显示澳门回归祖国天数信息 */
       now = time(0);
        tmpnum = countdays(1999,12,20,now);
        if ( tmpnum > 0 )
                prints("^[[1;33;41m今天距澳门回归祖国还有 %d 天!^[[m\n",
                        abs(tmpnum));
        else
                prints("^[[1;33;41m热烈 :匕 门回归祖国怀抱!!!!^[[m\n");
/* Added End. */
        prints("^[[1;35m欢迎光临^[[1;40;33m【 %s 】^[[0;1;32m。 本站一共可以
让 ^
[[1;36m%d^[[0;1;32m 人注册使用。^[[m\n",
3. 如果想在活动看板里显示的话,还需要修改 goodbye.c 中的代码:
   修改 showstuff(buf, limit) 函数。加变量:
   static char GoodDays[10],AllDays[10];
/* GoodDays 一些有意义的日子距今天的天数. 如澳门回归, 下次生日距今天数等.*/
/* AllDays 从生日到今天的日子 */
  修改 static logout loglst[] = { 中的成员,增加这两个。
        static logout loglst[] =
        {
                "gooddays",GoodDays,
                "alldays",AllDays,
                "userid", currentuser.userid,
                "username", currentuser.username,
   在  if (currentuser.numlogins > 0) {      分支中添加:
                tmpnum = countdays(1999,12,20,now);/*澳门回归*/
                sprintf(GoodDays,"%d",abs(tmpnum));
                tmpnum = countdays(currentuser.birthyear+1900,
                        currentuser.birthmonth,currentuser.birthday,now);
                sprintf(AllDays,"%d",abs(tmpnum));
4. OK. 活动看板中就可以用 $gooddays 和 $alldays 这两个咚咚了。 
--
 我想,我们都是对方舟船上的摆渡的过客。撑一竿,渡一程,都是能给的所有,而岸的彼方,注定不是并肩而行的天光水色。我知道我会记得水路上行经的激流险滩,粼粼波光,然后在靠岸的时刻,转身背离川上所有,因为,情深不堪负荷的缘故。
※ 来源:·珞珈山水 bbs.whu.edu.cn·◆ FROM: 219.242.122.83
[返回单文区目录]

武汉大学BBS 珞珈山水站 All rights reserved.
wForum , 页面执行时间:11.927毫秒