Exemplo n.º 1
0
 /**
  * @param array $headers
  * @param bool $hasMoreActivities
  * @return array
  */
 protected function generateHeaders(array $headers, $hasMoreActivities)
 {
     if ($hasMoreActivities && isset($headers['X-Activity-Last-Given'])) {
         // Set the "Link" header for the next page
         $nextPageParameters = ['since' => $headers['X-Activity-Last-Given'], 'limit' => $this->limit, 'sort' => $this->sort];
         if ($this->objectType && $this->objectId) {
             $nextPageParameters['object_type'] = $this->objectType;
             $nextPageParameters['object_id'] = $this->objectId;
         }
         if ($this->request->getParam('format') !== null) {
             $nextPageParameters['format'] = $this->request->getParam('format');
         }
         $nextPage = $this->request->getServerProtocol();
         # http
         $nextPage .= '://' . $this->request->getServerHost();
         # localhost
         $nextPage .= $this->request->getScriptName();
         # /ocs/v2.php
         $nextPage .= $this->request->getPathInfo();
         # /apps/activity/api/v2/activity
         $nextPage .= '?' . http_build_query($nextPageParameters);
         $headers['Link'] = '<' . $nextPage . '>; rel="next"';
     }
     return $headers;
 }
Exemplo n.º 2
0
 /**
  * @return bool
  */
 protected function isV2()
 {
     return $this->request->getScriptName() === '/ocs/v2.php';
 }
Exemplo n.º 3
0
Arquivo: api.php Projeto: nem0xff/core
 /**
  * @param \OCP\IRequest $request
  * @return bool
  */
 protected static function isV2(\OCP\IRequest $request)
 {
     $script = $request->getScriptName();
     return substr($script, -11) === '/ocs/v2.php';
 }
Exemplo n.º 4
0
 /**
  * Limit maintenance mode access
  * @param IRequest $request
  */
 public static function checkMaintenanceMode(IRequest $request)
 {
     // Check if requested URL matches 'index.php/occ'
     $isOccControllerRequested = preg_match('|/index\\.php$|', $request->getScriptName()) === 1 && strpos($request->getPathInfo(), '/occ/') === 0;
     // Allow ajax update script to execute without being stopped
     if (\OC::$server->getSystemConfig()->getValue('maintenance', false) && OC::$SUBURI != '/core/ajax/update.php' && !$isOccControllerRequested) {
         // send http status 503
         header('HTTP/1.1 503 Service Temporarily Unavailable');
         header('Status: 503 Service Temporarily Unavailable');
         header('Retry-After: 120');
         // render error page
         $template = new OC_Template('', 'update.user', 'guest');
         OC_Util::addScript('maintenance-check');
         $template->printPage();
         die;
     }
 }