5 * Copyright 2012, Franck Villaume - TrivialDev
6 * http://fusionforge.org
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once $gfcommon.'include/account.php';
28 $authorized_key = getStringFromRequest('authorized_key');
29 $uploaded_filekey = getUploadedFile('uploaded_filekey');
30 if (strlen($authorized_key)) {
31 checkKeys($authorized_key);
32 if (!$u->addAuthorizedKey($authorized_key)) {
33 session_redirect('/account/?&error_msg='.urlencode($u->getErrorMessage()));
35 $feedback = _('SSH Key added successfully.');
36 session_redirect('/account/?&feedback='.urlencode($feedback));
39 if (!is_uploaded_file($uploaded_filekey['tmp_name'])) {
40 $return_msg = _('Invalid file name.');
41 session_redirect('/account/?&error_msg='.urlencode($return_msg));
44 $payload = fread(fopen($uploaded_filekey['tmp_name'], 'r'), $uploaded_filekey['size']);
45 if (strlen($payload)) {
47 if (!$u->addAuthorizedKey($payload)) {
48 session_redirect('/account/?&error_msg='.urlencode($u->getErrorMessage()));
50 $feedback = _('SSH Key added successfully.');
51 session_redirect('/account/?&feedback='.urlencode($feedback));
54 session_redirect('/account/');