Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

! fixed error with county only database and Invalid Value Sent to Dat…

…abase error

! fixed issue with external lookups parsing
! fixed issue with duplicate language strings
! some code cleaning
  • Loading branch information...
commit d683a5bb01e42e02d7fcab6ae3828ed048162fea 1 parent 7d78147
@Spuds authored
View
84 Sources/geoIP.php
@@ -7,7 +7,7 @@
* @copyright (c) 2011 Spuds
* @license license.txt (included with package) BSD
*
- * @version 1.1
+ * @version 1.1.1
*
*/
@@ -26,14 +26,14 @@
function geoIP()
{
global $db_prefix, $context, $txt, $smcFunc, $modSettings;
-
+
// whos online enabled and geoip enabled are required
if (!empty($modSettings['who_enabled']) && !empty($modSettings['geoIP_enablemap']));
{
// First are they allowed to view whos online and the online map?
isallowedTo(array('geoIP_view'));
isallowedTo(array('who_view'));
-
+
// language files
loadLanguage('geoIP');
@@ -43,7 +43,7 @@ function geoIP()
// requesting the XML details or the JS file?
if (isset($_GET['sa']) && $_GET['sa'] == '.xml')
return geoMapsXML();
-
+
if (isset($_GET['sa']) && $_GET['sa'] == '.js')
return geoMapsJS();
@@ -65,24 +65,24 @@ function geoIP()
function geoMapsJS()
{
global $db_prefix, $context, $scripturl, $txt, $modSettings;
-
+
// what type of pin are we using?
$npin = $modSettings['npin'];
$mshd = (!empty($modSettings['geoIPPinShadow'])) ? $mshd = '_withshadow' : $mshd = '';
// Validate the icon size to keep from breaking
$m_iconsize = (isset($modSettings['geoIPPinSize']) && $modSettings['geoIPPinSize'] > 19) ? $modSettings['geoIPPinSize'] : 20;
-
+
// set our member and pin sizes the image sizes are 21 X 34 for standard 40 X 37 with a shadow
// we need to tweak the sizes based on these W/H ratios to maintain aspect ratio and overall size so that a mixed shadown./no appear the same size
$m_icon_w = ($mshd != '') ? $m_iconsize * 1.08 : $m_iconsize * .62;
$m_icon_h = $m_iconsize;
-
+
// Now set all those anchor points based on the icon size, icon at pin mid bottom, info mid top(ish)....
$m_iconanchor_w = ($mshd != '') ? $m_icon_w / 3 : $m_icon_w / 2;
$m_iconanchor_h = $m_icon_h;
$m_infoanchor_h = $m_icon_h / 4;
-
+
// Lets dump everything in the buffer so we can return nice clean javascript to the template
ob_end_clean();
if (!empty($modSettings['enableCompressedOutput']))
@@ -90,7 +90,7 @@ function geoMapsJS()
else
ob_start();
ob_start('ob_sessrewrite');
-
+
echo '// Read the xml data
var xhr = false;
function makeRequest(url) {
@@ -178,7 +178,7 @@ function makeMarkers(xmldoc) {
var label = markers[i].getAttribute("label");
var marker = createMarker(point, pic, label, html, i);
}
-
+
// put the assembled sidebar_html contents into the sidebar div
document.getElementById("gooSidebar").innerHTML = sidebar_html;
}
@@ -192,18 +192,18 @@ function createMarker(point, pic, name, html, i) {
infowindow = new google.maps.InfoWindow({content: html});
infowindow.open(map, marker);
});
-
+
// save the info we need to use later for the sidebar
gmarkers[i] = marker;
htmls[i] = html;
-
+
// add a line to the sidebar html';
if ($modSettings['geoIPSidebar'] == 'right')
- echo '
+ echo '
sidebar_html += \'<a href="javascript:myclick(\' + i + \')">\' + name + \'</a><br /> \';';
-
+
if ($modSettings['geoIPSidebar'] == 'none')
- echo '
+ echo '
sidebar_html += \'<a href="javascript:myclick(\' + i + \')">\' + name + \'</a>, \';';
echo '
@@ -253,7 +253,7 @@ function geoMapsXML()
$temp = array();
$ips = array();
$spider = false;
-
+
// can they see spiders ... ewww stomp em :P
if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
$spider = '(lo.id_member = 0 AND lo.id_spider > 0)';
@@ -288,7 +288,7 @@ function geoMapsXML()
'city' => $row['city'],
'cc' => $row['cc'],
);
-
+
// keep track of the members vs guests/spiders
if (!empty($row['id_member']))
$temp[] = $row['id_member'];
@@ -297,7 +297,7 @@ function geoMapsXML()
}
}
$smcFunc['db_free_result']($request);
-
+
// Get the geoIP information for these members
$memberIPData = geo_search($ips);
@@ -305,7 +305,7 @@ function geoMapsXML()
loadMemberData($temp);
foreach ($temp as $v)
loadMemberContext($v);
-
+
// Let's actually start making the XML
echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>
<markers>';
@@ -318,7 +318,7 @@ function geoMapsXML()
// no location ... no pin ;)
if (empty($memberIPData[$marker['id']]['latitude']) && empty($memberIPData[$marker['id']]['longitude']))
continue;
-
+
// if they are allowed to see the user info to pin, build the blurb.
if (!empty($modSettings['geoIP_enablepinid']) || allowedTo('moderate_forum'))
{
@@ -328,7 +328,7 @@ function geoMapsXML()
<td style="white-space: nowrap;" align="left">
<a href="' . $marker['href'] . '">' . $marker['name'] . '</a>
</td>';
-
+
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($marker['avatar']['image']))
$datablurb .= '<td style="height:100px;width:100px" rowspan="2">' . $marker['avatar']['image'] . '</td>';
@@ -338,7 +338,7 @@ function geoMapsXML()
</tr>
<tr>
<td style="white-space: nowrap;" align="left">' . $marker['post_group'] . '<br />' . $marker['group_stars'] . '</td>';
-
+
$datablurb .= '
</tr>
<tr>
@@ -366,7 +366,7 @@ function geoMapsXML()
echo $markers;
}
}
-
+
// and now those lovely little guests and spiders as well
if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
$spidernames = unserialize($modSettings['spider_name_cache']);
@@ -379,7 +379,7 @@ function geoMapsXML()
$markers .= 'label="' . $marker['name'] . '"><![CDATA[' . $marker['name'] . ']]></marker>';
echo $markers;
}
-
+
echo '
</markers>';
@@ -397,11 +397,11 @@ function geoMapsXML()
function geo_buildpins()
{
global $modSettings;
-
+
// lets work out all those options
$modSettings['geoIPPinBackground'] = geo_validate_color('geoIPPinBackground', '66FF66');
$modSettings['geoIPPinForeground'] = geo_validate_color('geoIPPinForeground', '202020');
-
+
// what kind of pins have been chosen
$mpin = geo_validate_pin('geoIPPinStyle', 'd_map_pin_icon');
@@ -417,7 +417,7 @@ function geo_buildpins()
$mpin = 'd_map_pin_letter';
$mchld = '';
}
-
+
// and now for the colors
$mchld .= '|' . $modSettings['geoIPPinBackground'] . '|' . $modSettings['geoIPPinForeground'];
@@ -443,15 +443,15 @@ function geo_buildpins()
function geo_validate_color($color,$default)
{
global $modSettings;
-
+
// no leading #'s please
if (substr($modSettings[$color], 0, 1) == '#')
$modSettings[$color] = substr($modSettings[$color],1);
-
+
// is it a hex
if (!preg_match('/^[a-f0-9]{6}$/i', $modSettings[$color]))
$modSettings[$color] = $default;
-
+
return strtoupper($modSettings[$color]);
}
@@ -487,7 +487,7 @@ function geo_validate_pin($area, $default)
}
else
$pin = $default;
-
+
return $pin;
}
@@ -534,7 +534,7 @@ function geo_search($ip_input, $search = true)
require_once ($sourcedir . '/Subs-Package.php');
$memberIPData = array();
$ips = array();
-
+
// It must be an array, even if we are only looking up one IP
if (!is_array($ip_input))
$ips = array($ip_input);
@@ -584,7 +584,7 @@ function geo_search($ip_input, $search = true)
'ip' => (int) $ip
)
);
-
+
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$memberIPData[$member] = false;
@@ -598,7 +598,7 @@ function geo_search($ip_input, $search = true)
{
// did not find a full match, likely the center of a country, so try an external service
$data = fetch_web_data('http://api.hostip.info/get_html.php?ip=' . geo_dot2long($ip) . '&position=true');
- if (preg_match('~Country: (.*(?:\((.*)\))?)\n?City: (.*)\n?Latitude: (.*)\nLongitude: (.*)\n~isU', $data, $match))
+ if (preg_match('~Country: (.*(?:\((.*)\)))\n?City: (.*)\n?Latitude: (.*)\nLongitude: (.*)\n~isU', $data, $match))
{
// We trust the country & data from geomind just a bit more
if (!empty($match[2]) && $match[2] == $row['cc'])
@@ -608,7 +608,7 @@ function geo_search($ip_input, $search = true)
$memberIPData[$member]['city'] = $match[3];
$memberIPData[$member]['latitude'] = $match[4];
$memberIPData[$member]['longitude'] = $match[5];
-
+
// now update the online log so we don't do this again if it was for an online user ofcourse
if (!empty($memberIPData[$member]['session']))
geo_save_data($memberIPData[$member]);
@@ -637,10 +637,10 @@ function geo_search($ip_input, $search = true)
function geo_search_lite($ip_input, $search = false)
{
global $smcFunc, $sourcedir;
-
+
require_once ($sourcedir . '/Subs-Package.php');
$ips = array();
-
+
// It must be an array
if (!is_array($ip_input))
$ips = array($ip_input);
@@ -668,7 +668,7 @@ function geo_search_lite($ip_input, $search = false)
// make sure its an int an not in a 1.2.3.4 format
if (strpos($ip,'.'))
$ip = geo_dot2long($ip);
-
+
$request = $smcFunc['db_query']('', '
SELECT ip.start, ip.end,
gc.cc, gc.cn as country
@@ -692,13 +692,13 @@ function geo_search_lite($ip_input, $search = false)
$memberIPData[$member] = $row;
$memberIPData[$member]['city'] = '';
$memberIPData[$member]['region'] = '';
- $memberIPData[$member]['latitude'] = '';
- $memberIPData[$member]['longitude'] = '';
+ $memberIPData[$member]['latitude'] = 0.0;
+ $memberIPData[$member]['longitude'] = 0.0;
if ($search)
{
// We want more so use an external service
$data = fetch_web_data('http://api.hostip.info/get_html.php?ip=' . geo_dot2long($ip) . '&position=true');
- if (preg_match('~Country: (.*(?:\((.*)\))?)\n?City: (.*)\n?Latitude: (.*)\nLongitude: (.*)\n~isU', $data, $match))
+ if (preg_match('~Country: (.*(?:\((.*)\)))\n?City: (.*)\n?Latitude: (.*)\nLongitude: (.*)\n~isU', $data, $match))
{
// We trust the country & data from geomind more, so make sure the CC's match before adding
if (!empty($match[2]) && $match[2] == $row['cc'])
@@ -721,7 +721,7 @@ function geo_search_lite($ip_input, $search = false)
function geo_save_data($data)
{
global $smcFunc;
-
+ $data=array();
// simply update this session with the newly found data
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_online
View
8 Sources/geoIPAdmin.php
@@ -7,7 +7,7 @@
* @copyright (c) 2011 Spuds
* @license license.txt (included with package) BSD
*
- * @version 1.1
+ * @version 1.1.1
*
*/
@@ -588,7 +588,7 @@ function geoIPMapSettings()
'info' => $txt['info'],
'landslide' => $txt['landslide'],
'legal' => $txt['legal'],
- 'location' => $txt['location'],
+ 'location' => $txt['location1'],
'locomotive' => $txt['locomotive'],
'medical' => $txt['medical'],
'mobile' => $txt['mobile'],
@@ -737,11 +737,11 @@ function geoIP_importCsv($filename, $tablename, $extra = '', $remove = true)
// make the everything safe for our query, ** yup load data is mysql ONLY, sorry to non conformers
$query = 'LOAD DATA LOCAL INFILE {string:filename} INTO TABLE {db_prefix}' . $tablename . ' FIELDS TERMINATED BY {string:comma} OPTIONALLY ENCLOSED BY {string:quote} LINES TERMINATED BY {string:break}';
- $query = $smcFunc['db_quote']($query,array('filename' => $filename, 'comma' => ',', 'quote' => '"', 'break' => "\n"));
+ $query = $smcFunc['db_quote']($query, array('filename' => $filename, 'comma' => ',', 'quote' => '"', 'break' => "\n"));
// Load all the new data in one big gulp
$connection = ($connection == null ? @mysql_connect($db_server, $db_user, $db_passwd) : $connection);
- $result = mysql_query($query,$connection);
+ $result = mysql_query($query, $connection);
if ($result)
{
if ($remove)
View
4 install-readme.txt
@@ -39,6 +39,10 @@ This mod is compatible with SMF 2.0 Only.
Please use the geoIP modification thread for support with this modification.
[color=blue][b][size=12pt][u]Changelog[/u][/size][/b][/color]
+[b]1.1.1 - 23 Jan 2012[/b]
+! fixed error with county only database and Invalid Value Sent to Database error
+! fixed issue with external lookups parsing
+
[b]1.1 - 08 Dec 2011[/b]
+ Country flags next to member names in whos online list
+ Membergroup permissions for IDing member pin on online map (was on/off for all)
View
2  language/geoIP.english-utf8.php
@@ -116,7 +116,7 @@
$txt['info'] = 'info';
$txt['landslide'] = 'landslide';
$txt['legal'] = 'legal';
-$txt['location'] = 'location';
+$txt['location1'] = 'location';
$txt['locomotive'] = 'locomotive';
$txt['medical'] = 'medical';
$txt['mobile'] = 'mobile';
View
2  language/geoIP.english.php
@@ -116,7 +116,7 @@
$txt['info'] = 'info';
$txt['landslide'] = 'landslide';
$txt['legal'] = 'legal';
-$txt['location'] = 'location';
+$txt['location1'] = 'location';
$txt['locomotive'] = 'locomotive';
$txt['medical'] = 'medical';
$txt['mobile'] = 'mobile';
View
2  package-info.xml
@@ -3,7 +3,7 @@
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>spuds:geoipMod</id>
<name>geoIP Location</name>
- <version>1.1</version>
+ <version>1.1.1</version>
<type>modification</type>
<install for="2.0 - 2.0.99">
Please sign in to comment.
Something went wrong with that request. Please try again.