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.

51 lines
1.5 KiB

14 years ago
14 years ago
  1. <?php
  2. /**
  3. * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
  4. * This file is licensed under the Affero General Public License version 3 or later.
  5. * See the COPYING-README file.
  6. */
  7. OC_Util::checkAdminUser();
  8. OCP\JSON::callCheck();
  9. $action=isset($_POST['action'])?$_POST['action']:$_GET['action'];
  10. if(isset($_POST['app']) || isset($_GET['app'])) {
  11. $app=OC_App::cleanAppId(isset($_POST['app'])?$_POST['app']:$_GET['app']);
  12. }
  13. // An admin should not be able to add remote and public services
  14. // on its own. This should only be possible programmatically.
  15. // This change is due the fact that an admin may not be expected
  16. // to execute arbitrary code in every environment.
  17. if($app === 'core' && isset($_POST['key']) &&(substr($_POST['key'],0,7) === 'remote_' || substr($_POST['key'],0,7) === 'public_')) {
  18. OC_JSON::error(array('data' => array('message' => 'Unexpected error!')));
  19. return;
  20. }
  21. $result=false;
  22. switch($action) {
  23. case 'getValue':
  24. $result=OC_Appconfig::getValue($app, $_GET['key'], $_GET['defaultValue']);
  25. break;
  26. case 'setValue':
  27. $result=OC_Appconfig::setValue($app, $_POST['key'], $_POST['value']);
  28. break;
  29. case 'getApps':
  30. $result=OC_Appconfig::getApps();
  31. break;
  32. case 'getKeys':
  33. $result=OC_Appconfig::getKeys($app);
  34. break;
  35. case 'hasKey':
  36. $result=OC_Appconfig::hasKey($app, $_GET['key']);
  37. break;
  38. case 'deleteKey':
  39. $result=OC_Appconfig::deleteKey($app, $_POST['key']);
  40. break;
  41. case 'deleteApp':
  42. $result=OC_Appconfig::deleteApp($app);
  43. break;
  44. }
  45. OC_JSON::success(array('data'=>$result));