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.

notify_edit.php 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. #declare(strict_types = 1);
  3. if (!check_perms('site_torrents_notify')) {
  4. error(403);
  5. }
  6. View::show_header(
  7. 'Manage notifications',
  8. 'vendor/jquery.validate.min,form_validate'
  9. ); ?>
  10. <div>
  11. <h2 class="header">
  12. Notify me of all new torrents with&hellip;
  13. </h2>
  14. <div class="linkbox">
  15. <a href="torrents.php?action=notify" class="brackets">View notifications</a>
  16. </div>
  17. <?php
  18. $DB->query("
  19. SELECT
  20. `ID`,
  21. `Label`,
  22. `Artists`,
  23. `NewGroupsOnly`,
  24. `Tags`,
  25. `NotTags`,
  26. `ReleaseTypes`,
  27. `Categories`,
  28. `Formats`,
  29. `Encodings`,
  30. `Media`,
  31. `FromYear`,
  32. `ToYear`,
  33. `Users`
  34. FROM `users_notify_filters`
  35. WHERE `UserID` = $LoggedUser[ID]
  36. ");
  37. $NumFilters = $DB->record_count();
  38. $Notifications = $DB->to_array();
  39. $Notifications[] = array(
  40. 'ID' => false,
  41. 'Label' => '',
  42. 'Artists' => '',
  43. 'NewGroupsOnly' => true,
  44. 'Tags' => '',
  45. 'NotTags' => '',
  46. 'ReleaseTypes' => '',
  47. 'Categories' => '',
  48. 'Formats' => '',
  49. 'Encodings' => '',
  50. 'Media' => '',
  51. 'FromYear' => '',
  52. 'ToYear' => '',
  53. 'Users' => ''
  54. );
  55. $i = 0;
  56. foreach ($Notifications as $N) { // $N stands for Notifications
  57. $i++;
  58. $NewFilter = $N['ID'] === false;
  59. $N['Artists'] = implode(', ', explode('|', substr($N['Artists'], 1, -1)));
  60. $N['Tags'] = implode(', ', explode('|', substr($N['Tags'], 1, -1)));
  61. $N['NotTags'] = implode(', ', explode('|', substr($N['NotTags'], 1, -1)));
  62. $N['ReleaseTypes'] = explode('|', substr($N['ReleaseTypes'], 1, -1));
  63. $N['Categories'] = explode('|', substr($N['Categories'], 1, -1));
  64. $N['Formats'] = explode('|', substr($N['Formats'], 1, -1));
  65. $N['Encodings'] = explode('|', substr($N['Encodings'], 1, -1));
  66. $N['Media'] = explode('|', substr($N['Media'], 1, -1));
  67. $N['Users'] = explode('|', substr($N['Users'], 1, -1));
  68. $Usernames = '';
  69. foreach ($N['Users'] as $UserID) {
  70. $UserInfo = Users::user_info($UserID);
  71. $Usernames .= $UserInfo['Username'] . ', ';
  72. }
  73. $Usernames = rtrim($Usernames, ', ');
  74. if ($N['FromYear'] === 0) {
  75. $N['FromYear'] = '';
  76. }
  77. if ($N['ToYear'] === 0) {
  78. $N['ToYear'] = '';
  79. }
  80. if ($NewFilter && $NumFilters > 0) {
  81. ?>
  82. <br><br>
  83. <h3>Create a new notification filter</h3>
  84. <?php
  85. } elseif ($NumFilters > 0) { ?>
  86. <h3>
  87. <a
  88. href="feeds.php?feed=torrents_notify_<?=$N['ID']?>_<?=$LoggedUser['torrent_pass']?>&amp;user=<?=$LoggedUser['ID']?>&amp;auth=<?=$LoggedUser['RSS_Auth']?>&amp;passkey=<?=$LoggedUser['torrent_pass']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;name=<?=urlencode($N['Label'])?>"><img
  89. src="<?=STATIC_SERVER?>/common/symbols/rss.png"
  90. alt="RSS feed"></a>
  91. <?=display_str($N['Label'])?>
  92. <a href="user.php?action=notify_delete&amp;id=<?=$N['ID']?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
  93. onclick="return confirm('Are you sure you want to delete this notification filter?')" class="brackets">Delete</a>
  94. <a data-toggle-target="#filter_<?=$N['ID']?>"
  95. class="brackets">Show</a>
  96. </h3>
  97. <?php } ?>
  98. <form
  99. class="box pad slight_margin <?=($NewFilter ? 'create_form' : 'edit_form')?>"
  100. id="<?=($NewFilter ? 'filter_form' : '')?>"
  101. name="notification" action="user.php" method="post">
  102. <input type="hidden" name="formid" value="<?=$i?>">
  103. <input type="hidden" name="action" value="notify_handle">
  104. <input type="hidden" name="auth"
  105. value="<?=$LoggedUser['AuthKey']?>">
  106. <?php if (!$NewFilter) { ?>
  107. <input type="hidden" name="id<?=$i?>"
  108. value="<?=$N['ID']?>">
  109. <?php } ?>
  110. <table <?=(!$NewFilter ? 'id="filter_'.$N['ID'].'" class="layout hidden"' : 'class="layout"')?>>
  111. <?php if ($NewFilter) { ?>
  112. <tr>
  113. <td class="label">
  114. <strong>Notification filter name</strong>
  115. <strong class="important_text">*</strong>
  116. </td>
  117. <td>
  118. <input type="text" class="required" name="label<?=$i?>"
  119. style="width: 100%;">
  120. A name for the notification filter set to tell different filters apart
  121. </td>
  122. </tr>
  123. <!--
  124. <tr>
  125. <td colspan="2" class="center">
  126. <strong>All fields below here are optional</strong>
  127. </td>
  128. </tr>
  129. -->
  130. <?php } ?>
  131. <tr>
  132. <td class="label"><strong>One of these artists</strong></td>
  133. <td>
  134. <textarea name="artists<?=$i?>" style="width: 100%;"
  135. rows="5"><?=display_str($N['Artists'])?></textarea>
  136. Comma-separated list, e.g., Yumeno Aika, Pink Pineapple
  137. </td>
  138. </tr>
  139. <tr>
  140. <td class="label"><strong>One of these users</strong></td>
  141. <td>
  142. <textarea name="users<?=$i?>" style="width: 100%;"
  143. rows="5"><?=display_str($Usernames)?></textarea>
  144. Comma-separated list of usernames
  145. </td>
  146. </tr>
  147. <tr>
  148. <td class="label"><strong>At least one of these tags</strong></td>
  149. <td>
  150. <textarea name="tags<?=$i?>" style="width: 100%;"
  151. rows="2"><?=display_str($N['Tags'])?></textarea>
  152. Comma-separated list, e.g., paizuri, nakadashi
  153. </td>
  154. </tr>
  155. <tr>
  156. <td class="label"><strong>None of these tags</strong></td>
  157. <td>
  158. <textarea name="nottags<?=$i?>" style="width: 100%;"
  159. rows="2"><?=display_str($N['NotTags'])?></textarea>
  160. Comma-separated list, e.g., paizuri, nakadashi
  161. </td>
  162. </tr>
  163. <tr>
  164. <td class="label"><strong>Only these categories</strong></td>
  165. <td>
  166. <?php foreach ($Categories as $Category) { ?>
  167. <input type="checkbox" name="categories<?=$i?>[]"
  168. id="<?=$Category?>_<?=$N['ID']?>"
  169. value="<?=$Category?>" <?php if (in_array($Category, $N['Categories'])) {
  170. echo ' checked="checked"';
  171. } ?>>
  172. <label
  173. for="<?=$Category?>_<?=$N['ID']?>"><?=$Category?></label><br />
  174. <?php } ?>
  175. </td>
  176. </tr>
  177. <tr>
  178. <td class="label"><strong>Only new releases</strong></td>
  179. <td>
  180. <input type="checkbox" name="newgroupsonly<?=$i?>"
  181. id="newgroupsonly_<?=$N['ID']?>"
  182. <?php if ($N['NewGroupsOnly'] == '1') { # todo: Fix strict equality checking
  183. echo ' checked="checked"';
  184. } ?>>
  185. <label
  186. for="newgroupsonly_<?=$N['ID']?>">Only
  187. notify for new releases, not new formats</label>
  188. </td>
  189. </tr>
  190. <tr>
  191. <td colspan="2" class="center">
  192. <input type="submit" class="button-primary"
  193. value="<?=($NewFilter ? 'Create' : 'Update')?>">
  194. </td>
  195. </tr>
  196. </table>
  197. </form>
  198. <?php
  199. } ?>
  200. </div>
  201. <?php View::show_footer();