Code Duplication    Length = 29-30 lines in 2 locations

lib/elFinderVolumeBox.class.php 1 location

@@ 151-180 (lines=30) @@
148
                return ['exit' => true, 'body' => '{msg:errNetMountNoDriver}'];
149
            }
150
151
            if (isset($_GET['code'])) {
152
                try {
153
                    // Obtain the token using the code received by the Box.com API
154
                    $this->session->set('BoxTokens',
155
                                        $this->_bd_obtainAccessToken($options['client_id'], $options['client_secret'], $_GET['code']));
156
157
                    $out = [
158
                            'node' => $options['id'],
159
                            'json' => '{"protocol": "box", "mode": "done", "reset": 1}',
160
                            'bind' => 'netmount',
161
162
                    ];
163
164
                    return ['exit' => 'callback', 'out' => $out];
165
                } catch (Exception $e) {
166
                    $out = [
167
                            'node' => $options['id'],
168
                            'json' => json_encode(['error' => $e->getMessage()]),
169
                    ];
170
171
                    return ['exit' => 'callback', 'out' => $out];
172
                }
173
            } elseif (! empty($_GET['error'])) {
174
                $out = [
175
                        'node' => $options['id'],
176
                        'json' => json_encode(['error' => elFinder::ERROR_ACCESS_DENIED]),
177
                ];
178
179
                return ['exit' => 'callback', 'out' => $out];
180
            }
181
182
            if ($options['user'] === 'init') {
183
                $this->token = $this->session->get('BoxTokens');

lib/elFinderVolumeOneDrive.class.php 1 location

@@ 148-176 (lines=29) @@
145
                return ['exit' => true, 'body' => '{msg:errNetMountNoDriver}'];
146
            }
147
148
            if (isset($_GET['code'])) {
149
                try {
150
                    // Obtain the token using the code received by the OneDrive API
151
                    $this->session->set('OneDriveTokens',
152
                                        $this->_od_obtainAccessToken($options['client_id'], $options['client_secret'], $_GET['code']));
153
154
                    $out = [
155
                            'node' => $options['id'],
156
                            'json' => '{"protocol": "onedrive", "mode": "done", "reset": 1}',
157
                            'bind' => 'netmount',
158
                    ];
159
160
                    return ['exit' => 'callback', 'out' => $out];
161
                } catch (Exception $e) {
162
                    $out = [
163
                            'node' => $options['id'],
164
                            'json' => json_encode(['error' => elFinder::ERROR_ACCESS_DENIED.' '.$e->getMessage()]),
165
                    ];
166
167
                    return ['exit' => 'callback', 'out' => $out];
168
                }
169
            } elseif (! empty($_GET['error'])) {
170
                $out = [
171
                        'node' => $options['id'],
172
                        'json' => json_encode(['error' => elFinder::ERROR_ACCESS_DENIED]),
173
                ];
174
175
                return ['exit' => 'callback', 'out' => $out];
176
            }
177
178
            if ($options['user'] === 'init') {
179
                $this->token = $this->session->get('OneDriveTokens');