summaryrefslogtreecommitdiffstats
path: root/lib/ocs.php
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-09-13 10:23:41 +0000
committerTom Needham <needham.thomas@gmail.com>2012-09-13 10:23:41 +0000
commit227ada32576b7b9de56efe1f5d9ae96c6493be52 (patch)
tree41f3a88fb646488e043ba638e92e7f313d2cb64c /lib/ocs.php
parentfa5dff22a02aeb5985215454549ab1020382b197 (diff)
parent5a149dcfab960fe21c2df1bf4f1ba27f1a10b2c8 (diff)
downloadnextcloud-server-227ada32576b7b9de56efe1f5d9ae96c6493be52.tar.gz
nextcloud-server-227ada32576b7b9de56efe1f5d9ae96c6493be52.zip
Fix merge conflicts
Diffstat (limited to 'lib/ocs.php')
-rw-r--r--lib/ocs.php174
1 files changed, 85 insertions, 89 deletions
diff --git a/lib/ocs.php b/lib/ocs.php
index d0b835b522b..6cdb2480860 100644
--- a/lib/ocs.php
+++ b/lib/ocs.php
@@ -75,17 +75,19 @@ class OC_OCS {
$method='get';
}elseif($_SERVER['REQUEST_METHOD'] == 'PUT') {
$method='put';
- parse_str(file_get_contents("php://input"),$put_vars);
+ parse_str(file_get_contents("php://input"), $put_vars);
}elseif($_SERVER['REQUEST_METHOD'] == 'POST') {
$method='post';
}else{
echo('internal server error: method not supported');
exit();
}
+<<<<<<< HEAD
$format = self::readData($method, 'format', 'text', '');
$txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
$txt.=OC_OCS::getDebugOutput();
echo(OC_OCS::generateXml($format,'failed',999,$txt));
+
}
/**
@@ -116,7 +118,7 @@ class OC_OCS {
if(isset($_SERVER['PHP_AUTH_PW'])) $authpw=$_SERVER['PHP_AUTH_PW']; else $authpw='';
if(empty($authuser)) {
- if($forceuser){
+ if($forceuser) {
header('WWW-Authenticate: Basic realm="your valid user account or api key"');
header('HTTP/1.0 401 Unauthorized');
exit;
@@ -124,8 +126,8 @@ class OC_OCS {
$identifieduser='';
}
}else{
- if(!OC_User::login($authuser,$authpw)){
- if($forceuser){
+ if(!OC_User::login($authuser, $authpw)) {
+ if($forceuser) {
header('WWW-Authenticate: Basic realm="your valid user account or api key"');
header('HTTP/1.0 401 Unauthorized');
exit;
@@ -170,69 +172,69 @@ class OC_OCS {
$writer = xmlwriter_open_memory();
xmlwriter_set_indent( $writer, 2 );
xmlwriter_start_document($writer );
- xmlwriter_start_element($writer,'ocs');
- xmlwriter_start_element($writer,'meta');
- xmlwriter_write_element($writer,'status',$status);
- xmlwriter_write_element($writer,'statuscode',$statuscode);
- xmlwriter_write_element($writer,'message',$message);
+ xmlwriter_start_element($writer, 'ocs');
+ xmlwriter_start_element($writer, 'meta');
+ xmlwriter_write_element($writer, 'status', $status);
+ xmlwriter_write_element($writer, 'statuscode', $statuscode);
+ xmlwriter_write_element($writer, 'message', $message);
if($itemscount<>'') xmlwriter_write_element($writer,'totalitems',$itemscount);
- if(!empty($itemsperpage)) xmlwriter_write_element($writer,'itemsperpage',$itemsperpage);
+ if(!empty($itemsperpage)) xmlwriter_write_element($writer, 'itemsperpage', $itemsperpage);
xmlwriter_end_element($writer);
if($dimension=='0') {
// 0 dimensions
- xmlwriter_write_element($writer,'data',$data);
+ xmlwriter_write_element($writer, 'data', $data);
}elseif($dimension=='1') {
- xmlwriter_start_element($writer,'data');
+ xmlwriter_start_element($writer, 'data');
foreach($data as $key=>$entry) {
- xmlwriter_write_element($writer,$key,$entry);
+ xmlwriter_write_element($writer, $key, $entry);
}
xmlwriter_end_element($writer);
}elseif($dimension=='2') {
xmlwriter_start_element($writer,'data');
foreach($data as $entry) {
- xmlwriter_start_element($writer,$tag);
- if(!empty($tagattribute)) {
- xmlwriter_write_attribute($writer,'details',$tagattribute);
- }
- foreach($entry as $key=>$value) {
- if(is_array($value)){
- foreach($value as $k=>$v) {
- xmlwriter_write_element($writer,$k,$v);
- }
- } else {
- xmlwriter_write_element($writer,$key,$value);
- }
- }
- xmlwriter_end_element($writer);
- }
+ xmlwriter_start_element($writer, $tag);
+ if(!empty($tagattribute)) {
+ xmlwriter_write_attribute($writer, 'details', $tagattribute);
+ }
+ foreach($entry as $key=>$value) {
+ if(is_array($value)) {
+ foreach($value as $k=>$v) {
+ xmlwriter_write_element($writer, $k, $v);
+ }
+ } else {
+ xmlwriter_write_element($writer, $key, $value);
+ }
+ }
+ xmlwriter_end_element($writer);
+ }
xmlwriter_end_element($writer);
}elseif($dimension=='3') {
- xmlwriter_start_element($writer,'data');
+ xmlwriter_start_element($writer, 'data');
foreach($data as $entrykey=>$entry) {
- xmlwriter_start_element($writer,$tag);
- if(!empty($tagattribute)) {
- xmlwriter_write_attribute($writer,'details',$tagattribute);
- }
- foreach($entry as $key=>$value) {
- if(is_array($value)){
- xmlwriter_start_element($writer,$entrykey);
- foreach($value as $k=>$v) {
- xmlwriter_write_element($writer,$k,$v);
- }
- xmlwriter_end_element($writer);
- } else {
- xmlwriter_write_element($writer,$key,$value);
- }
- }
- xmlwriter_end_element($writer);
+ xmlwriter_start_element($writer, $tag);
+ if(!empty($tagattribute)) {
+ xmlwriter_write_attribute($writer, 'details', $tagattribute);
+ }
+ foreach($entry as $key=>$value) {
+ if(is_array($value)) {
+ xmlwriter_start_element($writer, $entrykey);
+ foreach($value as $k=>$v) {
+ xmlwriter_write_element($writer, $k, $v);
+ }
+ xmlwriter_end_element($writer);
+ } else {
+ xmlwriter_write_element($writer, $key, $value);
+ }
+ }
+ xmlwriter_end_element($writer);
}
xmlwriter_end_element($writer);
}elseif($dimension=='dynamic') {
- xmlwriter_start_element($writer,'data');
- OC_OCS::toxml($writer,$data,'comment');
+ xmlwriter_start_element($writer, 'data');
+ OC_OCS::toxml($writer, $data, 'comment');
xmlwriter_end_element($writer);
}
@@ -250,19 +252,16 @@ class OC_OCS {
if (is_numeric($key)) {
$key = $node;
}
- if (is_array($value)){
- xmlwriter_start_element($writer,$key);
- OC_OCS::toxml($writer,$value,$node);
+ if (is_array($value)) {
+ xmlwriter_start_element($writer, $key);
+ OC_OCS::toxml($writer,$value, $node);
xmlwriter_end_element($writer);
}else{
- xmlwriter_write_element($writer,$key,$value);
+ xmlwriter_write_element($writer, $key, $value);
}
}
}
-
-
-
/**
* return the config data of this server
* @param string $format
@@ -271,17 +270,16 @@ class OC_OCS {
public static function apiConfig($parameters) {
$format = $parameters['format'];
$user=OC_OCS::checkpassword(false);
- $url=substr(OCP\Util::getServerHost().$_SERVER['SCRIPT_NAME'],0,-11).'';
+ $url=substr(OCP\Util::getServerHost().$_SERVER['SCRIPT_NAME'], 0, -11).'';
$xml['version']='1.7';
$xml['website']='ownCloud';
$xml['host']=OCP\Util::getServerHost();
$xml['contact']='';
$xml['ssl']='false';
- echo(OC_OCS::generatexml($format,'ok',100,'',$xml,'config','',1));
+ echo(OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'config', '', 1));
}
-
/**
* check if the provided login/apikey/password is valid
* @param string $format
@@ -290,20 +288,18 @@ class OC_OCS {
* @return string xml/json
*/
private static function personCheck($format,$login,$passwd) {
- if($login<>''){
- if(OC_User::login($login,$passwd)){
+ if($login<>'') {
+ if(OC_User::login($login, $passwd)) {
$xml['person']['personid']=$login;
- echo(OC_OCS::generatexml($format,'ok',100,'',$xml,'person','check',2));
+ echo(OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'person', 'check', 2));
}else{
- echo(OC_OCS::generatexml($format,'failed',102,'login not valid'));
+ echo(OC_OCS::generatexml($format, 'failed', 102, 'login not valid'));
}
}else{
- echo(OC_OCS::generatexml($format,'failed',101,'please specify all mandatory fields'));
+ echo(OC_OCS::generatexml($format, 'failed', 101, 'please specify all mandatory fields'));
}
}
-
-
// ACTIVITY API #############################################
/**
@@ -313,12 +309,12 @@ class OC_OCS {
* @param string $pagesize
* @return string xml/json
*/
- private static function activityGet($format,$page,$pagesize) {
+ private static function activityGet($format, $page, $pagesize) {
$user=OC_OCS::checkpassword();
//TODO
- $txt=OC_OCS::generatexml($format,'ok',100,'',$xml,'activity','full',2,$totalcount,$pagesize);
+ $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'activity', 'full', 2, $totalcount,$pagesize);
echo($txt);
}
@@ -331,7 +327,7 @@ class OC_OCS {
private static function activityPut($format,$message) {
// not implemented in ownCloud
$user=OC_OCS::checkpassword();
- echo(OC_OCS::generatexml($format,'ok',100,''));
+ echo(OC_OCS::generatexml($format, 'ok', 100, ''));
}
// PRIVATEDATA API #############################################
@@ -343,9 +339,9 @@ class OC_OCS {
* @param string $key
* @return string xml/json
*/
- private static function privateDataGet($format,$app="",$key="") {
+ private static function privateDataGet($format, $app="", $key="") {
$user=OC_OCS::checkpassword();
- $result=OC_OCS::getData($user,$app,$key);
+ $result=OC_OCS::getData($user, $app, $key);
$xml=array();
foreach($result as $i=>$log) {
$xml[$i]['key']=$log['key'];
@@ -368,8 +364,8 @@ class OC_OCS {
*/
private static function privateDataSet($format, $app, $key, $value) {
$user=OC_OCS::checkpassword();
- if(OC_OCS::setData($user,$app,$key,$value)){
- echo(OC_OCS::generatexml($format,'ok',100,''));
+ if(OC_OCS::setData($user, $app, $key, $value)) {
+ echo(OC_OCS::generatexml($format, 'ok', 100, ''));
}
}
@@ -381,15 +377,15 @@ class OC_OCS {
* @return string xml/json
*/
private static function privateDataDelete($format, $app, $key) {
- if($key=="" or $app==""){
+ if($key=="" or $app=="") {
return; //key and app are NOT optional here
}
$user=OC_OCS::checkpassword();
- if(OC_OCS::deleteData($user,$app,$key)){
- echo(OC_OCS::generatexml($format,'ok',100,''));
+ if(OC_OCS::deleteData($user, $app, $key)) {
+ echo(OC_OCS::generatexml($format, 'ok', 100, ''));
}
}
-
+
/**
* get private data
* @param string $user
@@ -398,24 +394,24 @@ class OC_OCS {
* @param bool $like use LIKE instead of = when comparing keys
* @return array
*/
- public static function getData($user,$app="",$key="") {
- if($app){
+ public static function getData($user, $app="", $key="") {
+ if($app) {
$apps=array($app);
}else{
$apps=OC_Preferences::getApps($user);
}
- if($key){
+ if($key) {
$keys=array($key);
}else{
- foreach($apps as $app){
- $keys=OC_Preferences::getKeys($user,$app);
+ foreach($apps as $app) {
+ $keys=OC_Preferences::getKeys($user, $app);
}
}
$result=array();
- foreach($apps as $app){
- foreach($keys as $key){
- $value=OC_Preferences::getValue($user,$app,$key);
- $result[]=array('app'=>$app,'key'=>$key,'value'=>$value);
+ foreach($apps as $app) {
+ foreach($keys as $key) {
+ $value=OC_Preferences::getValue($user, $app, $key);
+ $result[]=array('app'=>$app, 'key'=>$key, 'value'=>$value);
}
}
return $result;
@@ -430,7 +426,7 @@ class OC_OCS {
* @return bool
*/
public static function setData($user, $app, $key, $value) {
- return OC_Preferences::setValue($user,$app,$key,$value);
+ return OC_Preferences::setValue($user, $app, $key, $value);
}
/**
@@ -441,7 +437,7 @@ class OC_OCS {
* @return string xml/json
*/
public static function deleteData($user, $app, $key) {
- return OC_Preferences::deleteKey($user,$app,$key);
+ return OC_Preferences::deleteKey($user, $app, $key);
}
@@ -480,7 +476,7 @@ class OC_OCS {
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$user)) {
- if(OC_User::userExists($user)){
+ if(OC_User::userExists($user)) {
// calculate the disc space
$user_dir = '/'.$user.'/files';
OC_Filesystem::init($user_dir);
@@ -541,7 +537,7 @@ class OC_OCS {
private static function publicKeyGet($format,$user) {
$login=OC_OCS::checkpassword();
- if(OC_User::userExists($user)){
+ if(OC_User::userExists($user)) {
// calculate the disc space
$txt='this is the public key of '.$user;
echo($txt);
@@ -560,7 +556,7 @@ class OC_OCS {
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$user)) {
- if(OC_User::userExists($user)){
+ if(OC_User::userExists($user)) {
// calculate the disc space
$txt='this is the private key of '.$user;
echo($txt);