DNS_import improvement

Discussion in 'Developers' Forum' started by asig, Aug 13, 2014.

  1. asig

    asig New Member

    Good afternoon; this is my first post. When I used the dns import process, I obtain some errors when the TTL field is specified in a non-numeric format (4h, 1d, ...)

    The following function (in file ispconfig/interface/web/dns/dns_import.php ) solve this issue (if it's used in the right if/switch):

    //ASIG funcion is_numericTTL
    // $fff is the evaluated string
    // Function result return: true is the $fff argument is a TTL number; false in other case.
    // $numttl (by reference) the numeric value of the $fff string (if the argument is a TTL number); else -1
    function is_numericTTL($fff, &$numttl) {
    $time_format = strtolower(substr($fff, -1));
    switch ($time_format) {
    case 's':
    $numttl = (int)(substr($fff, 0, -1));
    break;
    case 'm':
    $numttl = (int)(substr($fff, 0, -1) * 60);
    break;
    case 'h':
    $numttl = (int)(substr($fff, 0, -1) * 3600);
    break;
    case 'd':
    $numttl = (int)(substr($fff, 0, -1) * 86400);
    break;
    case 'w':
    $numttl = (int)(substr($fff, 0, -1) * 604800);
    break;
    default:
    if (is_numeric($fff)) {
    $numttl = (int)$fff;
    } else {
    $numttl = -1; }
    }
    return ($numttl != -1);
    }
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Thank you for the patch. I added it to the bugtracker.
     

Share This Page