예제 #1
0
 function zb_AskoziaGetConf()
 {
     $result = array();
     $emptyArray = array();
     //getting url
     $url = zb_StorageGet('ASKOZIAPBX_URL');
     if (empty($url)) {
         $url = 'http://sip.isp/';
         zb_StorageSet('ASKOZIAPBX_URL', $url);
     }
     //getting login
     $login = zb_StorageGet('ASKOZIAPBX_LOGIN');
     if (empty($login)) {
         $login = '******';
         zb_StorageSet('ASKOZIAPBX_LOGIN', $login);
     }
     //getting password
     $password = zb_StorageGet('ASKOZIAPBX_PASSWORD');
     if (empty($password)) {
         $password = '******';
         zb_StorageSet('ASKOZIAPBX_PASSWORD', $password);
     }
     //getting caching time
     $cache = zb_StorageGet('ASKOZIAPBX_CACHETIME');
     if (empty($cache)) {
         $cache = '1';
         zb_StorageSet('ASKOZIAPBX_CACHETIME', $cache);
     }
     $result['url'] = $url;
     $result['login'] = $login;
     $result['password'] = $password;
     $result['cachetime'] = $cache;
     return $result;
 }
예제 #2
0
 function zb_PhpConsoleCreateTemplate($name, $body)
 {
     $key = 'PHPCONSOLETEMPLATE:' . zb_rand_string(16);
     $newtemplatedata = array();
     $newtemplatedata['name'] = $name;
     $newtemplatedata['body'] = $body;
     $value = serialize($newtemplatedata);
     zb_StorageSet($key, $value);
 }
예제 #3
0
 function zb_PaySysPercentDelete($mark)
 {
     $mark = mysql_real_escape_string($mark);
     $olddata = zb_PaySysPercentGetAll();
     $newdata = $olddata;
     if (isset($newdata[$mark])) {
         unset($newdata[$mark]);
         $newdata = serialize($newdata);
         $newdata = base64_encode($newdata);
         zb_StorageSet('PAYSYSPC', $newdata);
         log_register("PAYSYSPC DELETE `" . $mark . "`");
     }
 }
예제 #4
0
 function zb_SetHelpdeskUnDenied($login)
 {
     $access = zb_GetHelpdeskDeniedAll();
     if (!empty($login)) {
         if (isset($access[$login])) {
             unset($access[$login]);
             $newarray = serialize($access);
             $newarray = base64_encode($newarray);
             zb_StorageSet('ZBS_HELP_DENIED', $newarray);
             log_register("ZBSMAN SET ALLOWED (" . $login . ")");
         }
     }
 }
예제 #5
0
 function zb_AsteriskGetConf()
 {
     $result = array();
     $emptyArray = array();
     //getting url
     $host = zb_StorageGet('ASTERISK_HOST');
     if (empty($host)) {
         $host = 'localhost';
         zb_StorageSet('ASTERISK_HOST', $host);
     }
     //getting login
     $login = zb_StorageGet('ASTERISK_LOGIN');
     if (empty($login)) {
         $login = '******';
         zb_StorageSet('ASTERISK_LOGIN', $login);
     }
     //getting DB name
     $db = zb_StorageGet('ASTERISK_DB');
     if (empty($db)) {
         $db = 'asteriskdb';
         zb_StorageSet('ASTERISK_DB', $db);
     }
     //getting CDR table name
     $table = zb_StorageGet('ASTERISK_TABLE');
     if (empty($table)) {
         $table = 'cdr';
         zb_StorageSet('ASTERISK_TABLE', $table);
     }
     //getting password
     $password = zb_StorageGet('ASTERISK_PASSWORD');
     if (empty($password)) {
         $password = '******';
         zb_StorageSet('ASTERISK_PASSWORD', $password);
     }
     //getting caching time
     $cache = zb_StorageGet('ASTERISK_CACHETIME');
     if (empty($cache)) {
         $cache = '1';
         zb_StorageSet('ASTERISK_CACHETIME', $cache);
     }
     $result['host'] = $host;
     $result['db'] = $db;
     $result['table'] = $table;
     $result['login'] = $login;
     $result['password'] = $password;
     $result['cachetime'] = $cache;
     return $result;
 }
예제 #6
0
 function tsms_SetTz($tz)
 {
     zb_StorageSet('TSMS_TZ', $tz);
     log_register("TSMS TIMEZONE CHANGE");
 }
예제 #7
0
 /**
  * saves tariff lines config to database
  * 
  * @param string $newlines    new lines, comma separated
  * 
  * @return void
  */
 public function saveConfig($newlines)
 {
     zb_StorageSet('ARPU_LINES', $newlines);
     log_register('ARPUREPORT CHANGE CONFIG');
 }
예제 #8
0
 function docsis_ModemSnmpWalkSet($path)
 {
     zb_StorageSet('DOCSIS_SNMPWALK_PATH', $path);
     log_register("DOCSIS SNMPWALK SET `" . $path . "`");
 }
예제 #9
0
            $editform .= wf_Link('?module=cashtypes', 'Back', true, 'ubButton');
            show_window(__('Edit') . ' ' . __('Cash type'), $editform);
        }
    }
    //creating new cash type
    if (isset($_POST['newcashtype'])) {
        $newcashtype = mysql_real_escape_string($_POST['newcashtype']);
        if (!empty($newcashtype)) {
            zb_CashCreateCashType($newcashtype);
            rcms_redirect("?module=cashtypes");
        } else {
            show_error(__('No all of required fields is filled'));
        }
    }
    //setting default cashtype
    if (wf_CheckPost(array('setdefaultcashtype'))) {
        zb_StorageSet('DEF_CT', $_POST['setdefaultcashtype']);
        log_register("CASHTYPE SET DEFAULT [" . $_POST['setdefaultcashtype'] . "]");
        rcms_redirect("?module=cashtypes");
    }
    // Edit form construct
    $fieldname = __('Cash type');
    $fieldkey = 'cashtype';
    $formurl = '?module=cashtypes';
    $olddata = zb_CashGetAlltypes();
    $form = web_EditorTableDataFormOneField($fieldname, $fieldkey, $formurl, $olddata);
    show_window(__('Edit payment types'), $form);
    show_window(__('Default cash type'), web_CashCashtypeDefaultForm());
} else {
    show_error(__('You cant control this module'));
}
예제 #10
0
/**
 * Returns task typical problems editing form
 * 
 * @return string
 */
function ts_TaskProblemsEditForm()
{
    $rawNotes = zb_StorageGet('PROBLEMS');
    //extract old or create new typical problems array
    if (!empty($rawNotes)) {
        $rawNotes = base64_decode($rawNotes);
        $rawNotes = unserialize($rawNotes);
    } else {
        $emptyArray = array();
        $newNotes = serialize($emptyArray);
        $newNotes = base64_encode($newNotes);
        zb_StorageSet('PROBLEMS', $newNotes);
        $rawNotes = $emptyArray;
    }
    //adding and deletion subroutines
    if (wf_CheckPost(array('createtypicalnote'))) {
        $toPush = strip_tags($_POST['createtypicalnote']);
        array_push($rawNotes, $toPush);
        $newNotes = serialize($rawNotes);
        $newNotes = base64_encode($newNotes);
        zb_StorageSet('PROBLEMS', $newNotes);
        log_register('TASKMAN ADD TYPICALPROBLEM');
        rcms_redirect("?module=taskman&probsettings=true");
    }
    if (wf_CheckPost(array('deletetypicalnote', 'typicalnote'))) {
        $toUnset = $_POST['typicalnote'];
        if (($delkey = array_search($toUnset, $rawNotes)) !== false) {
            unset($rawNotes[$delkey]);
        }
        $newNotes = serialize($rawNotes);
        $newNotes = base64_encode($newNotes);
        zb_StorageSet('PROBLEMS', $newNotes);
        log_register('TASKMAN DELETE TYPICALPROBLEM');
        rcms_redirect("?module=taskman&probsettings=true");
    }
    $rows = '';
    $result = wf_Link("?module=taskman", __('Back'), true, 'ubButton');
    if (!empty($rawNotes)) {
        foreach ($rawNotes as $eachNote) {
            $cells = wf_TableCell($eachNote);
            $rows .= wf_TableRow($cells, 'row3');
        }
    }
    $result .= wf_TableBody($rows, '100%', '0', '');
    $result .= wf_delimiter();
    $addinputs = wf_TextInput('createtypicalnote', __('Create'), '', true, '20');
    $addinputs .= wf_Submit(__('Save'));
    $addform = wf_Form("", "POST", $addinputs, 'glamour');
    $result .= $addform;
    $delinputs = ts_TaskTypicalNotesSelector(false);
    $delinputs .= wf_HiddenInput('deletetypicalnote', 'true');
    $delinputs .= wf_Submit(__('Delete'));
    $delform = wf_Form("", "POST", $delinputs, 'glamour');
    $result .= $delform;
    return $result;
}
예제 #11
0
 /**
  * Saves config in database
  * 
  * @return void
  */
 public function saveConfig()
 {
     //TurboSMS configuration
     if ($_POST['edittsmsgateway'] != $this->settings['TSMS_GATEWAY']) {
         zb_StorageSet('SENDDOG_TSMS_GATEWAY', $_POST['edittsmsgateway']);
         log_register('SENDDOG CONFIG SET TSMSGATEWAY `' . $_POST['edittsmsgateway'] . '`');
     }
     if ($_POST['edittsmslogin'] != $this->settings['TSMS_LOGIN']) {
         zb_StorageSet('SENDDOG_TSMS_LOGIN', $_POST['edittsmslogin']);
         log_register('SENDDOG CONFIG SET TSMSLOGIN `' . $_POST['edittsmslogin'] . '`');
     }
     if ($_POST['edittsmspassword'] != $this->settings['TSMS_PASSWORD']) {
         zb_StorageSet('SENDDOG_TSMS_PASSWORD', $_POST['edittsmspassword']);
         log_register('SENDDOG CONFIG SET TSMSPASSWORD `' . $_POST['edittsmspassword'] . '`');
     }
     if ($_POST['edittsmssign'] != $this->settings['TSMS_SIGN']) {
         zb_StorageSet('SENDDOG_TSMS_SIGN', $_POST['edittsmssign']);
         log_register('SENDDOG CONFIG SET TSMSSIGN `' . $_POST['edittsmssign'] . '`');
     }
     //SMS-Fly configuration
     if ($_POST['editsmsflygateway'] != $this->settings['SMSFLY_GATEWAY']) {
         zb_StorageSet('SENDDOG_SMSFLY_GATEWAY', $_POST['editsmsflygateway']);
         log_register('SENDDOG CONFIG SET SMSFLYGATEWAY `' . $_POST['editsmsflygateway'] . '`');
     }
     if ($_POST['editsmsflylogin'] != $this->settings['SMSFLY_LOGIN']) {
         zb_StorageSet('SENDDOG_SMSFLY_LOGIN', $_POST['editsmsflylogin']);
         log_register('SENDDOG CONFIG SET SMSFLYLOGIN `' . $_POST['editsmsflylogin'] . '`');
     }
     if ($_POST['editsmsflypassword'] != $this->settings['SMSFLY_PASSWORD']) {
         zb_StorageSet('SENDDOG_SMSFLY_PASSWORD', $_POST['editsmsflypassword']);
         log_register('SENDDOG CONFIG SET SMSFLYPASSWORD `' . $_POST['editsmsflypassword'] . '`');
     }
     if ($_POST['editsmsflysign'] != $this->settings['SMSFLY_SIGN']) {
         zb_StorageSet('SENDDOG_SMSFLY_SIGN', $_POST['editsmsflysign']);
         log_register('SENDDOG CONFIG SET SMSFLYSIGN `' . $_POST['editsmsflysign'] . '`');
     }
     //telegram bot token configuration
     if ($_POST['edittelegrambottoken'] != $this->settings['TELEGRAM_BOTTOKEN']) {
         zb_StorageSet('SENDDOG_TELEGRAM_BOTTOKEN', $_POST['edittelegrambottoken']);
         log_register('SENDDOG CONFIG SET TELEGRAMBOTTOKEN');
     }
     //default sms service
     if ($_POST['defaultsmsservice'] != $this->settings['SMS_SERVICE']) {
         zb_StorageSet('SENDDOG_SMS_SERVICE', $_POST['defaultsmsservice']);
         log_register('SENDDOG CONFIG SET SMSSERVICE `' . $_POST['defaultsmsservice'] . '`');
     }
 }
예제 #12
0
 /**
  * save the current settings of watchdog as it posted in settingsForm
  * 
  * @return void
  */
 public function saveSettings()
 {
     if (wf_CheckPost(array('changealert'))) {
         zb_StorageSet('WATCHDOG_ALERT', $_POST['changealert']);
         zb_StorageSet('WATCHDOG_PHONES', $_POST['changephones']);
         zb_StorageSet('WATCHDOG_EMAILS', $_POST['changeemails']);
         zb_StorageSet('WATCHDOG_TELEGRAM', $_POST['changetelegram']);
         log_register("WATCHDOG SETTINGS CHANGED");
     }
 }
예제 #13
0
/**
 * Shows payments year graph with caching
 * 
 * @param int $year
 */
function web_PaymentsShowGraph($year)
{
    $months = months_array();
    $year_summ = zb_PaymentsGetYearSumm($year);
    $curtime = time();
    $yearPayData = array();
    $yearStats = array();
    $cacheTime = 3600;
    //sec intervall to cache
    $cells = wf_TableCell('');
    $cells .= wf_TableCell(__('Month'));
    $cells .= wf_TableCell(__('Payments count'));
    $cells .= wf_TableCell(__('ARPU'));
    $cells .= wf_TableCell(__('Cash'));
    $cells .= wf_TableCell(__('Visual'), '50%');
    $rows = wf_TableRow($cells, 'row1');
    //caching subroutine
    $renewTime = zb_StorageGet('YPD_LAST');
    if (empty($renewTime)) {
        //first usage
        $renewTime = $curtime;
        zb_StorageSet('YPD_LAST', $renewTime);
        $updateCache = true;
    } else {
        //cache time already set
        $timeShift = $curtime - $renewTime;
        if ($timeShift > $cacheTime) {
            //cache update needed
            $updateCache = true;
        } else {
            //load data from cache or init new cache
            $yearPayData_raw = zb_StorageGet('YPD_CACHE');
            if (empty($yearPayData_raw)) {
                //first usage
                $emptyCache = array();
                $emptyCache = serialize($emptyCache);
                $emptyCache = base64_encode($emptyCache);
                zb_StorageSet('YPD_CACHE', $emptyCache);
                $updateCache = true;
            } else {
                // data loaded from cache
                $yearPayData = base64_decode($yearPayData_raw);
                $yearPayData = unserialize($yearPayData);
                $updateCache = false;
                //check is current year already cached?
                if (!isset($yearPayData[$year]['graphs'])) {
                    $updateCache = true;
                }
                //check is manual cache refresh is needed?
                if (wf_CheckGet(array('forcecache'))) {
                    $updateCache = true;
                    rcms_redirect("?module=report_finance");
                }
            }
        }
    }
    if ($updateCache) {
        //extracting all of needed payments in one query
        $allYearPayments_q = "SELECT * from `payments` WHERE `date` LIKE '" . $year . "-%' AND `summ`>'0';";
        $allYearPayments = simple_queryall($allYearPayments_q);
        if (!empty($allYearPayments)) {
            foreach ($allYearPayments as $idx => $eachYearPayment) {
                //Here we can get up to 50% of CPU time on month extraction, but this hacks is to ugly :(
                //Benchmark results: http://pastebin.com/i7kadpN7
                $statsMonth = date("m", strtotime($eachYearPayment['date']));
                if (isset($yearStats[$statsMonth])) {
                    $yearStats[$statsMonth]['count']++;
                    $yearStats[$statsMonth]['summ'] = $yearStats[$statsMonth]['summ'] + $eachYearPayment['summ'];
                } else {
                    $yearStats[$statsMonth]['count'] = 1;
                    $yearStats[$statsMonth]['summ'] = $eachYearPayment['summ'];
                }
            }
        }
        foreach ($months as $eachmonth => $monthname) {
            $month_summ = isset($yearStats[$eachmonth]) ? $yearStats[$eachmonth]['summ'] : 0;
            $paycount = isset($yearStats[$eachmonth]) ? $yearStats[$eachmonth]['count'] : 0;
            $cells = wf_TableCell($eachmonth);
            $cells .= wf_TableCell(wf_Link('?module=report_finance&month=' . $year . '-' . $eachmonth, rcms_date_localise($monthname)));
            $cells .= wf_TableCell($paycount);
            $cells .= wf_TableCell(@round($month_summ / $paycount, 2));
            $cells .= wf_TableCell(web_roundValue($month_summ, 2));
            $cells .= wf_TableCell(web_bar($month_summ, $year_summ));
            $rows .= wf_TableRow($cells, 'row3');
        }
        $result = wf_TableBody($rows, '100%', '0', 'sortable');
        $yearPayData[$year]['graphs'] = $result;
        //write to cache
        zb_StorageSet('YPD_LAST', $curtime);
        $newCache = serialize($yearPayData);
        $newCache = base64_encode($newCache);
        zb_StorageSet('YPD_CACHE', $newCache);
    } else {
        //take data from cache
        if (isset($yearPayData[$year]['graphs'])) {
            $result = $yearPayData[$year]['graphs'];
            $result .= __('Cache state at time') . ': ' . date("Y-m-d H:i:s", $renewTime) . ' ';
            $result .= wf_Link("?module=report_finance&forcecache=true", wf_img('skins/icon_cleanup.png', __('Renew')), false, '');
        } else {
            $result = __('Strange exeption');
        }
    }
    show_window(__('Payments by') . ' ' . $year, $result);
}
예제 #14
0
                         show_error(__('No') . ' ' . __('SNMP template'));
                     }
                 }
             }
         }
     }
 } else {
     //display all of available fdb tables
     $fdbData_raw = rcms_scandir('./exports/', '*_fdb');
     if (!empty($fdbData_raw)) {
         //// mac filters setup
         if (wf_CheckPost(array('setmacfilters'))) {
             //setting new MAC filters
             if (!empty($_POST['newmacfilters'])) {
                 $newFilters = base64_encode($_POST['newmacfilters']);
                 zb_StorageSet('FDBCACHEMACFILTERS', $newFilters);
             }
             //deleting old filters
             if (isset($_POST['deletemacfilters'])) {
                 zb_StorageDelete('FDBCACHEMACFILTERS');
             }
         }
         //log download
         if (wf_CheckGet(array('dlswpolllog'))) {
             zb_FDBTableLogDownload();
         }
         //push ajax data
         if (wf_CheckGet(array('ajax'))) {
             if (wf_CheckGet(array('swfilter'))) {
                 $fdbData_raw = array($_GET['swfilter'] . '_fdb');
             }
예제 #15
0
 public function saveSettings()
 {
     if (wf_CheckPost(array('changealert'))) {
         zb_StorageSet('WATCHDOG_ALERT', $_POST['changealert']);
         zb_StorageSet('WATCHDOG_PHONES', $_POST['changephones']);
         zb_StorageSet('WATCHDOG_EMAILS', $_POST['changeemails']);
         zb_StorageSet('WATCHDOG_TSMS_GATEWAY', $_POST['changetsmsgateway']);
         zb_StorageSet('WATCHDOG_TSMS_LOGIN', $_POST['changetsmslogin']);
         zb_StorageSet('WATCHDOG_TSMS_PASSWORD', $_POST['changetsmspassword']);
         zb_StorageSet('WATCHDOG_TSMS_SIGN', $_POST['changetsmssign']);
         log_register("WATCHDOG SETTINGS CHANGED");
     }
 }
예제 #16
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;
}
예제 #17
0
 function web_MigrationPrepare($import_rawdata, $import_opts)
 {
     $import_rawdata = unserialize(base64_decode($import_rawdata));
     $import_opts = unserialize(base64_decode($import_opts));
     $cells = wf_TableCell('#');
     $cells .= wf_TableCell('[login]');
     $cells .= wf_TableCell('[password]');
     $cells .= wf_TableCell('[ip]');
     $cells .= wf_TableCell('[mac]');
     $cells .= wf_TableCell('[tariff]');
     $cells .= wf_TableCell('[cash]');
     $cells .= wf_TableCell('[phone]');
     $cells .= wf_TableCell('[mobile]');
     $cells .= wf_TableCell('[email]');
     $cells .= wf_TableCell('[credit]');
     $cells .= wf_TableCell('[creditex]');
     $cells .= wf_TableCell('[address]');
     $cells .= wf_TableCell('[realname]');
     $cells .= wf_TableCell('[contract]');
     $cells .= wf_TableCell('[ao]');
     $cells .= wf_TableCell('[down]');
     $cells .= wf_TableCell('[passive]');
     $rows = wf_TableRow($cells, 'row1');
     $regdata = array();
     $i = 0;
     foreach ($import_rawdata as $eachrow) {
         $i++;
         $cells = wf_TableCell($i);
         if ($import_opts['login_col'] != 'RANDOM') {
             $login = $eachrow[$import_opts['login_col']];
         } else {
             $login = '******' . zb_rand_string(8);
         }
         $cells .= wf_TableCell($login);
         if ($import_opts['password_col'] != 'RANDOM') {
             $password = $eachrow[$import_opts['password_col']];
         } else {
             $password = zb_rand_string(10);
         }
         $cells .= wf_TableCell($password);
         $ip = $eachrow[$import_opts['ip_col']];
         $cells .= wf_TableCell($ip);
         if ($import_opts['mac_col'] != 'RANDOM') {
             $mac = $eachrow[$import_opts['mac_col']];
         } else {
             $mac = '14:' . '88' . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99) . ':' . rand(10, 99);
         }
         $cells .= wf_TableCell($mac);
         $tariff = $eachrow[$import_opts['tariff_col']];
         $cells .= wf_TableCell($tariff);
         $cash = $eachrow[$import_opts['cash_col']];
         $cells .= wf_TableCell($cash);
         if ($import_opts['phone_col'] != 'NONE') {
             $phone = $eachrow[$import_opts['phone_col']];
         } else {
             $phone = '';
         }
         $cells .= wf_TableCell($phone);
         if ($import_opts['mobile_col'] != 'NONE') {
             $mobile = $eachrow[$import_opts['mobile_col']];
         } else {
             $mobile = '';
         }
         $cells .= wf_TableCell($mobile);
         if ($import_opts['email_col'] != 'NONE') {
             $email = $eachrow[$import_opts['email_col']];
         } else {
             $email = '';
         }
         $cells .= wf_TableCell($email);
         if ($import_opts['credit_col'] != 'ZERO') {
             $credit = $eachrow[$import_opts['credit_col']];
         } else {
             $credit = 0;
         }
         $cells .= wf_TableCell($credit);
         if ($import_opts['creditex_col'] != 'NONE') {
             $creditex = $eachrow[$import_opts['creditex_col']];
         } else {
             $creditex = '0';
         }
         $cells .= wf_TableCell($creditex);
         if ($import_opts['address_col'] != 'NONE') {
             $address = $eachrow[$import_opts['address_col']];
         } else {
             $address = '';
         }
         $cells .= wf_TableCell($address);
         if ($import_opts['realname_col'] != 'NONE') {
             $realname = $eachrow[$import_opts['realname_col']];
         } else {
             $realname = '';
         }
         $cells .= wf_TableCell($realname);
         if ($import_opts['contract_col'] != 'NONE') {
             $contract = $eachrow[$import_opts['contract_col']];
         } else {
             $contract = '';
         }
         $cells .= wf_TableCell($contract);
         if ($import_opts['ao_col'] != 'AO_1') {
             $ao = $eachrow[$import_opts['ao_col']];
         } else {
             $ao = 1;
         }
         $cells .= wf_TableCell($ao);
         if ($import_opts['down_col'] != 'DOWN_0') {
             $down = $eachrow[$import_opts['down_col']];
         } else {
             $down = 0;
         }
         $cells .= wf_TableCell($down);
         if ($import_opts['passive_col'] != 'PASSIVE_0') {
             $passive = $eachrow[$import_opts['passive_col']];
         } else {
             $passive = 0;
         }
         $cells .= wf_TableCell($passive);
         $rows .= wf_TableRow($cells, 'row3');
         // filling userreg array
         $regdata[$login]['login'] = $login;
         $regdata[$login]['password'] = $password;
         $regdata[$login]['ip'] = $ip;
         $regdata[$login]['mac'] = $mac;
         $regdata[$login]['tariff'] = $tariff;
         $regdata[$login]['cash'] = $cash;
         $regdata[$login]['phone'] = $phone;
         $regdata[$login]['mobile'] = $mobile;
         $regdata[$login]['email'] = $email;
         $regdata[$login]['credit'] = $credit;
         $regdata[$login]['creditex'] = $creditex;
         $regdata[$login]['address'] = $address;
         $regdata[$login]['realname'] = $realname;
         $regdata[$login]['contract'] = $contract;
         $regdata[$login]['ao'] = $ao;
         $regdata[$login]['down'] = $down;
         $regdata[$login]['passive'] = $passive;
     }
     $regdata_save = serialize($regdata);
     $regdata_save = base64_encode($regdata_save);
     zb_StorageSet('IMPORT_REGDATA', $regdata_save);
     $preparse = wf_TableBody($rows, '100%', '0', '');
     show_window(__('All correct') . '?', $preparse);
     $inputs = wf_Link('?module=migration', 'No I want to try another import settings', false, 'ubButton');
     $inputs .= wf_Link('?module=migration&setpointers=true&goregister=ok', 'Yes proceed registeration of this users', false, 'ubButton');
     show_window('', $inputs);
 }
예제 #18
0
<?php

//frontend for cron task
if (isset($_GET['cronping'])) {
    $hostid_q = "SELECT * from `ubstats` WHERE `key`='ubid'";
    $hostid = simple_query($hostid_q);
    if (!empty($hostid)) {
        $ubserial = $hostid['value'];
        //check for ubserial validity
        if ($_GET['cronping'] == $ubserial) {
            $currenttime = time();
            $deadSwitches = zb_SwitchesRepingAll();
            zb_StorageSet('SWPINGTIME', $currenttime);
            //store dead switches log data
            if (!empty($deadSwitches)) {
                zb_SwitchesDeadLog($currenttime, $deadSwitches);
            }
            die('SWITCH REPING DONE ' . date("Y-m-d H:i:s"));
        } else {
            die('WRONG SERIAL');
        }
    }
}
if (cfr('SWITCHES')) {
    $altCfg = $ubillingConfig->getAlter();
    //icmp ping handling
    if (wf_CheckGet(array('backgroundicmpping'))) {
        $billingConf = $ubillingConfig->getBilling();
        $command = $billingConf['SUDO'] . ' ' . $billingConf['PING'] . ' -i 0.01 -c 10  ' . $_GET['backgroundicmpping'];
        $icmpPingResult = shell_exec($command);
        die(wf_tag('pre') . $icmpPingResult . wf_tag('pre', true));
예제 #19
0
/**
 * Changes existing typical answer preset data in database
 * 
 * @param string $key
 * @param string $text
 * 
 * @return void
 */
function zb_TicketsTAPEdit($key, $text)
{
    $storeData = base64_encode($text);
    zb_StorageSet($key, $storeData);
    log_register('TICKET TAP CHANGE `' . $key . '`');
}
예제 #20
0
 /**
  * shows payments graph for some year
  * 
  * @param string $year year to show
  * 
  * @return void
  */
 protected function paymentsShowGraph($year)
 {
     $months = months_array();
     $year_summ = $this->paymentsGetYearSumm($year);
     $curtime = time();
     $yearPayData = array();
     $cells = wf_TableCell('');
     $cells .= wf_TableCell(__('Month'));
     $cells .= wf_TableCell(__('Payments count'));
     $cells .= wf_TableCell(__('ARPU'));
     $cells .= wf_TableCell(__('Cash'));
     $cells .= wf_TableCell(__('Visual'), '50%');
     $rows = wf_TableRow($cells, 'row1');
     //caching subroutine
     $renewTime = zb_StorageGet('UKVYPD_LAST');
     if (empty($renewTime)) {
         //first usage
         $renewTime = $curtime;
         zb_StorageSet('UKVYPD_LAST', $renewTime);
         $updateCache = true;
     } else {
         //cache time already set
         $timeShift = $curtime - $renewTime;
         if ($timeShift > 3600) {
             //cache update needed
             $updateCache = true;
         } else {
             //load data from cache or init new cache
             $yearPayData_raw = zb_StorageGet('UKVYPD_CACHE');
             if (empty($yearPayData_raw)) {
                 //first usage
                 $emptyCache = array();
                 $emptyCache = serialize($emptyCache);
                 $emptyCache = base64_encode($emptyCache);
                 zb_StorageSet('UKVYPD_CACHE', $emptyCache);
                 $updateCache = true;
             } else {
                 // data loaded from cache
                 $yearPayData = base64_decode($yearPayData_raw);
                 $yearPayData = unserialize($yearPayData);
                 $updateCache = false;
                 //check is current year already cached?
                 if (!isset($yearPayData[$year]['graphs'])) {
                     $updateCache = true;
                 }
                 //check is manual cache refresh is needed?
                 if (wf_CheckGet(array('forcecache'))) {
                     $updateCache = true;
                     rcms_redirect(self::URL_REPORTS_MGMT . 'reportFinance');
                 }
             }
         }
     }
     if ($updateCache) {
         foreach ($months as $eachmonth => $monthname) {
             $month_summ = $this->paymentsGetMonthSumm($year, $eachmonth);
             $paycount = $this->paymentsGetMonthCount($year, $eachmonth);
             $cells = wf_TableCell($eachmonth);
             $cells .= wf_TableCell(wf_Link(self::URL_REPORTS_MGMT . 'reportFinance&month=' . $year . '-' . $eachmonth, rcms_date_localise($monthname)));
             $cells .= wf_TableCell($paycount);
             $cells .= wf_TableCell(@round($month_summ / $paycount, 2));
             $cells .= wf_TableCell(web_roundValue($month_summ, 2));
             $cells .= wf_TableCell(web_bar($month_summ, $year_summ));
             $rows .= wf_TableRow($cells, 'row3');
         }
         $result = wf_TableBody($rows, '100%', '0', 'sortable');
         $yearPayData[$year]['graphs'] = $result;
         //write to cache
         zb_StorageSet('UKVYPD_LAST', $curtime);
         $newCache = serialize($yearPayData);
         $newCache = base64_encode($newCache);
         zb_StorageSet('UKVYPD_CACHE', $newCache);
     } else {
         //take data from cache
         if (isset($yearPayData[$year]['graphs'])) {
             $result = $yearPayData[$year]['graphs'];
             $result .= __('Cache state at time') . ': ' . date("Y-m-d H:i:s", $renewTime) . ' ';
             $result .= wf_Link(self::URL_REPORTS_MGMT . 'reportFinance&forcecache=true', wf_img('skins/icon_cleanup.png', __('Renew')), false, '');
         } else {
             $result = __('Strange exeption');
         }
     }
     show_window(__('Payments by') . ' ' . $year, $result);
 }
예제 #21
0
 public function run()
 {
     // Проверить, обновилась ли выгрузка из реестра. Для этого вызвать метод
     // getLastDumpDateEx и сравнить полученное значение со значением, полученным на
     // предыдущей итерации. В случае если значение lastDumpDateUrgently изменилось, то
     // незамедлительно запросить обновленную выгрузку. В остальных случаях обновлять
     // выгрузку на усмотрение, но не реже одного раза в сутки.
     // P.S. Для Ubilling`а "своё усмотрение" - это обновить немедленно!
     $lastSync = zb_StorageGet(self::STORAGE_LASTSYNC_KEY);
     try {
         if (($this->_isUrgent = $lastSync < $this->getLastDumpDateEx('lastDumpDateUrgently')) || $lastSync < $this->getLastDumpDateEx('lastDumpDate')) {
             // В случае, если выгрузка обновилась, направить запрос на получение выгрузки с
             // использованием метода sendRequest и получить в ответ код запроса
             if ($this->sendRequest('result') == true) {
                 // Через несколько минут для получения результата обработки запроса вызвать метод
                 // getResult с кодом, полученным на этапе 2. Данный метод необходимо опрашивать с
                 // определенным интервалом (1-2 минуты) до тех пор, пока значение resultCode равно нулю.
                 // При получении ненулевого значения запрос результата по данному коду необходимо
                 // прекратить, так как будет либо получена выгрузка, либо код ошибки.
                 // P.S. Ubilling не ждёт, после отправки запроса он сразу пытается получить ответ...
                 if ($this->getResult('result') == true) {
                     // Записываем полученный от Роскомнадзора zip-архив во временный
                     // файл
                     $tmp = tempnam(sys_get_temp_dir(), 'rbs_');
                     file_put_contents($tmp, $this->getResult('registerZipArchive'));
                     try {
                         $zip = new ZipArchive();
                         $resource = $zip->open($tmp);
                         if ($resource === true) {
                             // Чистим БД от старых записей
                             nr_query("TRUNCATE `rbs_banned`");
                             nr_query("TRUNCATE `rbs_banned_ips`");
                             nr_query("TRUNCATE `rbs_banned_urls`");
                             nr_query("TRUNCATE `rbs_banned_domains`");
                             nr_query("TRUNCATE `rbs_banned_ipSubnets`");
                             nr_query("TRUNCATE `rbs_banned_decisions`");
                             // Инициируем DomDocument, открываем извлечённый xml-документ
                             // и вносим данные из xml-документа в базу данных
                             $dom = new DOMDocument();
                             $dom->loadXML($zip->getFromName('dump.xml'));
                             foreach ($dom->documentElement->getElementsByTagName('content') as $content) {
                                 // Добавляем данные о записях, подлежащих блокировке:
                                 //  * Уникальный идентификатор записи в Роскомнадзоре;
                                 //  * Момент времени, с которого возникает необходимость
                                 //    ограничения доступа;
                                 //  * Тип срочности реагирования;
                                 //  * Код типа реестра;
                                 nr_query("INSERT INTO `rbs_banned` VALUES(\r\n                    '" . $content->getAttribute('id') . "',\r\n                    '" . $content->getAttribute('includeTime') . "',\r\n                    '" . $content->getAttribute('urgencyType') . "',\r\n                    '" . $content->getAttribute('entryType') . "'\r\n                  )");
                                 // Вносим реквизиты решения о необходимости ограничения доступа
                                 //  * Дата решения;
                                 //  * Номер решения;
                                 //  * Орган, принявший решение;
                                 foreach ($content->getElementsByTagName('decision') as $decision) {
                                     nr_query("INSERT INTO `rbs_banned_decisions` VALUES(\r\n                      NULL,\r\n                      '" . $content->getAttribute('id') . "',\r\n                      '" . $decision->getAttribute('date') . "',\r\n                      '" . $decision->getAttribute('number') . "',\r\n                      '" . $decision->getAttribute('org') . "'\r\n                    )");
                                 }
                                 // Добавляем указатели страниц сайтов
                                 foreach ($content->getElementsByTagName('url') as $url) {
                                     nr_query("INSERT INTO `rbs_banned_urls` VALUES(NULL, '" . $content->getAttribute('id') . "', '" . $url->nodeValue . "')");
                                 }
                                 // Добавляем доменные имена
                                 foreach ($content->getElementsByTagName('domain') as $domain) {
                                     nr_query("INSERT INTO `rbs_banned_domains` VALUES(NULL, '" . $content->getAttribute('id') . "', '" . $domain->nodeValue . "')");
                                 }
                                 // Добавляем IP-адреса
                                 foreach ($content->getElementsByTagName('ip') as $ip) {
                                     nr_query("INSERT INTO `rbs_banned_ips` VALUES(NULL, '" . $content->getAttribute('id') . "', '" . $ip->nodeValue . "' )");
                                 }
                                 // Добавляем IP-подсети
                                 foreach ($content->getElementsByTagName('ipSubnet') as $ipSubnet) {
                                     nr_query("INSERT INTO `rbs_banned_ipSubnets` VALUES(NULL, '" . $content->getAttribute('id') . "', '" . $ipSubnet->nodeValue . "')");
                                 }
                             }
                             // Закрываем zip-архив
                             $zip->close();
                             // Обновляем время последней синхронизации
                             zb_StorageSet(self::STORAGE_LASTSYNC_KEY, time() * 1000);
                         } else {
                             throw new Exception("Couldn't open zip-archive, code: " . $resource);
                         }
                     } catch (Exception $ex) {
                         throw $ex;
                     }
                     // Удаляем временный файл
                     unlink($tmp);
                 } else {
                     throw new Exception("Невозможно получить результат: " . $this->getResult('resultComment'));
                 }
             } else {
                 throw new Exception("Невозможно отправить запрос: " . $this->sendRequest('resultComment'));
             }
         } else {
             throw new Exception("Обновление пока не требуется...");
         }
     } catch (Exception $ex) {
         print $ex->getMessage();
     }
 }