summaryrefslogtreecommitdiffstats
path: root/s.php
blob: 9223fd784ad5875d37aaba5fe2f8ef2f59970984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

try {

	require_once 'lib/base.php';
	OC::checkMaintenanceMode();
	OC::checkSingleUserMode();
	$file = OCP\CONFIG::getAppValue('core', 'public_files');
	if(is_null($file)) {
		header('HTTP/1.0 404 Not Found');
		exit;
	}

	// convert the token to hex, if it's base36
	if (strlen((string)$_GET['t']) != 16 && strlen((string)$_GET['t']) != 32) {
		$_GET['t'] = base_convert($_GET['t'], 36, 16);

		// the token should have leading zeroes and needs to be padded
		if (strlen((string)$_GET['t']) != 16) {
			$padding = '';
			for ($i = 0; $i < (16 - strlen((string)$_GET['t'])); $i++) {
				$padding .= '0';
			}
			$_GET['t'] = $padding . $_GET['t'];
		}
	}

	print($_GET['t']);

	OC_Util::checkAppEnabled('files_sharing');
	OC_App::loadApp('files_sharing');
	OC_User::setIncognitoMode(true);

	require_once OC_App::getAppPath('files_sharing') .'/public.php';

} catch (Exception $ex) {
	//show the user a detailed error page
	OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
	\OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
	OC_Template::printExceptionErrorPage($ex);
}