@@ -43,16 +43,16 @@ |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | /* do checks */ |
46 | -require_once $SETTINGS['cpassman_dir'] . '/sources/checks.php'; |
|
47 | -if (! checkUser($_SESSION['user_id'], $_SESSION['key'], curPage($SETTINGS), $SETTINGS)) { |
|
46 | +require_once $SETTINGS['cpassman_dir'].'/sources/checks.php'; |
|
47 | +if (!checkUser($_SESSION['user_id'], $_SESSION['key'], curPage($SETTINGS), $SETTINGS)) { |
|
48 | 48 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; |
49 | 49 | //not allowed page |
50 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
50 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
51 | 51 | exit; |
52 | 52 | } |
53 | 53 | |
54 | 54 | // Load |
55 | -require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php'; |
|
55 | +require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php'; |
|
56 | 56 | |
57 | 57 | ?> |
58 | 58 |
@@ -43,16 +43,16 @@ |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | /* do checks */ |
46 | -require_once $SETTINGS['cpassman_dir'] . '/sources/checks.php'; |
|
47 | -if (! checkUser($_SESSION['user_id'], $_SESSION['key'], curPage($SETTINGS), $SETTINGS)) { |
|
46 | +require_once $SETTINGS['cpassman_dir'].'/sources/checks.php'; |
|
47 | +if (!checkUser($_SESSION['user_id'], $_SESSION['key'], curPage($SETTINGS), $SETTINGS)) { |
|
48 | 48 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; |
49 | 49 | //not allowed page |
50 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
50 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
51 | 51 | exit; |
52 | 52 | } |
53 | 53 | |
54 | 54 | // Load |
55 | -require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php'; |
|
55 | +require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php'; |
|
56 | 56 | |
57 | 57 | ?> |
58 | 58 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | try { |
31 | 31 | $this->connection = new mysqli(DB_HOST, DB_USER, DB_PASSWD_CLEAR, DB_NAME); |
32 | 32 | |
33 | - if ( mysqli_connect_errno()) { |
|
33 | + if (mysqli_connect_errno()) { |
|
34 | 34 | throw new Exception("Could not connect to database."); |
35 | 35 | } |
36 | 36 | } catch (Exception $e) { |
@@ -38,38 +38,38 @@ discard block |
||
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | - public function select($query = "" , $params = []) |
|
41 | + public function select($query = "", $params = []) |
|
42 | 42 | { |
43 | 43 | try { |
44 | - $stmt = $this->executeStatement( $query , $params ); |
|
44 | + $stmt = $this->executeStatement($query, $params); |
|
45 | 45 | $result = $stmt->get_result()->fetch_all(MYSQLI_ASSOC); |
46 | 46 | $stmt->close(); |
47 | 47 | |
48 | 48 | return $result; |
49 | - } catch(Exception $e) { |
|
50 | - throw New Exception( $e->getMessage() ); |
|
49 | + } catch (Exception $e) { |
|
50 | + throw New Exception($e->getMessage()); |
|
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - private function executeStatement($query = "" , $params = []) |
|
55 | + private function executeStatement($query = "", $params = []) |
|
56 | 56 | { |
57 | 57 | try { |
58 | - $stmt = $this->connection->prepare( $query ); |
|
58 | + $stmt = $this->connection->prepare($query); |
|
59 | 59 | |
60 | - if($stmt === false) { |
|
61 | - throw New Exception("Unable to do prepared statement: " . $query); |
|
60 | + if ($stmt === false) { |
|
61 | + throw New Exception("Unable to do prepared statement: ".$query); |
|
62 | 62 | } |
63 | 63 | |
64 | - if( $params ) { |
|
64 | + if ($params) { |
|
65 | 65 | $stmt->bind_param($params[0], $params[1]); |
66 | 66 | } |
67 | 67 | |
68 | 68 | $stmt->execute(); |
69 | 69 | |
70 | 70 | return $stmt; |
71 | - } catch(Exception $e) { |
|
72 | - throw New Exception( $e->getMessage() ); |
|
71 | + } catch (Exception $e) { |
|
72 | + throw New Exception($e->getMessage()); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
76 | 76 | \ No newline at end of file |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * |
22 | 22 | * @see https://www.teampass.net |
23 | 23 | */ |
24 | -require_once API_ROOT_PATH . "/Model/Database.php"; |
|
24 | +require_once API_ROOT_PATH."/Model/Database.php"; |
|
25 | 25 | |
26 | 26 | class UserModel extends Database |
27 | 27 | { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | // SQL where clause with folders list |
53 | 53 | if (isset($arrQueryStringParams['folders']) === true) { |
54 | 54 | // convert the folders to an array |
55 | - $arrQueryStringParams['folders'] = explode(',', str_replace( array('[',']') , '' , $arrQueryStringParams['folders'])); |
|
55 | + $arrQueryStringParams['folders'] = explode(',', str_replace(array('[', ']'), '', $arrQueryStringParams['folders'])); |
|
56 | 56 | |
57 | 57 | // ensure to only use the intersection |
58 | 58 | $foldersList = implode(',', array_intersect($arrQueryStringParams['folders'], $userData['folders_list'])); |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | // SQL where clause with item id |
127 | 127 | if (isset($arrQueryStringParams['id']) === true) { |
128 | 128 | // build sql where clause by ID |
129 | - $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'] . $sql_constraint; |
|
129 | + $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'].$sql_constraint; |
|
130 | 130 | } else if (isset($arrQueryStringParams['label']) === true) { |
131 | 131 | // build sql where clause by LABEL |
132 | - $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']) . $sql_constraint; |
|
132 | + $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']).$sql_constraint; |
|
133 | 133 | } else if (isset($arrQueryStringParams['description']) === true) { |
134 | 134 | // build sql where clause by LABEL |
135 | 135 | $sqlExtra = ' WHERE i.description '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['description'] : ' = '.$arrQueryStringParams['description']).$sql_constraint; |
@@ -54,7 +54,7 @@ |
||
54 | 54 | Container::addConnection($connection); |
55 | 55 | |
56 | 56 | // get id attribute |
57 | - if (isset($SETTINGS['ldap_guid_attibute']) ===true && empty($SETTINGS['ldap_guid_attibute']) === false) { |
|
57 | + if (isset($SETTINGS['ldap_guid_attibute']) === true && empty($SETTINGS['ldap_guid_attibute']) === false) { |
|
58 | 58 | $idAttribute = $SETTINGS['ldap_guid_attibute']; |
59 | 59 | } else { |
60 | 60 | $idAttribute = 'objectguid'; |
@@ -50,7 +50,7 @@ |
||
50 | 50 | $arrFolders = $folderModel->getFoldersInfo(explode(",", $userData['folders_list'])); |
51 | 51 | $responseData = json_encode($arrFolders); |
52 | 52 | } catch (Error $e) { |
53 | - $strErrorDesc = $e->getMessage() . ' Something went wrong! Please contact support.'; |
|
53 | + $strErrorDesc = $e->getMessage().' Something went wrong! Please contact support.'; |
|
54 | 54 | $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; |
55 | 55 | } |
56 | 56 | } |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @see https://www.teampass.net |
24 | 24 | */ |
25 | -require_once API_ROOT_PATH . "/Model/Database.php"; |
|
25 | +require_once API_ROOT_PATH."/Model/Database.php"; |
|
26 | 26 | |
27 | 27 | class FolderModel extends Database |
28 | 28 | { |
29 | 29 | public function getFoldersInfo(array $foldersId): array |
30 | 30 | { |
31 | - $rows = $this->select( "SELECT id, title FROM " . prefixTable('nested_tree') . " WHERE nlevel=1" ); |
|
31 | + $rows = $this->select("SELECT id, title FROM ".prefixTable('nested_tree')." WHERE nlevel=1"); |
|
32 | 32 | |
33 | 33 | $ret = []; |
34 | 34 | |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | private function getFoldersChildren(int $parentId, array $foldersId): array |
56 | 56 | { |
57 | 57 | $ret = []; |
58 | - $childrens = $this->select('SELECT id, title FROM ' . prefixTable('nested_tree') . ' WHERE parent_id=' . $parentId); |
|
58 | + $childrens = $this->select('SELECT id, title FROM '.prefixTable('nested_tree').' WHERE parent_id='.$parentId); |
|
59 | 59 | |
60 | - if ( count($childrens) > 0) { |
|
60 | + if (count($childrens) > 0) { |
|
61 | 61 | foreach ($childrens as $children) { |
62 | 62 | $isVisible = in_array((int) $children['id'], $foldersId); |
63 | 63 | $childs = $this->getFoldersChildren($children['id'], $foldersId); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | DB::debugmode(false); |
64 | 64 | $rows = DB::query( |
65 | 65 | 'SELECT * |
66 | - FROM ' . prefixTable('processes') . ' |
|
66 | + FROM ' . prefixTable('processes').' |
|
67 | 67 | WHERE is_in_progress = %i AND process_type = %s |
68 | 68 | ORDER BY increment_id ASC LIMIT 0,10', |
69 | 69 | 0, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | { |
119 | 119 | //if ((int) $SETTINGS['enable_backlog_mail'] === 1) { |
120 | 120 | $row = DB::queryFirstRow( |
121 | - 'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', |
|
121 | + 'SELECT valeur FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', |
|
122 | 122 | 'cron', |
123 | 123 | 'sending_emails' |
124 | 124 | ); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | if ((int) (time() - $row['valeur']) >= 300 || (int) $row['valeur'] === 0) { |
127 | 127 | $rows = DB::query( |
128 | 128 | 'SELECT * |
129 | - FROM ' . prefixTable('emails') . |
|
129 | + FROM ' . prefixTable('emails'). |
|
130 | 130 | ' WHERE status != %s', |
131 | 131 | 'sent' |
132 | 132 | ); |