Created
March 9, 2017 23:39
-
-
Save sapslaj/39a9ff4611f2972739e949e69ace8cf8 to your computer and use it in GitHub Desktop.
Prevents unwanted information from leaking in a public Nextcloud instance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @copyright Copyright (c) 2016, ownCloud, Inc. | |
* | |
* @author Andreas Fischer <[email protected]> | |
* @author Christopher Schäpers <[email protected]> | |
* @author Frank Karlitschek <[email protected]> | |
* @author Joas Schilling <[email protected]> | |
* @author Jörn Friedrich Dreyer <[email protected]> | |
* @author Lukas Reschke <[email protected]> | |
* @author Masaki Kawabata Neto <[email protected]> | |
* @author Morris Jobke <[email protected]> | |
* | |
* @license AGPL-3.0 | |
* | |
* This code is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU Affero General Public License, version 3, | |
* as published by the Free Software Foundation. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU Affero General Public License for more details. | |
* | |
* You should have received a copy of the GNU Affero General Public License, version 3, | |
* along with this program. If not, see <http://www.gnu.org/licenses/> | |
* | |
*/ | |
try { | |
require_once __DIR__ . '/lib/base.php'; | |
$systemConfig = \OC::$server->getSystemConfig(); | |
$installed = (bool) $systemConfig->getValue('installed', false); | |
$maintenance = (bool) $systemConfig->getValue('maintenance', false); | |
# see core/lib/private/legacy/defaults.php and core/themes/example/defaults.php | |
# for description and defaults | |
$defaults = new \OCP\Defaults(); | |
$values=array( | |
'installed'=>$installed, | |
'maintenance' => $maintenance, | |
'needsDbUpgrade' => \OCP\Util::needUpgrade(), | |
'version'=>implode('.', \OCP\Util::getVersion()), | |
'versionstring'=>OC_Util::getVersionString(), | |
'edition'=> '', | |
'productname'=>$defaults->getName()); | |
if (OC::$CLI) { | |
print_r($values); | |
} else { | |
if ($userSession->isLoggedIn()) { | |
header('Access-Control-Allow-Origin: *'); | |
header('Content-Type: application/json'); | |
echo json_encode($values); | |
} else { | |
header("HTTP/1.0 404 Not Found"); | |
$tmpl = new OCP\Template( '', '404', 'guest' ); | |
$tmpl->assign('file', $filename); | |
$tmpl->printPage(); | |
exit; | |
} | |
} | |
} catch (Exception $ex) { | |
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); | |
\OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment