Gazelle/sections/torrents/add_cover_art.php

51 lines
1001 B
PHP
Raw Normal View History

2013-05-27 08:00:58 +00:00
<?
authorize();
if (!check_perms('site_edit_wiki')) {
error(403);
}
$UserID = $LoggedUser['ID'];
$GroupID = db_string($_POST['groupid']);
$Summaries = $_POST['summary'];
$Images = $_POST['image'];
$Time = sqltime();
if (!is_number($GroupID) || !$GroupID) {
error(0);
}
if (count($Images) != count($Summaries)) {
error('Missing an image or a summary');
}
$Changed = false;
for ($i = 0; $i < count($Images); $i++) {
$Image = $Images[$i];
$Summary = $Summaries[$i];
if (ImageTools::blacklisted($Image, true) || !preg_match("/^".IMAGE_REGEX."$/i", $Image)) {
continue;
}
// sanitize inputs
$Image = db_string($Image);
$Summary = db_string($Summary);
$DB->query("
2013-07-10 00:08:53 +00:00
INSERT IGNORE INTO cover_art
(GroupID, Image, Summary, UserID, Time)
VALUES
('$GroupID', '$Image', '$Summary', '$UserID', '$Time')");
2013-05-27 08:00:58 +00:00
if ($DB->affected_rows()) {
$Changed = true;
}
}
if ($Changed) {
2013-07-10 00:08:53 +00:00
$Cache->delete_value("torrents_cover_art_$GroupID");
2013-05-27 08:00:58 +00:00
}
header('Location: '.$_SERVER['HTTP_REFERER']);
?>