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.

appconfig.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. $appConfig = \OC::$server->getAppConfig();
  23. switch($action) {
  24. case 'getValue':
  25. $result=$appConfig->getValue($app, $_GET['key'], $_GET['defaultValue']);
  26. break;
  27. case 'setValue':
  28. $result=$appConfig->setValue($app, $_POST['key'], $_POST['value']);
  29. break;
  30. case 'getApps':
  31. $result=$appConfig->getApps();
  32. break;
  33. case 'getKeys':
  34. $result=$appConfig->getKeys($app);
  35. break;
  36. case 'hasKey':
  37. $result=$appConfig->hasKey($app, $_GET['key']);
  38. break;
  39. case 'deleteKey':
  40. $result=$appConfig->deleteKey($app, $_POST['key']);
  41. break;
  42. case 'deleteApp':
  43. $result=$appConfig->deleteApp($app);
  44. break;
  45. }
  46. OC_JSON::success(array('data'=>$result));