build warehouse directories on demand
This commit is contained in:
parent
d0d3e72b74
commit
7a5be72cbd
@ -8,6 +8,7 @@
|
||||
class FlashFileHandler extends DataHandlerExtension {
|
||||
protected function create_thumb($hash) {
|
||||
// FIXME: scale image, as not all boards use 192x192
|
||||
mkdir(dirname(warehouse_path("thumbs", $hash)), 0755, true);
|
||||
copy("ext/handle_flash/thumb.jpg", warehouse_path("thumbs", $hash));
|
||||
}
|
||||
|
||||
|
@ -99,6 +99,7 @@ class IcoFileHandler extends SimpleExtension {
|
||||
$q = $config->get_int("thumb_quality");
|
||||
$mem = $config->get_int("thumb_max_memory") / 1024 / 1024; // IM takes memory in MB
|
||||
|
||||
mkdir(dirname($outname), 0755, true);
|
||||
if($config->get_bool("ico_convert")) {
|
||||
// "-limit memory $mem" broken?
|
||||
exec("convert {$inname}[0] -geometry {$w}x{$h} -quality {$q} jpg:$outname");
|
||||
|
@ -8,6 +8,7 @@
|
||||
class MP3FileHandler extends DataHandlerExtension {
|
||||
protected function create_thumb($hash) {
|
||||
// FIXME: scale image, as not all boards use 192x192
|
||||
mkdir(dirname(warehouse_path("thumbs", $hash)), 0755, true);
|
||||
copy("ext/handle_mp3/thumb.jpg", warehouse_path("thumbs", $hash));
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ class SVGFileHandler implements Extension {
|
||||
// }
|
||||
// else {
|
||||
// FIXME: scale image, as not all boards use 192x192
|
||||
mkdir(dirname(warehouse_path("thumbs", $hash)), 0755, true);
|
||||
copy("ext/handle_svg/thumb.jpg", warehouse_path("thumbs", $hash));
|
||||
// }
|
||||
}
|
||||
|
@ -949,6 +949,7 @@ class Tag {
|
||||
*/
|
||||
function move_upload_to_archive($event) {
|
||||
$target = warehouse_path("images", $event->hash);
|
||||
mkdir(dirname($target), 0755, true);
|
||||
if(!@copy($event->tmpname, $target)) {
|
||||
throw new UploadException("Failed to copy file from uploads ({$event->tmpname}) to archive ($target)");
|
||||
return false;
|
||||
|
@ -48,6 +48,7 @@ class PixelFileHandler extends DataHandlerExtension {
|
||||
|
||||
$ok = false;
|
||||
|
||||
mkdir(dirname($outname), 0755, true);
|
||||
switch($config->get_string("thumb_engine")) {
|
||||
default:
|
||||
case 'gd':
|
||||
|
30
install.php
30
install.php
@ -149,9 +149,9 @@ function begin() { // {{{
|
||||
EOD;
|
||||
} // }}}
|
||||
function install_process($database_dsn) { // {{{
|
||||
build_dirs();
|
||||
create_tables($database_dsn);
|
||||
insert_defaults($database_dsn);
|
||||
build_dirs();
|
||||
write_config($database_dsn);
|
||||
|
||||
header("Location: index.php");
|
||||
@ -266,34 +266,26 @@ function insert_defaults($dsn) { // {{{
|
||||
}
|
||||
} // }}}
|
||||
function build_dirs() { // {{{
|
||||
if(!file_exists("images")) @mkdir("images"); // *try* and make default dirs. Ignore any errors --
|
||||
if(!file_exists("thumbs")) @mkdir("thumbs"); // if something is amiss, we'll tell the user later
|
||||
if(!file_exists("data")) @mkdir("data");
|
||||
// *try* and make default dirs. Ignore any errors --
|
||||
// if something is amiss, we'll tell the user later
|
||||
if(!file_exists("images")) @mkdir("images");
|
||||
if(!file_exists("thumbs")) @mkdir("thumbs");
|
||||
if(!file_exists("data") ) @mkdir("data");
|
||||
if(!is_writable("images")) @chmod("images", 0755);
|
||||
if(!is_writable("thumbs")) @chmod("thumbs", 0755);
|
||||
if(!is_writable("data") ) @chmod("data", 0755);
|
||||
|
||||
if(
|
||||
((!file_exists("images") || !file_exists("thumbs") || !file_exists("data")) && !is_writable("./")) ||
|
||||
(!is_writable("images") || !is_writable("thumbs") || !is_writable("data"))
|
||||
!file_exists("images") || !file_exists("thumbs") || !file_exists("data") ||
|
||||
!is_writable("images") || !is_writable("thumbs") || !is_writable("data")
|
||||
) {
|
||||
print "Shimmie needs three folders in it's directory, 'images', 'thumbs', and 'data',
|
||||
and they need to be writable by the PHP user (if you see this error,
|
||||
if probably means the folders are owned by you, and they need to be
|
||||
writable by the web server).
|
||||
|
||||
<p>Once you have created these folders, hit 'refresh' to continue.";
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
assert(file_exists("images") && is_writable("images"));
|
||||
assert(file_exists("thumbs") && is_writable("thumbs"));
|
||||
assert(file_exists("data") && is_writable("data"));
|
||||
|
||||
if(!file_exists("images/ff")) {
|
||||
for($i=0; $i<256; $i++) {
|
||||
mkdir(sprintf("images/%02x", $i));
|
||||
mkdir(sprintf("thumbs/%02x", $i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} // }}}
|
||||
function write_config($dsn) { // {{{
|
||||
$file_content = "<?php \$database_dsn='$dsn'; ?>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user