Code: Show/Hide local void Cdir(const char *params, Player *p, const Target *target)
{ /* Just opens 'dir' command as a pipe and sends data back to user */ FILE *f = _popen("dir", "r"); char str[255]; while (!foef(f)) { if (fgets(str, sizeof(str), f) != NULL) chat->SendMessage(p, "%s", str); } _pclose(f); } |
Code: Show/Hide local helptext_t getfile_help =
"Targets: none\n" "Args: <filename>\n" "Transfers the specified filefrom the server to the client.\n" "The filename should include the full relative path from the server's\n" "base directory.\n"; local void Cgetfile(const char *params, Player *p, const Target *target) { const char *t1 = strrchr(params, '/'); const char *t2 = strrchr(params, '\\'); if (t2 > t1) t1 = t2; t1 = t1 ? t1 + 1 : params; if (params[0] == '/' || strstr(params, "..")) lm->LogP(L_MALICIOUS, "playercmd", p, "Attempted ?getfile with bad path: '%s'", params); else filetrans->SendFile(p, params, t1, 0); } |
Code: Show/Hide #ifndef WIN32
char aconf[PATH_MAX]; DIR *dir = opendir("arenas"); if (dir) { struct dirent *de; while ((de = readdir(dir))) { /* every arena must have an arena.conf. this filters out * ., .., CVS, etc. */ snprintf(aconf, PATH_MAX, "arenas/%s/arena.conf", de->d_name); if ( (pos-buf+strlen(de->d_name)) < 480 && access(aconf, R_OK) == 0 && (de->d_name[0] != '#' || seehid) && check_arena(buf, pos-buf, de->d_name) ) { l = strlen(de->d_name) + 1; strncpy(pos, de->d_name, l); pos += l; *pos++ = 0; *pos++ = 0; } } closedir(dir); } #else char aconf[PATH_MAX]; struct _finddata_t fi; long FH = _findfirst("arenas/*", &fi); if (FH != -1) { do { if ((fi.attrib & _A_SUBDIR) && strcmp(fi.name, "..") && strcmp(fi.name, ".")) { /* every arena must have an arena.conf */ snprintf(aconf, PATH_MAX, "arenas/%s/arena.conf", fi.name); if ( (pos-buf+strlen(fi.name)) < 480 && access(aconf, R_OK) == 0 && (fi.name[0] != '#' || seehid) && check_arena(buf, pos-buf, fi.name) ) { l = strlen(fi.name) + 1; strncpy(pos, fi.name, l); pos += l; *pos++ = 0; *pos++ = 0; } } } while (_findnext(FH,&fi) != -1); _findclose(FH); } #endif |