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

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