setting the timezone is now part of the login process and true part of the core.

This commit is contained in:
Thomas Müller 2012-12-20 11:10:45 +01:00
parent ecf82d2218
commit 7d811e57e6
4 changed files with 779 additions and 744 deletions

View File

@ -1,2 +0,0 @@
<?php
$_SESSION['timezone'] = $_GET['time'];

View File

@ -1,114 +1,111 @@
<?php <?php
/** /**
* ownCloud - ajax frontend * ownCloud - ajax frontend
* *
* @author Robin Appelman * @author Robin Appelman
* @copyright 2010 Robin Appelman icewind1991@gmail.com * @copyright 2010 Robin Appelman icewind1991@gmail.com
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 3 of the License, or any later version. * version 3 of the License, or any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
* *
* You should have received a copy of the GNU Affero General Public * You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
// Check if we are a user // Check if we are a user
OCP\User::checkLoggedIn(); OCP\User::checkLoggedIn();
// Load the files we need // Load the files we need
OCP\Util::addStyle( 'files', 'files' ); OCP\Util::addStyle('files', 'files');
OCP\Util::addscript( 'files', 'jquery.iframe-transport' ); OCP\Util::addscript('files', 'jquery.iframe-transport');
OCP\Util::addscript( 'files', 'jquery.fileupload' ); OCP\Util::addscript('files', 'jquery.fileupload');
OCP\Util::addscript( 'files', 'files' ); OCP\Util::addscript('files', 'files');
OCP\Util::addscript( 'files', 'filelist' ); OCP\Util::addscript('files', 'filelist');
OCP\Util::addscript( 'files', 'fileactions' ); OCP\Util::addscript('files', 'fileactions');
OCP\Util::addscript( 'files', 'keyboardshortcuts' ); OCP\Util::addscript('files', 'keyboardshortcuts');
if(!isset($_SESSION['timezone'])) {
OCP\Util::addscript( 'files', 'timezone' ); OCP\App::setActiveNavigationEntry('files_index');
}
OCP\App::setActiveNavigationEntry( 'files_index' );
// Load the files // Load the files
$dir = isset( $_GET['dir'] ) ? stripslashes($_GET['dir']) : ''; $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
// Redirect if directory does not exist // Redirect if directory does not exist
if(!OC_Filesystem::is_dir($dir.'/')) { if (!OC_Filesystem::is_dir($dir . '/')) {
header('Location: '.$_SERVER['SCRIPT_NAME'].''); header('Location: ' . $_SERVER['SCRIPT_NAME'] . '');
exit(); exit();
} }
$files = array(); $files = array();
foreach( OC_Files::getdirectorycontent( $dir ) as $i ) { foreach (OC_Files::getdirectorycontent($dir) as $i) {
$i['date'] = OCP\Util::formatDate($i['mtime'] ); $i['date'] = OCP\Util::formatDate($i['mtime']);
if($i['type']=='file') { if ($i['type'] == 'file') {
$fileinfo=pathinfo($i['name']); $fileinfo = pathinfo($i['name']);
$i['basename']=$fileinfo['filename']; $i['basename'] = $fileinfo['filename'];
if (!empty($fileinfo['extension'])) { if (!empty($fileinfo['extension'])) {
$i['extension']='.' . $fileinfo['extension']; $i['extension'] = '.' . $fileinfo['extension'];
} } else {
else { $i['extension'] = '';
$i['extension']=''; }
} }
} if ($i['directory'] == '/') {
if($i['directory']=='/') { $i['directory'] = '';
$i['directory']=''; }
} $files[] = $i;
$files[] = $i;
} }
// Make breadcrumb // Make breadcrumb
$breadcrumb = array(); $breadcrumb = array();
$pathtohere = ''; $pathtohere = '';
foreach( explode( '/', $dir ) as $i ) { foreach (explode('/', $dir) as $i) {
if( $i != '' ) { if ($i != '') {
$pathtohere .= '/'.$i; $pathtohere .= '/' . $i;
$breadcrumb[] = array( 'dir' => $pathtohere, 'name' => $i ); $breadcrumb[] = array('dir' => $pathtohere, 'name' => $i);
} }
} }
// make breadcrumb und filelist markup // make breadcrumb und filelist markup
$list = new OCP\Template( 'files', 'part.list', '' ); $list = new OCP\Template('files', 'part.list', '');
$list->assign( 'files', $files, false ); $list->assign('files', $files, false);
$list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir=', false); $list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
$list->assign( 'downloadURL', OCP\Util::linkTo('files', 'download.php').'?file=', false); $list->assign('downloadURL', OCP\Util::linkTo('files', 'download.php') . '?file=', false);
$breadcrumbNav = new OCP\Template( 'files', 'part.breadcrumb', '' ); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign( 'breadcrumb', $breadcrumb, false ); $breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
$breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir=', false); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size); $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$freeSpace=OC_Filesystem::free_space($dir); $freeSpace = OC_Filesystem::free_space($dir);
$freeSpace=max($freeSpace, 0); $freeSpace = max($freeSpace, 0);
$maxUploadFilesize = min($maxUploadFilesize, $freeSpace); $maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
$permissions = OCP\PERMISSION_READ; $permissions = OCP\PERMISSION_READ;
if (OC_Filesystem::isUpdatable($dir.'/')) { if (OC_Filesystem::isUpdatable($dir . '/')) {
$permissions |= OCP\PERMISSION_UPDATE; $permissions |= OCP\PERMISSION_UPDATE;
} }
if (OC_Filesystem::isDeletable($dir.'/')) { if (OC_Filesystem::isDeletable($dir . '/')) {
$permissions |= OCP\PERMISSION_DELETE; $permissions |= OCP\PERMISSION_DELETE;
} }
if (OC_Filesystem::isSharable($dir.'/')) { if (OC_Filesystem::isSharable($dir . '/')) {
$permissions |= OCP\PERMISSION_SHARE; $permissions |= OCP\PERMISSION_SHARE;
} }
$tmpl = new OCP\Template( 'files', 'index', 'user' ); $tmpl = new OCP\Template('files', 'index', 'user');
$tmpl->assign( 'fileList', $list->fetchPage(), false ); $tmpl->assign('fileList', $list->fetchPage(), false);
$tmpl->assign( 'breadcrumb', $breadcrumbNav->fetchPage(), false ); $tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage(), false);
$tmpl->assign( 'dir', OC_Filesystem::normalizePath($dir)); $tmpl->assign('dir', OC_Filesystem::normalizePath($dir));
$tmpl->assign( 'isCreatable', OC_Filesystem::isCreatable($dir.'/')); $tmpl->assign('isCreatable', OC_Filesystem::isCreatable($dir . '/'));
$tmpl->assign('permissions', $permissions); $tmpl->assign('permissions', $permissions);
$tmpl->assign( 'files', $files ); $tmpl->assign('files', $files);
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign( 'uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
$tmpl->assign( 'allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
$tmpl->printPage(); $tmpl->printPage();

View File

@ -1,32 +1,50 @@
<!--[if IE 8]><style>input[type="checkbox"]{padding:0;}</style><![endif]--> <!--[if IE 8]><style>input[type="checkbox"]{padding:0;}</style><![endif]-->
<form method="post"> <form method="post">
<fieldset> <fieldset>
<?php if(!empty($_['redirect_url'])) { echo '<input type="hidden" name="redirect_url" value="'.$_['redirect_url'].'" />'; } ?> <?php if (!empty($_['redirect_url'])) {
<ul> echo '<input type="hidden" name="redirect_url" value="' . $_['redirect_url'] . '" />';
<?php if(isset($_['invalidcookie']) && ($_['invalidcookie'])): ?> } ?>
<li class="errors"> <ul>
<?php echo $l->t('Automatic logon rejected!'); ?><br> <?php if (isset($_['invalidcookie']) && ($_['invalidcookie'])): ?>
<small><?php echo $l->t('If you did not change your password recently, your account may be compromised!'); ?></small><br> <li class="errors">
<small><?php echo $l->t('Please change your password to secure your account again.'); ?></small> <?php echo $l->t('Automatic logon rejected!'); ?><br>
</li> <small><?php echo $l->t('If you did not change your password recently, your account may be compromised!'); ?></small>
<?php endif; ?> <br>
<?php if(isset($_['invalidpassword']) && ($_['invalidpassword'])): ?> <small><?php echo $l->t('Please change your password to secure your account again.'); ?></small>
<a href="<?php echo OC_Helper::linkToRoute('core_lostpassword_index') ?>"><li class="errors"> </li>
<?php echo $l->t('Lost your password?'); ?> <?php endif; ?>
</li></a> <?php if (isset($_['invalidpassword']) && ($_['invalidpassword'])): ?>
<?php endif; ?> <a href="<?php echo OC_Helper::linkToRoute('core_lostpassword_index') ?>">
</ul> <li class="errors">
<p class="infield grouptop"> <?php echo $l->t('Lost your password?'); ?>
<input type="text" name="user" id="user" value="<?php echo $_['username']; ?>"<?php echo $_['user_autofocus']?' autofocus':''; ?> autocomplete="on" required /> </li>
<label for="user" class="infield"><?php echo $l->t( 'Username' ); ?></label> </a>
<img class="svg" src="<?php echo image_path('', 'actions/user.svg'); ?>" alt="" /> <?php endif; ?>
</p> </ul>
<p class="infield groupbottom"> <p class="infield grouptop">
<input type="password" name="password" id="password" value="" required<?php echo $_['user_autofocus']?'':' autofocus'; ?> /> <input type="text" name="user" id="user"
<label for="password" class="infield"><?php echo $l->t( 'Password' ); ?></label> value="<?php echo $_['username']; ?>"<?php echo $_['user_autofocus'] ? ' autofocus' : ''; ?>
<img class="svg" src="<?php echo image_path('', 'actions/password.svg'); ?>" alt="" /> autocomplete="on" required/>
</p> <label for="user" class="infield"><?php echo $l->t('Username'); ?></label>
<input type="checkbox" name="remember_login" value="1" id="remember_login" /><label for="remember_login"><?php echo $l->t('remember'); ?></label> <img class="svg" src="<?php echo image_path('', 'actions/user.svg'); ?>" alt=""/>
<input type="submit" id="submit" class="login primary" value="<?php echo $l->t( 'Log in' ); ?>" /> </p>
</fieldset>
<p class="infield groupbottom">
<input type="password" name="password" id="password" value=""
required<?php echo $_['user_autofocus'] ? '' : ' autofocus'; ?> />
<label for="password" class="infield"><?php echo $l->t('Password'); ?></label>
<img class="svg" src="<?php echo image_path('', 'actions/password.svg'); ?>" alt=""/>
</p>
<input type="checkbox" name="remember_login" value="1" id="remember_login"/><label
for="remember_login"><?php echo $l->t('remember'); ?></label>
<input type="hidden" name="timezone-offset" id="timezone-offset"/>
<input type="submit" id="submit" class="login primary" value="<?php echo $l->t('Log in'); ?>"/>
</fieldset>
</form> </form>
<script>
$(document).ready(function () {
var visitortimezone = (-new Date().getTimezoneOffset() / 60);
$('#timezone-offset').val(visitortimezone);
});
</script>

File diff suppressed because it is too large Load Diff