forked from GithubBackups/vichan
Config: add a thing for clustered installations
This commit is contained in:
parent
4238249af6
commit
fbdb72994a
@ -425,12 +425,12 @@ function setupBoard($array) {
|
||||
|
||||
if (!file_exists($board['dir']))
|
||||
@mkdir($board['dir'], 0777) or error("Couldn't create " . $board['dir'] . ". Check permissions.", true);
|
||||
if (!file_exists($board['dir'] . $config['dir']['img']))
|
||||
@mkdir($board['dir'] . $config['dir']['img'], 0777)
|
||||
or error("Couldn't create " . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true);
|
||||
if (!file_exists($board['dir'] . $config['dir']['thumb']))
|
||||
@mkdir($board['dir'] . $config['dir']['thumb'], 0777)
|
||||
or error("Couldn't create " . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true);
|
||||
if (!file_exists($config['dir']['img_root'] . $board['dir'] . $config['dir']['img']))
|
||||
@mkdir($config['dir']['img_root'] . $board['dir'] . $config['dir']['img'], 0777)
|
||||
or error("Couldn't create " . $config['dir']['img_root'] . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true);
|
||||
if (!file_exists($config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb']))
|
||||
@mkdir($config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb'], 0777)
|
||||
or error("Couldn't create " . $config['dir']['img_root'] . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true);
|
||||
if (!file_exists($board['dir'] . $config['dir']['res']))
|
||||
@mkdir($board['dir'] . $config['dir']['res'], 0777)
|
||||
or error("Couldn't create " . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true);
|
||||
@ -997,11 +997,11 @@ function deleteFile($id, $remove_entirely_if_already=true, $file=null) {
|
||||
foreach ($files as $i => $f) {
|
||||
if (($file !== false && $i == $file) || $file === null) {
|
||||
// Delete thumbnail
|
||||
file_unlink($board['dir'] . $config['dir']['thumb'] . $f->thumb);
|
||||
file_unlink($config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb'] . $f->thumb);
|
||||
unset($files[$i]->thumb);
|
||||
|
||||
// Delete file
|
||||
file_unlink($board['dir'] . $config['dir']['img'] . $f->file);
|
||||
file_unlink($config['dir']['img_root'] . $board['dir'] . $config['dir']['img'] . $f->file);
|
||||
$files[$i]->file = 'deleted';
|
||||
}
|
||||
}
|
||||
@ -1080,8 +1080,8 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) {
|
||||
// Delete file
|
||||
foreach (json_decode($post['files']) as $i => $f) {
|
||||
if ($f->file !== 'deleted') {
|
||||
file_unlink($board['dir'] . $config['dir']['img'] . $f->file);
|
||||
file_unlink($board['dir'] . $config['dir']['thumb'] . $f->thumb);
|
||||
file_unlink($config['dir']['img_root'] . $board['dir'] . $config['dir']['img'] . $f->file);
|
||||
file_unlink($config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb'] . $f->thumb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1121,8 +1121,8 @@ function mod_move_reply($originBoard, $postID) {
|
||||
$post['files'] = json_decode($post['files'], TRUE);
|
||||
$post['has_file'] = true;
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
$file['file_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file'];
|
||||
$file['thumb_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb'];
|
||||
$file['file_path'] = sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['img'] . $file['file'];
|
||||
$file['thumb_path'] = sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['thumb'] . $file['thumb'];
|
||||
}
|
||||
} else {
|
||||
$post['has_file'] = false;
|
||||
@ -1140,9 +1140,9 @@ function mod_move_reply($originBoard, $postID) {
|
||||
if ($post['has_file']) {
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
// move the image
|
||||
rename($file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||
rename($file['file_path'], sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||
if ($file['thumb'] != 'spoiler') { //trying to move/copy the spoiler thumb raises an error
|
||||
rename($file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||
rename($file['thumb_path'], sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1222,8 +1222,8 @@ function mod_move($originBoard, $postID) {
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
if ($file['file'] === 'deleted')
|
||||
continue;
|
||||
$file['file_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file'];
|
||||
$file['thumb_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb'];
|
||||
$file['file_path'] = sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['img'] . $file['file'];
|
||||
$file['thumb_path'] = sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['thumb'] . $file['thumb'];
|
||||
}
|
||||
} else {
|
||||
$post['has_file'] = false;
|
||||
@ -1242,9 +1242,9 @@ function mod_move($originBoard, $postID) {
|
||||
// copy image
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
if ($file['file'] !== 'deleted')
|
||||
$clone($file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||
$clone($file['file_path'], sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||
if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file')))
|
||||
$clone($file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||
$clone($file['thumb_path'], sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1265,8 +1265,8 @@ function mod_move($originBoard, $postID) {
|
||||
$post['files'] = json_decode($post['files'], TRUE);
|
||||
$post['has_file'] = true;
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
$file['file_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file'];
|
||||
$file['thumb_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb'];
|
||||
$file['file_path'] = sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['img'] . $file['file'];
|
||||
$file['thumb_path'] = sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['thumb'] . $file['thumb'];
|
||||
}
|
||||
} else {
|
||||
$post['has_file'] = false;
|
||||
@ -1305,8 +1305,8 @@ function mod_move($originBoard, $postID) {
|
||||
if ($post['has_file']) {
|
||||
// copy image
|
||||
foreach ($post['files'] as $i => &$file) {
|
||||
$clone($file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||
$clone($file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||
$clone($file['file_path'], sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['img'] . $file['file']);
|
||||
$clone($file['thumb_path'], sprintf($config['board_path'], $config['dir']['img_root'] . $board['uri']) . $config['dir']['thumb'] . $file['thumb']);
|
||||
}
|
||||
}
|
||||
// insert reply
|
||||
@ -1582,7 +1582,7 @@ function mod_spoiler_image($board, $post, $file) {
|
||||
$result = $query->fetch(PDO::FETCH_ASSOC);
|
||||
$files = json_decode($result['files']);
|
||||
|
||||
file_unlink($board . '/' . $config['dir']['thumb'] . $files[$file]->thumb);
|
||||
file_unlink($config['dir']['img_root'] . $board . '/' . $config['dir']['thumb'] . $files[$file]->thumb);
|
||||
$files[$file]->thumb = 'spoiler';
|
||||
$files[$file]->thumbheight = 128;
|
||||
$files[$file]->thumbwidth = 128;
|
||||
|
8
post.php
8
post.php
@ -445,8 +445,8 @@ if (isset($_POST['delete'])) {
|
||||
if (sizeof($_FILES) > 1)
|
||||
$file['file_id'] .= "-$i";
|
||||
|
||||
$file['file'] = $board['dir'] . $config['dir']['img'] . $file['file_id'] . '.' . $file['extension'];
|
||||
$file['thumb'] = $board['dir'] . $config['dir']['thumb'] . $file['file_id'] . '.' . ($config['thumb_ext'] ? $config['thumb_ext'] : $file['extension']);
|
||||
$file['file'] = $config['dir']['img_root'] . $board['dir'] . $config['dir']['img'] . $file['file_id'] . '.' . $file['extension'];
|
||||
$file['thumb'] = $config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb'] . $file['file_id'] . '.' . ($config['thumb_ext'] ? $config['thumb_ext'] : $file['extension']);
|
||||
$post['files'][] = $file;
|
||||
$i++;
|
||||
}
|
||||
@ -771,9 +771,9 @@ if (isset($_POST['delete'])) {
|
||||
foreach ($post['files'] as $key => &$file) {
|
||||
$file['file_path'] = $file['file'];
|
||||
$file['thumb_path'] = $file['thumb'];
|
||||
$file['file'] = mb_substr($file['file'], mb_strlen($board['dir'] . $config['dir']['img']));
|
||||
$file['file'] = mb_substr($file['file'], mb_strlen($config['dir']['img_root'] . $board['dir'] . $config['dir']['img']));
|
||||
if ($file['is_an_image'] && $file['thumb'] != 'spoiler')
|
||||
$file['thumb'] = mb_substr($file['thumb'], mb_strlen($board['dir'] . $config['dir']['thumb']));
|
||||
$file['thumb'] = mb_substr($file['thumb'], mb_strlen($config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb']));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user