Selaa lähdekoodia

Initial work on shorter links

tags/v8.0.0alpha1
kondou 10 vuotta sitten
vanhempi
commit
0f2ad9862e
5 muutettua tiedostoa jossa 53 lisäystä ja 3 poistoa
  1. 2
    0
      core/ajax/share.php
  2. 7
    2
      core/js/share.js
  3. 1
    1
      lib/private/share/constants.php
  4. 2
    0
      public.php
  5. 41
    0
      s.php

+ 2
- 0
core/ajax/share.php Näytä tiedosto

@@ -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 {

+ 7
- 2
core/js/share.js Näytä tiedosto

@@ -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');

+ 1
- 1
lib/private/share/constants.php Näytä tiedosto

@@ -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;

+ 2
- 0
public.php Näytä tiedosto

@@ -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);

+ 41
- 0
s.php Näytä tiedosto

@@ -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);
}

Loading…
Peruuta
Tallenna