Пример #1
0
/**
 * Returns list of all available switches devices with its controls. Also catches ajaxping and forcereping events.
 * 
 * @return string
 */
function web_SwitchesShow()
{
    global $ubillingConfig;
    $alterconf = $ubillingConfig->getAlter();
    $allswitches = zb_SwitchesGetAll();
    $modelnames = zb_SwitchModelsGetAllTag();
    $currenttime = time();
    $reping_timeout = $alterconf['SW_PINGTIMEOUT'];
    $deathTime = zb_SwitchesGetAllDeathTime();
    //counters
    $countTotal = 0;
    $countAlive = 0;
    $countDead = 0;
    $countNp = 0;
    $countOnMap = 0;
    $countSwpoll = 0;
    $countMtsigmon = 0;
    $countOlt = 0;
    $countLinked = 0;
    //non realtime switches pinging
    $last_pingtime = zb_StorageGet('SWPINGTIME');
    if (!$last_pingtime) {
        zb_SwitchesRepingAll();
        zb_StorageSet('SWPINGTIME', $currenttime);
        $last_pingtime = $currenttime;
    } else {
        if ($currenttime > $last_pingtime + $reping_timeout * 60) {
            // normal timeout reping sub here
            zb_SwitchesRepingAll();
            zb_StorageSet('SWPINGTIME', $currenttime);
        }
    }
    //force total reping and update cache
    if (wf_CheckGet(array('forcereping'))) {
        zb_SwitchesRepingAll();
        zb_StorageSet('SWPINGTIME', $currenttime);
        if (wf_CheckGet(array('ajaxping'))) {
            $dead_raw = zb_StorageGet('SWDEAD');
            $deathTime = zb_SwitchesGetAllDeathTime();
            $deadarr = array();
            $ajaxResult = '';
            if ($dead_raw) {
                $deadarr = unserialize($dead_raw);
                if (!empty($deadarr)) {
                    //there is some dead switches
                    $deadcount = sizeof($deadarr);
                    if ($alterconf['SWYMAP_ENABLED']) {
                        //getting geodata
                        $switchesGeo = zb_SwitchesGetAllGeo();
                    }
                    //ajax container
                    $ajaxResult .= wf_tag('div', false, '', 'id="switchping"');
                    foreach ($deadarr as $ip => $switch) {
                        if ($alterconf['SWYMAP_ENABLED']) {
                            if (isset($switchesGeo[$ip])) {
                                if (!empty($switchesGeo[$ip])) {
                                    $devicefind = wf_Link('?module=switchmap&finddevice=' . $switchesGeo[$ip], wf_img('skins/icon_search_small.gif', __('Find on map'))) . ' ';
                                } else {
                                    $devicefind = '';
                                }
                            } else {
                                $devicefind = '';
                            }
                        } else {
                            $devicefind = '';
                        }
                        //check morgue records for death time
                        if (isset($deathTime[$ip])) {
                            $deathClock = wf_img('skins/clock.png', __('Switch dead since') . ' ' . $deathTime[$ip]) . ' ';
                        } else {
                            $deathClock = '';
                        }
                        //switch location link
                        $switchLocator = wf_Link('?module=switches&gotoswitchbyip=' . $ip, web_edit_icon(__('Go to switch')));
                        //add switch as dead
                        $ajaxResult .= $devicefind . ' ' . $switchLocator . ' ' . $deathClock . $ip . ' - ' . $switch . '<br>';
                    }
                } else {
                    $ajaxResult = __('Switches are okay, everything is fine - I guarantee');
                }
            }
            $ajaxResult .= wf_delimiter() . __('Cache state at time') . ': ' . date("H:i:s");
            print $ajaxResult;
            //darkvoid update
            $notifyArea = new DarkVoid();
            $notifyArea->flushCache();
            die;
        }
    }
    //load dead switches cache
    $dead_switches_raw = zb_StorageGet('SWDEAD');
    if (!$dead_switches_raw) {
        $dead_switches = array();
    } else {
        $dead_switches = unserialize($dead_switches_raw);
    }
    //create new ADcomments object if enabled
    if ($alterconf['ADCOMMENTS_ENABLED']) {
        $adcomments = new ADcomments('SWITCHES');
    }
    $tablecells = wf_TableCell(__('ID'));
    $tablecells .= wf_TableCell(__('IP'));
    $tablecells .= wf_TableCell(__('Location'));
    $tablecells .= wf_TableCell(__('Active'));
    $tablecells .= wf_TableCell(__('Model'));
    $tablecells .= wf_TableCell(__('SNMP community'));
    $tablecells .= wf_TableCell(__('Geo location'));
    $tablecells .= wf_TableCell(__('Description'));
    $tablecells .= wf_TableCell(__('Actions'));
    $tablerows = wf_TableRow($tablecells, 'row1');
    $lighter = 'onmouseover="this.className = \'row2\';" onmouseout="this.className = \'row3\';" ';
    if (!empty($allswitches)) {
        foreach ($allswitches as $io => $eachswitch) {
            if (isset($dead_switches[$eachswitch['ip']])) {
                if (isset($deathTime[$eachswitch['ip']])) {
                    $obituary = __('Switch dead since') . ' ' . $deathTime[$eachswitch['ip']];
                } else {
                    $obituary = '';
                }
                $aliveled = web_red_led($obituary);
                $aliveflag = '0';
                $countDead++;
            } else {
                if (strpos($eachswitch['desc'], 'NP') === false) {
                    $aliveled = web_green_led();
                    $aliveflag = '1';
                    $countAlive++;
                } else {
                    $aliveled = web_yellow_led();
                    $aliveflag = '2';
                    $countNp++;
                }
            }
            $tablecells = wf_TableCell($eachswitch['id']);
            $tablecells .= wf_TableCell($eachswitch['ip'], '', '', 'sorttable_customkey="' . ip2int($eachswitch['ip']) . '"');
            $tablecells .= wf_TableCell($eachswitch['location']);
            $tablecells .= wf_TableCell($aliveled, '', '', 'sorttable_customkey="' . $aliveflag . '"');
            $tablecells .= wf_TableCell(@$modelnames[$eachswitch['modelid']]);
            $tablecells .= wf_TableCell($eachswitch['snmp']);
            $tablecells .= wf_TableCell($eachswitch['geo']);
            $tablecells .= wf_TableCell($eachswitch['desc']);
            $switchcontrols = '';
            if (cfr('SWITCHESEDIT')) {
                $switchcontrols .= wf_Link('?module=switches&edit=' . $eachswitch['id'], web_edit_icon());
            }
            if (cfr('SWITCHPOLL')) {
                if (!empty($eachswitch['snmp']) and ispos($eachswitch['desc'], 'SWPOLL')) {
                    $switchcontrols .= '&nbsp;' . wf_Link('?module=switchpoller&switchid=' . $eachswitch['id'], wf_img('skins/snmp.png', __('SNMP query')));
                    $countSwpoll++;
                }
            }
            if ($alterconf['SWYMAP_ENABLED']) {
                if (!empty($eachswitch['geo'])) {
                    $switchcontrols .= wf_Link('?module=switchmap&finddevice=' . $eachswitch['geo'], wf_img('skins/icon_search_small.gif', __('Find on map')));
                    $countOnMap++;
                }
                if (!empty($eachswitch['parentid'])) {
                    $switchcontrols .= wf_Link('?module=switchmap&finddevice=' . $eachswitch['geo'] . '&showuplinks=true&traceid=' . $eachswitch['id'], wf_img('skins/ymaps/uplinks.png', __('Uplink switch')));
                    $countLinked++;
                }
            }
            if (ispos($eachswitch['desc'], 'MTSIGMON')) {
                $countMtsigmon++;
            }
            if (ispos($eachswitch['desc'], 'OLT')) {
                $countOlt++;
            }
            if ($alterconf['ADCOMMENTS_ENABLED']) {
                $switchcontrols .= $adcomments->getCommentsIndicator($eachswitch['id']);
            }
            if (isset($alterconf['SW_WEBNAV'])) {
                if ($alterconf['SW_WEBNAV']) {
                    $switchcontrols .= ' ' . wf_tag('a', false, '', 'href="http://' . $eachswitch['ip'] . '" target="_BLANK"') . wf_img('skins/ymaps/globe.png', __('Go to the web interface')) . wf_tag('a', true);
                }
            }
            $tablecells .= wf_TableCell($switchcontrols);
            $tablerows .= wf_tag('tr', false, 'row3', $lighter);
            $tablerows .= $tablecells;
            $tablerows .= wf_tag('tr', true);
            $countTotal++;
        }
    }
    $result = wf_TableBody($tablerows, '100%', '0', 'sortable');
    $result .= wf_img('skins/icon_active.gif') . ' ' . __('Alive switches') . ' - ' . ($countAlive + $countNp) . ' (' . $countAlive . '+' . $countNp . ')' . wf_tag('br');
    $result .= wf_img('skins/icon_inactive.gif') . ' ' . __('Dead switches') . ' - ' . $countDead . wf_tag('br');
    $result .= wf_img('skins/yellow_led.png') . ' ' . __('NP switches') . ' - ' . $countNp . wf_tag('br');
    $result .= wf_img('skins/snmp.png') . ' ' . __('SWPOLL query') . ' - ' . $countSwpoll . wf_tag('br');
    $result .= wf_img('skins/wifi.png') . ' ' . __('MTSIGMON devices') . ' - ' . $countMtsigmon . wf_tag('br');
    $result .= wf_img('skins/pon_icon.gif') . ' ' . __('OLT devices') . ' - ' . $countOlt . wf_tag('br');
    $result .= wf_img('skins/icon_search_small.gif') . ' ' . __('Placed on map') . ' - ' . $countOnMap . wf_tag('br');
    $result .= wf_img('skins/ymaps/uplinks.png') . ' ' . __('Have uplinks') . ' - ' . $countLinked . wf_tag('br');
    $result .= wf_tag('br') . wf_tag('b') . __('Total') . ': ' . $countTotal . wf_tag('b', true) . wf_tag('br');
    return $result;
}
Пример #2
0
    function stg_show_fulluserlistOld()
    {
        global $alter_conf;
        $allusers = zb_UserGetAllStargazerData();
        $allrealnames = zb_UserGetAllRealnames();
        $alladdress = zb_AddressGetFulladdresslist();
        if ($alter_conf['USER_LINKING_ENABLED']) {
            $alllinkedusers = cu_GetAllLinkedUsers();
            $allparentusers = cu_GetAllParentUsers();
        }
        $totaltraff_i = 0;
        $totaltraff_m = 0;
        $totaltraff = 0;
        $ucount = 0;
        $trueonline = 0;
        $inacacount = 0;
        $tcredit = 0;
        $tcash = 0;
        // LAT column
        if ($alter_conf['ONLINE_LAT']) {
            $lat_col_head = wf_TableCell(__('LAT'));
            $act_offset = 1;
        } else {
            $lat_col_head = '';
            $act_offset = 0;
        }
        //online stars
        if ($alter_conf['DN_ONLINE_DETECT']) {
            $true_online_header = wf_TableCell(__('Users online'));
            $true_online_selector = ' col_' . (5 + $act_offset) . ': "select",';
        } else {
            $true_online_header = '';
            $true_online_selector = '';
        }
        //extended filters
        if ($alter_conf['ONLINE_FILTERS_EXT']) {
            $extfilters = wf_Link('javascript:showfilter();', __('Extended filters'), false);
        } else {
            $extfilters = '';
        }
        //additional finance links
        if ($alter_conf['FAST_CASH_LINK']) {
            $fastcash = true;
        } else {
            $fastcash = false;
        }
        $result = $extfilters;
        $result .= wf_tag('table', false, 'sortable', 'width="100%" id="onlineusers"');
        $headerCells = wf_TableCell(__('Full address'));
        $headerCells .= wf_TableCell(__('Real Name'));
        $headerCells .= wf_TableCell(__('IP'));
        $headerCells .= wf_TableCell(__('Tariff'));
        $headerCells .= $lat_col_head;
        $headerCells .= wf_TableCell(__('Active'));
        $headerCells .= $true_online_header;
        $headerCells .= wf_TableCell(__('Traffic'));
        $headerCells .= wf_TableCell(__('Balance'));
        $headerCells .= wf_TableCell(__('Credit'));
        $headerRow = wf_TableRow($headerCells, 'row1');
        $result .= $headerRow;
        if (!empty($allusers)) {
            foreach ($allusers as $io => $eachuser) {
                $tinet = 0;
                $ucount++;
                $cash = $eachuser['Cash'];
                $credit = $eachuser['Credit'];
                for ($classcounter = 0; $classcounter <= 9; $classcounter++) {
                    $dc = 'D' . $classcounter . '';
                    $uc = 'U' . $classcounter . '';
                    $tinet = $tinet + ($eachuser[$dc] + $eachuser[$uc]);
                }
                $totaltraff = $totaltraff + $tinet;
                $tcredit = $tcredit + $credit;
                $tcash = $tcash + $cash;
                $act = web_green_led() . ' ' . __('Yes');
                //finance check
                if ($cash < '-' . $credit) {
                    $act = web_red_led() . ' ' . __('No');
                    $inacacount++;
                }
                if ($alter_conf['ONLINE_LAT']) {
                    $user_lat = wf_TableCell(date("Y-m-d H:i:s", $eachuser['LastActivityTime']));
                } else {
                    $user_lat = '';
                }
                //online check
                if ($alter_conf['DN_ONLINE_DETECT']) {
                    if (file_exists(DATA_PATH . 'dn/' . $eachuser['login'])) {
                        $online_flag = 1;
                        $trueonline++;
                    } else {
                        $online_flag = 0;
                    }
                    $online_cell = wf_TableCell(web_bool_star($online_flag, true), '', '', 'sorttable_customkey="' . $online_flag . '"');
                } else {
                    $online_cell = '';
                    $online_flag = 0;
                }
                if ($alter_conf['ONLINE_LIGHTER']) {
                    $lighter = 'onmouseover="this.className = \'row2\';" onmouseout="this.className = \'row3\';" ';
                } else {
                    $lighter = '';
                }
                //user linking indicator
                if ($alter_conf['USER_LINKING_ENABLED']) {
                    //is user child?
                    if (isset($alllinkedusers[$eachuser['login']])) {
                        $corporate = wf_Link('?module=corporate&userlink=' . $alllinkedusers[$eachuser['login']], web_corporate_icon(), false);
                    } else {
                        $corporate = '';
                    }
                    //is  user parent?
                    if (isset($allparentusers[$eachuser['login']])) {
                        $corporate = wf_Link('?module=corporate&userlink=' . $allparentusers[$eachuser['login']], web_corporate_icon('Corporate parent'), false);
                    }
                } else {
                    $corporate = '';
                }
                //fast cash link
                if ($fastcash) {
                    $financelink = wf_Link('?module=addcash&username='******'login'] . '#profileending', wf_img('skins/icon_dollar.gif', __('Finance operations')), false);
                } else {
                    $financelink = '';
                }
                $result .= wf_tag('tr', false, 'row3', $lighter);
                $result .= wf_tag('td', false);
                $result .= wf_Link('?module=traffstats&username='******'login'], web_stats_icon(), false);
                $result .= $financelink;
                $result .= wf_Link('?module=userprofile&username='******'login'], web_profile_icon(), false);
                $result .= $corporate;
                $result .= @$alladdress[$eachuser['login']];
                $result .= wf_tag('td', true);
                $result .= wf_TableCell(@$allrealnames[$eachuser['login']]);
                $result .= wf_TableCell($eachuser['IP'], '', '', 'sorttable_customkey="' . ip2int($eachuser['IP']) . '"');
                $result .= wf_TableCell($eachuser['Tariff']);
                $result .= $user_lat;
                $result .= wf_TableCell($act);
                $result .= $online_cell;
                $result .= wf_TableCell(stg_convert_size($tinet), '', '', 'sorttable_customkey="' . $tinet . '"');
                $result .= wf_TableCell(round($eachuser['Cash'], 2));
                $result .= wf_TableCell(round($eachuser['Credit'], 2));
                $result .= wf_tag('tr', true);
            }
        }
        if ($alter_conf['DN_ONLINE_DETECT']) {
            $true_online_counter = wf_TableCell(__('Users online') . ' ' . $trueonline);
        } else {
            $true_online_counter = null;
        }
        $result .= wf_tag('table', true);
        $footerCells = wf_TableCell(__('Total') . ': ' . $ucount);
        $footerCells .= wf_TableCell(__('Active users') . ' ' . ($ucount - $inacacount) . ' / ' . __('Inactive users') . ' ' . $inacacount);
        $footerCells .= $true_online_counter;
        $footerCells .= wf_TableCell(__('Traffic') . ': ' . stg_convert_size($totaltraff));
        $footerCells .= wf_TableCell(__('Total') . ': ' . round($tcash, 2));
        $footerCells .= wf_TableCell(__('Credit total') . ': ' . $tcredit);
        $footerRows = wf_TableRow($footerCells, 'row1');
        $result .= wf_TableBody($footerRows, '100%', '0');
        //extended filters again
        if ($alter_conf['ONLINE_FILTERS_EXT']) {
            $filtercode = wf_tag('script', false, '', 'language="javascript" type="text/javascript"');
            $filtercode .= '
            //<![CDATA[
            function showfilter() {
            var onlinefilters = {
		btn: false,
          	col_' . (4 + $act_offset) . ': "select",
               ' . $true_online_selector . '
		btn_text: ">"
               }
                setFilterGrid("onlineusers",0,onlinefilters);
             }
            //]]>';
            $filtercode .= wf_tag('script', true);
        } else {
            $filtercode = '';
        }
        $result .= $filtercode;
        return $result;
    }
Пример #3
0
/**
 * Returns boolean led indicator
 * 
 * @param bool/string $flag
 * @param bool $text
 * @return string
 */
function web_bool_led($flag, $text = false)
{
    if ($text) {
        $no = ' ' . __('No') . ' ';
        $yes = __('Yes') . ' ';
    } else {
        $no = '';
        $yes = '';
    }
    $led = $no . web_red_led();
    if ($flag) {
        $led = $yes . web_green_led();
    }
    return $led;
}
Пример #4
0
/**
 * Returns user array in table view
 * 
 * @global object $ubillingConfig
 * @param array $usersarr
 * @return string
 */
function web_UserArrayShower($usersarr)
{
    global $ubillingConfig;
    $alterconf = $ubillingConfig->getAlter();
    if (!empty($usersarr)) {
        $alladdress = zb_AddressGetFulladdresslistCached();
        $allrealnames = zb_UserGetAllRealnames();
        $alltariffs = zb_TariffsGetAllUsers();
        $allusercash = zb_CashGetAllUsers();
        $allusercredits = zb_CreditGetAllUsers();
        $alluserips = zb_UserGetAllIPs();
        if ($alterconf['ONLINE_LAT']) {
            $alluserlat = zb_LatGetAllUsers();
        }
        //additional finance links
        if ($alterconf['FAST_CASH_LINK']) {
            $fastcash = true;
        } else {
            $fastcash = false;
        }
        $tablecells = wf_TableCell(__('Login'));
        $tablecells .= wf_TableCell(__('Address'));
        $tablecells .= wf_TableCell(__('Real Name'));
        $tablecells .= wf_TableCell(__('IP'));
        $tablecells .= wf_TableCell(__('Tariff'));
        // last activity time
        if ($alterconf['ONLINE_LAT']) {
            $tablecells .= wf_TableCell(__('LAT'));
        }
        $tablecells .= wf_TableCell(__('Active'));
        //online detect
        if ($alterconf['DN_ONLINE_DETECT']) {
            $tablecells .= wf_TableCell(__('Users online'));
        }
        $tablecells .= wf_TableCell(__('Balance'));
        $tablecells .= wf_TableCell(__('Credit'));
        $tablerows = wf_TableRow($tablecells, 'row1');
        foreach ($usersarr as $eachlogin) {
            @($usercash = $allusercash[$eachlogin]);
            @($usercredit = $allusercredits[$eachlogin]);
            //finance check
            $activity = web_green_led();
            $activity_flag = 1;
            if ($usercash < '-' . $usercredit) {
                $activity = web_red_led();
                $activity_flag = 0;
            }
            //fast cash link
            if ($fastcash) {
                $financelink = wf_Link('?module=addcash&username='******'skins/icon_dollar.gif', __('Finance operations')), false, '');
            } else {
                $financelink = '';
            }
            $profilelink = $financelink . wf_Link('?module=userprofile&username='******' ' . $eachlogin);
            $tablecells = wf_TableCell($profilelink);
            $tablecells .= wf_TableCell(@$alladdress[$eachlogin]);
            $tablecells .= wf_TableCell(@$allrealnames[$eachlogin]);
            $tablecells .= wf_TableCell(@$alluserips[$eachlogin], '', '', 'sorttable_customkey="' . ip2int(@$alluserips[$eachlogin]) . '"');
            $tablecells .= wf_TableCell(@$alltariffs[$eachlogin]);
            if ($alterconf['ONLINE_LAT']) {
                if (isset($alluserlat[$eachlogin])) {
                    $cUserLat = date("Y-m-d H:i:s", $alluserlat[$eachlogin]);
                } else {
                    $cUserLat = __('No');
                }
                $tablecells .= wf_TableCell($cUserLat);
            }
            $tablecells .= wf_TableCell($activity, '', '', 'sorttable_customkey="' . $activity_flag . '"');
            if ($alterconf['DN_ONLINE_DETECT']) {
                if (file_exists(DATA_PATH . 'dn/' . $eachlogin)) {
                    $online_flag = 1;
                } else {
                    $online_flag = 0;
                }
                $tablecells .= wf_TableCell(web_bool_star($online_flag), '', '', 'sorttable_customkey="' . $online_flag . '"');
            }
            $tablecells .= wf_TableCell($usercash);
            $tablecells .= wf_TableCell($usercredit);
            $tablerows .= wf_TableRow($tablecells, 'row3');
        }
        $result = wf_TableBody($tablerows, '100%', '0', 'sortable');
        $result .= wf_tag('b') . __('Total') . ': ' . wf_tag('b', true) . sizeof($usersarr);
    } else {
        $result = __('Any users found');
    }
    return $result;
}