示例#1
0
function multinet_rebuild_all_handlers()
{
    $allnets = multinet_get_all_networks();
    if (!empty($allnets)) {
        foreach ($allnets as $io => $eachnet) {
            if ($eachnet['nettype'] == 'dhcpstatic') {
                $dhcpdata = dhcp_get_data_by_netid($eachnet['id']);
                handle_dhcp_rebuild_static($eachnet['id'], $dhcpdata['confname']);
                //deb('REBUILD NETWORK:'.$eachnet['id'].'|'.$dhcpdata['confname']);
            }
            if ($eachnet['nettype'] == 'dhcp82') {
                $dhcpdata82 = dhcp_get_data_by_netid($eachnet['id']);
                handle_dhcp_rebuild_option82($eachnet['id'], $dhcpdata82['confname']);
            }
            if ($eachnet['nettype'] == 'dhcp82_vpu') {
                $dhcpdata82_vpu = dhcp_get_data_by_netid($eachnet['id']);
                handle_dhcp_rebuild_option82_vpu($eachnet['id'], $dhcpdata82_vpu['confname']);
            }
            if ($eachnet['nettype'] == 'dhcp82_bdcom') {
                $dhcpdata82_bdcom = dhcp_get_data_by_netid($eachnet['id']);
                handle_dhcp_rebuild_option82_bdcom($eachnet['id'], $dhcpdata82_bdcom['confname']);
            }
            if ($eachnet['nettype'] == 'dhcp82_zte') {
                $dhcpdata82_zte = dhcp_get_data_by_netid($eachnet['id']);
                handle_dhcp_rebuild_option82_zte($eachnet['id'], $dhcpdata82_zte['confname']);
            }
            if ($eachnet['nettype'] == 'pppstatic') {
                handle_ppp_rebuild_static($eachnet['id']);
            }
            if ($eachnet['nettype'] == 'pppdynamic') {
                handle_ppp_rebuild_dynamic($eachnet['id']);
            }
        }
    }
    //rebuilding global conf
    multinet_rebuild_globalconf();
    //restarting dhcpd
    multinet_RestartDhcp();
    //debarr(dhcp_get_data_by_netid(5));
}
示例#2
0
 /**
  * Performs user changing IP subroutine
  * 
  * @global object $billing
  * @param int $serviceId
  * @param string $newIp
  * 
  * @return void/string
  */
 public function changeUserIp($serviceId, $newIp)
 {
     global $billing;
     $result = '';
     $serviceId = vf($serviceId, 3);
     $networkId = multinet_get_service_networkid($serviceId);
     if (isset($this->allServices[$serviceId])) {
         if (zb_ip_unique($newIp)) {
             if (!empty($this->currentIp)) {
                 if ($this->isNethostExists()) {
                     //force user disconnect
                     if ($this->billingCfg['RESET_AO']) {
                         $billing->setao($this->login, 0);
                     } else {
                         $billing->setdown($this->login, 1);
                     }
                     $billing->setip($this->login, $newIp);
                     multinet_delete_host($this->currentIp);
                     multinet_add_host($networkId, $newIp, $this->currentMac);
                     log_register("CHANGE MultiNetIP (" . $this->login . ") FROM " . $this->currentIp . " ON " . $newIp . "");
                     multinet_rebuild_all_handlers();
                     multinet_RestartDhcp();
                     //back teh user online
                     if ($this->billingCfg['RESET_AO']) {
                         $billing->setao($this->login, 1);
                     } else {
                         $billing->setdown($this->login, 0);
                     }
                 } else {
                     log_register("CHANGE FAIL MultiNetIP (" . $this->login . ") FROM " . $this->currentIp . " ON " . $newIp . " NO_NETHOST");
                     $result = __('No existing nethost for current IP');
                 }
             } else {
                 log_register("CHANGE FAIL MultiNetIP (" . $this->login . ") FROM " . $this->currentIp . " ON " . $newIp . " EMPTY_IP");
                 $result = __('Something went wrong') . ': ' . __('empty current IP');
             }
         } else {
             log_register("CHANGE FAIL MultiNetIP (" . $this->login . ") FROM " . $this->currentIp . " ON " . $newIp . " IP_DUPLICATE");
             $result = __('This IP is already used by another user');
         }
     } else {
         log_register("CHANGE FAIL MultiNetIP (" . $this->login . ") FROM " . $this->currentIp . " ON " . $newIp . " NO_SERVICE");
         $result = __('Unexistent service');
     }
     return $result;
 }
示例#3
0
 $currentip = zb_UserGetIP($login);
 $currentmac = zb_MultinetGetMAC($currentip);
 $newnetid = multinet_get_service_networkid($service);
 $newip = trim($_POST['editip']);
 $newip = mysql_real_escape_string($newip);
 @($checkfreeip = multinet_get_next_freeip('nethosts', 'ip', $newnetid));
 if (!empty($checkfreeip)) {
     //check is ip acceptable for this pool?
     $allfreeips = multinet_get_all_free_ip('nethosts', 'ip', $newnetid);
     $allfreeips = array_flip($allfreeips);
     if (isset($allfreeips[$newip])) {
         $billing->setip($login, $newip);
         multinet_delete_host($currentip);
         multinet_add_host($newnetid, $newip, $currentmac);
         multinet_rebuild_all_handlers();
         multinet_RestartDhcp();
         log_register("CHANGE MultiNetIP (" . $login . ") FROM " . $currentip . " ON " . $newip);
     } else {
         $alert = '
     <script type="text/javascript">
       alert("' . __('Error') . ': ' . __('Wrong IP') . '");
       document.location.href="?module=expresscard&username='******'";
     </script>
     ';
         die($alert);
     }
 } else {
     //no free IPs left in network
     $alert = '
     <script type="text/javascript">
     alert("' . __('Error') . ': ' . __('No free IP available in selected pool') . '");
示例#4
0
 /**
  * Flushes all old user`s networking data and applies new one
  * 
  * @param   string   $current_ip        current users`s IP
  * @param   string   $current_mac       current users`s MAC address
  * @param   int      $new_multinet_id   new network ID extracted from service
  * @param   string   $new_free_ip       new IP address which be applied for user
  * @param   string   $login             existing stargazer user login
  * 
  * @return void
  */
 function zb_IPChange($current_ip, $current_mac, $new_multinet_id, $new_free_ip, $login)
 {
     global $billing;
     global $billingConf;
     //force user disconnect
     if ($billingConf['RESET_AO']) {
         $billing->setao($login, 0);
     } else {
         $billing->setdown($login, 1);
     }
     $billing->setip($login, $new_free_ip);
     multinet_delete_host($current_ip);
     multinet_add_host($new_multinet_id, $new_free_ip, $current_mac);
     multinet_rebuild_all_handlers();
     multinet_RestartDhcp();
     //back teh user online
     if ($billingConf['RESET_AO']) {
         $billing->setao($login, 1);
     } else {
         $billing->setdown($login, 0);
     }
 }