Example #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 . ")");
 }
Example #2
0
 /**
  * Get current nethost options by user`s login
  * 
  * @param $login - user`s login
  * 
  * @return array
  */
 function opt82_GetCurrentOptions($login)
 {
     $login = mysql_real_escape_string($login);
     $userIp = zb_UserGetIP($login);
     $nethost_q = "SELECT * from `nethosts` WHERE `ip`='" . $userIp . "'";
     $nethostRaw = simple_query($nethost_q);
     $result = array();
     $result['hostid'] = '';
     $result['hostip'] = '';
     $result['netid'] = '';
     $result['remoteid'] = '';
     $result['circuitid'] = '';
     if (!empty($nethostRaw)) {
         $result['hostid'] = $nethostRaw['id'];
         $result['hostip'] = $nethostRaw['ip'];
         $result['netid'] = $nethostRaw['netid'];
         if (!empty($nethostRaw['option'])) {
             $explode = explode('|', $nethostRaw['option']);
             if (isset($explode[1])) {
                 $result['remoteid'] = $explode[0];
                 $result['circuitid'] = $explode[1];
             }
         }
     }
     return $result;
 }
Example #3
0
 function zb_plchecknethost($login)
 {
     $login = vf($login);
     $ip = zb_UserGetIP($login);
     $query = "SELECT `id` from `nethosts` where `ip`='" . $ip . "'";
     $result = simple_queryall($query);
     $return = !empty($result);
     return $return;
 }
Example #4
0
 // Main code part
 $alter_config = $ubillingConfig->getAlter();
 if ($alter_config['MTSIGMON_ENABLED']) {
     $sigmon = new MTSIGMON();
     $allMonitoredDevices = $sigmon->getDevices();
     $allusermacs = zb_UserGetAllMACs();
     $alladdress = zb_AddressGetFullCityaddresslist();
     $alltariffs = zb_TariffsGetAllUsers();
     $allrealnames = zb_UserGetAllRealnames();
     $alluserips = zb_UserGetAllIPs();
     $result = '';
     $hlightmac = '';
     //hlight user mac sub
     if (isset($_GET['username'])) {
         $login = mysql_real_escape_string($_GET['username']);
         $userip = zb_UserGetIP($login);
         $usermac = zb_MultinetGetMAC($userip);
         $hlightmac = $usermac;
     }
     if (!empty($allMonitoredDevices)) {
         foreach ($allMonitoredDevices as $io => $eachdevice) {
             $userCounter = 0;
             $hostdata = $sigmon->deviceQuery($eachdevice['ip'], $eachdevice['community']);
             $result .= wf_tag('h2', false) . wf_img('skins/wifi.png') . ' ' . $eachdevice['location'] . ' - ' . $eachdevice['ip'] . wf_tag('h2', true);
             $tablecells = wf_TableCell(__('Full address'));
             $tablecells .= wf_TableCell(__('Real Name'));
             $tablecells .= wf_TableCell(__('Tariff'));
             $tablecells .= wf_TableCell(__('IP'));
             $tablecells .= wf_TableCell(__('MAC'));
             $tablecells .= wf_TableCell(__('Signal') . ' dBm');
             $tablerows = wf_TableRow($tablecells, 'row1');
Example #5
0
function ra_UserRebuild($login, $verbose = false)
{
    $login = mysql_real_escape_string($login);
    $userip = zb_UserGetIP($login);
    $netid = zb_NetworkGetByIp($userip);
    $nasid = zb_NasGetByNet($netid);
    $nastemplate = ra_NasGetTemplate($nasid);
    $alluserdata = zb_TemplateGetAllUserData();
    $parsed_template = zb_TemplateReplace($login, $nastemplate, $alluserdata);
    ra_UserRebuildAttributes($login, $parsed_template, $verbose);
    log_register("RADIUST REBUILD (" . $login . ")");
}
Example #6
0
/**
 * Shows editing form of express card for some login
 * 
 * @param $login - user login
 * 
 * @return string
 */
function web_ExpressCardEditForm($login)
{
    $contract = zb_UserGetContract($login);
    $allcontractdates = zb_UserContractDatesGetAll();
    $realname = zb_UserGetRealName($login);
    $phone = zb_UserGetPhone($login);
    $mobile = zb_UserGetMobile($login);
    $email = zb_UserGetEmail($login);
    $passportdata = zb_UserPassportDataGet($login);
    $addressdata = zb_AddressGetAptData($login);
    $currentip = zb_UserGetIP($login);
    $mac = zb_MultinetGetMAC($currentip);
    $notes = zb_UserGetNotes($login);
    $stgdata = zb_UserGetStargazerData($login);
    $currenttariff = $stgdata['Tariff'];
    //extracting passport data
    if (!empty($passportdata)) {
        $birthdate = $passportdata['birthdate'];
        $passportnum = $passportdata['passportnum'];
        $passportdate = $passportdata['passportdate'];
        $passportwho = $passportdata['passportwho'];
        $pcity = $passportdata['pcity'];
        $pstreet = $passportdata['pstreet'];
        $pbuild = $passportdata['pbuild'];
        $papt = $passportdata['papt'];
    } else {
        $birthdate = '';
        $passportnum = '';
        $passportdate = '';
        $passportwho = '';
        $pcity = '';
        $pstreet = '';
        $pbuild = '';
        $papt = '';
    }
    ///extracting realname to 3 different fields
    $nm = explode(' ', $realname);
    @($rnm_f = $nm[0]);
    @($rnm_i = $nm[1]);
    @($rnm_o = $nm[2]);
    /*
     * эту формочку нужно поровнять
     */
    $inputs = zb_AjaxLoader() . wf_delimiter();
    $inputs .= __('Contract');
    $inputs .= wf_TextInput('editcontract', '', $contract, false, '10');
    $inputs .= __('Contract date');
    $inputs .= wf_DatePickerPreset('editcontractdate', @$allcontractdates[$contract]);
    $inputs .= wf_delimiter();
    $inputs .= __('Surname');
    $inputs .= wf_TextInput('editsurname', '', $rnm_f, false, '20');
    $inputs .= __('Name');
    $inputs .= wf_TextInput('editname', '', $rnm_i, false, '20');
    $inputs .= __('Patronymic');
    $inputs .= wf_TextInput('editpatronymic', '', $rnm_o, false, '20');
    $inputs .= __('Birth date');
    $inputs .= wf_DatePickerPreset('editbirthdate', $birthdate);
    $inputs .= wf_delimiter();
    $inputs .= __('Passport number');
    $inputs .= wf_TextInput('editpassportnum', '', $passportnum, false, '30');
    $inputs .= __('Date of issue');
    $inputs .= wf_DatePickerPreset('editpassportdate', $passportdate);
    $inputs .= __('Issuing authority');
    $inputs .= wf_TextInput('editpassportwho', '', $passportwho, false, '40');
    $inputs .= wf_delimiter();
    $inputs .= __('Phone');
    $inputs .= wf_TextInput('editphone', '', $phone, false, '20');
    $inputs .= __('Mobile');
    $inputs .= wf_TextInput('editmobile', '', $mobile, false, '20');
    $inputs .= __('email');
    $inputs .= wf_TextInput('editemail', '', $email, false, '20');
    $inputs .= wf_delimiter();
    $inputs .= wf_tag('fieldset');
    //address data form
    $inputs .= __('Address of service') . ' ';
    if (!empty($addressdata)) {
        //if user have existing address - modify form
        $inputs .= web_ExpressAddressAptForm($login);
    } else {
        //new address creation form
        $inputs .= web_ExpressAddressOccupancyForm();
    }
    $inputs .= wf_delimiter();
    //additional address fields
    $inputs .= __('Registration address') . ' ';
    $inputs .= zb_JSHider();
    $inputs .= web_PaddressUnhideBox();
    $inputs .= web_HidingDiv('paddress');
    $inputs .= __('City');
    $inputs .= wf_TextInput('editpcity', '', $pcity, false, '20');
    $inputs .= __('Street');
    $inputs .= wf_TextInput('editpstreet', '', $pstreet, false, '20');
    $inputs .= __('Build');
    $inputs .= wf_TextInput('editpbuild', '', $pbuild, false, '5');
    $inputs .= __('Apartment');
    $inputs .= wf_TextInput('editpapt', '', $papt, false, '5');
    $inputs .= wf_tag('div', true);
    $inputs .= wf_tag('fieldset', true);
    $inputs .= wf_delimiter();
    $inputs .= __('Tariff');
    $inputs .= web_ExpressTariffSelector('edittariff', $currenttariff);
    $inputs .= __('Service');
    $inputs .= web_ExpressServiceSelector();
    $inputs .= __('IP');
    $inputs .= wf_tag('span', false, '', 'id="dipbox"');
    $inputs .= wf_TextInput('editip', '', $currentip, false, '20');
    $inputs .= wf_tag('span', true);
    $inputs .= __('MAC');
    $inputs .= wf_TextInput('editmac', '', $mac, false, '20');
    $inputs .= wf_delimiter();
    $inputs .= __('Notes');
    $inputs .= wf_TextInput('editnotes', '', $notes, false, '120');
    $inputs .= wf_HiddenInput('expresscardedit', 'true');
    $inputs .= wf_delimiter();
    $inputs .= wf_Submit('Save');
    $expresscardform = wf_Form("", "POST", $inputs, 'expresscard');
    show_window(__('Express card user edit'), $expresscardform);
}
Example #7
0
/**
 * Generates user's traffic statistic module content
 * 
 * @param   str     $login  User's login, for whitch generate module content
 * @return  str             Module content
 */
function web_UserTraffStats($login)
{
    $login = vf($login);
    $dirs = zb_DirectionsGetAll();
    // Current month traffic stats:
    $cells = wf_TableCell(__('Traffic classes'));
    $cells .= wf_TableCell(__('Downloaded'));
    $cells .= wf_TableCell(__('Uploaded'));
    $cells .= wf_TableCell(__('Total'));
    $rows = wf_TableRow($cells, 'row1');
    if (!empty($dirs)) {
        foreach ($dirs as $dir) {
            $query_downup = "SELECT `D" . $dir['rulenumber'] . "`,`U" . $dir['rulenumber'] . "` FROM `users` WHERE `login` = '" . $login . "'";
            $downup = simple_query($query_downup);
            $cells = wf_TableCell($dir['rulename']);
            $cells .= wf_TableCell(stg_convert_size($downup['D' . $dir['rulenumber']]), '', '', 'sorttable_customkey="' . $downup['D' . $dir['rulenumber']] . '"');
            $cells .= wf_TableCell(stg_convert_size($downup['U' . $dir['rulenumber']]), '', '', 'sorttable_customkey="' . $downup['U' . $dir['rulenumber']] . '"');
            $cells .= wf_TableCell(stg_convert_size($downup['U' . $dir['rulenumber']] + $downup['D' . $dir['rulenumber']]), '', '', 'sorttable_customkey="' . ($downup['U' . $dir['rulenumber']] + $downup['D' . $dir['rulenumber']]) . '"');
            $rows .= wf_TableRow($cells, 'row3');
        }
    }
    $result = wf_tag('h3') . __('Current month traffic stats') . wf_tag('h3', true);
    $result .= wf_TableBody($rows, '100%', '0', 'sortable');
    // End of current month traffic stats
    // Per-user graphs buttons:
    $ip = zb_UserGetIP($login);
    $bandwidthd = zb_BandwidthdGetUrl($ip);
    if (!empty($bandwidthd)) {
        $bwd = zb_BandwidthdGenLinks($ip);
        // Dayly graph button:
        $daybw = wf_img($bwd['dayr'], __('Downloaded'));
        if (!empty($bwd['days'])) {
            $daybw .= wf_delimiter() . wf_img($bwd['days'], __('Uploaded'));
        }
        // Weekly graph button:
        $weekbw = wf_img($bwd['weekr'], __('Downloaded'));
        if (!empty($bwd['weeks'])) {
            $weekbw .= wf_delimiter() . wf_img($bwd['weeks'], __('Uploaded'));
        }
        // Monthly graph button:
        $monthbw = wf_img($bwd['monthr'], __('Downloaded'));
        if (!empty($bwd['months'])) {
            $monthbw .= wf_delimiter() . wf_img($bwd['months'], __('Uploaded'));
        }
        // Yearly graph button:
        $yearbw = wf_img($bwd['yearr'], __('Downloaded'));
        if (!empty($bwd['years'])) {
            $yearbw .= wf_delimiter() . wf_img($bwd['years'], __('Uploaded'));
        }
        // Modal window sizes:
        if (!empty($bwd['days'])) {
            //bandwidthd
            $width = 920;
            $heidht = 640;
            $graphLegend = wf_tag('br') . wf_img('skins/bwdlegend.gif');
        } else {
            //mikrotik
            $width = 530;
            $heidht = 230;
            $graphLegend = '';
        }
        $result .= wf_delimiter();
        $result .= wf_tag('h3') . __('Graphs') . wf_tag('h3', true);
        $bwcells = wf_TableCell(wf_modal(__('Graph by day'), __('Graph by day'), $daybw . $graphLegend, 'ubButton', $width, $heidht));
        $bwcells .= wf_TableCell(wf_modal(__('Graph by week'), __('Graph by week'), $weekbw . $graphLegend, 'ubButton', $width, $heidht));
        $bwcells .= wf_TableCell(wf_modal(__('Graph by month'), __('Graph by month'), $monthbw . $graphLegend, 'ubButton', $width, $heidht));
        $bwcells .= wf_TableCell(wf_modal(__('Graph by year'), __('Graph by year'), $yearbw . $graphLegend, 'ubButton', $width, $heidht));
        $bwrows = wf_TableRow($bwcells);
        // Adding graphs buttons to result:
        $result .= wf_TableBody($bwrows, '', '0', '');
        $result .= wf_delimiter();
    } else {
        $result .= __('No user graphs because no NAS with bandwidthd for his network');
    }
    // End of per-user graphs buttons
    // Traffic statistic by previous months:
    $monthNames = months_array_wz();
    $result .= wf_tag('h3') . __('Previous month traffic stats') . wf_tag('h3', true);
    $cells = wf_TableCell(__('Year'));
    $cells .= wf_TableCell(__('Month'));
    $cells .= wf_TableCell(__('Traffic classes'));
    $cells .= wf_TableCell(__('Downloaded'));
    $cells .= wf_TableCell(__('Uploaded'));
    $cells .= wf_TableCell(__('Total'));
    $cells .= wf_TableCell(__('Cash'));
    $rows = wf_TableRow($cells, 'row1');
    if (!empty($dirs)) {
        foreach ($dirs as $dir) {
            $query_prev = "SELECT `D" . $dir['rulenumber'] . "`, `U" . $dir['rulenumber'] . "`, `month`, `year`, `cash` FROM `stat` WHERE `login` = '" . $login . "' ORDER BY `year`, `month`";
            $prevmonths = simple_queryall($query_prev);
            if (!empty($prevmonths)) {
                foreach ($prevmonths as $prevmonth) {
                    $cells = wf_TableCell($prevmonth['year']);
                    $cells .= wf_TableCell(rcms_date_localise($monthNames[$prevmonth['month']]));
                    $cells .= wf_TableCell($dir['rulename']);
                    $cells .= wf_TableCell(stg_convert_size($prevmonth['D' . $dir['rulenumber']]), '', '', 'sorttable_customkey="' . $prevmonth['D' . $dir['rulenumber']] . '"');
                    $cells .= wf_TableCell(stg_convert_size($prevmonth['U' . $dir['rulenumber']]), '', '', 'sorttable_customkey="' . $prevmonth['U' . $dir['rulenumber']] . '"');
                    $cells .= wf_TableCell(stg_convert_size($prevmonth['U' . $dir['rulenumber']] + $prevmonth['D' . $dir['rulenumber']]), '', '', 'sorttable_customkey="' . ($prevmonth['U' . $dir['rulenumber']] + $prevmonth['D' . $dir['rulenumber']]) . '"');
                    $cells .= wf_TableCell(round($prevmonth['cash'], 2));
                    $rows .= wf_TableRow($cells, 'row3');
                }
            }
        }
    }
    // End of traffic statistic by previous months
    // Generate table:
    $result .= wf_TableBody($rows, '100%', '0', 'sortable');
    // Return result:
    return $result;
}
Example #8
0
 /**
  * Changes\applies users vlan
  * 
  * @param int $newVlanPoolID
  * @param string $login
  * @return void
  */
 public function VlanChange($newVlanPoolID, $login)
 {
     $QinQ = $this->GetVlanPoolQinQ($newVlanPoolID);
     $ip = zb_UserGetIP($login);
     $this->DeleteVlanHost($login);
     $this->DeleteVlanHostQinQ($login);
     if ($QinQ == 0) {
         $newVlan = $this->GetNextFreeVlan($newVlanPoolID);
         if (empty($newVlan)) {
             $alert = wf_JSAlert(self::MODULE_URL_ADDVLAN, __("Error"), __("No free Vlan available in selected pool"));
             print $alert;
             rcms_redirect(self::MODULE_URL_ADDVLAN);
         }
         $this->AddVlanHost($newVlanPoolID, $newVlan, $login);
     } else {
         $poolData = $this->AllVlanPools[$newVlanPoolID];
         $svlan = $poolData['svlan'];
         $this->AddVlanHostQinQ($newVlanPoolID, $svlan, $newVlan, $login);
     }
     $this->OnVlanConnect($ip, $newVlan);
     log_register(__("Change vlan") . " " . "(" . $login . ")" . " " . __("ON") . " " . $newVlan);
 }
Example #9
0
 /**
  * Inits user params as current IP and MAC
  * 
  * @return void
  */
 public function initUserParams()
 {
     if (!empty($this->login)) {
         $this->currentIp = zb_UserGetIP($this->login);
         $this->currentMac = zb_MultinetGetMAC($this->currentIp);
     }
 }
Example #10
0
<?php

if (cfr('PLIPCHANGE')) {
    if (isset($_GET['username'])) {
        $login = mysql_real_escape_string($_GET['username']);
        $current_ip = zb_UserGetIP($login);
        // getting IP by login
        $current_mac = zb_MultinetGetMAC($current_ip);
        //extracting current user MAC
        $billingConf = $ubillingConfig->getBilling();
        //getting billing.ini config
        /**
         * Returns new user service select form
         * 
         * @return string
         */
        function web_IPChangeFormService()
        {
            global $current_ip;
            $inputs = multinet_service_selector() . ' ' . __('New IP service');
            $inputs .= wf_delimiter();
            $inputs .= wf_Submit(__('Save'));
            $result = wf_Form("", 'POST', $inputs, 'floatpanels');
            return $result;
        }
        /**
         * Returns array with subnets usage stats
         * 
         * @return array
         */
        function zb_FreeIpStats()