</th><th><?php 
__("IP");
?>
</th><th><?php 
__("Informations");
?>
</th><th colspan='2' /></tr>
      <?php 
foreach ($list_ip as $i) {
    if (checkip($i['ip'])) {
        if ($i['subnet'] == 32) {
            $txt = "Address IPv4";
        } else {
            $txt = "Subnet IPv4";
        }
    } elseif (checkipv6($i['ip'])) {
        if ($i['subnet'] == 128) {
            $txt = "Address IPv6";
        } else {
            $txt = "Subnet IPv6";
        }
    } else {
        $txt = "Unknow IP";
    }
    echo "<tr class='lst'><td>{$txt}</td><td>{$i['ip_human']}</td><td>{$i['infos']}</td>";
    ?>
        <td><div class="ina edit"><a href="javascript:edit_ip(<?php 
    echo "'" . htmlentities($i['id']) . "','" . htmlentities($i['ip_human']) . "','" . htmlentities($i['infos']) . "'";
    ?>
);"><?php 
    __("Edit");
Example #2
0
 /**
  * Sauvegarde une IP dans les IP authorisée
  * 
  * @global    m_mysql $db
  * @global    m_mem   $mem
  * @global int $cuid
  * @param     int     $id     id de la ligne à modifier. Si vide ou
  *                            égal à 0, alors c'est une insertion
  * @param     string  $ipsub  IP (v4 ou v6), potentiellement avec un subnet ( /24)
  * @param     string  $infos  Commentaire pour l'utilisateur
  * @param     int     $uid    Si $uid=0 et qu'on est super-admin, insertion avec uid=0
  *                            ce qui correspond a une ip toujours authorisée 
  * @return    boolean         Retourne FALSE si erreur, sinon TRUE
  * 
  */
 function ip_save($id, $ipsub, $infos, $uid = null)
 {
     global $db, $mem;
     // If we ask for uid=0, we have to check to be super-user
     // else, juste use global cuid;
     if ($uid === 0 && $mem->checkRight()) {
         $cuid = 0;
     } else {
         global $cuid;
     }
     $id = intval($id);
     $infos = mysql_real_escape_string($infos);
     // Extract subnet from ipsub
     $tmp = explode('/', $ipsub);
     $ip = $tmp[0];
     // Error if $ip not an IP
     if (!checkip($ip) && !checkipv6($ip)) {
         echo "Failed : not an IP address";
         return false;
     }
     // Check the subnet, if not defined, give a /32 or a /128
     if (isset($tmp[1])) {
         $subnet = intval($tmp[1]);
     } else {
         if (checkip($ip)) {
             $subnet = 32;
         } else {
             $subnet = 128;
         }
     }
     // An IPv4 can't have subnet > 32
     if (checkip($ip) && $subnet > 32) {
         $subnet = 32;
     }
     if ($id) {
         // Update
         $list_affected = $this->list_affected($id);
         foreach ($list_affected as $k => $v) {
             $this->call_hooks("authip_on_delete", $k);
         }
         if (!$db->query("update authorised_ip set ip='{$ip}', subnet='{$subnet}', infos='{$infos}' where id='{$id}' and uid='{$cuid}' ;")) {
             echo "query failed: " . $db->Error;
             return false;
         }
         foreach ($list_affected as $k => $v) {
             $this->call_hooks("authip_on_create", $k);
         }
     } else {
         // Insert
         if (!$db->query("insert into authorised_ip (uid, ip, subnet, infos) values ('{$cuid}', '{$ip}', '{$subnet}', '{$infos}' );")) {
             echo "query failed: " . $db->Error;
             return false;
         }
     }
     return true;
 }
Example #3
0
 /**
  * @param integer $type
  * @param string $value
  */
 function check_type_value($type, $value)
 {
     global $db, $err, $cuid;
     // check the type we can have in domaines_type.target
     switch ($this->domains_type_target_values($type)) {
         case 'NONE':
             if (empty($value) or is_null($value)) {
                 return true;
             }
             break;
         case 'URL':
             if ($value == strval($value)) {
                 if (filter_var($value, FILTER_VALIDATE_URL)) {
                     return true;
                 } else {
                     $err->raise("dom", _("invalid url"));
                     return false;
                 }
             }
             break;
         case 'DIRECTORY':
             if (substr($value, 0, 1) != "/") {
                 $value = "/" . $value;
             }
             if (!checkuserpath($value)) {
                 $err->raise("dom", _("The folder you entered is incorrect or does not exist"));
                 return false;
             }
             return true;
             break;
         case 'IP':
             if (checkip($value)) {
                 return true;
             } else {
                 $err->raise("dom", _("The ip address is invalid"));
                 return false;
             }
             break;
         case 'IPV6':
             if (checkipv6($value)) {
                 return true;
             } else {
                 $err->raise("dom", _("The ip address is invalid"));
                 return false;
             }
             break;
         case 'DOMAIN':
             if (checkcname($value)) {
                 return true;
             } else {
                 $err->raise("dom", _("The name you entered is incorrect"));
                 return false;
             }
             break;
         case 'TXT':
             if ($value == strval($value)) {
                 return true;
             } else {
                 $err->raise("dom", _("The TXT value you entered is incorrect"));
                 return false;
             }
             break;
         default:
             $err->raise("dom", _("Invalid domain type selected, please check"));
             return false;
             break;
     }
     return false;
 }
Example #4
0
                break;
            case "password":
                $password = $regs[2];
                break;
            case "host":
                $host = $regs[2];
                break;
        }
    }
    # Then, read specific alternc configuration
    if (preg_match('/^#alternc_var ([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
        ${$regs}[1] = $regs[2];
    }
}
# Set value of human_host if unset
if (!isset($human_hostname) || empty($human_hostname)) {
    if (checkip($host) || checkipv6($host)) {
        $human_hostname = gethostbyaddr($host);
    } else {
        $human_hostname = $host;
    }
}
// populate it if there is not entry
$db->query("select * from db_servers;");
if ($db->num_rows() == 0) {
    $db->query(" insert into db_servers (name, host, login, password, client) values ('" . mysql_escape_string($human_hostname) . "','" . mysql_escape_string($host) . "','" . mysql_escape_string($user) . "','" . mysql_escape_string($password) . "','" . mysql_escape_string($L_MYSQL_CLIENT) . "');");
}
// set the membres.db_server_id
$db->query(" update membres set db_server_id = (select max(id) from db_servers) where db_server_id is null ;");
// END of db_servers part
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++