Beispiel #1
0
 function ipdel($ip, $dep = NULL)
 {
     global $db;
     if ($this->exists) {
         $ipadr = ip_exists_in_table($ip);
         $sql = 'UPDATE vps_ip SET vps_id = 0 WHERE ip_addr="' . $db->check($ip) . '"';
         if ($result = $db->query($sql)) {
             $command = array('addr' => $ip, 'version' => (int) $ipadr['ip_v'], 'shaper' => array('class_id' => $ipadr['class_id']));
             add_transaction($_SESSION["member"]["m_id"], $this->ve["vps_server"], $this->veid, T_EXEC_IPDEL, $command, NULL, $dep);
             return $db->insertId();
         } else {
             return NULL;
         }
     }
 }
Beispiel #2
0
function ip_is_free($ip_addr)
{
    if (validate_ip_address($ip_addr)) {
        $ip_try = ip_exists_in_table($ip_addr);
    } else {
        return false;
    }
    if (!$ip_try) {
        return true;
    }
    if ($ip_try["vps_id"] == 0) {
        return true;
    } else {
        return false;
    }
}
Beispiel #3
0
 public function table_add_2($ip_addr, $location_id)
 {
     if ($this->check_syntax($ip_addr) == false) {
     } else {
         if (!ip_exists_in_table($ip_addr)) {
             $sql = "INSERT INTO `vps_ip` SET `ip_v`=" . $this->type . ",`ip_location`=" . $location_id . ", `vps_id`=0, `ip_addr`='" . $ip_addr . "';";
             if ($this->db->query($sql)) {
                 $t_param["ip_v"] = $this->type;
                 $t_param["ip_addr"] = $ip_addr;
                 $t_param["ip_id"] = $this->db->insert_id();
                 add_transaction_locationwide($_SESSION["member"]["m_id"], 0, T_CLUSTER_IP_REGISTER, $t_param, $location_id);
                 $this->xtpl->perex(_("Operation successful"), sprintf(_("IP address '%s' has been successfully added"), $ip_addr));
             } else {
                 $this->xtpl->perex(_("Operation not successful"), _("An error has occured, while you were trying to add a new IP"));
             }
         } else {
             $this->xtpl->perex(_("Operation not successful"), _("IP already exists in DB"));
         }
     }
 }
Beispiel #4
0
 public function table_add_2($ip_addrs, $location_id)
 {
     $raw_ips = preg_split("/(\r\n|\n|\r)/", $ip_addrs);
     $out = array();
     $insert = array();
     $cleaned = array();
     $err = true;
     foreach ($raw_ips as $ip_addr) {
         if (!$this->check_syntax($ip_addr)) {
             $out[] = _("Bad format") . ": '{$ip_addr}'";
             $err = true;
         } else {
             if (ip_exists_in_table($ip_addr)) {
                 $out[] = "IP '{$ip_addr}' is already in database";
                 $err = true;
             } else {
                 $insert[] = $ip_addr;
                 $err = false;
             }
         }
     }
     if ($err) {
         $this->xtpl->perex(_("Operation not successful"), implode("<br/>", $out));
         return;
     }
     if (!count($insert)) {
         return;
     }
     foreach ($insert as $ip) {
         if ($this->register_ip($location_id, $ip)) {
             $out[] = _("Added IP") . " {$ip}";
             $cleaned[] = array("ver" => $this->type, "addr" => $ip);
             $err = false;
         } else {
             $out[] = _("Failed to register IP") . " {$ip}";
             $err = true;
         }
     }
     if (count($cleaned) > 0) {
         $params = array("ip_addrs" => $cleaned);
         add_transaction_locationwide($_SESSION["member"]["m_id"], 0, T_CLUSTER_IP_REGISTER, $params, $location_id);
     }
     if ($err) {
         $this->xtpl->perex(_("Operation not completely successful"), implode("<br/>", $out));
     } else {
         $this->xtpl->perex(_("Operation successful"), implode("<br/>", $out));
     }
 }
Beispiel #5
0
    function ipadd($ip, $type = 4)
    {
        global $db;
        if ($this->exists) {
            if ($ipadr = ip_exists_in_table($ip)) {
                $sql = 'UPDATE vps_ip
			SET vps_id = "' . $db->check($this->veid) . '"
			WHERE ip_id = "' . $db->check($ipadr["ip_id"]) . '"';
                $db->query($sql);
                if ($db->affected_rows() > 0) {
                    $command = '--ipadd ' . $ip;
                    add_transaction($_SESSION["member"]["m_id"], $this->ve["vps_server"], $this->veid, T_EXEC_IPADD, $command);
                } else {
                    return null;
                }
            }
        }
    }