Example #1
0
 /**
  * Returns array of fees by some login with parsing it from stargazer log
  * 
  * @param string $login existing user login
  * 
  * @return array
  */
 public function getFees($login)
 {
     $login = mysql_real_escape_string($login);
     $sudo = $this->billingConf['SUDO'];
     $cat = $this->billingConf['CAT'];
     $grep = $this->billingConf['GREP'];
     $stglog = $this->alterConf['STG_LOG_PATH'];
     $result = array();
     $feeadmin = 'stargazer';
     $feenote = '';
     $feecashtype = 'z';
     // monthly fees output
     $command = $sudo . ' ' . $cat . ' ' . $stglog . ' | ' . $grep . ' "fee charge"' . ' | ' . $grep . ' "User \'' . $login . '\'" ';
     $rawdata = shell_exec($command);
     if (!empty($rawdata)) {
         $cleardata = exploderows($rawdata);
         foreach ($cleardata as $eachline) {
             $eachfee = explode(' ', $eachline);
             if (isset($eachfee[1])) {
                 $counter = strtotime($eachfee[0] . ' ' . $eachfee[1]);
                 $feefrom = str_replace("'.", '', $eachfee[12]);
                 $feeto = str_replace("'.", '', $eachfee[14]);
                 $feefrom = str_replace("'", '', $feefrom);
                 $feeto = str_replace("'", '', $feeto);
                 $result[$counter]['login'] = $login;
                 $result[$counter]['date'] = $eachfee[0] . ' ' . $eachfee[1];
                 $result[$counter]['admin'] = $feeadmin;
                 $result[$counter]['summ'] = $feeto - $feefrom;
                 $result[$counter]['from'] = $feefrom;
                 $result[$counter]['to'] = $feeto;
                 $result[$counter]['operation'] = 'Fee';
                 $result[$counter]['note'] = $feenote;
                 $result[$counter]['cashtype'] = $feecashtype;
             }
         }
     }
     return $result;
 }
Example #2
0
function zb_NewMacShow()
{
    global $ubillingConfig;
    $billing_config = $ubillingConfig->getBilling();
    $alter_config = $ubillingConfig->getAlter();
    $allarp = array();
    $sudo = $billing_config['SUDO'];
    $cat = $billing_config['CAT'];
    $grep = $billing_config['GREP'];
    $tail = $billing_config['TAIL'];
    $alter_conf = parse_ini_file(CONFIG_PATH . 'alter.ini');
    $leases = $alter_conf['NMLEASES'];
    $leasemark = $alter_conf['NMLEASEMARK'];
    $command = $sudo . ' ' . $cat . ' ' . $leases . ' | ' . $grep . ' "' . $leasemark . '" | ' . $tail . ' -n 200';
    $rawdata = shell_exec($command);
    $allusedMacs = zb_getAllUsedMac();
    $result = '';
    //fdb cache preprocessing
    $fdbData_raw = rcms_scandir('./exports/', '*_fdb');
    if (!empty($fdbData_raw)) {
        $fdbArr = sn_SnmpParseFdbCacheArray($fdbData_raw);
        $fdbColumn = true;
    } else {
        $fdbArr = array();
        $fdbColumn = false;
    }
    $cells = wf_TableCell(__('MAC'));
    if (!empty($fdbColumn)) {
        $cells .= wf_TableCell(__('Switch'));
    }
    if ($alter_config['MACVEN_ENABLED']) {
        $cells .= wf_TableCell(__('Manufacturer'));
    }
    $rows = wf_TableRow($cells, 'row1');
    if (!empty($rawdata)) {
        $cleardata = exploderows($rawdata);
        foreach ($cleardata as $eachline) {
            preg_match('/[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}/i', $eachline, $matches);
            if (!empty($matches)) {
                $allarp[] = $matches[0];
            }
        }
        $un_arr = array_unique($allarp);
        if (!empty($un_arr)) {
            if ($alter_config['MACVEN_ENABLED']) {
                //adding ajax loader
                $result .= wf_AjaxLoader();
            }
            foreach ($un_arr as $io => $eachmac) {
                if (zb_checkMacFree($eachmac, $allusedMacs)) {
                    $cells = wf_TableCell(@$eachmac);
                    if (!empty($fdbColumn)) {
                        $cells .= wf_TableCell(sn_SnmpParseFdbExtract(@$fdbArr[$eachmac]));
                    }
                    if ($alter_config['MACVEN_ENABLED']) {
                        $containerName = 'NMRSMCNT_' . zb_rand_string(8);
                        $lookupVendorLink = wf_AjaxLink('?module=macvendor&mac=' . @$eachmac . '&raw=true', wf_img('skins/macven.gif', __('Device vendor')), $containerName, false, '');
                        $lookupVendorLink .= wf_tag('span', false, '', 'id="' . $containerName . '"') . '' . wf_tag('span', true);
                        $cells .= wf_TableCell($lookupVendorLink, '350');
                    }
                    $rows .= wf_TableRow($cells, 'row3');
                }
            }
        }
    }
    $result .= wf_TableBody($rows, '100%', '0', 'sortable');
    return $result;
}
Example #3
0
/**
 * Returns simple MAC address selector
 * 
 * @global object $ubillingConfig
 * @param string $name
 * @return string
 */
function zb_NewMacSelect($name = 'newmac')
{
    global $ubillingConfig;
    $billing_config = $ubillingConfig->getBilling();
    $alter_conf = $ubillingConfig->getAlter();
    $sudo = $billing_config['SUDO'];
    $cat = $billing_config['CAT'];
    $grep = $billing_config['GREP'];
    $tail = $billing_config['TAIL'];
    $leases = $alter_conf['NMLEASES'];
    $leasesmark = $alter_conf['NMLEASEMARK'];
    $command = $sudo . ' ' . $cat . ' ' . $leases . ' | ' . $grep . '  "' . $leasesmark . '" | ' . $tail . ' -n 200';
    $rawdata = shell_exec($command);
    $allUsedMacs = zb_getAllUsedMac();
    $resultArr = array();
    if (!empty($rawdata)) {
        $cleardata = exploderows($rawdata);
        foreach ($cleardata as $eachline) {
            preg_match('/[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}/i', $eachline, $matches);
            if (!empty($matches[0])) {
                $nmarr[] = $matches[0];
                $unique_nmarr = array_unique($nmarr);
            }
        }
        if (!empty($unique_nmarr)) {
            foreach ($unique_nmarr as $newmac) {
                if (zb_checkMacFree($newmac, $allUsedMacs)) {
                    $resultArr[$newmac] = $newmac;
                }
            }
        }
    }
    $result = wf_Selector($name, $resultArr, '', '', false);
    return $result;
}