Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

takeedit.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?
  2. /*********************************************************************\
  3. The page that handles the backend of the 'edit artist' function.
  4. \*********************************************************************/
  5. authorize();
  6. if (!$_REQUEST['artistid'] || !is_number($_REQUEST['artistid'])) {
  7. error(404);
  8. }
  9. if (!check_perms('site_edit_wiki')) {
  10. error(403);
  11. }
  12. // Variables for database input
  13. $UserID = $LoggedUser['ID'];
  14. $ArtistID = $_REQUEST['artistid'];
  15. if ($_GET['action'] === 'revert') { // if we're reverting to a previous revision
  16. authorize();
  17. $RevisionID = $_GET['revisionid'];
  18. if (!is_number($RevisionID)) {
  19. error(0);
  20. }
  21. } else { // with edit, the variables are passed with POST
  22. $Body = db_string($_POST['body']);
  23. $Summary = db_string($_POST['summary']);
  24. $Image = db_string($_POST['image']);
  25. ImageTools::blacklisted($Image);
  26. // Trickery
  27. if (!preg_match("/^".IMAGE_REGEX."$/i", $Image)) {
  28. $Image = '';
  29. }
  30. }
  31. // Insert revision
  32. if (!$RevisionID) { // edit
  33. $DB->query("
  34. INSERT INTO wiki_artists
  35. (PageID, Body, Image, UserID, Summary, Time)
  36. VALUES
  37. ('$ArtistID', '$Body', '$Image', '$UserID', '$Summary', '".sqltime()."')");
  38. } else { // revert
  39. $DB->query("
  40. INSERT INTO wiki_artists (PageID, Body, Image, UserID, Summary, Time)
  41. SELECT '$ArtistID', Body, Image, '$UserID', 'Reverted to revision $RevisionID', '".sqltime()."'
  42. FROM wiki_artists
  43. WHERE RevisionID = '$RevisionID'");
  44. }
  45. $RevisionID = $DB->inserted_id();
  46. // Update artists table (technically, we don't need the RevisionID column, but we can use it for a join which is nice and fast)
  47. $DB->query("
  48. UPDATE artists_group
  49. SET
  50. RevisionID = '$RevisionID'
  51. WHERE ArtistID = '$ArtistID'");
  52. // There we go, all done!
  53. $Cache->delete_value("artist_$ArtistID"); // Delete artist cache
  54. header("Location: artist.php?id=$ArtistID");
  55. ?>