summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-02-17 23:25:31 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-08-14 13:42:56 +0200
commita7e4785be97dc305c0593332a7222db2c9b01e35 (patch)
tree52574f32e8b63e8c7ba6fbbc12477acadc77414b
parentddc7f668e59223d95cb42e4f0281d5dab5888d79 (diff)
downloadnextcloud-server-a7e4785be97dc305c0593332a7222db2c9b01e35.tar.gz
nextcloud-server-a7e4785be97dc305c0593332a7222db2c9b01e35.zip
Cleanup OCS code
This removes unused code from `OC_OCS` which nobody understood what it really was for anyways.
-rw-r--r--lib/private/ocs.php66
-rw-r--r--lib/private/ocs/privatedata.php2
-rw-r--r--lib/public/appframework/http/ocsresponse.php2
3 files changed, 6 insertions, 64 deletions
diff --git a/lib/private/ocs.php b/lib/private/ocs.php
index bb1aabf8f18..f03f0c6a1a6 100644
--- a/lib/private/ocs.php
+++ b/lib/private/ocs.php
@@ -32,71 +32,15 @@ use OCP\API;
/**
* Class to handle open collaboration services API requests
- *
*/
class OC_OCS {
-
/**
- * reads input data from get/post and converts the date to a special data-type
- *
- * @param string $method HTTP method to read the key from
- * @param string $key Parameter to read
- * @param string $type Variable type to format data
- * @param string $default Default value to return if the key is not found
- * @return string Data or if the key is not found and no default is set it will exit with a 400 Bad request
- */
- public static function readData($method, $key, $type = 'raw', $default = null) {
- $data = false;
- if ($method == 'get') {
- if (isset($_GET[$key])) {
- $data = $_GET[$key];
- } else if (isset($default)) {
- return $default;
- } else {
- $data = false;
- }
- } else if ($method == 'post') {
- if (isset($_POST[$key])) {
- $data = $_POST[$key];
- } else if (isset($default)) {
- return $default;
- } else {
- $data = false;
- }
- }
- if ($data === false) {
- throw new \OC\OCS\Exception(new OC_OCS_Result(null, 400, 'Bad request. Please provide a valid '.$key));
- } else {
- // NOTE: Is the raw type necessary? It might be a little risky without sanitization
- if ($type == 'raw') return $data;
- elseif ($type == 'text') return OC_Util::sanitizeHTML($data);
- elseif ($type == 'int') return (int) $data;
- elseif ($type == 'float') return (float) $data;
- elseif ($type == 'array') return OC_Util::sanitizeHTML($data);
- else return OC_Util::sanitizeHTML($data);
- }
- }
-
+ * Called when a not existing OCS endpoint has been called
+ */
public static function notFound() {
- $format = OC_API::requestedFormat();
+ $format = \OC::$server->getRequest()->getParam('format', 'xml');
$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();
+ .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
+ OC_API::respond(new OC_OCS_Result(null, API::RESPOND_UNKNOWN_ERROR, $txt), $format); }
- OC_API::respond(new OC_OCS_Result(null, API::RESPOND_UNKNOWN_ERROR, $txt), $format);
- }
-
- /**
- * generated some debug information to make it easier to find failed API calls
- * @return string data
- */
- private static function getDebugOutput() {
- $txt='';
- $txt.="debug output:\n";
- if(isset($_SERVER['REQUEST_METHOD'])) $txt.='http request method: '.$_SERVER['REQUEST_METHOD']."\n";
- if(isset($_SERVER['REQUEST_URI'])) $txt.='http request uri: '.$_SERVER['REQUEST_URI']."\n";
- if(isset($_GET)) foreach($_GET as $key=>$value) $txt.='get parameter: '.$key.'->'.$value."\n";
- if(isset($_POST)) foreach($_POST as $key=>$value) $txt.='post parameter: '.$key.'->'.$value."\n";
- return($txt);
- }
}
diff --git a/lib/private/ocs/privatedata.php b/lib/private/ocs/privatedata.php
index 0fa50ad0c67..249c17b3792 100644
--- a/lib/private/ocs/privatedata.php
+++ b/lib/private/ocs/privatedata.php
@@ -69,7 +69,7 @@ class OC_OCS_Privatedata {
$user = OC_User::getUser();
$app = addslashes(strip_tags($parameters['app']));
$key = addslashes(strip_tags($parameters['key']));
- $value = OC_OCS::readData('post', 'value', 'text');
+ $value = (string)$_POST['value'];
// update in DB
$query = \OCP\DB::prepare('UPDATE `*PREFIX*privatedata` SET `value` = ? WHERE `user` = ? AND `app` = ? AND `key` = ?');
diff --git a/lib/public/appframework/http/ocsresponse.php b/lib/public/appframework/http/ocsresponse.php
index adbe33d7c3c..37af07b70c8 100644
--- a/lib/public/appframework/http/ocsresponse.php
+++ b/lib/public/appframework/http/ocsresponse.php
@@ -29,8 +29,6 @@ namespace OCP\AppFramework\Http;
use OCP\AppFramework\Http;
-use OC_OCS;
-
/**
* A renderer for OCS responses
* @since 8.1.0