1
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2025-07-29 22:41:11 +03:00

phpcs insists on some brace changes

This commit is contained in:
David Goodwin
2021-04-13 21:19:16 +01:00
parent bbec16aac1
commit 2edabc3e03
60 changed files with 926 additions and 466 deletions

View File

@ -110,7 +110,8 @@ class PostfixAdmin
*
* @param array $args the argv.
*/
public function __construct($args = array()) {
public function __construct($args = array())
{
set_time_limit(0);
$this->__initConstants();
$this->parseParams($args);
@ -120,7 +121,8 @@ class PostfixAdmin
/**
* Defines core configuration.
*/
private function __initConstants() {
private function __initConstants()
{
ini_set('display_errors', '1');
ini_set('error_reporting', '' . E_ALL);
ini_set('html_errors', "0");
@ -131,7 +133,8 @@ class PostfixAdmin
/**
* Defines current working environment.
*/
private function __initEnvironment() {
private function __initEnvironment()
{
$this->stdin = fopen('php://stdin', 'r');
$this->stdout = fopen('php://stdout', 'w');
$this->stderr = fopen('php://stderr', 'w');
@ -152,7 +155,8 @@ class PostfixAdmin
* - and then a CliView object (Shell class)
* - call CliView->view() ... which under the covers uses AdminHandler*
*/
public function dispatch() {
public function dispatch()
{
check_db_version(); # ensure the database layout is up to date
if (!isset($this->args[0])) {
@ -264,7 +268,8 @@ class PostfixAdmin
* @param string $default Default input value.
* @return string Either the default value, or the user-provided input.
*/
public function getInput($prompt, $options = null, $default = null) {
public function getInput($prompt, $options = null, $default = null)
{
if (!is_array($options)) {
$print_options = '';
} else {
@ -295,7 +300,8 @@ class PostfixAdmin
* @param string $string String to output.
* @param boolean $newline If true, the outputs gets an added newline.
*/
public function stdout($string, $newline = true) {
public function stdout($string, $newline = true)
{
if ($newline) {
fwrite($this->stdout, $string . "\n");
} else {
@ -308,7 +314,8 @@ class PostfixAdmin
*
* @param string $string Error text to output.
*/
public function stderr($string) {
public function stderr($string)
{
fwrite($this->stderr, 'Error: '. $string . "\n");
}
@ -317,7 +324,8 @@ class PostfixAdmin
*
* @param array $params Parameters to parse
*/
public function parseParams($params) {
public function parseParams($params)
{
$count = count($params);
for ($i = 0; $i < $count; $i++) {
if ($params[$i] != '' && $params[$i][0] === '-' && $params[$i] != '-1') {
@ -342,7 +350,8 @@ class PostfixAdmin
*
* @return boolean False if there are no arguments
*/
public function shiftArgs() {
public function shiftArgs()
{
if (empty($this->args)) {
return false;
}
@ -354,7 +363,8 @@ class PostfixAdmin
/**
* prints help message and exits.
*/
public function help() {
public function help()
{
$this->stdout("\nWelcome to Postfixadmin-CLI v" . $this->version);
$this->stdout("---------------------------------------------------------------");
$this->stdout("Usage:");

View File

@ -16,18 +16,21 @@ class Crypt
protected $size;
public function __construct($plaintext) {
public function __construct($plaintext)
{
$this->plain = $plaintext;
}
/**
* @return bool
*/
public function crypt($algorithm) {
public function crypt($algorithm)
{
return true;
}
public function get() {
public function get()
{
return $this->password;
}
}

View File

@ -48,7 +48,8 @@ class DovecotCrypt extends Crypt
public function crypt($algorithm) {
public function crypt($algorithm)
{
if (!array_key_exists($algorithm, $this->password_schemes)) {
$this->errormsg[] = "This password scheme isn't supported. Check our Wiki!";
return false;
@ -62,7 +63,8 @@ class DovecotCrypt extends Crypt
return true;
}
public function verify($algorithm, $password) {
public function verify($algorithm, $password)
{
if (!array_key_exists($algorithm, $this->password_schemes)) {
$this->errormsg[] = "This password scheme isn't supported. Check our Wiki!";
return false;
@ -78,22 +80,28 @@ class DovecotCrypt extends Crypt
return $this->$func($this->plain, $password);
}
private function __crypt_verify($plaintext, $password) {
private function __crypt_verify($plaintext, $password)
{
$crypted = crypt($plaintext, $password);
return strcmp($crypted, $password) == 0;
}
private function __crypt_generate($plaintext) {
private function __crypt_generate($plaintext)
{
$password = crypt($plaintext);
return $password;
}
private function __md5_generate($plaintext) {
private function __md5_generate($plaintext)
{
return $plaintext;
}
private function __sha1_generate() {
private function __sha1_generate()
{
}
private function __plain_generate() {
private function __plain_generate()
{
}
private function __cram_md5_generate($plaintext) {
private function __cram_md5_generate($plaintext)
{
#http://hg.dovecot.org/dovecot-1.2/file/84373d238073/src/lib/hmac-md5.c
#http://hg.dovecot.org/dovecot-1.2/file/84373d238073/src/auth/password-scheme.c cram_md5_generate
@ -110,7 +118,8 @@ class DovecotCrypt extends Crypt
/**
* @return string
*/
public function custom_hmac($algo, $data, $key, $raw_output = false) {
public function custom_hmac($algo, $data, $key, $raw_output = false)
{
$algo = strtolower($algo);
$pack = 'H'.strlen($algo('test'));
$size = 64;