myfreeforum.org Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups  Who is OnlineWho is Online   Join! (free) Join! (free)  
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
For an excellent guide to using your myfreeforum forum, you can visit
howtodoit
The howtodoit "readonly" forum provides answers and walkthroughs for all common questions.
  • Welcome
  • Guest


NEVERWINTERNIGHTS2 component

 
Post new topic   Reply to topic    myfreeforum.org Forum Index -> Portal components
View previous topic :: View next topic  
Author Message
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42960

Joined: 22 May 2005
Posts: 19353

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Thu Apr 12, 2007 12:32 pm    Post subject: NEVERWINTERNIGHTS2 component Reply with quote

In beta, so subject to change without notice.

{MYFF.NEVERWINTERNIGHTS2}

[NEVERWINTERNIGHTS2]
title=title here
server1=server name
address1=server address
port1=5121
server2=server name
address2=server address
port2=5121
...


This seems a good opportunity to show the php code, so people can contribute their own similar components!

Code:

<?
function com_neverwinternights2($params)
{
global $db;
global $userdata;
global $lang;
global $images;
global $template ;
global $phpEx;
global $board_config;
global $myffcms_options;
global $HTTP_GET_VARS;

$timeout = 5;

//
// Load templates
//
$template->set_filenames(array(
   strtolower($params->name) => 'cms_'. strtolower($params->name) .'.tpl')
);

if ($params->show_title== 1)
{
   $template->assign_block_vars('switch_'.strtolower($params->name).'_title', array());
}


$i = 1;

$item="server$i";

while(($server = $params->$item)!= "")
{
   
   $status="";
   $error="";
   $item="address$i";
   $address = $params->$item;
   if ($address=="") $address=$server;

   $item="port$i";
   $port = $params->$item;
   if ($port=="") $port=5121;
   $connect = @fsockopen( "udp://" . $address,$port, $errno, $errstr, $timeout );
   if ( ! $connect ) {
   
      $error = "{$errno} - {$errstr}";
      $status = "offline";


   } else {

      socket_set_timeout( $connect, $timeout );
      $send = "\xFE\xFD\x00\xE0\xEB\x2D\x0E\x14\x01\x0B\x01\x05\x08\x0A\x33\x34\x35\x13\x04\x36\x37\x38\x39\x14\x3A\x3B\x3C\x3D\x00\x00";
      fwrite( $connect, $send );
      $output = fread( $connect, 5000 );
      if ( ! $output ) {
         
         $error = "no response";
         $status = "Error";

      } else {
         $lines = explode( "\x00", $output );
         $players1=$lines[5];
         $players2=$lines[6];
         $status = $players1."/".$players2;
      
      }
      
      fclose( $connect );
   }
   $row_array = array(
         'STATUS' => $status,
         'SERVER' => $server,
         'ERROR' => $error
         
         );
   $template->assign_block_vars(strtolower($params->name).'_row',$row_array);
   $i++;

   $item="server$i";


}


$template->assign_vars(array(
   strtoupper($params->name).'_TITLE' => $params->title)
   
);


return $template->cms_pparse($params);

//End output

}
?>



_________________

Family Friendly Shareware | | Web Design/Services | Free Forums

forum.myfreeforum.org
Back to top
View user's profile Private message Send e-mail Visit poster's website
Stag eats Deer
Pupil
Pupil


Joined: 18 Mar 2007
Posts: 36
Location: Linköping, Sweden
Add Karma

rated by 0 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Apr 17, 2007 6:55 am    Post subject: Reply with quote

what is this code doing? it doesn't seem similar to the short template nwn2 file
_________________
"The early bird suffers from insomnia"


Back to top
View user's profile Private message Visit poster's website
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42960

Joined: 22 May 2005
Posts: 19353

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Apr 17, 2007 7:41 am    Post subject: Reply with quote

Perhaps not to your eye. But it really is functionally the same, but done for our phpbb2 portal system.
_________________

Family Friendly Shareware | | Web Design/Services | Free Forums

forum.myfreeforum.org
Back to top
View user's profile Private message Send e-mail Visit poster's website
Stag eats Deer
Pupil
Pupil


Joined: 18 Mar 2007
Posts: 36
Location: Linköping, Sweden
Add Karma

rated by 0 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Apr 17, 2007 4:44 pm    Post subject: Reply with quote

ok is there anyway to make some kind of player online list? like your online in the forum but on the erver?
_________________
"The early bird suffers from insomnia"


Back to top
View user's profile Private message Visit poster's website
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42960

Joined: 22 May 2005
Posts: 19353

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Apr 17, 2007 5:41 pm    Post subject: Reply with quote

Stag eats Deer wrote:
ok is there anyway to make some kind of player online list? like your online in the forum but on the erver?


probably, but that is not what the code you supplied did!

I have provided an example of how we can implement these things, and if other code is supplied that does what you want, it can probably be incorporated.
_________________

Family Friendly Shareware | | Web Design/Services | Free Forums

forum.myfreeforum.org
Back to top
View user's profile Private message Send e-mail Visit poster's website
Stag eats Deer
Pupil
Pupil


Joined: 18 Mar 2007
Posts: 36
Location: Linköping, Sweden
Add Karma

rated by 0 members
Add Comment
Show Comments

online/offline
PostPosted: Wed Apr 18, 2007 1:33 pm    Post subject: Reply with quote

ok thank you

If I find such a code I'll be noticing
_________________
"The early bird suffers from insomnia"


Back to top
View user's profile Private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    myfreeforum.org Forum Index -> Portal components All times are GMT + 1 Hour
Page 1 of 1
 
 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Card File  Gallery  Forum Archive
Powered by phpBB © 2001, 2005 phpBB Group
Create your own free forum | Buy a domain to use with your forum