Example #1
0
 /**
  * Возвращает массив, в котором ключи - это ID сети, а
  * значения - "ID сети - Название сервиса"
  * @return  array
  */
 function getServiceIdDesc()
 {
     $return = array('');
     $services = multinet_get_services();
     foreach ($services as $service) {
         $return[$service['id']] = $service['id'] . ' - ' . $service['desc'];
     }
     return $return;
 }
Example #2
0
 /**
  * Returns array with subnets usage stats
  * 
  * @return array
  */
 function zb_FreeIpStats()
 {
     $result = array();
     $allServices = array();
     $allNets = array();
     $nethostsUsed = array();
     $servicesTmp = multinet_get_services();
     $netsTmp = multinet_get_all_networks();
     $neth_q = "SELECT COUNT(id) as count, netid from `nethosts` group by `netid`";
     $nethTmp = simple_queryall($neth_q);
     if (!empty($nethTmp)) {
         foreach ($nethTmp as $io => $each) {
             $nethostsUsed[$each['netid']] = $each['count'];
         }
     }
     if (!empty($servicesTmp)) {
         foreach ($servicesTmp as $io => $each) {
             $allServices[$each['netid']] = $each['desc'];
         }
     }
     if (!empty($netsTmp)) {
         foreach ($netsTmp as $io => $each) {
             $totalIps = multinet_expand_network($each['startip'], $each['endip']);
             $allNets[$each['id']]['desc'] = $each['desc'];
             $allNets[$each['id']]['total'] = count($totalIps);
             //finding used hosts count
             if (isset($nethostsUsed[$each['id']])) {
                 $allNets[$each['id']]['used'] = $nethostsUsed[$each['id']];
             } else {
                 $allNets[$each['id']]['used'] = 0;
             }
             //finding network associated service
             if (isset($allServices[$each['id']])) {
                 $allNets[$each['id']]['service'] = $allServices[$each['id']];
             } else {
                 $allNets[$each['id']]['service'] = '';
             }
         }
     }
     return $allNets;
 }
Example #3
0
function multinet_service_selector()
{
    $allservices = multinet_get_services();
    $result = '<select name="serviceselect">';
    if (!empty($allservices)) {
        foreach ($allservices as $io => $eachservice) {
            $result .= '<option value="' . $eachservice['id'] . '">' . $eachservice['desc'] . '</option>';
        }
    }
    $result .= '</select>';
    return $result;
}
Example #4
0
/**
 * Shows user register form of express card 
 * 
 * 
 * @return string
 */
function web_ExpressCardRegForm()
{
    $altconf = rcms_parse_ini_file(CONFIG_PATH . "alter.ini");
    $allcontracts = zb_UserGetAllContracts();
    //contract proposal
    $top_offset = 100000;
    //contract generation mode default
    if ($altconf['CONTRACT_GENERATION_DEFAULT']) {
        for ($i = 1; $i < $top_offset; $i++) {
            if (!isset($allcontracts[$i])) {
                $contract = $i;
                break;
            }
        }
    } else {
        //alternate generation method
        $max_contract = max(array_keys($allcontracts));
        $contract = $max_contract + 1;
    }
    $mac = '14:' . '88' . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99);
    $phone = '';
    $mobile = '';
    $email = '';
    $notes = '';
    $stgdata = '';
    $currenttariff = '';
    $birthdate = '';
    $passportnum = '';
    $passportdate = '';
    $passportwho = '';
    $pcity = '';
    $pstreet = '';
    $pbuild = '';
    $papt = '';
    $inputs = zb_AjaxLoader() . wf_delimiter();
    $inputs .= __('Contract');
    $inputs .= wf_TextInput('newcontract', '', $contract, false, '10');
    $inputs .= __('Contract date');
    $inputs .= wf_DatePickerPreset('newcontractdate', @$allcontractdates[$contract]);
    $inputs .= wf_delimiter();
    $inputs .= __('Surname');
    $inputs .= wf_TextInput('newsurname', '', '', false, '20');
    $inputs .= __('Name');
    $inputs .= wf_TextInput('newname', '', '', false, '20');
    $inputs .= __('Patronymic');
    $inputs .= wf_TextInput('newpatronymic', '', '', false, '20');
    $inputs .= __('Birth date');
    $inputs .= wf_DatePickerPreset('newbirthdate', $birthdate);
    $inputs .= wf_delimiter();
    $inputs .= __('Passport number');
    $inputs .= wf_TextInput('newpassportnum', '', $passportnum, false, '30');
    $inputs .= __('Date of issue');
    $inputs .= wf_DatePickerPreset('newpassportdate', $passportdate);
    $inputs .= __('Issuing authority');
    $inputs .= wf_TextInput('newpassportwho', '', $passportwho, false, '40');
    $inputs .= wf_delimiter();
    $inputs .= __('Phone');
    $inputs .= wf_TextInput('newphone', '', $phone, false, '20');
    $inputs .= __('Mobile');
    $inputs .= wf_TextInput('newmobile', '', $mobile, false, '20');
    $inputs .= __('email');
    $inputs .= wf_TextInput('newemail', '', $email, false, '20');
    $inputs .= wf_delimiter();
    $inputs .= wf_tag('fieldset');
    //address data form
    $inputs .= __('Address of service') . ' ';
    //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('newpcity', '', $pcity, false, '20');
    $inputs .= __('Street');
    $inputs .= wf_TextInput('newpstreet', '', $pstreet, false, '20');
    $inputs .= __('Build');
    $inputs .= wf_TextInput('newpbuild', '', $pbuild, false, '5');
    $inputs .= __('Apartment');
    $inputs .= wf_TextInput('newpapt', '', $papt, false, '5');
    $inputs .= wf_tag('div', true);
    $inputs .= wf_tag('fieldset', true);
    $inputs .= wf_delimiter();
    $inputs .= __('Tariff');
    $inputs .= web_ExpressTariffSelector('newtariff', $currenttariff);
    $inputs .= __('Service');
    $inputs .= web_ExpressServiceSelectorReg();
    $inputs .= __('IP');
    $inputs .= wf_tag('span', false, '', 'id="dipbox"');
    $allservices = multinet_get_services();
    if (!empty($allservices)) {
        $firstService = $allservices[0];
        $firstNet = $firstService['netid'];
        @($ip_proposal = multinet_get_next_freeip('nethosts', 'ip', $firstNet));
        if (empty($ip_proposal)) {
            show_window('', wf_modalOpened(__('Error'), __('No free IP available in selected pool'), '400', '250'));
        }
    } else {
        $ip_proposal = __('Error');
    }
    $inputs .= wf_TextInput('editip', '', $ip_proposal, false, '20');
    $inputs .= wf_tag('span', true);
    //dummy login proposal
    $login = zb_RegLoginProposal('', '', '', '', $ip_proposal);
    $inputs .= __('MAC');
    $inputs .= wf_TextInput('newmac', '', $mac, false, '20');
    $inputs .= __('Login');
    $inputs .= wf_TextInput('newlogin', '', $login, false, '20');
    $inputs .= wf_delimiter();
    $inputs .= __('Notes');
    $inputs .= wf_TextInput('newnotes', '', $notes, false, '120');
    $inputs .= wf_HiddenInput('expresscardreg', 'true');
    $inputs .= wf_delimiter();
    $inputs .= wf_Submit('Let register that user');
    $expresscardform = wf_Form("", "POST", $inputs, 'expresscard');
    show_window(__('Express card user register'), $expresscardform);
}