Blame view

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