/** * 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 .= ' ' . 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; }
/** * Renders available and enabled alerts into DarkVoid notification area * * @return void */ protected function updateAlerts() { //new tickets alert if ($this->altCfg['TB_NEWTICKETNOTIFY']) { $newticketcount = zb_TicketsGetAllNewCount(); if ($newticketcount != 0) { $this->alerts .= wf_Link('?module=ticketing', wf_img('skins/ticketnotify.gif', $newticketcount . ' ' . __('support tickets expected processing')), false); } } //new signups notification if ($this->altCfg['SIGREQ_ENABLED']) { $signups = new SignupRequests(); $newreqcount = $signups->getAllNewCount(); if ($newreqcount != 0) { $this->alerts .= wf_Link('?module=sigreq', wf_img('skins/sigreqnotify.gif', $newreqcount . ' ' . __('signup requests expected processing')), false); } } //check for unread messages in instant messanger if ($this->altCfg['TB_UBIM']) { if (cfr('UBIM')) { $unreadMessageCount = im_CheckForUnreadMessages(); if ($unreadMessageCount) { //we have new messages $unreadIMNotify = __('You received') . ' ' . $unreadMessageCount . ' ' . __('new messages'); $urlIM = $unreadIMNotify . wf_delimiter() . wf_Link("?module=ubim&checknew=true", __('Click here to go to the instant messaging service.'), false, 'ubButton'); $this->alerts .= wf_Link("?module=ubim&checknew=true", wf_img("skins/ubim_blink.gif", $unreadMessageCount . ' ' . __('new message received')), false, ''); //$this->alerts.=wf_modalOpened(__('New messages received'), $urlIM, '450', '200'); } } } //check sms sending queue if ($this->altCfg['WATCHDOG_ENABLED']) { $smsQueueCount = rcms_scandir(DATA_PATH . 'tsms/'); $smsQueueCount = sizeof($smsQueueCount); if ($smsQueueCount > 0) { $this->alerts .= wf_Link("?module=tsmsqueue", wf_img("skins/sms.png", $smsQueueCount . ' ' . __('SMS in queue')), false, ''); } } if ($this->altCfg['TB_TASKMANNOTIFY']) { //only "for me" tasks notification if ($this->altCfg['TB_TASKMANNOTIFY'] == 1) { $undoneTasksCount = ts_GetUndoneCountersMy(); if ($undoneTasksCount > 0) { $undoneAlert = $undoneTasksCount . ' ' . __('Undone tasks') . ' ' . __('for me'); $this->alerts .= wf_Link("?module=taskman&show=undone", wf_img("skins/jobnotify.png", $undoneAlert), false, ''); } } //total undone tasks count notification if ($this->altCfg['TB_TASKMANNOTIFY'] == 2) { $undoneTasksCount = ts_GetUndoneCountersAll(); if ($undoneTasksCount > 0) { $undoneAlert = $undoneTasksCount . ' ' . __('Undone tasks') . ' ' . __('for all'); $this->alerts .= wf_Link("?module=taskman&show=undone", wf_img("skins/jobnotify.png", $undoneAlert), false, ''); } } //total+my undone tasks count notification if ($this->altCfg['TB_TASKMANNOTIFY'] == 3) { $undoneTasksCount = ts_GetUndoneCountersAll(); if ($undoneTasksCount > 0) { $undoneTasksCountMy = ts_GetUndoneCountersMy(); $undoneAlert = $undoneTasksCount . ' ' . __('Undone tasks') . ': ' . __('for all') . ' ' . ($undoneTasksCount - $undoneTasksCountMy) . ' / ' . __('for me') . ' ' . $undoneTasksCountMy; $this->alerts .= wf_Link("?module=taskman&show=undone", wf_img("skins/jobnotify.png", $undoneAlert), false, ''); } } } //switchmon at notify area if ($this->altCfg['TB_SWITCHMON']) { $dead_raw = zb_StorageGet('SWDEAD'); $last_pingtime = zb_StorageGet('SWPINGTIME'); $deathTime = zb_SwitchesGetAllDeathTime(); $deadarr = array(); $content = ''; if ($this->altCfg['SWYMAP_ENABLED']) { $content = wf_Link('?module=switchmap', wf_img('skins/swmapsmall.png', __('Switches map')), false); } $content .= wf_AjaxLoader() . wf_AjaxLink("?module=switches&forcereping=true&ajaxping=true", wf_img('skins/refresh.gif', __('Force ping')), 'switchping', true, ''); if ($dead_raw) { $deadarr = unserialize($dead_raw); if (!empty($deadarr)) { //there is some dead switches $deadcount = sizeof($deadarr); if ($this->altCfg['SWYMAP_ENABLED']) { //getting geodata $switchesGeo = zb_SwitchesGetAllGeo(); } //ajax container $content .= wf_tag('div', false, '', 'id="switchping"'); foreach ($deadarr as $ip => $switch) { if ($this->altCfg['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 $content .= $devicefind . ' ' . $switchLocator . ' ' . $deathClock . $ip . ' - ' . $switch . '<br>'; } //ajax container end $content .= wf_delimiter() . __('Cache state at time') . ': ' . date("H:i:s", $last_pingtime) . wf_tag('div', true); $this->alerts .= wf_tag('div', false, 'ubButton') . wf_modal(__('Dead switches') . ': ' . $deadcount, __('Dead switches'), $content, '', '500', '400') . wf_tag('div', true); } else { $content .= wf_tag('div', false, '', 'id="switchping"') . __('Switches are okay, everything is fine - I guarantee') . wf_delimiter() . __('Cache state at time') . ': ' . date("H:i:s", $last_pingtime) . wf_tag('div', true); $this->alerts .= wf_tag('div', false, 'ubButton') . wf_modal(__('All switches alive'), __('All switches alive'), $content, '', '500', '400') . wf_tag('div', true); } } else { $content .= wf_tag('div', false, '', 'id="switchping"') . __('Switches are okay, everything is fine - I guarantee') . wf_delimiter() . __('Cache state at time') . ': ' . @date("H:i:s", $last_pingtime) . wf_tag('div', true); $this->alerts .= wf_tag('div', false, 'ubButton') . wf_modal(__('All switches alive'), __('All switches alive'), $content, '', '500', '400') . wf_tag('div', true); } } file_put_contents(self::CACHE_PATH . self::CACHE_PREFIX . $this->myLogin, $this->alerts); }