/** * Parse option 82 leases from dhcpd.log * * @param $billing_config - preprocessed billing.ini * @param $altercfg - preprocessed alter.ini * * @return array */ function opt82_LoadLeases($billing_config, $altercfg, $busyLeases) { $sudo = $billing_config['SUDO']; $cat = $billing_config['CAT']; $grep = $billing_config['GREP']; $tail = $billing_config['TAIL']; $leasePath = $altercfg['NMLEASES']; $leasemark = '(with opt82)'; $command = $sudo . ' ' . $cat . ' ' . $leasePath . ' | ' . $grep . ' "' . $leasemark . '" | ' . $tail . ' -n 100'; $rawData = shell_exec($command); $rawArr = array(); $rawArr = explodeRows($rawData); $result = array(); if (!empty($rawArr)) { foreach ($rawArr as $eachline) { $explodeLine = preg_split('/\\s+/', $eachline); //log have normal format if (isset($explodeLine[9]) and isset($explodeLine[11]) and isset($explodeLine[7])) { $leaseIp = $explodeLine[7]; $remoteId = $explodeLine[9]; $circuitID = $explodeLine[11]; //check for new lease? if (!isset($busyLeases[$remoteId . '|' . $circuitID])) { $result[$remoteId . '|' . $circuitID] = $remoteId . '->' . $circuitID; } } } } return $result; }
/** * Returns array of MAC=>Signal data for some MikroTik/UBNT device * * @param string $ip * @param string $community * @return array */ function deviceQuery($ip, $community) { $oid = '.1.3.6.1.4.1.14988.1.1.1.2.1.3'; $mask_mac = false; $ubnt_shift = 0; $result = array(); $rawsnmp = array(); $snmp = new SNMPHelper(); $snmp->setBackground(false); $snmp->setMode('native'); $tmpSnmp = $snmp->walk($ip, $community, $oid, false); // Returned string '.1.3.6.1.4.1.14988.1.1.1.2.1.3 = ' // in AirOS 5.6 and newer if ($tmpSnmp === "{$oid} = ") { $oid = '.1.3.6.1.4.1.41112.1.4.7.1.3.1'; $tmpSnmp = $snmp->walk($ip, $community, $oid, false); $ubnt_shift = 1; } if (!empty($tmpSnmp) and $tmpSnmp !== "{$oid} = ") { $explodeData = explodeRows($tmpSnmp); if (!empty($explodeData)) { foreach ($explodeData as $io => $each) { $explodeRow = explode(' = ', $each); if (isset($explodeRow[1])) { $rawsnmp[$explodeRow[0]] = $explodeRow[1]; } } } } if (!empty($rawsnmp)) { if (is_array($rawsnmp)) { foreach ($rawsnmp as $indexOID => $rssi) { $oidarray = explode(".", $indexOID); $end_num = sizeof($oidarray) + $ubnt_shift; $mac = ''; for ($counter = 2; $counter < 8; $counter++) { $temp = sprintf('%02x', $oidarray[$end_num - $counter]); if ($counter < 5 && $mask_mac) { $mac = ":xx{$mac}"; } else { if ($counter == 7) { $mac = "{$temp}{$mac}"; } else { $mac = ":{$temp}.{$mac}"; } } } $mac = str_replace('.', '', $mac); $mac = trim($mac); $rssi = str_replace('INTEGER:', '', $rssi); $rssi = trim($rssi); $result[$mac] = $rssi; } } } return $result; }
function ra_UserRebuildAttributes($login, $attrtemplate, $verbose = false) { $login = mysql_real_escape_string($login); $clean_q = "DELETE from `radattr` WHERE `login`='" . $login . "'"; nr_query($clean_q); if (!empty($attrtemplate)) { if ($verbose) { show_window(__('User attributes'), '<pre>' . $attrtemplate . '</pre>'); } $splitted = explodeRows($attrtemplate); if (!empty($splitted)) { foreach ($splitted as $io => $eachattr) { if (ispos($eachattr, '=')) { $attr_raw = explode('=', $eachattr); $attr = $attr_raw[0]; $value = $attr_raw[1]; $query = "INSERT INTO `radattr` (`id` ,`login` ,`attr` ,`value`) VALUES (NULL , '" . $login . "', '" . $attr . "', '" . $value . "');"; nr_query($query); } } } } }
function web_MigrationPreprocessing($filename, $delimiter, $encoding) { $path = 'exports/'; $raw_data = file_get_contents($path . $filename); $parsed_data = array(); if ($encoding != 'utf-8') { $raw_data = iconv($encoding, 'utf-8', $raw_data); } $raw_data = explodeRows($raw_data); if (!empty($raw_data)) { foreach ($raw_data as $eachrow) { if (!empty($eachrow)) { $parsed_data[] = explode($delimiter, $eachrow); } } } if (sizeof($parsed_data) > 1) { $col_count = sizeof($parsed_data[0]); $cells = wf_TableCell(__('Column number')); $cells .= wf_TableCell(__('Column content')); $rows = wf_TableRow($cells, 'row1'); foreach ($parsed_data[0] as $col_num => $col_data) { $cells = wf_TableCell($col_num); $cells .= wf_TableCell($col_data); $rows .= wf_TableRow($cells, 'row3'); } $first_row = wf_TableBody($rows, '100%', '0', ''); show_window(__('Found count of data columns'), $col_count); show_window(__('First of imported data rows'), $first_row); //construct of data processing form $rowNumArr = array(); for ($i = 0; $i < $col_count; $i++) { $rowNumArr[$i] = $i; } $login_arr = $rowNumArr + array('RANDOM' => __('Generate Random')); $password_arr = $rowNumArr + array('RANDOM' => __('Generate Random')); $ip_arr = $rowNumArr; $mac_arr = $rowNumArr + array('RANDOM' => __('Generate Random')); $tariff_arr = $rowNumArr; $cash_arr = $rowNumArr; $credit_arr = $rowNumArr + array('ZERO' => __('Set to zero')); $creditex_arr = $rowNumArr + array('NONE' => __('Set to none')); $phone_arr = $rowNumArr + array('NONE' => __('Set to none')); $mobile_arr = $rowNumArr + array('NONE' => __('Set to none')); $email_arr = $rowNumArr + array('NONE' => __('Set to none')); $address_arr = $rowNumArr + array('NONE' => __('Set to none')); $realname_arr = $rowNumArr + array('NONE' => __('Set to none')); $contract_arr = $rowNumArr + array('NONE' => __('Set to none')); $ao_arr = $rowNumArr + array('AO_1' => __('AlwaysOnline=1')); $down_arr = $rowNumArr + array('DOWN_0' => __('Down=0')); $passive_arr = $rowNumArr + array('PASSIVE_0' => __('Passive=0')); $regtype_arr = array('SQL' => 'Show SQL dump', 'UB' => 'Ubilling live register'); //data column setting form $inputs = wf_Selector('login_col', $login_arr, __('User login'), '', true); $inputs .= wf_Selector('password_col', $password_arr, __('User password'), '', true); $inputs .= wf_Selector('ip_col', $ip_arr, __('User IP'), '', true); $inputs .= wf_Selector('mac_col', $mac_arr, __('User MAC'), '', true); $inputs .= wf_Selector('tariff_col', $tariff_arr, __('User tariff'), '', true); $inputs .= wf_Selector('cash_col', $cash_arr, __('User cash'), '', true); $inputs .= wf_Selector('credit_col', $credit_arr, __('User credit limit'), '', true); $inputs .= wf_Selector('creditex_col', $creditex_arr, __('User credit expire date'), '', true); $inputs .= wf_Selector('phone_col', $phone_arr, __('User phone'), '', true); $inputs .= wf_Selector('mobile_col', $mobile_arr, __('User mobile'), '', true); $inputs .= wf_Selector('email_col', $email_arr, __('User email'), '', true); $inputs .= wf_Selector('address_col', $address_arr, __('User address'), '', true); $inputs .= wf_Selector('realname_col', $realname_arr, __('User realname'), '', true); $inputs .= wf_Selector('contract_col', $contract_arr, __('User contract'), '', true); $inputs .= wf_Selector('ao_col', $ao_arr, __('User AlwaysOnline state'), '', true); $inputs .= wf_Selector('down_col', $down_arr, __('User Down state'), '', true); $inputs .= wf_Selector('passive_col', $passive_arr, __('User Passive state'), '', true); $inputs .= wf_Selector('regtype', $regtype_arr, __('User registration mode'), '', true); $inputs .= multinet_network_selector() . __('Target network') . wf_delimiter(); $inputs .= wf_HiddenInput('import_rawdata', base64_encode(serialize($parsed_data))); $inputs .= wf_Submit('Save this column pointers and continue import'); $colform = wf_Form("?module=migration&setpointers=true", 'POST', $inputs, 'glamour'); show_window(__('Select data columns and their values'), $colform); } else { show_error(__('Parsing error')); } }
/** * Returns JSON for actual ARP table * * @return string */ public function ajaxReplyArp() { $result = ''; $command = 'arp -a'; $raw = shell_exec($command); $jsonAAData = array(); if (!empty($raw)) { $allUserAddress = zb_AddressGetFulladdresslistCached(); $allUserIps = zb_UserGetAllIPs(); $allUserIps = array_flip($allUserIps); $allSwitchesIps = $this->getAllSwitchesIps(); $raw = explodeRows($raw); if (!empty($raw)) { foreach ($raw as $io => $each) { if (!empty($each)) { $ip = zb_ExtractIpAddress($each); $mac = zb_ExtractMacAddress($each); $hostType = $this->getHostLink($allUserIps, $allUserAddress, $allSwitchesIps, $ip); $jsonItem = array(); $jsonItem[] = $ip; $jsonItem[] = $mac; $jsonItem[] = $hostType; $jsonAAData[] = $jsonItem; } } } } $result = array("aaData" => $jsonAAData); return json_encode($result); }
/** * function that display JSON data for display FDB cache * * @param $fdbData_raw - array of existing cache _fdb files * * @return string */ function sn_SnmpParseFdbCacheJson($fdbData_raw) { $allusermacs = zb_UserGetAllMACs(); $allusermacs = array_flip($allusermacs); $alladdress = zb_AddressGetFulladdresslist(); $allswitches = zb_SwitchesGetAll(); $rawFilters = zb_StorageGet('FDBCACHEMACFILTERS'); $filteredCounter = 0; $switchdata = array(); $allfilters = array(); //switch data preprocessing if (!empty($allswitches)) { foreach ($allswitches as $io => $eachswitch) { $switchdata[$eachswitch['ip']] = $eachswitch['location']; } } //mac filters preprocessing if (!empty($rawFilters)) { $rawFilters = base64_decode($rawFilters); $rawFilters = explodeRows($rawFilters); if (!empty($rawFilters)) { foreach ($rawFilters as $rawfindex => $rawfmac) { $eachMacFilter = strtolower($rawfmac); $allfilters[trim($eachMacFilter)] = $rawfindex; } } } $result = '{ "aaData": ['; foreach ($fdbData_raw as $each_raw) { $nameExplode = explode('_', $each_raw); if (sizeof($nameExplode) == 2) { $switchIp = $nameExplode[0]; if (file_exists('exports/' . $each_raw)) { $eachfdb_raw = file_get_contents('exports/' . $each_raw); $eachfdb = unserialize($eachfdb_raw); if (!empty($eachfdb_raw)) { foreach ($eachfdb as $mac => $port) { //detecting user login by his mac if (isset($allusermacs[$mac])) { $userlogin = $allusermacs[$mac]; } else { $userlogin = false; } if ($userlogin) { $userlink = '<a href=?module=userprofile&username='******'><img src=skins/icon_user.gif> ' . @$alladdress[$userlogin] . '</a>'; } else { $userlink = ''; } if (sn_FDBFilterCheckMac($mac, $allfilters)) { $result .= ' [ "' . $switchIp . '", "' . $port . '", "' . @$switchdata[$switchIp] . '", "' . $mac . '", "' . $userlink . '" ],'; $filteredCounter++; } } } } } } //show some data if filters failed if ($filteredCounter == 0) { $result .= ' [ "", "", "", "' . __('Nothing found') . '", "" ],'; } $result = substr($result, 0, -1); $result .= '] }'; return $result; }
/** * Askozia PBX data fetching and processing * * @return void */ protected function preprocessAskoziaData() { if ($this->askoziaFlag) { if (!empty($this->askoziaUrl) and !empty($this->askoziaLogin) and !empty($this->askoziaPassword)) { $callsTmp = array(); $normalCalls = array(); //working time setup $rawWorkTime = $this->altCfg['WORKING_HOURS']; $rawWorkTime = explode('-', $rawWorkTime); $workStartTime = $rawWorkTime[0]; $workEndTime = $rawWorkTime[1]; $fields = array('extension_number' => 'all', 'cdr_filter' => 'incomingoutgoing', 'period_from' => $this->curmonth . '-01', 'period_to' => curdate(), 'date_format' => 'Y-m-d', 'time_format' => 'H:i:s', 'page_format' => 'A4', 'SubmitCSVCDR' => 'Download CSV'); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $this->askoziaUrl . '/status_cdr.php'); curl_setopt($ch, CURLOPT_USERPWD, $this->askoziaLogin . ":" . $this->askoziaPassword); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); $rawResult = curl_exec($ch); curl_close($ch); if (!empty($rawResult)) { $callsTmp = explodeRows($rawResult); if (!empty($callsTmp)) { foreach ($callsTmp as $eachline) { $explode = explode(';', $eachline); //in 2.2.8 delimiter changed from ," to ; if (!empty($eachline)) { $normalCalls[] = str_replace('"', '', $explode); } } } if (!empty($normalCalls)) { unset($normalCalls[0]); foreach ($normalCalls as $io => $each) { if ($each[16] != 'outbound') { $startTime = explode(' ', $each[9]); @($startTime = $startTime[1]); //only working time if (zb_isTimeBetween($workStartTime, $workEndTime, $startTime)) { if (ispos($each[14], 'ANSWERED') and !ispos($each[7], 'VoiceMail')) { $this->storeTmp['a_totalanswered']++; } $this->storeTmp['a_totalcalls']++; //call duration in seconds increment $this->storeTmp['a_totalcallsduration'] += $each[13]; } } } //average calls duration $this->storeTmp['a_averagecallduration'] = $this->storeTmp['a_totalcallsduration'] / $this->storeTmp['a_totalanswered']; } } } } }
/** * Renders ONU signal history chart * * @param int $onuId * @return string */ protected function onuSignalHistory($onuId) { $onuId = vf($onuId, 3); $result = ''; if (isset($this->allOnu[$onuId])) { //not empty MAC if ($this->allOnu[$onuId]['mac']) { if (file_exists(self::ONUSIG_PATH . md5($this->allOnu[$onuId]['mac']))) { $historyKey = self::ONUSIG_PATH . md5($this->allOnu[$onuId]['mac']); } elseif (file_exists(self::ONUSIG_PATH . md5($this->allOnu[$onuId]['serial']))) { $historyKey = self::ONUSIG_PATH . md5($this->allOnu[$onuId]['serial']); } else { $historyKey = ''; } if (!empty($historyKey)) { $rawData = file_get_contents($historyKey); $result .= wf_delimiter(); $result .= wf_tag('h2') . __('ONU signal history') . wf_tag('h2', true); //current day signal levels $todaySignal = ''; $curdate = curdate(); if (!empty($rawData)) { $todayTmp = explodeRows($rawData); if (!empty($todayTmp)) { foreach ($todayTmp as $io => $each) { if (ispos($each, $curdate)) { $todaySignal .= $each . "\n"; } } } } $result .= __('Today'); $result .= wf_tag('div', false, '', ''); $result .= wf_Graph($todaySignal, '800', '300', false); $result .= wf_tag('div', true); $result .= wf_tag('br'); //current month signal levels $monthSignal = ''; $curmonth = curmonth(); if (!empty($rawData)) { $monthTmp = explodeRows($rawData); if (!empty($monthTmp)) { foreach ($monthTmp as $io => $each) { if (ispos($each, $curmonth)) { $monthSignal .= $each . "\n"; } } } } $result .= __('Month'); $result .= wf_tag('div', false, '', ''); $result .= wf_Graph($monthSignal, '800', '300', false); $result .= wf_tag('div', true); $result .= wf_tag('br'); //all time signal history $result .= __('All time'); $result .= wf_tag('div', false, '', ''); $result .= wf_GraphCSV($historyKey, '800', '300', false); $result .= wf_tag('div', true); } } } return $result; }
$arping_path = $alterconfig['ARPING']; $arping_iface = $alterconfig['ARPING_IFACE']; $arping_options = $alterconfig['ARPING_EXTRA_OPTIONS']; $sudo_path = $config['SUDO']; $userdata = zb_UserGetStargazerData($login); $user_ip = $userdata['IP']; $command = $sudo_path . ' ' . $arping_path . ' ' . $arping_iface . ' ' . $arping_options . ' ' . $user_ip; $raw_result = shell_exec($command); if (wf_CheckGet(array('ajax'))) { die($raw_result); } $ping_result = wf_AjaxLoader(); $ping_result .= wf_AjaxLink('?module=pl_arping&username='******'&ajax=true', __('Renew'), 'ajaxarping', true, 'ubButton'); $ping_result .= wf_tag('pre', false, '', 'id="ajaxarping"') . $raw_result . wf_tag('pre', true); //detecting duplicate MAC $rawArray = explodeRows($raw_result); if (!empty($rawArray)) { foreach ($rawArray as $io => $eachline) { if (ispos($eachline, 'packets transmitted')) { $parseMe = $eachline; } } } if (!empty($parseMe)) { $parseMe = explode(',', $parseMe); if (sizeof($parseMe) == 3) { $txCount = vf($parseMe[0], 3); $rxCount = vf($parseMe[1], 3); if ($rxCount > $txCount) { $cloneFlag = true; }
/** * Checks PHP loaded modules * * @return string */ function zb_CheckPHPExtensions() { $result = ''; if (file_exists(CONFIG_PATH . 'optsextcfg')) { $allRequired = file_get_contents(CONFIG_PATH . 'optsextcfg'); if (!empty($allRequired)) { $allRequired = explodeRows($allRequired); if (!empty($allRequired)) { foreach ($allRequired as $io => $each) { if (!extension_loaded($each)) { $result .= wf_tag('span', false, 'alert_error') . __('PHP extension not found') . ': ' . $each . wf_tag('span', true); } else { $result .= wf_tag('span', false, 'alert_success') . __('PHP extension loaded') . ': ' . $each . wf_tag('span', true); } } } } } else { $result .= wf_tag('span', false, 'alert_error') . __('Strange exeption') . ': OPTSEXTCFG_NOT_FOUND' . wf_tag('span', true); } return $result; }
/** * Returns full map marks for builds with filled GEO field * * @return string */ function um_MapDrawBuilds() { $ym_conf = rcms_parse_ini_file(CONFIG_PATH . "ymaps.ini"); $query = "SELECT * from `build` WHERE `geo` != '' "; $allbuilds = simple_queryall($query); $allstreets = zb_AddressGetStreetAllData(); $streetData = array(); $cacheDir = 'exports/'; $cacheTime = 10; $cacheTime = time() - $cacheTime * 60; //street id => streetname if (!empty($allstreets)) { foreach ($allstreets as $ia => $eachstreet) { $streetData[$eachstreet['id']] = $eachstreet['streetname']; } } //get apts in all builds aggregated with users logins $aptData = array(); $allapts_q = "SELECT `buildid`,`apt`,`login` from `apt` JOIN `address` ON `apt`.`id`=`address`.`aptid`"; $allapts = simple_queryall($allapts_q); if (!empty($allapts)) { $aptData = $allapts; } //get all user ips $alluserips = zb_UserGetAllIPs(); //form alive ips array $aliveIps = array(); if (file_exists("exports/nmaphostscan")) { $nmapData = file_get_contents("exports/nmaphostscan"); $nmapData = explodeRows($nmapData); if (!empty($nmapData)) { foreach ($nmapData as $ic => $eachnmaphost) { $zhost = zb_ExtractIpAddress($eachnmaphost); if ($zhost) { $aliveIps[$zhost] = $zhost; } } } } $result = ''; if (!empty($allbuilds)) { foreach ($allbuilds as $io => $each) { $geo = mysql_real_escape_string($each['geo']); @($streetname = $streetData[$each['streetid']]); $title = wf_Link("?module=builds&action=editbuild&streetid=" . $each['streetid'] . "&buildid=" . $each['id'], $streetname . ' ' . $each['buildnum'], false); $content = ''; $cells = wf_TableCell(__('apt.')); $cells .= wf_TableCell(__('User')); $cells .= wf_TableCell(__('Status')); $rows = wf_tag('tr', false, '', 'bgcolor=#DCDCDC') . $cells . wf_tag('tr', true); $iconlabel = ''; $footer = ''; $aliveUsers = 0; $usersCount = 0; if (!empty($aptData)) { //build users data caching $cacheName = $cacheDir . $each['id'] . '.inbuildusers'; if (file_exists($cacheName)) { $updateCache = false; if (filemtime($cacheName) > $cacheTime) { $updateCache = false; } else { $updateCache = true; } } else { $updateCache = true; } if (!$updateCache) { $cachePrev = file_get_contents($cacheName); $cachePrev = unserialize($cachePrev); $rows = $cachePrev['rows']; $usersCount = $cachePrev['userscount']; $aliveUsers = $cachePrev['aliveusers']; } else { foreach ($aptData as $ib => $eachapt) { if ($eachapt['buildid'] == $each['id']) { if (isset($alluserips[$eachapt['login']])) { $userIp = $alluserips[$eachapt['login']]; $usersCount++; if (isset($aliveIps[$userIp])) { $aliveFlag = web_bool_led(true); $aliveUsers++; } else { $aliveFlag = web_bool_led(false); } $cells = wf_TableCell($eachapt['apt']); $cells .= wf_TableCell(wf_Link('?module=userprofile&username='******'login'], $userIp, false)); $cells .= wf_TableCell($aliveFlag); $rows .= wf_TableRow($cells); } } } $cacheStore = array(); $cacheStore['rows'] = $rows; $cacheStore['userscount'] = $usersCount; $cacheStore['aliveusers'] = $aliveUsers; $cacheStore = serialize($cacheStore); file_put_contents($cacheName, $cacheStore); } } $footer = __('Active') . ' ' . $aliveUsers . '/' . $usersCount; $icon = um_MapBuildIcon($usersCount); $content = json_encode(wf_TableBody($rows, '', 0)); $title = json_encode($title); $content = str_replace('"', '', $content); $content = str_replace("'", '', $content); $content = str_replace("\n", '', $content); $title = str_replace('"', '', $title); $title = str_replace("'", '', $title); $title = str_replace("\n", '', $title); $result .= sm_MapAddMark($geo, $title, $content, $footer, $icon, $iconlabel, true); } } return $result; }
/** * Parses log data for some user login * * @return array */ protected function getLogData() { $result = array(); global $ubillingConfig; $billCfg = $ubillingConfig->getBilling(); $cat = $billCfg['CAT']; $grep = $billCfg['GREP']; $i = 0; if (!empty($this->login)) { if (file_exists($this->logPath)) { $command = $cat . ' ' . $this->logPath . ' | grep "(' . $this->login . ')"'; $raw = shell_exec($command); if (!empty($raw)) { $raw = explodeRows($raw); if (!empty($raw)) { foreach ($raw as $io => $each) { if (!empty($each)) { $line = explode(' ', $each); $date = $line[0] . ' ' . $line[1]; $event = $line[3]; $params = explode(')', $each); $params = $params[1]; $result[$i]['date'] = $date; $result[$i]['event'] = $event; $result[$i]['params'] = $params; $i++; } } } } } } return $result; }
/** * Renders swpoll logs control * * @global object $ubillingConfig * * @return string */ function web_FDBTableLogControl() { global $ubillingConfig; $messages = new UbillingMessageHelper(); $result = ''; $logPath = 'exports/swpolldata.log'; $logData = array(); $renderData = ''; $rows = ''; $recordsLimit = 200; $prevTime = ''; $curTimeTime = ''; $diffTime = ''; if (file_exists($logPath)) { $billCfg = $ubillingConfig->getBilling(); $tailCmd = $billCfg['TAIL']; $runCmd = $tailCmd . ' -n ' . $recordsLimit . ' ' . $logPath; $rawResult = shell_exec($runCmd); $renderData .= __('Showing') . ' ' . $recordsLimit . ' ' . __('last events') . wf_tag('br'); $renderData .= wf_Link('?module=switchpoller&dlswpolllog=true', wf_img('skins/icon_download.png', __('Download')) . ' ' . __('Download full log'), true); if (!empty($rawResult)) { $logData = explodeRows($rawResult); if (!empty($logData)) { $cells = wf_TableCell(__('Time') . ' (' . __('seconds') . ')'); $cells .= wf_TableCell(__('Date')); $cells .= wf_TableCell(__('IP')); $cells .= wf_TableCell(__('Event')); $rows .= wf_TableRow($cells, 'row1'); // $logData = array_reverse($logData); foreach ($logData as $io => $each) { if (!empty($each)) { if (!ispos($each, 'SWPOLLSTART')) { $eachEntry = explode(' ', $each); $curTime = $eachEntry[0] . ' ' . $eachEntry[1]; $curTime = strtotime($curTime); if (!empty($prevTime)) { $diffTime = $curTime - $prevTime; } else { $diffTime = 0; } $prevTime = $eachEntry[0] . ' ' . $eachEntry[1]; $prevTime = strtotime($prevTime); $cells = wf_TableCell($diffTime); $cells .= wf_TableCell($eachEntry[0] . ' ' . $eachEntry[1]); $cells .= wf_TableCell($eachEntry[2]); $cells .= wf_TableCell($eachEntry[3] . ' ' . @$eachEntry[4] . ' ' . @$eachEntry[5]); $rows .= wf_TableRow($cells, 'row3'); } else { $eachEntry = explode(' ', $each); $prevTime = strtotime($eachEntry[0] . ' ' . $eachEntry[1]); } } } $renderData .= wf_TableBody($rows, '100%', 0, 'sortable'); } } else { $renderData .= $messages->getStyledMessage(__('Nothing found'), 'warning'); } $result = wf_modal(wf_img('skins/log_icon_small.png', __('Swpoll log')), __('Swpoll log'), $renderData, '', '800', '600'); } return $result; }
} } } //writing to cache $savePrev = serialize($curTraff); file_put_contents('exports/prevtraff', $savePrev); } } //saving scan data file_put_contents('exports/nmaphostscan', $fullScanResult); //postprocessing DN data if ($alterconf['DN_FULLHOSTSCAN']) { $activeIps = array(); if (file_exists("exports/nmaphostscan")) { $nmapData = file_get_contents("exports/nmaphostscan"); $nmapData = explodeRows($nmapData); if (!empty($nmapData)) { foreach ($nmapData as $ic => $eachnmaphost) { $zhost = zb_ExtractIpAddress($eachnmaphost); if ($zhost) { $activeIps[$zhost] = $zhost; } } } } if (!empty($activeIps)) { if (file_exists(DATA_PATH . "dn")) { //directory clanup $oldDnData = rcms_scandir(DATA_PATH . "dn/"); if (!empty($oldDnData)) { foreach ($oldDnData as $deleteFile) {
/** * Returns Chart source * * @param string $data - CSV formatted data * @param string $widht - graph width in pixels * @param string $height - graph height in pixels * @param bool $errorbars - display error bars around data series * * @return string */ function wf_Graph($data, $width = '500', $height = '300', $errorbars = false) { $randomId = wf_InputId(); $objectId = 'graph_' . $randomId; $data = trim($data); $data = explodeRows($data); $cleandata = ''; if ($errorbars) { $errorbars = 'true'; } else { $errorbars = 'false'; } if (!empty($data)) { foreach ($data as $eachrow) { $cleandata .= '"' . trim($eachrow) . '\\n" +' . "\n"; } $cleandata = mb_substr($cleandata, 0, -2, 'utf-8'); } $result = wf_tag('div', false, '', 'id="' . $randomId . '" style="width:' . $width . 'px; height:' . $height . 'px;"') . wf_tag('div', true); $result .= wf_tag('script', false, '', 'type="text/javascript"'); $result .= $objectId . ' = new Dygraph('; $result .= 'document.getElementById("' . $randomId . '"),' . "\n"; $result .= $cleandata; $result .= ', { errorBars: ' . $errorbars . ' }' . "\n"; $result .= ');'; $result .= wf_tag('script', true); return $result; }
function catvbs_ParseRaw($rawid) { $alterconf = rcms_parse_ini_file(CONFIG_PATH . "catv.ini"); $bs_options = $alterconf['BS_OPTIONS']; //delimiter,data,name,addr,summ $options = explode(',', $bs_options); //magic numbers, khe khe $data_offset = $options[1]; $realname_offset = $options[2]; $address_offset = $options[3]; $summ_offset = $options[4]; $delimiter = $options[0]; $date = curdatetime(); $rawdata_q = "SELECT `rawdata` from `catv_bankstaraw` WHERE `id`='" . $rawid . "'"; $rawdata = simple_query($rawdata_q); $rawdata = $rawdata['rawdata']; $hash = md5($rawdata); $splitrows = explodeRows($rawdata); if (sizeof($splitrows) > $data_offset) { $i = 0; foreach ($splitrows as $eachrow) { if ($i >= $data_offset) { $rowsplit = explode($delimiter, $eachrow); //filter ending if (isset($rowsplit[$summ_offset])) { $realname = trim(strtolower_utf8($rowsplit[$realname_offset])); $address = trim(strtolower_utf8($rowsplit[$address_offset])); $address = mysql_real_escape_string($address); $realname = str_replace(' ', '', $realname); $summ = trim($rowsplit[$summ_offset]); $realname = mysql_real_escape_string($realname); $address = str_replace(' ', '', $address); $query = "INSERT INTO `catv_bankstaparsed` (\r\n `id` ,\r\n `hash` ,\r\n `date` ,\r\n `row` ,\r\n `realname` ,\r\n `address` ,\r\n `summ` ,\r\n `state` ,\r\n `login`\r\n )\r\n VALUES (\r\n NULL ,\r\n '" . $hash . "',\r\n '" . $date . "',\r\n '" . $i . "',\r\n '" . $realname . "',\r\n '" . $address . "',\r\n '" . $summ . "',\r\n '0',\r\n ''\r\n ); \r\n "; nr_query($query); } } $i++; } } }
function zb_AskoziaParseStatus($rawData) { $exploded = explodeRows($rawData); $data = array('phones' => 0, 'curcalls' => 0, 'totalcalls' => 0, 'ram' => 0, 'disk' => 0, 'uptime' => 0); if (!empty($exploded)) { foreach ($exploded as $each) { //detecting stats if (ispos($each, ';')) { $parse = explode(';', $each); //current calls $data['curcalls'] = $parse[1]; //total calls $data['totalcalls'] = $parse[2]; //registered phones $data['phones'] = $parse[4]; //uptime in days or minutes $data['uptime'] = $parse[5]; $data['uptime'] = str_replace('min', __('minutes'), $data['uptime']); $data['uptime'] = str_replace('hours', __('hours'), $data['uptime']); $data['uptime'] = str_replace('hour', __('hour'), $data['uptime']); $data['uptime'] = str_replace('days', __('days'), $data['uptime']); $data['uptime'] = str_replace('day', __('day'), $data['uptime']); //system memory $data['ram'] = $parse[6]; //external storage $data['disk'] = $parse[7]; } } } $cells = wf_TableCell(__('Phones')); $cells .= wf_TableCell(__('Current calls')); $cells .= wf_TableCell(__('Calls processed')); $cells .= wf_TableCell(__('Uptime')); $cells .= wf_TableCell(__('Memory usage')); $cells .= wf_TableCell(__('External storage')); $rows = wf_TableRow($cells, 'row2'); $cells = wf_TableCell($data['phones']); $cells .= wf_TableCell($data['curcalls']); $cells .= wf_TableCell($data['totalcalls']); $cells .= wf_TableCell($data['uptime']); $cells .= wf_TableCell(web_bar($data['ram'], '100') . ' ' . $data['ram'] . '%'); $cells .= wf_TableCell(web_bar($data['disk'], '100') . ' ' . $data['disk'] . '%'); $rows .= wf_TableRow($cells, 'row3'); $result = wf_TableBody($rows, '100%', 0, ''); return $result; }
$config = $ubillingConfig->getBilling(); $alter_conf = $ubillingConfig->getAlter(); $cat_path = $config['CAT']; $grep_path = $config['GREP']; $tail_path = $config['TAIL']; $sudo_path = $config['SUDO']; $leasefile = $alter_conf['NMLEASES']; $userdata = zb_UserGetStargazerData($login); $user_ip = $userdata['IP']; $user_mac = zb_MultinetGetMAC($user_ip); show_window(__('Current MAC') . ' ' . $user_mac, ''); $command = $sudo_path . ' ' . $cat_path . ' ' . $leasefile . ' | ' . $grep_path . ' ' . $user_mac . ' | ' . $tail_path . ' -n 30'; $output = shell_exec($command); if (!empty($output)) { $result = ''; $rowdata = ''; $allrows = explodeRows($output); foreach ($allrows as $eachrow) { if (!empty($eachrow)) { $celldata = wf_TableCell($eachrow); $rowdata .= wf_TableRow($celldata, 'row3'); } } $result = wf_TableBody($rowdata, '100%', 0); show_window(__('User DHCP log'), $result); } show_window('', web_UserControls($login)); } } else { show_error(__('You cant control this module')); }
$txt=""; if(!file_exists($txt_file)){ //$fechaHoy = date('dmY'); $mensaje = "Ejecuci�n correcta a las: \t".date("Y/m/d h:i:s")."\t No hay archivo para procesar.\r\n"; $file_log = $RUTA_IRH_LOG."log_RH".".txt"; $reffichero001 = fopen($file_log, "a+"); fwrite($reffichero001, $mensaje); fclose($reffichero001); } $archivo = fopen($txt_file, "r") or exit("echo Unable to open file"); $data = fread($archivo, filesize($txt_file)); $rowsArr = explodeRows($data); $lineTotal=(explodeTabs($rowsArr[count($rowsArr)-1])); //var_dump($lineTotal); if (strcmp("TOTAL",$lineTotal[0]{0}.$lineTotal[0]{1}.$lineTotal[0]{2}.$lineTotal[0]{3}.$lineTotal[0]{4})!= 0){ guardaLogError("004",$lineTotal,0); $mensaje = "Ejecuci�n correcta a las: \t".date("Y/m/d h:i:s")."\t Archivo incompleto para procesar.\r\n"; $file_log = $RUTA_IRH_LOG."log_RH".".txt"; $reffichero001 = fopen($file_log, "a+"); fwrite($reffichero001, $mensaje); fclose($reffichero001); } else{ for($i=1;$i<count($rowsArr)-1;$i++) { $U = new Usuario(); $adamS=array();
<?php if (cfr('ARPDIAG')) { $alterconf = $ubillingConfig->getAlter(); if ($alterconf['ARPDIAG_ENABLED']) { $config = $ubillingConfig->getBilling(); $log_path = $alterconf['ARPDIAG_LOG']; $sudo_path = $config['SUDO']; $cat_path = $config['CAT']; $grep_path = $config['GREP']; $command = $sudo_path . ' ' . $cat_path . ' ' . $log_path . ' | ' . $grep_path . ' "arp"'; $rawdata = shell_exec($command); $tablerows = ''; if (!empty($rawdata)) { $splitdata = explodeRows($rawdata); if (!empty($splitdata)) { foreach ($splitdata as $eachrow) { if (!empty($eachrow)) { if (ispos($eachrow, 'attemp')) { $rowclass = 'row2'; } else { $rowclass = 'row3'; } $tablecells = wf_TableCell($eachrow); $tablerows .= wf_TableRow($tablecells, $rowclass); } } } $result = wf_TableBody($tablerows, '100%', '0', ''); } else { $result = __('It seems there is nothing unusual');