Changeset 457348
- Timestamp:
- 10/30/2011 11:48:42 AM (14 years ago)
- Location:
- game-server-tracker/trunk
- Files:
-
- 2 edited
-
index.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
game-server-tracker/trunk/index.php
r452732 r457348 2 2 /* 3 3 Plugin Name: Game Server Tracker 4 Plugin URI: http://hannawerner.com/wordpress/game-server-tracker /5 Description: Gets current stats of a Game Server from GameTracker.com and displays them in the sidebar. Some of the games this tracker works on are: Battlefield 3 [BETA], Battlefield Bad Company 2, Call of Duty 2, Call of Duty 4, Call of Duty : Black Ops, Counter Strike 1.6, Counter Strike Source, Day of Defeat Source, Left 4 Dead 2, Medal of Honor, Minecraft, Team Fortress 2 and Wolfenstein Enemy Territory.6 Version: 1. 04 Plugin URI: http://hannawerner.com/wordpress/game-server-tracker-version-1-1/ 5 Description: Gets current stats of a Game Server from GameTracker.com and displays them in the sidebar. The Game Server Tracker supports all games supported by GameTracker.com. 6 Version: 1.1 7 7 License: GPLv2 8 8 Author: Hanna Camille Werner … … 10 10 */ 11 11 12 class hcw_gameserver_tracker extends WP_Widget { 13 14 15 /** constructor -- name this the same as the class above */ 16 function hcw_gameserver_tracker() { 17 parent::WP_Widget(false, $name = 'Game Server Tracker'); 18 } 19 20 /** @see WP_Widget::widget -- do not rename this */ 12 // Inspired by the built-in WP_Widget_Text class 21 13 22 function widget($args, $instance) { 23 extract( $args ); 24 $title = apply_filters('widget_title', $instance['title']); 25 $serverip = $instance['message']; 26 /** $clanname = $instance['messagetwo']; **/ 27 ?> 28 <?php echo $before_widget; ?> 29 <?php if ( $title ) 30 echo $before_title . $title . $after_title; ?> 14 class HCW_Gameserver_Tracker extends WP_Widget { 31 15 16 function HCW_Gameserver_Tracker() { 17 $widget_ops = array('classname' => 'widget_hcw_gst', 'description' => __('Displays Game Server Information')); 18 $control_ops = array(); 19 $this->WP_Widget('hcwgst', __('Game Server Tracker'), $widget_ops, $control_ops); 20 } 32 21 33 <!-------------------------------------> 22 function widget( $args, $instance ) { 23 extract($args); 24 $serverip = $instance['serverip']; 25 26 echo $before_widget; 27 28 ?> 29 30 <script type="text/javascript" language="JavaScript"> 31 <!-- 32 function HideMoreContent(d) { 33 document.getElementById(d).style.display = "none"; 34 } 35 function ShowMoreContent(d) { 36 document.getElementById(d).style.display = "block"; 37 } 38 function ReverseDisplay(d) { 39 if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; } 40 else { document.getElementById(d).style.display = "none"; } 41 } 42 //--> 43 </script> 34 44 35 45 <?php 46 $content = file_get_contents("http://www.gametracker.com/server_info/$serverip/"); 47 preg_match("/<span class=\"item_color_success\"(.*?)>(.+?)<\/span>/s", $content, $matchesalive); 48 preg_match("/<span id=\"HTML_num_players\"(.*?)>(.+?)<\/span>/s", $content, $matchesnumplayers); 49 preg_match("/<span id=\"HTML_max_players\"(.*?)>(.+?)<\/span>/s", $content, $matchestotalplayers); 50 preg_match("/<span id=\"HTML_num_bots\"(.*?)>(.+?)<\/span>/s", $content, $matchesbots); 51 preg_match("/<div class=\"si_map_header\" id=\"HTML_curr_map\"(.*?)>(.+?)<\/div>/s", $content, $matchesmap); 52 preg_match("/<span class=\"item_color_title\"(.*?)>Game:<\/span>(.+?) /s", $content, $matchesgame); 53 preg_match("/<span class=\"item_color_title\"(.*?)>Name:<\/span>(.+?)<br\/\>/s", $content, $matchesclan); 54 preg_match("/<div class=\"si_map_image\" id=\"HTML_map_ss_img\"(.*?)>(.+?)<\/div>/s", $content, $matchesimgmap); 36 55 37 function textbetweenarray($s1,$s2,$s){ 38 $myarray=array(); 39 $s1=strtolower($s1); 40 $s2=strtolower($s2); 41 $L1=strlen($s1); 42 $L2=strlen($s2); 43 $scheck=strtolower($s); 56 echo '<ul>'; 57 echo '<li><strong>'; 58 echo $instance['alttitle']; 59 echo '</strong><br /><strong>Game: </strong>'; 60 echo $matchesgame[2]; 61 echo '<br /><strong>Server Status: </strong>'; 62 echo $matchesalive[2]; 63 echo '<br /><strong>Players: </strong>'; 64 echo $matchesnumplayers[2]; 65 echo '/'; 66 echo $matchestotalplayers[2]; 67 echo '<br /><strong>Bots: </strong>'; 68 echo $matchesbots[2]; 69 echo '<br /><strong>Map: </strong>'; 70 echo $matchesmap[2]; 71 ?> 72 <a class="moreserverinfo" href="javascript:ReverseDisplay('<?php echo $serverip; ?>')"><strong>↓</strong></a> 73 <div class="content-sidebar" id="<?php echo $serverip; ?>" style="display:none;"> 74 <?php echo $matchesimgmap[2]; ?> 75 </div> 76 <?php 77 echo '</li>'; 78 echo '</ul>'; 79 ?> 80 <?php echo $after_widget; 81 } 44 82 45 do{ 46 $pos1 = strpos($scheck,$s1); 47 if($pos1!==false){ 48 $pos2 = strpos(substr($scheck,$pos1+$L1),$s2); 49 if($pos2!==false){ 50 $myarray[]=substr($s,$pos1+$L1,$pos2); 51 $s=substr($s,$pos1+$L1+$pos2+$L2); 52 $scheck=strtolower($s); 53 } 54 } 55 } while (($pos1!==false)and($pos2!==false)); 56 return $myarray; 83 function update( $new_instance, $old_instance ) { 84 $instance = $old_instance; 85 $instance['serverip'] = strip_tags($new_instance['serverip']); 86 $instance['alttitle'] = strip_tags($new_instance['alttitle']); 87 return $instance; 88 } 89 90 function form( $instance ) { 91 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'serverip' => '', 'alttitle' => false ) ); 92 93 if ($instance['serverip']) 94 $title = preg_replace('/\?.*/', "", basename($instance['serverip'])); 95 96 ?> 97 <?php ?> 98 <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="hidden" value="<?php echo $title; ?>" /> 99 100 <p> 101 <label for="<?php echo $this->get_field_id('alttitle'); ?>"> 102 <?php _e('Server Name:'); ?> 103 <input class="widefat" id="<?php echo $this->get_field_id('alttitle'); ?>" name="<?php echo $this->get_field_name('alttitle'); ?>" type="text" value="<?php echo $instance['alttitle']; ?>" /> 104 105 </label> 106 </p> 107 108 <p> 109 <label for="<?php echo $this->get_field_id('serverip'); ?>"> 110 <?php _e('Server IP and Port:'); ?> 111 <input class="widefat" id="<?php echo $this->get_field_id('serverip'); ?>" name="<?php echo $this->get_field_name('serverip'); ?>" type="text" value="<?php echo $instance['serverip']; ?>" /><br /> <small>e.g. 127.0.0.1:27960</small><br /> 112 </label> 113 </p> 114 115 <?php 116 } 57 117 } 58 118 59 $content = file_get_contents("http://www.gametracker.com/server_info/$serverip"); 119 function widget_hcw_gst_init() { 120 register_widget('HCW_Gameserver_Tracker'); 121 } 122 add_action('init', 'widget_hcw_gst_init', 1); 60 123 61 $servergame = "<strong>Game:</strong> ";62 $playerstats = "<strong>Players Online:</strong> ";63 $serverstatus = "<strong>Status:</strong> ";64 $currentmap = "<strong>Current Map:</strong> ";65 $serverclan = "<strong>Clan:</strong> ";66 /** $members = "<strong>Members:</strong> "; **/67 68 $nextline = "<br />";69 70 $trServerName = textbetweenarray("<span class=\"item_color_title\">Name:</span>", "<br/>", $content);71 $trServerGame = textbetweenarray("<span class=\"item_color_title\">Game:</span>", " ", $content);72 $trCurrent = textbetweenarray("<span id=\"HTML_num_players\">", "</span>", $content);73 $trTotal = textbetweenarray("<span id=\"HTML_max_players\">", "</span>", $content);74 $trStatus = textbetweenarray("<span class=\"item_color_success\">", "</span>", $content);75 $trCurrMap = textbetweenarray("<div class=\"si_map_header\" id=\"HTML_curr_map\">", "</div>", $content);76 /** $trMembers = textbetweenarray("<span class=\"item_color_title\">Members:</span>", " ", $content); **/77 78 /** SERVER NAME **/79 80 foreach($trServerName as $tr) {81 echo $tr;82 }83 84 echo $nextline. "\n";85 86 /** CLAN87 88 echo $serverclan;89 echo $clanname;90 echo $nextline. "\n";91 92 **/93 /** MEMBERS94 95 echo $members ;96 foreach($trMembers as $tr) {97 echo $tr;98 }99 echo $nextline. "\n";100 **/101 /** GAME **/102 103 echo $servergame;104 foreach($trServerGame as $tr) {105 echo $tr;106 }107 echo $nextline. "\n";108 109 /** STATUS **/110 111 echo $serverstatus;112 foreach($trStatus as $tr) {113 echo $tr;114 }115 echo $nextline. "\n";116 117 /** CURRENT and TOTAL **/118 119 echo $playerstats;120 foreach($trCurrent as $tr) {121 echo $tr;122 }123 ?>/<?php124 foreach($trTotal as $tr) {125 echo $tr;126 }127 echo $nextline. "\n";128 124 ?> 129 <?php130 /** CURRENTMAP **/131 132 echo $currentmap;133 foreach($trCurrMap as $tr) {134 echo $tr;135 }136 echo $nextline. "\n";137 138 139 /*****************************/140 ?>141 142 143 <?php echo $after_widget; ?>144 <?php145 }146 147 /** @see WP_Widget::update -- do not rename this */148 function update($new_instance, $old_instance) {149 $instance = $old_instance;150 $instance['title'] = strip_tags($new_instance['title']);151 $instance['message'] = strip_tags($new_instance['message']);152 /** $instance['messagetwo'] = strip_tags($new_instance['messagetwo']); **/153 return $instance;154 }155 156 /** @see WP_Widget::form -- do not rename this */157 function form($instance) {158 159 $title = esc_attr($instance['title']);160 $serverip = esc_attr($instance['message']);161 /** $clanname = esc_attr($instance['messagetwo']); **/162 ?>163 <p>164 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>165 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />166 </p>167 <p>168 <label for="<?php echo $this->get_field_id('message'); ?>"><?php _e('Server and port. eg: 127.0.0.1:27960'); ?></label>169 <input class="widefat" id="<?php echo $this->get_field_id('message'); ?>" name="<?php echo $this->get_field_name('message'); ?>" type="text" value="<?php echo $serverip; ?>" />170 </p>171 172 173 <?php174 }175 176 177 } // end class hcw_gameserver_tracker178 add_action('widgets_init', create_function('', 'return register_widget("hcw_gameserver_tracker");'));179 ?> -
game-server-tracker/trunk/readme.txt
r452732 r457348 1 1 === Plugin Name === 2 2 Contributors: Sinopa 3 Tags: games, servers, tracker, clan3 Tags: games, servers, details, tracker 4 4 Requires at least: 3.0 5 5 Tested up to: 3.2.1 6 Stable tag: 1. 06 Stable tag: 1.1 7 7 8 Gets current stats of a Game Server from GameTracker.com and displays them in the sidebar.8 Gets current stats of a Game Server from GameTracker.com and displays them in the sidebar. 9 9 10 10 == Description == 11 11 12 Gets current stats for a Game Server from GameTracker.com and displays them in the sidebar. Some of the games this tracker works on are: Battlefield 3 [BETA], Battlefield Bad Company 2, Call of Duty 2, Call of Duty 4, Call of Duty : Black Ops, Counter Strike 1.6, Counter Strike Source, Day of Defeat Source, Left 4 Dead 2, Medal of Honor, Minecraft, Team Fortress 2 and Wolfenstein Enemy Territory. 13 14 Everything that GameTracker.com supports, this widget supports. 12 Gets current stats of a Game Server from GameTracker.com and displays them in the sidebar. The Game Server Tracker supports all games supported by GameTracker.com. 15 13 16 14 == Installation == 17 15 18 This section describes how to install the plugin and get it working. 19 20 e.g. 21 22 1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory 23 1. Activate the plugin through the 'Plugins' menu in WordPress 24 1. Drag the widget to sidebar menu 16 1. Download the plugin. 17 2. Install it to your /wp-content/plugins/ directory 18 3. Activate the plugin in your Wordpress Admin UI. 19 4. Drag the widget to sidebar menu 20 5. Write Server Name in widget. 21 6. Write IP address and Port. eg. 127.0.0.1:27960 25 22 26 23 == Frequently Asked Questions == 27 24 28 = No questions yet=25 = Does Game Server Tracker support multiple instances? = 29 26 30 So no answers have been given. 31 27 Yes. Now it supports multiple instances. 32 28 33 29 == Changelog == 34 30 35 = 1.0 = 36 * No Changes yet 31 Added support for multiple instances and current map thumbnail. 37 32 38 33 == Upgrade Notice == 39 34 35 = 1.1 = 36 * October 30, 2011 - 1.1 release. 37 * Added support for multiple instances and current map thumbnail. 38 40 39 = 1.0 = 41 * No upgrades has been done40 * October 19, 2011 - 1.0 release. 42 41 43 42 == Screenshots == 44 43 45 Screenshots can be found at http://hannawerner.com/wordpress/game-server-tracker /44 Screenshots can be found at http://hannawerner.com/wordpress/game-server-tracker-version-1-1/ 46 45 47 46 == Donate == 48 47 49 If you feel you want to donate something. Send me a postcard or something:)48 If you feel you want to donate something. Then donate a small area in your blog with a linke to my site http://www.hannawerner.com :) 50 49 51
Note: See TracChangeset
for help on using the changeset viewer.