pull a bunch of small fixes from #659
This commit is contained in:
@ -37,9 +37,9 @@ class BulkAdd extends Extension
|
||||
set_time_limit(0);
|
||||
$bae = new BulkAddEvent($_POST['dir']);
|
||||
send_event($bae);
|
||||
foreach ($bae->results as $result) {
|
||||
$this->theme->add_status("Adding files", $result);
|
||||
}
|
||||
foreach ($bae->results as $result) {
|
||||
$this->theme->add_status("Adding files", $result);
|
||||
}
|
||||
$this->theme->display_upload_results($page);
|
||||
}
|
||||
}
|
||||
|
@ -64,12 +64,11 @@ class BulkAddCSV extends Extension
|
||||
assert(file_exists($tmpname));
|
||||
|
||||
$pathinfo = pathinfo($filename);
|
||||
if (!array_key_exists('extension', $pathinfo)) {
|
||||
throw new UploadException("File has no extension");
|
||||
}
|
||||
$metadata = [];
|
||||
$metadata['filename'] = $pathinfo['basename'];
|
||||
$metadata['extension'] = $pathinfo['extension'];
|
||||
if (array_key_exists('extension', $pathinfo)) {
|
||||
$metadata['extension'] = $pathinfo['extension'];
|
||||
}
|
||||
$metadata['tags'] = Tag::explode($tags);
|
||||
$metadata['source'] = $source;
|
||||
$event = new DataUploadEvent($tmpname, $metadata);
|
||||
|
@ -274,7 +274,7 @@ class CronUploader extends Extension
|
||||
} catch (Exception $e) {
|
||||
$this->move_uploaded($img[0], $img[1], true);
|
||||
if (strpos($e->getMessage(), 'SQLSTATE') !== false) {
|
||||
// Postgres invalidates the transaction if there is an SQL error,
|
||||
// Postgres invalidates the transaction if there is an SQL error,
|
||||
// so all subsequence transactions will fail.
|
||||
break;
|
||||
}
|
||||
@ -296,20 +296,20 @@ class CronUploader extends Extension
|
||||
|
||||
$relativeDir = dirname(substr($path, strlen($this->root_dir) + 7));
|
||||
|
||||
// Determine which dir to move to
|
||||
if ($corrupt) {
|
||||
// Move to corrupt dir
|
||||
$newDir .= "/failed_to_upload/".$relativeDir;
|
||||
$info = "ERROR: Image was not uploaded.";
|
||||
}
|
||||
else {
|
||||
$newDir .= "/uploaded/".$relativeDir;
|
||||
$info = "Image successfully uploaded. ";
|
||||
}
|
||||
$newDir = str_replace ( "//", "/", $newDir."/" );
|
||||
// Determine which dir to move to
|
||||
if ($corrupt) {
|
||||
// Move to corrupt dir
|
||||
$newDir .= "/failed_to_upload/".$relativeDir;
|
||||
$info = "ERROR: Image was not uploaded.";
|
||||
} else {
|
||||
$newDir .= "/uploaded/".$relativeDir;
|
||||
$info = "Image successfully uploaded. ";
|
||||
}
|
||||
$newDir = str_replace("//", "/", $newDir."/");
|
||||
|
||||
if (!is_dir($newDir))
|
||||
mkdir ( $newDir, 0775, true );
|
||||
if (!is_dir($newDir)) {
|
||||
mkdir($newDir, 0775, true);
|
||||
}
|
||||
|
||||
// move file to correct dir
|
||||
rename($path, $newDir.$filename);
|
||||
@ -325,13 +325,12 @@ class CronUploader extends Extension
|
||||
assert(file_exists($tmpname));
|
||||
|
||||
$pathinfo = pathinfo($filename);
|
||||
if (! array_key_exists('extension', $pathinfo)) {
|
||||
throw new UploadException("File has no extension");
|
||||
}
|
||||
$metadata = [];
|
||||
$metadata ['filename'] = $pathinfo ['basename'];
|
||||
$metadata ['extension'] = $pathinfo ['extension'];
|
||||
$metadata ['tags'] = Tag::explode($tags);
|
||||
if (array_key_exists('extension', $pathinfo)) {
|
||||
$metadata['extension'] = $pathinfo['extension'];
|
||||
}
|
||||
$metadata ['tags'] = Tag::explode($tags);
|
||||
$metadata ['source'] = null;
|
||||
$event = new DataUploadEvent($tmpname, $metadata);
|
||||
send_event($event);
|
||||
@ -344,7 +343,6 @@ class CronUploader extends Extension
|
||||
$infomsg = "Image uploaded. ID: {$event->image_id} - Filename: {$filename} - Tags: {$tags}";
|
||||
}
|
||||
$msgNumber = $this->add_upload_info($infomsg);
|
||||
|
||||
}
|
||||
|
||||
private function generate_image_queue(): void
|
||||
@ -361,7 +359,7 @@ class CronUploader extends Extension
|
||||
if (!is_link($fullpath) && !is_dir($fullpath)) {
|
||||
$pathinfo = pathinfo($fullpath);
|
||||
|
||||
$relativePath = substr($fullpath,strlen($base));
|
||||
$relativePath = substr($fullpath, strlen($base));
|
||||
$tags = path_to_tags($relativePath);
|
||||
|
||||
$img = [
|
||||
|
@ -366,7 +366,9 @@ class DanbooruApi extends Extension
|
||||
$fileinfo = pathinfo($filename);
|
||||
$metadata = [];
|
||||
$metadata['filename'] = $fileinfo['basename'];
|
||||
$metadata['extension'] = $fileinfo['extension'];
|
||||
if (array_key_exists('extension', $pathinfo)) {
|
||||
$metadata['extension'] = $pathinfo['extension'];
|
||||
}
|
||||
$metadata['tags'] = $posttags;
|
||||
$metadata['source'] = $source;
|
||||
//log_debug("danbooru_api","========== NEW($filename) =========");
|
||||
|
@ -362,8 +362,8 @@ class PoolsTheme extends Themelet
|
||||
} elseif ($history['action'] == 0) {
|
||||
$prefix = "-";
|
||||
} else {
|
||||
throw new Exception("history['action'] not in {0, 1}");
|
||||
}
|
||||
throw new Exception("history['action'] not in {0, 1}");
|
||||
}
|
||||
|
||||
$images = trim($history['images']);
|
||||
$images = explode(" ", $images);
|
||||
|
@ -155,12 +155,9 @@ class RotateImage extends Extension
|
||||
|
||||
|
||||
/* Attempt to load the image */
|
||||
switch ($info[2]) {
|
||||
case IMAGETYPE_GIF: $image = imagecreatefromgif($image_filename); break;
|
||||
case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($image_filename); break;
|
||||
case IMAGETYPE_PNG: $image = imagecreatefrompng($image_filename); break;
|
||||
default:
|
||||
throw new ImageRotateException("Unsupported image type or ");
|
||||
$image = imagecreatefromstring(file_get_contents($image_filename));
|
||||
if ($image == false) {
|
||||
throw new ImageRotateException("Could not load image: ".$image_filename);
|
||||
}
|
||||
|
||||
/* Rotate and resample the image */
|
||||
|
@ -123,8 +123,8 @@ class Rule34 extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("admin"));
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("admin"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ class TagEditCloud extends Extension
|
||||
|
||||
$ignore_tags = Tag::explode($config->get_string("tageditcloud_ignoretags"));
|
||||
|
||||
$cat_color = [];
|
||||
$cat_color = [];
|
||||
if (ext_is_live("TagCategories")) {
|
||||
$categories = $database->get_all("SELECT category, color FROM image_tag_categories");
|
||||
foreach ($categories as $row) {
|
||||
|
@ -307,7 +307,9 @@ class Upload extends Extension
|
||||
$pathinfo = pathinfo($file['name']);
|
||||
$metadata = [];
|
||||
$metadata['filename'] = $pathinfo['basename'];
|
||||
$metadata['extension'] = $pathinfo['extension'];
|
||||
if (array_key_exists('extension', $pathinfo)) {
|
||||
$metadata['extension'] = $pathinfo['extension'];
|
||||
}
|
||||
$metadata['tags'] = $tags;
|
||||
$metadata['source'] = $source;
|
||||
|
||||
@ -389,7 +391,7 @@ class Upload extends Extension
|
||||
|
||||
$ext = false;
|
||||
if (is_array($headers)) {
|
||||
$ext = getExtension(findHeader($headers, 'Content-Type'));
|
||||
$ext = get_extension(findHeader($headers, 'Content-Type'));
|
||||
}
|
||||
if ($ext === false) {
|
||||
$ext = $pathinfo['extension'];
|
||||
@ -411,8 +413,8 @@ class Upload extends Extension
|
||||
$metadata['replace'] = $replace;
|
||||
}
|
||||
|
||||
$event = new DataUploadEvent($tmp_filename, $metadata);
|
||||
try {
|
||||
$event = new DataUploadEvent($tmp_filename, $metadata);
|
||||
send_event($event);
|
||||
} catch (UploadException $ex) {
|
||||
$this->theme->display_upload_error(
|
||||
|
@ -491,8 +491,8 @@ class Wiki extends Extension
|
||||
return "--- $value\n";
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("stat needs to be =, + or -");
|
||||
default:
|
||||
throw new Exception("stat needs to be =, + or -");
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
Reference in New Issue
Block a user