Ejemplo n.º 1
0
void do_time( CHAR_DATA* ch, const char* argument)
{
   HOLIDAY_DATA *holiday;
   extern char str_boot_time[];
   // Uncomment if you have Samson's Pfile Cleanup Snippet installed.
   //char buf[MSL];
   const char *suf;
   short day;

   day = time_info.day + 1;

   if( day > 4 && day < 20 )
      suf = "th";
   else if( day % 10 == 1 )
      suf = "st";
   else if( day % 10 == 2 )
      suf = "nd";
   else if( day % 10 == 3 )
      suf = "rd";
   else
      suf = "th";

   ch_printf( ch, "&wIt is &W%d&w o'clock &W%s&w, Day of &W%s&w,&W %d%s&w day in the Month of &W%s&w.\r\n"
              "&wIt is the season of %s&w, in the year &W%d&w.\r\n"
              "&wThe mud started up at  :  &W %s\r\n"
              "&wThe system time        :  &W %s\r\n",
              ( time_info.hour % sysdata.hournoon == 0 ) ? sysdata.hournoon : time_info.hour % sysdata.hournoon,
              time_info.hour >= sysdata.hournoon ? "pm" : "am", day_name[( time_info.day ) % sysdata.daysperweek], day, suf,
              month_name[time_info.month], season_name[time_info.season], time_info.year, str_boot_time,
              c_time( current_time, -1 ) );

   ch_printf( ch, "&wYour local time        :  &W %s&D\r\n", c_time( current_time, ch->pcdata->timezone ) );
   holiday = get_holiday( time_info.month, day - 1 );

   if( holiday != NULL )
      ch_printf( ch, "&wIt's a holiday today:&W %s\r\n", holiday->name );

   if( !IS_NPC( ch ) )
   {
      if( day == ch->pcdata->day + 1 && time_info.month == ch->pcdata->month )
         send_to_char( "&WToday is your &Pb&pi&Yr&Oth&Yd&pa&Py&R!&D\r\n", ch );
   }

  /* Uncomment if you have Samson's Pfile Cleanup Snippet installed.
   if( IS_IMMORTAL( ch ) && sysdata.CLEANPFILES == TRUE )
   {
      long ptime, curtime;

      ptime = ( long int )( new_pfile_time_t );
      curtime = ( long int )( current_time );

      buf[0] = '\0';
      sec_to_hms( ptime - curtime, buf );
      ch_printf( ch, "&wThe next pfile cleanup is in&W %s&w.&D\r\n", buf );
   } */
   return;
}
Ejemplo n.º 2
0
void do_timezone( CHAR_DATA* ch, const char* argument)
{
   int i;

   if( IS_NPC( ch ) )
      return;

   if( !argument || argument[0] == '\0' )
   {
      ch_printf( ch, "%-6s %-30s (%s)\r\n", "Name", "City/Zone Crosses", "Time" );
      send_to_char( "-------------------------------------------------------------------------\r\n", ch );
      for( i = 0; i < MAX_TZONE; i++ )
      {
         ch_printf( ch, "%-6s %-30s (%s)\r\n", tzone_table[i].name, tzone_table[i].zone, c_time( current_time, i ) );
      }
      send_to_char( "-------------------------------------------------------------------------\r\n", ch );
      return;
   }

   i = tzone_lookup( argument );

   if( i == -1 )
   {
      send_to_char( "That time zone does not exists. Make sure to use the exact name.\r\n", ch );
      return;
   }

   ch->pcdata->timezone = i;
   ch_printf( ch, "Your time zone is now %s %s (%s)\r\n", tzone_table[i].name,
              tzone_table[i].zone, c_time( current_time, i ) );
}
Ejemplo n.º 3
0
void Message_Service::Banner (FILE *file)
{
	time_t ltime;
	int  pad1, pad2;
	char buffer [FIELD_BUFFER];

	char blank = ' ';
	char *bar = "********************************************";

	if (file == NULL) file = stdout;
	
	fprintf (file, "\n\t%s", bar);
	fprintf (file, "\n\t|%42c|", blank);

	str_fmt (buffer, sizeof (buffer), "%s - Version %s", Program (), Version ());

	pad1 = (int) (42 - strlen (buffer));
	pad2 = pad1 - pad1 / 2;
	pad1 = pad1 / 2;

	fprintf (file, "\n\t|%*c%s%*c|", pad1, blank, buffer, pad2, blank);

	str_fmt (buffer, sizeof (buffer), "Copyright (c) %s", CopyRight ());

	pad1 = (int) (42 - strlen (buffer));
	pad2 = pad1 - pad1 / 2;
	pad1 = pad1 / 2;

	fprintf (file, "\n\t|%*c%s%*c|", pad1, blank, buffer, pad2, blank);

	ltime = StartTime ();
	
	str_cpy (buffer, sizeof (buffer), c_time (&ltime));

	pad1 = (int) (42 - strlen (buffer));
	pad2 = pad1 - pad1 / 2;
	pad1 = pad1 / 2;

	fprintf (file, "\n\t|%*c%s%*c|", pad1, blank, buffer, pad2, blank);

	fprintf (file, "\n\t|%42c|", blank);
	fprintf (file, "\n\t%s\n", bar);
	fflush (file);
}
Ejemplo n.º 4
0
int
main(int n, char *arg[])
{
	char buf[256], dir[256], tmp[256],tmp1[256];
	if (n < 2)
		exit(0);
	strcpy(board, arg[1]);
	sprintf(buf, dl_path "/%s.tgz", board);
	if (do_testtime(file_time(buf), ".", 0, 2*3600) == 0) {
		printf("#no need to update %s\n", buf);
		return 0;
	}
	printf("process %s\n",board);
	sprintf(dir, dl_path "/tmp/an.tmp/%s", board);
	sprintf(buf, "mkdir -p %s", dir);
	system(buf);
	system("pwd");
	sprintf(tmp, "一塌糊涂BBS %s版精华区(%s)", board, c_time(time(0)));
	do_index(".", dir, tmp, 1, 0);
	sprintf(tmp1, "%s/tmp/an.tmp/%s", dl_path, board);
	chdir(tmp1);
	sprintf(tmp1, "%s/bin/makechm -b %s", MY_BBS_HOME, board);
	system(tmp1);
	chdir(dl_path "/tmp/an.tmp");
	printf("board: %s\n", board);
	sprintf(buf, "tar -zcf %s.tgz %s", board, board);
	system(buf);
	sprintf(buf, "rm -rf %s", board);
	printf("%s\n", buf);
	system(buf);
	snprintf(buf,sizeof(buf),"%s/%s.tgz",dl_path,board);
	if(file_size(buf)>100*1024*1024)
		truncate(buf,0);
	sprintf(buf, "mv -f %s.tgz %s", board, dl_path);
	printf("%s\n", buf);
	system(buf);
	sync();
	return 0;
}
Ejemplo n.º 5
0
string replaceCommon(const string& what)
{
    string ret(what);
    ret = replace(ret, "%TIME%", c_time());
    return ret;
}
Ejemplo n.º 6
0
void do_bankinfo( CHAR_DATA *ch, char *argument )
{
    BANK_DATA              *bank;

    char                    arg1[MAX_INPUT_LENGTH];
    char                    arg2[MAX_INPUT_LENGTH];

    if ( IS_NPC( ch ) )
        return;

    if ( !argument || argument[0] == '\0' ) {
        send_to_char( "Syntax: bankinfo all/old\r\nSyntax: bankinfo [name]\r\n", ch );
        return;
    }

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

    if ( !str_cmp( arg1, "all" ) ) {
        int                     iHash;
        int                     counter = 0;
        BANK_DATA              *bank;

        for ( iHash = 0; iHash < 27; iHash++ ) {
            for ( bank = bank_index[iHash]; bank; bank = bank->next ) {
                counter++;
                ch_printf( ch, "%d. %s %s\r\n", counter,
                           bank->lastused == 0 ? "Never" : c_time( bank->lastused, -1 ),
                           bank->name );
            }
        }
        return;
    }
    else if ( !str_cmp( arg1, "old" ) ) {
        int                     iHash,
                                counter = 0,
            days;
        BANK_DATA              *bank;

        for ( iHash = 0; iHash < 27; iHash++ ) {
            for ( bank = bank_index[iHash]; bank; bank = bank->next ) {
                if ( !bank->lastused )
                    days = 0;
                else {
                    days = ( ( current_time - bank->lastused ) / 86400 );
                    if ( days < 30 )
                        continue;
                }
                ch_printf( ch, "%d. %s %s\r\n", ++counter,
                           days == 0 ? "Never" : c_time( bank->lastused, -1 ), bank->name );
            }
        }
        if ( counter == 0 )
            send_to_char( "All banks have been used in the last 30 days.\r\n", ch );
        return;
    }

    bank = find_bank( arg1 );

    if ( !bank ) {
        send_to_char( "There is no account with that name!\r\n", ch );
        return;
    }

    ch_printf( ch, "Name: %s\r\nPassword: %s\r\nLastUsed: %d\r\nBalance: %d\r\n", bank->name,
               bank->password, c_time( bank->lastused, -1 ), bank->amount );
}
Ejemplo n.º 7
0
int main( int argc, char **argv )
#endif
{
   struct timeval now_time;
   int temp = -1, temp2 = -1;
   bool fCopyOver = false;

#if !defined(WIN32)
   moron_check(  );  // Debatable weather or not this is true in WIN32 anyway :)
#endif

   DONT_UPPER = false;
   num_descriptors = 0;
   num_logins = 0;
   dlist.clear(  );
   mudstrlcpy( lastplayercmd, "No commands issued yet", MIL * 2 );

   // Init time.
   tzset(  );
   gettimeofday( &now_time, NULL );
   current_time = now_time.tv_sec;
   mudstrlcpy( str_boot_time, c_time( current_time, -1 ), MIL );  /* Records when the mud was last rebooted */

   new_pfile_time_t = current_time + 86400;
   mud_start_time = current_time;

   // Get the port number.
   mud_port = 9500;
   if( argc > 1 )
   {
      if( !is_number( argv[1] ) )
      {
         fprintf( stderr, "Usage: %s [port #]\n", argv[0] );
         exit( 1 );
      }
      else if( ( mud_port = atoi( argv[1] ) ) <= 1024 )
      {
         fprintf( stderr, "%s", "Port number must be above 1024.\n" );
         exit( 1 );
      }

      if( argv[2] && argv[2][0] )
      {
         fCopyOver = true;
         control = atoi( argv[3] );
#ifdef IMC
         temp2 = atoi( argv[4] );
#endif
      }
      else
         fCopyOver = false;
   }

#if defined(WIN32)
   {
      /*
       * Initialise Windows sockets library 
       */
      unsigned short wVersionRequested = MAKEWORD( 1, 1 );
      WSADATA wsadata;
      int err;

      /*
       * Need to include library: wsock32.lib for Windows Sockets 
       */
      err = WSAStartup( wVersionRequested, &wsadata );
      if( err )
      {
         fprintf( stderr, "Error %i on WSAStartup\n", err );
         exit( 1 );
      }

      /*
       * standard termination signals 
       */
      signal( SIGINT, bailout );
      signal( SIGTERM, bailout );
   }
#endif /* WIN32 */

   // Initialize all startup functions of the mud. 
   init_mud( fCopyOver, mud_port, temp, temp2 );

#if !defined(WIN32)
   /*
    * Set various signal traps, waiting until after completing all bootup operations
    * before doing so because crashes during bootup should not be intercepted. Samson 3-11-04
    */
   signal( SIGTERM, SigTerm );   /* Catch kill signals */
   signal( SIGPIPE, SIG_IGN );
   signal( SIGALRM, caught_alarm );
   signal( SIGUSR1, SigUser1 );  /* Catch user defined signals */
   signal( SIGUSR2, SigUser2 );
#endif
#ifdef MULTIPORT
   signal( SIGCHLD, SigChld );
#endif

   /*
    * If this setting is active, intercept SIGSEGV and keep the mud running.
    * Doing so sets a flag variable which if true will cause SegVio to abort()
    * If game_loop is restarted and makes it through once without crashing again,
    * then the flag is unset and SIGSEGV will continue to be intercepted. Samson 3-11-04
    */
   if( sysdata->crashhandler == true )
      set_chandler(  );

   log_string( "No people online yet. Suspending autonomous update handlers." );

   // Sick isn't it? The whole game being run inside of one little statement..... :P 
   game_loop(  );

   // Clean up the loose ends. 
   close_mud(  );

   // That's all, folks.
   log_string( "Normal termination of game." );
   log_string( "Cleaning up Memory.&d" );
   cleanup_memory(  );
   exit( 0 );
}
Ejemplo n.º 8
0
FILE *
do_index(char *path0, char *path2, char *title0, int thisno, int isdir)
{
	FILE *fp, *fp2;
	unsigned char names[512], index[512], title[256];
	unsigned char genbuf[512], path00[512], path22[512];
	int no = 0, m, lastisdir = 0;
	FILE *lastfp = NULL;
	static int depth = 0;
	depth++;
	mkdir(path2, 0777);
	if (!lfile_isdir(path0))
		return NULL;
	sprintf(names, "%s/.Names", path0);
	fp = fopen(names, "r");

	sprintf(index, "%s/index.html", path2);
	fp2 = fopen(index, "w");
	fprintf(fp2, "<html><head><TITLE>");
	htmlline(fp2, title0);
	fprintf(fp2, "</TITLE> <style> body {font - size:14 px}"
		"A {text - decoration:none; color: #0000FF}"
		" A:hover {color: #FF0000}"
		"</style></head><body><pre><center>");
	htmlline(fp2, title0);
	fprintf(fp2, "<hr width=560>\r\n");
	if (fp != NULL) {
		while (fgets(genbuf, 80, fp) > 0) {
			if (!strncmp(genbuf, "Name=", 5)) {
				sprintf(title, "%s", genbuf + 5);
				title[38] = 0;
				for (m = 0; m < strlen(title); m++)
					if (title[m] <= 27)
						title[m] = 0;
				fgets(genbuf, 256, fp);
				if (!strncmp("Path=~/", genbuf, 6)) {
					for (m = 0; m < strlen(genbuf); m++)
						if (genbuf[m] <= 27)
							genbuf[m] = 0;
					if (!strcmp("Path=~/", genbuf))
						continue;
					sprintf(path00, "%s/%s", path0,
						genbuf + 7);
					for (m = 0; m < strlen(path00); m++)
						if (path00[m] <= 27)
							path00[m] = 0;
					if (!file_exist(path00))
						continue;
					no++;
					if (lfile_isdir(path00)) {
						sprintf(path22, "%s/%d", path2,
							no);
						if (strstr(title, "BMS")
						    || strstr(title, "SYSOPS")
						    || strstr(title, "<HIDE>"))
							continue;
						fprintf(fp2,
							"%4d  [目录] <a href='%d/index.html'>",
							no, no);
						sprintf(genbuf, "%-40.40s",
							title);
						htmlline(fp2, genbuf);
						fprintf(fp2, "</a> [%s]\r\n",
							c_time(file_time
							       (path00)));
						if (lastfp != NULL) {
							fprintf(lastfp,
								"&nbsp;<a href=%s/%d/index.html>下一项</a></center></body></html>\r\n",
								lastisdir ? ".."
								: ".", no);
							fclose(lastfp);
						}
						lastfp =
						    do_index(path00, path22,
							     title, no,
							     lastisdir);
						lastisdir = 1;
						continue;
					}
					sprintf(path22, "%s/%d.html", path2,
						no);
					if (lastfp != NULL) {
						fprintf(lastfp,
							"&nbsp;<a href=%s/%d.html>下一项</a></center></body></html>\r\n",
							lastisdir ? ".." : ".",
							no);
						fclose(lastfp);
					}
					lastfp =
					    filetohtml(path00, path22, no,
						       lastisdir, depth);
					lastisdir = 0;
					fprintf(fp2,
						"%4d  [文件] <a href='%d.html'>",
						no, no);
					sprintf(genbuf, "%-40.40s", title);
					htmlline(fp2, genbuf);
					fprintf(fp2, "</a> [%s]\r\n",
						c_time(file_time(path00)));
				}
			}
		}
		if (lastfp != NULL) {
			fprintf(lastfp, "</body></html>\r\n");
			fclose(lastfp);
		}
		fclose(fp);
	}
	fprintf(fp2,
		"<hr width=560><a href=http://ytht.net><font color=green>一塌糊涂 BBS</font></a>&nbsp;&nbsp;1999-2002&nbsp;&nbsp;</center></pre>\r\n");
	fprintf(fp2, "<center>");
	fprintf(fp2, "<a href=javascript:history.go(-1)>返回</a>");
	if (depth > 1) {
		if (thisno > 1)
			fprintf(fp2, "&nbsp;<a href=../%d%s>上一项</a>",
				thisno - 1, isdir ? "/index.html" : ".html");
		fprintf(fp2,
			"&nbsp;<a href=../index.html>回到目录</a>&nbsp;<a href=");
		for (m = 1; m < depth; m++)
			fprintf(fp2, "../");
		fprintf(fp2, "index.html>首页</a>");
	}
	depth--;
	if (depth)
		return fp2;
	else {
		fprintf(fp2, "</center></body></html>");
		fclose(fp2);
		return NULL;
	}
}