2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
/*********************************************************************\
|
2013-02-22 08:00:24 +00:00
|
|
|
The page that handles the backend of the 'edit artist' function.
|
2011-03-28 14:21:28 +00:00
|
|
|
\*********************************************************************/
|
|
|
|
|
|
|
|
authorize();
|
|
|
|
|
2013-05-05 08:00:31 +00:00
|
|
|
if (!$_REQUEST['artistid'] || !is_number($_REQUEST['artistid'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(404);
|
|
|
|
}
|
|
|
|
|
2013-05-05 08:00:31 +00:00
|
|
|
if (!check_perms('site_edit_wiki')) {
|
|
|
|
error(403);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
// Variables for database input
|
|
|
|
$UserID = $LoggedUser['ID'];
|
|
|
|
$ArtistID = $_REQUEST['artistid'];
|
2013-05-05 08:00:31 +00:00
|
|
|
if (check_perms('artist_edit_vanityhouse')) {
|
2013-11-01 08:01:02 +00:00
|
|
|
$VanityHouse = isset($_POST['vanity_house']) ? 1 : 0 ;
|
2011-08-09 21:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-11-01 08:01:02 +00:00
|
|
|
if ($_GET['action'] === 'revert') { // if we're reverting to a previous revision
|
2011-03-28 14:21:28 +00:00
|
|
|
authorize();
|
2013-11-01 08:01:02 +00:00
|
|
|
$RevisionID = $_GET['revisionid'];
|
2013-05-05 08:00:31 +00:00
|
|
|
if (!is_number($RevisionID)) {
|
|
|
|
error(0);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
} else { // with edit, the variables are passed with POST
|
|
|
|
$Body = db_string($_POST['body']);
|
|
|
|
$Summary = db_string($_POST['summary']);
|
|
|
|
$Image = db_string($_POST['image']);
|
2013-02-25 21:16:55 +00:00
|
|
|
ImageTools::blacklisted($Image);
|
2011-03-28 14:21:28 +00:00
|
|
|
// Trickery
|
2013-05-05 08:00:31 +00:00
|
|
|
if (!preg_match("/^".IMAGE_REGEX."$/i", $Image)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$Image = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert revision
|
2013-05-05 08:00:31 +00:00
|
|
|
if (!$RevisionID) { // edit
|
|
|
|
$DB->query("
|
2013-11-01 08:01:02 +00:00
|
|
|
INSERT INTO wiki_artists
|
|
|
|
(PageID, Body, Image, UserID, Summary, Time)
|
|
|
|
VALUES
|
|
|
|
('$ArtistID', '$Body', '$Image', '$UserID', '$Summary', '".sqltime()."')");
|
2011-03-28 14:21:28 +00:00
|
|
|
} else { // revert
|
2013-05-05 08:00:31 +00:00
|
|
|
$DB->query("
|
|
|
|
INSERT INTO wiki_artists (PageID, Body, Image, UserID, Summary, Time)
|
2013-02-22 08:00:24 +00:00
|
|
|
SELECT '$ArtistID', Body, Image, '$UserID', 'Reverted to revision $RevisionID', '".sqltime()."'
|
2013-05-05 08:00:31 +00:00
|
|
|
FROM wiki_artists
|
2013-11-01 08:01:02 +00:00
|
|
|
WHERE RevisionID = '$RevisionID'");
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
2013-05-05 08:00:31 +00:00
|
|
|
$RevisionID = $DB->inserted_id();
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
// Update artists table (technically, we don't need the RevisionID column, but we can use it for a join which is nice and fast)
|
2013-05-05 08:00:31 +00:00
|
|
|
$DB->query("
|
|
|
|
UPDATE artists_group
|
2013-02-22 08:00:24 +00:00
|
|
|
SET
|
2013-11-01 08:01:02 +00:00
|
|
|
". (isset($VanityHouse) ? "VanityHouse = '$VanityHouse'," : '') ."
|
|
|
|
RevisionID = '$RevisionID'
|
|
|
|
WHERE ArtistID = '$ArtistID'");
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
// There we go, all done!
|
2013-11-01 08:01:02 +00:00
|
|
|
$Cache->delete_value("artist_$ArtistID"); // Delete artist cache
|
|
|
|
header("Location: artist.php?id=$ArtistID");
|
2012-07-11 08:00:16 +00:00
|
|
|
?>
|