File indexing completed on 2024-04-28 05:55:04

0001 <?php
0002 
0003 use Ocs\Storage\FilesystemAdapter;
0004 
0005 /**
0006  * ocs-fileserver
0007  *
0008  * Copyright 2016 by pling GmbH.
0009  *
0010  * This file is part of ocs-fileserver.
0011  *
0012  * ocs-fileserver is free software: you can redistribute it and/or modify
0013  * it under the terms of the GNU Affero General Public License as published by
0014  * the Free Software Foundation, either version 3 of the License, or
0015  * (at your option) any later version.
0016  *
0017  * ocs-fileserver is distributed in the hope that it will be useful,
0018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0020  * GNU Affero General Public License for more details.
0021  *
0022  * You should have received a copy of the GNU Affero General Public License
0023  * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
0024  **/
0025 
0026 class Index extends BaseController
0027 {
0028 
0029     public function getIndex()
0030     {
0031         if ($this->_isAllowedAccess()) {
0032             $this->_setResponseContent('success');
0033             return;
0034         }
0035 
0036         $this->response->setStatus(403);
0037         throw new Flooer_Exception('Forbidden', LOG_NOTICE);
0038     }
0039 
0040     public function getHealth() {
0041         $filesystem = new FilesystemAdapter($this->appConfig);
0042         if ($filesystem->isFile($this->appConfig->general['filesDir'] . '/empty')) {
0043             $this->_setResponseContent('success',['message' => "I'm alive."]);
0044             return;
0045         }
0046         $this->response->setStatus(500);
0047         throw new Flooer_Exception('Internal Server Error: Resource not accessible.', LOG_NOTICE);
0048     }
0049 
0050 }