BioTorrents.de’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.

collages.class.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. #declare(strict_types=1);
  3. class Collages
  4. {
  5. public static function increase_subscriptions($CollageID)
  6. {
  7. $QueryID = G::$DB->get_query_id();
  8. G::$DB->query("
  9. UPDATE
  10. `collages`
  11. SET
  12. `Subscribers` = `Subscribers` + 1
  13. WHERE
  14. `ID` = '$CollageID'
  15. ");
  16. G::$DB->set_query_id($QueryID);
  17. }
  18. public static function decrease_subscriptions($CollageID)
  19. {
  20. $QueryID = G::$DB->get_query_id();
  21. G::$DB->query("
  22. UPDATE
  23. `collages`
  24. SET
  25. `Subscribers` = IF(
  26. `Subscribers` < 1,
  27. 0,
  28. `Subscribers` - 1
  29. )
  30. WHERE
  31. `ID` = '$CollageID'
  32. ");
  33. G::$DB->set_query_id($QueryID);
  34. }
  35. public static function create_personal_collage()
  36. {
  37. G::$DB->query("
  38. SELECT
  39. COUNT(`ID`)
  40. FROM
  41. `collages`
  42. WHERE
  43. `UserID` = '".G::$LoggedUser['ID']."' AND `CategoryID` = '0' AND `Deleted` = '0'
  44. ");
  45. list($CollageCount) = G::$DB->next_record();
  46. if ($CollageCount >= G::$LoggedUser['Permissions']['MaxCollages']) {
  47. // todo: Fix this, the query was for COUNT(ID), so I highly doubt that this works... - Y
  48. list($CollageID) = G::$DB->next_record();
  49. header("Location: collage.php?id=$CollageID");
  50. error();
  51. }
  52. $NameStr = db_string(G::$LoggedUser['Username']."'s personal collage".($CollageCount > 0 ? ' no. '.($CollageCount + 1) : ''));
  53. $Description = db_string('Personal collage for '.G::$LoggedUser['Username'].'. The first 5 albums will appear on his or her [url='.site_url().'user.php?id= '.G::$LoggedUser['ID'].']profile[/url].');
  54. G::$DB->query("
  55. INSERT INTO `collages`(
  56. `Name`,
  57. `Description`,
  58. `CategoryID`,
  59. `UserID`
  60. )
  61. VALUES(
  62. '$NameStr',
  63. '$Description',
  64. '0',
  65. ".G::$LoggedUser['ID']."
  66. )
  67. ");
  68. $CollageID = G::$DB->inserted_id();
  69. header("Location: collage.php?id=$CollageID");
  70. error();
  71. }
  72. }