Exemplo n.º 1
0
 function zb_AnnihilateUser($login)
 {
     global $billing;
     $alter_conf = rcms_parse_ini_file(CONFIG_PATH . "alter.ini");
     $user_ip = zb_UserGetIP($login);
     $user_aptdata = zb_AddressGetAptData($login);
     @($user_aptid = $user_aptdata['aptid']);
     zb_AddressDeleteApartment($user_aptid);
     zb_AddressOrphanUser($login);
     zb_UserDeleteEmail($login);
     zb_UserDeleteNotes($login);
     zb_UserDeletePhone($login);
     zb_UserDeleteRealName($login);
     zb_UserDeleteSpeedOverride($login);
     if (!$alter_conf['STRICT_CONTRACTS_PROTECT']) {
         zb_UserDeleteContract($login);
     }
     zb_VserviceCashClear($login);
     log_register("DELETE VCASH (" . $login . ")");
     cf_FlushAllUserCF($login);
     zb_FlushAllUserTags($login);
     vlan_delete_host($login);
     multinet_delete_host($user_ip);
     multinet_rebuild_all_handlers();
     //destroy stargazer user
     $billing->deleteuser($login);
     log_register("StgUser DELETE (" . $login . ")");
 }
Exemplo n.º 2
0
 //edits existing ONU in database
 if (wf_CheckPost(array('editonu', 'editoltid', 'editmac'))) {
     $pon->onuSave($_POST['editonu'], $_POST['editonumodelid'], $_POST['editoltid'], $_POST['editip'], $_POST['editmac'], $_POST['editserial'], $_POST['editlogin']);
     multinet_rebuild_all_handlers();
     rcms_redirect('?module=ponizer&editonu=' . $_POST['editonu']);
 }
 //deleting existing ONU
 if (wf_CheckGet(array('deleteonu'))) {
     $pon->onuDelete($_GET['deleteonu']);
     multinet_rebuild_all_handlers();
     rcms_redirect('?module=ponizer');
 }
 //assigning ONU with some user
 if (wf_CheckPost(array('assignonulogin', 'assignonuid'))) {
     $pon->onuAssign($_POST['assignonuid'], $_POST['assignonulogin']);
     multinet_rebuild_all_handlers();
     rcms_redirect('?module=ponizer&editonu=' . $_POST['assignonuid']);
 }
 if (!wf_CheckGet(array('editonu'))) {
     if (wf_CheckGet(array('username'))) {
         //try to detect ONU id by user login
         $login = $_GET['username'];
         $userOnuId = $pon->getOnuIdByUser($login);
         //redirecting to assigned ONU
         if ($userOnuId) {
             rcms_redirect('?module=ponizer&editonu=' . $userOnuId);
         } else {
             //rendering assign form
             show_window(__('ONU assign'), $pon->onuAssignForm($login));
         }
     } else {
Exemplo n.º 3
0
 function docsis_ModemDelete($modemid)
 {
     $modemid = vf($modemid, 3);
     $modemdata = docsis_ModemGetData($modemid);
     if (!empty($modemdata)) {
         $modemip = $modemdata['ip'];
         $query = "DELETE from `modems` WHERE `id`='" . $modemid . "'";
         nr_query($query);
         log_register("DOCSIS MODEM DELETE IP " . $modemip . " [" . $modemid . "]");
         multinet_delete_host($modemip);
         multinet_rebuild_all_handlers();
     }
 }
Exemplo n.º 4
0
/**
 * Performs an user registration
 * 
 * @global object $billing
 * @param array $user_data
 * @param bool $goprofile
 */
function zb_UserRegister($user_data, $goprofile = true)
{
    global $billing;
    // Init all of needed user data
    $login = vf($user_data['login']);
    $login = zb_RegLoginFilter($login);
    $password = vf($user_data['password']);
    $ip = $user_data['IP'];
    $cityid = $user_data['city'];
    $streetid = $user_data['street'];
    $buildid = $user_data['build'];
    @($entrance = $user_data['entrance']);
    @($floor = $user_data['floor']);
    $apt = $user_data['apt'];
    $serviceid = $user_data['service'];
    $netid = multinet_get_service_networkid($serviceid);
    $busylogins = zb_AllBusyLogins();
    //check login lenght
    $maxStLen = 42;
    $loginLen = strlen($login);
    if ($loginLen > $maxStLen) {
        log_register("HUGELOGIN REGISTER TRY (" . $login . ")");
        $alert = __('Attention generated login longer than') . ' ' . $maxStLen . ' ' . __('bytes') . '. (' . $login . ' > ' . $loginLen . ') ' . __('And is not compatible with Stargazer') . '.';
        die($alert);
    }
    // empty login validation
    if (empty($login)) {
        $alert = wf_tag('script', false, '', 'type="text/javascript"');
        $alert .= 'alert("' . __('Error') . ': ' . __('Empty login') . '");';
        $alert .= wf_tag('script', true);
        print $alert;
        rcms_redirect("?module=userreg");
        die;
    }
    //duplicate login validation
    if (isset($busylogins[$login])) {
        $alert = wf_tag('script', false, '', 'type="text/javascript"');
        $alert .= 'alert("' . __('Error') . ': ' . __('Duplicate login') . '");';
        $alert .= wf_tag('script', true);
        print $alert;
        rcms_redirect("?module=userreg");
        die;
    }
    //last check
    if (!zb_ip_unique($ip)) {
        $alert = wf_tag('script', false, '', 'type="text/javascript"');
        $alert .= 'alert("' . __('Error') . ': ' . __('This IP is already used by another user') . '");';
        $alert .= wf_tag('script', true);
        print $alert;
        rcms_redirect("?module=userreg");
        die;
    }
    // registration subroutine
    $billing->createuser($login);
    log_register("StgUser REGISTER (" . $login . ")");
    $billing->setpassword($login, $password);
    log_register("StgUser (" . $login . ") PASSWORD `" . $password . "`");
    $billing->setip($login, $ip);
    log_register("StgUser (" . $login . ") IP `" . $ip . "`");
    zb_AddressCreateApartment($buildid, $entrance, $floor, $apt);
    zb_AddressCreateAddress($login, zb_AddressGetLastid());
    multinet_add_host($netid, $ip);
    zb_UserCreateRealName($login, '');
    zb_UserCreatePhone($login, '', '');
    zb_UserCreateContract($login, '');
    zb_UserCreateEmail($login, '');
    zb_UserCreateSpeedOverride($login, 0);
    zb_UserRegisterLog($login);
    // if random mac needed
    $billingconf = rcms_parse_ini_file(CONFIG_PATH . '/billing.ini');
    $alterconf = rcms_parse_ini_file(CONFIG_PATH . "alter.ini");
    if ($billingconf['REGRANDOM_MAC']) {
        // funny random mac, yeah? :)
        $mac = '14:' . '88' . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99);
        multinet_change_mac($ip, $mac);
        multinet_rebuild_all_handlers();
    }
    // if AlwaysOnline to new user needed
    if ($billingconf['REGALWONLINE']) {
        $alwaysonline = 1;
        $billing->setao($login, $alwaysonline);
        log_register('CHANGE AlwaysOnline (' . $login . ') ON ' . $alwaysonline);
    }
    // if we want to disable detailed stats to new user by default
    if ($billingconf['REGDISABLEDSTAT']) {
        $dstat = 1;
        $billing->setdstat($login, $dstat);
        log_register('CHANGE dstat (' . $login . ') ON ' . $dstat);
    }
    //set contract same as login for this user
    if (isset($alterconf['CONTRACT_SAME_AS_LOGIN'])) {
        if ($alterconf['CONTRACT_SAME_AS_LOGIN']) {
            $newUserContract = $login;
            zb_UserChangeContract($login, $newUserContract);
        }
    }
    //cemetery processing
    if (isset($alterconf['CEMETERY_ENABLED'])) {
        if ($alterconf['CEMETERY_ENABLED']) {
            if ($alterconf['CEMETERY_ENABLED'] == 2) {
                $cemetery = new Cemetery(false);
                $cemetery->setDead($login);
            }
        }
    }
    //contract autogeneration
    if (isset($alterconf['CONTRACT_AUTOGEN'])) {
        if ($alterconf['CONTRACT_AUTOGEN']) {
            $contract_proposal = '';
            $allcontracts = zb_UserGetAllContracts();
            $top_offset = 100000;
            //contract generation mode default
            if ($alterconf['CONTRACT_GENERATION_DEFAULT']) {
                for ($i = 1; $i < $top_offset; $i++) {
                    if (!isset($allcontracts[$i])) {
                        $contract_proposal = $i;
                        break;
                    }
                }
            } else {
                //alternate generation method
                $max_contract = max(array_keys($allcontracts));
                $contract_proposal = $max_contract + 1;
            }
            //setting generated contract to new user
            if (!isset($allcontracts[$contract_proposal])) {
                $contractDate = date("Y-m-d");
                zb_UserChangeContract($login, $contract_proposal);
                zb_UserContractDateCreate($contract_proposal, $contractDate);
            }
        }
    }
    ///////////////////////////////////
    if ($goprofile) {
        rcms_redirect("?module=userprofile&username=" . $login);
    }
}
Exemplo n.º 5
0
 /**
  * Apply vlan on vlan terminator
  * 
  * @param string $ip
  * @param int $vlan
  * @return void
  */
 protected function OnVlanConnect($ip, $vlan)
 {
     multinet_rebuild_all_handlers();
     $networkID = $this->GetNetidByIP($ip);
     $terminatorID = $this->GetTermIdByNetid($networkID);
     $termData = $this->AllTerminators[$terminatorID];
     $term_ip = $termData['ip'];
     $term_type = $termData['type'];
     $term_user = $termData['username'];
     $term_pass = $termData['password'];
     $term_int = $termData['interface'];
     $relay = $termData['relay'];
     if ($term_ip == '127.0.0.1') {
         if ($term_type == 'FreeBSD') {
             $res = shell_exec(self::SCRIPT_PATH . "bsd.local.sh {$term_int} {$ip} {$vlan}");
         }
         if ($term_type == 'Linux') {
             $res = shell_exec(self::SCRIPT_PATH . "linux.local.sh");
         }
     } else {
         if ($term_type == 'FreeBSD') {
             $res = shell_exec(self::SCRIPT_PATH . "bsd.remote.sh {$term_user} {$term_pass} {$term_int} {$ip} {$vlan}");
         }
         if ($term_type == 'Linux') {
             $res = shell_exec(self::SCRIPT_PATH . "linux.remote.sh {$term_user} {$term_pass} {$term_int} {$ip} {$vlan}");
         }
         if ($term_type == 'Cisco') {
             $res = shell_exec(self::SCRIPT_PATH . "cisco.sh {$term_user} {$term_pass} {$vlan} {$term_int} {$relay} {$term_ip}");
         }
         if ($term_type == 'Cisco_static') {
             $res = shell_exec(self::SCRIPT_PATH . "cisco_static.sh {$term_user} {$term_pass} {$vlan} {$term_int} {$relay} {$term_ip}");
         }
     }
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
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);
     }
 }
Exemplo n.º 8
0
 /**
  * Rebuilds all configs and restarts DHCP server
  * 
  * @return void
  */
 public function restartDhcpServer()
 {
     multinet_rebuild_all_handlers();
 }