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.9KB

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