I have a mumble server installed on my site and while everything displays fine when view the php directly, when i try to create a phpbox and call the file for viewing I'm finding that javascript is not being displayed as it should.
I've Included a screenshot of the two running and highlighting a user. Any ideas what I could be doing wrong.... Thanks In advance for any help!!
PHPBox Code
global $ICE;
include("mumble/MumbleViewer.php");
MumbleViewer.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Mumbleviewer 1.0</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="http://lavalit.com:8080/mumble/style.css" rel="stylesheet" type="text/css"/>
<script src="http://lavalit.com:8080/mumble/tooltip.js" type="text/javascript"></script>
</head>
<?php
Ice_loadProfile();
try {
$base = $ICE->stringToProxy("Meta:tcp -h 127.0.0.1 -p 6502");
$meta = $base->ice_checkedCast("::Murmur::Meta");
$servers = $meta->getBootedServers();
$default = $meta->getDefaultConf();
} catch (Ice_LocalException $ex) {
print_r($ex);
}
$level[-1] = 0;
foreach($servers as $s) {
$name = $s->getConf("registername");
if (! $name) {
$name = $default["registername"];
}
$channels = $s->getChannels();
$players = $s->getPlayers();
echo " <table class=\"table\"><tr><td align=\"center\"></td></tr>\n";
echo "<tr><td>\n";
echo "<div class='div_list'>\n";
echo "<div class='div_server'><span class='text_server'>$name</span></div>\n";
echo "<div class='div_serverspace'></div>";
print_users(0,has_children(0));
print_tree($channels, 0);
echo "<div class='div_serverspace'></div>\n";
echo "<a href=\"http://mumbleviewer.mine.nu\"target=\"_blank\"><div class ='div_footer' title=\"header=[MumbleViewer v1.0] body=[This tool on your Site? Just click.]\">";
echo "<center><div class='text_footer'>MUMBLE VIEWER v1.0</div></center></div></a>\n";
echo "</div></td></tr></table>\n";
}
// Functions
//Mainfunction: print tree structure
function print_tree($channels, $parentid) {
global $level;
global $printline;
$children = children($channels, $parentid);
if(!empty($children)){
foreach($children as $child => $name){
$has_children = children($channels,$child);
if(!empty($has_children)){
$has_children = 1;
}
else{
$has_children = 0;
}
if($name == end($children)){
$last_channel = 1;
}
echo "\n <!-- New channelline -->\n";
echo "<div class='div_clear'></div>";
if ($name == end($children)){
$printline[$level[$child]] = 0;
}
else{
$printline[$level[$child]] = 1;
}
for ($i = 1; $i <= $level[$child] - 1; $i++){
if($printline[$i] == 1){
print "<div class='div_space'><img src = 'http://lavalit.com:8080/mumble/images/list_tree_line.gif' class='image' alt=''/></div>";
}
else{
print "<div class='div_space'><img src = 'http://lavalit.com:8080/mumble/images/list_empty.png' class='image' alt=''/></div>";
}
}
//last branch infront of channel
if($last_channel){
echo "<div class='div_space'><img src = 'http://lavalit.com:8080/mumble/images/list_tree_end.gif' class='image' alt=''/></div>";
}
else{
echo "<div class='div_space'><img src = 'http://lavalit.com:8080/mumble/images/list_tree_mid.gif' class='image' alt=''/></div>";
}
//channel symbol and channel name
echo "<div class ='div_channel'><img src = 'http://lavalit.com:8080/mumble/images/list_channel.png' class='image' alt=''/>";
echo "<span class='text_channel'>$name</span></div>";
echo "\n <!-- End channelline -->\n";
print_users($child,has_children($child));
print_tree($channels, $child);
}
}
}
//Return all children of an ID
function children($channels, $id){
global $level;
foreach($channels as $c){
//if pid = id, push into array
if($c->parent == $id){
$children[$c->id] = $c->name;
//set level of child
$level[$c->id] = $level[$id] + 1;
}
}
if(!empty($children)){
asort($children);
}
return $children;
}
//display all users of a given channel
function print_users($channelid, $has_children){
global $players;
global $level;
global $printline;
//Look for players in channel and sort them
foreach($players as $player){
if($player->channel == $channelid){
$users[$player->session] = $player->name;
}
if(!empty($users)){
asort($users);
}
}
//display users
if(!empty($users)){
foreach($users as $session => $username){
echo "\n <!-- New userline -->\n";
echo "<div class='div_clear'></div>";
//Spaces
for ($i = 1; $i <= $level[$channelid]; $i++){
if($printline[$i] == 1){
print "<div class='div_space'><img src = 'http://lavalit.com:8080/mumble/images/list_tree_line.gif' class='image' alt=''/></div>";
}
else{
print "<div class='div_space'><img src = 'http://lavalit.com:8080/mumble/images/list_empty.png' class='image' alt=''/></div>";
}
}
//last branch infront of an user
if($username == end($users) && $has_children == 0){
echo "<div class='div_space'><img src = 'http://lavalit.com:8080/mumble/images/list_tree_end.gif' class='image' alt=''/></div>";
}
else{
echo "<div class='div_space'><img src = 'http://lavalit.com:8080/mumble/images/list_tree_mid.gif' class='image' alt=''/></div>";
}
//html chars for users;
$username = html_chars($username);
echo "<div class='div_user' title=\"header=[<img src='http://lavalit.com:8080/mumble/images/stats_header.png' class = 'image_stats'/>Stats for ";
echo "$username";
echo "] body=[<img src='http://lavalit.com:8080/mumble/images/stats_online_time.png' class = 'image_stats'/><b>Time online:</b> ";
get_timeonline($session);
echo "<br/><img src = 'http://lavalit.com:8080/mumble/images/stats_visitor.png' class = 'image_stats'/><b>Visitor:</b> # $session]\">";
echo "<img src = 'http://lavalit.com:8080/mumble/images/list_user.png' class='image'/>";
echo "<span class='text_user'>$username</span>";
print_userflags($session);
echo "<div class = 'div_clear'></div>";
echo "\n<!-- End userline -->\n";
}
}
}
//display all userflags
function print_userflags($session){
global $players;
if($players[$session]->playerid != -1){
echo "<img src = 'http://lavalit.com:8080/mumble/images/flag_authenticated.png' class = 'image_flags' alt = ''/>";
}
if($players[$session]->mute == 1){
echo "<img src = 'http://lavalit.com:8080/mumble/images/flag_muted_server.png' class = 'image_flags' alt = ''/>";
}
if($players[$session]->deaf == 1){
echo "<img src = 'http://lavalit.com:8080/mumble/images/flag_deafened_server.png' class = 'image_flags' alt = ''/>";
}
if($players[$session]->selfMute == 1){
echo "<img src = 'http://lavalit.com:8080/mumble/images/flag_muted_self.png' class = 'image_flags' alt = ''/>";
}
if($players[$session]->selfDeaf == 1){
echo "<img src = 'http://lavalit.com:8080/mumble/images/flag_deafened_self.png' class = 'image_flags' alt = ''/>";
}
echo "</div>";
}
//boolean, if channeld has children
function has_children($id){
global $channels;
$has_children = children($channels, $id);
if(!empty($has_children)){
return true;
}
return false;
}
//onlinetime of an user
function get_timeonline($session){
global $players;
$onlinesecs = $players[$session]->onlinesecs;
$onlinesecs = $onlinesecs % (60 * 60 * 24);
$hours = intval($onlinesecs / (60 * 60));
$onlinesecs = $onlinesecs % (60 * 60);
$mins = intval($onlinesecs / 60);
$onlinesecs = $onlinesecs % 60;
if(strlen($hours)==1){
$hours = "0".$hours;
}
if(strlen($mins)==1){
$mins = "0".$mins;
}
if(strlen($onlinesecs)==1){
$onlinesecs = "0".$onlinesecs;
}
$time = $hours.":".$mins.":".$onlinesecs;
echo $time;
}
//correct html chars
function html_chars($string){
$string = str_replace ("ü", "ü", $string);
$string = str_replace ("ÃÅ"", "Ü", $string);
$string = str_replace ("ö", "ö", $string);
$string = str_replace ("Ãâ€"", "Ö", $string);
$string = str_replace ("ä", "ä", $string);
$string = str_replace ("Ä", "Ä", $string);
$string = str_replace ("ß", "ß", $string);
return $string;
}
?>
</body>
</html>
The first thing I would suggest is checking the path to the file. Usually the default directory for blocks is the Sources directory, so I would try
include("../mumble/MumbleViewer.php");
assuming that your "mumble" directory is on the same level as the "Sources" directory. Or you can put in the whole path.
I haven't looked at the code, but it's likely that there are paths to files within the file as well and that might be a problem. Hard to tell.
I've changed the paths from relative to hardcoded urls and it made no change. Its almost like a PHPBox doesn't support javascript. Because its aquiring the names from the channels (which doesn't use javascript) but the players and player stats are acquired from javascript. Any other hints...
Quotehardcoded urls
You can't use a url with an
include. You have to use a file path. Something like
/home/user/html/forum/mumble
QuoteIts almost like a PHPBox doesn't support javascript.
It doesn't. It supports php. If you have javascript, you need to use a script box. I was assuming that you were saying that there was javascript that was being implemented by php.
Maybe we should start over with what you are trying to do and I can help walk you through it.
I'm trying to take MumbleViewer.php and display it on the left hand side blocks. So far I have it semi working with it listing the channels but not the members when they are logged in. It works perfectly if I view MumbleViewer.php directly but when displaying it within a block it does not and I'm not sure why its only partially working.
So if a phpbox can't load a php file that uses javascript then is there an alternative?
Here is phpbox which include() MumbleViewer.php (Left hand Block called Mumble Status): http://lavalit.com:8080/index.php
Here is MumbleViewer.php: http://lavalit.com:8080/mumble/MumbleViewer.php
Yes, php can run javascript on a page. php will merely output text onto an html page. If it works on an html page, then it can be done with php, assuming that the paths are all working correctly.
Is that "lavalit" site yours? If so, what is it that you want to do that you're not able to do?
If it isn't yours, can I see your site so I can see what it's doing?
Yes, lavalit is mine. What I'm trying to accomplish is to have a block that displays the same information as MumbleViewer.php. Basically take MumbleViewer.php and embed it into a block. As you can see the current phpbox on the left hand side is not displaying all the information that the dedicated MumbleViewer.php is and I'm not sure why... I have hardcoded the path in the phpbox (/home/lavalitc/public_html/mumble/MumbleViewer.php) and all references to images i have placed the hardcoded url paths in MumbleViewer.php (http://lavalit.com:8080/mumble/etc....).
As you can see the MumbleViewer.php displays all the information about a channel and its users within channels and if you highlight a user you can see how long he has been online.
Within the phpbox it only displays channels and i don't understand why the user within the channel is not displayable, because its doing nothing more than calling MumbleViewer.php.
Thankyou by the way for all your help thus far!
I really don't know why it doesn't work the way you want it to. However, you might try using an iframe to display the Mumbleviewer.php page in the block. I've never used iframe myself, but if you do a search for it here on TP, you'll find lots and lots of references to it.
Thank You SO much iframe did the job but it was not expanding properly which was an easy fix by added a small script calculate the height of an iframe based on the source and then adjust it properly and its now displaying users and info perfectly as it should. I will remain logged into mumble, if you want to check it out. Once again Thank You for all your help!
Cool! I'm glad you were able to work it out. :)
Please share the todo / how to, i used a mumble server and will display its status in a left block
Marked solved then :up: