[BUG] Image reject repost board option now also affects YT embeds
This commit is contained in:
parent
2fa37278db
commit
b476b66007
@ -2438,6 +2438,53 @@ function getPostByHashInThread($hash, $thread) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPostByEmbed($embed) {
|
||||||
|
global $board, $config;
|
||||||
|
$matches = array();
|
||||||
|
foreach ($config['embedding'] as &$e) {
|
||||||
|
if (preg_match($e[0], $embed, $matches) && isset($matches[1]) && !empty($matches[1])) {
|
||||||
|
$embed = '%'.$matches[1].'%';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($embed)) return false;
|
||||||
|
|
||||||
|
$query = prepare(sprintf("SELECT `id`,`thread` FROM ``posts_%s`` WHERE `embed` LIKE :embed", $board['uri']));
|
||||||
|
$query->bindValue(':embed', $embed, PDO::PARAM_STR);
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
if ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
return $post;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPostByEmbedInThread($embed, $thread) {
|
||||||
|
global $board, $config;
|
||||||
|
$matches = array();
|
||||||
|
foreach ($config['embedding'] as &$e) {
|
||||||
|
if (preg_match($e[0], $embed, $matches) && isset($matches[1]) && !empty($matches[1])) {
|
||||||
|
$embed = '%'.$matches[1].'%';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($embed)) return false;
|
||||||
|
|
||||||
|
$query = prepare(sprintf("SELECT `id`,`thread` FROM ``posts_%s`` WHERE `embed` = :embed AND ( `thread` = :thread OR `id` = :thread )", $board['uri']));
|
||||||
|
$query->bindValue(':embed', $embed, PDO::PARAM_STR);
|
||||||
|
$query->bindValue(':thread', $thread, PDO::PARAM_INT);
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
if ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
return $post;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function undoImage(array $post) {
|
function undoImage(array $post) {
|
||||||
if (!$post['has_file'] || !isset($post['files']))
|
if (!$post['has_file'] || !isset($post['files']))
|
||||||
return;
|
return;
|
||||||
|
28
post.php
28
post.php
@ -294,6 +294,32 @@ if (isset($_POST['delete'])) {
|
|||||||
if (!isset($post['embed'])) {
|
if (!isset($post['embed'])) {
|
||||||
error($config['error']['invalid_embed']);
|
error($config['error']['invalid_embed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($config['image_reject_repost']) {
|
||||||
|
if ($p = getPostByEmbed($post['embed'])) {
|
||||||
|
error(sprintf($config['error']['fileexists'],
|
||||||
|
($post['mod'] ? $config['root'] . $config['file_mod'] . '?/' : $config['root']) .
|
||||||
|
($board['dir'] . $config['dir']['res'] .
|
||||||
|
($p['thread'] ?
|
||||||
|
$p['thread'] . '.html#' . $p['id']
|
||||||
|
:
|
||||||
|
$p['id'] . '.html'
|
||||||
|
))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else if (!$post['op'] && $config['image_reject_repost_in_thread']) {
|
||||||
|
if ($p = getPostByEmbedInThread($post['embed'], $post['thread'])) {
|
||||||
|
error(sprintf($config['error']['fileexistsinthread'],
|
||||||
|
($post['mod'] ? $config['root'] . $config['file_mod'] . '?/' : $config['root']) .
|
||||||
|
($board['dir'] . $config['dir']['res'] .
|
||||||
|
($p['thread'] ?
|
||||||
|
$p['thread'] . '.html#' . $p['id']
|
||||||
|
:
|
||||||
|
$p['id'] . '.html'
|
||||||
|
))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPermission($config['mod']['bypass_field_disable'], $board['uri'])) {
|
if (!hasPermission($config['mod']['bypass_field_disable'], $board['uri'])) {
|
||||||
@ -798,7 +824,7 @@ if (isset($_POST['delete'])) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPermission($config['mod']['postunoriginal'], $board['uri']) && $config['robot_enable'] && checkRobot($post['body_nomarkup'])) {
|
if (!hasPermission($config['mod']['postunoriginal'], $board['uri']) && $config['robot_enable'] && checkRobot($post['body_nomarkup'])) {
|
||||||
undoImage($post);
|
undoImage($post);
|
||||||
|
Loading…
Reference in New Issue
Block a user