* @param string $filename Existing sms filename * * @return int 0 - ok */ public function deleteSms($filename) { $result = $this->smsObj->deleteSms($filename); return $result; } } $tsmsQueue = new TSMSQueue(); if (wf_CheckGet(array('deletesms'))) { $deletionResult = $tsmsQueue->deleteSms($_GET['deletesms']); if ($deletionResult == 0) { $darkVoid = new DarkVoid(); $darkVoid->flushCache(); rcms_redirect('?module=tsmsqueue'); } else { if ($deletionResult == 2) { show_error(__('Not existing item')); } if ($deletionResult == 1) { show_error(__('Permission denied')); } } } show_window(__('SMS in queue'), $tsmsQueue->render()); } else { show_error(__('Access denied')); } } else {
/** * Creates new task in database * * @param string $startdate * @param string $starttime * @param string $address * @param string $login * @param string $phone * @param int $jobtypeid * @param int $employeeid * @param string $jobnote * * @return void */ function ts_CreateTask($startdate, $starttime, $address, $login, $phone, $jobtypeid, $employeeid, $jobnote) { $altercfg = rcms_parse_ini_file(CONFIG_PATH . "alter.ini"); $curdate = curdatetime(); $admin = whoami(); $address = str_replace('\'', '`', $address); $address = mysql_real_escape_string($address); $login = mysql_real_escape_string($login); $phone = mysql_real_escape_string($phone); $startdate = mysql_real_escape_string($startdate); $jobSendTime = !empty($starttime) ? ' ' . date("H:i", strtotime($starttime)) : ''; if (!empty($starttime)) { $starttime = "'" . mysql_real_escape_string($starttime) . "'"; } else { $starttime = 'NULL'; } $jobtypeid = vf($jobtypeid, 3); $employeeid = vf($employeeid, 3); $jobnote = mysql_real_escape_string($jobnote); $smsData = 'NULL'; //store sms for backround processing via watchdog if ($altercfg['WATCHDOG_ENABLED']) { if (isset($_POST['newtasksendsms'])) { $newSmsText = $address . ' ' . $phone . ' ' . $jobnote . $jobSendTime; $smsDataRaw = ts_SendSMS($employeeid, $newSmsText); if (!empty($smsDataRaw)) { $smsData = serialize($smsDataRaw); $smsData = "'" . base64_encode($smsData) . "'"; } } } $query = "INSERT INTO `taskman` (`id` , `date` , `address` , `login` , `jobtype` , `jobnote` , `phone` , `employee` , `employeedone` ,`donenote` , `startdate` ,`starttime`, `enddate` , `admin` , `status`,`smsdata`)\n VALUES (NULL , '" . $curdate . "', '" . $address . "', '" . $login . "', '" . $jobtypeid . "', '" . $jobnote . "', '" . $phone . "', '" . $employeeid . "',NULL, NULL , '" . $startdate . "'," . $starttime . ",NULL , '" . $admin . "', '0'," . $smsData . ");"; nr_query($query); //flushing darkvoid $darkVoid = new DarkVoid(); $darkVoid->flushCache(); log_register("TASKMAN CREATE `" . $address . "`"); }
/** * 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; }