Skip to content
This repository has been archived by the owner on Aug 5, 2018. It is now read-only.

Commit

Permalink
fixed some problems with spaces, optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
hajo-p committed Jan 8, 2013
1 parent f536281 commit afe6f45
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
31 changes: 20 additions & 11 deletions tinyts3/mods/tinyts3/func.php
Expand Up @@ -2,6 +2,12 @@

function cs_ts3_status($host, $query_port, $client_port) {

# max length for user nicks (some chars like space count as two)
$maxnick = 20;
# max length for all user nicks as combined string
$maxlen = 70;

# exit when port data is not available
if(empty($query_port) OR empty($client_port))
return false;

Expand Down Expand Up @@ -32,24 +38,22 @@ function cs_ts3_status($host, $query_port, $client_port) {
fwrite($ts3_con, 'clientlist' . $nl);
$result['user'] = fread($ts3_con, 4096);
$result['user_status'] = fread($ts3_con, 4096);

$user = str_replace(array('\/','\s','\p'), array('/',' ','|'), $result['user']);
$user = explode(' ', $user);


$user = explode(' ', $result['user']);
$userlist = '';
foreach($user AS $part)
{
$parted = explode('=', $part, 2);
if($parted[0] == 'client_nickname' AND $parted[1] != 'Unknown')
$userlist .= (strlen($parted[1]) > 10) ? ', ' . substr($parted[1], 0, 8) . '..' : ', ' . $parted[1];
$unknown = substr($parted[1], 0, 15);
if($parted[0] == 'client_nickname' AND $unknown != 'Unknown\sfrom\s')
$userlist .= (strlen($parted[1]) > $maxnick) ? ', ' . substr($parted[1], 0, ($maxnick-2)) . '..' : ', ' . $parted[1];
}
$userlist = substr($userlist, 2);
if(strlen($userlist) > 70)
$userlist = substr($userlist, 0, 70) . '..';

$conf = str_replace(array('\/','\s','\p'), array('/',' ','|'), $result['info']);
$conf = explode(' ', $conf);
$userlist = str_replace(array('\/','\s','\p'), array('/',' ','|'), $userlist);
if(strlen($userlist) > $maxlen)
$userlist = substr($userlist, 0, ($maxlen-2)) . '..';

$conf = explode(' ', $result['info']);
$vars = array();
foreach($conf AS $part)
{
Expand All @@ -60,7 +64,12 @@ function cs_ts3_status($host, $query_port, $client_port) {
# remove one client count due to the query user
if(!empty($vars['virtualserver_clientsonline']))
$vars['virtualserver_clientsonline']--;

# remove build info to shorten version information
$end = strpos($vars['virtualserver_version'], '\s');
$vars['virtualserver_version'] = substr($vars['virtualserver_version'], 0, $end);

# set optimized userlist as clientlist var
$vars['virtualserver_clientlist'] = $userlist;

return $vars;
Expand Down
4 changes: 2 additions & 2 deletions tinyts3/mods/tinyts3/info.php
Expand Up @@ -5,8 +5,8 @@
$cs_lang = cs_translate('tinyts3');

$mod_info['name'] = $cs_lang['mod_name'];
$mod_info['version'] = '2011.3 v1';
$mod_info['released'] = '2012-02-06';
$mod_info['version'] = '2011.3 v1.1';
$mod_info['released'] = '2013-01-08';
$mod_info['creator'] = 'ClanSphere';
$mod_info['team'] = 'ClanSphere';
$mod_info['url'] = 'www.clansphere.net';
Expand Down
13 changes: 10 additions & 3 deletions tinyts3/readme.txt
@@ -1,5 +1,5 @@
tinyts3 for clansphere v1
-------------------------
tinyts3 for clansphere 1.1
--------------------------

requirements:

Expand All @@ -20,4 +20,11 @@ install steps:

5. enable tinyts3 by using the {tinyts3:navlist} placeholder inside your template file, e.g. index.htm

6. have fun using it
6. have fun using it


changelog:

0.1 - initial test release
1.0 - final release containing some bugfixes
1.1 - fixed some problems with spaces plus minor code optimizations

0 comments on commit afe6f45

Please sign in to comment.