本文整理汇总了PHP中CProfile类的典型用法代码示例。如果您正苦于以下问题:PHP CProfile类的具体用法?PHP CProfile怎么用?PHP CProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public static function update($idx, $value, $type, $idx2 = 0)
{
global $USER_DETAILS;
if (is_null(self::$profiles)) {
self::init();
}
if (!self::checkValueType($value, $type)) {
return false;
}
$profile = array('idx' => $idx, 'value' => $value, 'type' => $type, 'idx2' => $idx2);
$current = CProfile::get($idx, null, $idx2);
if (is_null($current)) {
if (!isset(self::$insert[$idx])) {
self::$insert[$idx] = array();
}
self::$insert[$idx][$idx2] = $profile;
} else {
if ($current != $value) {
if (!isset(self::$update[$idx])) {
self::$update[$idx] = array();
}
self::$update[$idx][$idx2] = $profile;
}
}
if (!isset(self::$profiles[$idx])) {
self::$profiles[$idx] = array();
}
self::$profiles[$idx][$idx2] = $value;
}
示例2: login
/**
* Tries to login a user and populates self::$data on success.
*
* @param string $login user login
* @param string $password user password
*
* @throws Exception if user cannot be logged in
*
* @return bool
*/
public static function login($login, $password)
{
try {
self::setDefault();
self::$data = API::User()->login(array('user' => $login, 'password' => $password, 'userData' => true));
if (!self::$data) {
throw new Exception();
}
if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
error(_('GUI access disabled.'));
throw new Exception();
}
if (empty(self::$data['url'])) {
self::$data['url'] = CProfile::get('web.menu.view.last', 'index.php');
}
$result = (bool) self::$data;
if (isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) {
CProfile::init();
CProfile::update('web.login.attempt.failed', self::$data['attempt_failed'], PROFILE_TYPE_INT);
CProfile::update('web.login.attempt.ip', self::$data['attempt_ip'], PROFILE_TYPE_STR);
CProfile::update('web.login.attempt.clock', self::$data['attempt_clock'], PROFILE_TYPE_INT);
$result &= CProfile::flush();
}
// remove guest session after successful login
$result &= DBexecute('DELETE FROM sessions WHERE sessionid=' . zbx_dbstr(get_cookie('zbx_sessionid')));
if ($result) {
self::setSessionCookie(self::$data['sessionid']);
add_audit_ext(AUDIT_ACTION_LOGIN, AUDIT_RESOURCE_USER, self::$data['userid'], '', null, null, null);
}
return $result;
} catch (Exception $e) {
self::setDefault();
return false;
}
}
示例3: login
public static function login($login, $password)
{
try {
self::setDefault();
self::$data = API::User()->login(array('user' => $login, 'password' => $password, 'userData' => true));
if (!self::$data) {
throw new Exception();
}
if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
error(_('GUI access disabled.'));
throw new Exception();
}
if (empty(self::$data['url'])) {
self::$data['url'] = CProfile::get('web.menu.view.last', 'index.php');
}
if (isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) {
CProfile::init();
CProfile::update('web.login.attempt.failed', self::$data['attempt_failed'], PROFILE_TYPE_INT);
CProfile::update('web.login.attempt.ip', self::$data['attempt_ip'], PROFILE_TYPE_STR);
CProfile::update('web.login.attempt.clock', self::$data['attempt_clock'], PROFILE_TYPE_INT);
CProfile::flush();
}
// remove guest session after successful login
DBexecute('DELETE FROM sessions WHERE sessionid=' . zbx_dbstr(get_cookie('zbx_sessionid')));
zbx_setcookie('zbx_sessionid', self::$data['sessionid'], self::$data['autologin'] ? time() + SEC_PER_DAY * 31 : 0);
return true;
} catch (Exception $e) {
self::setDefault();
return false;
}
}
示例4: local_generateHeader
function local_generateHeader($data)
{
// only needed for zbx_construct_menu
global $page;
header('Content-Type: text/html; charset=UTF-8');
// construct menu
$main_menu = [];
$sub_menus = [];
zbx_construct_menu($main_menu, $sub_menus, $page, $data['controller']['action']);
$pageHeader = new CView('layout.htmlpage.header', ['javascript' => ['files' => $data['javascript']['files']], 'page' => ['title' => $data['page']['title']], 'user' => ['lang' => CWebUser::$data['lang'], 'theme' => CWebUser::$data['theme']]]);
echo $pageHeader->getOutput();
if ($data['fullscreen'] == 0) {
global $ZBX_SERVER_NAME;
$pageMenu = new CView('layout.htmlpage.menu', ['server_name' => isset($ZBX_SERVER_NAME) ? $ZBX_SERVER_NAME : '', 'menu' => ['main_menu' => $main_menu, 'sub_menus' => $sub_menus, 'selected' => $page['menu']], 'user' => ['is_guest' => CWebUser::isGuest(), 'alias' => CWebUser::$data['alias'], 'name' => CWebUser::$data['name'], 'surname' => CWebUser::$data['surname']]]);
echo $pageMenu->getOutput();
}
echo '<div class="' . ZBX_STYLE_ARTICLE . '">';
// should be replaced with addPostJS() at some point
zbx_add_post_js('initMessages({});');
// if a user logs in after several unsuccessful attempts, display a warning
if ($failedAttempts = CProfile::get('web.login.attempt.failed', 0)) {
$attempt_ip = CProfile::get('web.login.attempt.ip', '');
$attempt_date = CProfile::get('web.login.attempt.clock', 0);
$error_msg = _n('%4$s failed login attempt logged. Last failed attempt was from %1$s on %2$s at %3$s.', '%4$s failed login attempts logged. Last failed attempt was from %1$s on %2$s at %3$s.', $attempt_ip, zbx_date2str(DATE_FORMAT, $attempt_date), zbx_date2str(TIME_FORMAT, $attempt_date), $failedAttempts);
error($error_msg);
CProfile::update('web.login.attempt.failed', 0, PROFILE_TYPE_INT);
}
show_messages();
}
示例5: doAction
protected function doAction()
{
$sortField = $this->getInput('sort', CProfile::get('web.media_types.php.sort', 'description'));
$sortOrder = $this->getInput('sortorder', CProfile::get('web.media_types.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.media_type.php.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.media_types.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
$config = select_config();
$data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder];
// get media types
$data['mediatypes'] = API::Mediatype()->get(['output' => ['mediatypeid', 'description', 'type', 'smtp_server', 'smtp_helo', 'smtp_email', 'exec_path', 'gsm_modem', 'username', 'status'], 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]);
if ($data['mediatypes']) {
// get media types used in actions
$actions = API::Action()->get(['output' => ['actionid', 'name'], 'selectOperations' => ['operationtype', 'opmessage'], 'mediatypeids' => array_keys($data['mediatypes'])]);
foreach ($data['mediatypes'] as &$mediaType) {
$mediaType['typeid'] = $mediaType['type'];
$mediaType['type'] = media_type2str($mediaType['type']);
$mediaType['listOfActions'] = [];
foreach ($actions as $action) {
foreach ($action['operations'] as $operation) {
if ($operation['operationtype'] == OPERATION_TYPE_MESSAGE && $operation['opmessage']['mediatypeid'] == $mediaType['mediatypeid']) {
$mediaType['listOfActions'][$action['actionid']] = ['actionid' => $action['actionid'], 'name' => $action['name']];
}
}
}
order_result($mediaType['listOfActions'], 'name');
}
unset($mediaType);
order_result($data['mediatypes'], $sortField, $sortOrder);
}
$url = (new CUrl('zabbix.php'))->setArgument('action', 'mediatype.list');
$data['paging'] = getPagingLine($data['mediatypes'], $sortOrder, $url);
$response = new CControllerResponseData($data);
$response->setTitle(_('Configuration of media types'));
$this->setResponse($response);
}
示例6: doAction
protected function doAction()
{
$sortField = $this->getInput('sort', CProfile::get('web.proxies.php.sort', 'host'));
$sortOrder = $this->getInput('sortorder', CProfile::get('web.proxies.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.proxies.php.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.proxies.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
$config = select_config();
$data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder, 'config' => ['max_in_table' => $config['max_in_table']]];
$data['proxies'] = API::Proxy()->get(['output' => ['proxyid', 'host', 'status', 'lastaccess', 'tls_connect', 'tls_accept'], 'selectHosts' => ['hostid', 'name', 'status'], 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]);
// sorting & paging
order_result($data['proxies'], $sortField, $sortOrder);
$url = (new CUrl('zabbix.php'))->setArgument('action', 'proxy.list');
$data['paging'] = getPagingLine($data['proxies'], $sortOrder, $url);
foreach ($data['proxies'] as &$proxy) {
order_result($proxy['hosts'], 'name');
}
unset($proxy);
// get proxy IDs for a *selected* page
$proxyIds = array_keys($data['proxies']);
if ($proxyIds) {
// calculate performance
$dbPerformance = DBselect('SELECT h.proxy_hostid,SUM(1.0/i.delay) AS qps' . ' FROM hosts h,items i' . ' WHERE h.hostid=i.hostid' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.delay<>0' . ' AND i.flags<>' . ZBX_FLAG_DISCOVERY_PROTOTYPE . ' AND ' . dbConditionInt('h.proxy_hostid', $proxyIds) . ' GROUP BY h.proxy_hostid');
while ($performance = DBfetch($dbPerformance)) {
$data['proxies'][$performance['proxy_hostid']]['perf'] = round($performance['qps'], 2);
}
// get items
$items = API::Item()->get(['proxyids' => $proxyIds, 'groupCount' => true, 'countOutput' => true, 'webitems' => true, 'monitored' => true]);
foreach ($items as $item) {
$data['proxies'][$item['proxy_hostid']]['item_count'] = $item['rowscount'];
}
}
$response = new CControllerResponseData($data);
$response->setTitle(_('Configuration of proxies'));
$this->setResponse($response);
}
示例7: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
$this->dataId = 'graph_full';
$containerId = 'graph_container';
// time control
$graphDims = getGraphDims($this->graphid);
if ($graphDims['graphtype'] == GRAPH_TYPE_PIE || $graphDims['graphtype'] == GRAPH_TYPE_EXPLODED) {
$loadSBox = 0;
$src = 'chart6.php';
} else {
$loadSBox = 1;
$src = 'chart2.php';
}
$src .= '?graphid=' . $this->graphid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'] . $this->getProfileUrlParams();
$this->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_graphid($this->graphid));
$timeControlData = array('id' => $this->getDataId(), 'containerid' => $containerId, 'src' => $src, 'objDims' => $graphDims, 'loadSBox' => $loadSBox, 'loadImage' => 1, 'dynamic' => 1, 'periodFixed' => CProfile::get($this->profileIdx . '.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD);
// output
if ($this->mode == SCREEN_MODE_JS) {
$timeControlData['dynamic'] = 0;
$timeControlData['loadSBox'] = 0;
return 'timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ')';
} else {
if ($this->mode == SCREEN_MODE_SLIDESHOW) {
insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');');
} else {
zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');');
}
return $this->getOutput(new CDiv(null, 'center', $containerId), true, array('graphid' => $this->graphid));
}
}
示例8: doAction
protected function doAction()
{
$show_discovery_widget = $this->getUserType() >= USER_TYPE_ZABBIX_ADMIN && (bool) API::DRule()->get(['output' => [], 'filter' => ['status' => DRULE_STATUS_ACTIVE], 'limit' => 1]);
$data = ['fullscreen' => $this->getInput('fullscreen', 0), 'filter_enabled' => CProfile::get('web.dashconf.filter.enable', 0), 'favourite_graphs' => getFavouriteGraphs(), 'favourite_maps' => getFavouriteMaps(), 'favourite_screens' => getFavouriteScreens(), 'show_status_widget' => $this->getUserType() == USER_TYPE_SUPER_ADMIN, 'show_discovery_widget' => $show_discovery_widget];
$response = new CControllerResponseData($data);
$response->setTitle(_('Dashboard'));
$this->setResponse($response);
}
示例9: doAction
protected function doAction()
{
$sortField = $this->getInput('sort', CProfile::get('web.scripts.php.sort', 'name'));
$sortOrder = $this->getInput('sortorder', CProfile::get('web.scripts.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.scripts.php.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.scripts.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
$config = select_config();
$data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder];
// list of scripts
$data['scripts'] = API::Script()->get(['output' => ['scriptid', 'name', 'command', 'host_access', 'usrgrpid', 'groupid', 'type', 'execute_on'], 'editable' => true, 'limit' => $config['search_limit'] + 1]);
// sorting & paging
order_result($data['scripts'], $sortField, $sortOrder);
$url = (new CUrl('zabbix.php'))->setArgument('action', 'script.list');
$data['paging'] = getPagingLine($data['scripts'], $sortOrder, $url);
// find script host group name and user group name. set to '' if all host/user groups used.
$usrgrpids = [];
$groupids = [];
foreach ($data['scripts'] as &$script) {
$script['userGroupName'] = null;
// all user groups
$script['hostGroupName'] = null;
// all host groups
if ($script['usrgrpid'] != 0) {
$usrgrpids[] = $script['usrgrpid'];
}
if ($script['groupid'] != 0) {
$groupids[] = $script['groupid'];
}
}
unset($script);
if ($usrgrpids) {
$userGroups = API::UserGroup()->get(['output' => ['name'], 'usrgrpids' => $usrgrpids, 'preservekeys' => true]);
foreach ($data['scripts'] as &$script) {
if ($script['usrgrpid'] != 0 && array_key_exists($script['usrgrpid'], $userGroups)) {
$script['userGroupName'] = $userGroups[$script['usrgrpid']]['name'];
}
unset($script['usrgrpid']);
}
unset($script);
}
if ($groupids) {
$hostGroups = API::HostGroup()->get(['output' => ['name'], 'groupids' => $groupids, 'preservekeys' => true]);
foreach ($data['scripts'] as &$script) {
if ($script['groupid'] != 0 && array_key_exists($script['groupid'], $hostGroups)) {
$script['hostGroupName'] = $hostGroups[$script['groupid']]['name'];
}
unset($script['groupid']);
}
unset($script);
}
$response = new CControllerResponseData($data);
$response->setTitle(_('Configuration of scripts'));
$this->setResponse($response);
}
示例10: __construct
public function __construct($filterid)
{
parent::__construct('div', true);
$this->addClass(ZBX_STYLE_FILTER_CONTAINER);
$this->setId('filter-space');
$this->filterid = $filterid;
$this->columns = [];
$this->form = (new CForm('get'))->cleanItems()->setAttribute('name', $this->name)->setId('id', $this->name);
// filter is opened by default
$this->opened = CProfile::get($this->filterid, 1) == 1;
}
示例11: doAction
protected function doAction()
{
$sortField = $this->getInput('sort', CProfile::get('web.httpmon.php.sort', 'name'));
$sortOrder = $this->getInput('sortorder', CProfile::get('web.httpmon.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.httpmon.php.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.httpmon.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
$data = ['fullscreen' => $this->getInput('fullscreen', 0), 'sort' => $sortField, 'sortorder' => $sortOrder, 'page' => $this->getInput('page', 1)];
$data['pageFilter'] = new CPageFilter(['groups' => ['real_hosts' => true, 'with_httptests' => true], 'hosts' => ['with_monitored_items' => true, 'with_httptests' => true], 'hostid' => $this->hasInput('hostid') ? $this->getInput('hostid') : null, 'groupid' => $this->hasInput('groupid') ? $this->getInput('groupid') : null]);
$response = new CControllerResponseData($data);
$response->setTitle(_('Web monitoring'));
$this->setResponse($response);
}
示例12: doAction
protected function doAction()
{
CProfile::update('web.maps.sysmapid', $this->sysmapid, PROFILE_TYPE_ID);
$data = ['fullscreen' => $this->getInput('fullscreen', 0)];
$maps = API::Map()->get(['output' => ['name', 'severity_min'], 'sysmapids' => [$this->sysmapid]]);
$data['map'] = reset($maps);
$data['map']['editable'] = API::Map()->isWritable([$this->sysmapid]);
$data['pageFilter'] = new CPageFilter(['severitiesMin' => ['default' => $data['map']['severity_min'], 'mapId' => $this->sysmapid], 'severityMin' => $this->hasInput('severity_min') ? $this->getInput('severity_min') : null]);
$data['severity_min'] = $data['pageFilter']->severityMin;
$response = new CControllerResponseData($data);
$response->setTitle(_('Network maps'));
$this->setResponse($response);
}
示例13: doAction
protected function doAction()
{
foreach (CJs::decodeJson($this->getInput('grid')) as $col => $column) {
foreach ($column as $row => $widgetName) {
$widgetName = str_replace('_widget', '', $widgetName);
CProfile::update('web.dashboard.widget.' . $widgetName . '.col', $col, PROFILE_TYPE_INT);
CProfile::update('web.dashboard.widget.' . $widgetName . '.row', $row, PROFILE_TYPE_INT);
}
}
$data = ['main_block' => ''];
$response = new CControllerResponseData($data);
$this->setResponse($response);
}
示例14: doAction
protected function doAction()
{
$sortField = $this->getInput('sort', CProfile::get('web.discovery.php.sort', 'ip'));
$sortOrder = $this->getInput('sortorder', CProfile::get('web.discovery.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.discovery.php.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.discovery.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
/*
* Display
*/
$data = ['fullscreen' => $this->getInput('fullscreen', 0), 'druleid' => $this->getInput('druleid', 0), 'sort' => $sortField, 'sortorder' => $sortOrder];
$data['pageFilter'] = new CPageFilter(['drules' => ['filter' => ['status' => DRULE_STATUS_ACTIVE]], 'druleid' => $data['druleid']]);
$response = new CControllerResponseData($data);
$response->setTitle(_('Status of discovery'));
$this->setResponse($response);
}
示例15: doAction
protected function doAction()
{
$widget = $this->getInput('widget');
$data = ['main_block' => ''];
// refresh rate
if ($this->hasInput('refreshrate')) {
$refreshrate = $this->getInput('refreshrate');
CProfile::update('web.dashboard.widget.' . $widget . '.rf_rate', $refreshrate, PROFILE_TYPE_INT);
$data['main_block'] = 'PMasters["dashboard"].dolls["' . $widget . '"].frequency(' . CJs::encodeJson($refreshrate) . ');' . "\n" . 'PMasters["dashboard"].dolls["' . $widget . '"].restartDoll();';
}
// widget state
if ($this->hasInput('state')) {
CProfile::update('web.dashboard.widget.' . $widget . '.state', $this->getInput('state'), PROFILE_TYPE_INT);
}
$this->setResponse(new CControllerResponseData($data));
}