Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save the directory you're working in the session #3347

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions apps/files/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
// Check if we are a user
OCP\User::checkLoggedIn();

// Start session
session_start();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't manually start the session, lib/base takes care of that


// Load the files we need
OCP\Util::addStyle('files', 'files');
OCP\Util::addscript('files', 'jquery.iframe-transport');
Expand All @@ -32,8 +35,18 @@
OCP\Util::addscript('files', 'filelist');

OCP\App::setActiveNavigationEntry('files_index');

// Load the files
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
$dir = '';
if (isset($_GET['dir'])) {
$dir = stripslashes($_GET['dir']);
// Save the directory you're working in session
$_SESSION['dir'] = $dir;
} elseif (isset($_SESSION['dir'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the session interface (https://github.com/owncloud/core/blob/master/lib/session/session.php) instead of $_SESSION

i.e. OC::$session->get('dir')

// Get the directory you're working from session
$dir = $_SESSION['dir'];
}

// Redirect if directory does not exist
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
header('Location: ' . OCP\Util::getScriptName() . '');
Expand Down Expand Up @@ -137,4 +150,4 @@ function fileCmp($a, $b) {
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
$tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']);
$tmpl->printPage();
}
}