Ejemplo n.º 1
0
void main (int argc, char *argv[])
{
   int i;
   USHORT Pack, Purge, Level;

   Pack = FALSE;
   Purge = Level = 0;

   printf ("\nLUSER; %s v%s - User maintenance utility\n", NAME, VERSION);
   printf ("       Copyright (c) 1991-96 by Marco Maccaferri. All Rights Reserved.\n\n");

/*
   if (ValidateKey ("bbs", NULL, NULL) == KEY_UNREGISTERED) {
      printf ("* * *     WARNING: No license key found    * * *\n");
      if ((i = CheckExpiration ()) == 0) {
         printf ("* * *   This evaluation copy has expired   * * *\n\a\n");
          exit (0);
      }
      else
         printf ("* * * You have %2d days left for evaluation * * * \n\a\n", i);
   }
*/

   if (argc <= 1) {
      printf (" * Command-line parameters:\n\n");

      printf ("        -P        Pack (compress) user file\n");
      printf ("        -D[n]     Delete users who haven't called in [n] days\n");
      printf ("        -M[s]     Only purge users with security level less than [s]\n");

      printf ("\n * Please refer to the documentation for a more complete command summary\n\n");
   }
   else {
      for (i = 1; i < argc; i++) {
         if (argv[i][0] == '-' || argv[i][0] == '/') {
            switch (toupper (argv[i][1])) {
               case 'D':
                  Purge = (USHORT)atoi (&argv[i][2]);
                  break;
               case 'M':
                  Level = (USHORT)atoi (&argv[i][2]);
                  break;
               case 'P':
                  Pack = TRUE;
                  break;
            }
         }
      }

      if (Purge != 0)
         PurgeUsers (Purge, Level);
      if (Pack == TRUE)
         PackUsers ();

      if (Purge != 0 || Pack == TRUE)
         printf (" * Done\n\n");
      else
         printf (" * Nothing to do\n\n");
   }
}
Ejemplo n.º 2
0
void purge_databases(void)
{
	int retval;
	static time_t last_purge = 0;
	time_t now;
	struct tm tm;

	/* Do the auto-purge if the current hour equals the purge hour,
	 * but not if the operation has already been performed in the
	 * last twelve hours.  This is usually enough granularity.
	 */
	now = time(NULL);
	localtime_r(&now, &tm);
	if (
		((tm.tm_hour != config.c_purge_hour) || ((now - last_purge) < 43200))
		&& (force_purge_now == 0)
	) {
			return;
	}

	syslog(LOG_INFO, "Auto-purger: starting.");

	if (!server_shutting_down)
	{
		retval = PurgeUsers();
		syslog(LOG_NOTICE, "Purged %d users.", retval);
	}
		
	if (!server_shutting_down)
	{
		PurgeMessages();
	       	syslog(LOG_NOTICE, "Expired %d messages.", messages_purged);
	}

	if (!server_shutting_down)
	{
       		retval = PurgeRooms();
       		syslog(LOG_NOTICE, "Expired %d rooms.", retval);
	}

	if (!server_shutting_down)
	{
       		retval = PurgeVisits();
       		syslog(LOG_NOTICE, "Purged %d visits.", retval);
	}

	if (!server_shutting_down)
	{
		StrBuf *ErrMsg;

		ErrMsg = NewStrBuf ();
		retval = PurgeUseTable(ErrMsg);
       		syslog(LOG_NOTICE, "Purged %d entries from the use table.", retval);
////TODO: fix errmsg
		FreeStrBuf(&ErrMsg);
	}

	if (!server_shutting_down)
	{
       	retval = PurgeEuidIndexTable();
       	syslog(LOG_NOTICE, "Purged %d entries from the EUID index.", retval);
	}

	if (!server_shutting_down)
	{
		retval = PurgeStaleOpenIDassociations();
	       	syslog(LOG_NOTICE, "Purged %d stale OpenID associations.", retval);
	}

	if (!server_shutting_down)
	{
       		retval = TDAP_ProcessAdjRefCountQueue();
	       	syslog(LOG_NOTICE, "Processed %d message reference count adjustments.", retval);
	}

	if (!server_shutting_down)
	{
	       	syslog(LOG_INFO, "Auto-purger: finished.");
		last_purge = now;	/* So we don't do it again soon */
		force_purge_now = 0;
	}
	else {
	       	syslog(LOG_INFO, "Auto-purger: STOPPED.");
	}
}