Enables Uberspace users to administrate some functions via a very simple web panel
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.

submit.php 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /***********************************************************************
  3. * Copyright (C) 2016 Max Mehl <mail [at] mehl [dot] mx>
  4. ************************************************************************
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public
  17. * License along with this program. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. *
  20. ************************************************************************
  21. *
  22. * This file get the input from index.php, sanitises the data and
  23. * forwards it to action.sh. The output of action.sh will be returned
  24. * in the end.
  25. *
  26. ***********************************************************************/
  27. ?>
  28. <?php include_once 'lang.php'; ?>
  29. <!DOCTYPE html>
  30. <html lang="<?php echo $lang['LANG']; ?>">
  31. <head>
  32. <meta charset="utf-8">
  33. <title>UAAP | <?php echo $lang['S_INTRO']; ?></title>
  34. <link rel='stylesheet' href='/static/style.css' type='text/css' media='all' />
  35. </head>
  36. <body>
  37. <div class="wrapper">
  38. <h1><?php echo $lang['S_INTRO']; ?></h1>
  39. <p><strong><a href="/"><?php echo $lang['S_BACK1']; ?></a></strong> <?php echo $lang['S_BACK2']; ?></p>
  40. <table class="boxed"><tr><td>
  41. <?php
  42. // Reads variables of HTML form in index.php
  43. $ACTION = $_POST['action'];
  44. $USER = isset($_POST['user']) ? $_POST['user'] : ''; // surpress empty variable errors
  45. $PASS = isset($_POST['pass']) ? $_POST['pass'] : '';
  46. $SURE = isset($_POST['sure']) ? $_POST['sure'] : '';
  47. // Sanitize variables
  48. $ACTION = escapeshellarg($ACTION);
  49. $USER = escapeshellarg($USER);
  50. $RAND = mt_rand(100000, 999999);
  51. $PASSFILE = '.' . $RAND . '.pass';
  52. file_put_contents($PASSFILE, $PASS);
  53. // Checks if checkbox is activated (default at most forms)
  54. if($SURE == "yes")
  55. {
  56. // Creates full command
  57. $command = '/bin/bash action.sh ' . $ACTION . ' ' . $USER . ' ' . $PASSFILE;
  58. // Execute command and give output
  59. $output = shell_exec($command);
  60. echo "<pre>$output</pre>";
  61. }
  62. else
  63. {
  64. echo $lang['S_CHECKERR'];
  65. }
  66. // Delete passfile
  67. unlink($PASSFILE);
  68. ?>
  69. </td></tr></table>
  70. <p><?php echo $lang['S_MESSAGE']; ?></p>
  71. </div> <!-- /wrapper -->
  72. <div class="footer">
  73. <p><?php echo $lang['FOOTER']; ?></p>
  74. </div>
  75. </body>
  76. </html>