本文整理汇总了PHP中Toolbox::decrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::decrypt方法的具体用法?PHP Toolbox::decrypt怎么用?PHP Toolbox::decrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toolbox
的用法示例。
在下文中一共展示了Toolbox::decrypt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
**/
function __construct()
{
global $CFG_GLPI;
$this->WordWrap = 80;
$this->CharSet = "utf-8";
// Comes from config
$this->SetLanguage("en", Config::getLibraryDir("PHPMailer") . "/language/");
if ($CFG_GLPI['smtp_mode'] != MAIL_MAIL) {
$this->Mailer = "smtp";
$this->Host = $CFG_GLPI['smtp_host'] . ':' . $CFG_GLPI['smtp_port'];
if ($CFG_GLPI['smtp_username'] != '') {
$this->SMTPAuth = true;
$this->Username = $CFG_GLPI['smtp_username'];
$this->Password = Toolbox::decrypt($CFG_GLPI['smtp_passwd'], GLPIKEY);
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPSSL) {
$this->SMTPSecure = "ssl";
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPTLS) {
$this->SMTPSecure = "tls";
}
if (!$CFG_GLPI['smtp_check_certificate']) {
$this->SMTPOptions = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true));
}
}
if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
$this->do_debug = 3;
}
}
示例2: __construct
/**
* Constructor
*
**/
function __construct()
{
global $CFG_GLPI;
$this->WordWrap = 80;
$this->CharSet = "utf-8";
// Comes from config
$this->SetLanguage("en", GLPI_PHPMAILER_DIR . "/language/");
if ($CFG_GLPI['smtp_mode'] != MAIL_MAIL) {
$this->Mailer = "smtp";
$this->Host = $CFG_GLPI['smtp_host'] . ':' . $CFG_GLPI['smtp_port'];
if ($CFG_GLPI['smtp_username'] != '') {
$this->SMTPAuth = true;
$this->Username = $CFG_GLPI['smtp_username'];
$this->Password = Toolbox::decrypt($CFG_GLPI['smtp_passwd'], GLPIKEY);
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPSSL) {
$this->SMTPSecure = "ssl";
}
if ($CFG_GLPI['smtp_mode'] == MAIL_SMTPTLS) {
$this->SMTPSecure = "tls";
}
}
if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
$this->do_debug = 3;
}
}
示例3: cURLData
static function cURLData($options)
{
global $CFG_GLPI;
if (!function_exists('curl_init')) {
return __('Curl PHP package not installed', 'manufacturersimports') . "\n";
}
$data = '';
$timeout = 10;
$proxy_host = $CFG_GLPI["proxy_name"] . ":" . $CFG_GLPI["proxy_port"];
// host:port
$proxy_ident = $CFG_GLPI["proxy_user"] . ":" . Toolbox::decrypt($CFG_GLPI["proxy_passwd"], GLPIKEY);
// username:password
$ch = curl_init($options["url"]);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
if (preg_match('`^https://`i', $options["url"])) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
}
if (!$options["download"]) {
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
}
// Activation de l'utilisation d'un serveur proxy
if (!empty($CFG_GLPI["proxy_name"])) {
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
// Définition de l'adresse du proxy
curl_setopt($ch, CURLOPT_PROXY, $proxy_host);
// Définition des identifiants si le proxy requiert une identification
if ($proxy_ident) {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_ident);
}
}
if ($options["download"]) {
$fp = fopen($options["file"], "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
} else {
$data = curl_exec($ch);
}
curl_close($ch);
if ($options["download"]) {
fclose($fp);
}
if (!$options["download"] && $data) {
return $data;
}
}
示例4: __construct
function __construct($options = array())
{
global $CFG_GLPI;
if (!isset($options['exceptions'])) {
$options['exceptions'] = false;
}
$options['features'] = SOAP_SINGLE_ELEMENT_ARRAYS;
if (!empty($CFG_GLPI["proxy_name"])) {
$options['proxy_host'] = $CFG_GLPI["proxy_name"];
$options['proxy_port'] = intval($CFG_GLPI["proxy_port"]);
$options['proxy_login'] = $CFG_GLPI["proxy_user"];
$options['proxy_password'] = Toolbox::decrypt($CFG_GLPI["proxy_passwd"], GLPIKEY);
}
parent::__construct(self::ADDR, $options);
}
示例5: connect
function connect()
{
$PluginSccmConfig = new PluginSccmConfig();
$PluginSccmConfig->getFromDB(1);
$host = $PluginSccmConfig->getField('sccmdb_host');
$dbname = $PluginSccmConfig->getField('sccmdb_dbname');
$user = $PluginSccmConfig->getField('sccmdb_user');
$password = $PluginSccmConfig->getField('sccmdb_password');
$password = Toolbox::decrypt($password, GLPIKEY);
$this->dbconn = mssql_connect($host, $user, $password) or die('Connection error : ' . mssql_get_last_message());
if (!mssql_select_db($dbname, $this->dbconn)) {
die('Unable to connect do DB!' . mssql_get_last_message());
}
return true;
}
示例6: connect
/**
* Connect to the mail box
**/
function connect()
{
if (version_compare(PHP_VERSION, '5.3.2', '<') || $this->fields['use_kerberos']) {
$this->marubox = @imap_open($this->fields['host'], $this->fields['login'], Toolbox::decrypt($this->fields['passwd'], GLPIKEY), CL_EXPUNGE, 1);
} else {
$this->marubox = @imap_open($this->fields['host'], $this->fields['login'], Toolbox::decrypt($this->fields['passwd'], GLPIKEY), CL_EXPUNGE, 1, array('DISABLE_AUTHENTICATOR' => 'GSSAPI'));
}
// Reset errors
if ($this->marubox) {
// call this to avoid the mailbox is empty error message
if (imap_num_msg($this->marubox) == 0) {
$errors = imap_errors();
}
if ($this->fields['errors'] > 0) {
$this->update(array('id' => $this->getID(), 'errors' => 0));
}
} else {
$this->update(array('id' => $this->getID(), 'errors' => $this->fields['errors'] + 1));
}
}
示例7: Login
/**
* Manage use authentication and initialize the session
*
* @param $login_name string
* @param $login_password string
* @param $noauto boolean (false by default)
*
* @return boolean (success)
*/
function Login($login_name, $login_password, $noauto = false)
{
global $DB, $CFG_GLPI;
$this->getAuthMethods();
$this->user_present = 1;
$this->auth_succeded = false;
//In case the user was deleted in the LDAP directory
$user_deleted_ldap = false;
// Trim login_name : avoid LDAP search errors
$login_name = trim($login_name);
if (!$noauto && ($authtype = self::checkAlternateAuthSystems())) {
if ($this->getAlternateAuthSystemsUserLogin($authtype) && !empty($this->user->fields['name'])) {
// Used for log when login process failed
$login_name = $this->user->fields['name'];
$this->auth_succeded = true;
$this->extauth = 1;
$this->user_present = $this->user->getFromDBbyName(addslashes($login_name));
$this->user->fields['authtype'] = $authtype;
$user_dn = false;
$ldapservers = '';
//if LDAP enabled too, get user's infos from LDAP
if (Toolbox::canUseLdap()) {
$ldapservers = array();
//User has already authenticate, at least once : it's ldap server if filled
if (isset($this->user->fields["auths_id"]) && $this->user->fields["auths_id"] > 0) {
$authldap = new AuthLdap();
//If ldap server is enabled
if ($authldap->getFromDB($this->user->fields["auths_id"]) && $authldap->fields['is_active']) {
$ldapservers[] = $authldap->fields;
}
//User has never beeen authenticated : try all active ldap server to find the right one
} else {
foreach (getAllDatasFromTable('glpi_authldaps', "`is_active`='1'") as $ldap_config) {
$ldapservers[] = $ldap_config;
}
}
foreach ($ldapservers as $ldap_method) {
$ds = AuthLdap::connectToServer($ldap_method["host"], $ldap_method["port"], $ldap_method["rootdn"], Toolbox::decrypt($ldap_method["rootdn_passwd"], GLPIKEY), $ldap_method["use_tls"], $ldap_method["deref_option"]);
if ($ds) {
$params['method'] = AuthLdap::IDENTIFIER_LOGIN;
$params['fields'][AuthLdap::IDENTIFIER_LOGIN] = $ldap_method["login_field"];
$user_dn = AuthLdap::searchUserDn($ds, array('basedn' => $ldap_method["basedn"], 'login_field' => $ldap_method['login_field'], 'search_parameters' => $params, 'user_params' => array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $login_name), 'condition' => $ldap_method["condition"]));
if ($user_dn) {
$this->user->fields['auths_id'] = $ldap_method['id'];
$this->user->getFromLDAP($ds, $ldap_method, $user_dn['dn'], $login_name, !$this->user_present);
break;
}
}
}
}
if (count($ldapservers) == 0 && $authtype == self::EXTERNAL) {
// Case of using external auth and no LDAP servers, so get data from external auth
$this->user->getFromSSO();
} else {
//If user is set as present in GLPI but no LDAP DN found : it means that the user
//is not present in an ldap directory anymore
if (!$user_dn && $this->user_present) {
$user_deleted_ldap = true;
$this->user_deleted_ldap = true;
}
}
// Reset to secure it
$this->user->fields['name'] = $login_name;
$this->user->fields["last_login"] = $_SESSION["glpi_currenttime"];
} else {
$this->addToError(__('Empty login or password'));
}
}
// If not already auth
if (!$this->auth_succeded) {
if (empty($login_name) || strstr($login_name, "") || empty($login_password) || strstr($login_password, "")) {
$this->addToError(__('Empty login or password'));
} else {
// exists=0 -> user doesn't yet exist
// exists=1 -> user is present in DB with password
// exists=2 -> user is present in DB but without password
$exists = $this->userExists(array('name' => addslashes($login_name)));
// Pas en premier car sinon on ne fait pas le blankpassword
// First try to connect via le DATABASE
if ($exists == 1) {
// Without UTF8 decoding
if (!$this->auth_succeded) {
$this->auth_succeded = $this->connection_db(addslashes($login_name), $login_password);
if ($this->auth_succeded) {
$this->extauth = 0;
$this->user_present = $this->user->getFromDBbyName(addslashes($login_name));
$this->user->fields["authtype"] = self::DB_GLPI;
$this->user->fields["password"] = $login_password;
}
}
} else {
//.........这里部分代码省略.........
示例8: searchUser
/**
* @param $authldap AuthLDAP object
**/
static function searchUser(AuthLDAP $authldap)
{
if (self::connectToServer($authldap->getField('host'), $authldap->getField('port'), $authldap->getField('rootdn'), Toolbox::decrypt($authldap->getField('rootdn_passwd'), GLPIKEY), $authldap->getField('use_tls'), $authldap->getField('deref_option'))) {
self::showLdapUsers();
} else {
echo "<div class='center b firstbloc'>" . __('Unable to connect to the LDAP directory');
}
}
示例9: getRSSFeed
/**
* Get a specific RSS feed
*
* @param $url string/array URL of the feed or array of URL
* @param $cache_duration timestamp cache duration (default DAY_TIMESTAMP)
*
* @return feed object
**/
static function getRSSFeed($url, $cache_duration = DAY_TIMESTAMP)
{
global $CFG_GLPI;
$feed = new SimplePie();
$feed->set_cache_location(GLPI_RSS_DIR);
$feed->set_cache_duration($cache_duration);
// proxy support
if (!empty($CFG_GLPI["proxy_name"])) {
$prx_opt = array();
$prx_opt[CURLOPT_PROXY] = $CFG_GLPI["proxy_name"];
$prx_opt[CURLOPT_PROXYPORT] = $CFG_GLPI["proxy_port"];
if (!empty($CFG_GLPI["proxy_user"])) {
$prx_opt[CURLOPT_HTTPAUTH] = CURLAUTH_ANYSAFE;
$prx_opt[CURLOPT_PROXYUSERPWD] = $CFG_GLPI["proxy_user"] . ":" . Toolbox::decrypt($CFG_GLPI["proxy_passwd"], GLPIKEY);
}
$feed->set_curl_options($prx_opt);
}
$feed->enable_cache(true);
$feed->set_feed_url($url);
$feed->force_feed(true);
// Initialize the whole SimplePie object. Read the feed, process it, parse it, cache it, and
// all that other good stuff. The feed's information will not be available to SimplePie before
// this is called.
$feed->init();
// We'll make sure that the right content type and character encoding gets set automatically.
// This function will grab the proper character encoding, as well as set the content type to text/html.
$feed->handle_content_type();
if ($feed->error()) {
return false;
}
return $feed;
}
示例10: cURLData
static function cURLData($options)
{
global $CFG_GLPI;
if (!function_exists('curl_init')) {
return __('Curl PHP package not installed', 'manufacturersimports') . "\n";
}
$data = '';
$timeout = 10;
$proxy_host = $CFG_GLPI["proxy_name"] . ":" . $CFG_GLPI["proxy_port"];
// host:port
$proxy_ident = $CFG_GLPI["proxy_user"] . ":" . Toolbox::decrypt($CFG_GLPI["proxy_passwd"], GLPIKEY);
// username:password
$url = $options["url"];
$ch = curl_init();
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
if (preg_match('`^https://`i', $options["url"])) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
# SAME cookiefile
//Do we have post field to send?
if (!empty($options["post"])) {
//curl_setopt($ch, CURLOPT_POST,true);
$post = '';
foreach ($options['post'] as $key => $value) {
$post .= $key . '=' . $value . '&';
}
rtrim($post, '&');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/x-www-form-urlencoded"));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTREDIR, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if (!$options["download"]) {
//curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
}
// Activation de l'utilisation d'un serveur proxy
if (!empty($CFG_GLPI["proxy_name"])) {
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
// Définition de l'adresse du proxy
curl_setopt($ch, CURLOPT_PROXY, $proxy_host);
// Définition des identifiants si le proxy requiert une identification
if ($proxy_ident) {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_ident);
}
}
if ($options["download"]) {
$fp = fopen($options["file"], "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
} else {
$data = curl_exec($ch);
}
if (!$options["download"] && !$data) {
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// make sure we closeany current curl sessions
//die($http_code.' Unable to connect to server. Please come back later.');
} else {
curl_close($ch);
}
if ($options["download"]) {
fclose($fp);
}
if (!$options["download"] && $data) {
return $data;
}
}
示例11: getAllDatasFromTable
// Check session dir (usefull when NFS mounted))
if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) {
echo "GLPI_SESSION_DIR_OK\n";
} else {
echo "GLPI_SESSION_DIR_PROBLEM\n";
$ok = false;
}
// Reestablished DB connection
if (($ok_master || $ok_slave) && DBConnection::establishDBConnection(false, false, false)) {
// Check LDAP Auth connections
$ldap_methods = getAllDatasFromTable('glpi_authldaps', '`is_active`=1');
if (count($ldap_methods)) {
echo "Check LDAP servers:";
foreach ($ldap_methods as $method) {
echo " " . $method['name'];
if (AuthLDAP::tryToConnectToServer($method, $method["rootdn"], Toolbox::decrypt($method["rootdn_passwd"], GLPIKEY))) {
echo "_OK";
} else {
echo "_PROBLEM";
$ok = false;
}
echo "\n";
}
} else {
echo "No LDAP server\n";
}
// Check IMAP Auth connections
$imap_methods = getAllDatasFromTable('glpi_authmails', '`is_active`=1');
if (count($imap_methods)) {
echo "Check IMAP servers:";
foreach ($imap_methods as $method) {
示例12: __construct
public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
{
/// Patch GLPI
global $CFG_GLPI;
if (class_exists('idna_convert')) {
$idn = new idna_convert();
$parsed = SimplePie_Misc::parse_url($url);
$url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
}
$this->url = $url;
$this->useragent = $useragent;
if (preg_match('/^http(s)?:\\/\\//i', $url)) {
if ($useragent === null) {
$useragent = ini_get('user_agent');
$this->useragent = $useragent;
}
if (!is_array($headers)) {
$headers = array();
}
if (!$force_fsockopen && function_exists('curl_exec')) {
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
$fp = curl_init();
$headers2 = array();
foreach ($headers as $key => $value) {
$headers2[] = "{$key}: {$value}";
}
if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) {
curl_setopt($fp, CURLOPT_ENCODING, '');
}
curl_setopt($fp, CURLOPT_URL, $url);
curl_setopt($fp, CURLOPT_HEADER, 1);
curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($fp, CURLOPT_REFERER, $url);
curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
/// Patch GLPI
if (!empty($CFG_GLPI["proxy_name"])) {
curl_setopt($fp, CURLOPT_PROXY, $CFG_GLPI["proxy_name"]);
curl_setopt($fp, CURLOPT_PROXYPORT, $CFG_GLPI["proxy_port"]);
if (!empty($CFG_GLPI["proxy_user"])) {
curl_setopt($fp, CURLOPT_HTTPAUTH, CURLAUTH_ANYSAFE);
curl_setopt($fp, CURLOPT_PROXYUSERPWD, $CFG_GLPI["proxy_user"] . ":" . Toolbox::decrypt($CFG_GLPI["proxy_passwd"], GLPIKEY));
}
}
if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) {
curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
}
$this->headers = curl_exec($fp);
if (curl_errno($fp) === 23 || curl_errno($fp) === 61) {
curl_setopt($fp, CURLOPT_ENCODING, 'none');
$this->headers = curl_exec($fp);
}
if (curl_errno($fp)) {
$this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
$this->success = false;
} else {
$info = curl_getinfo($fp);
curl_close($fp);
$this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
$this->headers = array_pop($this->headers);
$parser = new SimplePie_HTTP_Parser($this->headers);
if ($parser->parse()) {
$this->headers = $parser->headers;
$this->body = $parser->body;
$this->status_code = $parser->status_code;
if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) {
$this->redirects++;
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
}
}
}
} else {
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
$url_parts = parse_url($url);
$socket_host = $url_parts['host'];
if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
$socket_host = "ssl://{$url_parts['host']}";
$url_parts['port'] = 443;
}
if (!isset($url_parts['port'])) {
$url_parts['port'] = 80;
}
$fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
if (!$fp) {
$this->error = 'fsockopen error: ' . $errstr;
$this->success = false;
} else {
stream_set_timeout($fp, $timeout);
if (isset($url_parts['path'])) {
if (isset($url_parts['query'])) {
$get = "{$url_parts['path']}?{$url_parts['query']}";
} else {
$get = $url_parts['path'];
}
} else {
$get = '/';
//.........这里部分代码省略.........
示例13: methodStatus
/**
* This method return GLPI status (same as status.php)
*
* @param $params array of option : ignored
* @param $protocol the communication protocol used
*
* @return an response ready to be encode
**/
static function methodStatus($params, $protocol)
{
global $DB;
if (isset($params['help'])) {
return array('help' => 'bool,optional');
}
$resp = array();
$ok_master = true;
$ok_slave = true;
$ok = true;
// Check slave server connection
if (DBConnection::isDBSlaveActive()) {
$DBslave = DBConnection::getDBSlaveConf();
if (is_array($DBslave->dbhost)) {
$hosts = $DBslave->dbhost;
} else {
$hosts = array($DBslave->dbhost);
}
foreach ($hosts as $num => $name) {
$diff = DBConnection::getReplicateDelay($num);
if ($diff > 1000000000) {
$resp['slavedb_' . $num] = "offline";
$ok_slave = false;
} else {
if ($diff) {
$resp['slavedb_' . $num] = $diff;
if ($diff > HOUR_TIMESTAMP) {
$ok_slave = false;
}
} else {
$resp['slavedb_' . $num] = "ok";
}
}
}
} else {
$resp['slavedb'] = "not configured";
}
// Check main server connection
if (DBConnection::establishDBConnection(false, true, false)) {
$resp['maindb'] = "ok";
} else {
$resp['slavedb'] = "offline";
$ok_master = false;
}
// Slave and master ok;
$ok = $ok_slave && $ok_master;
// Check session dir (usefull when NFS mounted))
if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) {
$resp['sessiondir'] = "ok";
} else {
$resp['sessiondir'] = "not writable";
$ok = false;
}
// Reestablished DB connection
if (($ok_master || $ok_slave) && DBConnection::establishDBConnection(false, false, false)) {
// Check Auth connections
$auth = new Auth();
$auth->getAuthMethods();
$ldap_methods = $auth->authtypes["ldap"];
if (count($ldap_methods)) {
foreach ($ldap_methods as $method) {
if ($method['is_active']) {
if (AuthLdap::tryToConnectToServer($method, $method["rootdn"], Toolbox::decrypt($method["rootdn_passwd"], GLPIKEY))) {
$resp['LDAP_' . $method['name']] = "ok";
} else {
$resp['LDAP_' . $method['name']] = "offline";
$ok = false;
}
}
}
}
}
if ($ok) {
$resp['glpi'] = "ok";
} else {
$resp['glpi'] = "error";
}
return $resp;
}
示例14: connect
/**
* Connect to the mail box
**/
function connect()
{
if ($this->fields['use_kerberos']) {
$this->marubox = @imap_open($this->fields['host'], $this->fields['login'], Toolbox::decrypt($this->fields['passwd'], GLPIKEY), CL_EXPUNGE, 1);
} else {
$try_options = array(array('DISABLE_AUTHENTICATOR' => 'GSSAPI'), array('DISABLE_AUTHENTICATOR' => 'PLAIN'));
foreach ($try_options as $option) {
$this->marubox = @imap_open($this->fields['host'], $this->fields['login'], Toolbox::decrypt($this->fields['passwd'], GLPIKEY), CL_EXPUNGE, 1, $option);
if (is_resource($this->marubox)) {
break;
}
}
}
// Reset errors
if ($this->marubox) {
// call this to avoid the mailbox is empty error message
if (imap_num_msg($this->marubox) == 0) {
$errors = imap_errors();
}
if ($this->fields['errors'] > 0) {
$this->update(array('id' => $this->getID(), 'errors' => 0));
}
} else {
$this->update(array('id' => $this->getID(), 'errors' => $this->fields['errors'] + 1));
}
}
示例15: getAllDatasFromTable
}
// Reestablished DB connection
if (($ok_master || $ok_slave )
&& DBConnection::establishDBConnection(false, false, false)) {
// Check LDAP Auth connections
$ldap_methods = getAllDatasFromTable('glpi_authldaps', '`is_active`=1');
if (count($ldap_methods)) {
echo "Check LDAP servers:";
foreach ($ldap_methods as $method) {
echo " ".$method['name'];
if (AuthLDAP::tryToConnectToServer($method, $method["rootdn"],
Toolbox::decrypt($method["rootdn_passwd"],
GLPIKEY))) {
echo "_OK";
} else {
echo "_PROBLEM";
$ok = false;
}
echo "\n";
}
} else {
echo "No LDAP server\n";
}
// Check IMAP Auth connections
$imap_methods = getAllDatasFromTable('glpi_authmails', '`is_active`=1');