List of Pilots online

Hello All,

Does anybody have the code for this?

[![post-799-051610300 1284489438_thumb.jpg](<fileStore.core_Attachment>/monthly_09_2010/post-799-051610300%201284489438_thumb.jpg)](<fileStore.core_Attachment>/monthly_09_2010/post-799-051610300%201284489438.jpg)

I cannot remember which VA it was on but it shows a list of all pilot’s online

Thanks!

Is this the right location to post a request??

Anyway, i would like to know this too :slight_smile:

Regards

Lucas

<?php

$usersonline = StatsData::UsersOnline();

$guestsonline = StatsData::GuestsOnline();



?>

<h4>Pilots Online</h4>

<?php
$shown = array();
foreach($usersonline as $pilot) 
{

if(in_array($pilot->pilotid, $shown))
continue;
else
$shown[] = $pilot->pilotid; 

echo "<p>";
echo '<img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).'" />';
echo " {$pilot->firstname} {$pilot->lastname}<br />"; 
echo "</p>";

}

?>

<h4>Guests Online</h4>

<p class="txt-red10">Currently

<?php echo count($guestsonline);?>

guest(s) visiting.

would be something like this

1 Like
<?php $usersonline = StatsData::UsersOnline(); $guestsonline = StatsData::GuestsOnline(); ?>

Pilots Online

<?php $shown = array(); foreach($usersonline as $pilot) { if(in_array($pilot->pilotid, $shown)) continue; else $shown[] = $pilot->pilotid; echo "

"; echo ''.Countries::getCountryName($pilot->location).''; echo " {$pilot->firstname} {$pilot->lastname}
"; echo "

"; } ?>

Guests Online

Currently <?php echo count($guestsonline);?>

guest(s) visiting.

would be something like this

works fine, thanks!

Any way of adding a link to the pilots profile in this?

anyone know ^

anyone know ^

In the line…

echo " {$pilot->firstname} {$pilot->lastname}<br />";

… do like this:

echo "<a href=\"http://your-domain.com/index.php/profile/view/". $pilot->pilotid ."\"> {$pilot->firstname} {$pilot->lastname}</a><br />";

In the line…

echo " {$pilot->firstname} {$pilot->lastname}
";

… do like this:

echo “<a href="http://your-domain.com/index.php/profile/view/”. $pilot->pilotid .“"> {$pilot->firstname} {$pilot->lastname}
”;

Best to make use of the url function:

echo '<a href="'.url('/profile/view/'.$pilot->pilotid).'"> '.$pilot->firstname.' '.$pilot->lastname.'</a><br />';

Thanks!

Would there be a way of getting it to say " No Pilots Online" if there are no pilots online?

You can put the enitre code for dispalying in an if statement. if ($usersonline) { before the foreach loop amd then close it } else echo ‘no pilots online’;

Thanks Sava!

were do i put this code what file ??

Depends where you want it to show up.

you could put in in your Layout.tpl or maybe the frontpage_main.tpl. It can go on any page,

PILOTS ONLINE and STAFF ONLINE with avatar, country, and link to profile

It was late, so the only thing to add in this code is to have the counts show ‘0’ when there are no pilots to count for staff and pilots online. Know that an admin must have access to your admin panel in order to be included in the Staff Online side of the table.

Also, the pic below is not accurate, but only the first attempt. The code posted has been fixed to show staff only on the left and pilots only on the right.

Also, the only problem with the code is the counts. Guests are counted correctly, however when a pilot or staff member is online with kacars and flying a flight, they are counted again, so when it says there’s 2 there is actually only 1. If anyone can find a fix or knows of a fix, this code would be 100%.

Thank You.

<table class="(to your favorite table style in your css)" border="0" align="center" width="100%" height="300">
			    <th colspan="1" align="center" class="(to your favorite th style in your css)">Pilots Online</th>									   
						    <tr>
						    <td>
						    <table align="center" width="100%" style="text-align:center; background-color: #F1AD43; font-weight: bold; color: #000000; height: 10px;">
						    <tr>
						    <td>STAFF ONLINE</td>
						    <td>PILOTS ONLINE</td>
						    </tr>
						    </table>
						    <table border="0" align="center" width="100%" height="150">
						    <tr>
   <!-- ==================================================VVVV STAFF ONLINE VVVV============================================== -->
				    <td align="left" width="50%" style="padding-left: 100px;">					   

				    <div style="overflow-y: auto; overflow-x: hidden; height: 150px; background: transparent;">					   
					    <?php  
						    $shown = array();
						    $staff = StatsData::UsersOnline();
						    foreach($staff as $pilot)
						    {
						    if(PilotGroups::group_has_perm(PilotGroups::getUserGroups($pilot->pilotid), ACCESS_ADMIN) == true)
						    {
						    if(in_array($pilot->pilotid, $shown))

								    continue;
								    else
								    $shown[] = $pilot->pilotid;
						    ?>
						    <a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>" title="Visit Pilots Profile"><img style="padding-bottom: 2px; border: 1px; border-radius: 4px;" align="center" height="28px" width="28px" src="<?php echo PilotData::getPilotAvatar($pilot->pilotid);?>"/> 
						    <img src="<?php echo Countries::getCountryImage($pilot->location);?>" alt="<?php echo Countries::getCountryName($pilot->location);?>" title="<?php echo Countries::getCountryName($pilot->location);?>" />
						    <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid). ' - ' .$pilot->firstname . ' ' . $pilot->lastname?>
						    </a><br />
						    <?php
						    }
						    }
						    if(count($shown) < 1){
							    echo '<br /><br /><br /><h3><font color="#ff0000"><p style="padding-left: 50px;">No Staff Online</p></font></h3>';
						    }
						    ?>													 
				    </div>								   
				    </td>				 
   <!-- ==================================================VVVV PILOTS ONLINE VVVV============================================== -->
				    <td align="left" width="50%" style="padding-left: 100px;">

					 <div style="overflow-y: auto; overflow-x: hidden; height: 150px; background: transparent;">  

					    <?php

						    $shown = array();
						    $usersonline = StatsData::UsersOnline();																																			   
						    foreach($usersonline as $pilot)							   
						    {
						    if(PilotGroups::group_has_perm(PilotGroups::getUserGroups($pilot->pilotid), ACCESS_ADMIN) == false)
						    {							   
						    if(in_array($pilot->pilotid, $shown))

								    continue;
								    else
								    $shown[] = $pilot->pilotid;
						    ?>
						    <a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>" title="Visit Pilots Profile"><img style="padding-bottom: 2px; border: 1px; border-radius: 4px;" align="center" height="28px" width="28px" src="<?php echo PilotData::getPilotAvatar($pilot->pilotid);?>"/> 
						    <img src="<?php echo Countries::getCountryImage($pilot->location);?>" alt="<?php echo Countries::getCountryName($pilot->location);?>" title="<?php echo Countries::getCountryName($pilot->location);?>" />
						    <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid). ' - ' .$pilot->firstname . ' ' . $pilot->lastname?>
						    </a><br />
						    <?php
						    }
						    }
						    if(count($shown) < 1){
							    echo '<br /><br /><br /><h3><font color="#ff0000"><p style="padding-left: 50px;">No Pilots Online</p></font></h3>';
						    }
						    ?> 
				    </div>	  
				    </td>
				    </tr>
			 </table>
				    </td>
				    </tr>
				    <tr>							   
				    <td>
					    <hr />
						    <?php
						    $userCount = 0;
						    $staffCount = 0;
						    $guestsonline = count(StatsData::GuestsOnline());

						    $pilots = StatsData::UsersOnline();
						    foreach($pilots as $staff){
							    if(PilotGroups::group_has_perm(PilotGroups::getUserGroups($staff->pilotid), ACCESS_ADMIN) == true)
							    {
								    $staffCount++;
							    }else{
								    $userCount++;
							    }
						    }
						    ?>
						    <p align="center">
							    <b>
								    <font color="#F1AD43">Staff Online:</font>
								    <font color="#00FF00"><?php echo $staffCount; ?></font>
								    <font color="#F1AD43">Pilots Online:</font>
								    <font color="#00FF00"><?php echo $userCount; ?></font>
								    <font color="#F1AD43">Guests Online:</font>
								    <font color="#00FF00"><?php echo $guestsonline; ?></font>
							    </b>
						    </p>
						    <br />
				    </td>
				    </tr>
</table>
2 Likes