/** * Get Results of the Application SelfTest. * * Fields * - title * - state (OK, WARNING or ERROR) * - hint * * @return Array */ public static function getResults() { /** * ['title'] * ['state'] = OK, WARNING, ERROR * ['hint'] */ $checks = array(); // Checks PHP Version $title = 'PHP - Version - ' . PHP_VERSION; if (version_compare(PHP_VERSION, '5.4', '>=')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Minimum 5.4'); } // Checks GD Extension $title = 'PHP - GD Extension'; if (function_exists('gd_info')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install GD Extension'); } $title = 'PHP - INTL Extension'; if (function_exists('collator_create')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install INTL Extension'); } $icuVersion = defined('INTL_ICU_VERSION') ? INTL_ICU_VERSION : 0; $icuMinVersion = '4.8.1'; $title = 'PHP - INTL Extension - ICU Version (' . INTL_ICU_VERSION . ')'; if (version_compare($icuVersion, $icuMinVersion, '>=')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'WARNING', 'hint' => 'ICU Data ' . $icuMinVersion . ' or higher is required'); } $icuDataVersion = defined('INTL_ICU_DATA_VERSION') ? INTL_ICU_DATA_VERSION : 0; $icuMinDataVersion = '4.8.1'; $title = 'PHP - INTL Extension - ICU Data Version (' . INTL_ICU_DATA_VERSION . ')'; if (version_compare($icuDataVersion, $icuMinDataVersion, '>=')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'WARNING', 'hint' => 'ICU Data ' . $icuMinDataVersion . ' or higher is required'); } // Checks GD Extension $title = 'PHP - EXIF Extension'; if (function_exists('exif_read_data')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install EXIF Extension'); } // Check FileInfo Extension $title = 'PHP - FileInfo Extension'; if (extension_loaded('fileinfo')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install FileInfo Extension'); } // Checks CURL Extension $title = 'PHP - Multibyte String Functions'; if (function_exists('mb_substr')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install PHP Multibyte Extension'); } // Checks CURL Extension $title = 'PHP - Curl Extension'; if (function_exists('curl_version')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install Curl Extension'); } // Checks ZIP Extension $title = 'PHP - ZIP Extension'; if (class_exists('ZipArchive')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install PHP Zip Extension'); } // Checks LDAP Extension $title = 'LDAP Support'; if (\humhub\modules\user\libs\Ldap::isAvailable()) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'WARNING', 'hint' => 'Optional - Install PHP LDAP Extension and Zend LDAP Composer Package'); } // Checks APC Extension $title = 'PHP - APC Support'; if (function_exists('apc_add')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'WARNING', 'hint' => 'Optional - Install APC Extension for APC Caching'); } // Checks SQLite3 Extension $title = 'PHP - SQLite3 Support'; if (class_exists('SQLite3')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'WARNING', 'hint' => 'Optional - Install SQLite3 Extension for DB Caching'); } // Checks Writeable Config /* $title = 'Permissions - Config'; $configFile = dirname(Yii::$app->params['dynamicConfigFile']); if (is_writeable($configFile)) { $checks[] = array( 'title' => Yii::t('base', $title), 'state' => 'OK' ); } else { $checks[] = array( 'title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $configFile . " writable for the webserver/php!" ); } */ // Check Runtime Directory $title = 'Permissions - Runtime'; $path = Yii::getAlias('@runtime'); if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } // Check Assets Directory $title = 'Permissions - Assets'; $path = Yii::getAlias('@webroot/assets'); if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } // Check Uploads Directory $title = 'Permissions - Uploads'; $path = Yii::getAlias('@webroot/uploads'); if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } // Check Custom Modules Directory $title = 'Permissions - Module Directory'; $path = Yii::getAlias(Yii::$app->params['moduleMarketplacePath']); if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } // Check Custom Modules Directory $title = 'Permissions - Dynamic Config'; $path = Yii::getAlias(Yii::$app->params['dynamicConfigFile']); if (!is_file($path)) { $path = dirname($path); } if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } return $checks; }
/** * Get Results of the Application SelfTest. * * Fields * - title * - state (OK, WARNING or ERROR) * - hint * * @return Array */ public static function getResults() { /** * ['title'] * ['state'] = OK, WARNING, ERROR * ['hint'] */ $checks = array(); // Checks PHP Version $title = 'PHP - Version - ' . PHP_VERSION; # && version_compare(PHP_VERSION, '5.9.0', '<') if (version_compare(PHP_VERSION, '5.4.0', '>=')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } elseif (version_compare(PHP_VERSION, '5.4.0', '<=')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'WARNING', 'hint' => 'Untested on this version!'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Minimum 5.3'); } // Checks GD Extension $title = 'PHP - GD Extension'; if (function_exists('gd_info')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install GD Extension'); } // Checks GD Extension $title = 'PHP - EXIF Extension'; if (function_exists('exif_read_data')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install EXIF Extension'); } // Checks CURL Extension $title = 'PHP - Multibyte String Functions'; if (function_exists('mb_substr')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install PHP Multibyte Extension'); } // Checks CURL Extension $title = 'PHP - Curl Extension'; if (function_exists('curl_version')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install Curl Extension'); } // Checks ZIP Extension $title = 'PHP - ZIP Extension'; if (class_exists('ZipArchive')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Install PHP Zip Extension'); } // Checks LDAP Extension $title = 'LDAP Support'; if (\humhub\modules\user\libs\Ldap::isAvailable()) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'WARNING', 'hint' => 'Optional - Install PHP LDAP Extension and Zend LDAP Composer Package'); } // Checks APC Extension $title = 'PHP - APC Support'; if (function_exists('apc_add')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'WARNING', 'hint' => 'Optional - Install APC Extension for APC Caching'); } // Checks SQLite3 Extension $title = 'PHP - SQLite3 Support'; if (class_exists('SQLite3')) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'WARNING', 'hint' => 'Optional - Install SQLite3 Extension for DB Caching'); } // Checks Writeable Config /* $title = 'Permissions - Config'; $configFile = dirname(Yii::$app->params['dynamicConfigFile']); if (is_writeable($configFile)) { $checks[] = array( 'title' => Yii::t('base', $title), 'state' => 'OK' ); } else { $checks[] = array( 'title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $configFile . " writable for the webserver/php!" ); } */ // Check Runtime Directory $title = 'Permissions - Runtime'; $path = Yii::getAlias('@runtime'); if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } // Check Assets Directory $title = 'Permissions - Assets'; $path = Yii::getAlias('@webroot/assets'); if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } // Check Uploads Directory $title = 'Permissions - Uploads'; $path = Yii::getAlias('@webroot/uploads'); if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } // Check Custom Modules Directory $title = 'Permissions - Module Directory'; $path = Yii::getAlias('@app/modules'); if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } // Check Custom Modules Directory $title = 'Permissions - Dynamic Config'; $path = Yii::getAlias(Yii::$app->params['dynamicConfigFile']); if (!is_file($path)) { $path = dirname($path); } if (is_writeable($path)) { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'OK'); } else { $checks[] = array('title' => Yii::t('base', $title), 'state' => 'ERROR', 'hint' => 'Make ' . $path . " writable for the webserver/php!"); } return $checks; }
public static function onHourlyCron($event) { $controller = $event->sender; if (Setting::Get('enabled', 'authentication_ldap') && Setting::Get('refreshUsers', 'authentication_ldap') && Ldap::isAvailable()) { $controller->stdout("Refresh ldap users... "); Ldap::getInstance()->refreshUsers(); $controller->stdout('done.' . PHP_EOL, \yii\helpers\Console::FG_GREEN); } // Delete expired session foreach (models\Session::find()->where(['<', 'expire', time()])->all() as $session) { $session->delete(); } }
/** * Finds user by [[username]] * * @return User|null */ public function getUser() { if ($this->_user === false) { $this->_user = User::find()->where(['username' => $this->username])->orWhere(['email' => $this->username])->one(); // Could not found user -> lookup in LDAP if ($this->_user === null && Ldap::isAvailable() && Setting::Get('enabled', 'authentication_ldap')) { try { // Try load/create LDAP user $usernameDn = Ldap::getInstance()->ldap->getCanonicalAccountName($this->username, \Zend\Ldap\Ldap::ACCTNAME_FORM_DN); Ldap::getInstance()->handleLdapUser(Ldap::getInstance()->ldap->getNode($usernameDn)); // Check if user is availble now $this->_user = User::find()->where(['username' => $this->username])->orWhere(['email' => $this->username])->one(); } catch (\Zend\Ldap\Exception\LdapException $ex) { // User not found } } } return $this->_user; }
public static function onHourlyCron($event) { $controller = $event->sender; if (Setting::Get('enabled', 'authentication_ldap') && Setting::Get('refreshUsers', 'authentication_ldap') && Ldap::isAvailable()) { $controller->stdout("Refresh ldap users... "); Ldap::getInstance()->refreshUsers(); $controller->stdout('done.' . PHP_EOL, \yii\helpers\Console::FG_GREEN); } }