function _createEmptyFile($cwd, $filename) { if ($cwd == 0) { $cwd = 1; } if ($cwd == $GLOBALS['kfm']->setting('root_folder_id') && !$GLOBALS['kfm']->setting('allow_files_in_root')) { return kfm_error(kfm_lang('files are not allowed to be create, moved or copied into root')); } $dir = kfmDirectory::getInstance($cwd); $path = $dir->path(); if (!kfmFile::checkName($filename)) { return kfm_error(kfm_lang('illegalFileName', $filename)); } if (in_array(kfmFile::getExtension($filename), $GLOBALS['kfm']->setting('banned_upload_extensions'))) { return kfm_error(kfm_lang('illegalFileName', $filename)); } $success = touch($path . $filename); if ($success) { chmod($path . $filename, octdec('0' . $GLOBALS['kfm']->setting('default_upload_permission'))); return kfm_loadFiles($cwd); } return kfm_error(kfm_lang('couldNotCreateFile', $filename)); }
} else { $to = $toDir->path() . '/' . $filename; } if (!is_file($tmpname)) { $errors[] = 'No file uploaded'; } else { if (!kfmFile::checkName($filename)) { $errors[] = 'The filename: ' . $filename . ' is not allowed'; } else { if (in_array(kfmFile::getExtension($filename), $kfm->setting('banned_upload_extensions'))) { $errors[] = 'The extension: ' . kfmFile::getExtension($filename) . ' is not allowed'; } } } // { check to see if it's an image, and if so, is it bloody massive if (in_array(kfmFile::getExtension($filename), array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) { list($width, $height, $type, $attr) = getimagesize($tmpname); if ($width > $toDir->maxWidth() || $height > $toDir->maxHeight()) { $errors[] = 'Please do not upload images which are larger than ' . $toDir->maxWidth() . 'x' . $toDir->maxHeight(); } } // } } if ($cwd == $kfm->setting('root_folder_id') && !$kfm->setting('allow_files_in_root')) { $errors[] = 'Cannot upload files to the root directory'; } if (!$replace && file_exists($to)) { $errors[] = 'File already exists'; } // TODO new string if (!count($errors)) {
$replace_file = kfmFile::getInstance($replace); $to = $replace_file->path; if ($replace_file->isImage()) { $replace_file->deleteThumbs(); } } else { $to = $toDir->path() . '/' . $filename; } if (!$tmpname || !is_file($tmpname)) { $errors[] = 'No file uploaded'; } else { if (@(!kfmFile::checkName($filename))) { $errors[] = 'The filename: ' . $filename . ' is not allowed'; } else { if (in_array(@kfmFile::getExtension($filename), $kfm->setting('banned_upload_extensions'))) { $errors[] = 'The extension: ' . kfmFile::getExtension($filename) . ' is not allowed'; } } } // { check to see if it's an image, and if so, is it bloody massive if (in_array(strtolower(preg_replace('/.*\\./', '', $filename)), array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) { list($width, $height, $type, $attr) = getimagesize($tmpname); if ($width > $toDir->maxWidth() || $height > $toDir->maxHeight()) { $errors[] = 'Please do not upload images which are larger than ' . $toDir->maxWidth() . 'x' . $toDir->maxHeight(); } } // } } if ($cwd == $kfm->setting('root_folder_id') && !$kfm->setting('allow_files_in_root')) { $errors[] = 'Cannot upload files to the root directory'; }