convert array to short syntax

Signed-off-by: Hamid Dehnavi <hamid.dev.pro@gmail.com>
This commit is contained in:
Hamid Dehnavi 2023-07-05 17:58:46 +03:30
parent 6aecf8046a
commit 8f5de1fd72
18 changed files with 122 additions and 122 deletions

View file

@ -72,12 +72,12 @@ class Activity implements \OCP\Activity\IExtension {
*/
public function getNotificationTypes(string $languageCode) {
$l = $this->factory->get(self::APP_NAME, $languageCode);
return array(
return [
self::TYPE_ITEM_ACTION => $l->t('A Passman item has been created, modified or deleted'),
self::TYPE_ITEM_EXPIRED => $l->t('A Passman item has expired'),
self::TYPE_ITEM_SHARED => $l->t('A Passman item has been shared'),
self::TYPE_ITEM_RENAMED => $l->t('A Passman item has been renamed')
);
];
}
/**
@ -101,18 +101,18 @@ class Activity implements \OCP\Activity\IExtension {
*/
public function getDefaultTypes($method) {
if ($method === 'stream') {
return array(
return [
self::TYPE_ITEM_ACTION,
self::TYPE_ITEM_EXPIRED,
self::TYPE_ITEM_SHARED,
self::TYPE_ITEM_EXPIRED,
self::TYPE_ITEM_RENAMED,
);
];
}
if ($method === 'email') {
return array(
return [
self::TYPE_ITEM_EXPIRED,
);
];
}
return false;
}
@ -198,25 +198,25 @@ class Activity implements \OCP\Activity\IExtension {
case self::SUBJECT_ITEM_RECOVERED_SELF:
case self::SUBJECT_ITEM_DESTROYED:
case self::SUBJECT_ITEM_DESTROYED_SELF:
return array(
return [
0 => 'passman',
1 => 'username',
);
];
case self::SUBJECT_APPLY_REV:
case self::SUBJECT_APPLY_REV_SELF:
return array(
return [
0 => 'passman',
1 => 'username',
2 => '', //unknown
);
];
case self::SUBJECT_ITEM_EXPIRED:
case self::SUBJECT_ITEM_RENAMED_SELF:
case self::SUBJECT_ITEM_RENAMED:
case self::SUBJECT_ITEM_SHARED:
case self::SUBJECT_ITEM_SHARED_PUBLICLY:
return array(
return [
0 => 'passman',
);
];
}
}
return false;
@ -262,16 +262,16 @@ class Activity implements \OCP\Activity\IExtension {
*/
public function getNavigation() {
$l = $this->factory->get(self::APP_NAME);
return array(
'top' => array(),
'apps' => array(self::FILTER_PASSMAN =>
array(
return [
'top' => [],
'apps' => [self::FILTER_PASSMAN =>
[
'id' => 'passman',
'name' => (string)$l->t('Passwords'),
'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', ['filter' => self::FILTER_PASSMAN]),
),
),
);
],
],
];
}
/**

View file

@ -69,7 +69,7 @@ class CredentialController extends ApiController {
$description, $email, $expire_time, $favicon, $files, $guid,
$hidden, $icon, $label, $otp, $password, $renew_interval,
$tags, $url, $username, $vault_id, $compromised) {
$credential = array(
$credential = [
'credential_id' => $credential_id,
'guid' => $guid,
'user_id' => $this->userId,
@ -93,14 +93,14 @@ class CredentialController extends ApiController {
'otp' => $otp,
'hidden' => $hidden,
'compromised' => $compromised
);
];
$credential = $this->credentialService->createCredential($credential);
$link = ''; // @TODO create direct link to credential
if (!$credential->getHidden()) {
$this->activityService->add(
Activity::SUBJECT_ITEM_CREATED_SELF, array($label, $this->userId),
'', array(),
Activity::SUBJECT_ITEM_CREATED_SELF, [$label, $this->userId],
'', [],
$link, $this->userId, Activity::TYPE_ITEM_ACTION);
}
@ -129,7 +129,7 @@ class CredentialController extends ApiController {
$storedCredential = $this->credentialService->getCredentialByGUID($credential_guid);
$credential = array(
$credential = [
'credential_id' => $credential_id,
'guid' => $guid,
'label' => $label,
@ -152,7 +152,7 @@ class CredentialController extends ApiController {
'otp' => $otp,
'user_id' => $storedCredential->getUserId(),
'compromised' => $compromised
);
];
if (!hash_equals($storedCredential->getUserId(), $this->userId)) {
@ -172,32 +172,32 @@ class CredentialController extends ApiController {
if ($revision_created) {
$activity = 'item_apply_revision';
$this->activityService->add(
$activity . '_self', array($label, $this->userId, $revision_created),
'', array(),
$activity . '_self', [$label, $this->userId, $revision_created],
'', [],
$link, $this->userId, Activity::TYPE_ITEM_ACTION);
} else if (($storedCredential->getDeleteTime() === 0) && (int)$delete_time > 0) {
$activity = 'item_deleted';
$this->activityService->add(
$activity . '_self', array($label, $this->userId),
'', array(),
$activity . '_self', [$label, $this->userId],
'', [],
$link, $this->userId, Activity::TYPE_ITEM_ACTION);
} else if (($storedCredential->getDeleteTime() > 0) && (int)$delete_time === 0) {
$activity = 'item_recovered';
$this->activityService->add(
$activity . '_self', array($label, $this->userId),
'', array(),
$activity . '_self', [$label, $this->userId],
'', [],
$link, $this->userId, Activity::TYPE_ITEM_ACTION);
} else if ($label !== $storedCredential->getLabel()) {
$activity = 'item_renamed';
$this->activityService->add(
$activity . '_self', array($storedCredential->getLabel(), $label, $this->userId),
'', array(),
$activity . '_self', [$storedCredential->getLabel(), $label, $this->userId],
'', [],
$link, $this->userId, Activity::TYPE_ITEM_RENAMED);
} else {
$activity = 'item_edited';
$this->activityService->add(
$activity . '_self', array($label, $this->userId),
'', array(),
$activity . '_self', [$label, $this->userId],
'', [],
$link, $this->userId, Activity::TYPE_ITEM_ACTION);
}
$acl_list = null;
@ -208,18 +208,18 @@ class CredentialController extends ApiController {
// Just check if we have an acl list
}
if (!empty($acl_list)) {
$params = array();
$params = [];
switch ($activity) {
case 'item_recovered':
case 'item_deleted':
case 'item_edited':
$params = array($credential['label'], $this->userId);
$params = [$credential['label'], $this->userId];
break;
case 'item_apply_revision':
$params = array($credential['label'], $this->userId, $revision_created);
$params = [$credential['label'], $this->userId, $revision_created];
break;
case 'item_renamed':
$params = array($storedCredential->getLabel(), $label, $this->userId);
$params = [$storedCredential->getLabel(), $label, $this->userId];
break;
}
@ -230,13 +230,13 @@ class CredentialController extends ApiController {
}
$this->activityService->add(
$activity, $params,
'', array(),
'', [],
$link, $target_user, Activity::TYPE_ITEM_ACTION);
}
if (!hash_equals($this->userId, $storedCredential->getUserId())) {
$this->activityService->add(
$activity, $params,
'', array(),
'', [],
$link, $storedCredential->getUserId(), Activity::TYPE_ITEM_ACTION);
}
}
@ -326,12 +326,12 @@ class CredentialController extends ApiController {
try {
$revision = $this->credentialRevisionService->getRevision($revision_id);
} catch (\Exception $exception) {
return new JSONResponse(array());
return new JSONResponse([]);
}
$revision->setCredentialData($credential_data);
$this->credentialRevisionService->updateRevision($revision);
return new JSONResponse(array());
return new JSONResponse([]);
}
}

View file

@ -44,13 +44,13 @@ class FileController extends ApiController {
* @NoCSRFRequired
*/
public function uploadFile($data, $filename, $mimetype, $size) {
$file = array(
$file = [
'filename' => $filename,
'size' => $size,
'mimetype' => $mimetype,
'file_data' => $data,
'user_id' => $this->userId
);
];
return new JSONResponse($this->fileService->createFile($file, $this->userId));
}
@ -89,7 +89,7 @@ class FileController extends ApiController {
}
}
}
return new JSONResponse(array('ok' => empty($failed_file_ids), 'failed' => $failed_file_ids));
return new JSONResponse(['ok' => empty($failed_file_ids), 'failed' => $failed_file_ids]);
}
/**

View file

@ -86,7 +86,7 @@ class InternalController extends ApiController {
* @NoCSRFRequired
*/
public function getAppVersion() {
return new JSONResponse(array('version' => $this->appManager->getAppInfo('passman')["version"]));
return new JSONResponse(['version' => $this->appManager->getAppInfo('passman')["version"]]);
}
/**
@ -104,14 +104,14 @@ class InternalController extends ApiController {
* @NoCSRFRequired
*/
public function getSettings() {
$settings = array(
$settings = [
'link_sharing_enabled' => intval($this->config->getAppValue('passman', 'link_sharing_enabled', 1)),
'user_sharing_enabled' => intval($this->config->getAppValue('passman', 'user_sharing_enabled', 1)),
'vault_key_strength' => intval($this->config->getAppValue('passman', 'vault_key_strength', 3)),
'check_version' => intval($this->config->getAppValue('passman', 'check_version', 1)),
'https_check' => intval($this->config->getAppValue('passman', 'https_check', 1)),
'disable_contextmenu' => intval($this->config->getAppValue('passman', 'disable_contextmenu', 1)),
);
];
return new JSONResponse($settings);
}

View file

@ -43,7 +43,7 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function bookmarklet($url='', $title='') {
$params = array('url' => $url, 'title' => $title);
$params = ['url' => $url, 'title' => $title];
return new TemplateResponse($this->appName, 'bookmarklet', $params);
}

View file

@ -117,7 +117,7 @@ class ShareController extends ApiController {
$this->activityService->add(
'item_shared_publicly', [$credential->getLabel()],
'', array(),
'', [],
'', $this->userId->getUID(), Activity::TYPE_ITEM_SHARED);
} else {
$this->shareService->updateCredentialACL($acl);
@ -142,7 +142,7 @@ class ShareController extends ApiController {
try {
$shareRequests = $this->shareService->getPendingShareRequestsForCredential($item_guid, $first_vault['user_id']);
if (count($shareRequests) > 0) {
return new JSONResponse(array('error' => 'User got already pending requests'));
return new JSONResponse(['error' => 'User got already pending requests']);
}
} catch (\Exception $exception) {
// no need to catch this
@ -156,23 +156,23 @@ class ShareController extends ApiController {
}
if ($acl) {
return new JSONResponse(array('error' => 'User got already this credential'));
return new JSONResponse(['error' => 'User got already this credential']);
}
$result = $this->shareService->createBulkRequests($item_id, $item_guid, $vaults, $permissions, $credential_owner);
if ($credential) {
$processed_users = array();
$processed_users = [];
foreach ($result as $vault) {
if (!in_array($vault->getTargetUserId(), $processed_users)) {
$target_user = $vault->getTargetUserId();
$notification = array(
$notification = [
'from_user' => ucfirst($this->userId->getDisplayName()),
'credential_label' => $credential->getLabel(),
'credential_id' => $credential->getId(),
'item_id' => $credential->getId(),
'target_user' => $target_user,
'req_id' => $vault->getId()
);
];
$this->notificationService->credentialSharedNotification(
$notification
);
@ -180,13 +180,13 @@ class ShareController extends ApiController {
$this->activityService->add(
'item_shared', [$credential->getLabel(), $target_user],
'', array(),
'', [],
'', $this->userId->getUID(), Activity::TYPE_ITEM_SHARED);
$this->activityService->add(
'item_share_received', [$credential->getLabel(), $this->userId->getUID()],
'', array(),
'', [],
'', $target_user, Activity::TYPE_ITEM_SHARED);
}
}
@ -201,16 +201,16 @@ class ShareController extends ApiController {
* @NoCSRFRequired
*/
public function searchUsers($search) {
$users = array();
$users = [];
$usersTmp = $this->userManager->searchDisplayName($search, $this->limit, $this->offset);
foreach ($usersTmp as $user) {
if ($this->userId->getUID() !== $user->getUID() && count($this->vaultService->getByUser($user->getUID())) >= 1) {
$users[] = array(
$users[] = [
'text' => $user->getDisplayName(),
'uid' => $user->getUID(),
'type' => 'user'
);
];
}
}
return $users;
@ -223,7 +223,7 @@ class ShareController extends ApiController {
*/
public function unshareCredential($item_guid) {
$this->shareService->unshareCredential($item_guid);
return new JSONResponse(array('result' => true));
return new JSONResponse(['result' => true]);
}
/**
@ -256,7 +256,7 @@ class ShareController extends ApiController {
if ($acl) {
$this->shareService->deleteShareACL($acl);
}
return new JSONResponse(array('result' => true));
return new JSONResponse(['result' => true]);
}
/**
@ -275,15 +275,15 @@ class ShareController extends ApiController {
*/
public function getVaultsByUser($user_id) {
$user_vaults = $this->vaultService->getByUser($user_id);
$result = array();
$result = [];
foreach ($user_vaults as $vault) {
array_push($result,
array(
[
'vault_id' => $vault->getId(),
'guid' => $vault->getGuid(),
'public_sharing_key' => $vault->getPublicSharingKey(),
'user_id' => $user_id,
));
]);
}
return new JSONResponse($result);
}
@ -305,12 +305,12 @@ class ShareController extends ApiController {
->setUser($this->userId->getUID());
$this->manager->markProcessed($notification);
$notification = array(
$notification = [
'from_user' => ucfirst($this->userId->getDisplayName()),
'credential_label' => $this->credentialService->getCredentialLabelById($sr->getItemId())->getLabel(),
'target_user' => $sr->getFromUserId(),
'req_id' => $sr->getId()
);
];
$this->notificationService->credentialAcceptedSharedNotification(
$notification
@ -327,7 +327,7 @@ class ShareController extends ApiController {
public function getPendingRequests() {
try {
$requests = $this->shareService->getUserPendingRequests($this->userId->getUID());
$results = array();
$results = [];
foreach ($requests as $request) {
$result = $request->jsonSerialize();
$c = $this->credentialService->getCredentialLabelById($request->getItemId());
@ -392,12 +392,12 @@ class ShareController extends ApiController {
try {
$sr = $this->shareService->getShareRequestById($share_request_id);
$notification = array(
$notification = [
'from_user' => ucfirst($this->userId->getDisplayName()),
'credential_label' => $this->credentialService->getCredentialLabelById($sr->getItemId())->getLabel(),
'target_user' => $sr->getFromUserId(),
'req_id' => $sr->getId()
);
];
$this->notificationService->credentialDeclinedSharedNotification(
$notification
);
@ -410,7 +410,7 @@ class ShareController extends ApiController {
$this->manager->markProcessed($notification);
$this->shareService->cleanItemRequestsForUser($sr);
return new JSONResponse(array('result' => true));
return new JSONResponse(['result' => true]);
} catch (\Exception $ex) {
return new NotFoundJSONResponse();
}
@ -471,7 +471,7 @@ class ShareController extends ApiController {
return new NotFoundResponse();
}
} catch (\Exception $ex) {
return new JSONResponse(array());
return new JSONResponse([]);
}
}
@ -529,13 +529,13 @@ class ShareController extends ApiController {
}
}
$file = array(
$file = [
'filename' => $filename,
'size' => $size,
'mimetype' => $mimetype,
'file_data' => $data,
'user_id' => $credential->getUserId()
);
];
// save the file with the id of the user that owns the credential
return new JSONResponse($this->fileService->createFile($file, $credential->getUserId()));

View file

@ -39,7 +39,7 @@ class TranslationController extends ApiController {
* @PublicPage
*/
public function getLanguageStrings() {
$translations = array(
$translations = [
// js/app/controllers/bookmarklet.js
'generating.sharing.keys' => $this->trans->t('Generating sharing keys (%s/2)','%step'),
'invalid.vault.key' => $this->trans->t('Incorrect vault password!'),
@ -450,7 +450,7 @@ class TranslationController extends ApiController {
'search.settings.defaults_button' => $this->trans->t('Revert to defaults'),
);
];
return new JSONResponse($translations);
}
}

View file

@ -62,16 +62,16 @@ class VaultController extends ApiController {
* @NoCSRFRequired
*/
public function listVaults() {
$result = array();
$result = [];
$vaults = $this->vaultService->getByUser($this->userId);
$protected_credential_fields = array('getDescription', 'getEmail', 'getUsername', 'getPassword');
$protected_credential_fields = ['getDescription', 'getEmail', 'getUsername', 'getPassword'];
if (isset($vaults)) {
foreach ($vaults as $vault) {
$credential = $this->credentialService->getRandomCredentialByVaultId($vault->getId(), $this->userId);
$secret_field = $protected_credential_fields[array_rand($protected_credential_fields)];
if (isset($credential)) {
array_push($result, array(
array_push($result, [
'vault_id' => $vault->getId(),
'guid' => $vault->getGuid(),
'name' => $vault->getName(),
@ -80,7 +80,7 @@ class VaultController extends ApiController {
'last_access' => $vault->getlastAccess(),
'challenge_password' => $credential->{$secret_field}(),
'delete_request_pending' => ($this->deleteVaultRequestService->getDeleteRequestForVault($vault->getGuid())) ? true : false
));
]);
}
}
}
@ -108,11 +108,11 @@ class VaultController extends ApiController {
} catch (\Exception $e) {
return new NotFoundJSONResponse();
}
$result = array();
$result = [];
if (isset($vault)) {
$credentials = $this->credentialService->getCredentialsByVaultId($vault->getId(), $this->userId);
$result = array(
$result = [
'vault_id' => $vault->getId(),
'guid' => $vault->getGuid(),
'name' => $vault->getName(),
@ -123,7 +123,7 @@ class VaultController extends ApiController {
'vault_settings' => $vault->getVaultSettings(),
'last_access' => $vault->getlastAccess(),
'delete_request_pending' => ($this->deleteVaultRequestService->getDeleteRequestForVault($vault->getGuid())) ? true : false
);
];
$result['credentials'] = $credentials;
$this->vaultService->setLastAccess($vault->getId(), $this->userId);
@ -196,6 +196,6 @@ class VaultController extends ApiController {
}
$this->vaultService->deleteVault($vault_guid, $this->userId);
return new JSONResponse(array('ok' => empty($failed_credential_guids), 'failed' => $failed_credential_guids));
return new JSONResponse(['ok' => empty($failed_credential_guids), 'failed' => $failed_credential_guids]);
}
}

View file

@ -20,9 +20,9 @@ class ShareMiddleware extends Middleware {
public function beforeController($controller, $methodName) {
if ($controller instanceof ShareController) {
$http_response_code = Http::STATUS_OK;
$result = array();
$publicMethods = array('createPublicShare', 'getPublicCredentialData');
$user_pub_methods = array('updateSharedCredentialACL', 'getFile', 'getItemAcl');
$result = [];
$publicMethods = ['createPublicShare', 'getPublicCredentialData'];
$user_pub_methods = ['updateSharedCredentialACL', 'getFile', 'getItemAcl'];
$setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled';
$sharing_enabled = ($this->settings->isEnabled($setting));

View file

@ -48,9 +48,9 @@ class ActivityService {
* @param $type string
* @return array
*/
public function add($subject,$subjectParams=array(),
$message='',$messageParams=array(),
$link='',$user=null,$type='') {
public function add($subject, $subjectParams = [],
$message = '', $messageParams = [],
$link = '', $user = null, $type = '') {
if($user) {
$activity = $this->manager->generateEvent();
$activity->setType($type);
@ -62,6 +62,6 @@ class ActivityService {
$activity->setTimestamp(time());
$activity->setMessage($message, $messageParams);
}
return array('success'=>'ok');
return ['success'=>'ok'];
}
}
}

View file

@ -117,8 +117,8 @@ class CredentialService {
*/
public function deleteCredentialParts(Credential $credential, $userId) {
$this->activityService->add(
'item_destroyed_self', array($credential->getLabel()),
'', array(),
'item_destroyed_self', [$credential->getLabel()],
'', [],
'', $userId, Activity::TYPE_ITEM_ACTION);
$this->shareService->unshareCredential($credential->getGuid());
foreach ($this->credentialRevisionService->getRevisions($credential->getId()) as $revision) {

View file

@ -59,18 +59,18 @@ class CronService {
->andWhere($qb->expr()->eq('subject', $qb->createNamedParameter('credential_expired', IQueryBuilder::PARAM_STR)));
try {
$this->logger->debug($credential->getLabel() . ' is expired, checking notifications!', array('app' => 'passman'));
$this->logger->debug($credential->getLabel() . ' is expired, checking notifications!', ['app' => 'passman']);
$notificationCount = $qb->execute()->rowCount();
if ($notificationCount === 0) {
$this->logger->debug($credential->getLabel() . ' is expired, adding notification!', array('app' => 'passman'));
$this->logger->debug($credential->getLabel() . ' is expired, adding notification!', ['app' => 'passman']);
$this->activityService->add(
Activity::SUBJECT_ITEM_EXPIRED, array($credential->getLabel(), $credential->getUserId()),
'', array(),
Activity::SUBJECT_ITEM_EXPIRED, [$credential->getLabel(), $credential->getUserId()],
'', [],
$link, $credential->getUserId(), Activity::TYPE_ITEM_EXPIRED);
$this->notificationService->credentialExpiredNotification($credential);
}
} catch (Exception $exception) {
$this->logger->error('Error while creating a notification: ' . $exception->getMessage(), array('app' => 'passman'));
$this->logger->error('Error while creating a notification: ' . $exception->getMessage(), ['app' => 'passman']);
}
}
}

View file

@ -55,21 +55,21 @@ class EncryptService {
*
* @var array
*/
const SUPPORTED_ALGORITHMS = array(
'aes-256-cbc' => array('name' => 'AES-256', 'keySize' => 32, 'blockSize' => 32),
'bf' => array('name' => 'BF', 'keySize' => 16, 'blockSize' => 8),
'des' => array('name' => 'DES', 'keySize' => 7, 'blockSize' => 8),
'des-ede3' => array('name' => 'DES-EDE3', 'keySize' => 21, 'blockSize' => 8), // 3 different 56-bit keys
'cast5' => array('name' => 'CAST5', 'keySize' => 16, 'blockSize' => 8),
);
const SUPPORTED_ALGORITHMS = [
'aes-256-cbc' => ['name' => 'AES-256', 'keySize' => 32, 'blockSize' => 32],
'bf' => ['name' => 'BF', 'keySize' => 16, 'blockSize' => 8],
'des' => ['name' => 'DES', 'keySize' => 7, 'blockSize' => 8],
'des-ede3' => ['name' => 'DES-EDE3', 'keySize' => 21, 'blockSize' => 8], // 3 different 56-bit keys
'cast5' => ['name' => 'CAST5', 'keySize' => 16, 'blockSize' => 8],
];
const OP_ENCRYPT = 'encrypt';
const OP_DECRYPT = 'decrypt';
// The fields of a credential which are encrypted
public $encrypted_credential_fields = array(
public $encrypted_credential_fields = [
'description', 'username', 'password', 'files', 'custom_fields', 'otp', 'email', 'tags', 'url', 'icon'
);
];
// Contains the server key
private $server_key;
@ -203,7 +203,7 @@ class EncryptService {
$cipherKey = substr($key, 0, $keySize);
$macKey = substr($key, $keySize, $keySize);
$iv = substr($key, 2 * $keySize);
return array($cipherKey, $macKey, $iv);
return [$cipherKey, $macKey, $iv];
}
/**
@ -303,7 +303,7 @@ class EncryptService {
$userSuppliedKey = $credential['label'];
$userKey = (isset($credential['shared_key'])) ? $credential['shared_key'] : $credential['user_id'];
}
return array($userKey, $userSuppliedKey);
return [$userKey, $userSuppliedKey];
}
/**

View file

@ -122,7 +122,7 @@ class FileService {
*/
public function getFileGuidsFromUser(string $userId) {
$files = $this->fileMapper->getFileGuidsFromUser($userId);
$results = array();
$results = [];
foreach ($files as $fileGuid) {
array_push($results, $fileGuid->getGuid());
}

View file

@ -301,7 +301,7 @@ class IconService {
$this->error = "Empty content";
return false;
}
$textTypes = array('text/html', 'text/plain');
$textTypes = ['text/html', 'text/plain'];
if (in_array($info['content_type'], $textTypes) || preg_match('#(</html>|</b>)#i', $content)) {
$this->error = "Seems to be a text document";
return false;
@ -328,7 +328,7 @@ class IconService {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0');
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
// Don't check SSL certificate to allow autosigned certificate
@ -378,12 +378,12 @@ class IconService {
* @return string
*/
public static function getExtensionFromMimeType($mimeType) {
$typeMapping = array(
$typeMapping = [
'ico' => '#image/(x-icon|ico)#i',
'png' => '#image/png#i',
'gif' => '#image/gif#i',
'jpg' => '#image/jpe?g#i',
);
];
foreach ($typeMapping as $key => $val) {
if (preg_match($val, $mimeType)) {
return $key;

View file

@ -33,7 +33,7 @@ class SettingsService {
private $appName;
public $settings;
private $numeric_settings = array(
private $numeric_settings = [
'link_sharing_enabled',
'user_sharing_enabled',
'vault_key_strength',
@ -42,13 +42,13 @@ class SettingsService {
'disable_contextmenu',
'enable_global_search',
'settings_loaded'
);
];
public function __construct($UserId, IConfig $config, $AppName) {
$this->userId = $UserId;
$this->config = $config;
$this->appName = $AppName;
$this->settings = array(
$this->settings = [
'link_sharing_enabled' => intval($this->config->getAppValue('passman', 'link_sharing_enabled', 1)),
'user_sharing_enabled' => intval($this->config->getAppValue('passman', 'user_sharing_enabled', 1)),
'vault_key_strength' => intval($this->config->getAppValue('passman', 'vault_key_strength', 3)),
@ -60,7 +60,7 @@ class SettingsService {
'disable_debugger' => $this->config->getAppValue('passman', 'disable_debugger', 1),
'enable_global_search' => $this->config->getAppValue('passman', 'enable_global_search', 0),
'settings_loaded' => 1
);
];
}
/**

View file

@ -78,7 +78,7 @@ class ShareService {
*/
public function createBulkRequests($target_item_id, $target_item_guid, $request_array, $permissions, $credential_owner) {
$created = Utils::getTime();
$requests = array();
$requests = [];
foreach ($request_array as $req) {
$t = new ShareRequest();
$t->setItemId($target_item_id);

View file

@ -68,7 +68,7 @@ class Utils {
* @param array $results
* @return array|mixed
*/
public static function getDirContents(string $dir, &$results = array()){
public static function getDirContents(string $dir, &$results = []){
$files = scandir($dir);
foreach($files as $value){