Esempio n. 1
0
    } else {
        file_put_contents("{$nImgPrefix}/html/{$uplImage}.html", "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n\t<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='ru' lang='ru'>\n\t<head>\n\t<title>{$fullname['1']}</title>\n\t<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n\t<link rel='STYLESHEET' href='{$r}/css.css' type= 'text/css' />\n\t<link rel='icon' type='image/png' href='{$r}/favicon.png' />\n\t</head>\n\t<body>\n\t<a href='{$r}/{$nImgPrefix}/{$uplImage}'><img src='{$r}/{$nImgPrefix}/thumbs/{$uplImage}' alt='Image'></a><br />\n\t<form action='/' method='post'>\n\tDirect link: <input type='text' size='75' readonly='readonly' name='direct' value='http://{$siteroot}{$r}/{$nImgPrefix}/{$uplImage}' /><br />\n\tThumbnail link: <input type='text' size='75' readonly='readonly' name='directthumb' value='http://{$siteroot}{$r}/{$nImgPrefix}/thumbs/{$uplImage}' /><br />\n\tBBCODE: <input type='text' readonly='readonly' size='75' name='phpbb' value='[url=http://{$siteroot}{$r}/{$nImgPrefix}/{$uplImage}][img]http://{$siteroot}{$r}/{$nImgPrefix}/thumbs/{$uplImage}" . "[/img][/url]' /><br />\n\tBBCODE (w/o preview): <input type='text' size='75' readonly='readonly' name='phpbb' value='[img]http://{$siteroot}{$r}/{$nImgPrefix}/{$uplImage}" . "[/img]' /><br />\n\tHTML: <input type='text' size='75' readonly='readonly' name='html' value='<a href=\"http://{$siteroot}{$r}/{$nImgPrefix}/{$uplImage}\"> <img src=\"http://{$siteroot}{$r}/{$nImgPrefix}/thumbs/{$uplImage}\" alt=\"NBL Image\" /> </a>' /> <br />\n\tHTML (w/o preview): <input type='text' size='75' readonly='readonly' name='html' value='<img src=\"http://{$siteroot}{$r}/{$nImgPrefix}/{$uplImage}\" alt=\"NBL Image\" />' /> <br />\n\tTextile: <input type='text' size='75' readonly='readonly' name='html' value='!http://{$siteroot}{$r}/{$nImgPrefix}/thumbs/{$uplImage}!:http://{$siteroot}{$r}/{$nImgPrefix}/{$uplImage}' /> <br />\n\tTextile (w/o preview): <input type='text' size='75' readonly='readonly' name='html' value='!http://{$siteroot}{$r}/{$nImgPrefix}/{$uplImage}!' /> <br />\n\t</form>\n\n\t<form action='{$r}/' method='post' enctype='multipart/form-data'>\n\t<input type='hidden' name='MAX_FILE_SIZE' value='{$imglimit}' />\n\t<input type='file' size='50' name='image' /> <br />\n\t<input type='submit' value='Dump another one!' />\n\n\t<a href='{$r}/'>NBL file dumping facility</a>\n\t</body>\n\t</html>");
        chmod("{$nImgPrefix}/html/{$uplImage}.html", 0755);
        if ($_POST['simple']) {
            redir("{$r}/{$nImgPrefix}/{$uplImage}");
        } elseif ($useHtaccess) {
            redir("{$r}/i/{$uplImage}");
        } else {
            redir("{$r}/{$nImgPrefix}/html/{$uplImage}.html");
        }
    }
} elseif (isset($_FILES['file']) && $filesEnabled) {
    $uplFile = nFileHandleUpload($_FILES['file']);
    $about = preg_replace("/^.*:([^:]+)\$/", "\$1", exec("file --mime {$nFilePrefix}/{$uplFile}"));
    if (!$uplFile) {
        err_inf("Something is wrong. " . $_FILES['image']['error']);
    } else {
        $fullname = split('/', $uplFile);
        file_put_contents("{$nFilePrefix}/html/{$uplFile}.html", "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n\t<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='ru' lang='ru'>\n\t<head>\n\t<title>{$fullname['1']}</title>\n\t<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n\t<link rel='icon' type='image/png' href='{$r}/favicon.png' />\n\t<link rel='STYLESHEET' href='{$r}/css.css' type= 'text/css' />\n\t</head>\n\t<body><p>\n\t{$fullname['1']}, {$about}, " . size_readable(filesize("{$nFilePrefix}/{$uplFile}"), null, '%d %s') . "\n\t<br />\n\t<a href='http://{$siteroot}{$r}/{$nFilePrefix}/{$uplFile}'>Download</a></p>\n\t<form action='{$r}/' method='post' enctype='multipart/form-data'>\n\t<input type='hidden' name='MAX_FILE_SIZE' value='{$filelimit}' />\n\t<input type='file' size='50' name='file' /> <br />\n\t<input type='submit' value='Dump another one!' />\n\t<a href='{$r}/'>NBL file dumping facility</a> | <small><a href='{$r}/?delete={$nFilePrefix}/{$uplFile}'>Delete this file</a></small> </body></html>");
        chmod("{$nFilePrefix}/html/{$uplFile}.html", 0755) or $fail = 1;
        if ($_POST['simple']) {
            redir("{$r}/{$nFilePrefix}/{$uplFile}");
        } elseif ($useHtaccess) {
            redir("{$r}/f/{$uplFile}");
        } else {
            redir("{$r}/{$nFilePrefix}/html/{$uplFile}.html");
        }
    }
}
// uploading form
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='ru' lang='ru'>\n<head>\n<title>NBL file dumping facility</title>\n<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n<link rel='icon' type='image/png' href='{$r}/favicon.png' />\n<link rel='STYLESHEET' href='{$r}/css.css' type= 'text/css' />\n</head>\n<body><div class='content'>\n";
Esempio n. 2
0
function nImageHandleUpload($file)
{
    global $nImgPrefix, $thumbwidth, $thumbheight, $r, $siteroot, $imglimit, $useIM;
    $name = $file['name'];
    $tmpname = $file['tmp_name'];
    if ($file['size'] > $imglimit) {
        return 0;
    }
    $name = preg_replace("{/|\\s+}", "_", $name);
    $name = preg_replace("/\\.\\w+\$/", "", $name);
    if (!$useIM) {
        $size = getimagesize($tmpname);
        switch ($size[2]) {
            case IMAGETYPE_PNG:
                $imgtype = "png";
                break;
            case IMAGETYPE_GIF:
                $imgtype = "gif";
                break;
            case IMAGETYPE_JPEG:
                $imgtype = "jpeg";
                break;
            default:
                return 0;
        }
        $action = "imagecreatefrom{$imgtype}";
        if (!($image = $action($tmpname))) {
            return 0;
        }
    } else {
        if (!preg_match("/^\\S+ ([A-Z0-9]+) \\d+x\\d+\\S+ .*\$/", exec("identify {$tmpname}"), $matches)) {
            err_inf("Not an supported image");
            return 0;
        }
        $imgtype = strtolower($matches[1]);
    }
    $name = "{$name}.{$imgtype}";
    if (!in_array($imgtype, array('png', 'jpeg', 'gif', 'tiff'))) {
        return 0;
    }
    do {
        $pref = gen_id();
    } while (is_file("{$nImgPrefix}/{$pref}/{$name}"));
    $name = "{$pref}/{$name}";
    if (!is_dir("{$nImgPrefix}/{$pref}")) {
        mkdir_perms("{$nImgPrefix}/{$pref}", 0755);
    }
    if (!is_dir("{$nImgPrefix}/html/{$pref}")) {
        mkdir_perms("{$nImgPrefix}/html/{$pref}", 0755);
    }
    if (!is_dir("{$nImgPrefix}/thumbs/{$pref}")) {
        mkdir_perms("{$nImgPrefix}/thumbs/{$pref}", 0755);
    }
    move_uploaded_file($tmpname, "{$nImgPrefix}/{$name}");
    if (!$useIM) {
        if (imagesx($image) > $thumbwidth) {
            $thumb = imagecreatetruecolor($thumbwidth, imagesy($image) * $thumbwidth / imagesx($image));
            imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumbwidth, imagesy($image) * $thumbwidth / imagesx($image), imagesx($image), imagesy($image));
        } else {
            $thumb = $image;
        }
        $action = "image{$imgtype}";
        $action($thumb, "{$nImgPrefix}/thumbs/{$name}");
    } else {
        exec("convert -size " . $thumbwidth . "x" . $thumbheight . " {$nImgPrefix}/{$name} -resize " . $thumbwidth . "x" . $thumbheight . " +profile \"*\" {$nImgPrefix}/thumbs/{$name}");
    }
    chmod("{$nImgPrefix}/{$name}", 0755) or $fail = 1;
    chmod("{$nImgPrefix}/thumbs/{$name}", 0755) or $fail = 1;
    return $name;
}