[DEV] Atlas Mod

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
cavallino
Registered User
Posts: 317
Joined: Thu Aug 04, 2005 7:06 am

Post by cavallino » Sat Jan 07, 2006 1:45 pm

jonemo wrote: boah, can't be bothered to reset the database again. i'll write a script for doing that, maybe tomorrow. my respect to the person who invests time to change all the config parameters just to deface a forum that has less visitors than the south pole.


How could they deface your forum if they didn't know your admin account rights? I mean... they maybe could change the password for test user but how they managed to access the admin?? And.... what was the phpbb version you had installed? :roll:

Anyway about your mod I've been knowing it and installed in my board since a lot before you showed it up here and I find it very good and uselful :) Thanks for it

ktbabe
Registered User
Posts: 73
Joined: Sun Apr 18, 2004 1:54 pm

Post by ktbabe » Sat Jan 07, 2006 4:14 pm

Is there anyway of stopping it resetting every time someone edits their profile?

User avatar
tahoebuff
Registered User
Posts: 1427
Joined: Tue Jul 20, 2004 12:33 am
Location: Nevada
Name: Michael
Contact:

Post by tahoebuff » Sat Jan 07, 2006 4:41 pm

What would a person do that uses other than the default phpbb_ table within his/her database? You have it hard coded to install with the default settings.

I changed two areas to reflect my table setting within the admin_atlas_mod.php and it's still not taking...

Tahoebuff

User avatar
jonemo
Registered User
Posts: 20
Joined: Wed Feb 27, 2002 7:12 pm
Location: london

Post by jonemo » Sat Jan 07, 2006 5:00 pm

ktbabe wrote: Is there anyway of stopping it resetting every time someone edits their profile?


ehm, don't quite get what you're saying. what exactly is resetting?
What would a person do that uses other than the default phpbb_ table within his/her database? You have it hard coded to install with the default settings.


You got me. That definitely is a bug. Do the following.

Find

Code: Select all

		$sql = "ALTER TABLE `phpbb_users` ADD `user_long` FLOAT( 6 ) NOT NULL ,
 ADD `user_lat` FLOAT( 6 ) NOT NULL";
		$db->sql_query($sql);
		
		$sql = "INSERT INTO `phpbb_config` ( `config_name` , `config_value` )
				VALUES ('atlas_start_long', '0'),
 						('atlas_start_lat', '0'),
						('atlas_start_zoom', '11'),
						('atlas_width', '600'),
						('atlas_height', '450'),
						('atlas_start_map_type', '0'),
						('atlas_google_api_key', '" . str_replace("\'", "''", $HTTP_POST_VARS['install_key']) . "'),
						('atlas_google_api_key_admin', '" . str_replace("\'", "''", $HTTP_POST_VARS['install_key_admin']) . "'),
						('atlas_control_glmc', 1),
						('atlas_control_gsmc', 0),
						('atlas_control_gszc', 0),
						('atlas_control_gmtc', 1),
						('atlas_override_center_to_user', 0),
						('atlas_override_automode', 0),
						('atlas_distance_unit', 'km')";
		$db->sql_query($sql);
and replace it with

Code: Select all

		$sql = "ALTER TABLE " . USERS_TABLE . " ADD `user_long` FLOAT( 6 ) NOT NULL ,
 ADD `user_lat` FLOAT( 6 ) NOT NULL";
		$db->sql_query($sql);
		
		$sql = "INSERT INTO " . CONFIG_TABLE . " ( `config_name` , `config_value` )
				VALUES ('atlas_start_long', '0'),
 						('atlas_start_lat', '0'),
						('atlas_start_zoom', '11'),
						('atlas_width', '600'),
						('atlas_height', '450'),
						('atlas_start_map_type', '0'),
						('atlas_google_api_key', '" . str_replace("\'", "''", $HTTP_POST_VARS['install_key']) . "'),
						('atlas_google_api_key_admin', '" . str_replace("\'", "''", $HTTP_POST_VARS['install_key_admin']) . "'),
						('atlas_control_glmc', 1),
						('atlas_control_gsmc', 0),
						('atlas_control_gszc', 0),
						('atlas_control_gmtc', 1),
						('atlas_override_center_to_user', 0),
						('atlas_override_automode', 0),
						('atlas_distance_unit', 'km')";
		$db->sql_query($sql);
that should be it as I do not use fixed table prefixes anywhere else. If you are still experiencing problems please tell me what exactly is not working. this issue will be resolved in 0.2.1.

ktbabe
Registered User
Posts: 73
Joined: Sun Apr 18, 2004 1:54 pm

Post by ktbabe » Sat Jan 07, 2006 5:05 pm

ok someone will put themself on the map....

then if they go to change something in their profile, they get taken off the map and have to set it again.

hope this makes sense!

User avatar
tahoebuff
Registered User
Posts: 1427
Joined: Tue Jul 20, 2004 12:33 am
Location: Nevada
Name: Michael
Contact:

Post by tahoebuff » Sat Jan 07, 2006 5:14 pm

Hmmmmmmmmm....it's still not taking. I had already changed those areas to reflect my tables. When I click on the map link it still continues to say the installation isn't completed.

Tahoebuff

nfan
Registered User
Posts: 3
Joined: Sat Jan 07, 2006 5:16 pm

Post by nfan » Sat Jan 07, 2006 5:21 pm

How would I change the font color in the bubble? It's using the correct color (a yellow) but that doesn't show up very well on a white bubble.

nfan
Registered User
Posts: 3
Joined: Sat Jan 07, 2006 5:16 pm

Post by nfan » Sat Jan 07, 2006 5:50 pm

Nevermind, I knew as soon as I posted it that I would find it.

User avatar
jonemo
Registered User
Posts: 20
Joined: Wed Feb 27, 2002 7:12 pm
Location: london

Post by jonemo » Sat Jan 07, 2006 6:54 pm

ktbabe wrote: ok someone will put themself on the map....

then if they go to change something in their profile, they get taken off the map and have to set it again.

hope this makes sense!


hm, i never use the function to edit users via the admin panel but rather do that directly in the database. therefore i might have missed this bug. The next time I have enough spare time I will have a look into that issue.

For all people who find bugs: It would help me very much if you post them in the support forum on http://jonemo.de/atlasmod/forum/ as a new thread. This way I will certainly not miss one out and I can easily give you feedback and notifiy you when the bug is resolved by just replying to that post.

@tahoebuff: That seems strange to me. Are you sure you submitted the form shown (with the two input fields for the keys) once? What was the result of that operation? Have you tried doing the operations manually?

User avatar
jonemo
Registered User
Posts: 20
Joined: Wed Feb 27, 2002 7:12 pm
Location: london

Post by jonemo » Sat Jan 07, 2006 7:02 pm

Could you please resist from posting your problems/bugs/suggestions here and in the support forum at the same time? This will not result in a faster reply from me and only causes confusion.

Caio Borghoff
Registered User
Posts: 8
Joined: Tue Jan 03, 2006 5:58 am
Location: Brasil
Contact:

Post by Caio Borghoff » Sun Jan 08, 2006 8:06 am

A small contribution:

This code will add a link to the poster coordinates on the map, below his avatar. It will replace the standard location text.

Only posters with location and coordinates on their profile will display this link. Viewers without coordinates will not be able to see the distance and guests will see the default map.

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php

#
#-----[ FIND ]------------------------------------------
#
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from,

#
#-----[ IN-LINE FIND ]------------------------------------------
#
u.user_from,

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
#
u.user_long, u.user_lat,


#
#-----[ FIND ]------------------------------------------
#
    $poster_from .= ( $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] : '';
#
#-----[ REPLACE WITH ]------------------------------------------
#
    $poster_from = ( $postrow[$i]['user_long'] && $postrow[$i]['user_lat'] && $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("atlasviewpost.$phpEx?mode=distance&" . POST_USERS_URL . '=' . $poster_id) . '" class="genmed">' : '';
	$poster_from .= ( $postrow[$i]['user_long'] && $postrow[$i]['user_lat'] && $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] : '';
	$poster_from .= ( $postrow[$i]['user_long'] && $postrow[$i]['user_lat'] && $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? '</a>' : '';

Then, save this code as "atlasviewprofile.php" and put it together with "atlas.php".

Code: Select all

<?php
/***************************************************************************
 *
 *   MOD                  : Atlas MOD
 *   file                 : gmap.php
 *   copyright            : (C) 2005 Jonas Neubert
 *   web                  : www.jonemo.de
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_GMAP);
init_userprefs($userdata);
//
// End session management
//

//
// Start Determining what page type has to be shown
//

// (mode="xml") means that this file is called via XmlHttpRequest from a JavaScript
if ($HTTP_GET_VARS['mode'] == 'xml')
{
	include($phpbb_root_path . 'includes/atlas_xml.php');
	die();
}

// all other modes than "xml" mean that a page will be shown to the user that contains a map of some sort
define('SHOW_ONLINE', true);
$page_title = $lang['GMap'];
include($phpbb_root_path . 'includes/atlas_functions.' . $phpEx);

// (mode="findcoords") is shown in a popup, therefore we show a simple header
if ($HTTP_GET_VARS['mode'] === 'findcoords')
	$gen_simple_header = true;

include($phpbb_root_path . 'includes/page_header.'.$phpEx);

// no matter which mode, all have the same template
$template->set_filenames(array(
    'body' => 'atlas_view.tpl')
);

//
// End Determining what page type has to be shown
//



if (!isset($board_config['atlas_google_api_key']))
{
	message_die(GENERAL_ERROR, sprintf($lang['AtlasError_not_finished_install']));
}
else
{
	$template->assign_block_vars('atlasmod', array());
	$template->assign_block_vars('switch_installed', array());
	
	// (mode="findcoords") means that no users are shown in the map but the map is used to find
	// the coordinates of a place and maybe also to set the zoom level and map type and so
	// "findcoords" is either called from a user editing his/her profile or from the
	// general board configuration where the admin wants to set the initial values for the map
	if ($HTTP_GET_VARS['mode'] === 'findcoords')
	{
		$l_map_title = $lang['GMap_find_coordinates'];
		$l_explain = $lang['GMap_find_coordinates_explain'];
		
		$modus = 3;
	}
	
	// (mode="viewmap") means that the page where all users are shown in a map is displayed
	elseif ($HTTP_GET_VARS['mode'] === 'viewmap' && $userdata["session_logged_in"])
	{
		$modus = 1;
	}
	
	// (mode="distance") means that the distance to another user is to be shown
	elseif ($HTTP_GET_VARS['mode'] == 'distance' && $userdata["session_logged_in"])
	{
		if (is_numeric($HTTP_GET_VARS['u']))
		{
          if ($userdata['user_long'] != 0 && $userdata['user_lat'] != 0)
          {
			$sql = "SELECT user_id, username, user_long, user_lat FROM " . USERS_TABLE . " WHERE user_id = '" . $HTTP_GET_VARS['u'] . "'";
			$erg = $db->sql_query($sql);
			$row = $db->sql_fetchrowset($erg);
	
			$distance_parameters['lon'] = $row[0]['user_long'];
			$distance_parameters['lat'] = $row[0]['user_lat'];
			$distance_parameters['pid'] = $row[0]['user_id'];
			$distance_parameters['username'] = $row[0]['username'];
			
			$start_long = ( $row[0]['user_long'] + $userdata['user_long'] ) / 2;
			$start_lat = ( $row[0]['user_lat'] + $userdata['user_lat'] ) / 2;
			
			$modus = 2;
          }
          else
          {
            $distance = sprintf($lang['Atlas_Show_user_on_map'], $profiledata['username']);
            $distance_link = append_sid($phpbb_root_path. 'profile.' . $phpEx . '?mode=editprofile');
          }
		}
	}
	
	// this comes into action when an anonymous user wants to do anything else than set his coordinates (during registration)
	else
	{
		$l_explain = $lang['GMap_Please_log_in'];
		$modus = -1;
	}
	
	// where to center the map at the beginning
	if (empty($start_long) || empty($start_lat))
	{
		if ($board_config['atlas_override_center_to_user'] == 1)
		{
			$start_long = $userdata['user_long'];
			$start_lat = $userdata['user_lat'];
		}
		elseif ($board_config['atlas_override_automode'] == 1)
		{
			$sql = "SELECT MIN(user_long) AS min_long, MAX(user_long) AS max_long, MIN(user_lat) AS min_lat, MAX(user_lat) AS max_lat FROM " . USERS_TABLE . " WHERE user_long != '' AND user_lat != ''";
			$erg = $db->sql_query($sql);
			$limits = $db->sql_fetchrow($erg);
			
			$start_long	= $limits['min_long'] + ( $limits['max_long'] - $limits['min_long'] ) / 2;
			$start_lat	= $limits['min_lat'] + ( $limits['max_lat'] - $limits['min_lat'] ) / 2;
			$start_zoom_level = 'auto';
		}
		else
		{
			$start_long = $board_config['atlas_start_long'];
			$start_lat = $board_config['atlas_start_lat'];
		}
	}
	
	//
	// Most of the settings and stuff is general (for all modes) and is done here:
	//
	
	/*
		possible modi for calling this page are:
			1 => view the map with all usercoordinates
			2 => view the distance to another user
			3 => "find coordinates"
			4 => adminpanel
	*/
	
	make_atlasmod_js ($modus, $start_long, $start_lat, $start_zoom_level, $limits, $distance_parameters);
	
	$template->assign_vars(array(
		'MAP_WIDTH' => intval($board_config['atlas_width']) . 'px',
		'MAP_HEIGHT' => intval($board_config['atlas_height']) . 'px',
		'L_MAP_TITLE' => ( empty($l_map_title) ) ? $lang['GMap'] : $l_map_title,
		'L_EXPLAIN' => ( empty($l_explain) ) ? '' : $l_explain
	));
}

//
// Generate the page
//
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
NOTE: Despite the fact that it is working for me, I'm not a programmer. So please do not use this additional code unless you are pretty much sure what your are doing.

By the way, I would like to thank Jonas Neubert for this incredible MOD.

**Sorry for any spelling errors. English is my second language**

User avatar
okada1314
Registered User
Posts: 209
Joined: Sat Oct 29, 2005 10:51 am

Post by okada1314 » Sun Jan 08, 2006 2:05 pm

why my map have a erro page?

User avatar
jonemo
Registered User
Posts: 20
Joined: Wed Feb 27, 2002 7:12 pm
Location: london

Post by jonemo » Sun Jan 08, 2006 2:18 pm

okada1314 wrote: why my map have a erro page?


Well, if you read the error message, you should know, why. There is no satellite imagery at that zoom level. as i see you have only one user in your forum this behaviour my have been caused by the "automatic override" setting at the very bottom of the Admin Panel page. Make sure both of the override features are switched off when testing.

993ti
Registered User
Posts: 119
Joined: Sat Nov 02, 2002 1:16 am
Location: The Netherlands
Contact:

Post by 993ti » Mon Jan 09, 2006 1:51 am

Would be cool when users can enter their city and a dropdownlist is shown with available cities.
frappr.com has that and it's more userfriendly.
I had a javascript map mod once where users could enter the cities and that worked great too.
Don't steal, the government doesn't like competition!
Admin of Twenteracingscene
Streetcars
Aibo-forum
iRobot Roomba and Scooba for sale
Faqs Board
Online Sales

starwarz2
Registered User
Posts: 44
Joined: Tue Jan 03, 2006 4:22 pm
Location: Sweden

Post by starwarz2 » Mon Jan 09, 2006 10:28 am

993ti wrote: Would be cool when users can enter their city and a dropdownlist is shown with available cities.
frappr.com has that and it's more userfriendly.
I had a javascript map mod once where users could enter the cities and that worked great too.


Yeah that would be cool. Do you share that java script here? Do you have any demo of it ?

Post Reply

Return to “[2.0.x] MODs in Development”