From: Florent Bruneau Date: Tue, 18 Mar 2008 20:28:53 +0000 (+0100) Subject: Fix display of ip_address in table editor table view. X-Git-Tag: xorg/0.9.16~101 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=bcf051059878214bcf12bdffd59f068ad21de669;p=platal.git Fix display of ip_address in table editor table view. Signed-off-by: Florent Bruneau --- diff --git a/include/xorg.misc.inc.php b/include/xorg.misc.inc.php index c0afbad..2c8c88a 100644 --- a/include/xorg.misc.inc.php +++ b/include/xorg.misc.inc.php @@ -232,24 +232,14 @@ function make_forlife($prenom, $nom, $promo) */ function ip_to_uint($ip) { - $part = explode('.', $ip); - $v = 0; - $fact = 0x1000000; - for ($i = 0 ; $i < 4 ; ++$i) { - $v += $fact * $part[$i]; - $fact >>= 8; - } - return $v; + return ip2long($ip); } /** Convert uint to ip (to build a human understandable ip) */ function uint_to_ip($uint) { - return sprintf('%d.%d.%d.%d', ($uint / 16777216) % 0xff, - ($uint / 65536) & 0xff, - ($uint / 256) & 0xff, - ($uint / 1.0) & 0xff); + return long2ip($uint); } diff --git a/templates/core/table-editor.tpl b/templates/core/table-editor.tpl index 4cc89ef..7bd9a4f 100644 --- a/templates/core/table-editor.tpl +++ b/templates/core/table-editor.tpl @@ -64,6 +64,8 @@ {$myrow.$myfield|date_format:"%x %X"} {elseif $myval.Type eq 'checkbox'} + {elseif $myval.Type eq 'ip_address'} + {$myrow.$myfield|uint_to_ip} {else} {$myrow.$myfield} {/if}