Changeset 531536
- Timestamp:
- 04/15/2012 10:13:20 PM (14 years ago)
- Location:
- minequery-widget/trunk
- Files:
-
- 1 added
- 1 deleted
- 1 edited
-
README.txt (added)
-
mq_funcs.php (modified) (2 diffs)
-
readme.txt (deleted)
Legend:
- Unmodified
- Added
- Removed
-
minequery-widget/trunk/mq_funcs.php
r520845 r531536 1 <<<<<<< .mine 2 <?php 3 /* 4 Plugin Name: Minequery Widget 5 Plugin URI: http://sablednah.dnydns.org/ 6 Description: Display information about a minecraft server. 7 Version: 1.1 8 Author: Darren Douglas - [email protected] 9 Author URI: http://sablednah.dnydns.org/ 10 License: GPL3 11 */ 12 13 /* 14 * Minequery Widget 15 * Copyright (C) 2012 Sable Designs - [email protected] 16 * 17 * This program is free software: you can redistribute it and/or modify 18 * it under the terms of the GNU General Public License as published by 19 * the Free Software Foundation, either version 3 of the License, or 20 * (at your option) any later version. 21 * 22 * This program is distributed in the hope that it will be useful, 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 * GNU General Public License for more details. 26 * 27 * You should have received a copy of the GNU General Public License 28 * along with this program. If not, see <http://www.gnu.org/licenses/>. 29 */ 30 31 if (!class_exists('Minequery')) { 32 require('minequery.class.php'); 33 } 34 35 defined('ABSPATH') or die("Cannot access pages directly."); 36 37 add_action( 'widgets_init', create_function( '', 'register_widget("MineQueryWidget");' ) ); 38 39 class MineQueryWidget extends WP_Widget 40 { 41 function MineQueryWidget() { 42 $widget_ops = array( 43 'classname' => 'MineQueryWidget', 44 'description' => 'Display information about a minecraft server.' 45 ); 46 $this->WP_Widget( 'MineQueryWidget', 'MineQuery Widget', $widget_ops ); 47 } 48 49 function widget($args, $instance) { 50 extract( $args ); 51 52 $title = apply_filters('widget_title', $instance['title'] ); 53 $mq_ip = $instance['mq_ip']; 54 $mq_port = $instance['mq_port']; 55 56 echo $before_widget; 57 58 if ( $title ) echo $before_title . $title . $after_title; 59 60 $thisarray = Minequery::query($mq_ip,$mq_port); 61 if (!$thisarray) { 62 echo("<div style='color:red;'>Offline</div>"); 63 } else { 64 echo("<div style='color:green;'>Online</div>"); 65 echo("<div>$thisarray[playerCount] / $thisarray[maxPlayers] Players</div>"); 66 $players=$thisarray[playerList]; 67 echo("<div>"); 68 foreach ($players as $player) { 69 echo ("$player "); 70 } 71 echo("</div>"); 72 echo("<div>"); 73 $latency=number_format($thisarray[latency],3); 74 echo($latency); 75 echo(" Latency</div>"); 76 } 77 echo $after_widget; 78 } 79 80 81 function form( $instance ) { 82 $defaults = array( 'title' => 'Server Status', 'mq_ip' => 'localhost', 'mq_port' => '25566' ); 83 $instance = wp_parse_args( (array) $instance, $defaults ); 84 ?> 85 <p> 86 <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title</label> 87 <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" /> 88 </p> 89 90 <p> 91 <label for="<?php echo $this->get_field_id( 'mq_ip' ); ?>">Server IP</label> 92 <input id="<?php echo $this->get_field_id( 'mq_ip' ); ?>" name="<?php echo $this->get_field_name( 'mq_ip' ); ?>" value="<?php echo $instance['mq_ip']; ?>" style="width:100%;" /> 93 </p> 94 95 <p> 96 <label for="<?php echo $this->get_field_id( 'mq_port' ); ?>">Server Port</label> 97 <input id="<?php echo $this->get_field_id( 'mq_port' ); ?>" name="<?php echo $this->get_field_name( 'mq_port' ); ?>" value="<?php echo $instance['mq_port']; ?>" style="width:100%;" /> 98 </p> 99 <?php 100 } 101 102 function update( $new_instance, $old_instance ) { 103 $instance = $old_instance; 104 $instance['title'] = strip_tags( $new_instance['title'] ); 105 $instance['mq_ip'] = strip_tags( $new_instance['mq_ip'] ); 106 $instance['mq_port'] = strip_tags( $new_instance['mq_port'] ); 107 return $instance; 108 } 109 }======= 1 110 <?php 2 111 /* … … 104 213 return $instance; 105 214 } 106 } 215 }>>>>>>> .r531535
Note: See TracChangeset
for help on using the changeset viewer.