<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <ctype.h>
#include "structonline.h"
#include "../../zipscript/conf/zsconfig.h"
#include "zsconfig.defaults.h"

struct GROUP {
	char           *name;
	gid_t		id;
};

int		groups = 0, GROUPS = 0;

static struct ONLINE *user;
static struct GROUP **group;

long long	shmid;
struct shmid_ds	ipcbuf;
struct stat	filestat;

char           *header = 0, *footer = 0, *glpath = 0, *mpaths = 0, *husers = 0, *hgroups = 0, *ipckey = 0, *glgroup = 0, *nocase = 0,
               *def_ipckey = "0x0000DEAD", *def_glgroup = "/etc/group", *def_nocase = "false", 
	       *def_husers = "pzs-ng", *def_hgroups = "pzs-ng", *def_mpaths = "/ftp-data/pzs-ng", *def_glpath = "/glftpd/",
	       *def_count_hidden = "true", *count_hidden, *def_header = "/ftp-data/misc/who.head",
	       *def_footer = "/ftp-data/misc/who.foot";
int		maxusers = 20 , showall = 0, uploads = 0, downloads = 0, onlineusers = 0, browsers = 0, idlers = 0, chidden = 1,
		idle_barrier = -1, def_idle_barrier = 30, threshold = -1, def_threshold = 1024;
double		total_dn_speed = 0, total_up_speed = 0;

int
check_path(char *filename)
{
	if (stat(filename, &filestat) != 0)
		return 0;
	return 1;
}

unsigned long 
filesize(char *filename)
{
	char           *file;

	file = malloc(strlen(glpath) + strlen(filename) + 2);
	sprintf(file, "%s/%s", glpath, filename);
	if (stat(file, &filestat) != 0) {
		if (!strcmp(filename, "")) {
			filestat.st_size = 1;
		} else {
			sprintf(file, "/%s", filename);
			if (stat(file, &filestat) != 0) {
				if (!strcmp(filename, "")) {
					filestat.st_size = 1;
				} else {
					fprintf(stderr, "Could not stat file '%s', is glrootpath set correctly in sitewho.conf? (error: %s)\n", file, strerror(errno));
					free(file);
					exit(1);
				}
			}
		}
	}
	free(file);
	return filestat.st_size;
}

char           *
get_g_name(unsigned int gid)
{
	int		n;

	for (n = 0; n < groups; n++) {
		if (group[n]->id == gid)<commit_msg>"fix" for sitewho output when user is downloading or idle in a dir that no longer exists on site.<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <ctype.h>
#include "structonline.h"
#include "../../zipscript/conf/zsconfig.h"
#include "zsconfig.defaults.h"

struct GROUP {
	char           *name;
	gid_t		id;
};

int		groups = 0, GROUPS = 0;

static struct ONLINE *user;
static struct GROUP **group;

long long	shmid;
struct shmid_ds	ipcbuf;
struct stat	filestat;

char           *header = 0, *footer = 0, *glpath = 0, *mpaths = 0, *husers = 0, *hgroups = 0, *ipckey = 0, *glgroup = 0, *nocase = 0,
               *def_ipckey = "0x0000DEAD", *def_glgroup = "/etc/group", *def_nocase = "false", 
	       *def_husers = "pzs-ng", *def_hgroups = "pzs-ng", *def_mpaths = "/ftp-data/pzs-ng", *def_glpath = "/glftpd/",
	       *def_count_hidden = "true", *count_hidden, *def_header = "/ftp-data/misc/who.head",
	       *def_footer = "/ftp-data/misc/who.foot";
int		maxusers = 20 , showall = 0, uploads = 0, downloads = 0, onlineusers = 0, browsers = 0, idlers = 0, chidden = 1,
		idle_barrier = -1, def_idle_barrier = 30, threshold = -1, def_threshold = 1024;
double		total_dn_speed = 0, total_up_speed = 0;

int
check_path(char *filename)
{
	if (stat(filename, &filestat) != 0)
		return 0;
	return 1;
}

unsigned long 
filesize(char *filename)
{
	char           *file;

	file = malloc(strlen(glpath) + strlen(filename) + 2);
	sprintf(file, "%s/%s", glpath, filename);
	if (stat(file, &filestat) != 0) {
		if (!strcmp(filename, "")) {
			filestat.st_size = 1;
		} else {
			sprintf(file, "/%s", filename);
			if (stat(file, &filestat) != 0) {
				if (!strcmp(filename, "")) {
					filestat.st_size = 1;
				} else {
//					fprintf(stderr, "Could not stat file '%s', is glrootpath set correctly in sitewho.conf? (error: %s)\n", file, strerror(errno));
//					free(file);
					filestat.st_size = 1;
//					exit(1);
				}
			}
		}
	}
	free(file);
	return filestat.st_size;
}

char           *
get_g_name(unsigned int gid)
{
	int		n;

	for (n = 0; n < groups; n++) {
		if (group[n]->id == gid)
{'fraction_non_alphanumeric': 0.17375647085302723, 'fraction_numerical': 0.02048165653837497, 'mean_word_length': 3.2689721421709894, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5241186', 'n_tokens_mistral': 1976, 'n_tokens_neox': 1795, 'n_words': 439}