function getFilesNumber($path, $type)
{
    $files = 0;
    $dirs = 0;
    $tmp = listDirectory($path);
    foreach ($tmp as $ff) {
        if ($ff == '.' || $ff == '..' || $ff == 'index.php' || $ff == '.htaccess') {
            continue;
        } elseif (is_file($path . '/' . $ff) && ($type == '' || $type == 'image' && RoxyFile::IsImage($ff) || $type == 'flash' && RoxyFile::IsFlash($ff))) {
            $files++;
        } elseif (is_dir($path . '/' . $ff)) {
            $dirs++;
        }
    }
    return array('files' => $files, 'dirs' => $dirs);
}
Example #2
0
function copyDir($path, $newPath)
{
    $items = listDirectory($path);
    if (!is_dir($newPath)) {
        mkdir($newPath, octdec(DIRPERMISSIONS));
    }
    foreach ($items as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }
        $oldPath = RoxyFile::FixPath($path . '/' . $item);
        $tmpNewPath = RoxyFile::FixPath($newPath . '/' . $item);
        if (is_file($oldPath)) {
            copy($oldPath, $tmpNewPath);
        } elseif (is_dir($oldPath)) {
            copyDir($oldPath, $tmpNewPath);
        }
    }
}
Example #3
0
 public static function Crop($source, $destination, $x, $y, $cropWidth, $cropHeight, $width, $height, $quality = 90)
 {
     $thumbImg = imagecreatetruecolor($width, $height);
     $img = self::GetImage($source);
     imagecopyresampled($thumbImg, $img, 0, 0, $x, $y, $width, $height, $cropWidth, $cropHeight);
     self::OutputImage($thumbImg, RoxyFile::GetExtension(basename($source)), $destination, $quality);
 }
Example #4
0
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'));
        } elseif ($errors) {
            $res = getSuccessRes(t('E_UploadNotAll'));
        } else {
            $res = getSuccessRes();
        }
    } else {
        $res = getErrorRes(t('E_UploadNoFiles'));
    }
Example #5
0
include 'functions.inc.php';
verifyAction('FILESLIST');
checkAccess('FILESLIST');
$path = empty($_GET['d']) ? getFilesPath() : $_GET['d'];
$type = empty($_GET['type']) ? '' : strtolower($_GET['type']);
if ($type != 'image' && $type != 'flash') {
    $type = '';
}
verifyPath($path);
$files = listDirectory(fixPath($path), 0);
natcasesort($files);
$str = '';
echo '[';
foreach ($files as $f) {
    $fullPath = $path . '/' . $f;
    if (!is_file(fixPath($fullPath)) || $type == 'image' && !RoxyFile::IsImage($f) || $type == 'flash' && !RoxyFile::IsFlash($f)) {
        continue;
    }
    $size = filesize(fixPath($fullPath));
    $time = filemtime(fixPath($fullPath));
    $tmp = @getimagesize(fixPath($fullPath));
    $w = 0;
    $h = 0;
    if ($tmp) {
        $w = $tmp[0];
        $h = $tmp[1];
    }
    $str .= '{"p":"' . mb_ereg_replace('"', '\\"', $fullPath) . '","s":"' . $size . '","t":"' . $time . '","w":"' . $w . '","h":"' . $h . '"},';
}
$str = mb_substr($str, 0, -1);
echo $str;
Example #6
0
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  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('COPYFILE');
checkAccess('COPYFILE');
$path = trim(empty($_POST['f']) ? '' : $_POST['f']);
$newPath = trim(empty($_POST['n']) ? '' : $_POST['n']);
if (!$newPath) {
    $newPath = getFilesPath();
}
verifyPath($path);
verifyPath($newPath);
if (is_file(fixPath($path))) {
    $newPath = $newPath . '/' . RoxyFile::MakeUniqueFilename(fixPath($newPath), basename($path));
    if (copy(fixPath($path), fixPath($newPath))) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_CopyFile'));
    }
} else {
    echo getErrorRes(t('E_CopyFileInvalisPath'));
}
Example #7
0
$path = empty($_POST['d']) ? getFilesPath() : $_POST['d'];
$type = empty($_POST['type']) ? '' : strtolower($_POST['type']);
if ($type != 'image' && $type != 'flash') {
    $type = '';
}
verifyPath($path);
$files = listDirectory(fixPath($path), 0);
natcasesort($files);
$str = '';
echo '[';
foreach ($files as $f) {
    $fullPath = $path . '/' . $f;
    if (!is_file(fixPath($fullPath)) || $type == 'image' && !RoxyFile::IsImage($f) || $type == 'flash' && !RoxyFile::IsFlash($f)) {
        continue;
    }
    $size = filesize(fixPath($fullPath));
    $time = filemtime(fixPath($fullPath));
    $w = 0;
    $h = 0;
    if (RoxyFile::IsImage($f)) {
        $tmp = @getimagesize(fixPath($fullPath));
        if ($tmp) {
            $w = $tmp[0];
            $h = $tmp[1];
        }
    }
    $str .= '{"p":"' . mb_ereg_replace('"', '\\"', $fullPath) . '","s":"' . $size . '","t":"' . $time . '","w":"' . $w . '","h":"' . $h . '"},';
}
$str = mb_substr($str, 0, -1);
echo $str;
echo ']';
Example #8
0
  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
@ini_set('memory_limit', -1);
verifyAction('DOWNLOADDIR');
checkAccess('DOWNLOADDIR');
$path = trim($_GET['d']);
verifyPath($path);
$path = fixPath($path);
if (!class_exists('ZipArchive')) {
    echo '<script>alert("Cannot create zip archive - ZipArchive class is missing. Check your PHP version and configuration");</script>';
} else {
    try {
        $filename = basename($path);
        $zipFile = $filename . '.zip';
        $zipPath = BASE_PATH . '/tmp/' . $zipFile;
        RoxyFile::ZipDir($path, $zipPath);
        header('Content-Disposition: attachment; filename="' . $zipFile . '"');
        header('Content-Type: application/force-download');
        readfile($zipPath);
        function deleteTmp($zipPath)
        {
            @unlink($zipPath);
        }
        register_shutdown_function('deleteTmp', $zipPath);
    } catch (Exception $ex) {
        echo '<script>alert("' . addslashes(t('E_CreateArchive')) . '");</script>';
    }
}
Example #9
0
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  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';
header("Pragma: cache");
header("Cache-Control: max-age=3600");
verifyAction('GENERATETHUMB');
checkAccess('GENERATETHUMB');
$path = urldecode(empty($_GET['f']) ? '' : $_GET['f']);
verifyPath($path);
@chmod(fixPath(dirname($path)), octdec(DIRPERMISSIONS));
@chmod(fixPath($path), octdec(FILEPERMISSIONS));
$w = intval(empty($_GET['width']) ? '100' : $_GET['width']);
$h = intval(empty($_GET['height']) ? '0' : $_GET['height']);
header('Content-type: ' . RoxyFile::GetMIMEType(basename($path)));
if ($w && $h) {
    RoxyImage::CropCenter(fixPath($path), null, $w, $h);
} else {
    RoxyImage::Resize(fixPath($path), null, $w, $h);
}
Example #10
0
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  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('RENAMEFILE');
checkAccess('RENAMEFILE');
$path = trim(empty($_GET['f']) ? '' : $_GET['f']);
$name = trim(empty($_GET['n']) ? '' : $_GET['n']);
verifyPath($path);
if (is_file(fixPath($path))) {
    if (!RoxyFile::CanUploadFile($name)) {
        echo getErrorRes(t('E_FileExtensionForbidden') . ' ".' . RoxyFile::GetExtension($name) . '"');
    } elseif (rename(fixPath($path), dirname(fixPath($path)) . '/' . $name)) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_RenameFile') . ' ' . basename($path));
    }
} else {
    echo getErrorRes(t('E_RenameFileInvalidPath'));
}
Example #11
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'));
}