@@ -24,23 +24,23 @@ |
||
24 | 24 | namespace OC\Template; |
25 | 25 | |
26 | 26 | class ResourceNotFoundException extends \LogicException { |
27 | - protected $resource; |
|
28 | - protected $webPath; |
|
27 | + protected $resource; |
|
28 | + protected $webPath; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param string $resource |
|
32 | - * @param string $webPath |
|
33 | - */ |
|
34 | - public function __construct($resource, $webPath) { |
|
35 | - parent::__construct('Resource not found'); |
|
36 | - $this->resource = $resource; |
|
37 | - $this->webPath = $webPath; |
|
38 | - } |
|
30 | + /** |
|
31 | + * @param string $resource |
|
32 | + * @param string $webPath |
|
33 | + */ |
|
34 | + public function __construct($resource, $webPath) { |
|
35 | + parent::__construct('Resource not found'); |
|
36 | + $this->resource = $resource; |
|
37 | + $this->webPath = $webPath; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function getResourcePath() { |
|
44 | - return $this->webPath . '/' . $this->resource; |
|
45 | - } |
|
40 | + /** |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function getResourcePath() { |
|
44 | + return $this->webPath . '/' . $this->resource; |
|
45 | + } |
|
46 | 46 | } |
@@ -41,6 +41,6 @@ |
||
41 | 41 | * @return string |
42 | 42 | */ |
43 | 43 | public function getResourcePath() { |
44 | - return $this->webPath . '/' . $this->resource; |
|
44 | + return $this->webPath.'/'.$this->resource; |
|
45 | 45 | } |
46 | 46 | } |
@@ -26,37 +26,37 @@ |
||
26 | 26 | namespace OC\Template; |
27 | 27 | |
28 | 28 | class TemplateFileLocator { |
29 | - protected $dirs; |
|
30 | - private $path; |
|
29 | + protected $dirs; |
|
30 | + private $path; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param string[] $dirs |
|
34 | - */ |
|
35 | - public function __construct( $dirs ) { |
|
36 | - $this->dirs = $dirs; |
|
37 | - } |
|
32 | + /** |
|
33 | + * @param string[] $dirs |
|
34 | + */ |
|
35 | + public function __construct( $dirs ) { |
|
36 | + $this->dirs = $dirs; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $template |
|
41 | - * @return string |
|
42 | - * @throws \Exception |
|
43 | - */ |
|
44 | - public function find( $template ) { |
|
45 | - if ($template === '') { |
|
46 | - throw new \InvalidArgumentException('Empty template name'); |
|
47 | - } |
|
39 | + /** |
|
40 | + * @param string $template |
|
41 | + * @return string |
|
42 | + * @throws \Exception |
|
43 | + */ |
|
44 | + public function find( $template ) { |
|
45 | + if ($template === '') { |
|
46 | + throw new \InvalidArgumentException('Empty template name'); |
|
47 | + } |
|
48 | 48 | |
49 | - foreach($this->dirs as $dir) { |
|
50 | - $file = $dir.$template.'.php'; |
|
51 | - if (is_file($file)) { |
|
52 | - $this->path = $dir; |
|
53 | - return $file; |
|
54 | - } |
|
55 | - } |
|
56 | - throw new \Exception('template file not found: template:'.$template); |
|
57 | - } |
|
49 | + foreach($this->dirs as $dir) { |
|
50 | + $file = $dir.$template.'.php'; |
|
51 | + if (is_file($file)) { |
|
52 | + $this->path = $dir; |
|
53 | + return $file; |
|
54 | + } |
|
55 | + } |
|
56 | + throw new \Exception('template file not found: template:'.$template); |
|
57 | + } |
|
58 | 58 | |
59 | - public function getPath() { |
|
60 | - return $this->path; |
|
61 | - } |
|
59 | + public function getPath() { |
|
60 | + return $this->path; |
|
61 | + } |
|
62 | 62 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @param string[] $dirs |
34 | 34 | */ |
35 | - public function __construct( $dirs ) { |
|
35 | + public function __construct($dirs) { |
|
36 | 36 | $this->dirs = $dirs; |
37 | 37 | } |
38 | 38 | |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | * @return string |
42 | 42 | * @throws \Exception |
43 | 43 | */ |
44 | - public function find( $template ) { |
|
44 | + public function find($template) { |
|
45 | 45 | if ($template === '') { |
46 | 46 | throw new \InvalidArgumentException('Empty template name'); |
47 | 47 | } |
48 | 48 | |
49 | - foreach($this->dirs as $dir) { |
|
49 | + foreach ($this->dirs as $dir) { |
|
50 | 50 | $file = $dir.$template.'.php'; |
51 | 51 | if (is_file($file)) { |
52 | 52 | $this->path = $dir; |
@@ -24,5 +24,5 @@ |
||
24 | 24 | namespace OC\Hooks; |
25 | 25 | |
26 | 26 | abstract class BasicEmitter implements Emitter { |
27 | - use EmitterTrait; |
|
27 | + use EmitterTrait; |
|
28 | 28 | } |
@@ -32,19 +32,19 @@ |
||
32 | 32 | * @package OC\Hooks |
33 | 33 | */ |
34 | 34 | interface Emitter { |
35 | - /** |
|
36 | - * @param string $scope |
|
37 | - * @param string $method |
|
38 | - * @param callable $callback |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - public function listen($scope, $method, callable $callback); |
|
35 | + /** |
|
36 | + * @param string $scope |
|
37 | + * @param string $method |
|
38 | + * @param callable $callback |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + public function listen($scope, $method, callable $callback); |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $scope optional |
|
45 | - * @param string $method optional |
|
46 | - * @param callable $callback optional |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public function removeListener($scope = null, $method = null, callable $callback = null); |
|
43 | + /** |
|
44 | + * @param string $scope optional |
|
45 | + * @param string $method optional |
|
46 | + * @param callable $callback optional |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public function removeListener($scope = null, $method = null, callable $callback = null); |
|
50 | 50 | } |
@@ -31,35 +31,35 @@ |
||
31 | 31 | * @package OC\Hooks |
32 | 32 | */ |
33 | 33 | abstract class ForwardingEmitter extends BasicEmitter { |
34 | - /** |
|
35 | - * @var \OC\Hooks\Emitter[] array |
|
36 | - */ |
|
37 | - private $forwardEmitters = array(); |
|
34 | + /** |
|
35 | + * @var \OC\Hooks\Emitter[] array |
|
36 | + */ |
|
37 | + private $forwardEmitters = array(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $scope |
|
41 | - * @param string $method |
|
42 | - * @param callable $callback |
|
43 | - */ |
|
44 | - public function listen($scope, $method, callable $callback) { |
|
45 | - parent::listen($scope, $method, $callback); |
|
46 | - foreach ($this->forwardEmitters as $emitter) { |
|
47 | - $emitter->listen($scope, $method, $callback); |
|
48 | - } |
|
49 | - } |
|
39 | + /** |
|
40 | + * @param string $scope |
|
41 | + * @param string $method |
|
42 | + * @param callable $callback |
|
43 | + */ |
|
44 | + public function listen($scope, $method, callable $callback) { |
|
45 | + parent::listen($scope, $method, $callback); |
|
46 | + foreach ($this->forwardEmitters as $emitter) { |
|
47 | + $emitter->listen($scope, $method, $callback); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param \OC\Hooks\Emitter $emitter |
|
53 | - */ |
|
54 | - protected function forward(Emitter $emitter) { |
|
55 | - $this->forwardEmitters[] = $emitter; |
|
51 | + /** |
|
52 | + * @param \OC\Hooks\Emitter $emitter |
|
53 | + */ |
|
54 | + protected function forward(Emitter $emitter) { |
|
55 | + $this->forwardEmitters[] = $emitter; |
|
56 | 56 | |
57 | - //forward all previously connected hooks |
|
58 | - foreach ($this->listeners as $key => $listeners) { |
|
59 | - list($scope, $method) = explode('::', $key, 2); |
|
60 | - foreach ($listeners as $listener) { |
|
61 | - $emitter->listen($scope, $method, $listener); |
|
62 | - } |
|
63 | - } |
|
64 | - } |
|
57 | + //forward all previously connected hooks |
|
58 | + foreach ($this->listeners as $key => $listeners) { |
|
59 | + list($scope, $method) = explode('::', $key, 2); |
|
60 | + foreach ($listeners as $listener) { |
|
61 | + $emitter->listen($scope, $method, $listener); |
|
62 | + } |
|
63 | + } |
|
64 | + } |
|
65 | 65 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param callable $callback |
36 | 36 | */ |
37 | 37 | public function listen($scope, $method, callable $callback) { |
38 | - $eventName = $scope . '::' . $method; |
|
38 | + $eventName = $scope.'::'.$method; |
|
39 | 39 | if (!isset($this->listeners[$eventName])) { |
40 | 40 | $this->listeners[$eventName] = array(); |
41 | 41 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $names = array(); |
54 | 54 | $allNames = array_keys($this->listeners); |
55 | 55 | if ($scope and $method) { |
56 | - $name = $scope . '::' . $method; |
|
56 | + $name = $scope.'::'.$method; |
|
57 | 57 | if (isset($this->listeners[$name])) { |
58 | 58 | $names[] = $name; |
59 | 59 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param array $arguments optional |
94 | 94 | */ |
95 | 95 | protected function emit($scope, $method, array $arguments = array()) { |
96 | - $eventName = $scope . '::' . $method; |
|
96 | + $eventName = $scope.'::'.$method; |
|
97 | 97 | if (isset($this->listeners[$eventName])) { |
98 | 98 | foreach ($this->listeners[$eventName] as $callback) { |
99 | 99 | call_user_func_array($callback, $arguments); |
@@ -24,80 +24,80 @@ |
||
24 | 24 | |
25 | 25 | trait EmitterTrait { |
26 | 26 | |
27 | - /** |
|
28 | - * @var callable[][] $listeners |
|
29 | - */ |
|
30 | - protected $listeners = array(); |
|
27 | + /** |
|
28 | + * @var callable[][] $listeners |
|
29 | + */ |
|
30 | + protected $listeners = array(); |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param string $scope |
|
34 | - * @param string $method |
|
35 | - * @param callable $callback |
|
36 | - */ |
|
37 | - public function listen($scope, $method, callable $callback) { |
|
38 | - $eventName = $scope . '::' . $method; |
|
39 | - if (!isset($this->listeners[$eventName])) { |
|
40 | - $this->listeners[$eventName] = array(); |
|
41 | - } |
|
42 | - if (array_search($callback, $this->listeners[$eventName], true) === false) { |
|
43 | - $this->listeners[$eventName][] = $callback; |
|
44 | - } |
|
45 | - } |
|
32 | + /** |
|
33 | + * @param string $scope |
|
34 | + * @param string $method |
|
35 | + * @param callable $callback |
|
36 | + */ |
|
37 | + public function listen($scope, $method, callable $callback) { |
|
38 | + $eventName = $scope . '::' . $method; |
|
39 | + if (!isset($this->listeners[$eventName])) { |
|
40 | + $this->listeners[$eventName] = array(); |
|
41 | + } |
|
42 | + if (array_search($callback, $this->listeners[$eventName], true) === false) { |
|
43 | + $this->listeners[$eventName][] = $callback; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $scope optional |
|
49 | - * @param string $method optional |
|
50 | - * @param callable $callback optional |
|
51 | - */ |
|
52 | - public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
53 | - $names = array(); |
|
54 | - $allNames = array_keys($this->listeners); |
|
55 | - if ($scope and $method) { |
|
56 | - $name = $scope . '::' . $method; |
|
57 | - if (isset($this->listeners[$name])) { |
|
58 | - $names[] = $name; |
|
59 | - } |
|
60 | - } elseif ($scope) { |
|
61 | - foreach ($allNames as $name) { |
|
62 | - $parts = explode('::', $name, 2); |
|
63 | - if ($parts[0] == $scope) { |
|
64 | - $names[] = $name; |
|
65 | - } |
|
66 | - } |
|
67 | - } elseif ($method) { |
|
68 | - foreach ($allNames as $name) { |
|
69 | - $parts = explode('::', $name, 2); |
|
70 | - if ($parts[1] == $method) { |
|
71 | - $names[] = $name; |
|
72 | - } |
|
73 | - } |
|
74 | - } else { |
|
75 | - $names = $allNames; |
|
76 | - } |
|
47 | + /** |
|
48 | + * @param string $scope optional |
|
49 | + * @param string $method optional |
|
50 | + * @param callable $callback optional |
|
51 | + */ |
|
52 | + public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
53 | + $names = array(); |
|
54 | + $allNames = array_keys($this->listeners); |
|
55 | + if ($scope and $method) { |
|
56 | + $name = $scope . '::' . $method; |
|
57 | + if (isset($this->listeners[$name])) { |
|
58 | + $names[] = $name; |
|
59 | + } |
|
60 | + } elseif ($scope) { |
|
61 | + foreach ($allNames as $name) { |
|
62 | + $parts = explode('::', $name, 2); |
|
63 | + if ($parts[0] == $scope) { |
|
64 | + $names[] = $name; |
|
65 | + } |
|
66 | + } |
|
67 | + } elseif ($method) { |
|
68 | + foreach ($allNames as $name) { |
|
69 | + $parts = explode('::', $name, 2); |
|
70 | + if ($parts[1] == $method) { |
|
71 | + $names[] = $name; |
|
72 | + } |
|
73 | + } |
|
74 | + } else { |
|
75 | + $names = $allNames; |
|
76 | + } |
|
77 | 77 | |
78 | - foreach ($names as $name) { |
|
79 | - if ($callback) { |
|
80 | - $index = array_search($callback, $this->listeners[$name], true); |
|
81 | - if ($index !== false) { |
|
82 | - unset($this->listeners[$name][$index]); |
|
83 | - } |
|
84 | - } else { |
|
85 | - $this->listeners[$name] = array(); |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
78 | + foreach ($names as $name) { |
|
79 | + if ($callback) { |
|
80 | + $index = array_search($callback, $this->listeners[$name], true); |
|
81 | + if ($index !== false) { |
|
82 | + unset($this->listeners[$name][$index]); |
|
83 | + } |
|
84 | + } else { |
|
85 | + $this->listeners[$name] = array(); |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @param string $scope |
|
92 | - * @param string $method |
|
93 | - * @param array $arguments optional |
|
94 | - */ |
|
95 | - protected function emit($scope, $method, array $arguments = array()) { |
|
96 | - $eventName = $scope . '::' . $method; |
|
97 | - if (isset($this->listeners[$eventName])) { |
|
98 | - foreach ($this->listeners[$eventName] as $callback) { |
|
99 | - call_user_func_array($callback, $arguments); |
|
100 | - } |
|
101 | - } |
|
102 | - } |
|
90 | + /** |
|
91 | + * @param string $scope |
|
92 | + * @param string $method |
|
93 | + * @param array $arguments optional |
|
94 | + */ |
|
95 | + protected function emit($scope, $method, array $arguments = array()) { |
|
96 | + $eventName = $scope . '::' . $method; |
|
97 | + if (isset($this->listeners[$eventName])) { |
|
98 | + foreach ($this->listeners[$eventName] as $callback) { |
|
99 | + call_user_func_array($callback, $arguments); |
|
100 | + } |
|
101 | + } |
|
102 | + } |
|
103 | 103 | } |
@@ -34,87 +34,87 @@ |
||
34 | 34 | * @deprecated Use \OCP\Http\Client\IClientService |
35 | 35 | */ |
36 | 36 | class HTTPHelper { |
37 | - const USER_AGENT = 'ownCloud Server Crawler'; |
|
37 | + const USER_AGENT = 'ownCloud Server Crawler'; |
|
38 | 38 | |
39 | - /** @var \OCP\IConfig */ |
|
40 | - private $config; |
|
41 | - /** @var IClientService */ |
|
42 | - private $clientService; |
|
39 | + /** @var \OCP\IConfig */ |
|
40 | + private $config; |
|
41 | + /** @var IClientService */ |
|
42 | + private $clientService; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param IConfig $config |
|
46 | - * @param IClientService $clientService |
|
47 | - */ |
|
48 | - public function __construct(IConfig $config, |
|
49 | - IClientService $clientService) { |
|
50 | - $this->config = $config; |
|
51 | - $this->clientService = $clientService; |
|
52 | - } |
|
44 | + /** |
|
45 | + * @param IConfig $config |
|
46 | + * @param IClientService $clientService |
|
47 | + */ |
|
48 | + public function __construct(IConfig $config, |
|
49 | + IClientService $clientService) { |
|
50 | + $this->config = $config; |
|
51 | + $this->clientService = $clientService; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Get URL content |
|
56 | - * @param string $url Url to get content |
|
57 | - * @throws \Exception If the URL does not start with http:// or https:// |
|
58 | - * @return string of the response or false on error |
|
59 | - * This function get the content of a page via curl, if curl is enabled. |
|
60 | - * If not, file_get_contents is used. |
|
61 | - * @deprecated Use \OCP\Http\Client\IClientService |
|
62 | - */ |
|
63 | - public function getUrlContent($url) { |
|
64 | - try { |
|
65 | - $client = $this->clientService->newClient(); |
|
66 | - $response = $client->get($url); |
|
67 | - return $response->getBody(); |
|
68 | - } catch (\Exception $e) { |
|
69 | - return false; |
|
70 | - } |
|
71 | - } |
|
54 | + /** |
|
55 | + * Get URL content |
|
56 | + * @param string $url Url to get content |
|
57 | + * @throws \Exception If the URL does not start with http:// or https:// |
|
58 | + * @return string of the response or false on error |
|
59 | + * This function get the content of a page via curl, if curl is enabled. |
|
60 | + * If not, file_get_contents is used. |
|
61 | + * @deprecated Use \OCP\Http\Client\IClientService |
|
62 | + */ |
|
63 | + public function getUrlContent($url) { |
|
64 | + try { |
|
65 | + $client = $this->clientService->newClient(); |
|
66 | + $response = $client->get($url); |
|
67 | + return $response->getBody(); |
|
68 | + } catch (\Exception $e) { |
|
69 | + return false; |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Returns the response headers of a HTTP URL without following redirects |
|
75 | - * @param string $location Needs to be a HTTPS or HTTP URL |
|
76 | - * @return array |
|
77 | - * @deprecated Use \OCP\Http\Client\IClientService |
|
78 | - */ |
|
79 | - public function getHeaders($location) { |
|
80 | - $client = $this->clientService->newClient(); |
|
81 | - $response = $client->get($location); |
|
82 | - return $response->getHeaders(); |
|
83 | - } |
|
73 | + /** |
|
74 | + * Returns the response headers of a HTTP URL without following redirects |
|
75 | + * @param string $location Needs to be a HTTPS or HTTP URL |
|
76 | + * @return array |
|
77 | + * @deprecated Use \OCP\Http\Client\IClientService |
|
78 | + */ |
|
79 | + public function getHeaders($location) { |
|
80 | + $client = $this->clientService->newClient(); |
|
81 | + $response = $client->get($location); |
|
82 | + return $response->getHeaders(); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Checks whether the supplied URL begins with HTTPS:// or HTTP:// (case insensitive) |
|
87 | - * @param string $url |
|
88 | - * @return bool |
|
89 | - */ |
|
90 | - public function isHTTPURL($url) { |
|
91 | - return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0; |
|
92 | - } |
|
85 | + /** |
|
86 | + * Checks whether the supplied URL begins with HTTPS:// or HTTP:// (case insensitive) |
|
87 | + * @param string $url |
|
88 | + * @return bool |
|
89 | + */ |
|
90 | + public function isHTTPURL($url) { |
|
91 | + return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * send http post request |
|
96 | - * |
|
97 | - * @param string $url |
|
98 | - * @param array $fields data send by the request |
|
99 | - * @return array |
|
100 | - * @deprecated Use \OCP\Http\Client\IClientService |
|
101 | - */ |
|
102 | - public function post($url, array $fields) { |
|
103 | - $client = $this->clientService->newClient(); |
|
94 | + /** |
|
95 | + * send http post request |
|
96 | + * |
|
97 | + * @param string $url |
|
98 | + * @param array $fields data send by the request |
|
99 | + * @return array |
|
100 | + * @deprecated Use \OCP\Http\Client\IClientService |
|
101 | + */ |
|
102 | + public function post($url, array $fields) { |
|
103 | + $client = $this->clientService->newClient(); |
|
104 | 104 | |
105 | - try { |
|
106 | - $response = $client->post( |
|
107 | - $url, |
|
108 | - [ |
|
109 | - 'body' => $fields, |
|
110 | - 'connect_timeout' => 10, |
|
111 | - ] |
|
112 | - ); |
|
113 | - } catch (\Exception $e) { |
|
114 | - return ['success' => false, 'result' => $e->getMessage()]; |
|
115 | - } |
|
105 | + try { |
|
106 | + $response = $client->post( |
|
107 | + $url, |
|
108 | + [ |
|
109 | + 'body' => $fields, |
|
110 | + 'connect_timeout' => 10, |
|
111 | + ] |
|
112 | + ); |
|
113 | + } catch (\Exception $e) { |
|
114 | + return ['success' => false, 'result' => $e->getMessage()]; |
|
115 | + } |
|
116 | 116 | |
117 | - return ['success' => true, 'result' => $response->getBody()]; |
|
118 | - } |
|
117 | + return ['success' => true, 'result' => $response->getBody()]; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | } |
@@ -30,23 +30,23 @@ |
||
30 | 30 | * error code for functions not provided by the group backend |
31 | 31 | * @deprecated Use \OC_Group_Backend::NOT_IMPLEMENTED instead |
32 | 32 | */ |
33 | -define('OC_GROUP_BACKEND_NOT_IMPLEMENTED', -501); |
|
33 | +define('OC_GROUP_BACKEND_NOT_IMPLEMENTED', -501); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * actions that user backends can define |
37 | 37 | */ |
38 | 38 | /** @deprecated Use \OC_Group_Backend::CREATE_GROUP instead */ |
39 | -define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001); |
|
39 | +define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001); |
|
40 | 40 | /** @deprecated Use \OC_Group_Backend::DELETE_GROUP instead */ |
41 | -define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010); |
|
41 | +define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010); |
|
42 | 42 | /** @deprecated Use \OC_Group_Backend::ADD_TO_GROUP instead */ |
43 | -define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00000100); |
|
43 | +define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00000100); |
|
44 | 44 | /** @deprecated Use \OC_Group_Backend::REMOVE_FROM_GOUP instead */ |
45 | -define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00001000); |
|
45 | +define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00001000); |
|
46 | 46 | /** @deprecated Obsolete */ |
47 | -define('OC_GROUP_BACKEND_GET_DISPLAYNAME', 0x00010000); //OBSOLETE |
|
47 | +define('OC_GROUP_BACKEND_GET_DISPLAYNAME', 0x00010000); //OBSOLETE |
|
48 | 48 | /** @deprecated Use \OC_Group_Backend::COUNT_USERS instead */ |
49 | -define('OC_GROUP_BACKEND_COUNT_USERS', 0x00100000); |
|
49 | +define('OC_GROUP_BACKEND_COUNT_USERS', 0x00100000); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Abstract base class for user management |
@@ -51,13 +51,11 @@ discard block |
||
51 | 51 | if ($cache_time > 0) { |
52 | 52 | self::setExpiresHeader('PT'.$cache_time.'S'); |
53 | 53 | header('Cache-Control: max-age='.$cache_time.', must-revalidate'); |
54 | - } |
|
55 | - else { |
|
54 | + } else { |
|
56 | 55 | self::setExpiresHeader(0); |
57 | 56 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
58 | 57 | } |
59 | - } |
|
60 | - else { |
|
58 | + } else { |
|
61 | 59 | header('Cache-Control: cache'); |
62 | 60 | header('Pragma: cache'); |
63 | 61 | } |
@@ -228,8 +226,7 @@ discard block |
||
228 | 226 | |
229 | 227 | self::setContentLengthHeader(filesize($filepath)); |
230 | 228 | fpassthru($fp); |
231 | - } |
|
232 | - else { |
|
229 | + } else { |
|
233 | 230 | self::setStatus(self::STATUS_NOT_FOUND); |
234 | 231 | } |
235 | 232 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | static public function enableCaching($cache_time = null) { |
49 | 49 | if (is_numeric($cache_time)) { |
50 | - header('Pragma: public');// enable caching in IE |
|
50 | + header('Pragma: public'); // enable caching in IE |
|
51 | 51 | if ($cache_time > 0) { |
52 | 52 | self::setExpiresHeader('PT'.$cache_time.'S'); |
53 | 53 | header('Cache-Control: max-age='.$cache_time.', must-revalidate'); |
@@ -78,29 +78,29 @@ discard block |
||
78 | 78 | */ |
79 | 79 | static public function setStatus($status) { |
80 | 80 | $protocol = \OC::$server->getRequest()->getHttpProtocol(); |
81 | - switch($status) { |
|
81 | + switch ($status) { |
|
82 | 82 | case self::STATUS_NOT_MODIFIED: |
83 | - $status = $status . ' Not Modified'; |
|
83 | + $status = $status.' Not Modified'; |
|
84 | 84 | break; |
85 | 85 | case self::STATUS_TEMPORARY_REDIRECT: |
86 | 86 | if ($protocol == 'HTTP/1.1') { |
87 | - $status = $status . ' Temporary Redirect'; |
|
87 | + $status = $status.' Temporary Redirect'; |
|
88 | 88 | break; |
89 | 89 | } else { |
90 | 90 | $status = self::STATUS_FOUND; |
91 | 91 | // fallthrough |
92 | 92 | } |
93 | 93 | case self::STATUS_FOUND; |
94 | - $status = $status . ' Found'; |
|
94 | + $status = $status.' Found'; |
|
95 | 95 | break; |
96 | 96 | case self::STATUS_NOT_FOUND; |
97 | - $status = $status . ' Not Found'; |
|
97 | + $status = $status.' Not Found'; |
|
98 | 98 | break; |
99 | 99 | case self::STATUS_INTERNAL_SERVER_ERROR; |
100 | - $status = $status . ' Internal Server Error'; |
|
100 | + $status = $status.' Internal Server Error'; |
|
101 | 101 | break; |
102 | 102 | case self::STATUS_SERVICE_UNAVAILABLE; |
103 | - $status = $status . ' Service Unavailable'; |
|
103 | + $status = $status.' Service Unavailable'; |
|
104 | 104 | break; |
105 | 105 | } |
106 | 106 | header($protocol.' '.$status); |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | * @param string $filename file name |
181 | 181 | * @param string $type disposition type, either 'attachment' or 'inline' |
182 | 182 | */ |
183 | - static public function setContentDispositionHeader( $filename, $type = 'attachment' ) { |
|
183 | + static public function setContentDispositionHeader($filename, $type = 'attachment') { |
|
184 | 184 | if (\OC::$server->getRequest()->isUserAgent( |
185 | 185 | [ |
186 | 186 | \OC\AppFramework\Http\Request::USER_AGENT_IE, |
187 | 187 | \OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME, |
188 | 188 | \OC\AppFramework\Http\Request::USER_AGENT_FREEBOX, |
189 | 189 | ])) { |
190 | - header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
190 | + header('Content-Disposition: '.rawurlencode($type).'; filename="'.rawurlencode($filename).'"'); |
|
191 | 191 | } else { |
192 | - header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename ) |
|
193 | - . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
192 | + header('Content-Disposition: '.rawurlencode($type).'; filename*=UTF-8\'\''.rawurlencode($filename) |
|
193 | + . '; filename="'.rawurlencode($filename).'"'); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -256,12 +256,12 @@ discard block |
||
256 | 256 | . 'connect-src *; ' |
257 | 257 | . 'object-src \'none\'; ' |
258 | 258 | . 'base-uri \'self\'; '; |
259 | - header('Content-Security-Policy:' . $policy); |
|
259 | + header('Content-Security-Policy:'.$policy); |
|
260 | 260 | header('X-Frame-Options: SAMEORIGIN'); // Disallow iFraming from other domains |
261 | 261 | |
262 | 262 | // Send fallback headers for installations that don't have the possibility to send |
263 | 263 | // custom headers on the webserver side |
264 | - if(getenv('modHeadersAvailable') !== 'true') { |
|
264 | + if (getenv('modHeadersAvailable') !== 'true') { |
|
265 | 265 | header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters |
266 | 266 | header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE |
267 | 267 | header('X-Robots-Tag: none'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag |
@@ -29,245 +29,245 @@ |
||
29 | 29 | */ |
30 | 30 | |
31 | 31 | class OC_Response { |
32 | - const STATUS_FOUND = 304; |
|
33 | - const STATUS_NOT_MODIFIED = 304; |
|
34 | - const STATUS_TEMPORARY_REDIRECT = 307; |
|
35 | - const STATUS_BAD_REQUEST = 400; |
|
36 | - const STATUS_FORBIDDEN = 403; |
|
37 | - const STATUS_NOT_FOUND = 404; |
|
38 | - const STATUS_INTERNAL_SERVER_ERROR = 500; |
|
39 | - const STATUS_SERVICE_UNAVAILABLE = 503; |
|
32 | + const STATUS_FOUND = 304; |
|
33 | + const STATUS_NOT_MODIFIED = 304; |
|
34 | + const STATUS_TEMPORARY_REDIRECT = 307; |
|
35 | + const STATUS_BAD_REQUEST = 400; |
|
36 | + const STATUS_FORBIDDEN = 403; |
|
37 | + const STATUS_NOT_FOUND = 404; |
|
38 | + const STATUS_INTERNAL_SERVER_ERROR = 500; |
|
39 | + const STATUS_SERVICE_UNAVAILABLE = 503; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Enable response caching by sending correct HTTP headers |
|
43 | - * @param integer $cache_time time to cache the response |
|
44 | - * >0 cache time in seconds |
|
45 | - * 0 and <0 enable default browser caching |
|
46 | - * null cache indefinitely |
|
47 | - */ |
|
48 | - static public function enableCaching($cache_time = null) { |
|
49 | - if (is_numeric($cache_time)) { |
|
50 | - header('Pragma: public');// enable caching in IE |
|
51 | - if ($cache_time > 0) { |
|
52 | - self::setExpiresHeader('PT'.$cache_time.'S'); |
|
53 | - header('Cache-Control: max-age='.$cache_time.', must-revalidate'); |
|
54 | - } |
|
55 | - else { |
|
56 | - self::setExpiresHeader(0); |
|
57 | - header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
|
58 | - } |
|
59 | - } |
|
60 | - else { |
|
61 | - header('Cache-Control: cache'); |
|
62 | - header('Pragma: cache'); |
|
63 | - } |
|
41 | + /** |
|
42 | + * Enable response caching by sending correct HTTP headers |
|
43 | + * @param integer $cache_time time to cache the response |
|
44 | + * >0 cache time in seconds |
|
45 | + * 0 and <0 enable default browser caching |
|
46 | + * null cache indefinitely |
|
47 | + */ |
|
48 | + static public function enableCaching($cache_time = null) { |
|
49 | + if (is_numeric($cache_time)) { |
|
50 | + header('Pragma: public');// enable caching in IE |
|
51 | + if ($cache_time > 0) { |
|
52 | + self::setExpiresHeader('PT'.$cache_time.'S'); |
|
53 | + header('Cache-Control: max-age='.$cache_time.', must-revalidate'); |
|
54 | + } |
|
55 | + else { |
|
56 | + self::setExpiresHeader(0); |
|
57 | + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
|
58 | + } |
|
59 | + } |
|
60 | + else { |
|
61 | + header('Cache-Control: cache'); |
|
62 | + header('Pragma: cache'); |
|
63 | + } |
|
64 | 64 | |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * disable browser caching |
|
69 | - * @see enableCaching with cache_time = 0 |
|
70 | - */ |
|
71 | - static public function disableCaching() { |
|
72 | - self::enableCaching(0); |
|
73 | - } |
|
67 | + /** |
|
68 | + * disable browser caching |
|
69 | + * @see enableCaching with cache_time = 0 |
|
70 | + */ |
|
71 | + static public function disableCaching() { |
|
72 | + self::enableCaching(0); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Set response status |
|
77 | - * @param int $status a HTTP status code, see also the STATUS constants |
|
78 | - */ |
|
79 | - static public function setStatus($status) { |
|
80 | - $protocol = \OC::$server->getRequest()->getHttpProtocol(); |
|
81 | - switch($status) { |
|
82 | - case self::STATUS_NOT_MODIFIED: |
|
83 | - $status = $status . ' Not Modified'; |
|
84 | - break; |
|
85 | - case self::STATUS_TEMPORARY_REDIRECT: |
|
86 | - if ($protocol == 'HTTP/1.1') { |
|
87 | - $status = $status . ' Temporary Redirect'; |
|
88 | - break; |
|
89 | - } else { |
|
90 | - $status = self::STATUS_FOUND; |
|
91 | - // fallthrough |
|
92 | - } |
|
93 | - case self::STATUS_FOUND; |
|
94 | - $status = $status . ' Found'; |
|
95 | - break; |
|
96 | - case self::STATUS_NOT_FOUND; |
|
97 | - $status = $status . ' Not Found'; |
|
98 | - break; |
|
99 | - case self::STATUS_INTERNAL_SERVER_ERROR; |
|
100 | - $status = $status . ' Internal Server Error'; |
|
101 | - break; |
|
102 | - case self::STATUS_SERVICE_UNAVAILABLE; |
|
103 | - $status = $status . ' Service Unavailable'; |
|
104 | - break; |
|
105 | - } |
|
106 | - header($protocol.' '.$status); |
|
107 | - } |
|
75 | + /** |
|
76 | + * Set response status |
|
77 | + * @param int $status a HTTP status code, see also the STATUS constants |
|
78 | + */ |
|
79 | + static public function setStatus($status) { |
|
80 | + $protocol = \OC::$server->getRequest()->getHttpProtocol(); |
|
81 | + switch($status) { |
|
82 | + case self::STATUS_NOT_MODIFIED: |
|
83 | + $status = $status . ' Not Modified'; |
|
84 | + break; |
|
85 | + case self::STATUS_TEMPORARY_REDIRECT: |
|
86 | + if ($protocol == 'HTTP/1.1') { |
|
87 | + $status = $status . ' Temporary Redirect'; |
|
88 | + break; |
|
89 | + } else { |
|
90 | + $status = self::STATUS_FOUND; |
|
91 | + // fallthrough |
|
92 | + } |
|
93 | + case self::STATUS_FOUND; |
|
94 | + $status = $status . ' Found'; |
|
95 | + break; |
|
96 | + case self::STATUS_NOT_FOUND; |
|
97 | + $status = $status . ' Not Found'; |
|
98 | + break; |
|
99 | + case self::STATUS_INTERNAL_SERVER_ERROR; |
|
100 | + $status = $status . ' Internal Server Error'; |
|
101 | + break; |
|
102 | + case self::STATUS_SERVICE_UNAVAILABLE; |
|
103 | + $status = $status . ' Service Unavailable'; |
|
104 | + break; |
|
105 | + } |
|
106 | + header($protocol.' '.$status); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Send redirect response |
|
111 | - * @param string $location to redirect to |
|
112 | - */ |
|
113 | - static public function redirect($location) { |
|
114 | - self::setStatus(self::STATUS_TEMPORARY_REDIRECT); |
|
115 | - header('Location: '.$location); |
|
116 | - } |
|
109 | + /** |
|
110 | + * Send redirect response |
|
111 | + * @param string $location to redirect to |
|
112 | + */ |
|
113 | + static public function redirect($location) { |
|
114 | + self::setStatus(self::STATUS_TEMPORARY_REDIRECT); |
|
115 | + header('Location: '.$location); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Set response expire time |
|
120 | - * @param string|DateTime|int $expires date-time when the response expires |
|
121 | - * string for DateInterval from now |
|
122 | - * DateTime object when to expire response |
|
123 | - */ |
|
124 | - static public function setExpiresHeader($expires) { |
|
125 | - if (is_string($expires) && $expires[0] == 'P') { |
|
126 | - $interval = $expires; |
|
127 | - $expires = new DateTime('now'); |
|
128 | - $expires->add(new DateInterval($interval)); |
|
129 | - } |
|
130 | - if ($expires instanceof DateTime) { |
|
131 | - $expires->setTimezone(new DateTimeZone('GMT')); |
|
132 | - $expires = $expires->format(DateTime::RFC2822); |
|
133 | - } |
|
134 | - header('Expires: '.$expires); |
|
135 | - } |
|
118 | + /** |
|
119 | + * Set response expire time |
|
120 | + * @param string|DateTime|int $expires date-time when the response expires |
|
121 | + * string for DateInterval from now |
|
122 | + * DateTime object when to expire response |
|
123 | + */ |
|
124 | + static public function setExpiresHeader($expires) { |
|
125 | + if (is_string($expires) && $expires[0] == 'P') { |
|
126 | + $interval = $expires; |
|
127 | + $expires = new DateTime('now'); |
|
128 | + $expires->add(new DateInterval($interval)); |
|
129 | + } |
|
130 | + if ($expires instanceof DateTime) { |
|
131 | + $expires->setTimezone(new DateTimeZone('GMT')); |
|
132 | + $expires = $expires->format(DateTime::RFC2822); |
|
133 | + } |
|
134 | + header('Expires: '.$expires); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Checks and set ETag header, when the request matches sends a |
|
139 | - * 'not modified' response |
|
140 | - * @param string $etag token to use for modification check |
|
141 | - */ |
|
142 | - static public function setETagHeader($etag) { |
|
143 | - if (empty($etag)) { |
|
144 | - return; |
|
145 | - } |
|
146 | - $etag = '"'.$etag.'"'; |
|
147 | - if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && |
|
148 | - trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { |
|
149 | - self::setStatus(self::STATUS_NOT_MODIFIED); |
|
150 | - exit; |
|
151 | - } |
|
152 | - header('ETag: '.$etag); |
|
153 | - } |
|
137 | + /** |
|
138 | + * Checks and set ETag header, when the request matches sends a |
|
139 | + * 'not modified' response |
|
140 | + * @param string $etag token to use for modification check |
|
141 | + */ |
|
142 | + static public function setETagHeader($etag) { |
|
143 | + if (empty($etag)) { |
|
144 | + return; |
|
145 | + } |
|
146 | + $etag = '"'.$etag.'"'; |
|
147 | + if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && |
|
148 | + trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { |
|
149 | + self::setStatus(self::STATUS_NOT_MODIFIED); |
|
150 | + exit; |
|
151 | + } |
|
152 | + header('ETag: '.$etag); |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * Checks and set Last-Modified header, when the request matches sends a |
|
157 | - * 'not modified' response |
|
158 | - * @param int|DateTime|string $lastModified time when the response was last modified |
|
159 | - */ |
|
160 | - static public function setLastModifiedHeader($lastModified) { |
|
161 | - if (empty($lastModified)) { |
|
162 | - return; |
|
163 | - } |
|
164 | - if (is_int($lastModified)) { |
|
165 | - $lastModified = gmdate(DateTime::RFC2822, $lastModified); |
|
166 | - } |
|
167 | - if ($lastModified instanceof DateTime) { |
|
168 | - $lastModified = $lastModified->format(DateTime::RFC2822); |
|
169 | - } |
|
170 | - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && |
|
171 | - trim($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) { |
|
172 | - self::setStatus(self::STATUS_NOT_MODIFIED); |
|
173 | - exit; |
|
174 | - } |
|
175 | - header('Last-Modified: '.$lastModified); |
|
176 | - } |
|
155 | + /** |
|
156 | + * Checks and set Last-Modified header, when the request matches sends a |
|
157 | + * 'not modified' response |
|
158 | + * @param int|DateTime|string $lastModified time when the response was last modified |
|
159 | + */ |
|
160 | + static public function setLastModifiedHeader($lastModified) { |
|
161 | + if (empty($lastModified)) { |
|
162 | + return; |
|
163 | + } |
|
164 | + if (is_int($lastModified)) { |
|
165 | + $lastModified = gmdate(DateTime::RFC2822, $lastModified); |
|
166 | + } |
|
167 | + if ($lastModified instanceof DateTime) { |
|
168 | + $lastModified = $lastModified->format(DateTime::RFC2822); |
|
169 | + } |
|
170 | + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && |
|
171 | + trim($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) { |
|
172 | + self::setStatus(self::STATUS_NOT_MODIFIED); |
|
173 | + exit; |
|
174 | + } |
|
175 | + header('Last-Modified: '.$lastModified); |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Sets the content disposition header (with possible workarounds) |
|
180 | - * @param string $filename file name |
|
181 | - * @param string $type disposition type, either 'attachment' or 'inline' |
|
182 | - */ |
|
183 | - static public function setContentDispositionHeader( $filename, $type = 'attachment' ) { |
|
184 | - if (\OC::$server->getRequest()->isUserAgent( |
|
185 | - [ |
|
186 | - \OC\AppFramework\Http\Request::USER_AGENT_IE, |
|
187 | - \OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME, |
|
188 | - \OC\AppFramework\Http\Request::USER_AGENT_FREEBOX, |
|
189 | - ])) { |
|
190 | - header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
191 | - } else { |
|
192 | - header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename ) |
|
193 | - . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
194 | - } |
|
195 | - } |
|
178 | + /** |
|
179 | + * Sets the content disposition header (with possible workarounds) |
|
180 | + * @param string $filename file name |
|
181 | + * @param string $type disposition type, either 'attachment' or 'inline' |
|
182 | + */ |
|
183 | + static public function setContentDispositionHeader( $filename, $type = 'attachment' ) { |
|
184 | + if (\OC::$server->getRequest()->isUserAgent( |
|
185 | + [ |
|
186 | + \OC\AppFramework\Http\Request::USER_AGENT_IE, |
|
187 | + \OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME, |
|
188 | + \OC\AppFramework\Http\Request::USER_AGENT_FREEBOX, |
|
189 | + ])) { |
|
190 | + header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
191 | + } else { |
|
192 | + header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename ) |
|
193 | + . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
194 | + } |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * Sets the content length header (with possible workarounds) |
|
199 | - * @param string|int|float $length Length to be sent |
|
200 | - */ |
|
201 | - static public function setContentLengthHeader($length) { |
|
202 | - if (PHP_INT_SIZE === 4) { |
|
203 | - if ($length > PHP_INT_MAX && stripos(PHP_SAPI, 'apache') === 0) { |
|
204 | - // Apache PHP SAPI casts Content-Length headers to PHP integers. |
|
205 | - // This enforces a limit of PHP_INT_MAX (2147483647 on 32-bit |
|
206 | - // platforms). So, if the length is greater than PHP_INT_MAX, |
|
207 | - // we just do not send a Content-Length header to prevent |
|
208 | - // bodies from being received incompletely. |
|
209 | - return; |
|
210 | - } |
|
211 | - // Convert signed integer or float to unsigned base-10 string. |
|
212 | - $lfh = new \OC\LargeFileHelper; |
|
213 | - $length = $lfh->formatUnsignedInteger($length); |
|
214 | - } |
|
215 | - header('Content-Length: '.$length); |
|
216 | - } |
|
197 | + /** |
|
198 | + * Sets the content length header (with possible workarounds) |
|
199 | + * @param string|int|float $length Length to be sent |
|
200 | + */ |
|
201 | + static public function setContentLengthHeader($length) { |
|
202 | + if (PHP_INT_SIZE === 4) { |
|
203 | + if ($length > PHP_INT_MAX && stripos(PHP_SAPI, 'apache') === 0) { |
|
204 | + // Apache PHP SAPI casts Content-Length headers to PHP integers. |
|
205 | + // This enforces a limit of PHP_INT_MAX (2147483647 on 32-bit |
|
206 | + // platforms). So, if the length is greater than PHP_INT_MAX, |
|
207 | + // we just do not send a Content-Length header to prevent |
|
208 | + // bodies from being received incompletely. |
|
209 | + return; |
|
210 | + } |
|
211 | + // Convert signed integer or float to unsigned base-10 string. |
|
212 | + $lfh = new \OC\LargeFileHelper; |
|
213 | + $length = $lfh->formatUnsignedInteger($length); |
|
214 | + } |
|
215 | + header('Content-Length: '.$length); |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * Send file as response, checking and setting caching headers |
|
220 | - * @param string $filepath of file to send |
|
221 | - * @deprecated 8.1.0 - Use \OCP\AppFramework\Http\StreamResponse or another AppFramework controller instead |
|
222 | - */ |
|
223 | - static public function sendFile($filepath) { |
|
224 | - $fp = fopen($filepath, 'rb'); |
|
225 | - if ($fp) { |
|
226 | - self::setLastModifiedHeader(filemtime($filepath)); |
|
227 | - self::setETagHeader(md5_file($filepath)); |
|
218 | + /** |
|
219 | + * Send file as response, checking and setting caching headers |
|
220 | + * @param string $filepath of file to send |
|
221 | + * @deprecated 8.1.0 - Use \OCP\AppFramework\Http\StreamResponse or another AppFramework controller instead |
|
222 | + */ |
|
223 | + static public function sendFile($filepath) { |
|
224 | + $fp = fopen($filepath, 'rb'); |
|
225 | + if ($fp) { |
|
226 | + self::setLastModifiedHeader(filemtime($filepath)); |
|
227 | + self::setETagHeader(md5_file($filepath)); |
|
228 | 228 | |
229 | - self::setContentLengthHeader(filesize($filepath)); |
|
230 | - fpassthru($fp); |
|
231 | - } |
|
232 | - else { |
|
233 | - self::setStatus(self::STATUS_NOT_FOUND); |
|
234 | - } |
|
235 | - } |
|
229 | + self::setContentLengthHeader(filesize($filepath)); |
|
230 | + fpassthru($fp); |
|
231 | + } |
|
232 | + else { |
|
233 | + self::setStatus(self::STATUS_NOT_FOUND); |
|
234 | + } |
|
235 | + } |
|
236 | 236 | |
237 | - /** |
|
238 | - * This function adds some security related headers to all requests served via base.php |
|
239 | - * The implementation of this function has to happen here to ensure that all third-party |
|
240 | - * components (e.g. SabreDAV) also benefit from this headers. |
|
241 | - */ |
|
242 | - public static function addSecurityHeaders() { |
|
243 | - /** |
|
244 | - * FIXME: Content Security Policy for legacy ownCloud components. This |
|
245 | - * can be removed once \OCP\AppFramework\Http\Response from the AppFramework |
|
246 | - * is used everywhere. |
|
247 | - * @see \OCP\AppFramework\Http\Response::getHeaders |
|
248 | - */ |
|
249 | - $policy = 'default-src \'self\'; ' |
|
250 | - . 'script-src \'self\' \'unsafe-eval\' \'nonce-'.\OC::$server->getContentSecurityPolicyNonceManager()->getNonce().'\'; ' |
|
251 | - . 'style-src \'self\' \'unsafe-inline\'; ' |
|
252 | - . 'frame-src *; ' |
|
253 | - . 'img-src * data: blob:; ' |
|
254 | - . 'font-src \'self\' data:; ' |
|
255 | - . 'media-src *; ' |
|
256 | - . 'connect-src *; ' |
|
257 | - . 'object-src \'none\'; ' |
|
258 | - . 'base-uri \'self\'; '; |
|
259 | - header('Content-Security-Policy:' . $policy); |
|
260 | - header('X-Frame-Options: SAMEORIGIN'); // Disallow iFraming from other domains |
|
237 | + /** |
|
238 | + * This function adds some security related headers to all requests served via base.php |
|
239 | + * The implementation of this function has to happen here to ensure that all third-party |
|
240 | + * components (e.g. SabreDAV) also benefit from this headers. |
|
241 | + */ |
|
242 | + public static function addSecurityHeaders() { |
|
243 | + /** |
|
244 | + * FIXME: Content Security Policy for legacy ownCloud components. This |
|
245 | + * can be removed once \OCP\AppFramework\Http\Response from the AppFramework |
|
246 | + * is used everywhere. |
|
247 | + * @see \OCP\AppFramework\Http\Response::getHeaders |
|
248 | + */ |
|
249 | + $policy = 'default-src \'self\'; ' |
|
250 | + . 'script-src \'self\' \'unsafe-eval\' \'nonce-'.\OC::$server->getContentSecurityPolicyNonceManager()->getNonce().'\'; ' |
|
251 | + . 'style-src \'self\' \'unsafe-inline\'; ' |
|
252 | + . 'frame-src *; ' |
|
253 | + . 'img-src * data: blob:; ' |
|
254 | + . 'font-src \'self\' data:; ' |
|
255 | + . 'media-src *; ' |
|
256 | + . 'connect-src *; ' |
|
257 | + . 'object-src \'none\'; ' |
|
258 | + . 'base-uri \'self\'; '; |
|
259 | + header('Content-Security-Policy:' . $policy); |
|
260 | + header('X-Frame-Options: SAMEORIGIN'); // Disallow iFraming from other domains |
|
261 | 261 | |
262 | - // Send fallback headers for installations that don't have the possibility to send |
|
263 | - // custom headers on the webserver side |
|
264 | - if(getenv('modHeadersAvailable') !== 'true') { |
|
265 | - header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters |
|
266 | - header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE |
|
267 | - header('X-Robots-Tag: none'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag |
|
268 | - header('X-Download-Options: noopen'); // https://msdn.microsoft.com/en-us/library/jj542450(v=vs.85).aspx |
|
269 | - header('X-Permitted-Cross-Domain-Policies: none'); // https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html |
|
270 | - } |
|
271 | - } |
|
262 | + // Send fallback headers for installations that don't have the possibility to send |
|
263 | + // custom headers on the webserver side |
|
264 | + if(getenv('modHeadersAvailable') !== 'true') { |
|
265 | + header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters |
|
266 | + header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE |
|
267 | + header('X-Robots-Tag: none'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag |
|
268 | + header('X-Download-Options: noopen'); // https://msdn.microsoft.com/en-us/library/jj542450(v=vs.85).aspx |
|
269 | + header('X-Permitted-Cross-Domain-Policies: none'); // https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html |
|
270 | + } |
|
271 | + } |
|
272 | 272 | |
273 | 273 | } |