public function &__get($var) { $varName = "get" . $var; $methods = Z::getPublicMethods($this); for ($i = 0; $i < count($methods); $i++) { $methods[$i] = strtolower($methods[$i]); } // First check global access (public methods) if (in_array($varName, $methods)) { return call_user_func(array($this, $varName)); } // see if there is a 'private' method if (method_exists($this, $varName)) { // See if we have full access $stack = debug_backtrace(true); if (count($stack) < 3) { return null; } $callerObj = $stack[2]; if ($this == $callerObj) { return call_user_func(array($this, $varName)); } } $bla = array(); return $bla; }
/** * @return Z_Application */ public static function getInstance() { if (Z::getGlobal('@Z.Application')) { return Z::getGlobal('@Z.Application'); } Z::setGlobal('@Z.Application', Z::createApplication(NULL)); return Z::getGlobal('@Z.Application'); }
public function __construct($viewData = array()) { // Get class-specific options $this->_config = Z::getConfig(__CLASS__); $this->_viewData = $viewData; $core = Z_Application::getInstance(); $this->_response =& $core->getResponse(); $this->_request =& $core->getRequest(); }
public function __construct($viewData = array()) { parent::__construct($viewData); // Get class-specific options $this->_config = Z::getConfig(__CLASS__); $config = $this->_config; if (!isset($this->_config->buffer_response)) { $this->_config->buffer_response = true; } $this->_smarty = new Z_View_Smarty_Extended(); $this->_smarty->plugins_dir[] = realpath(dirname(__FILE__) . Z_DS . 'Smarty' . Z_DS . 'Plugins' . Z_DS); $this->_smarty->template_dir = $config->template_dir; $this->_smarty->compile_dir = $config->compile_dir; $this->_smarty->cache_dir = $config->cache_dir; // Expose assigned data as ViewData $this->_smarty->append_by_ref('ViewData', $this->_viewData); }
<?php trait T { private $x = 0; } class X { use T; function x() { return ++$this->x; } } class Y extends X { use T; function y() { return ++$this->x; } } class Z extends Y { function z() { return ++$this->x; } } $a = new Z(); echo join(" ", array($a->x(), $a->x(), $a->y(), $a->y(), $a->z(), $a->z())), "\n";
} class Z extends Y { public function zoo2() { return "zoo2/" . $this->nonexistingzoo(8, 8, 8); } public function zoo() { return $this->bar() . $this->zoo2() . X::nonexisting1(3); } } // calling static methods resolved in compile time echo X::nonexistingfoo(1, 2, 3); echo call_user_func_array(array("X", "nonexisting2"), array(10, 20, 30)); echo Y::nonexistingfoo(1, 2, 3); echo Y::nonexistingfoo2(4); echo call_user_func_array(array("Y", "nonexisting3"), array("a", 'b', 'c')); echo Z::nonexistingstatic(); // calling instance methods $x = new X(); echo $x->bar(); echo $x->non_existing_func(1, 2, 3); echo call_user_func(array($x, "foo"), 5, 6, 7); $y = new Y(); echo $y->bar(); echo $y->nonexisting4(9, 8, 7); echo call_user_func(array($y, "bar"), 4, 5, 6); echo call_user_func(array($y, "nonexisting5"), 333, 666, 999); $z = new Z(); echo $z->zoo();
echo 'This is Y' . '<br>'; } } class Z { public $ob; public function get_ob(X $var) { $this->ob = $var; } public function get_result() { echo $this->ob->get(); } } $x = new X(); $y = new Y(); $x->render(); $y->render(); $z = new Z(); $z->get_ob($x); $z->get_ob($y); $z->get_result(); $poly = new Poly(); $page = new Page('Page', 'hello i am page', 'footer'); echo $page->render_body(); $index = new Index('Index', 'hello i am index', 'footer', 'slideshow', 'news'); echo $index->render_body(); $poly->get_ob($page); $poly->get_ob($index); $poly->get_result();
public function __construct() { parent::__construct(); // OK Z::f(); }
// For application options $config['Z_Application'] = array(); $config['Z_Application']['page']['path'] = realpath(dirname(__FILE__) . Z_DS . 'pages'); $config['Z_Application']['page']['class_prefix'] = 'Z_Page_'; // For default view options $config['Z_View'] = array(); $config['Z_View']['buffer_response'] = true; // if true, it'll buffer the output $config['Z_View']['template_dir'] = realpath(dirname(__FILE__) . '/views'); // For Smarty view' options $config['Z_View_Smarty'] = array(); $config['Z_View_Smarty']['template_dir'] = realpath(dirname(__FILE__) . '/views'); $config['Z_View_Smarty']['compile_dir'] = realpath(dirname(__FILE__) . '/runtime/views'); $config['Z_View_Smarty']['cache_dir'] = realpath(dirname(__FILE__) . '/runtime/views/cached'); /** * Configuration is done - preboot Z (you could do this usually before configuring though) */ /** * Register the auto loader */ Z::registerAutoloader(); /** * Register 'namespaces' (to basicly make it easier to include files */ Z::registerNamespace('Library', DEMO_LIBRARY); /** * Register 'namespaces' (to basicly make it easier to include files */ Z::registerNamespace('Smarty', '../../library/smarty/'); // Now we show that it does accept stdclass objects return Z_Array::ToObject($config);
/** * Returns the array describing the database schema. * * If the $table parameter is passed, the method will return the schema for the given table, * otherwise - for the whole database. * * @static * * @throws APIException if the given table does not exist * * @param string $table * * @return array */ public static function getSchema($table = null) { if (is_null(self::$schema)) { self::$schema = (include Z::getRootDir() . '/' . self::SCHEMA_FILE); } if (is_null($table)) { return self::$schema; } elseif (isset(self::$schema[$table])) { return self::$schema[$table]; } else { self::exception(self::SCHEMA_ERROR, _s('Table "%1$s" does not exist.', $table)); } }
<?php interface X { const A = 1; } class Y { const B = 2; } class Z extends Y implements X { function x() { print self::A; print self::B; print Z::A; print Z::B; print X::A; print Y::B; } } $z = new Z(); $z->x();
public function __get($var) { $orname = $var; $varName = "Get" . $var; $methods = Z::getPublicMethods($this); for ($i = 0; $i < count($methods); $i++) { $methods[$i] = strtolower($methods[$i]); } // First check global access (public methods) if (in_array($varName, $methods)) { return call_user_func(array($this, $varName)); } // see if there is a 'private' method if (method_exists($this, $varName)) { // See if we have full access $stack = debug_backtrace(true); if (count($stack) < 3) { return null; } $callerObj = $stack[2]; if ($this == $callerObj) { return call_user_func(array($this, $varName)); } } $varName = $orname; if (count($this->_Fields) == 0) { // No fields defined .. Accept everything - WARNING - PLEASE DEFINE THEM :) if (isset($this->_Data[$varName])) { return $this->_Data[$varName]; } } // See if the varName is part of this obj if (in_array($varName, $this->_Fields)) { if (isset($this->_Data[$varName])) { return $this->_Data[$varName]; } } // Mappings if (isset($this->_MappingData[$varName])) { $infox = $this->_MappingData[$varName]; foreach ($infox as $index => $info) { foreach ($info as $fieldName => $info) { $obj = $info[0]; $pkey = $info[1]; if (!is_object($obj)) { $obj = new $obj(); $info[0] = $obj; //print_r($obj); $this->_MappingData[$varName][$index][$fieldName] = $info; } if ($obj->IsLoaded() && $this->_MappedLinks[$fieldName]) { return $obj; } //var_dump($obj->IsLoaded());die(); $res = $obj->FindByField($pkey, $this->_Data[$fieldName]); //echo $pkey . '-' . $this->_Data[$fieldName];die(); if ($res == false) { return null; } $this->_MappingData[$varName][$index] = array($fieldName => array($res, $pkey)); $this->_MappedLinks[$fieldName] = array($res, $pkey); return $res; } } } // NEW many Mappings if (isset($this->_ManyMappingData[$varName])) { $info = $this->_ManyMappingData[$varName]; foreach ($info as $fieldName => $info) { $obj = $info[0]; if (!is_object($obj)) { $obj = new $obj(); $info[0] = $obj; $this->_ManyMappingData[$varName][$fieldName] = $info; } $pkey = $info[1]; if ($obj->IsLoaded() && $this->_ManyMappedLinks[$fieldName]) { return $obj; } // echo get_class($obj) . '-'; $res = $obj->FindManyByField($pkey, $this->_Data[$fieldName]); if ($res == false) { return null; } $res = new Z_Array($res); $this->_ManyMappingData[$varName] = array($fieldName => array($res, $pkey)); $this->_ManyMappedLinks[$fieldName] = array($res, $pkey); return $res; } } return null; }
<?php $config['db_host'] = "localhost"; $config['db_user'] = ""; $config['db_password'] = ""; $config['db_database'] = ""; $config['debug'] = true; $config['admin_password'] = ""; Z::configMerge($config);
** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/js/administration.general.gui.php'; $comboTheme = new CComboBox('default_theme', $this->data['config']['default_theme'], null, Z::getThemes()); $comboDdFirstEntry = new CComboBox('dropdown_first_entry', $this->data['config']['dropdown_first_entry']); $comboDdFirstEntry->addItem(ZBX_DROPDOWN_FIRST_NONE, _('None')); $comboDdFirstEntry->addItem(ZBX_DROPDOWN_FIRST_ALL, _('All')); $guiTab = new CFormList('scriptsTab'); $guiTab->addRow(_('Default theme'), array($comboTheme)); $guiTab->addRow(_('Dropdown first entry'), array($comboDdFirstEntry, new CCheckBox('dropdown_first_remember', $this->data['config']['dropdown_first_remember'], null, 1), _('remember selected'))); $guiTab->addRow(_('Search/Filter elements limit'), new CNumericBox('search_limit', $this->data['config']['search_limit'], 6)); $guiTab->addRow(_('Max count of elements to show inside table cell'), new CNumericBox('max_in_table', $this->data['config']['max_in_table'], 5)); $guiTab->addRow(_('Enable event acknowledges'), new CCheckBox('event_ack_enable', $this->data['config']['event_ack_enable'], null, 1)); $guiTab->addRow(_('Show events not older than (in days)'), new CTextBox('event_expire', $this->data['config']['event_expire'], 5)); $guiTab->addRow(_('Max count of events per trigger to show'), new CTextBox('event_show_max', $this->data['config']['event_show_max'], 5)); $guiTab->addRow(_('Show warning if Zabbix server is down'), new CCheckBox('server_check_interval', $this->data['config']['server_check_interval'], null, SERVER_CHECK_INTERVAL)); $guiView = new CTabView(); $guiView->addTab('gui', _('GUI'), $guiTab); $guiForm = new CForm();
protected function checkInput(&$users, $method) { $create = $method === 'create'; $update = $method === 'update'; if ($update) { $userDBfields = array('userid' => null); $dbUsers = $this->get(array('output' => array('userid', 'alias', 'autologin', 'autologout'), 'userids' => zbx_objectValues($users, 'userid'), 'editable' => true, 'preservekeys' => true)); } else { $userDBfields = array('alias' => null, 'passwd' => null, 'usrgrps' => null, 'user_medias' => array()); } $themes = array_keys(Z::getThemes()); $themes[] = THEME_DEFAULT; $themeValidator = new CSetValidator(array('values' => $themes)); $alias = array(); foreach ($users as &$user) { if (!check_db_fields($userDBfields, $user)) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('Wrong fields for user "%s".', $user['alias'])); } // permissions if ($create) { if (self::$userData['type'] != USER_TYPE_SUPER_ADMIN) { self::exception(ZBX_API_ERROR_PARAMETERS, _('You do not have permissions to create users.')); } $dbUser = $user; } elseif ($update) { if (!isset($dbUsers[$user['userid']])) { self::exception(ZBX_API_ERROR_PARAMETERS, _('You do not have permissions to update user or user does not exist.')); } if (bccomp(self::$userData['userid'], $user['userid']) != 0 && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) { self::exception(ZBX_API_ERROR_PARAMETERS, _('You do not have permissions to update other users.')); } $dbUser = $dbUsers[$user['userid']]; } // check if user alias if (isset($user['alias'])) { // check if we change guest user if ($dbUser['alias'] === ZBX_GUEST_USER && $user['alias'] !== ZBX_GUEST_USER) { self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot rename guest user.')); } if (!isset($alias[$user['alias']])) { $alias[$user['alias']] = $update ? $user['userid'] : 1; } else { if ($create || bccomp($user['userid'], $alias[$user['alias']]) != 0) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('Duplicate user alias "%s".', $user['alias'])); } } if (zbx_strlen($user['alias']) > 64) { self::exception(ZBX_API_ERROR_PARAMETERS, _n('Maximum alias length is %1$d characters, "%2$s" is %3$d character.', 'Maximum alias length is %1$d characters, "%2$s" is %3$d characters.', 64, $user['alias'], zbx_strlen($user['alias']))); } } if (isset($user['usrgrps'])) { if (empty($user['usrgrps'])) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('User "%s" cannot be without user group.', $dbUser['alias'])); } // checking if user tries to disable himself (not allowed). No need to check this on creating a user. if (!$create && bccomp(self::$userData['userid'], $user['userid']) == 0) { $usrgrps = API::UserGroup()->get(array('usrgrpids' => zbx_objectValues($user['usrgrps'], 'usrgrpid'), 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'nopermissions' => true)); foreach ($usrgrps as $groupid => $group) { if ($group['gui_access'] == GROUP_GUI_ACCESS_DISABLED) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('User may not modify GUI access for himself by becoming a member of user group "%s".', $group['name'])); } if ($group['users_status'] == GROUP_STATUS_DISABLED) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('User may not modify system status for himself by becoming a member of user group "%s".', $group['name'])); } } } } if (isset($user['theme'])) { $themeValidator->messageInvalid = _s('Incorrect theme for user "%1$s".', $dbUser['alias']); $this->checkValidator($user['theme'], $themeValidator); } if (isset($user['type']) && USER_TYPE_SUPER_ADMIN != self::$userData['type']) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('You are not allowed to alter privileges for user "%s".', $dbUser['alias'])); } if (isset($user['autologin']) && $user['autologin'] == 1 && $dbUser['autologout'] != 0) { $user['autologout'] = 0; } if (isset($user['autologout']) && $user['autologout'] > 0 && $dbUser['autologin'] != 0) { $user['autologin'] = 0; } if (array_key_exists('passwd', $user)) { if (is_null($user['passwd'])) { unset($user['passwd']); } else { if ($dbUser['alias'] == ZBX_GUEST_USER && !zbx_empty($user['passwd'])) { self::exception(ZBX_API_ERROR_PARAMETERS, _('Not allowed to set password for user "guest".')); } $user['passwd'] = md5($user['passwd']); } } if (isset($user['alias'])) { $nodeids = $update ? id2nodeid($user['userid']) : get_current_nodeid(false); $userExist = $this->get(array('nodeids' => $nodeids, 'filter' => array('alias' => $user['alias']), 'nopermissions' => true)); if ($exUser = reset($userExist)) { if ($create || bccomp($exUser['userid'], $user['userid']) != 0) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('User with alias "%s" already exists.', $user['alias'])); } } } } unset($user); }
<!--[if IE 9]> <body class="ie ie9" ><![endif]--> <!--[if IE 8]> <body class="ie ie8" ><![endif]--> <!--[if IE 7]> <body class="ie ie7" ><![endif]--> <!--[if IE 6]> <body class="ie ie6" ><![endif]--> <!--[if !IE]>--><body class="not-ie"><!--<![endif]--> <script src="../js/lib/browserdetect.js" ></script> <script src="../js/init.js" ></script> <?php include Z::getFile('page'); ?> <script src="../js/lib/jquery.js" ></script> <script src="../js/lib/jquery.migrate.js" ></script> <script src="../js/behaviours.js" ></script> <script src="../js/lib/jquery.hashgrid.js" ></script> </body>
** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/include/classes/core/Z.php'; try { Z::getInstance()->run(ZBase::EXEC_MODE_SETUP); } catch (Exception $e) { $warningView = new CView('general.warning', array('message' => 'Configuration file error: ' . $e->getMessage())); $warningView->render(); exit; } require_once dirname(__FILE__) . '/include/setup.inc.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('type' => array(T_ZBX_STR, O_OPT, null, IN('"' . ZBX_DB_MYSQL . '","' . ZBX_DB_POSTGRESQL . '","' . ZBX_DB_ORACLE . '","' . ZBX_DB_DB2 . '","' . ZBX_DB_SQLITE3 . '"'), null), 'server' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null, _('Database host')), 'port' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Database port')), 'database' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null, _('Database name')), 'user' => array(T_ZBX_STR, O_OPT, null, null, null), 'password' => array(T_ZBX_STR, O_OPT, null, null, null), 'schema' => array(T_ZBX_STR, O_OPT, null, null, null), 'zbx_server' => array(T_ZBX_STR, O_OPT, null, null, null), 'zbx_server_name' => array(T_ZBX_STR, O_OPT, null, null, null), 'zbx_server_port' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 65535), null, _('Port')), 'message' => array(T_ZBX_STR, O_OPT, null, null, null), 'save_config' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'retry' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'finish' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'next' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'back' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null)); // config $ZBX_CONFIG = get_cookie('ZBX_CONFIG', null); $ZBX_CONFIG = isset($ZBX_CONFIG) ? unserialize($ZBX_CONFIG) : array(); $ZBX_CONFIG['check_fields_result'] = check_fields($fields, false); if (!isset($ZBX_CONFIG['step'])) { $ZBX_CONFIG['step'] = 0; }
<?php trait T { private $x = 0; } class X { use T; } class Y extends X { use T; function __construct() { return ++$this->x; } } class Z extends Y { function __construct() { return ++$this->x; } } $a = new Z(); $a->__construct(); echo "DONE";
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ // reset the LC_CTYPE locale so that case transformation functions would work correctly // it is also required for PHP to work with the Turkish locale (https://bugs.php.net/bug.php?id=18556) // WARNING: this must be done before executing any other code, otherwise code execution could fail! // this will be unnecessary in PHP 5.5 setlocale(LC_CTYPE, array('C', 'POSIX', 'en', 'en_US', 'en_US.UTF-8', 'English_United States.1252', 'en_GB', 'en_GB.UTF-8')); require_once dirname(__FILE__) . '/classes/core/Z.php'; try { Z::getInstance()->run(); } catch (DBException $e) { $warningView = new CView('general.warning', array('message' => array('header' => 'Database error', 'text' => $e->getMessage()))); $warningView->render(); exit; } catch (ConfigFileException $e) { switch ($e->getCode()) { case CConfigFile::CONFIG_NOT_FOUND: redirect('setup.php'); exit; case CConfigFile::CONFIG_ERROR: $warningView = new CView('general.warning', array('message' => array('header' => 'Configuration file error', 'text' => $e->getMessage()))); $warningView->render(); exit; } } catch (Exception $e) {
public static function getConfig($class = '') { if ($class == '') { return Z::getGlobal(Z_CONFIG); } $config = Z::getGlobal(Z_CONFIG); if (!isset($config->{$class})) { $config->{$class} = new stdClass(); } return $config->{$class}; }
$languageComboBox->addItem($localeId, $locale['name'], $localeId == $this->data['lang'] ? true : null, $localeExists); $allLocalesAvailable &= $localeExists; } } // restoring original locale setlocale(LC_MONETARY, zbx_locale_variants(CWebUser::$data['lang'])); $languageError = ''; if (!function_exists('bindtextdomain')) { $languageError = 'Translations are unavailable because the PHP gettext module is missing.'; $languageComboBox->attr('disabled', 'disabled'); } elseif (!$allLocalesAvailable) { $languageError = _('You are not able to choose some of the languages, because locales for them are not installed on the web server.'); } $userFormList->addRow(_('Language'), $languageError ? array($languageComboBox, SPACE, new CSpan($languageError, 'red wrap')) : $languageComboBox); // append themes to form list $themes = array_merge(array(THEME_DEFAULT => _('System default')), Z::getThemes()); $themeComboBox = new CComboBox('theme', $this->data['theme'], null, $themes); $userFormList->addRow(_('Theme'), $themeComboBox); // append auto-login & auto-logout to form list $autologoutCheckBox = new CCheckBox('autologout_visible', isset($this->data['autologout']) ? 'yes' : 'no'); if (isset($this->data['autologout'])) { $autologoutTextBox = new CNumericBox('autologout', $this->data['autologout'], 4); } else { $autologoutTextBox = new CNumericBox('autologout', 900, 4); $autologoutTextBox->setAttribute('disabled', 'disabled'); } if ($this->data['alias'] != ZBX_GUEST_USER) { $userFormList->addRow(_('Auto-login'), new CCheckBox('autologin', $this->data['autologin'], null, 1)); $userFormList->addRow(_('Auto-logout (min 90 seconds)'), array($autologoutCheckBox, $autologoutTextBox)); } $userFormList->addRow(_('Refresh (in seconds)'), new CNumericBox('refresh', $this->data['refresh'], 4));
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/include/config.inc.php'; require_once dirname(__FILE__) . '/include/users.inc.php'; require_once dirname(__FILE__) . '/include/forms.inc.php'; require_once dirname(__FILE__) . '/include/media.inc.php'; $page['title'] = _('User profile'); $page['file'] = 'profile.php'; $page['hist_arg'] = array(); $page['scripts'] = array('class.cviewswitcher.js'); ob_start(); require_once dirname(__FILE__) . '/include/page_header.php'; if (CWebUser::$data['alias'] == ZBX_GUEST_USER) { access_deny(); } $themes = array_keys(Z::getThemes()); $themes[] = THEME_DEFAULT; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('password1' => array(T_ZBX_STR, O_OPT, null, null, 'isset({update}) && isset({form}) && ({form} != "update") && isset({change_password})'), 'password2' => array(T_ZBX_STR, O_OPT, null, null, 'isset({update}) && isset({form}) && ({form} != "update") && isset({change_password})'), 'lang' => array(T_ZBX_STR, O_OPT, null, null, null), 'theme' => array(T_ZBX_STR, O_OPT, null, IN('"' . implode('","', $themes) . '"'), 'isset({update})'), 'autologin' => array(T_ZBX_INT, O_OPT, null, IN('1'), null), 'autologout' => array(T_ZBX_INT, O_OPT, null, BETWEEN(90, 10000), null, _('Auto-logout (min 90 seconds)')), 'autologout_visible' => array(T_ZBX_STR, O_OPT, null, IN('1'), null), 'url' => array(T_ZBX_STR, O_OPT, null, null, 'isset({update})'), 'refresh' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, SEC_PER_HOUR), 'isset({update})', _('Refresh (in seconds)')), 'rows_per_page' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 999999), 'isset({update})', _('Rows per page')), 'change_password' => array(T_ZBX_STR, O_OPT, null, null, null), 'user_medias' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null), 'user_medias_to_del' => array(T_ZBX_STR, O_OPT, null, DB_ID, null), 'new_media' => array(T_ZBX_STR, O_OPT, null, null, null), 'enable_media' => array(T_ZBX_INT, O_OPT, null, null, null), 'disable_media' => array(T_ZBX_INT, O_OPT, null, null, null), 'messages' => array(T_ZBX_STR, O_OPT, null, null, null), 'update' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'del_user_media' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null)); check_fields($fields); $_REQUEST['autologin'] = getRequest('autologin', 0); // secondary actions if (isset($_REQUEST['new_media'])) { $_REQUEST['user_medias'] = getRequest('user_medias', array()); array_push($_REQUEST['user_medias'], $_REQUEST['new_media']); } elseif (isset($_REQUEST['user_medias']) && isset($_REQUEST['enable_media'])) { if (isset($_REQUEST['user_medias'][$_REQUEST['enable_media']])) { $_REQUEST['user_medias'][$_REQUEST['enable_media']]['active'] = 0; } } elseif (isset($_REQUEST['user_medias']) && isset($_REQUEST['disable_media'])) { if (isset($_REQUEST['user_medias'][$_REQUEST['disable_media']])) {
<?php trait T { private $x = 0; } class X { use T; } class Y extends X { use T; function x() { return ++$this->x; } } class Z extends Y { function z() { return ++$this->x; } } $a = new Z(); $a->x(); echo "DONE";
/** * Clean all dictionaries */ function clean() { Z::c()->query("DELETE FROM t_dic"); Z::c()->query("DELETE FROM t_idx"); }
<?php /* ** Zabbix ** Copyright (C) 2001-2016 Zabbix SIA ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/js/administration.general.gui.php'; $widget = (new CWidget())->setTitle(_('GUI'))->setControls((new CForm())->cleanItems()->addItem((new CList())->addItem(makeAdministrationGeneralMenu('adm.gui.php')))); $guiTab = (new CFormList())->addRow(_('Default theme'), new CComboBox('default_theme', $data['default_theme'], null, Z::getThemes()))->addRow(_('Dropdown first entry'), [new CComboBox('dropdown_first_entry', $data['dropdown_first_entry'], null, [ZBX_DROPDOWN_FIRST_NONE => _('None'), ZBX_DROPDOWN_FIRST_ALL => _('All')]), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), new CLabel([(new CCheckBox('dropdown_first_remember'))->setChecked($data['dropdown_first_remember'] == 1), _('remember selected')], 'dropdown_first_remember')])->addRow(_('Search/Filter elements limit'), (new CNumericBox('search_limit', $data['search_limit'], 6))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH))->addRow(_('Max count of elements to show inside table cell'), (new CNumericBox('max_in_table', $data['max_in_table'], 5))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH))->addRow(_('Enable event acknowledges'), (new CCheckBox('event_ack_enable'))->setChecked($data['event_ack_enable'] == 1))->addRow(_('Show events not older than (in days)'), (new CTextBox('event_expire', $data['event_expire']))->setWidth(ZBX_TEXTAREA_TINY_WIDTH))->addRow(_('Max count of events per trigger to show'), (new CTextBox('event_show_max', $data['event_show_max']))->setWidth(ZBX_TEXTAREA_TINY_WIDTH))->addRow(_('Show warning if Zabbix server is down'), (new CCheckBox('server_check_interval', SERVER_CHECK_INTERVAL))->setChecked($data['server_check_interval'] == SERVER_CHECK_INTERVAL)); $guiView = (new CTabView())->addTab('gui', _('GUI'), $guiTab)->setFooter(makeFormFooter(new CSubmit('update', _('Update')))); $guiForm = (new CForm())->addItem($guiView); $widget->addItem($guiForm); return $widget;
/** * Some application-specific defines */ define('DEMO_LIBRARY', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . 'library')); /** * Require the Z framework. Make sure it is on the include path! * Otherwise unpack the Z framework in the library folder, and uncomment this */ @set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR)); /** * Include the Z core class (being simply 'Z') */ require_once '../../library/Z/Z.php'; /** * Create a new application instance, feeding in our configuration */ $application = Z::createApplication('application/config.inc.php'); /** * Load our 'routing table' configuration and other misc options */ require_once 'application/misc.inc.php'; /** * Run it (Error handling not yet correctly done :/) */ try { $application->run(); } catch (Exception $ex) { ob_end_clean(); echo "An exception occured: " . $ex->getMessage() . "\r\nFile: " . $ex->getFile() . "\r\nLine: " . $ex->getLine() . "\r\nStacktrace: \r\n\r\n"; echo $ex->getTraceAsString(); }
function eventHandler() { if (isset($_REQUEST['back'][$this->getStep()])) { $this->doBack(); } if ($this->getStep() == 1) { if (isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } $this->DISABLE_NEXT_BUTTON = true; } elseif ($this->getStep() == 2) { $this->setConfig('DB_TYPE', get_request('type', $this->getConfig('DB_TYPE'))); $this->setConfig('DB_SERVER', get_request('server', $this->getConfig('DB_SERVER', 'localhost'))); $this->setConfig('DB_PORT', get_request('port', $this->getConfig('DB_PORT', '0'))); $this->setConfig('DB_DATABASE', get_request('database', $this->getConfig('DB_DATABASE', 'zabbix'))); $this->setConfig('DB_USER', get_request('user', $this->getConfig('DB_USER', 'root'))); $this->setConfig('DB_PASSWORD', get_request('password', $this->getConfig('DB_PASSWORD', ''))); $this->setConfig('DB_SCHEMA', get_request('schema', $this->getConfig('DB_SCHEMA', ''))); if (isset($_REQUEST['retry'])) { if (!$this->checkConnection()) { $this->DISABLE_NEXT_BUTTON = true; unset($_REQUEST['next']); } } elseif (!isset($_REQUEST['next'][$this->getStep()])) { $this->DISABLE_NEXT_BUTTON = true; unset($_REQUEST['next']); } if (isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } } elseif ($this->getStep() == 3) { $this->setConfig('ZBX_SERVER', get_request('zbx_server', $this->getConfig('ZBX_SERVER', 'localhost'))); $this->setConfig('ZBX_SERVER_PORT', get_request('zbx_server_port', $this->getConfig('ZBX_SERVER_PORT', '10051'))); $this->setConfig('ZBX_SERVER_NAME', get_request('zbx_server_name', $this->getConfig('ZBX_SERVER_NAME', ''))); if (isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } } elseif ($this->getStep() == 4 && isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } elseif ($this->getStep() == 5) { if (isset($_REQUEST['save_config'])) { // make zabbix.conf.php downloadable header('Content-Type: application/x-httpd-php'); header('Content-Disposition: attachment; filename="' . basename(CConfigFile::CONFIG_FILE_PATH) . '"'); $config = new CConfigFile(Z::getInstance()->getRootDir() . CConfigFile::CONFIG_FILE_PATH); $config->config = array('DB' => array('TYPE' => $this->getConfig('DB_TYPE'), 'SERVER' => $this->getConfig('DB_SERVER'), 'PORT' => $this->getConfig('DB_PORT'), 'DATABASE' => $this->getConfig('DB_DATABASE'), 'USER' => $this->getConfig('DB_USER'), 'PASSWORD' => $this->getConfig('DB_PASSWORD'), 'SCHEMA' => $this->getConfig('DB_SCHEMA')), 'ZBX_SERVER' => $this->getConfig('ZBX_SERVER'), 'ZBX_SERVER_PORT' => $this->getConfig('ZBX_SERVER_PORT'), 'ZBX_SERVER_NAME' => $this->getConfig('ZBX_SERVER_NAME')); die($config->getString()); } } if (isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } }
break; } } array_multisort($sortClock, SORT_ASC, $sortEvent, SORT_ASC, $result); 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': $session = Z::getInstance()->getSession(); if (!isset($session['serverCheckResult']) || $session['serverCheckTime'] + SERVER_CHECK_INTERVAL <= time()) { $zabbixServer = new CZabbixServer($ZBX_SERVER, $ZBX_SERVER_PORT, ZBX_SOCKET_TIMEOUT, 0); $session['serverCheckResult'] = $zabbixServer->isRunning(); $session['serverCheckTime'] = time(); } $result = array('result' => (bool) $session['serverCheckResult'], 'message' => $session['serverCheckResult'] ? '' : _('Zabbix server is not running: the information displayed may not be current.')); break; case 'screen.get': $options = array('pageFile' => !empty($data['pageFile']) ? $data['pageFile'] : null, 'mode' => !empty($data['mode']) ? $data['mode'] : null, 'timestamp' => !empty($data['timestamp']) ? $data['timestamp'] : time(), 'resourcetype' => !empty($data['resourcetype']) ? $data['resourcetype'] : null, 'screenid' => isset($data['screenid']) && $data['screenid'] != 0 ? $data['screenid'] : null, 'screenitemid' => !empty($data['screenitemid']) ? $data['screenitemid'] : null, 'groupid' => !empty($data['groupid']) ? $data['groupid'] : null, 'hostid' => !empty($data['hostid']) ? $data['hostid'] : null, 'period' => !empty($data['period']) ? $data['period'] : null, 'stime' => !empty($data['stime']) ? $data['stime'] : null, 'profileIdx' => !empty($data['profileIdx']) ? $data['profileIdx'] : null, 'profileIdx2' => !empty($data['profileIdx2']) ? $data['profileIdx2'] : null, 'updateProfile' => isset($data['updateProfile']) ? $data['updateProfile'] : null); if ($options['resourcetype'] == SCREEN_RESOURCE_HISTORY) { $options['itemids'] = !empty($data['itemids']) ? $data['itemids'] : null; $options['action'] = !empty($data['action']) ? $data['action'] : null; $options['filter'] = !empty($data['filter']) ? $data['filter'] : null; $options['filter_task'] = !empty($data['filter_task']) ? $data['filter_task'] : null; $options['mark_color'] = !empty($data['mark_color']) ? $data['mark_color'] : null;
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/include/func.inc.php'; require_once dirname(__FILE__) . '/include/classes/class.chttp_request.php'; $allowed_content = array('application/json-rpc' => 'json-rpc', 'application/json' => 'json-rpc', 'application/jsonrequest' => 'json-rpc'); $http_request = new CHTTP_request(); $content_type = $http_request->header('Content-Type'); $content_type = explode(';', $content_type); $content_type = $content_type[0]; if (!isset($allowed_content[$content_type])) { header('HTTP/1.0 412 Precondition Failed'); exit; } require_once dirname(__FILE__) . '/include/classes/core/Z.php'; header('Content-Type: application/json'); $data = $http_request->body(); try { Z::getInstance()->run(ZBase::EXEC_MODE_API); $jsonRpc = new CJSONrpc($data); echo $jsonRpc->execute(); } catch (Exception $e) { // decode input json request to get request's id $jsonData = CJs::decodeJson($data); $response = array('jsonrpc' => '2.0', 'error' => array('code' => 1, 'message' => $e->getMessage()), 'id' => isset($jsonData['id']) ? $jsonData['id'] : null); echo CJs::encodeJson($response); }
function configMerge($upd) { self::$config = array_merge(self::$config, $upd); }