⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 who.c

📁 ·Free Chat beta release 2 fot linux,采用C语言写的运行在linux下的聊天室程序
💻 C
字号:
/*
  who.c
  
  For Free Chat
  
  By Bill Kendrick
  kendrick@zippy.sonoma.edu
  http://zippy.sonoma.edu/kendrick/

  September 29, 1996 - June 7, 1998
*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cgi-util.h"
#include "dump.h"
#include "readline.h"
#include "defines.h"
#include "whattime.h"
#include "chatwrite.h"
#include "copyback.h"
#include "myopen.h"
#include "nicetime.h"


int main(int argc, char * argv[])
{
  char xname[STRLEN], xemail[STRLEN], xstarttime[STRLEN], xtime[STRLEN];
  char time[STRLEN], temp[STRLEN], temp2[STRLEN];
  int user_time, now_time, i;
  FILE * fi, * fo, * fiface;
  
  
  /* Initialize CGI Interface: */
  
  cgiinit();
  printf("Content-type: text/html\n\n");
  
  
  /* Get time: */
  
  whattime(time);
  

  /* Dump top of page: */
  
  dump("included/who-top.html");
  printf("<p align=center><code>%s</code></p>\n\n", nicetime(time));
  
  
  /* Dump who's here list: */
  
  fi = fopen("who.dat", "r");
  if (fi == NULL)
    {
      printf("System is down!\n");
      exit(0);
    }
  
  fo = myopen("who.tmp", "w");
  if (fi == NULL)
    {
      printf("System is down!\n");
      exit(0);
    }
  
  printf("<center><table border=0>\n");
  
  do
    {
      readline(fi, xname);
      if (!feof(fi))
	{
	  readline(fi, xemail);
	  readline(fi, xstarttime);
	  readline(fi, xtime);
	  readline(fi, temp);
	  
	  user_time = ((((xtime[0] - '0') * 10) + xtime[1] - '0') * 60) +
            (((xtime[3] - '0') * 10) + xtime[4] - '0');
	  
          now_time = ((((time[0] - '0') * 10) + time[1] - '0') * 60) +
            (((time[3] - '0') * 10) + time[4] - '0');
	  
          if (now_time < user_time)
            now_time = now_time + (24 * 60);
	  
	  
          if (now_time - user_time < IDLE)
            {
              fprintf(fo, "%s\n", xname);
              fprintf(fo, "%s\n", xemail);
              fprintf(fo, "%s\n", xstarttime);
              fprintf(fo, "%s\n", xtime);
              fprintf(fo, "\n");
	      
	      printf("<tr><td valign=top height=55>");
	      
	      for (i = 0; i <= strlen(xname); i++)
		{
		  if (xname[i] == '-' || xname[i] == ' ')
		    temp2[i] = '_';
		  else
		    temp2[i] = xname[i];
		}
	      
	      sprintf(temp, "%sphotos/%s.gif", UNIX_PREPEND, temp2);
	      
	      fiface = fopen(temp, "r");
	      if (fiface != NULL)
		{
		  fclose(fiface);
		  
		  printf("<img src=\"%sphotos/%s\" width=40 height=40\n", PREPEND,
			 temp2);
		  printf("width=40 height=40 alt=\"\" border=0\n");
		  printf("alt=\"\" border=0>\n");
		}
	      
	      printf("</td><td valign=top>\n");
	      
	      printf("<b>%s</b></td>\n", xname);
	      printf("<td valign=top>");
	      if (strlen(xemail) != 0)
		printf("<code><a href=\"mailto:%s\">%s</a></code>", xemail, 
		       xemail);
	      printf("</td>\n");
	      printf("<td valign=top>On since: <code>%s</code></td>\n",
		     nicetime(xstarttime));
	      printf("<td valign=top>Last action:\n");
	      printf("<code>%s</code><br></td></tr>\n",
		     nicetime(xtime));
	    }
          else
            {
              sprintf(temp,"%s was idle over %d minutes and has been removed.",
                      xname, IDLE);
              chatwrite(time, "IDLE", temp);
            }
	}
    }
  while (!feof(fi));
  
  fclose(fi);
  fclose(fo);

  copyback("who.dat", "who.tmp");
  
  printf("</table></center>\n");
  
  
  /* Dump bottom of page: */
  
  dump("included/who-bottom.html");
  
  return(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -