Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display of IP addresses in server module; fix binary IP handling in MasterForm #387

Merged
merged 11 commits into from Feb 21, 2019
Merged
6 changes: 5 additions & 1 deletion inc/Classes/MasterForm.php
Expand Up @@ -506,7 +506,11 @@ public function SendForm($BaseURL, $table, $idname = '', $id = 0)
$db_query = '';
if ($this->SQLFields) {
foreach ($this->SQLFields as $val) {
$db_query .= ", $val";
if ($SQLFieldTypes[$val] == 'varbinary(16)' and $val == 'ip') {
M4LuZ marked this conversation as resolved.
Show resolved Hide resolved
$db_query .= ', INET6_NTOA('.$val.') AS '.$val;
} else {
$db_query .= ", $val";
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/server/search.inc.php
Expand Up @@ -13,7 +13,7 @@
$ms2->AddSelect('u.userid');
$ms2->AddResultField(t('Name'), 's.caption');
$ms2->AddResultField(t('Servertyp'), 's.type', 'ServerType');
$ms2->AddResultField(t('IP-Adresse / Domain'), 's.ip');
$ms2->AddResultField(t('IP-Adresse / Domain'), 'INET6_NTOA(s.ip) AS ip');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be this realip then? Or doesn't it have a direct relation to the other usages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... I initially fixed this code (overview page) and then noticed that the details view was still broken.
I didn't want to go far from "ip" here because that's how that field was always called.
However, in show_details.php a select * is done which also returns "a.ip" as "ip". Now if I would have called the INET6_NTOA result "ip" as well that query would return both columns as "ip" ... which would become rather interesting I guess; at least confusing. I then looked at the amount of columns of the server table and ended up with calling that field realip.
Reconsidering this, I guess the best way would be me changing this in show_details.php from a SELECT * to specifying all the columns and also calling the resulting field "ip" there.
What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reconsidering this, I guess the best way would be me changing this in show_details.php from a SELECT * to specifying all the columns and also calling the resulting field "ip" there.

Yes. I am for this. Personally, I like to avoid SELECT * and to make it explicit which fields you are requesting. Often this makes things easier. Do you want to adjust it in this PR or in a new one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do it here.

$ms2->AddResultField(t('Port'), 's.port');
$ms2->AddResultField(t('Besitzer'), 'u.username', 'UserNameAndIcon');
$ms2->AddResultField('PW', 's.pw', 'PWIcon');
Expand Down
14 changes: 13 additions & 1 deletion modules/server/show_details.php
Expand Up @@ -3,7 +3,19 @@

$server = $db->qry_first("
SELECT
a.*,
a.serverid,
a.owner,
a.caption,
a.text,
INET6_NTOA(a.ip) AS ip,
a.mac,
a.port,
a.os,
a.cpu,
a.ram,
a.hdd,
a.type,
a.pw,
b.userid,
b.username
FROM %prefix%server AS a
Expand Down