Exemplo n.º 1
0
function fileXML($file)
{
    global $HOST, $PUBLIC_HTML_DIR, $IMAGE_EXTENSIONS, $IMAGE_FORMATS, $dir, $directory, $DLG;
    if (substr($file, 0, 1) == ".") {
        return;
    }
    $path = $directory . $file;
    $pathinfo = swampy_pathinfo($path);
    $size = "";
    $dimentions = "";
    if (is_dir($path)) {
        $filename = $file;
        $extension = $DLG['dir'];
        $ext = "dir";
        $type = "dir";
    } else {
        $filename = $pathinfo['filename'];
        $extension = $ext = $pathinfo['extension'];
        $size = ceil(filesize($path) / 1024) . " KB";
        $type = "file";
        if (in_array($extension, $IMAGE_EXTENSIONS)) {
            list($width, $height) = getimagesize($path);
            $dimentions = $width . "x" . $height . " px";
            //if image thumb exists adds it to bacground style
            if (file_exists($directory . $IMAGE_FORMATS['mthumb']['dir'] . $pathinfo['filename'] . "." . $IMAGE_FORMATS['mthumb']['ext'])) {
                $bg = "/" . $dir . $IMAGE_FORMATS['mthumb']['dir'] . $pathinfo['filename'] . "." . $IMAGE_FORMATS['mthumb']['ext'];
                $type = "image";
            }
        }
    }
    return "\t<file type='{$type}' dir='{$dir}' file='{$file}' extension='{$extension}' size='{$size}' dimentions='{$dimentions}' bg='{$bg}'>{$filename}</file>\n";
}
Exemplo n.º 2
0
if ($file == "") {
    die(msg('alert', $DLG['select_file']));
}
if ($dir == "") {
    die(msg('alert', $DLG['select_dir']));
}
if (!file_exists($path)) {
    die(msg('error', $DLG['file_not_found'] . " <b>({$file})</b>"));
}
if (is_dir($path)) {
    die(msg('alert', $DLG['not_file'] . " <b>({$file})</b>"));
}
if (!validate_path($path)) {
    die(msg('error', $DLG['invalid_dir'] . " <b>({$dir}{$file})</b>"));
}
$info = swampy_pathinfo($path);
switch ($info['extension']) {
    case "jpeg":
    case "jpg":
    case "gif":
    case "png":
    case "bmp":
        die(show_image($dir . $file));
        break;
    case "txt":
    case "php":
    case "js":
        die(show_text($path));
        break;
    case "html":
    case "htm":
Exemplo n.º 3
0
$directory = $PUBLIC_HTML_DIR . $dir;
if ($dir == "") {
    die(msg('alert', $DLG['select_dir']));
}
if (!is_writable($directory)) {
    die(msg('error', $DLG['no_permission']));
}
if (!validate_path($dir)) {
    die(msg('error', $DLG['invalid_dir'] . " <b>({$directory})</b>"));
}
if ($_POST['upload']) {
    //cheking is file selected
    if ($_FILES['file']['name'] == "") {
        die(stopUpload('alert', $DLG['select_file']));
    }
    $info = swampy_pathinfo($_FILES['file']['name']);
    $ext = $info['extension'] != "" ? "." . $info['extension'] : "";
    $file = $_POST['filename'] != "" ? $_POST['filename'] . $ext : $info['filename'] . $ext;
    $file = format_filename($file);
    //cheking file name
    if (ereg("[^a-zA-Z0-9._-]", $file)) {
        die(stopUpload('alert', $DLG['invalid_filename']));
    }
    //check is file name exists
    if (file_exists($directory . $file)) {
        die(stopUpload('alert', $DLG['file_exists']));
    }
    umask(02);
    //uploadig file
    if (!copy($_FILES['file']['tmp_name'], $directory . $file)) {
        die(stopUpload('error', $DLG['upload_failure']));