@@ -46,6 +46,8 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo | |||
(!empty($_POST['expirationDate']) ? new \DateTime($_POST['expirationDate']) : null) | |||
); | |||
$token = base_convert($token, 16, 36); | |||
if (is_string($token)) { | |||
OC_JSON::success(array('data' => array('token' => $token))); | |||
} else { |
@@ -663,6 +663,8 @@ OC.Share={ | |||
// TODO: use oc webroot ? | |||
var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file); | |||
} else { | |||
// convert the token to base36 | |||
//token = parseInt(token, 16).toString(36); | |||
//TODO add path param when showing a link to file in a subfolder of a public link share | |||
var service=''; | |||
if(linkSharetype === 'folder' || linkSharetype === 'file'){ | |||
@@ -672,8 +674,11 @@ OC.Share={ | |||
} | |||
// TODO: use oc webroot ? | |||
var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service='+service+'&t='+token; | |||
if (service !== 'files') { | |||
var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service='+service+'&t='+token; | |||
} else { | |||
var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 's.php')+'?t='+token; | |||
} | |||
} | |||
$('#linkText').val(link); | |||
$('#linkText').show('blind'); |
@@ -34,7 +34,7 @@ class Constants { | |||
const FORMAT_STATUSES = -2; | |||
const FORMAT_SOURCES = -3; // ToDo Check if it is still in use otherwise remove it | |||
const TOKEN_LENGTH = 32; // see db_structure.xml | |||
const TOKEN_LENGTH = 16; // old length is 32, thus 32 in db_structure.xml | |||
protected static $shareTypeUserAndGroups = -1; | |||
protected static $shareTypeGroupUserUnique = 2; |
@@ -36,6 +36,8 @@ try { | |||
\OC::$REQUESTEDAPP = $app; | |||
OC_App::loadApps(array('authentication')); | |||
OC_App::loadApps(array('filesystem', 'logging')); | |||
print_r($_GET); | |||
print_r($parts); | |||
OC_Util::checkAppEnabled($app); | |||
OC_App::loadApp($app); |
@@ -0,0 +1,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); | |||
} |