/*
* Server functions which handle file transfers and room directories.
*
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2016 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3.
*/
void cmd_oimg(char *cmdbuf)
{
- char filename[256];
+ char filename[PATH_MAX];
char pathname[PATH_MAX];
char MimeTestBuf[32];
- struct ctdluser usbuf;
- char which_user[USERNAME_SIZE];
- int which_floor;
- int a;
int rv;
extract_token(filename, cmdbuf, 0, '|', sizeof filename);
return;
}
- if (!strcasecmp(filename, "_userpic_")) {
- extract_token(which_user, cmdbuf, 1, '|', sizeof which_user);
- if (CtdlGetUser(&usbuf, which_user) != 0) {
- cprintf("%d No such user.\n",
- ERROR + NO_SUCH_USER);
- return;
- }
- snprintf(pathname, sizeof pathname,
- "%s/%ld",
- ctdl_usrpic_dir,
- usbuf.usernum);
- } else if (!strcasecmp(filename, "_floorpic_")) {
- which_floor = extract_int(cmdbuf, 1);
- snprintf(pathname, sizeof pathname,
- "%s/floor.%d",
- ctdl_image_dir, which_floor);
- } else if (!strcasecmp(filename, "_roompic_")) {
- assoc_file_name(pathname, sizeof pathname, &CC->room, ctdl_image_dir);
- } else {
- for (a = 0; !IsEmptyStr(&filename[a]); ++a) {
- filename[a] = tolower(filename[a]);
- if ( (filename[a] == '/') || (filename[a] == '\\') ) {
- filename[a] = '_';
- }
- }
- if (strstr(filename, "../") != NULL)
- {
- cprintf("%d syntax error.\n",
- ERROR + ILLEGAL_VALUE);
- return;
- }
-
- snprintf(pathname, sizeof pathname,
- "%s/%s",
- ctdl_image_dir,
- filename);
- }
-
CC->download_fp = fopen(pathname, "rb");
if (CC->download_fp == NULL) {
strcat(pathname, ".gif");
}
rv = fread(&MimeTestBuf[0], 1, 32, CC->download_fp);
if (rv == -1) {
- cprintf("%d Cannot access %s: %s\n",
- ERROR + FILE_NOT_FOUND, pathname, strerror(errno));
+ cprintf("%d Cannot access %s: %s\n", ERROR + FILE_NOT_FOUND, pathname, strerror(errno));
return;
}
OpenCmdResult(pathname, GuessMimeType(&MimeTestBuf[0], 32));
}
+
/*
* open a file for uploading
*/
{
int is_this_for_real;
char basenm[256];
- int which_floor;
int a;
if (num_parms(cmdbuf) < 2) {
basenm);
}
- if (!strcasecmp(basenm, "_userpic_")) {
- snprintf(CC->upl_path, sizeof CC->upl_path,
- "%s/%ld.gif",
- ctdl_usrpic_dir,
- CC->user.usernum);
- }
-
- if ((!strcasecmp(basenm, "_floorpic_"))
- && (CC->user.axlevel >= AxAideU)) {
- which_floor = extract_int(cmdbuf, 2);
- snprintf(CC->upl_path, sizeof CC->upl_path,
- "%s/floor.%d.gif",
- ctdl_image_dir,
- which_floor);
- }
-
- if ((!strcasecmp(basenm, "_roompic_")) && (is_room_aide())) {
- assoc_file_name(CC->upl_path, sizeof CC->upl_path, &CC->room, ctdl_image_dir);
- }
-
if (IsEmptyStr(CC->upl_path)) {
cprintf("%d Higher access required.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
);
if (link(CCC->upl_path, final_filename) == 0) {
- CTDL_syslog(LOG_INFO, "UCLS: updoaded %s",
- final_filename);
+ CTDL_syslog(LOG_INFO, "UCLS: updoaded %s", final_filename);
unlink(CCC->upl_path);
}
else {
if (rc < 0) {
struct CitContext *CCC = CC;
cprintf("%d your file is smaller then %ld.\n", ERROR + ILLEGAL_VALUE, start_pos);
- CTDL_syslog(LOG_ERR, "your file %s is smaller then %ld. [%s]\n",
+ CTDL_syslog(LOG_ERR, "your file %s is smaller then %ld. [%s]",
CC->upl_path,
start_pos,
strerror(errno));
client_read(buf, bytes);
rv = fwrite(buf, bytes, 1, CCC->upload_fp);
if (rv == -1) {
- CTDL_syslog(LOG_EMERG, "Couldn't write: %s\n",
- strerror(errno));
+ CTDL_syslog(LOG_EMERG, "Couldn't write: %s", strerror(errno));
}
free(buf);
}