Unsupported scripts and control panel web app for a hosting company
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ssh.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?PHP
  2. require_once('lib/dashboard.php');
  3. require_once('lib/account.php');
  4. require_once('lib/common.php');
  5. checkAccess(HAS_SSH);
  6. define('TITLE', 'SSH');
  7. addDashboardItem('Frequently asked questions', 'How do I create SSH keys?', 'support/028');
  8. if (isset($_POST['delete'])) {
  9. $keys = array();
  10. foreach ($_POST as $k => $v) {
  11. if (substr($k, 0, 4) == 'key_' && ctype_digit(substr($k, 4))) {
  12. $keys[] = (int)substr($k, 4);
  13. }
  14. }
  15. if (count($keys) > 0) {
  16. $sql = 'DELETE FROM sshkeys WHERE (user_id = '.UID.') AND (0';
  17. foreach ($keys as $key) {
  18. $sql .= ' OR key_id = ' . $key;
  19. }
  20. $sql .= ')';
  21. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  22. logger::log('Deleted '.mysql_affected_rows().' SSH key(s)', logger::information);
  23. $sql = 'INSERT INTO actions (user_id, action_type, action_value) VALUES (';
  24. $sql .= UID . ', \'updateconf\', \'sshkeys\')';
  25. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  26. header('Location: ' . CP_PATH . 'ssh');
  27. exit();
  28. }
  29. }
  30. if (isset($_POST['add'])) {
  31. $sql = 'INSERT INTO sshkeys (user_id, key_comment, key_key) VALUES (';
  32. $sql .= UID . ', \'' . m($_POST['comment']) . '\', \'' . m($_POST['key']);
  33. $sql .= '\')';
  34. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  35. logger::log('Added SSH key: ' .$_POST['comment'], logger::information);
  36. $sql = 'INSERT INTO actions (user_id, action_type, action_value) VALUES (';
  37. $sql .= UID . ', \'updateconf\', \'sshkeys\')';
  38. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  39. header('Location: ' . CP_PATH . 'ssh');
  40. exit();
  41. }
  42. require_once('lib/header.php');
  43. require_once('pages/ssh.keys.php');
  44. require_once('pages/ssh.addkey.php');
  45. require_once('lib/footer.php');
  46. ?>