mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-28 09:20:58 +01:00
fixed bug when posting an image and getting muted
This commit is contained in:
parent
c4f078346f
commit
d3a30b93b4
@ -220,7 +220,11 @@
|
|||||||
|
|
||||||
function purge($uri) {
|
function purge($uri) {
|
||||||
global $config;
|
global $config;
|
||||||
|
if(preg_match($config['url_match'], $config['root'])) {
|
||||||
$uri = (str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) == '/' ? '/' : str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) . '/') . $uri;
|
$uri = (str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) == '/' ? '/' : str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) . '/') . $uri;
|
||||||
|
} else {
|
||||||
|
$uri = $config['root'] . $uri;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($config['purge'] as &$purge) {
|
foreach($config['purge'] as &$purge) {
|
||||||
$host = $purge[0];
|
$host = $purge[0];
|
||||||
@ -234,7 +238,6 @@
|
|||||||
// Cannot connect?
|
// Cannot connect?
|
||||||
error('Could not PURGE for ' . $host);
|
error('Could not PURGE for ' . $host);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +252,7 @@
|
|||||||
$command = 'scp ' . escapeshellarg($file) . ' ' . escapeshellarg($m[1]);
|
$command = 'scp ' . escapeshellarg($file) . ' ' . escapeshellarg($m[1]);
|
||||||
system($command);
|
system($command);
|
||||||
// Delete temporary file
|
// Delete temporary file
|
||||||
unlink($file);
|
file_unlink($file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,6 +288,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function file_unlink($path) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
@unlink($path);
|
||||||
|
if(isset($config['purge']) && isset($_SERVER['HTTP_HOST'])) {
|
||||||
|
// Purge cache
|
||||||
|
if(basename($path) == $config['file_index']) {
|
||||||
|
// Index file (/index.html); purge "/" as well
|
||||||
|
$uri = dirname($path);
|
||||||
|
// root
|
||||||
|
if($uri == '.')
|
||||||
|
$uri = '';
|
||||||
|
else
|
||||||
|
$uri .= '/';
|
||||||
|
purge($uri);
|
||||||
|
}
|
||||||
|
purge($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function listBoards() {
|
function listBoards() {
|
||||||
$query = query("SELECT * FROM `boards` ORDER BY `uri`") or error(db_error());
|
$query = query("SELECT * FROM `boards` ORDER BY `uri`") or error(db_error());
|
||||||
$boards = $query->fetchAll();
|
$boards = $query->fetchAll();
|
||||||
@ -586,10 +609,10 @@
|
|||||||
$query->bindValue(':file', null, PDO::PARAM_NULL);
|
$query->bindValue(':file', null, PDO::PARAM_NULL);
|
||||||
} else {
|
} else {
|
||||||
// Delete thumbnail
|
// Delete thumbnail
|
||||||
@unlink($board['dir'] . $config['dir']['thumb'] . $post['thumb']);
|
file_unlink($board['dir'] . $config['dir']['thumb'] . $post['thumb']);
|
||||||
|
|
||||||
// Delete file
|
// Delete file
|
||||||
@unlink($board['dir'] . $config['dir']['img'] . $post['file']);
|
file_unlink($board['dir'] . $config['dir']['img'] . $post['file']);
|
||||||
|
|
||||||
// Set file to 'deleted'
|
// Set file to 'deleted'
|
||||||
$query->bindValue(':file', 'deleted', PDO::PARAM_INT);
|
$query->bindValue(':file', 'deleted', PDO::PARAM_INT);
|
||||||
@ -621,18 +644,18 @@
|
|||||||
while($post = $query->fetch()) {
|
while($post = $query->fetch()) {
|
||||||
if(!$post['thread']) {
|
if(!$post['thread']) {
|
||||||
// Delete thread HTML page
|
// Delete thread HTML page
|
||||||
@unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['id']));
|
file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['id']));
|
||||||
} elseif($query->rowCount() == 1) {
|
} elseif($query->rowCount() == 1) {
|
||||||
// Rebuild thread
|
// Rebuild thread
|
||||||
$rebuild = $post['thread'];
|
$rebuild = $post['thread'];
|
||||||
}
|
}
|
||||||
if($post['thumb']) {
|
if($post['thumb']) {
|
||||||
// Delete thumbnail
|
// Delete thumbnail
|
||||||
@unlink($board['dir'] . $config['dir']['thumb'] . $post['thumb']);
|
file_unlink($board['dir'] . $config['dir']['thumb'] . $post['thumb']);
|
||||||
}
|
}
|
||||||
if($post['file']) {
|
if($post['file']) {
|
||||||
// Delete file
|
// Delete file
|
||||||
@unlink($board['dir'] . $config['dir']['img'] . $post['file']);
|
file_unlink($board['dir'] . $config['dir']['img'] . $post['file']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1056,7 +1079,7 @@
|
|||||||
if($page < $config['max_pages']) {
|
if($page < $config['max_pages']) {
|
||||||
for(;$page<=$config['max_pages'];$page++) {
|
for(;$page<=$config['max_pages'];$page++) {
|
||||||
$filename = $page==1 ? $config['file_index'] : sprintf($config['file_page'], $page);
|
$filename = $page==1 ? $config['file_index'] : sprintf($config['file_page'], $page);
|
||||||
@unlink($filename);
|
file_unlink($filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1354,7 +1377,7 @@
|
|||||||
if (filetype($dir."/".$object) == "dir")
|
if (filetype($dir."/".$object) == "dir")
|
||||||
rrmdir($dir."/".$object);
|
rrmdir($dir."/".$object);
|
||||||
else
|
else
|
||||||
unlink($dir."/".$object);
|
file_unlink($dir."/".$object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reset($objects);
|
reset($objects);
|
||||||
@ -1528,9 +1551,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function undoImage($post) {
|
function undoImage($post) {
|
||||||
if($post['has_file'])
|
if($post['has_file']) {
|
||||||
@unlink($post['file']);
|
if(isset($post['thumb']))
|
||||||
@unlink($post['thumb']);
|
file_unlink($post['file']);
|
||||||
|
if(isset($post['thumb']))
|
||||||
|
file_unlink($post['thumb']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createimage($type, $source_pic) {
|
function createimage($type, $source_pic) {
|
||||||
@ -1541,26 +1567,26 @@
|
|||||||
case 'jpg':
|
case 'jpg':
|
||||||
case 'jpeg':
|
case 'jpeg':
|
||||||
if(!$image = @imagecreatefromjpeg($source_pic)) {
|
if(!$image = @imagecreatefromjpeg($source_pic)) {
|
||||||
unlink($source_pic);
|
file_unlink($source_pic);
|
||||||
error($config['error']['invalidimg']);
|
error($config['error']['invalidimg']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'png':
|
case 'png':
|
||||||
if(!$image = @imagecreatefrompng($source_pic)) {
|
if(!$image = @imagecreatefrompng($source_pic)) {
|
||||||
unlink($source_pic);
|
file_unlink($source_pic);
|
||||||
error($config['error']['invalidimg']);
|
error($config['error']['invalidimg']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'gif':
|
case 'gif':
|
||||||
if(!$image = @imagecreatefromgif($source_pic)) {
|
if(!$image = @imagecreatefromgif($source_pic)) {
|
||||||
unlink($source_pic);
|
file_unlink($source_pic);
|
||||||
error($config['error']['invalidimg']);
|
error($config['error']['invalidimg']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'bmp':
|
case 'bmp':
|
||||||
if(!$image = @imagecreatefrombmp($source_pic)) {
|
if(!$image = @imagecreatefrombmp($source_pic)) {
|
||||||
unlink($source_pic);
|
unlink($source_pic);
|
||||||
error($config['error']['invalidimg']);
|
file_unlink($config['error']['invalidimg']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user