示例#1
0
function imageOut(&$image, $format = null)
{
    global $page, $IMAGE_FORMAT_DEFAULT;
    if (is_null($format)) {
        $format = $IMAGE_FORMAT_DEFAULT;
    }
    ob_start();
    if (IMAGE_FORMAT_JPEG == $format) {
        imagejpeg($image);
    } else {
        imagepng($image);
    }
    $imageSource = ob_get_contents();
    ob_end_clean();
    if ($page['type'] != PAGE_TYPE_IMAGE) {
        $imageId = md5(strlen($imageSource));
        CSession::setValue('image_id', [$imageId => $imageSource]);
    }
    switch ($page['type']) {
        case PAGE_TYPE_IMAGE:
            echo $imageSource;
            break;
        case PAGE_TYPE_JSON:
            $json = new CJson();
            echo $json->encode(['result' => $imageId]);
            break;
        case PAGE_TYPE_TEXT:
        default:
            echo $imageId;
    }
}
示例#2
0
            $ico = imageThumb($ico, $width, $height);
        }
        $w = imagesx($ico);
        $h = imagesy($ico);
        $css .= 'div.sysmap_iconid_' . $image['imageid'] . '{' . ' height: ' . $h . 'px;' . ' width: ' . $w . 'px;' . ' background: url("imgstore.php?iconid=' . $image['imageid'] . '&width=' . $w . '&height=' . $h . '") no-repeat center center;}' . "\n";
    }
    echo $css;
} elseif (isset($_REQUEST['iconid'])) {
    $iconid = getRequest('iconid', 0);
    if ($iconid > 0) {
        $image = get_image_by_imageid($iconid);
        $source = $image['image'] ? imageFromString($image['image']) : get_default_image();
    } else {
        $source = get_default_image();
    }
    if ($resize) {
        $source = imageThumb($source, $width, $height);
    }
    imageOut($source);
} elseif (isset($_REQUEST['imageid'])) {
    $imageid = getRequest('imageid', 0);
    if (CSession::keyExists('image_id')) {
        $image_data = CSession::getValue('image_id');
        if (array_key_exists($imageid, $image_data)) {
            echo $image_data[$imageid];
            unset($image_data[$imageid]);
            CSession::setValue('image_id', $image_data);
        }
    }
}
require_once dirname(__FILE__) . '/include/page_footer.php';
示例#3
0
 function setConfig($name, $value)
 {
     CSession::setValue($name, $value);
 }
示例#4
0
 /**
  * Process request and generate response. Main entry for all processing.
  */
 private function processRequest()
 {
     $router = new CRouter(getRequest('action'));
     $controller = $router->getController();
     $controller = new $controller();
     $controller->setAction($router->getAction());
     $response = $controller->run();
     // Controller returned data
     if ($response instanceof CControllerResponseData) {
         // if no view defined we pass data directly to layout
         if ($router->getView() === null) {
             $layout = new CView($router->getLayout(), $response->getData());
             echo $layout->getOutput();
         } else {
             $view = new CView($router->getView(), $response->getData());
             $data['page']['title'] = $response->getTitle();
             $data['controller']['action'] = $router->getAction();
             $data['main_block'] = $view->getOutput();
             $data['fullscreen'] = isset($_REQUEST['fullscreen']) && $_REQUEST['fullscreen'] == 1 ? 1 : 0;
             $data['javascript']['files'] = $view->getAddedJS();
             $data['javascript']['pre'] = $view->getIncludedJS();
             $data['javascript']['post'] = $view->getPostJS();
             $layout = new CView($router->getLayout(), $data);
             echo $layout->getOutput();
         }
     } else {
         if ($response instanceof CControllerResponseRedirect) {
             header('Content-Type: text/html; charset=UTF-8');
             if ($response->getMessageOk() !== null) {
                 CSession::setValue('messageOk', $response->getMessageOk());
             }
             if ($response->getMessageError() !== null) {
                 CSession::setValue('messageError', $response->getMessageError());
             }
             global $ZBX_MESSAGES;
             if (isset($ZBX_MESSAGES)) {
                 CSession::setValue('messages', $ZBX_MESSAGES);
             }
             if ($response->getFormData() !== null) {
                 CSession::setValue('formData', $response->getFormData());
             }
             redirect($response->getLocation());
         } else {
             if ($response instanceof CControllerResponseFatal) {
                 header('Content-Type: text/html; charset=UTF-8');
                 $response->addMessage('Controller: ' . $router->getAction());
                 ksort($_REQUEST);
                 foreach ($_REQUEST as $key => $value) {
                     // do not output SID
                     if ($key != 'sid') {
                         $response->addMessage($key . ': ' . $value);
                     }
                 }
                 CSession::setValue('messages', $response->getMessages());
                 redirect('zabbix.php?action=system.warning');
             }
         }
     }
 }
示例#5
0
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
require_once dirname(__FILE__) . '/include/classes/core/Z.php';
$page['file'] = 'setup.php';
try {
    Z::getInstance()->run(ZBase::EXEC_MODE_SETUP);
} catch (Exception $e) {
    (new CView('general.warning', ['header' => $e->getMessage(), 'messages' => [], 'theme' => ZBX_DEFAULT_THEME]))->render();
    exit;
}
// VAR	TYPE	OPTIONAL	FLAGS	VALIDATION	EXCEPTION
$fields = ['type' => [T_ZBX_STR, O_OPT, null, IN('"' . ZBX_DB_MYSQL . '","' . ZBX_DB_POSTGRESQL . '","' . ZBX_DB_ORACLE . '","' . ZBX_DB_DB2 . '","' . ZBX_DB_SQLITE3 . '"'), null], 'server' => [T_ZBX_STR, O_OPT, null, null, null], 'port' => [T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Database port')], 'database' => [T_ZBX_STR, O_OPT, null, NOT_EMPTY, null, _('Database name')], 'user' => [T_ZBX_STR, O_OPT, null, null, null], 'password' => [T_ZBX_STR, O_OPT, null, null, null], 'schema' => [T_ZBX_STR, O_OPT, null, null, null], 'zbx_server' => [T_ZBX_STR, O_OPT, null, null, null], 'zbx_server_name' => [T_ZBX_STR, O_OPT, null, null, null], 'zbx_server_port' => [T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Port')], 'save_config' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'retry' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'cancel' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'finish' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'next' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'back' => [T_ZBX_STR, O_OPT, P_SYS, null, null]];
CSession::start();
CSession::setValue('check_fields_result', check_fields($fields, false));
if (!CSession::keyExists('step')) {
    CSession::setValue('step', 0);
}
// if a guest or a non-super admin user is logged in
if (CWebUser::$data && CWebUser::getType() < USER_TYPE_SUPER_ADMIN) {
    // on the last step of the setup we always have a guest user logged in;
    // when he presses the "Finish" button he must be redirected to the login screen
    if (CWebUser::isGuest() && CSession::getValue('step') == 5 && hasRequest('finish')) {
        CSession::clear();
        redirect('index.php');
    } elseif (!(CWebUser::isGuest() && CSession::getValue('step') == 5)) {
        access_deny(ACCESS_DENY_PAGE);
    }
} elseif (hasRequest('cancel') || hasRequest('finish')) {
    CSession::clear();
    redirect('index.php');
}
示例#6
0
     break;
 case 'message.closeAll':
     $msgsettings = getMessageSettings();
     switch (strtolower($data['params']['caption'])) {
         case 'events':
             $msgsettings['last.clock'] = (int) $data['params']['time'] + 1;
             updateMessageSettings($msgsettings);
             break;
     }
     break;
 case 'zabbix.status':
     CSession::start();
     if (!CSession::keyExists('serverCheckResult') || CSession::getValue('serverCheckTime') + SERVER_CHECK_INTERVAL <= time()) {
         $zabbixServer = new CZabbixServer($ZBX_SERVER, $ZBX_SERVER_PORT, ZBX_SOCKET_TIMEOUT, 0);
         CSession::setValue('serverCheckResult', $zabbixServer->isRunning());
         CSession::setValue('serverCheckTime', time());
     }
     $result = ['result' => (bool) CSession::getValue('serverCheckResult'), 'message' => CSession::getValue('serverCheckResult') ? '' : _('Zabbix server is not running: the information displayed may not be current.')];
     break;
 case 'screen.get':
     $result = '';
     $screenBase = CScreenBuilder::getScreen($data);
     if ($screenBase !== null) {
         $screen = $screenBase->get();
         if ($data['mode'] == SCREEN_MODE_JS) {
             $result = $screen;
         } else {
             if (is_object($screen)) {
                 $result = $screen->toString();
             }
         }