Example #1
0
 private static function init()
 {
     $lang = DMsg::DEFAULT_LANG;
     if (isset($_SESSION[DMsg::_COOKIE_LANG_])) {
         $lang = $_SESSION[DMsg::_COOKIE_LANG_];
     } else {
         $lang1 = UIBase::GrabGoodInput('cookie', self::_COOKIE_LANG_);
         if ($lang1 != NULL && $lang != $lang1 && array_key_exists($lang1, self::$_supported)) {
             $lang = $lang1;
         }
         DMsg::SetLang($lang);
     }
     $filecode = self::$_supported[$lang][1];
     self::$_curlang = $lang;
     include SERVER_ROOT . self::LANG_DIR . 'en-US_msg.php';
     if ($lang != DMsg::DEFAULT_LANG) {
         include SERVER_ROOT . self::LANG_DIR . $filecode . '_msg.php';
     }
 }
Example #2
0
 private function parse_vhosts()
 {
     $this->_vhosts = array();
     $top = UIBase::GrabGoodInput("request", "vh_topn", 'int');
     $filter = UIBase::GrabGoodInput("request", "vh_filter", "string");
     $sort = UIBase::GrabGoodInput("request", "vh_sort", "int");
     $vhosts = array();
     $m = array();
     $found = preg_match_all("/REQ_RATE \\[(.+)\\]: REQ_PROCESSING: ([0-9]+), REQ_PER_SEC: ([0-9\\.]+), TOT_REQS: ([0-9]+)/i", $this->_rawdata, $m);
     //$found = preg_match_all("/REQ_RATE \[(.+)\]: REQ_PROCESSING: ([0-9]+), REQ_PER_SEC: ([0-9\.]+), TOT_REQS: ([0-9]+), CACHE_HITS_PER_SEC: ([0-9\.]+), TOTAL_CACHE_HITS: ([0-9]+)/i", $this->_rawdata, $m);
     for ($f = 0; $f < $found; $f++) {
         $vhname = trim($m[1][$f]);
         if ($filter != "" && !preg_match("/{$filter}/i", $vhname)) {
             continue;
         }
         if (!isset($vhosts[$vhname])) {
             $vhosts[$vhname] = array_fill(0, 10, 0);
             $vhosts[$vhname]['ea'] = array();
         }
         $vh =& $vhosts[$vhname];
         $vh[self::FLD_VH_REQ_PROCESSING] += (int) $m[2][$f];
         $vh[self::FLD_VH_REQ_PER_SEC] += doubleval($m[3][$f]);
         $vh[self::FLD_VH_TOT_REQS] += doubleval($m[4][$f]);
     }
     //reset
     $m = array();
     $found = preg_match_all("/EXTAPP \\[(.+)\\] \\[(.+)\\] \\[(.+)\\]: CMAXCONN: ([0-9]+), EMAXCONN: ([0-9]+), POOL_SIZE: ([0-9]+), INUSE_CONN: ([0-9]+), IDLE_CONN: ([0-9]+), WAITQUE_DEPTH: ([0-9]+), REQ_PER_SEC: ([0-9\\.]+), TOT_REQS: ([0-9]+)/i", $this->_rawdata, $m);
     for ($f = 0; $f < $found; $f++) {
         $vhname = trim($m[2][$f]);
         $extapp = trim($m[3][$f]);
         if ($vhname == '') {
             $vhname = '_Server';
             if (!isset($vhosts[$vhname])) {
                 $vhosts[$vhname] = array_fill(0, 10, 0);
                 $vhosts[$vhname]['ea'] = array();
             }
         } else {
             if (!isset($vhosts[$vhname])) {
                 continue;
             }
         }
         if (!isset($vhosts[$vhname]['ea'][$extapp])) {
             $vhosts[$vhname][self::FLD_VH_EAP_COUNT]++;
             $vhosts[$vhname]['ea'][$extapp] = array_fill(0, 8, 0);
         }
         $ea =& $vhosts[$vhname]['ea'][$extapp];
         $ea[self::FLD_EA_TYPE] = trim($m[1][$f]);
         $ea[self::FLD_EA_CMAXCONN] += (int) $m[4][$f];
         $ea[self::FLD_EA_EMAXCONN] += (int) $m[5][$f];
         $ea[self::FLD_EA_POOL_SIZE] += (int) $m[6][$f];
         $ea[self::FLD_EA_INUSE_CONN] += (int) $m[7][$f];
         $ea[self::FLD_EA_IDLE_CONN] += (int) $m[8][$f];
         $ea[self::FLD_EA_WAITQUE_DEPTH] += (int) $m[9][$f];
         $ea[self::FLD_EA_REQ_PER_SEC] += doubleval($m[10][$f]);
         $ea[self::FLD_EA_TOT_REQS] += doubleval($m[11][$f]);
         $vhosts[$vhname][self::FLD_VH_EAP_INUSE] += (int) $m[7][$f];
         $vhosts[$vhname][self::FLD_VH_EAP_IDLE] += (int) $m[8][$f];
         $vhosts[$vhname][self::FLD_VH_EAP_WAITQUE] += (int) $m[9][$f];
         $vhosts[$vhname][self::FLD_VH_EAP_REQ_PER_SEC] += doubleval($m[10][$f]);
     }
     $names = array_keys($vhosts);
     if ($sort != "" && count($names) > 1) {
         foreach ($names as $vhname) {
             if ($vhosts[$vhname][$sort] > 0) {
                 $sortDesc1[] = $vhosts[$vhname][$sort];
                 $sortAsc2[] = $vhname;
             }
         }
         if (count($sortAsc2) > 0) {
             array_multisort($sortDesc1, SORT_DESC, SORT_NUMERIC, $sortAsc2, SORT_ASC, SORT_STRING);
             $names = $sortAsc2;
         }
     }
     if ($top != 0 && count($names) > $top) {
         $names = array_slice($names, 0, $top);
     }
     foreach ($names as $vn) {
         $this->_vhosts[$vn] = $vhosts[$vn];
     }
 }
Example #3
0
 public static function GetErrLog($errorlogfile)
 {
     // get from input
     $filename = UIBase::GrabGoodInput('any', 'filename');
     if ($filename == '') {
         return self::GetDashErrLog($errorlogfile);
     }
     // todo: validate
     $level = UIBase::GrabGoodInput('ANY', 'sellevel', 'int');
     $startinput = UIBase::GrabGoodInput('any', 'startpos', 'float');
     $block = UIBase::GrabGoodInput('any', 'blksize', 'float');
     $act = UIBase::GrabGoodInput('any', 'act');
     switch ($act) {
         case 'begin':
             $startinput = 0;
             break;
         case 'end':
             $startinput = LogFilter::POS_FILEEND;
             break;
         case 'prev':
             $startinput -= $block;
             break;
         case 'next':
             $startinput += $block;
             break;
     }
     $filter = new LogFilter($filename);
     $filter->Set(LogFilter::FLD_LEVEL, $level);
     $filter->SetRange($startinput, $block);
     $filter->SetMesg('');
     self::loadErrorLog($filter);
     return $filter;
 }
Example #4
0
function ajax_downloadlog()
{
    $file = UIBase::GrabGoodInput('get', 'filename');
    if (file_exists($file)) {
        if (ob_get_level()) {
            ob_end_clean();
        }
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename=' . basename($file));
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        readfile($file);
        exit;
    } else {
        error_log("download log {$file} not exist");
    }
}
 private function emailFailedLogin($authUser)
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $url = UIBase::GrabGoodInput('server', 'SCRIPT_URI');
     error_log("[WebAdmin Console] Failed Login Attempt - username:{$authUser} ip:{$ip} url:{$url}\n");
     $emails = Service::ServiceData(SInfo::DATA_ADMIN_EMAIL);
     if ($emails != NULL) {
         $hostname = gethostbyaddr($ip);
         $date = date("F j, Y, g:i a");
         $repl = array('%%date%%' => $date, '%%authUser%%' => $authUser, '%%ip%%' => $ip, '%%hostname%%' => $hostname, '%%url%%' => $url);
         $subject = DMsg::UIStr('mail_failedlogin');
         $contents = DMsg::UIStr('mail_failedlogin_c', $repl);
         mail($emails, $subject, $contents);
     }
 }
Example #6
0
 public function InitConf()
 {
     $has_pid = FALSE;
     $mid = UIBase::GrabGoodInput("request", 'm');
     if ($mid != NULL) {
         $this->_mid = $mid;
         $pid = UIBase::GrabGoodInput("request", 'p');
         if ($pid != NULL) {
             $this->_pid = $pid;
             $has_pid = TRUE;
         }
     }
     if (($pos = strpos($this->_mid, '_')) > 0) {
         $this->_view = substr($this->_mid, 0, $pos + 1);
         $this->_viewName = substr($this->_mid, $pos + 1);
         if ($this->_pid == '' || $this->_view == 'sl' || $this->_view == 'sl_' || $this->_view == 'al' || $this->_view == 'al_' || $this->_pid == 'base' || $this->_pid == 'mbr') {
             $this->_ref = $this->_viewName;
         }
         // still in serv conf
     } else {
         $this->_view = $this->_mid;
     }
     $this->_confType = $this->_mid[0] == 'a' ? self::CT_ADMIN : self::CT_SERV;
     $this->_tabs = DPageDef::GetInstance()->GetTabDef($this->_view);
     if ($has_pid) {
         if (!array_key_exists($this->_pid, $this->_tabs)) {
             die("Invalid pid - {$this->_pid} \n");
         }
     } else {
         $this->_pid = key($this->_tabs);
         // default
     }
     if ($has_pid && !isset($_REQUEST['t0']) && isset($_REQUEST['t'])) {
         $t = UIBase::GrabGoodInput('request', 't');
         if ($t != NULL) {
             $this->_tid = $t;
             $t1 = UIBase::GrabGoodInputWithReset('request', 't1');
             if ($t1 != NULL && $this->GetLast(self::FLD_TID) != $t1) {
                 $this->_tid .= '`' . $t1;
             }
             if (($r = UIBase::GrabGoodInputWithReset('request', 'r')) != NULL) {
                 $this->_ref = $r;
             }
             if (($r1 = UIBase::GrabGoodInputWithReset('request', 'r1')) != NULL) {
                 $this->_ref .= '`' . $r1;
             }
         }
     }
     $this->_act = UIBase::GrabGoodInput("request", 'a');
     if ($this->_act == NULL) {
         $this->_act = 'v';
     }
     $tokenInput = UIBase::GrabGoodInput("request", 'tk');
     $this->_token = $_SESSION['token'];
     if ($this->_act != 'v' && $this->_token != $tokenInput) {
         die('Illegal entry point!');
     }
     if ($this->_act == 'B') {
         $this->TrimLastId();
         $this->_act = 'v';
     }
     $this->_sort = UIBase::GrabGoodInput("request", 'sort');
     $this->_allActions = array('a' => array(DMsg::UIStr('btn_add'), 'fa-indent'), 'v' => array(DMsg::UIStr('btn_view'), 'fa-search-plus'), 'E' => array(DMsg::UIStr('btn_edit'), 'fa-edit'), 's' => array(DMsg::UIStr('btn_save'), 'fa-save'), 'B' => array(DMsg::UIStr('btn_back'), 'fa-reply'), 'n' => array(DMsg::UIStr('btn_next'), 'fa-step-forward'), 'd' => array(DMsg::UIStr('btn_delete'), 'fa-trash-o'), 'D' => array(DMsg::UIStr('btn_delete'), 'fa-trash-o'), 'C' => array(DMsg::UIStr('btn_cancel'), 'fa-angle-double-left'), 'i' => array(DMsg::UIStr('btn_instantiate'), 'fa-cube'), 'I' => array(DMsg::UIStr('btn_instantiate'), 'fa-cube'), 'X' => array(DMsg::UIStr('btn_view'), 'fa-search-plus'));
 }
Example #7
0
 private function validate_step3()
 {
     $php_version = UIBase::GrabGoodInput('ANY', 'buildver');
     if ($php_version == '') {
         echo "missing php_version";
         return FALSE;
     }
     $this->pass_val['php_version'] = $php_version;
     $next = UIBase::GrabInput('ANY', 'next');
     if ($next == 0) {
         $this->next_step = 2;
         return TRUE;
     }
     if (!isset($_SESSION['progress_file'])) {
         echo "missing progress file";
         return FALSE;
     }
     $progress_file = $_SESSION['progress_file'];
     if (!isset($_SESSION['log_file'])) {
         echo "missing log file";
         return FALSE;
     }
     $log_file = $_SESSION['log_file'];
     if (!file_exists($log_file)) {
         echo "logfile does not exist";
         return FALSE;
     }
     $manual_script = UIBase::GrabGoodInput('ANY', 'manual_script');
     if ($manual_script == '' || !file_exists($manual_script)) {
         echo "missing manual script";
         return FALSE;
     }
     $this->pass_val['progress_file'] = $progress_file;
     $this->pass_val['log_file'] = $log_file;
     $this->pass_val['manual_script'] = $manual_script;
     $this->pass_val['extentions'] = UIBase::GrabGoodInput('ANY', 'extentions');
     $this->next_step = 4;
     return TRUE;
 }
Example #8
0
<?php

require_once "inc/auth.php";
$act = UIBase::GrabGoodInput("any", 'act');
$actId = UIBase::GrabGoodInput("any", 'actId');
switch ($act) {
    case 'restart':
        Service::ServiceRequest(SInfo::SREQ_RESTART_SERVER);
        break;
    case 'lang':
        DMsg::SetLang($actId);
        break;
    case 'toggledebug':
        Service::ServiceRequest(SInfo::SREQ_TOGGLE_DEBUG);
        break;
    case 'reload':
        if ($actId != '') {
            Service::ServiceRequest(SInfo::SREQ_VH_RELOAD, $actId);
        }
        break;
    case 'disable':
        if ($actId != '') {
            Service::ServiceRequest(SInfo::SREQ_VH_DISABLE, $actId);
        }
        break;
    case 'enable':
        if ($actId != '') {
            Service::ServiceRequest(SInfo::SREQ_VH_ENABLE, $actId);
        }
        break;
    default: