Fix display of ip_address in table editor table view.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 18 Mar 2008 20:28:53 +0000 (21:28 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 18 Mar 2008 20:28:53 +0000 (21:28 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/xorg.misc.inc.php
templates/core/table-editor.tpl

index c0afbad..2c8c88a 100644 (file)
@@ -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);
 }
 
 
index 4cc89ef..7bd9a4f 100644 (file)
@@ -64,6 +64,8 @@
       <span class="smaller">{$myrow.$myfield|date_format:"%x %X"}</span>
     {elseif $myval.Type eq 'checkbox'}
       <input type="checkbox" disabled="disabled"{if $myrow.$myfield} checked="checked"{/if}/>
+    {elseif $myval.Type eq 'ip_address'}
+      {$myrow.$myfield|uint_to_ip}
     {else}
       {$myrow.$myfield}
     {/if}