From ecaf66ee970d07bd257a3a938159e38708301a5f Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 13 Jul 2011 13:30:22 -0400 Subject: [PATCH 01/18] Add missing argument for fromTmpFile() inside of rename() --- lib/filesystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filesystem.php b/lib/filesystem.php index c8bafb2b58..b82fe2afeb 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -383,7 +383,7 @@ class OC_FILESYSTEM{ } }elseif($storage1=self::getStorage($path1) and $storage2=self::getStorage($path2)){ $tmpFile=$storage1->toTmpFile(self::getInternalPath($path1)); - $result=$storage2->fromTmpFile(self::getInternalPath($path2)); + $result=$storage2->fromTmpFile($tmpFile,self::getInternalPath($path2)); $storage1->unlink(self::getInternalPath($path1)); } OC_HOOK::emit( 'OC_FILESYSTEM', 'post_rename', array( 'oldpath' => $path1, 'newpath'=>$path2)); From f09f2d3290542f476de0276f1c2587ce9cd6a49f Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 13 Jul 2011 17:19:13 -0400 Subject: [PATCH 02/18] Fix typo in setup, thanks for pointing it out ab0oo --- lib/setup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 1be4dea286..1a33209ec5 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -102,12 +102,12 @@ class OC_SETUP { //add prefix to the mysql user name to prevent collissions $dbusername='oc_mysql_'.$username; //hash the password so we don't need to store the admin config in the config file - $dbpassowrd=md5(time().$password); + $dbpassword=md5(time().$password); - self::createDBUser($dbusername, $dbpassowrd, $connection); + self::createDBUser($dbusername, $dbpassword, $connection); OC_CONFIG::setValue('dbuser', $dbusername); - OC_CONFIG::setValue('dbpassword', $dbpassowrd); + OC_CONFIG::setValue('dbpassword', $dbpassword); //create the database self::createDatabase($dbname, $dbusername, $connection); From 6935f036a5faa75383c18b21a1f7710b6d20c38c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Jul 2011 15:22:04 +0200 Subject: [PATCH 03/18] move list of mimetypes by extention to a seperate file. --- lib/filestorage.php | 70 ++++-------------------------------- lib/mimetypes.list.php | 81 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 63 deletions(-) create mode 100644 lib/mimetypes.list.php diff --git a/lib/filestorage.php b/lib/filestorage.php index 819ad2e60b..c2614dc5dc 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -65,6 +65,7 @@ OC_FILESYSTEM::registerStorageType('local','OC_FILESTORAGE_LOCAL',array('datadir */ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{ private $datadir; + private static $mimetypes=null; public function __construct($arguments){ $this->datadir=$arguments['datadir']; if(substr($this->datadir,-1)!=='/'){ @@ -209,71 +210,14 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{ $mime_type=substr($reply,0,strrpos($reply,' ')); } if (empty($mime_type)) { - // Fallback solution: try to guess the type by the file extension - // TODO: add more ... - switch (strtolower(strrchr(basename($fspath), "."))) { - case '.css': - $mime_type = 'text/css'; - break; - case '.flac': - $mime_type = 'audio/flac'; - break; - case '.gif': - $mime_type = 'image/gif'; - break; - case '.gzip': - case '.gz': - $mime_type = 'application/x-gzip'; - break; - case '.htm': - case '.html': - $mime_type = 'text/html'; - break; - case '.jpeg': - case '.jpg': - $mime_type = 'image/jpeg'; - break; - case '.js': - $mime_type = 'application/x-javascript'; - break; - case '.oga': - case '.ogg': - $mime_type = 'audio/ogg'; - break; - case '.ogv': - $mime_type = 'video/ogg'; - break; - case '.pdf': - $mime_type = 'application/pdf'; - break; - case '.png': - $mime_type = 'image/png'; - break; - case '.svg': - $mime_type = 'image/svg+xml'; - break; - case '.tar': - $mime_type = 'application/x-tar'; - break; - case '.tgz': - $mime_type = 'application/x-compressed'; - break; - case '.tif': - case '.tiff': - $mime_type = 'image/tiff'; - break; - case '.txt': - $mime_type = 'text/plain'; - break; - case '.zip': - $mime_type = 'application/zip'; - break; - default: - $mime_type = 'application/octet-stream'; - break; + // Fallback solution: (try to guess the type by the file extension + if(!self::$mimetypes){ + self::$mimetypes=include('mimetypes.list.php'); } + $extention=strtolower(strrchr(basename($fspath), ".")); + $extention=substr($extention,1);//remove leading . + $mime_type=(isset(self::$mimetypes[$extention]))?self::$mimetypes[$extention]:'application/octet-stream'; } - return $mime_type; } } diff --git a/lib/mimetypes.list.php b/lib/mimetypes.list.php new file mode 100644 index 0000000000..6d8b3b9abc --- /dev/null +++ b/lib/mimetypes.list.php @@ -0,0 +1,81 @@ +. +* +*/ + +/** + * list of mimetypes by extention + */ + +return array( + 'css'=>'text/css', + 'flac'=>'audio/flac', + 'gif'=>'image/gif', + 'gzip'=>'application/x-gzip', + 'gz'=>'application/x-gzip', + 'html'=>'text/html', + 'htm'=>'text/html', + 'jpeg'=>'image/jpeg', + 'jpg'=>'image/jpeg', + 'js'=>'application/javascript', + 'oga'=>'audio/ogg', + 'ogg'=>'audio/ogg', + 'ogv'=>'video/ogg', + 'pdf'=>'application/pdf', + 'png'=>'image/png', + 'svg'=>'image/svg+xml', + 'tar'=>'application/x-tar', + 'tgz'=>'application/x-compressed', + 'tar.gz'=>'application/x-compressed', + 'tif'=>'image/tiff', + 'tiff'=>'image/tiff', + 'txt'=>'text/plain', + 'zip'=>'application/zip', + 'wav'=>'audio/wav', + 'odt'=>'application/vnd.oasis.opendocument.text', + 'ods'=>'application/vnd.oasis.opendocument.spreadsheet', + 'odg'=>'application/vnd.oasis.opendocument.graphics', + 'odp'=>'application/vnd.oasis.opendocument.presentation', + 'kra'=>'application/x-krita', + 'mp3'=>'audio/mpeg', + 'doc'=>'application/msword', + 'docx'=>'application/msword', + 'xls'=>'application/msexcel', + 'xlsx'=>'application/msexcel', + 'php'=>'application/x-php', + 'exe'=>'application/x-ms-dos-executable', + 'pl'=>'application/x-pearl', + 'py'=>'application/x-python', + 'blend'=>'application/x-blender', + 'xcf'=>'application/x-gimp', + 'psd'=>'application/x-photoshop', + 'xml'=>'application/xml', + 'avi'=>'video/x-msvideo', + 'dv'=>'video/dv', + 'm2t'=>'video/mp2t', + 'mp4'=>'video/mp4', + 'm4v'=>'video/mp4', + 'mpg'=>'video/mpeg', + 'mpeg'=>'video/mpeg', + 'mov'=>'video/quicktime', + 'webm'=>'video/webm', + 'wmv'=>'video/x-ms-asf' +); +?> \ No newline at end of file From f4121339afc887190291a14360ecb6765106efec Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Jul 2011 15:44:02 +0200 Subject: [PATCH 04/18] Fix expiring of public links --- apps/files_publiclink/lib_public.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_publiclink/lib_public.php b/apps/files_publiclink/lib_public.php index 93ccc52d0e..b4bc86505a 100644 --- a/apps/files_publiclink/lib_public.php +++ b/apps/files_publiclink/lib_public.php @@ -26,8 +26,8 @@ class OC_PublicLink{ */ public static function getPath($token){ //remove expired links - $query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE expire_time < NOW() AND expire_time!=0"); - $query->execute(); + $query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE expire_time < ? AND expire_time!=0"); + $query->execute(array(time())); //get the path and the user $query=OC_DB::prepare("SELECT user,path FROM *PREFIX*publiclink WHERE token=?"); From 4c0c5b64c2915e765ed4b5009eef2c283fc54024 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Jul 2011 16:36:15 +0200 Subject: [PATCH 05/18] show a proper error message in help when it can't get the data from apps.owncloud.com --- help/templates/index.php | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/help/templates/index.php b/help/templates/index.php index ac7e12b757..7105507f5e 100644 --- a/help/templates/index.php +++ b/help/templates/index.php @@ -1,23 +1,27 @@

t( 'Questions and Answers' ); ?>

- - - - - - - - - -
"") { echo(''); } ?>
'.$kb['description'].''); ?>
- '') echo('
Answer:
'.$kb['answer'].'');?> -
-printPage(); -?> -t( 'ASK A QUESTION' ); ?> + + Can't connect to Q&A database + + + + + + + + + + +
"") { echo(''); } ?>
'.$kb['description'].''); ?>
+ '') echo('
Answer:
'.$kb['answer'].'');?> +
+ printPage(); + ?> + t( 'ASK A QUESTION' ); ?> + From 24e81ce4d58f08e317846d10e1ca3aecb747775d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 18 Jul 2011 18:50:21 +0200 Subject: [PATCH 06/18] fix some ldap errors --- apps/user_ldap/user_ldap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index b197aaa250..a2fd48cdf0 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -97,7 +97,7 @@ class OC_USER_LDAP extends OC_USER_BACKEND { return $entries[0]["dn"]; } public function checkPassword( $uid, $password ) { - if(!self::$configured){ + if(!$this->configured){ return false; } $dn = $this->getDn( $uid ); @@ -108,7 +108,7 @@ class OC_USER_LDAP extends OC_USER_BACKEND { } public function userExists( $uid ) { - if(!self::$configured){ + if(!$this->configured){ return false; } $dn = $this->getDn($uid); From b69ae10b7423b1753f15bd16e0ae9c8ca5d157e4 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 19 Jul 2011 20:23:33 +0200 Subject: [PATCH 07/18] Provide ability to select mutliply files during upload for browsers that support it. --- files/ajax/upload.php | 22 ++++++++++++++-------- files/js/files.js | 30 +++++++++++++++++++++--------- files/templates/index.php | 2 +- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/files/ajax/upload.php b/files/ajax/upload.php index effee0c03c..f47f9b3d28 100644 --- a/files/ajax/upload.php +++ b/files/ajax/upload.php @@ -14,20 +14,26 @@ if( !OC_USER::isLoggedIn()){ exit(); } -$fileName=$_FILES['file']['name']; -$source=$_FILES['file']['tmp_name']; +$files=$_FILES['files']; + $dir = $_POST['dir']; if(!empty($dir)) $dir .= '/'; -$target='/' . stripslashes($dir) . $fileName; +$error=''; +$result=array(); if(strpos($dir,'..') === false){ - if(OC_FILESYSTEM::fromUploadedFile($source,$target)){ - echo json_encode(array( "status" => "success", 'mime'=>OC_FILESYSTEM::getMimeType($target),'size'=>OC_FILESYSTEM::filesize($target))); - exit(); + $fileCount=count($files['name']); + for($i=0;$i<$fileCount;$i++){ + $target='/' . stripslashes($dir) . $files['name'][$i]; + if(OC_FILESYSTEM::fromUploadedFile($files['tmp_name'][$i],$target)){ + $result[]=array( "status" => "success", 'mime'=>OC_FILESYSTEM::getMimeType($target),'size'=>OC_FILESYSTEM::filesize($target),'name'=>$files['name'][$i]); + } } + echo json_encode($result); + exit(); +}else{ + $error='invalid dir'; } -$error = $_FILES['file']['error']; - echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error, "file" => $fileName))); ?> diff --git a/files/js/files.js b/files/js/files.js index 3c02110fe2..9d05b3776f 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -150,27 +150,39 @@ $(document).ready(function() { $('#file_upload_submit').click(function(){ var name=$('#file_upload_filename').val(); - if($('#file_upload_start')[0].files[0] && $('#file_upload_start')[0].files[0].size>0){ - var size=simpleFileSize($('#file_upload_start')[0].files[0].size); - }else{ - var size='Pending'; - } + var files=$('#file_upload_start')[0].files; $('#file_upload_target').load(function(){ var response=jQuery.parseJSON($('#file_upload_target').contents().find('body').text()); //set mimetype and if needed filesize - $('tr[data-file="'+name+'"]').attr('data-mime',response.mime); - if(size=='Pending'){ - $('tr[data-file='+name+'] td.filesize').text(response.size); + for(var i=0;i0){ + var size=simpleFileSize(files[i].size); + }else{ + var size='Pending'; + } + FileList.addFile(files[i].name,size,uploadTime); + } $('#file_upload_filename').val($('#file_upload_filename').data('upload_text')); + $('#file_upload_submit').hide(); }); //save the original upload button text $('#file_upload_filename').data('upload_text',$('#file_upload_filename').val()); + + //add multiply file upload attribute to all browsers except konqueror (which crashes when it's used) + if(navigator.userAgent.search(/konqueror/i)==-1){ + $('#file_upload_start').attr('multiple','multiple') + } }); var adjustNewFolderSize = function() { diff --git a/files/templates/index.php b/files/templates/index.php index a1254eeb42..e2760d80da 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -6,7 +6,7 @@ " id="dir">
)"/> - +
  From ff54602be06c5a949664d0eec2302075e60f44f7 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 19 Jul 2011 20:34:01 +0200 Subject: [PATCH 08/18] No longer use the "Ok" button for file uploads --- files/js/files.js | 12 ------------ files/templates/index.php | 1 - 2 files changed, 13 deletions(-) diff --git a/files/js/files.js b/files/js/files.js index 9d05b3776f..33573bfbbb 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -142,14 +142,6 @@ $(document).ready(function() { }); $('#file_upload_start').change(function(){ - var filename=$(this).val(); - filename=filename.replace(/^.*[\/\\]/g, ''); - $('#file_upload_filename').val(filename); - $('#file_upload_submit').show(); - }) - - $('#file_upload_submit').click(function(){ - var name=$('#file_upload_filename').val(); var files=$('#file_upload_start')[0].files; $('#file_upload_target').load(function(){ var response=jQuery.parseJSON($('#file_upload_target').contents().find('body').text()); @@ -173,11 +165,7 @@ $(document).ready(function() { } FileList.addFile(files[i].name,size,uploadTime); } - $('#file_upload_filename').val($('#file_upload_filename').data('upload_text')); - $('#file_upload_submit').hide(); }); - //save the original upload button text - $('#file_upload_filename').data('upload_text',$('#file_upload_filename').val()); //add multiply file upload attribute to all browsers except konqueror (which crashes when it's used) if(navigator.userAgent.search(/konqueror/i)==-1){ diff --git a/files/templates/index.php b/files/templates/index.php index e2760d80da..2ee3651836 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -8,7 +8,6 @@ )"/>   -
From 025129079428d26cadf3d600635653b0de6cdcd5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 19 Jul 2011 20:57:40 +0200 Subject: [PATCH 09/18] Show loading icon for uploading files, and disable file actions and DnD for uploading files. --- files/js/filelist.js | 19 ++++++++++++++++--- files/js/files.js | 15 +++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/files/js/filelist.js b/files/js/filelist.js index 290f062dae..2c662087ab 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -2,16 +2,21 @@ FileList={ update:function(fileListHtml) { $('#fileList').empty().html(fileListHtml); }, - addFile:function(name,size,lastModified){ + addFile:function(name,size,lastModified,loading){ + var img=(loading)?'img/loading.gif':'img/file.png'; var html=''; html+=''; - html+=''+name+''; + html+=''+name+''; html+=''+size+''; html+=''+lastModified+''; html+=''; html+=''; FileList.insertElement(name,'file',$(html)); - $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); + if(loading){ + $('tr[data-file="'+name+'"]').data('loading',true); + }else{ + $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); + } }, addDir:function(name,size,lastModified){ var html=''; @@ -58,5 +63,13 @@ FileList={ }else{ $('#fileList').append(element); } + }, + loadingDone:function(name){ + $('tr[data-file="'+name+'"]').data('loading',false); + $('tr[data-file="'+name+'"] td.filename a').attr('style','background-image:url(img/file.png'); + $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); + }, + isLoading:function(name){ + return $('tr[data-file="'+name+'"]').data('loading'); } } diff --git a/files/js/files.js b/files/js/files.js index 33573bfbbb..c8cef87eb9 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -40,11 +40,13 @@ $(document).ready(function() { $('td.filename a').live('click',function(event) { event.preventDefault(); var filename=$(this).parent().parent().attr('data-file'); - var mime=$(this).parent().parent().attr('data-mime'); - var type=$(this).parent().parent().attr('data-type'); - var action=FileActions.getDefault(mime,type); - if(action){ - action(filename); + if(!FileList.isLoading(filename)){ + var mime=$(this).parent().parent().attr('data-mime'); + var type=$(this).parent().parent().attr('data-type'); + var action=FileActions.getDefault(mime,type); + if(action){ + action(filename); + } } }); @@ -152,6 +154,7 @@ $(document).ready(function() { if(size=='Pending'){ $('tr[data-file='+file.name+'] td.filesize').text(file.size); } + FileList.loadingDone(file.name); } }); $('#file_upload_form').submit(); @@ -163,7 +166,7 @@ $(document).ready(function() { }else{ var size='Pending'; } - FileList.addFile(files[i].name,size,uploadTime); + FileList.addFile(files[i].name,size,uploadTime,true); } }); From 6cd5270967a1cd681bd98620bcbd352cc5e3f763 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 19 Jul 2011 21:00:35 +0200 Subject: [PATCH 10/18] Also commiting the actual loading icon might be usefull --- files/img/loading.gif | Bin 0 -> 1849 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 files/img/loading.gif diff --git a/files/img/loading.gif b/files/img/loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..5b33f7e54f4e55b6b8774d86d96895db9af044b4 GIT binary patch literal 1849 zcma*odr(tX9tZI2z31lM+(&YVk%mZ}5P~KlG2s=WSbGzm0!x7^P##Mnh7t-jP!X0Q zk_SQ}Po-L1tlDK;6l?(>v)e5ZBQx4|Y-Q?nr@Px3?9h(3ZWr3^tj=`TP57gKr87N$ zp2wWee1GRRCwo_xahnw)5cxNPJbCg2L6DV|6`#+yw6v6!mDS$f9-JvFD^n;GQ&UrZ zzh5jCkByB101O60U0q#p_1BM>Cv-vP?&s4@g_((4_1L=L$(a91)0=J91Gas#R{McE znYG^9*0A5YZ>#;~+Wkn(W5B0^yELIYLP!K}mB~<)AM@1&nqekynuaEGqPrzoH|KodRXJy)%+w_fu3nE5>@Bd_b zqC$EQ;{c`T&?EsNO|igL9gC7Ygxv?aQUEXMq?~>wg{EyW;VcJ37CUF#HjrT=KQO_* zS>M9yydXk18D(+QDJ1>r);Lav_uYKp$T?4vr{Q$lTo&pKv^?(>L-)G2*lwH!Ah7k? z7oH<8h-(KTKt5V6$8gF)C7Io&P5=SjTh)=zV=E2EUhQZP##L8S{d%UK>>+y82>+FV+#^BzW7u3F)Bb>=lYQ%%j`F>ASe zo*cw@V#u6T`A2He;70mR(V&iV&-7{qP~=SRf&jm9-T{*ZeZ}$rd0#6c&fLG^xJcf5 z+p<`wJYgW+_s*V{uI$nMB;%8`S_3>PfGOj3Rq}@Cx^+j?rk92fANSFDBYnOqQ>Vdj z)(|$AhP4t&Lb=Gvo2#3Gl%9<=Gv`Mz?Po@P4iLF!x}GUWJICDlFk-hS^Whyh7x~VH z@0vD1>HYD4&e+~yzS*-sFR{9`{QEEZO1zg7>R&7cHts-6j!xHVdA8eI+ZlVzd%`es zJT@$#GX(gvCJ1oJN%yLBK}{V=V;seo;!w|Yte!W1%5qLNFWqvZW>h&IiH+oPT=b@E zPhGzv5=(Un*X>v`>%8h_nj^NdYcE6NHS_ifkCV$*D)Tqrbu`s;<=t<4 zAHNqNV?6(g<1PY-w@#I-WYFViz?9TrkMr)u0g`O`u|>T;k|2sV*YF^punvT;$SuTy{j3Gv)yqD!R_CF>yR)MzmmYS5v+~R zXAdD%ng9?df;wd8GxR#%3O+gz};Vo;)sK%Bj-q>Oq%R7JU-KD?vYu>#2UjaDo z&8$>5xW~?KPD_#XFToU1hIb*VOMidUr6iYiO0N|i-7s`T8!cFT`rN!^1Pt78J93i6 z5HI1wIM$94m{3SLDvISDe6$ZG1;eq_D9RTaaC>=cO{@Bs>$IlPCPJJ$h$)-3vzNUQ6OsN#_zWxey!_9%hxwH2_dEJi=yY|1c7nDm2_Lm!Cof8-R_+9UkS zcBE(o47yE)oMR(Q=dp1a2wTX5KvvGyLqlWTa7V&!A*|w|)ax~1_~aJ0=_Lilg*0iQk7#ZD EAHN$8j{pDw literal 0 HcmV?d00001 From 332cab0c559361e7295d4a993329d610a050bf94 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 19 Jul 2011 23:56:21 +0200 Subject: [PATCH 11/18] fix deleting files with spaces in the name --- files/js/fileactions.js | 2 +- files/js/files.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/js/fileactions.js b/files/js/fileactions.js index 1bdbc4ac0b..b683dc0cd3 100644 --- a/files/js/fileactions.js +++ b/files/js/fileactions.js @@ -86,7 +86,7 @@ FileActions.register('all','Download',function(filename){ FileActions.register('all','Delete',function(filename){ $.ajax({ url: 'ajax/delete.php', - data: "dir="+$('#dir').val()+"&file="+filename, + data: "dir="+encodeURIComponent($('#dir').val())+"&file="+encodeURIComponent(filename), complete: function(data){ boolOperationFinished(data, function(){ FileList.remove(filename); diff --git a/files/js/files.js b/files/js/files.js index c8cef87eb9..af0c344f18 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -117,7 +117,7 @@ $(document).ready(function() { //send the browser to the download location var dir=$('#dir').val()||'/'; // alert(files); - window.location='ajax/download.php?files='+files+'&dir='+dir; + window.location='ajax/download.php?files='+encodeURIComponent(files)+'&dir='+encodeURIComponent(dir); return false; }); @@ -130,7 +130,7 @@ $(document).ready(function() { $.ajax({ url: 'ajax/delete.php', - data: "dir="+$('#dir').val()+"&files="+files, + data: "dir="+$('#dir').val()+"&files="+encodeURIComponent(files), complete: function(data){ boolOperationFinished(data, function(){ $('td.selection input:checkbox:checked').parent().parent().each(function(i,element){ From 9bc3991c230ca464b8af9b7fb219ee7925edcac9 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 20 Jul 2011 00:53:55 +0200 Subject: [PATCH 12/18] serveral small fixes to the openid server --- apps/user_openid/phpmyid.php | 12 +++++------- apps/user_openid/user.php | 6 +++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 7991b87c6d..146eb380f7 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -209,7 +209,6 @@ function authorize_mode () { $profile['idp_url']=$IDENTITY; if (isset($_SERVER['PHP_AUTH_USER']) && $profile['authorized'] === false && $_SERVER['PHP_AUTH_USER']==$USERNAME) { if (OC_USER::checkPassword($USERNAME, $_SERVER['PHP_AUTH_PW'])) {// successful login! - error_log('success'); // return to the refresh url if they get in $_SESSION['openid_auth']=true; $_SESSION['openid_user']=$USERNAME; @@ -339,7 +338,7 @@ function checkid ( $wait ) { : error_get($return_to, 'Missing identity'); $assoc_handle = @strlen($_REQUEST['openid_assoc_handle']) - ? $_REQUEST['openid_assoc.handle'] + ? $_REQUEST['openid_assoc_handle'] : null; $trust_root = @strlen($_REQUEST['openid_trust_root']) @@ -1626,7 +1625,6 @@ $GLOBALS['port'] = ((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' && $_ : ':' . $_SERVER['SERVER_PORT']; -error_log($_SERVER['HTTP_HOST']); /** * Determine the HTTP request protocol * @name $proto @@ -1651,15 +1649,15 @@ $profile['req_url'] = sprintf("%s://%s%s", // $port,//host already includes the path $_SERVER["REQUEST_URI"]); -$fullId=urlencode('.php/'.$USERNAME); -$incompleteId=urlencode('.php/'); +$fullId='user.php/'.$USERNAME.'/'; +$incompleteId='user.php/'; if(!strpos($profile['req_url'],$fullId)){ $profile['req_url']=str_replace($incompleteId,$fullId,$profile['req_url']); } -error_log('inc id: '.$fullId); -error_log('req url: '.$profile['req_url']); +// error_log('inc id: '.$fullId); +// error_log('req url: '.$profile['req_url']); // Set the default allowance for testing if (! array_key_exists('allow_test', $profile)) diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php index 52af9ba3a5..4b5d13e339 100644 --- a/apps/user_openid/user.php +++ b/apps/user_openid/user.php @@ -25,6 +25,9 @@ $USERNAME=substr($_SERVER["REQUEST_URI"],strpos($_SERVER["REQUEST_URI"],'.php/') if(strpos($USERNAME,'?')!==false){ $USERNAME=substr($USERNAME,0,strpos($USERNAME,'?')); } +if(substr($USERNAME,-1,1)=='/'){//openid sometimes add slashes to the username + $USERNAME=substr($USERNAME,0,-1); +} if($USERNAME=='' and isset($_SERVER['PHP_AUTH_USER'])){ @@ -36,7 +39,8 @@ $RUNTIME_NOAPPS=false; require_once '../../lib/base.php'; if(!OC_USER::userExists($USERNAME)){ - $USERNAME=''; + error_log($USERNAME.' doesn\'t exist'); + $USERNAME=''; } global $WEBROOT; $IDENTITY=((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].$WEBROOT.'/apps/user_openid/user.php/'.$USERNAME; From 6230001a3c80c081001c46197cc95403cc73622f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 20 Jul 2011 00:55:47 +0200 Subject: [PATCH 13/18] show expire dates of public links as date and not as datetime --- apps/files_publiclink/templates/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_publiclink/templates/admin.php b/apps/files_publiclink/templates/admin.php index 95b99109f2..da4586cb3d 100644 --- a/apps/files_publiclink/templates/admin.php +++ b/apps/files_publiclink/templates/admin.php @@ -11,7 +11,7 @@ '> - l('datetime', $link['expire_time']);?> + l('date', $link['expire_time']);?> '>?token= From c5776fdae4c6ae1fbad1831946d2e6ba4fa0ffac Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Wed, 20 Jul 2011 15:04:14 +0200 Subject: [PATCH 14/18] remember login added --- core/css/styles.css | 5 ++++- core/templates/login.php | 7 +++++++ index.php | 11 ++++++++--- lib/user.php | 16 ++++++++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index f0dfd1e9b1..678ad009d1 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -107,7 +107,10 @@ div.controls { width:91%; margin:1em 1em 1em 2em; padding:0.5em 0; background-co background-color: #666; color: #FFF; } - +#login_form input[type="checkbox"] +{ + width:15px; +} #setup_form { margin: 3em auto; diff --git a/core/templates/login.php b/core/templates/login.php index 0ed4178a98..7c0efa9fa4 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -5,8 +5,15 @@ t( 'Login failed!' ); ?> + + t('Remember login'); ?> + + + t('Remember login'); ?> + + diff --git a/index.php b/index.php index d1726676c6..2e2d495fda 100644 --- a/index.php +++ b/index.php @@ -31,7 +31,6 @@ OC_UTIL::addScript('setup'); $not_installed = !OC_CONFIG::getValue('installed', false); $install_called = (isset($_POST['install']) AND $_POST['install']=='true'); - // First step : check if the server is correctly configured for ownCloud : $errors = OC_UTIL::checkServer(); if(count($errors) > 0) { @@ -61,17 +60,23 @@ elseif(isset($_POST["user"])) { OC_APP::loadApps(); if(OC_USER::login($_POST["user"], $_POST["password"])) { header("Location: ".$WEBROOT.'/'.OC_APPCONFIG::getValue("core", "defaultpage", "files/index.php")); + if(!empty($_POST["remember_login"])){ + OC_USER::setUsernameInCookie($_POST["user"]); + } + else { + OC_USER::unsetUsernameInCookie(); + } exit(); } else { - OC_TEMPLATE::printGuestPage("", "login", array("error" => true)); + OC_TEMPLATE::printGuestPage("", "login", array("error" => true, "username" => $_COOKIE["username"])); } } // For all others cases, we display the guest page : else { OC_APP::loadApps(); - OC_TEMPLATE::printGuestPage("", "login", array("error" => false)); + OC_TEMPLATE::printGuestPage("", "login", array("error" => false, "username" => $_COOKIE["username"])); } ?> \ No newline at end of file diff --git a/lib/user.php b/lib/user.php index 25f555b47b..a64ce05f2c 100644 --- a/lib/user.php +++ b/lib/user.php @@ -337,4 +337,20 @@ class OC_USER { } return false; } + + /** + * @brief Set cookie value to use in next page load + * @param string $username username to be set + */ + public static function setUsernameInCookie($username){ + setcookie("username", $username, mktime().time()+60*60*24*15); + } + + /** + * @brief Remove cookie for "remember username" + */ + public static function unsetUsernameInCookie(){ + unset($_COOKIE["username"]); + setcookie("username", NULL, -1); + } } From 5539f671359af44634ed1de8ab5c4b8be20ee477 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 20 Jul 2011 01:18:43 +0200 Subject: [PATCH 15/18] Some ui work on user management, but it can still use a lot of improvement. --- admin/js/users.js | 10 +-- admin/templates/users.php | 159 +++++++++++++++++++------------------- admin/users.php | 1 + core/css/styles.css | 6 +- files/css/files.css | 1 + 5 files changed, 86 insertions(+), 91 deletions(-) diff --git a/admin/js/users.js b/admin/js/users.js index 48f3b15e3b..994ce6f6cb 100644 --- a/admin/js/users.js +++ b/admin/js/users.js @@ -112,7 +112,7 @@ $(document).ready(function(){ //######################################################################### // Password (clicking on user name) - $("div[x-use='usernamediv']").live( "click", function(){ + $("span[x-use='usernamediv']").live( "click", function(){ if( togglepassword == "" || $(this).parent().parent().attr("x-uid") != togglepassword ){ togglepassword = $(this).parent().parent().attr("x-uid"); // Set the username! @@ -167,6 +167,7 @@ $(document).ready(function(){ } }); $("#changegroupuid").val(togglegroup); + $(this).empty(); $(this).parent().append( $('#changegroups') ); $('#changegroups').show(); } @@ -205,13 +206,6 @@ $(document).ready(function(){ // Clicking on buttons //######################################################################### - // Show the create user form - $( "#createuseroptionbutton" ) - .click(function(){ - $("#createuserform").show(); - $("#createuseroption").hide(); - return false; - }); // Create a new user $( "#createuserbutton" ) diff --git a/admin/templates/users.php b/admin/templates/users.php index 133028c4e2..147db7c7aa 100644 --- a/admin/templates/users.php +++ b/admin/templates/users.php @@ -1,101 +1,102 @@ -

t( 'Users' ); ?>

- - - - - - - - - - - - - - - - - - - - - - - - - - "> - - - - - - -
t( 'Name' ); ?>t( 'Groups' ); ?>
  
t( 'remove' ); ?>
- -

t( 'Groups' ); ?>

- - - - - - - - - +
+ t( 'Users' ); ?> +
t( 'Name' ); ?>
+ - - + + + - - - - - "> - - + + + + + + + + - - -
t( 'Name' ); ?>t( 'Groups' ); ?>
- - t( 'remove' ); ?> - -   - -
+ ' /> + ' /> + + + " type="checkbox" name="groups[]" value="" /> + "> + + + +
+ + + + "> + +
+ + + t( 'remove' ); ?> + + + + + + + + +
+ t( 'Groups' ); ?> + + + + + + + + + + + + + + + + + + "> + + + + + +
t( 'Name' ); ?>
+ + t( 'remove' ); ?> + +   + +
+
- - + - +
diff --git a/admin/users.php b/admin/users.php index 0848d57162..8237d06da0 100644 --- a/admin/users.php +++ b/admin/users.php @@ -30,6 +30,7 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )) // We have some javascript foo! OC_UTIL::addScript( "admin", "users" ); +OC_UTIL::addStyle( "admin", "users" ); OC_APP::setActiveNavigationEntry( "core_users" ); $users = array(); diff --git a/core/css/styles.css b/core/css/styles.css index 678ad009d1..f9b536a2b0 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -7,8 +7,6 @@ h1 { margin:1em 3em 1em 0; border-bottom:1px solid #666; text-transform:uppercas p.center { text-align:center; } a { color:#000; text-decoration:none; } -form { margin:2em 2em 2em 3em; } -form#quota { max-width:600px; } form#user_settings { max-width:600px; } form#user_settings p label { display:block; float:left; width:35%; padding:0.4em 0.5em 0 0; text-align:right; } form p { padding:0.5em 4em 0.5em 0.5em; text-align:left; } @@ -19,8 +17,8 @@ form input[type="submit"] { padding:0.1em 1em; border:1px solid #999; font-weigh form input[type="submit"]:hover, form input[type="submit"]:focus { border:1px solid #999; background-color:#999; outline:0; } form input[type="submit"]:active { outline:0; } form input[type="button"], form input[type="text"] { font-size: 0.9em; } -fieldset { padding:1em; background-color:#f7f7f7; border:1px solid #ddd; } -legend { padding:0 0.5em; font-size:1.2em; } +fieldset { padding:1em; background-color:#f7f7f7; border:1px solid #ddd; max-width:600px; margin:2em 2em 2em 3em; } +legend { padding: 0.5em; font-size:1.2em; } div.controls { width:91%; margin:1em 1em 1em 2em; padding:0.5em 0; background-color:#f7f7f7; border:1px solid #eee; } diff --git a/files/css/files.css b/files/css/files.css index ed67755ab4..40ce67c66f 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -22,6 +22,7 @@ #file_upload_form, #file_newfolder_form { display: inline; + margin-left:3em; } #fileSelector, #file_upload_submit, #file_newfolder_submit { From 6b034ad2f9ef2d5443cc9b1b02b19ba20a11f37f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 20 Jul 2011 15:50:42 +0200 Subject: [PATCH 16/18] Allow users to start a new upload before the current upload has finished --- files/css/files.css | 14 +++++++------- files/js/files.js | 38 ++++++++++++++++++++++++++------------ files/templates/index.php | 10 +++++----- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/files/css/files.css b/files/css/files.css index 40ce67c66f..f4da6fae98 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -20,7 +20,7 @@ text-decoration: none; } -#file_upload_form, #file_newfolder_form { +.file_upload_form, #file_newfolder_form { display: inline; margin-left:3em; } @@ -29,23 +29,23 @@ display: none; } -#file_upload_filename, #file_newfolder_name { +.file_upload_filename, #file_newfolder_name { background-repeat: no-repeat; background-position: 0.5em 0; padding-left: 2em; } -#file_upload_filename { +.file_upload_filename { background-image:url(../img/file.png); font-weight:bold; } -#file_upload_start {opacity:0;filter: alpha(opacity = 0);} +.file_upload_start {opacity:0;filter: alpha(opacity = 0);} #file_newfolder_name { background-image:url(../img/folder.png); font-weight:bold; width: 14em; } -#file_upload_start, #file_upload_filename{ +.file_upload_start, .file_upload_filename{ position:absolute; top:0px; left:0px; @@ -53,7 +53,7 @@ font-size: 0.9em; } -#file_upload_wrapper{ +.file_upload_wrapper{ position:relative; top:-1.2em; left:-2em; @@ -66,7 +66,7 @@ width: 3em; } -#file_upload_target { +.file_upload_target { display: none; } diff --git a/files/js/files.js b/files/js/files.js index af0c344f18..d419121597 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -143,21 +143,26 @@ $(document).ready(function() { return false; }); - $('#file_upload_start').change(function(){ - var files=$('#file_upload_start')[0].files; - $('#file_upload_target').load(function(){ - var response=jQuery.parseJSON($('#file_upload_target').contents().find('body').text()); + $('.file_upload_start').live('change',function(){ + var form=$(this).parent().parent(); + var uploadId=form.attr('data-upload-id'); + var files=this.files; + var target=form.children('iframe'); + target.load(function(){ + var response=jQuery.parseJSON(target.contents().find('body').text()); //set mimetype and if needed filesize - for(var i=0;i
- + " id="max_upload"> )"> " id="dir"> -
- )"/> - +
+ )"/> +
  - +
  From f40a1c8cb8c2782569ba646b39a27675d145de25 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Wed, 20 Jul 2011 16:06:58 +0200 Subject: [PATCH 17/18] fixed file size color calculation --- files/templates/part.list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/part.list.php b/files/templates/part.list.php index 14a359fe66..d717f28885 100644 --- a/files/templates/part.list.php +++ b/files/templates/part.list.php @@ -1,6 +1,6 @@ + $simple_size_color = 200-intval(pow(($file['size']/(1024*1024)),2)); ?> From 3fab6016f9a9b9648626e5ebdaa4ea25d5104443 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Wed, 20 Jul 2011 16:11:39 +0200 Subject: [PATCH 18/18] moved Remember login below password field --- core/templates/login.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/templates/login.php b/core/templates/login.php index 7c0efa9fa4..19830a2499 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -7,12 +7,12 @@ - t('Remember login'); ?> + t('Remember login'); ?> - t('Remember login'); ?> + t('Remember login'); ?>