Plugin Directory

Changeset 1407729


Ignore:
Timestamp:
04/29/2016 06:35:11 PM (10 years ago)
Author:
xnicoco
Message:

Added option to deactivate the torrent tracker, added plugin icons

Location:
katracker
Files:
2 added
3 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • katracker/trunk/admin/admin-page.php

    r1398530 r1407729  
    1414            ?>
    1515            <div class="wrap">
    16                 <h1><?php _e( 'Katracker Settings', 'katracker' ); ?></h1>
     16                <h1><span style="height:38px;width:140px;background:url('<?php echo plugin_dir_url( __FILE__ ) . 'SettingsLogo.png'; ?>') no-repeat;background-size:140px 38px;display:inline-block;" ></span>&nbsp;<?php _e( 'Settings', 'katracker' ); ?></h1>
    1717                <h2 class="nav-tab-wrapper">
    1818                <?php
  • katracker/trunk/admin/media-button.php

    r1398530 r1407729  
    11<?php
    22
    3 // License Information /////////////////////////////////////////////////////////////////////////////
    4 
    5 /*
    6  * KaTracker - BitTorrent Tracker Wordpress Plugin
    7  * Based mostly on peertracker, https://github.com/JonnyJD/peertracker
    8  * and ported to use the native wordpress functions by nicoco of KaTeam
    9  * Copyright (C) 2015 http://www.kateam.org/
    10  *
    11  * katracker is free software: you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation, either version 3 of the License, or
    14  * (at your option) any later version.
    15  *
    16  * KaTracker is distributed in the hope that it will be useful,
    17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
    22  * along with KaTracker. If not, see <http://www.gnu.org/licenses/>.
    23  */
     3// Add Torrent Button //////////////////////////////////////////////////////////////////////////////
    244
    255
  • katracker/trunk/admin/media-list.php

    r1398530 r1407729  
    1515    $cols['leechers'] = '<span title="'.__( 'Leechers', 'katracker' ).'">Le</span>';
    1616    $cols['seeders'] = '<span title="'.__( 'Seeders', 'katracker' ).'">Se</span>';
     17    $cols['hits'] = '<span title="'.__( 'Hits', 'katracker' ).'">Hits</span>';
    1718    // $cols['shortcode'] = '<span title="'.__( 'Shortcode', 'katracker' ).'">Shortcode</span>';
    1819    return $cols;
     
    3334        case 'seeders':
    3435            echo '<span style="color: green;">' . get_torrent_meta( $torrent_id, 'seeders' ) . '</span>';
     36            break;
     37        case 'hits':
     38            echo '<span style="color: black;">' . get_torrent_meta( $torrent_id, 'hits' ) . '</span>';
    3539            break;
    3640        // case 'shortcode':
     
    5458    $cols['leechers']                        = 'leechers';
    5559    $cols['seeders']                         = 'seeders';
     60    $cols['hits']                            = 'hits';
    5661    return $cols;
    5762} );
     
    9499            $query->set( 'orderby','meta_value_num' );
    95100            break;
     101        case 'hits':
     102            $query->set( 'meta_key', KATRACKER_META_PREFIX . 'hits' );
     103            $query->set( 'orderby','meta_value_num' );
     104            break;
    96105    }
    97106} );
     
    111120        .column-date, .column-author, .column-size, .column-shortcode {width: 5em;}
    112121        .column-taxonomy-<?php echo KATRACKER_CATEGORY; ?> {width: 9em;}
    113         .column-leechers, .column-seeders {width: 2.7em;}
     122        .column-leechers, .column-seeders, .column-hits {width: 2.7em;}
    114123        .column-tracked {width: 4.15em;}
    115124    </style>
  • katracker/trunk/admin/section-1-info.php

    r1398530 r1407729  
    1818
    1919    add_settings_section(
    20         KATRACKER_PREFIX . 'section-'.$katracker_section[basename( __FILE__ )]['name'], 
     20        KATRACKER_PREFIX . 'section-'.$katracker_section[basename( __FILE__ )]['name'],
    2121        __( $katracker_section[basename( __FILE__ )]['title'], 'katracker' ),
    2222        function () {
    23             $url = array( 
     23            $url = array(
    2424                'announce' => get_katracker_url( 'announce' ),
    2525                'scrape' => get_katracker_url( 'scrape' ),
     
    2828            $stats = get_torrent_stats();
    2929            ?>
     30            <p><strong><?php echo get_katracker_option( 'active' ) ? __( 'The tracker is up and running.', 'katracker' ) : __( 'The tracker is disabled.', 'katracker' ); ?></strong></p>
    3031            <table>
    3132                <thead><th colspan="2"><?php _e( 'Useful Tracker Urls', 'katracker' ); ?></th></thead>
     
    6061            </table>
    6162            <?php
    62         }, 
     63        },
    6364        $katracker_section[basename( __FILE__ )]['name']
    6465    );
  • katracker/trunk/admin/section-2-tracker.php

    r1398530 r1407729  
    2424        },
    2525        $katracker_section[basename( __FILE__ )]['name']
     26    );
     27
     28    register_setting( $katracker_section[basename( __FILE__ )]['name'], KATRACKER_PREFIX . 'active' );
     29    add_settings_field(
     30        KATRACKER_PREFIX . 'active',
     31        __( 'Activate Tracker', 'katracker' ),
     32        function () {
     33            $option = get_katracker_option( 'active' );
     34            echo '<input type="radio" name="' . KATRACKER_PREFIX . 'active" value="1" ' . checked( $option, 1, false ) . '>' . __( 'Yes', 'katracker' ) . '</br>' .
     35                 '<input type="radio" name="' . KATRACKER_PREFIX . 'active" value="0" ' . checked( $option, 0, false ) . '>' . __( 'No', 'katracker' );
     36        },
     37        $katracker_section[basename( __FILE__ )]['name'],
     38        KATRACKER_PREFIX . 'section-' . $katracker_section[basename( __FILE__ )]['name'],
     39        array( 'label_for' => KATRACKER_PREFIX . 'active' )
    2640    );
    2741
  • katracker/trunk/functions.php

    r1398530 r1407729  
    101101            'SELECT post_id ' .
    102102            // from postmeta
    103             "FROM $wpdb->postmeta" .
     103            "FROM $wpdb->postmeta " .
    104104            // that match hash_info
    105105            "WHERE meta_value = %s",
     
    370370    $options = array(
    371371                'init'               => 1,
     372                'acitve'             => 1,
    372373                'validate-hash'      => 1,
    373374                'labels'             => '',
     
    423424                            'post_status' => null
    424425                        ) );
    425            
     426
    426427            $success = true;
    427            
     428
    428429            foreach ( $torrents as $torrent ) {
    429430                $success &= ( bool )wp_delete_post( $torrent->ID, true );
    430431            }
    431            
     432
    432433            return $success;
    433434        case 'full':
     
    493494        'track'         => 0,
    494495        'update-title'  => 1,
     496        'hits'          => 0,
    495497        'seeders'       => 0,
    496498        'leechers'      => 0
    497499    );
    498    
     500
    499501    $success = true;
    500    
     502
    501503    if ( !isset( $attachment_id ) && $uninstall ) {
    502504        foreach( array_keys( $metadata ) as $key ) {
  • katracker/trunk/katracker.php

    r1398530 r1407729  
    55 * Description: The only full and all powerful, complete bittorrent tracker integration for wordpress.
    66 * Author: nicoco
    7  * Version: 1.0.1
     7 * Version: 1.0.2
    88 * Author URI: kateam.org
    99 * License: GPL2
    10 */
     10 */
    1111
    1212// Include dependencies ////////////////////////////////////////////////////////////////////////////
     
    4747// Setup Tracker File Loading //////////////////////////////////////////////////////////////////////
    4848add_action( 'plugins_loaded', function () {
    49     if ( $katracker_slug = get_katracker_option( 'slug' ) ){
     49    if ( get_katracker_option( 'active' ) && $katracker_slug = get_katracker_option( 'slug' ) ){
    5050        $current = array();
    5151        if ( get_option( 'permalink_structure' ) ) {
  • katracker/trunk/torrent/torrent-media.php

    r1398530 r1407729  
    154154function print_torrent_info( $torrent_id ) {
    155155    if ( is_object( $torrent_id ) ) $torrent_id = $torrent_id->ID;
    156     // grub torrent file info
    157     $stats = get_torrent_stats( $torrent_id );
    158156    $torrent_data = array(
    159157        array(
    160             'lable'  => __( 'Name' ),
    161             'name'   => 'name',
    162             'class'  => 'code',
    163             'data'   => get_torrent_meta( $torrent_id, 'name' )
    164         ),
    165         array(
    166             'lable'  => __( 'Hash Info', 'katracker' ),
    167             'name'   => 'hash-info',
    168             'class'  => 'code',
    169             'data'   => get_torrent_meta( $torrent_id, 'hash-info' )
    170         ),
    171         array(
    172             'lable'  => __( 'Leechers', 'katracker' ),
    173             'name'   => 'leechers',
    174             'class'  => 'code',
    175             'data'   => get_torrent_meta( $torrent_id, 'leechers' )
    176         ),
    177         array(
    178             'lable'  => __( 'Seeders', 'katracker' ),
    179             'name'   => 'seeders',
    180             'class'  => 'code',
    181             'data'   => get_torrent_meta( $torrent_id, 'seeders' )
    182         ),
    183         array(
    184             'lable'  => __( 'Piece Length', 'katracker' ),
    185             'name'   => 'piece-length',
    186             'class'  => 'code',
    187             'data'   => TorrentFile::format( get_torrent_meta( $torrent_id, 'piece-length' ) )
    188         ),
    189         array(
    190             'lable'  => __( 'Total Size', 'katracker' ),
    191             'name'   => 'size',
    192             'class'  => 'code',
    193             'data'   => TorrentFile::format( get_torrent_meta( $torrent_id, 'size' ))
    194         ),
    195         array(
    196             'lable'     => __( 'Announces', 'katracker' ),
    197             'name'      => 'announce',
    198             'class'     => 'urlfield code',
    199             'textarea'  => true,
    200             'data'      => get_torrent_meta( $torrent_id, 'announce' )
    201         ),
    202         array(
    203             'lable'     => __( 'Comment', 'katracker' ),
    204             'name'      => 'comment',
    205             'class'     => 'code',
    206             'textarea'  => true,
    207             'data'      => get_torrent_meta( $torrent_id, 'comment' )
     158            __( 'Name' ),
     159            'name',
     160            'code',
     161            get_torrent_meta( $torrent_id, 'name' )
     162        ),
     163        array(
     164            __( 'Hash Info', 'katracker' ),
     165            'hash-info',
     166            'code',
     167            get_torrent_meta( $torrent_id, 'hash-info' )
     168        ),
     169        array(
     170            __( 'Leechers', 'katracker' ),
     171            'leechers',
     172            'code',
     173            get_torrent_meta( $torrent_id, 'leechers' )
     174        ),
     175        array(
     176            __( 'Seeders', 'katracker' ),
     177            'seeders',
     178            'code',
     179            get_torrent_meta( $torrent_id, 'seeders' )
     180        ),
     181        array(
     182            __( 'Hits', 'katracker' ),
     183            'hits',
     184            'code',
     185            get_torrent_meta( $torrent_id, 'hits' )
     186        ),
     187        array(
     188            __( 'Piece Length', 'katracker' ),
     189            'piece-length',
     190            'code',
     191            TorrentFile::format( get_torrent_meta( $torrent_id, 'piece-length' ) )
     192        ),
     193        array(
     194            __( 'Total Size', 'katracker' ),
     195            'size',
     196            'code',
     197            TorrentFile::format( get_torrent_meta( $torrent_id, 'size' ))
     198        ),
     199        array(
     200            __( 'Announces', 'katracker' ),
     201            'announce',
     202            'urlfield code',
     203            get_torrent_meta( $torrent_id, 'announce' ),
     204            true,
     205        ),
     206        array(
     207            __( 'Comment', 'katracker' ),
     208            'comment',
     209            'code',
     210            get_torrent_meta( $torrent_id, 'comment' ),
     211            true
    208212        ),
    209213    );
    210214    foreach( $torrent_data as $data ): ?>
    211         <label for="torrent_data_<?php echo $data['name']; ?>"><?php echo $data['lable']; ?></label>
    212         <?php if ( isset( $data['textarea'] ) ): ?>
    213             <textarea name="attachments[<?php echo $torrent_id; ?>][<?php echo $data['name']; ?>]" id="torrent_data_<?php echo $data['name']; ?>" class="widefat <?php echo $data['class']; ?>" type="text"><?php echo $data['data']; ?></textarea>
     215        <label for="torrent_data_<?php echo $data[1]; ?>"><?php echo $data[0]; ?></label>
     216        <?php if ( isset( $data[4] ) ): ?>
     217            <textarea name="attachments[<?php echo $torrent_id; ?>][<?php echo $data[1]; ?>]" id="torrent_data_<?php echo $data[1]; ?>" class="widefat <?php echo $data[2]; ?>" type="text"><?php echo $data[3]; ?></textarea>
    214218        <?php else: ?>
    215             <input readonly="readonly" name="torrent_data_<?php echo $data['name']; ?>" id="torrent_data_<?php echo $data['name']; ?>" class="widefat <?php echo $data['class']; ?>" onClick="this.select();" type="text" value="<?php echo $data['data']; ?>"></input>
     219            <input readonly="readonly" name="torrent_data_<?php echo $data[1]; ?>" id="torrent_data_<?php echo $data[1]; ?>" class="widefat <?php echo $data[2]; ?>" onClick="this.select();" type="text" value="<?php echo $data[3]; ?>"></input>
    216220        <?php endif;
    217221    endforeach;
  • katracker/trunk/tracker/katracker.core.php

    r1398530 r1407729  
    77 * The tracker functionality mostly on peertracker's mysql version,
    88 * and ported to use native wordpress functions.
    9  * 
     9 *
    1010 * For more information about the peertracker project,
    1111 * please visit https://github.com/JonnyJD/peertracker
     
    389389
    390390    /**
     391     * Flush Torrent Statistics
     392     */
     393    public static function flush_statistics()
     394    {
     395        if ( !$torrent_id = get_torrent_id_from_hash( $_GET['info_hash'] ) ) return;
     396
     397        global $wpdb;
     398        $stats = get_torrent_stats( $torrent_id );
     399
     400        update_torrent_meta( $torrent_id, 'seeders', $stats['seeders'] );
     401        update_torrent_meta( $torrent_id, 'leechers', $stats['leechers'] );
     402    }
     403
     404    /**
    391405     * check if the torrent approved by the tracker
    392406     */
    393     public static function katracker_validate()
     407    public static function validate()
    394408    {
    395409        if ( $_SERVER['tracker']['open_tracker'] ) return;
  • katracker/trunk/tracker/tracker-announce.php

    r1398530 r1407729  
    66 * The tracker functionality mostly on peertracker's mysql version,
    77 * and ported to use native wordpress functions.
    8  * 
     8 *
    99 * For more information about the peertracker project,
    1010 * please visit https://github.com/JonnyJD/peertracker
     
    8282else $_GET['numwant'] += 0;
    8383
    84 // get the torrent id from the hash
    85 $_GET['torrent_id'] = get_torrent_id_from_hash( $_GET['info_hash'] );
    86 
    8784// Handle Request //////////////////////////////////////////////////////////////////////////////////
     85// flush wordpress statistics
     86KatrackerCore::flush_statistics();
    8887
    8988// check if the torrent is approved by the tracker
     
    9695KatrackerCore::event();
    9796
    98 // if the torrent exists in wordpress database, update the metadata
    99 if ( $torrent_id = get_torrent_id_from_hash( $_GET['info_hash'] ) ) {
    100     update_torrent_meta( $torrent_id, 'seeders', get_torrent_seeders( $torrent_id ) );
    101     update_torrent_meta( $torrent_id, 'leechers', get_torrent_leechers( $torrent_id ) );
    102 }
    10397
    10498exit;
  • katracker/trunk/tracker/tracker-download.php

    r1398530 r1407729  
    3636                preg_replace( '/,/', '', $torrent->name() );
    3737   
     38    $hits = get_torrent_meta( $_GET['torrent'], 'hits');
     39    update_torrent_meta( $_GET['torrent'], 'hits', $hits + 1);
     40   
    3841    exit( $torrent->send( $filename . '.torrent' ) );
    3942}
  • katracker/trunk/tracker/tracker-scrape.php

    r1398530 r1407729  
    5151// Handle Request //////////////////////////////////////////////////////////////////////////////////
    5252
     53// check if the torrent is approved by the tracker
     54KatrackerCore::validate();
     55
    5356// perform scrape
    5457KatrackerCore::scrape();
Note: See TracChangeset for help on using the changeset viewer.