MyBB Community Forums

Full Version: Usermap
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Moved to dedicated server and now I get a big white screen! Any ideas? how to fix?
Is this plugin similar to the one in PageManager for Usermaps? I'm using one that I've added to PageManager.

Here's the page code you have to add to PageManager:

<?php

$key = 'ABQIAAAAUXQ1BTEcP3ol7-jg_ALa4hR-AkeDkvCafxJobph2cOPhDWGArxQw8RDowloYt_QsFl5MJFVbgViyTQ';
$location = 'United States';
$zoom = 3;
$fid = 1;
$datacache = './cache/coords';

if(!$mybb->usergroup['canviewprofiles'])
{
	error_no_permission();
}

global $headerinclude, $header, $theme, $footer, $cache, $templates;

require_once MYBB_ROOT.'inc/class_xml.php';
require_once MYBB_ROOT.'inc/functions_image.php';

$contents = fetch_remote_file('http://maps.google.com/maps/geo?q=' . rawurlencode($location) . '&output=xml');
$parser = new XMLParser($contents);
$tree = $parser->get_tree();

if($tree['kml']['Response']['Placemark']['Point']['coordinates']['value'])
{
	$location = explode(',', $tree['kml']['Response']['Placemark']['Point']['coordinates']['value']);
}
else
{
	$location = array(0, 0);
	$zoom = 2;
}

if(!file_exists($datacache) || time()-filemtime($datacache) > 169200 || ($mybb->usergroup['cancp'] && intval($mybb->input['update']) == 1))
{
	$usergroups_cache = $cache->read('usergroups');
	$query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts', 'order_dir' => 'DESC'));
	while($usertitle = $db->fetch_array($query))
	{
		$usertitles_cache[$usertitle['posts']] = $usertitle;
	}
	$query = $db->query("
		SELECT u.*, f.*
		FROM ".TABLE_PREFIX."users u
		LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
		WHERE f.fid" . $fid . " != ''
		AND u.usergroup NOT IN (5, 7)
	");

	$usercache = array();

	while($user = $db->fetch_array($query))
	{
		$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);

		$user['profilelink'] = build_profile_link($user['username'], $user['uid']);

		if(!$user['displaygroup'])
		{
			$user['displaygroup'] = $user['usergroup'];
		}
		$usergroup = $usergroups_cache[$user['displaygroup']];
		
		if(!empty($usergroup['image']))
		{
			if(!empty($mybb->user['language']))
			{
				$language = $mybb->user['language'];
			}
			else
			{
				$language = $mybb->settings['bblanguage'];
			}
			$usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']);
			$usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']);
			$usergroup['groupimage'] = '<img src="' . $usergroup['image'] . '" alt="' . $usergroup['title'] . '" title="' . $usergroup['title'] . '" />';
		}

		$has_custom_title = 0;
		if(trim($user['usertitle']) != "")
		{
			$has_custom_title = 1;
		}

		if($usergroup['usertitle'] != "" && !$has_custom_title)
		{
			$user['usertitle'] = $usergroup['usertitle'];
		}
		elseif(is_array($usertitles_cache) && !$usergroup['usertitle'])
		{
			foreach($usertitles_cache as $posts => $titleinfo)
			{
				if($user['postnum'] >= $posts)
				{
					if(!$has_custom_title)
					{
						$user['usertitle'] = $titleinfo['title'];
					}
					$user['stars'] = $titleinfo['stars'];
					$user['starimage'] = $titleinfo['starimage'];
					break;
				}
			}
		}

		if($usergroup['stars'])
		{
			$user['stars'] = $usergroup['stars'];
		}

		if(!$user['starimage'])
		{
			$user['starimage'] = $usergroup['starimage'];
		}
		$user['starimage'] = str_replace("{theme}", $theme['imgdir'], $user['starimage']);

		for($i = 0; $i < $user['stars']; ++$i)
		{
			$user['userstars'] .= "<img src=\"".$user['starimage']."\" border=\"0\" alt=\"*\" />";
		}

		if($user['userstars'] && $usergroup['groupimage'])
		{
			$user['userstars'] = "<br />".$user['userstars'];
		}

		if($user['avatar'] != '')
		{
			$user['avatar'] = htmlspecialchars_uni($user['avatar']);
			$avatar_dimensions = explode("|", $user['avatardimensions']);
			
			if($avatar_dimensions[0] && $avatar_dimensions[1])
			{
				list($max_width, $max_height) = explode("x", my_strtolower($mybb->settings['memberlistmaxavatarsize']));
				if($avatar_dimensions[0] > $max_width || $avatar_dimensions[1] > $max_height)
				{
					$scaled_dimensions = scale_image($avatar_dimensions[0], $avatar_dimensions[1], $max_width, $max_height);
					$avatar_width_height = "width=\"{$scaled_dimensions['width']}\" height=\"{$scaled_dimensions['height']}\"";
				}
				else
				{
					$avatar_width_height = "width=\"{$avatar_dimensions[0]}\" height=\"{$avatar_dimensions[1]}\"";	
				}
			}

			$user['avatar'] = '<img src="' . $user['avatar'] . '" alt="" ' . $avatar_width_height . ' />';
		}
		else
		{
			$user['avatar'] = "";
		}

		$html = '<table><tr><td>' . $user['avatar'] . '</td><td>' . $user['profilelink'] . '<br /><span class="smalltext">' . $user['usertitle'] . '<br />' . $usergroup['groupimage'] . $user['userstars'] . '</span></td></tr></table>';

		$home = strtolower($user['fid' . $fid]);

		if(isset($usercache[$home]))
		{
			$usercache[$home] .= '<hr>'.$html;
		}
		else
		{
			$usercache[$home] = $html;
		}
	}

	$coordscache = array();

	foreach($usercache as $index => $value)
	{
		$contents = fetch_remote_file('http://maps.google.com/maps/geo?q=' . rawurlencode($index) . '&output=xml');
		$parser = new XMLParser($contents);
		$tree = $parser->get_tree();

		sleep(1);
		
		if($tree['kml']['Response']['Placemark']['Point']['coordinates']['value'])
		{
			if(isset($coordscache[$tree['kml']['Response']['Placemark']['Point']['coordinates']['value']]))
			{
				$coordscache[$tree['kml']['Response']['Placemark']['Point']['coordinates']['value']] .= '<hr>'.$value;
			}
			else
			{
				$coordscache[$tree['kml']['Response']['Placemark']['Point']['coordinates']['value']] = $value;
			}
		}
	}

	file_put_contents($datacache, serialize($coordscache));
}
else
{
	$coordscache = unserialize(file_get_contents($datacache));
}

$run = 1;

foreach($coordscache as $index => $value)
{
	$point = explode(',', $index);
	$output .= '
		var point' . $run . ' = new GLatLng(' . $point[1] . ',' . $point[0] . ');
		var html' . $run . ' = "' . str_replace('"', "'", $value) . '";
		var info' . $run . ' = new GMarker(point' . $run . ');
		GEvent.addListener(info' . $run . ', "click", function() {
			info' . $run . '.openInfoWindowHtml(html' . $run . ')
		});
		map.addOverlay(info' . $run . ');
	';
	$run++;
}

$template = '<html>
<head>
<title>' . $pages['name'] . '</title>
{$headerinclude}
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=' . $key . '&amp;sensor=false" type="text/javascript"></script>
<script type="text/javascript">
' . html_entity_decode('&lt;!--/*--&gt;&lt;![CDATA[/*&gt;&lt;!--*/') . '
function initialize() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(' . $location[1] . ',' . $location[0] . '), ' . $zoom . ');
	map.setUIToDefault();
	{$output}
	}
}
' . html_entity_decode('/*]]&gt;*/--&gt;') . '
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
{$header}
<table border="0" cellspacing="' . $theme['borderwidth'] . '" cellpadding="' . $theme['tablespace'] . '" class="tborder">
<thead>
<tr>
<td class="thead">
<strong>' . $pages['name'] . '</strong>
</td>
</tr>
</thead>
<tbody>
<tr>
<td class="trow1" style="padding: 0;"><div id="map" style="width: 100%; height: 500px;"></div></td>
</tr>
</tbody>
</table>
<br />
{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>
(2011-08-27, 02:09 PM)RocketFoot Wrote: [ -> ]Moved to dedicated server and now I get a big white screen! Any ideas? how to fix?

Your Google API key is tied to a specific domain name. Did your domain name change when you switched servers?
(2011-08-28, 07:27 PM)laie_techie Wrote: [ -> ]
(2011-08-27, 02:09 PM)RocketFoot Wrote: [ -> ]Moved to dedicated server and now I get a big white screen! Any ideas? how to fix?

Your Google API key is tied to a specific domain name. Did your domain name change when you switched servers?

No, everything is the same except the IP address...
So, is this plugin even working for anyone ? If it does, are you really using the newer versions ? Because as soon as we upgraded it to a recent version, it completely stopped working.
Yeah, I had an older version...but now it's not working either
Hi,
how is it possible to limit the avatar size showing in bubble when hovering over a pin?


Greetings,
Fatmax1982
What about MyBB 1.8?
Any updates planned?
Going to bump this very old thread as I can't find any solution

Has anyone got a usermap working with MyBB?

I have tried > https://www.mybb.de/erweiterungen/18x/pl.../usermap2/ but it returns no map (before you ask - I have added the API code!)

I have also tried the Xthread method, but that also returns no map

Any ideas?
Don't know about this issue with this plugin. The plugin is working on my forum. Can you provide a link to your page?
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25