Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mesh
meshmap
Commits
a3e8836b
Commit
a3e8836b
authored
May 29, 2019
by
Eric - kg6wxc
Browse files
Added duplicate record finder for node_info table.
Also changed the test-mode output a bit.
parent
01a94932
Changes
3
Show whitespace changes
Inline
Side-by-side
scripts/checkDB.inc
View file @
a3e8836b
<?php
function
wxc_check4Dupes
()
{
//this function should clear out any duplicate entries in the node_info table.
//sometimes, for various reasons, you'll end up with 2 nodes, with the same IP.
//that causes the trigger topology_get_latlons_brg_dist to explode,
//and you see no link lines on the map
$findDupeQuery
=
mysqli_query
(
$GLOBALS
[
'sql_connection'
],
"select node, wlan_ip from node_info group by wlan_ip having count(wlan_ip) > 1"
);
if
(
mysqli_num_rows
(
$findDupeQuery
)
>
0
)
{
echo
"FOUND DUPLICATES IN NODE_INFO TABLE! NOW REPAIRING...
\n
"
;
echo
"Removed from Database:
\n
"
;
$findDupeQuery
=
mysqli_fetch_all
(
$findDupeQuery
,
MYSQLI_ASSOC
);
foreach
(
$findDupeQuery
as
$dupe
)
{
mysqli_query
(
$GLOBALS
[
'sql_connection'
],
"delete from node_info where wlan_ip = '"
.
$dupe
[
'wlan_ip'
]
.
"'"
);
echo
"
\t
"
.
$dupe
[
'node'
]
.
" (and it's duplicate) with wlan_ip's of "
.
$dupe
[
'wlan_ip'
]
.
"
\n
"
;
}
}
}
function
wxc_checkDB
()
{
//this function is now in its own file
...
...
scripts/get-map-info.php
View file @
a3e8836b
...
...
@@ -146,6 +146,8 @@ if ($do_sql) {
wxc_connectToMySQL
();
//check for new or changed database items (tables, columns,etc)
wxc_checkDB
();
//find and remove dupes in node_info
wxc_check4Dupes
();
}
else
{
if
(
$TEST_MODE_NO_SQL
)
{
wxc_echoWithColor
(
"SQL Server access disabled!"
,
"red"
);
...
...
@@ -621,6 +623,9 @@ if ($getNodeInfo) {
echo
"API Version: "
;
switch
(
$api_version
)
{
case
"1.7"
:
wxc_echoWithColor
(
$api_version
,
"greenBold"
);
break
;
case
"1.6"
:
wxc_echoWithColor
(
$api_version
,
"green"
);
break
;
...
...
scripts/wxc_functions.inc
View file @
a3e8836b
...
...
@@ -449,6 +449,9 @@ function wxc_echoWithColor ($text, $color) {
if
(
$color
==
"red"
)
{
echo
"
\33
[31m"
.
$text
.
"
\033
[0m"
;
}
if
(
$color
==
'redBold'
)
{
echo
"
\033
[1m
\33
[31m"
.
$text
.
"
\033
[0m"
;
}
if
(
$color
==
"purple"
)
{
echo
"
\033
[35m"
.
$text
.
"
\033
[0m"
;
}
...
...
@@ -458,8 +461,8 @@ function wxc_echoWithColor ($text, $color) {
if
(
$color
==
"green"
)
{
echo
"
\033
[32m"
.
$text
.
"
\033
[0m"
;
}
if
(
$color
==
're
d
Bold'
)
{
echo
"
\033
[1m
\33
[3
1
m"
.
$text
.
"
\033
[0m"
;
if
(
$color
==
'
g
re
en
Bold'
)
{
echo
"
\033
[1m
\33
[3
2
m"
.
$text
.
"
\033
[0m"
;
}
if
(
$color
==
'alert'
)
{
echo
"
\033
[41m
\033
[30m
\033
[1m"
.
$text
.
"
\033
[0m"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment