summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorFredrick Brennan <admin@8chan.co>2015-08-23 09:04:37 +0800
committerczaks <marcin@6irc.net>2016-05-06 15:12:08 +0200
commitb476b660073adbe827836a7e7860b0fb3a061ff0 (patch)
treea867863c39eb1254e59d9c07d3734bd8ce7f1622 /inc
parent2fa37278db9ad0e802a2b4c6a54c5d179ce6df35 (diff)
[BUG] Image reject repost board option now also affects YT embeds
Diffstat (limited to 'inc')
-rwxr-xr-xinc/functions.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/inc/functions.php b/inc/functions.php
index d28d018d..cbe0bc62 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -2438,6 +2438,53 @@ function getPostByHashInThread($hash, $thread) {
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) {
if (!$post['has_file'] || !isset($post['files']))
return;