diff --git a/frontend/modules/admin/node/add.php b/frontend/modules/admin/node/add.php index c43fa4c..897d5e7 100644 --- a/frontend/modules/admin/node/add.php +++ b/frontend/modules/admin/node/add.php @@ -56,12 +56,29 @@ if(isset($_POST['submit'])) $sErrors[] = $locale->strings['error-admin-nodes-add-privatekey']; } } + else + { + $sPublicKeyName = ""; + $sPrivateKeyName = ""; + } if(empty($sErrors)) { - if(isset($_POST['customkey']) == false || - (move_uploaded_file($_FILES['publickey']['tmp_name'], "/etc/cvm/keys/{$sPublicKeyName}") && - move_uploaded_file($_FILES['privatekey']['tmp_name'], "/etc/cvm/keys/{$sPrivateKeyName}"))) + if(isset($_POST['customkey'])) + { + $sSuccess = move_uploaded_file($_FILES['publickey']['tmp_name'], "/etc/cvm/keys/{$sPublicKeyName}") && + move_uploaded_file($_FILES['privatekey']['tmp_name'], "/etc/cvm/keys/{$sPrivateKeyName}"); + if(!$sSuccess) + { + $sErrors[] = $locale->strings['error-admin-nodes-add-upload']; + } + } + else + { + $sSuccess = true; + } + + if($sSuccess) { $sNode = new Node(0); $sNode->uName = $_POST['name']; @@ -76,10 +93,6 @@ if(isset($_POST['submit'])) redirect("/admin/nodes/"); } - else - { - $sErrors[] = $locale->strings['error-admin-nodes-add-upload']; - } } }