Торрент трекер для Wordpress. Разработка не планируется со смертью модуля для PHP от которого зависит проект.
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.

torrent_tracker_adm.php 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. class TTSettingsPage {
  3. private $options;
  4. public function __construct() {
  5. add_action('admin_menu', array($this, 'add_plugin_page'));
  6. add_action('admin_init', array($this, 'page_init'));
  7. }
  8. public function add_plugin_page() {
  9. add_options_page(
  10. 'Settings Admin', 'Torrent Tracker', 'manage_options', 'tt-setting-admin', array($this, 'create_admin_page')
  11. );
  12. }
  13. public function create_admin_page() {
  14. $this->options = get_option('21h_torrent_tracker');
  15. ?>
  16. <div class="wrap">
  17. <h2>Torrent tracker</h2>
  18. <form method="post" action="options.php">
  19. <?php
  20. settings_fields('option_group1');
  21. do_settings_sections('tt-setting-admin');
  22. submit_button();
  23. ?>
  24. </form>
  25. </div>
  26. <?php
  27. }
  28. public function page_init() {
  29. register_setting(
  30. 'option_group1', '21h_torrent_tracker', array($this, 'sanitize')
  31. );
  32. add_settings_section(
  33. 'setting_section_id', 'View settings', array($this, 'print_section_info1'), 'tt-setting-admin'
  34. );
  35. add_settings_field(
  36. 'viewas', 'View list as table', array($this, 'viewas_callback'), 'tt-setting-admin', 'setting_section_id'
  37. );
  38. add_settings_field(
  39. 'showseed', 'Show seeders', array($this, 'showseed_callback'), 'tt-setting-admin', 'setting_section_id'
  40. );
  41. add_settings_field(
  42. 'showleech', 'Show leechers', array($this, 'showleech_callback'), 'tt-setting-admin', 'setting_section_id'
  43. );
  44. add_settings_field(
  45. 'torrents_per_page', 'Torrents per page (0 for all in one page)', array($this, 'torrents_per_page_callback'), 'tt-setting-admin', 'setting_section_id'
  46. );
  47. add_settings_field(
  48. 'cachetime', 'Caching seeders and leechers (sec)', array($this, 'cachetime_callback'), 'tt-setting-admin', 'setting_section_id'
  49. );
  50. add_settings_field(
  51. 'html_before', 'HTML before', array($this, 'html_before_callback'), 'tt-setting-admin', 'setting_section_id'
  52. );
  53. add_settings_field(
  54. 'html_after', 'HTML after', array($this, 'html_after_callback'), 'tt-setting-admin', 'setting_section_id'
  55. );
  56. add_settings_field(
  57. 'html_tracker_title', 'Tracker title', array($this, 'html_tracker_title_callback'), 'tt-setting-admin', 'setting_section_id'
  58. );
  59. add_settings_field(
  60. 'html_in_post_tracker_title', 'In-post tracker title', array($this, 'html_in_post_tracker_title_callback'), 'tt-setting-admin', 'setting_section_id'
  61. );
  62. }
  63. public function sanitize($input) {
  64. $new_input = array();
  65. if (isset($input['torrents_per_page']))
  66. $new_input['torrents_per_page'] = absint($input['torrents_per_page']);
  67. if (isset($input['viewas']))
  68. $new_input['viewas'] = 'checked';
  69. if (isset($input['showseed']))
  70. $new_input['showseed'] = 'checked';
  71. if (isset($input['showleech']))
  72. $new_input['showleech'] = 'checked';
  73. if (isset($input['cachetime']))
  74. $new_input['cachetime'] = absint($input['cachetime']);
  75. if (isset($input['html_before']))
  76. $new_input['html_before'] = $input['html_before'];
  77. if (isset($input['html_after']))
  78. $new_input['html_after'] = $input['html_after'];
  79. if (isset($input['html_tracker_title']))
  80. $new_input['html_tracker_title'] = $input['html_tracker_title'];
  81. if (isset($input['html_in_post_tracker_title']))
  82. $new_input['html_in_post_tracker_title'] = $input['html_in_post_tracker_title'];
  83. return $new_input;
  84. }
  85. public function print_section_info1() {
  86. print 'Check write permissions to plugin directory if something goes wrong. Updates and support only <a href="http://blindage.org/?p=7686">here</a>.';//.esc_attr(print_r($this->options,true));
  87. }
  88. public function torrents_per_page_callback() {
  89. printf(
  90. '<input type="text" id="torrents_per_page" name="21h_torrent_tracker[torrents_per_page]" value="%s" style="width:50px" />', isset($this->options['torrents_per_page']) ? esc_attr($this->options['torrents_per_page']) : ''
  91. );
  92. }
  93. public function viewas_callback() {
  94. printf(
  95. '<input type="checkbox" id="viewas" name="21h_torrent_tracker[viewas]" %s />', isset($this->options['viewas']) ? esc_attr($this->options['viewas']) : ''
  96. );
  97. }
  98. public function showseed_callback() {
  99. printf(
  100. '<input type="checkbox" id="showseed" name="21h_torrent_tracker[showseed]" %s />', isset($this->options['showseed']) ? esc_attr($this->options['showseed']) : ''
  101. );
  102. }
  103. public function showleech_callback() {
  104. printf(
  105. '<input type="checkbox" id="showleech" name="21h_torrent_tracker[showleech]" %s />', isset($this->options['showleech']) ? esc_attr($this->options['showleech']) : ''
  106. );
  107. }
  108. public function cachetime_callback() {
  109. printf(
  110. '<input type="text" id="cachetime" name="21h_torrent_tracker[cachetime]" value="%s" style="width:50px" />', isset($this->options['cachetime']) ? esc_attr($this->options['cachetime']) : ''
  111. );
  112. }
  113. public function html_before_callback() {
  114. printf(
  115. '<input type="text" id="html_before" name="21h_torrent_tracker[html_before]" value="%s" style="width:350px" />', isset($this->options['html_before']) ? esc_attr($this->options['html_before']) : ''
  116. );
  117. }
  118. public function html_after_callback() {
  119. printf(
  120. '<input type="text" id="html_after" name="21h_torrent_tracker[html_after]" value="%s" style="width:350px" />', isset($this->options['html_after']) ? esc_attr($this->options['html_after']) : ''
  121. );
  122. }
  123. public function html_tracker_title_callback() {
  124. printf(
  125. '<input type="text" id="html_tracker_title" name="21h_torrent_tracker[html_tracker_title]" value="%s" style="width:350px" />', isset($this->options['html_tracker_title']) ? esc_attr($this->options['html_tracker_title']) : ''
  126. );
  127. }
  128. public function html_in_post_tracker_title_callback() {
  129. printf(
  130. '<input type="text" id="html_in_post_tracker_title" name="21h_torrent_tracker[html_in_post_tracker_title]" value="%s" style="width:350px" />', isset($this->options['html_in_post_tracker_title']) ? esc_attr($this->options['html_in_post_tracker_title']) : ''
  131. );
  132. }
  133. }
  134. if (is_admin())
  135. $my_settings_page = new TTSettingsPage();