Exemple #1
0
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('UPLOAD');
checkAccess('UPLOAD');
$path = trim(empty($_POST['d']) ? getFilesPath() : $_POST['d']);
verifyPath($path);
$res = '';
if (is_dir(fixPath($path))) {
    if (!empty($_FILES['files']) && is_array($_FILES['files']['tmp_name'])) {
        $errors = $errorsExt = array();
        foreach ($_FILES['files']['tmp_name'] as $k => $v) {
            $filename = $_FILES['files']['name'][$k];
            $filename = RoxyFile::MakeUniqueFilename(fixPath($path), $filename);
            $filePath = fixPath($path) . '/' . $filename;
            if (!RoxyFile::CanUploadFile($filename)) {
                $errorsExt[] = $filename;
            } elseif (!move_uploaded_file($v, $filePath)) {
                $errors[] = $filename;
            }
            if (is_file($filePath)) {
                @chmod($filePath, octdec(FILEPERMISSIONS));
            }
            if (RoxyFile::IsImage($filename) && (intval(MAX_IMAGE_WIDTH) > 0 || intval(MAX_IMAGE_HEIGHT) > 0)) {
                RoxyImage::Resize($filePath, $filePath, intval(MAX_IMAGE_WIDTH), intval(MAX_IMAGE_HEIGHT));
            }
        }
        if ($errors && $errorsExt) {
            $res = getSuccessRes(t('E_UploadNotAll') . ' ' . t('E_FileExtensionForbidden'));
        } elseif ($errorsExt) {
            $res = getSuccessRes(t('E_FileExtensionForbidden'));
Exemple #2
0
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('MOVEFILE');
checkAccess('MOVEFILE');
$path = trim(empty($_POST['f']) ? '' : $_POST['f']);
$newPath = trim(empty($_POST['n']) ? '' : $_POST['n']);
if (!$newPath) {
    $newPath = getFilesPath();
}
verifyPath($path);
verifyPath($newPath);
if (!RoxyFile::CanUploadFile(basename($newPath))) {
    echo getErrorRes(t('E_FileExtensionForbidden'));
} elseif (is_file(fixPath($path))) {
    if (file_exists(fixPath($newPath))) {
        echo getErrorRes(t('E_MoveFileAlreadyExists') . ' ' . basename($newPath));
    } elseif (rename(fixPath($path), fixPath($newPath))) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_MoveFile') . ' ' . basename($path));
    }
} else {
    echo getErrorRes(t('E_MoveFileInvalisPath'));
}