Compare commits
67 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3833f2315a | |||
| e65c3ef9c9 | |||
| 552aee93fa | |||
| 1791fbdc49 | |||
| c2e3999f76 | |||
| 677cec6e1c | |||
| 7435064cd3 | |||
| 0c57d94467 | |||
| 366aeb7228 | |||
| 296884b24a | |||
| 2e5ce9f4ec | |||
| cc67ae9dbb | |||
| 71d33fa065 | |||
| db3b0b63da | |||
| 5433932bd4 | |||
| f5c6a22f17 | |||
| f47c64cec6 | |||
| 7feb0f737b | |||
| 5271c1a9ad | |||
| ef3e5899c6 | |||
| badd2908b7 | |||
| 3f3b92a149 | |||
| c3646f5554 | |||
| a97d73d616 | |||
| 50684a5a34 | |||
| f06467b95b | |||
| 9faae4b71c | |||
| e49d5a5f9a | |||
| ed10a5de5b | |||
| e8b84145e8 | |||
| 38f8734014 | |||
| a10564e214 | |||
| ecef3b6b98 | |||
| e65ea6a8b7 | |||
| 7139de2a6e | |||
| b5403de5e5 | |||
| 0966f1358b | |||
| a0ac64cbd6 | |||
| b03b6dfb99 | |||
| c11f9833ac | |||
| 9ee34ef6b3 | |||
| df7e519159 | |||
| 5e60812ad4 | |||
| 1263604703 | |||
| 5904db580f | |||
| 1960067926 | |||
| 33bd9ecd9d | |||
| 7f7c1fcccf | |||
| 34fdd0e839 | |||
| 9de4eccd99 | |||
| a0847dc852 | |||
| 87a3145ba1 | |||
| 85e236d798 | |||
| cb4c3d7a9e | |||
| e55fc87ad3 | |||
| 5398dea0df | |||
| e0eb6bbd28 | |||
| 822b323f8e | |||
| c1f645cd5f | |||
| f1d9359acf | |||
| 550e774db2 | |||
| e23b06ec8c | |||
| 4f8b8a8a59 | |||
| c06d71e662 | |||
| cce43652f0 | |||
| 9f0a4c8edb | |||
| f571cfbf71 |
+2
-2
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* FullCalendar v1.5.3 Stylesheet
|
||||
* FullCalendar v1.5.4 Stylesheet
|
||||
*
|
||||
* Copyright (c) 2011 Adam Shaw
|
||||
* Dual licensed under the MIT and GPL licenses, located in
|
||||
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
|
||||
*
|
||||
* Date: Mon Feb 6 22:40:40 2012 -0800
|
||||
* Date: Tue Sep 4 23:38:33 2012 -0700
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* FullCalendar v1.5.3 Print Stylesheet
|
||||
* FullCalendar v1.5.4 Print Stylesheet
|
||||
*
|
||||
* Include this stylesheet on your page to get a more printer-friendly calendar.
|
||||
* When including this stylesheet, use the media='print' attribute of the <link> tag.
|
||||
@@ -9,7 +9,7 @@
|
||||
* Dual licensed under the MIT and GPL licenses, located in
|
||||
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
|
||||
*
|
||||
* Date: Mon Feb 6 22:40:40 2012 -0800
|
||||
* Date: Tue Sep 4 23:38:33 2012 -0700
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+17
-21
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @preserve
|
||||
* FullCalendar v1.5.3
|
||||
* FullCalendar v1.5.4
|
||||
* http://arshaw.com/fullcalendar/
|
||||
*
|
||||
* Use fullcalendar.css for basic styling.
|
||||
@@ -11,7 +11,7 @@
|
||||
* Dual licensed under the MIT and GPL licenses, located in
|
||||
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
|
||||
*
|
||||
* Date: Mon Feb 6 22:40:40 2012 -0800
|
||||
* Date: Tue Sep 4 23:38:33 2012 -0700
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -111,7 +111,7 @@ var rtlDefaults = {
|
||||
|
||||
|
||||
|
||||
var fc = $.fullCalendar = { version: "1.5.3" };
|
||||
var fc = $.fullCalendar = { version: "1.5.4" };
|
||||
var fcViews = fc.views = {};
|
||||
|
||||
|
||||
@@ -1658,7 +1658,7 @@ function sliceSegs(events, visEventEnds, start, end) {
|
||||
msLength: segEnd - segStart
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return segs.sort(segCmp);
|
||||
}
|
||||
|
||||
@@ -1742,29 +1742,26 @@ function setOuterHeight(element, height, includeMargins) {
|
||||
}
|
||||
|
||||
|
||||
// TODO: curCSS has been deprecated (jQuery 1.4.3 - 10/16/2010)
|
||||
|
||||
|
||||
function hsides(element, includeMargins) {
|
||||
return hpadding(element) + hborders(element) + (includeMargins ? hmargins(element) : 0);
|
||||
}
|
||||
|
||||
|
||||
function hpadding(element) {
|
||||
return (parseFloat($.curCSS(element[0], 'paddingLeft', true)) || 0) +
|
||||
(parseFloat($.curCSS(element[0], 'paddingRight', true)) || 0);
|
||||
return (parseFloat($.css(element[0], 'paddingLeft', true)) || 0) +
|
||||
(parseFloat($.css(element[0], 'paddingRight', true)) || 0);
|
||||
}
|
||||
|
||||
|
||||
function hmargins(element) {
|
||||
return (parseFloat($.curCSS(element[0], 'marginLeft', true)) || 0) +
|
||||
(parseFloat($.curCSS(element[0], 'marginRight', true)) || 0);
|
||||
return (parseFloat($.css(element[0], 'marginLeft', true)) || 0) +
|
||||
(parseFloat($.css(element[0], 'marginRight', true)) || 0);
|
||||
}
|
||||
|
||||
|
||||
function hborders(element) {
|
||||
return (parseFloat($.curCSS(element[0], 'borderLeftWidth', true)) || 0) +
|
||||
(parseFloat($.curCSS(element[0], 'borderRightWidth', true)) || 0);
|
||||
return (parseFloat($.css(element[0], 'borderLeftWidth', true)) || 0) +
|
||||
(parseFloat($.css(element[0], 'borderRightWidth', true)) || 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1774,20 +1771,20 @@ function vsides(element, includeMargins) {
|
||||
|
||||
|
||||
function vpadding(element) {
|
||||
return (parseFloat($.curCSS(element[0], 'paddingTop', true)) || 0) +
|
||||
(parseFloat($.curCSS(element[0], 'paddingBottom', true)) || 0);
|
||||
return (parseFloat($.css(element[0], 'paddingTop', true)) || 0) +
|
||||
(parseFloat($.css(element[0], 'paddingBottom', true)) || 0);
|
||||
}
|
||||
|
||||
|
||||
function vmargins(element) {
|
||||
return (parseFloat($.curCSS(element[0], 'marginTop', true)) || 0) +
|
||||
(parseFloat($.curCSS(element[0], 'marginBottom', true)) || 0);
|
||||
return (parseFloat($.css(element[0], 'marginTop', true)) || 0) +
|
||||
(parseFloat($.css(element[0], 'marginBottom', true)) || 0);
|
||||
}
|
||||
|
||||
|
||||
function vborders(element) {
|
||||
return (parseFloat($.curCSS(element[0], 'borderTopWidth', true)) || 0) +
|
||||
(parseFloat($.curCSS(element[0], 'borderBottomWidth', true)) || 0);
|
||||
return (parseFloat($.css(element[0], 'borderTopWidth', true)) || 0) +
|
||||
(parseFloat($.css(element[0], 'borderBottomWidth', true)) || 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1956,7 +1953,6 @@ function firstDefined() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
fcViews.month = MonthView;
|
||||
|
||||
function MonthView(element, calendar) {
|
||||
@@ -4662,7 +4658,7 @@ function DayEventRenderer() {
|
||||
"</span>";
|
||||
}
|
||||
html +=
|
||||
"<span class='fc-event-title'>" + event.title + "</span>" +
|
||||
"<span class='fc-event-title'>" + htmlEscape(event.title) + "</span>" +
|
||||
"</div>";
|
||||
if (seg.isEnd && isEventResizable(event)) {
|
||||
html +=
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
FullCalendar v1.5.3
|
||||
FullCalendar v1.5.4
|
||||
http://arshaw.com/fullcalendar/
|
||||
|
||||
Use fullcalendar.css for basic styling.
|
||||
@@ -11,7 +11,7 @@
|
||||
Dual licensed under the MIT and GPL licenses, located in
|
||||
MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
|
||||
|
||||
Date: Mon Feb 6 22:40:40 2012 -0800
|
||||
Date: Tue Sep 4 23:38:33 2012 -0700
|
||||
|
||||
*/
|
||||
(function(m,ma){function wb(a){m.extend(true,Ya,a)}function Yb(a,b,e){function d(k){if(E){u();q();na();S(k)}else f()}function f(){B=b.theme?"ui":"fc";a.addClass("fc");b.isRTL&&a.addClass("fc-rtl");b.theme&&a.addClass("ui-widget");E=m("<div class='fc-content' style='position:relative'/>").prependTo(a);C=new Zb(X,b);(P=C.render())&&a.prepend(P);y(b.defaultView);m(window).resize(oa);t()||g()}function g(){setTimeout(function(){!n.start&&t()&&S()},0)}function l(){m(window).unbind("resize",oa);C.destroy();
|
||||
@@ -39,10 +39,10 @@ a[12])*1E3);lb(e,b)}else{e.setUTCFullYear(a[1],a[3]?a[3]-1:0,a[5]||1);e.setUTCHo
|
||||
10):0)}}function Oa(a,b,e){return ib(a,null,b,e)}function ib(a,b,e,d){d=d||Ya;var f=a,g=b,l,j=e.length,t,y,S,Q="";for(l=0;l<j;l++){t=e.charAt(l);if(t=="'")for(y=l+1;y<j;y++){if(e.charAt(y)=="'"){if(f){Q+=y==l+1?"'":e.substring(l+1,y);l=y}break}}else if(t=="(")for(y=l+1;y<j;y++){if(e.charAt(y)==")"){l=Oa(f,e.substring(l+1,y),d);if(parseInt(l.replace(/\D/,""),10))Q+=l;l=y;break}}else if(t=="[")for(y=l+1;y<j;y++){if(e.charAt(y)=="]"){t=e.substring(l+1,y);l=Oa(f,t,d);if(l!=Oa(g,t,d))Q+=l;l=y;break}}else if(t==
|
||||
"{"){f=b;g=a}else if(t=="}"){f=a;g=b}else{for(y=j;y>l;y--)if(S=dc[e.substring(l,y)]){if(f)Q+=S(f,d);l=y-1;break}if(y==l)if(f)Q+=t}}return Q}function Ua(a){return a.end?ec(a.end,a.allDay):ba(N(a.start),1)}function ec(a,b){a=N(a);return b||a.getHours()||a.getMinutes()?ba(a,1):Ka(a)}function fc(a,b){return(b.msLength-a.msLength)*100+(a.event.start-b.event.start)}function Cb(a,b){return a.end>b.start&&a.start<b.end}function nb(a,b,e,d){var f=[],g,l=a.length,j,t,y,S,Q;for(g=0;g<l;g++){j=a[g];t=j.start;
|
||||
y=b[g];if(y>e&&t<d){if(t<e){t=N(e);S=false}else{t=t;S=true}if(y>d){y=N(d);Q=false}else{y=y;Q=true}f.push({event:j,start:t,end:y,isStart:S,isEnd:Q,msLength:y-t})}}return f.sort(fc)}function ob(a){var b=[],e,d=a.length,f,g,l,j;for(e=0;e<d;e++){f=a[e];for(g=0;;){l=false;if(b[g])for(j=0;j<b[g].length;j++)if(Cb(b[g][j],f)){l=true;break}if(l)g++;else break}if(b[g])b[g].push(f);else b[g]=[f]}return b}function Db(a,b,e){a.unbind("mouseover").mouseover(function(d){for(var f=d.target,g;f!=this;){g=f;f=f.parentNode}if((f=
|
||||
g._fci)!==ma){g._fci=ma;g=b[f];e(g.event,g.element,g);m(d.target).trigger(d)}d.stopPropagation()})}function Va(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.width(Math.max(0,b-pb(f,e)))}}function Eb(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.height(Math.max(0,b-Sa(f,e)))}}function pb(a,b){return gc(a)+hc(a)+(b?ic(a):0)}function gc(a){return(parseFloat(m.curCSS(a[0],"paddingLeft",true))||0)+(parseFloat(m.curCSS(a[0],"paddingRight",true))||0)}function ic(a){return(parseFloat(m.curCSS(a[0],
|
||||
"marginLeft",true))||0)+(parseFloat(m.curCSS(a[0],"marginRight",true))||0)}function hc(a){return(parseFloat(m.curCSS(a[0],"borderLeftWidth",true))||0)+(parseFloat(m.curCSS(a[0],"borderRightWidth",true))||0)}function Sa(a,b){return jc(a)+kc(a)+(b?Fb(a):0)}function jc(a){return(parseFloat(m.curCSS(a[0],"paddingTop",true))||0)+(parseFloat(m.curCSS(a[0],"paddingBottom",true))||0)}function Fb(a){return(parseFloat(m.curCSS(a[0],"marginTop",true))||0)+(parseFloat(m.curCSS(a[0],"marginBottom",true))||0)}
|
||||
function kc(a){return(parseFloat(m.curCSS(a[0],"borderTopWidth",true))||0)+(parseFloat(m.curCSS(a[0],"borderBottomWidth",true))||0)}function Za(a,b){b=typeof b=="number"?b+"px":b;a.each(function(e,d){d.style.cssText+=";min-height:"+b+";_height:"+b})}function xb(){}function Gb(a,b){return a-b}function Hb(a){return Math.max.apply(Math,a)}function Pa(a){return(a<10?"0":"")+a}function jb(a,b){if(a[b]!==ma)return a[b];b=b.split(/(?=[A-Z])/);for(var e=b.length-1,d;e>=0;e--){d=a[b[e].toLowerCase()];if(d!==
|
||||
ma)return d}return a[""]}function Qa(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""").replace(/\n/g,"<br />")}function Ib(a){return a.id+"/"+a.className+"/"+a.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/ig,"")}function qb(a){a.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})}function ab(a){a.children().removeClass("fc-first fc-last").filter(":first-child").addClass("fc-first").end().filter(":last-child").addClass("fc-last")}
|
||||
g._fci)!==ma){g._fci=ma;g=b[f];e(g.event,g.element,g);m(d.target).trigger(d)}d.stopPropagation()})}function Va(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.width(Math.max(0,b-pb(f,e)))}}function Eb(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.height(Math.max(0,b-Sa(f,e)))}}function pb(a,b){return gc(a)+hc(a)+(b?ic(a):0)}function gc(a){return(parseFloat(m.css(a[0],"paddingLeft",true))||0)+(parseFloat(m.css(a[0],"paddingRight",true))||0)}function ic(a){return(parseFloat(m.css(a[0],"marginLeft",
|
||||
true))||0)+(parseFloat(m.css(a[0],"marginRight",true))||0)}function hc(a){return(parseFloat(m.css(a[0],"borderLeftWidth",true))||0)+(parseFloat(m.css(a[0],"borderRightWidth",true))||0)}function Sa(a,b){return jc(a)+kc(a)+(b?Fb(a):0)}function jc(a){return(parseFloat(m.css(a[0],"paddingTop",true))||0)+(parseFloat(m.css(a[0],"paddingBottom",true))||0)}function Fb(a){return(parseFloat(m.css(a[0],"marginTop",true))||0)+(parseFloat(m.css(a[0],"marginBottom",true))||0)}function kc(a){return(parseFloat(m.css(a[0],
|
||||
"borderTopWidth",true))||0)+(parseFloat(m.css(a[0],"borderBottomWidth",true))||0)}function Za(a,b){b=typeof b=="number"?b+"px":b;a.each(function(e,d){d.style.cssText+=";min-height:"+b+";_height:"+b})}function xb(){}function Gb(a,b){return a-b}function Hb(a){return Math.max.apply(Math,a)}function Pa(a){return(a<10?"0":"")+a}function jb(a,b){if(a[b]!==ma)return a[b];b=b.split(/(?=[A-Z])/);for(var e=b.length-1,d;e>=0;e--){d=a[b[e].toLowerCase()];if(d!==ma)return d}return a[""]}function Qa(a){return a.replace(/&/g,
|
||||
"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""").replace(/\n/g,"<br />")}function Ib(a){return a.id+"/"+a.className+"/"+a.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/ig,"")}function qb(a){a.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})}function ab(a){a.children().removeClass("fc-first fc-last").filter(":first-child").addClass("fc-first").end().filter(":last-child").addClass("fc-last")}
|
||||
function rb(a,b){a.each(function(e,d){d.className=d.className.replace(/^fc-\w*/,"fc-"+lc[b.getDay()])})}function Jb(a,b){var e=a.source||{},d=a.color,f=e.color,g=b("eventColor"),l=a.backgroundColor||d||e.backgroundColor||f||b("eventBackgroundColor")||g;d=a.borderColor||d||e.borderColor||f||b("eventBorderColor")||g;a=a.textColor||e.textColor||b("eventTextColor");b=[];l&&b.push("background-color:"+l);d&&b.push("border-color:"+d);a&&b.push("color:"+a);return b.join(";")}function $a(a,b,e){if(m.isFunction(a))a=
|
||||
[a];if(a){var d,f;for(d=0;d<a.length;d++)f=a[d].apply(b,e)||f;return f}}function Ta(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==ma)return arguments[a]}function mc(a,b){function e(j,t){if(t){hb(j,t);j.setDate(1)}j=N(j,true);j.setDate(1);t=hb(N(j),1);var y=N(j),S=N(t),Q=f("firstDay"),q=f("weekends")?0:1;if(q){Fa(y);Fa(S,-1,true)}ba(y,-((y.getDay()-Math.max(Q,q)+7)%7));ba(S,(7-S.getDay()+Math.max(Q,q))%7);Q=Math.round((S-y)/(Ab*7));if(f("weekMode")=="fixed"){ba(S,(6-Q)*7);Q=6}d.title=l(j,
|
||||
f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(6,Q,q?5:7,true)}var d=this;d.render=e;sb.call(d,a,b,"month");var f=d.opt,g=d.renderBasic,l=b.formatDate}function nc(a,b){function e(j,t){t&&ba(j,t*7);j=ba(N(j),-((j.getDay()-f("firstDay")+7)%7));t=ba(N(j),7);var y=N(j),S=N(t),Q=f("weekends");if(!Q){Fa(y);Fa(S,-1,true)}d.title=l(y,ba(N(S),-1),f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(1,1,Q?7:5,false)}var d=this;d.render=e;sb.call(d,a,b,"basicWeek");var f=d.opt,g=d.renderBasic,
|
||||
@@ -106,7 +106,7 @@ t,y=-1,S=-1;for(t=0;t<l;t++)if(g>=e[t][0]&&g<e[t][1]){y=t;break}for(t=0;t<j;t++)
|
||||
g=l=null;a.build();b(t);d=y||"mousemove";m(document).bind(d,b)};e.stop=function(){m(document).unbind(d,b);return l}}function xc(a){if(a.pageX===ma){a.pageX=a.originalEvent.pageX;a.pageY=a.originalEvent.pageY}}function Pb(a){function b(l){return d[l]=d[l]||a(l)}var e=this,d={},f={},g={};e.left=function(l){return f[l]=f[l]===ma?b(l).position().left:f[l]};e.right=function(l){return g[l]=g[l]===ma?e.left(l)+b(l).width():g[l]};e.clear=function(){d={};f={};g={}}}var Ya={defaultView:"month",aspectRatio:1.35,
|
||||
header:{left:"title",center:"",right:"today prev,next"},weekends:true,allDayDefault:true,ignoreTimezone:true,lazyFetching:true,startParam:"start",endParam:"end",titleFormat:{month:"MMMM yyyy",week:"MMM d[ yyyy]{ '—'[ MMM] d yyyy}",day:"dddd, MMM d, yyyy"},columnFormat:{month:"ddd",week:"ddd M/d",day:"dddd M/d"},timeFormat:{"":"h(:mm)t"},isRTL:false,firstDay:0,monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan",
|
||||
"Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],buttonText:{prev:" ◄ ",next:" ► ",prevYear:" << ",nextYear:" >> ",today:"today",month:"month",week:"week",day:"day"},theme:false,buttonIcons:{prev:"circle-triangle-w",next:"circle-triangle-e"},unselectAuto:true,dropAccept:"*"},yc=
|
||||
{header:{left:"next,prev today",center:"",right:"title"},buttonText:{prev:" ► ",next:" ◄ ",prevYear:" >> ",nextYear:" << "},buttonIcons:{prev:"circle-triangle-e",next:"circle-triangle-w"}},Aa=m.fullCalendar={version:"1.5.3"},Ja=Aa.views={};m.fn.fullCalendar=function(a){if(typeof a=="string"){var b=Array.prototype.slice.call(arguments,1),e;this.each(function(){var f=m.data(this,"fullCalendar");if(f&&m.isFunction(f[a])){f=f[a].apply(f,
|
||||
{header:{left:"next,prev today",center:"",right:"title"},buttonText:{prev:" ► ",next:" ◄ ",prevYear:" >> ",nextYear:" << "},buttonIcons:{prev:"circle-triangle-e",next:"circle-triangle-w"}},Aa=m.fullCalendar={version:"1.5.4"},Ja=Aa.views={};m.fn.fullCalendar=function(a){if(typeof a=="string"){var b=Array.prototype.slice.call(arguments,1),e;this.each(function(){var f=m.data(this,"fullCalendar");if(f&&m.isFunction(f[a])){f=f[a].apply(f,
|
||||
b);if(e===ma)e=f;a=="destroy"&&m.removeData(this,"fullCalendar")}});if(e!==ma)return e;return this}var d=a.eventSources||[];delete a.eventSources;if(a.events){d.push(a.events);delete a.events}a=m.extend(true,{},Ya,a.isRTL||a.isRTL===ma&&Ya.isRTL?yc:{},a);this.each(function(f,g){f=m(g);g=new Yb(f,a,d);f.data("fullCalendar",g);g.render()});return this};Aa.sourceNormalizers=[];Aa.sourceFetchers=[];var ac={dataType:"json",cache:false},bc=1;Aa.addDays=ba;Aa.cloneDate=N;Aa.parseDate=kb;Aa.parseISO8601=
|
||||
Bb;Aa.parseTime=mb;Aa.formatDate=Oa;Aa.formatDates=ib;var lc=["sun","mon","tue","wed","thu","fri","sat"],Ab=864E5,cc=36E5,wc=6E4,dc={s:function(a){return a.getSeconds()},ss:function(a){return Pa(a.getSeconds())},m:function(a){return a.getMinutes()},mm:function(a){return Pa(a.getMinutes())},h:function(a){return a.getHours()%12||12},hh:function(a){return Pa(a.getHours()%12||12)},H:function(a){return a.getHours()},HH:function(a){return Pa(a.getHours())},d:function(a){return a.getDate()},dd:function(a){return Pa(a.getDate())},
|
||||
ddd:function(a,b){return b.dayNamesShort[a.getDay()]},dddd:function(a,b){return b.dayNames[a.getDay()]},M:function(a){return a.getMonth()+1},MM:function(a){return Pa(a.getMonth()+1)},MMM:function(a,b){return b.monthNamesShort[a.getMonth()]},MMMM:function(a,b){return b.monthNames[a.getMonth()]},yy:function(a){return(a.getFullYear()+"").substring(2)},yyyy:function(a){return a.getFullYear()},t:function(a){return a.getHours()<12?"a":"p"},tt:function(a){return a.getHours()<12?"am":"pm"},T:function(a){return a.getHours()<
|
||||
|
||||
Vendored
+2
-2
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* FullCalendar v1.5.3 Google Calendar Plugin
|
||||
* FullCalendar v1.5.4 Google Calendar Plugin
|
||||
*
|
||||
* Copyright (c) 2011 Adam Shaw
|
||||
* Dual licensed under the MIT and GPL licenses, located in
|
||||
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
|
||||
*
|
||||
* Date: Mon Feb 6 22:40:40 2012 -0800
|
||||
* Date: Tue Sep 4 23:38:33 2012 -0700
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+2
-2
@@ -2000,7 +2000,7 @@ class CF_Object
|
||||
// }
|
||||
|
||||
//use OC's mimetype detection for files
|
||||
if(is_file($handle)){
|
||||
if(@is_file($handle)){
|
||||
$this->content_type=OC_Helper::getMimeType($handle);
|
||||
}else{
|
||||
$this->content_type=OC_Helper::getStringMimeType($handle);
|
||||
@@ -2537,7 +2537,7 @@ class CF_Object
|
||||
}
|
||||
$md5 = hash_final($ctx, false);
|
||||
rewind($data);
|
||||
} elseif ((string)is_file($data)) {
|
||||
} elseif ((string)@is_file($data)) {
|
||||
$md5 = md5_file($data);
|
||||
} else {
|
||||
$md5 = md5($data);
|
||||
|
||||
Vendored
+12
@@ -229,6 +229,8 @@ class smb {
|
||||
}
|
||||
|
||||
function addstatcache ($url, $info) {
|
||||
$url = str_replace('//', '/', $url);
|
||||
$url = rtrim($url, '/');
|
||||
global $__smb_cache;
|
||||
$is_file = (strpos ($info['attr'],'D') === FALSE);
|
||||
$s = ($is_file) ? stat ('/etc/passwd') : stat ('/tmp');
|
||||
@@ -238,11 +240,15 @@ class smb {
|
||||
}
|
||||
|
||||
function getstatcache ($url) {
|
||||
$url = str_replace('//', '/', $url);
|
||||
$url = rtrim($url, '/');
|
||||
global $__smb_cache;
|
||||
return isset ($__smb_cache['stat'][$url]) ? $__smb_cache['stat'][$url] : FALSE;
|
||||
}
|
||||
|
||||
function clearstatcache ($url='') {
|
||||
$url = str_replace('//', '/', $url);
|
||||
$url = rtrim($url, '/');
|
||||
global $__smb_cache;
|
||||
if ($url == '') $__smb_cache['stat'] = array (); else unset ($__smb_cache['stat'][$url]);
|
||||
}
|
||||
@@ -358,16 +364,22 @@ class smb_stream_wrapper extends smb {
|
||||
# cache
|
||||
|
||||
function adddircache ($url, $content) {
|
||||
$url = str_replace('//', '/', $url);
|
||||
$url = rtrim($url, '/');
|
||||
global $__smb_cache;
|
||||
return $__smb_cache['dir'][$url] = $content;
|
||||
}
|
||||
|
||||
function getdircache ($url) {
|
||||
$url = str_replace('//', '/', $url);
|
||||
$url = rtrim($url, '/');
|
||||
global $__smb_cache;
|
||||
return isset ($__smb_cache['dir'][$url]) ? $__smb_cache['dir'][$url] : FALSE;
|
||||
}
|
||||
|
||||
function cleardircache ($url='') {
|
||||
$url = str_replace('//', '/', $url);
|
||||
$url = rtrim($url, '/');
|
||||
global $__smb_cache;
|
||||
if ($url == ''){
|
||||
$__smb_cache['dir'] = array ();
|
||||
|
||||
@@ -36,7 +36,7 @@ if(!isset($_SESSION['timezone'])) {
|
||||
}
|
||||
OCP\App::setActiveNavigationEntry( 'files_index' );
|
||||
// Load the files
|
||||
$dir = isset( $_GET['dir'] ) ? stripslashes($_GET['dir']) : '';
|
||||
$dir = isset( $_GET['dir'] ) ? urldecode(stripslashes($_GET['dir'])) : '';
|
||||
// Redirect if directory does not exist
|
||||
if(!OC_Filesystem::is_dir($dir.'/')) {
|
||||
header('Location: '.$_SERVER['SCRIPT_NAME'].'');
|
||||
|
||||
@@ -15,9 +15,9 @@ var FileList={
|
||||
extension=false;
|
||||
}
|
||||
html+='<td class="filename" style="background-image:url('+img+')"><input type="checkbox" />';
|
||||
html+='<a class="name" href="download.php?file='+$('#dir').val().replace(/</, '<').replace(/>/, '>')+'/'+name+'"><span class="nametext">'+basename;
|
||||
html+='<a class="name" href="download.php?file='+$('#dir').val().replace(/</, '<').replace(/>/, '>')+'/'+escapeHTML(name)+'"><span class="nametext">'+escapeHTML(basename);
|
||||
if(extension){
|
||||
html+='<span class="extension">'+extension+'</span>';
|
||||
html+='<span class="extension">'+escapeHTML(extension)+'</span>';
|
||||
}
|
||||
html+='</span></a></td>';
|
||||
if(size!='Pending'){
|
||||
@@ -189,9 +189,9 @@ var FileList={
|
||||
checkName:function(oldName, newName, isNewFile) {
|
||||
if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) {
|
||||
if (isNewFile) {
|
||||
$('#notification').html(newName+' '+t('files', 'already exists')+'<span class="replace">'+t('files', 'replace')+'</span><span class="suggest">'+t('files', 'suggest name')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
||||
$('#notification').html(escapeHTML(newName)+' '+t('files', 'already exists')+'<span class="replace">'+t('files', 'replace')+'</span><span class="suggest">'+t('files', 'suggest name')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
||||
} else {
|
||||
$('#notification').html(newName+' '+t('files', 'already exists')+'<span class="replace">'+t('files', 'replace')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
||||
$('#notification').html(escapeHTML(newName)+' '+t('files', 'already exists')+'<span class="replace">'+t('files', 'replace')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
||||
}
|
||||
$('#notification').data('oldName', oldName);
|
||||
$('#notification').data('newName', newName);
|
||||
@@ -272,9 +272,9 @@ var FileList={
|
||||
} else {
|
||||
// NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
|
||||
if ($('#dir').val() == '/Shared') {
|
||||
$('#notification').html(t('files', 'unshared')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||
$('#notification').html(t('files', 'unshared')+' '+ escapeHTML(files) +'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||
} else {
|
||||
$('#notification').html(t('files', 'deleted')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||
$('#notification').html(t('files', 'deleted')+' '+ escapeHTML(files)+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||
}
|
||||
$('#notification').fadeIn();
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ $(document).ready(function() {
|
||||
var totalSize=0;
|
||||
if(files){
|
||||
for(var i=0;i<files.length;i++){
|
||||
if(files[i].size ==0 && files[i].type== '')
|
||||
if(files[i].size ==0 || files[i].type== '')
|
||||
{
|
||||
OC.dialogs.alert(t('files', 'Unable to upload your file as it is a directory or has 0 bytes'), t('files', 'Upload Error'));
|
||||
return;
|
||||
@@ -282,7 +282,7 @@ $(document).ready(function() {
|
||||
var fileName = files[i].name
|
||||
var dropTarget = $(e.originalEvent.target).closest('tr');
|
||||
if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder
|
||||
var dirName = dropTarget.attr('data-file')
|
||||
var dirName = dropTarget.attr('data-file');
|
||||
var jqXHR = $('.file_upload_start').fileupload('send', {files: files[i],
|
||||
formData: function(form) {
|
||||
var formArray = form.serializeArray();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php for($i=0; $i<count($_["breadcrumb"]); $i++):
|
||||
$crumb = $_["breadcrumb"][$i]; ?>
|
||||
<div class="crumb <?php if($i == count($_["breadcrumb"])-1) echo 'last';?> svg" data-dir='<?php echo urlencode($crumb["dir"]);?>' style='background-image:url("<?php echo OCP\image_path('core','breadcrumb.png');?>")'>
|
||||
<a href="<?php echo $_['baseURL'].urlencode($crumb["dir"]); ?>"><?php echo OCP\Util::sanitizeHTML($crumb["name"]); ?></a>
|
||||
<a href="<?php echo urlencode($_['baseURL'].$crumb["dir"]); ?>"><?php echo OCP\Util::sanitizeHTML($crumb["name"]); ?></a>
|
||||
</div>
|
||||
<?php endfor;?>
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
<script type="text/javascript">
|
||||
<?php if ( array_key_exists('publicListView', $_) && $_['publicListView'] == true ) {
|
||||
echo "var publicListView = true;";
|
||||
} else {
|
||||
echo "var publicListView = false;";
|
||||
}
|
||||
?>
|
||||
</script>
|
||||
|
||||
<?php foreach($_['files'] as $file):
|
||||
$simple_file_size = OCP\simple_file_size($file['size']);
|
||||
$simple_size_color = intval(200-$file['size']/(1024*1024)*2); // the bigger the file, the darker the shade of grey; megabytes*2
|
||||
|
||||
@@ -109,10 +109,10 @@ class OC_Mount_Config {
|
||||
return $personal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add directory for mount point to the filesystem
|
||||
* @param OC_Fileview instance $view
|
||||
* @param string path to mount point
|
||||
/**
|
||||
* Add directory for mount point to the filesystem
|
||||
* @param OC_Fileview instance $view
|
||||
* @param string path to mount point
|
||||
*/
|
||||
private static function addMountPointDirectory($view, $path) {
|
||||
$dir = '';
|
||||
@@ -288,6 +288,9 @@ class OC_Mount_Config {
|
||||
if (!is_dir($path)) mkdir($path);
|
||||
$result = array();
|
||||
$handle = opendir($path);
|
||||
if (!$handle) {
|
||||
return array();
|
||||
}
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if($file != '.' && $file != '..') $result[] = $file;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
|
||||
}
|
||||
|
||||
public function filetype($path) {
|
||||
return (bool)@$this->opendir($path);//using opendir causes the same amount of requests and caches the content of the folder in one go
|
||||
return (bool)@$this->opendir($path) ? 'dir' : 'file';//using opendir causes the same amount of requests and caches the content of the folder in one go
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
* @return string
|
||||
*/
|
||||
private function getContainerName($path) {
|
||||
$path=trim($this->root.$path,'/');
|
||||
$path=trim(trim($this->root,'/')."/".$path,'/.');
|
||||
return str_replace('/','\\',$path);
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
* @return CF_Container
|
||||
*/
|
||||
private function createContainer($path) {
|
||||
if($path=='' or $path=='/') {
|
||||
if($path=='' or $path=='/' or $path=='.') {
|
||||
return $this->conn->create_container($this->getContainerName($path));
|
||||
}
|
||||
$parent=dirname($path);
|
||||
if($parent=='' or $parent=='/') {
|
||||
if($parent=='' or $parent=='/' or $parent=='.') {
|
||||
$parentContainer=$this->rootContainer;
|
||||
}else{
|
||||
if(!$this->containerExists($parent)) {
|
||||
@@ -100,6 +100,9 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
if(is_null($container)) {
|
||||
return null;
|
||||
}else{
|
||||
if ($path=="/" or $path=='') {
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
$obj=$container->get_object(basename($path));
|
||||
$this->objects[$path]=$obj;
|
||||
@@ -135,7 +138,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
private function createObject($path) {
|
||||
$container=$this->getContainer(dirname($path));
|
||||
if(!is_null($container)) {
|
||||
$container=$this->createContainer($path);
|
||||
$container=$this->createContainer(dirname($path));
|
||||
}
|
||||
return $container->create_object(basename($path));
|
||||
}
|
||||
@@ -277,7 +280,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
|
||||
$this->conn = new CF_Connection($this->auth);
|
||||
|
||||
if(!$this->containerExists($this->root)) {
|
||||
if(!$this->containerExists('/')) {
|
||||
$this->rootContainer=$this->createContainer('/');
|
||||
}else{
|
||||
$this->rootContainer=$this->getContainer('/');
|
||||
@@ -391,6 +394,9 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
}
|
||||
|
||||
public function unlink($path) {
|
||||
if($this->containerExists($path)) {
|
||||
return $this->rmdir($path);
|
||||
}
|
||||
if($this->objectExists($path)) {
|
||||
$container=$this->getContainer(dirname($path));
|
||||
$container->delete_object(basename($path));
|
||||
@@ -401,13 +407,13 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
}
|
||||
|
||||
public function fopen($path,$mode) {
|
||||
$obj=$this->getObject($path);
|
||||
if(is_null($obj)) {
|
||||
return false;
|
||||
}
|
||||
switch($mode) {
|
||||
case 'r':
|
||||
case 'rb':
|
||||
$obj=$this->getObject($path);
|
||||
if (is_null($obj)) {
|
||||
return false;
|
||||
}
|
||||
$fp = fopen('php://temp', 'r+');
|
||||
$obj->stream($fp);
|
||||
|
||||
@@ -440,7 +446,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
}
|
||||
|
||||
public function free_space($path) {
|
||||
return 0;
|
||||
return 1024*1024*1024*8;
|
||||
}
|
||||
|
||||
public function touch($path,$mtime=null) {
|
||||
@@ -481,7 +487,17 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
}
|
||||
|
||||
public function stat($path) {
|
||||
$container=$this->getContainer($path);
|
||||
if (!is_null($container)) {
|
||||
return array(
|
||||
'mtime'=>-1,
|
||||
'size'=>$container->bytes_used,
|
||||
'ctime'=>-1
|
||||
);
|
||||
}
|
||||
|
||||
$obj=$this->getObject($path);
|
||||
|
||||
if(is_null($obj)) {
|
||||
return false;
|
||||
}
|
||||
@@ -505,7 +521,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||
$obj->save_to_filename($tmpFile);
|
||||
return $tmpFile;
|
||||
}else{
|
||||
return false;
|
||||
return OCP\Files::tmpFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,9 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||
switch($mode) {
|
||||
case 'r':
|
||||
case 'rb':
|
||||
if(!$this->file_exists($path)) {
|
||||
return false;
|
||||
}
|
||||
//straight up curl instead of sabredav here, sabredav put's the entire get result in memory
|
||||
$curl = curl_init();
|
||||
$fp = fopen('php://temp', 'r+');
|
||||
|
||||
@@ -1,43 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Michael Gapczynski
|
||||
* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
* ownCloud
|
||||
*
|
||||
* @author Michael Gapczynski
|
||||
* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
$config = include('apps/files_external/tests/config.php');
|
||||
if (!is_array($config) or !isset($config['amazons3']) or !$config['amazons3']['run']) {
|
||||
abstract class Test_Filestorage_AmazonS3 extends Test_FileStorage{}
|
||||
return;
|
||||
} else {
|
||||
class Test_Filestorage_AmazonS3 extends Test_FileStorage {
|
||||
class Test_Filestorage_AmazonS3 extends Test_FileStorage {
|
||||
|
||||
private $config;
|
||||
private $id;
|
||||
private $config;
|
||||
private $id;
|
||||
|
||||
public function setUp() {
|
||||
$id = uniqid();
|
||||
$this->config = include('apps/files_external/tests/config.php');
|
||||
$this->config['amazons3']['bucket'] = $id; // Make sure we have a new empty bucket to work in
|
||||
$this->instance = new OC_Filestorage_AmazonS3($this->config['amazons3']);
|
||||
public function setUp() {
|
||||
$id = uniqid();
|
||||
$this->config = include('files_external/tests/config.php');
|
||||
if (!is_array($this->config) or !isset($this->config['amazons3']) or !$this->config['amazons3']['run']) {
|
||||
$this->markTestSkipped('AmazonS3 backend not configured');
|
||||
}
|
||||
$this->config['amazons3']['bucket'] = $id; // Make sure we have a new empty bucket to work in
|
||||
$this->instance = new OC_Filestorage_AmazonS3($this->config['amazons3']);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() {
|
||||
if ($this->instance) {
|
||||
$s3 = new AmazonS3(array('key' => $this->config['amazons3']['key'], 'secret' => $this->config['amazons3']['secret']));
|
||||
if ($s3->delete_all_objects($this->id)) {
|
||||
$s3->delete_bucket($this->id);
|
||||
|
||||
@@ -26,7 +26,7 @@ return array(
|
||||
'run'=>false,
|
||||
'user'=>'test:tester',
|
||||
'token'=>'testing',
|
||||
'host'=>'localhost:8080/auth',
|
||||
'host'=>'localhost.local:8080/auth',
|
||||
'root'=>'/',
|
||||
),
|
||||
'smb'=>array(
|
||||
|
||||
@@ -6,22 +6,21 @@
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
$config=include('files_external/tests/config.php');
|
||||
if(!is_array($config) or !isset($config['dropbox']) or !$config['dropbox']['run']) {
|
||||
abstract class Test_Filestorage_Dropbox extends Test_FileStorage{}
|
||||
return;
|
||||
}else{
|
||||
class Test_Filestorage_Dropbox extends Test_FileStorage {
|
||||
private $config;
|
||||
class Test_Filestorage_Dropbox extends Test_FileStorage {
|
||||
private $config;
|
||||
|
||||
public function setUp() {
|
||||
$id=uniqid();
|
||||
$this->config=include('files_external/tests/config.php');
|
||||
$this->config['dropbox']['root'].='/'.$id;//make sure we have an new empty folder to work in
|
||||
$this->instance=new OC_Filestorage_Dropbox($this->config['dropbox']);
|
||||
public function setUp() {
|
||||
$id = uniqid();
|
||||
$this->config = include('files_external/tests/config.php');
|
||||
if (!is_array($this->config) or !isset($this->config['dropbox']) or !$this->config['dropbox']['run']) {
|
||||
$this->markTestSkipped('Dropbox backend not configured');
|
||||
}
|
||||
$this->config['dropbox']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||
$this->instance = new OC_Filestorage_Dropbox($this->config['dropbox']);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() {
|
||||
if ($this->instance) {
|
||||
$this->instance->unlink('/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,22 +6,21 @@
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
$config=include('apps/files_external/tests/config.php');
|
||||
if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']) {
|
||||
abstract class Test_Filestorage_FTP extends Test_FileStorage{}
|
||||
return;
|
||||
}else{
|
||||
class Test_Filestorage_FTP extends Test_FileStorage {
|
||||
private $config;
|
||||
class Test_Filestorage_FTP extends Test_FileStorage {
|
||||
private $config;
|
||||
|
||||
public function setUp() {
|
||||
$id=uniqid();
|
||||
$this->config=include('apps/files_external/tests/config.php');
|
||||
$this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in
|
||||
$this->instance=new OC_Filestorage_FTP($this->config['ftp']);
|
||||
public function setUp() {
|
||||
$id = uniqid();
|
||||
$this->config = include('files_external/tests/config.php');
|
||||
if (!is_array($this->config) or !isset($this->config['ftp']) or !$this->config['ftp']['run']) {
|
||||
$this->markTestSkipped('FTP backend not configured');
|
||||
}
|
||||
$this->config['ftp']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||
$this->instance = new OC_Filestorage_FTP($this->config['ftp']);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() {
|
||||
if ($this->instance) {
|
||||
OCP\Files::rmdirr($this->instance->constructUrl(''));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Michael Gapczynski
|
||||
* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
* ownCloud
|
||||
*
|
||||
* @author Michael Gapczynski
|
||||
* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
$config=include('apps/files_external/tests/config.php');
|
||||
if(!is_array($config) or !isset($config['google']) or !$config['google']['run']) {
|
||||
abstract class Test_Filestorage_Google extends Test_FileStorage{}
|
||||
return;
|
||||
}else{
|
||||
class Test_Filestorage_Google extends Test_FileStorage {
|
||||
class Test_Filestorage_Google extends Test_FileStorage {
|
||||
|
||||
private $config;
|
||||
private $config;
|
||||
|
||||
public function setUp() {
|
||||
$id=uniqid();
|
||||
$this->config=include('apps/files_external/tests/config.php');
|
||||
$this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in
|
||||
$this->instance=new OC_Filestorage_Google($this->config['google']);
|
||||
public function setUp() {
|
||||
$id = uniqid();
|
||||
$this->config = include('files_external/tests/config.php');
|
||||
if (!is_array($this->config) or !isset($this->config['google']) or !$this->config['google']['run']) {
|
||||
$this->markTestSkipped('Google backend not configured');
|
||||
}
|
||||
$this->config['google']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||
$this->instance = new OC_Filestorage_Google($this->config['google']);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() {
|
||||
if ($this->instance) {
|
||||
$this->instance->rmdir('/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,23 +6,21 @@
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
$config=include('apps/files_external/tests/config.php');
|
||||
class Test_Filestorage_SMB extends Test_FileStorage {
|
||||
private $config;
|
||||
|
||||
if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']) {
|
||||
abstract class Test_Filestorage_SMB extends Test_FileStorage{}
|
||||
return;
|
||||
}else{
|
||||
class Test_Filestorage_SMB extends Test_FileStorage {
|
||||
private $config;
|
||||
|
||||
public function setUp() {
|
||||
$id=uniqid();
|
||||
$this->config=include('apps/files_external/tests/config.php');
|
||||
$this->config['smb']['root'].=$id;//make sure we have an new empty folder to work in
|
||||
$this->instance=new OC_Filestorage_SMB($this->config['smb']);
|
||||
public function setUp() {
|
||||
$id = uniqid();
|
||||
$this->config = include('files_external/tests/config.php');
|
||||
if (!is_array($this->config) or !isset($this->config['smb']) or !$this->config['smb']['run']) {
|
||||
$this->markTestSkipped('Samba backend not configured');
|
||||
}
|
||||
$this->config['smb']['root'] .= $id; //make sure we have an new empty folder to work in
|
||||
$this->instance = new OC_Filestorage_SMB($this->config['smb']);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() {
|
||||
if ($this->instance) {
|
||||
OCP\Files::rmdirr($this->instance->constructUrl(''));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,25 +6,23 @@
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
$config=include('apps/files_external/tests/config.php');
|
||||
if(!is_array($config) or !isset($config['swift']) or !$config['swift']['run']) {
|
||||
abstract class Test_Filestorage_SWIFT extends Test_FileStorage{}
|
||||
return;
|
||||
}else{
|
||||
class Test_Filestorage_SWIFT extends Test_FileStorage {
|
||||
private $config;
|
||||
class Test_Filestorage_SWIFT extends Test_FileStorage {
|
||||
private $config;
|
||||
|
||||
public function setUp() {
|
||||
$id=uniqid();
|
||||
$this->config=include('apps/files_external/tests/config.php');
|
||||
$this->config['swift']['root'].='/'.$id;//make sure we have an new empty folder to work in
|
||||
$this->instance=new OC_Filestorage_SWIFT($this->config['swift']);
|
||||
public function setUp() {
|
||||
$id = uniqid();
|
||||
$this->config = include('files_external/tests/config.php');
|
||||
if (!is_array($this->config) or !isset($this->config['swift']) or !$this->config['swift']['run']) {
|
||||
$this->markTestSkipped('OpenStack SWIFT backend not configured');
|
||||
}
|
||||
$this->config['swift']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||
$this->instance = new OC_Filestorage_SWIFT($this->config['swift']);
|
||||
}
|
||||
|
||||
|
||||
public function tearDown() {
|
||||
$this->instance->rmdir('');
|
||||
public function tearDown() {
|
||||
if ($this->instance) {
|
||||
$this->instance->rmdir('');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,22 +6,21 @@
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
$config=include('apps/files_external/tests/config.php');
|
||||
if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run']) {
|
||||
abstract class Test_Filestorage_DAV extends Test_FileStorage{}
|
||||
return;
|
||||
}else{
|
||||
class Test_Filestorage_DAV extends Test_FileStorage {
|
||||
private $config;
|
||||
class Test_Filestorage_DAV extends Test_FileStorage {
|
||||
private $config;
|
||||
|
||||
public function setUp() {
|
||||
$id=uniqid();
|
||||
$this->config=include('apps/files_external/tests/config.php');
|
||||
$this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in
|
||||
$this->instance=new OC_Filestorage_DAV($this->config['webdav']);
|
||||
public function setUp() {
|
||||
$id = uniqid();
|
||||
$this->config = include('files_external/tests/config.php');
|
||||
if (!is_array($this->config) or !isset($this->config['webdav']) or !$this->config['webdav']['run']) {
|
||||
$this->markTestSkipped('WebDAV backend not configured');
|
||||
}
|
||||
$this->config['webdav']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||
$this->instance = new OC_Filestorage_DAV($this->config['webdav']);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() {
|
||||
if ($this->instance) {
|
||||
$this->instance->rmdir('/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ if (version_compare($installedVersion, '0.3', '<')) {
|
||||
OC_Util::tearDownFS();
|
||||
}
|
||||
}
|
||||
OC_User::setUserId(null);
|
||||
if ($update_error) {
|
||||
OCP\Util::writeLog('files_sharing', 'There were some problems upgrading the sharing of files', OCP\Util::ERROR);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined') {
|
||||
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !publicListView) {
|
||||
OC.Share.loadIcons('file');
|
||||
FileActions.register('all', 'Share', OC.PERMISSION_READ, function(filename) {
|
||||
// Return the correct sharing icon
|
||||
@@ -46,7 +46,7 @@ $(document).ready(function() {
|
||||
var appendTo = $(tr).find('td.filename');
|
||||
// Check if drop down is already visible for a different file
|
||||
if (OC.Share.droppedDown) {
|
||||
if (item != $('#dropdown').data('item')) {
|
||||
if ($(tr).data('id') != $('#dropdown').attr('data-item-source')) {
|
||||
OC.Share.hideDropDown(function () {
|
||||
$(tr).addClass('mouseOver');
|
||||
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
|
||||
|
||||
@@ -25,11 +25,17 @@ if (isset($_GET['file']) || isset($_GET['dir'])) {
|
||||
if (isset($_GET['dir'])) {
|
||||
$type = 'folder';
|
||||
$path = $_GET['dir'];
|
||||
if(strlen($path)>1 and substr($path,-1,1)==='/') {
|
||||
$path=substr($path,0,-1);
|
||||
}
|
||||
$baseDir = $path;
|
||||
$dir = $baseDir;
|
||||
} else {
|
||||
$type = 'file';
|
||||
$path = $_GET['file'];
|
||||
if(strlen($path)>1 and substr($path,-1,1)==='/') {
|
||||
$path=substr($path,0,-1);
|
||||
}
|
||||
}
|
||||
$uidOwner = substr($path, 1, strpos($path, '/', 1) - 1);
|
||||
if (OCP\User::userExists($uidOwner)) {
|
||||
@@ -45,6 +51,11 @@ if (isset($_GET['file']) || isset($_GET['dir'])) {
|
||||
}
|
||||
if (isset($linkItem['share_with'])) {
|
||||
// Check password
|
||||
if (isset($_GET['file'])) {
|
||||
$url = OCP\Util::linkToPublic('files').'&file='.$_GET['file'];
|
||||
} else {
|
||||
$url = OCP\Util::linkToPublic('files').'&dir='.$_GET['dir'];
|
||||
}
|
||||
if (isset($_POST['password'])) {
|
||||
$password = $_POST['password'];
|
||||
$storedHash = $linkItem['share_with'];
|
||||
@@ -52,7 +63,7 @@ if (isset($_GET['file']) || isset($_GET['dir'])) {
|
||||
$hasher = new PasswordHash(8, $forcePortable);
|
||||
if (!($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash))) {
|
||||
$tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
|
||||
$tmpl->assign('URL', OCP\Util::linkToPublic('files').'&file='.$_GET['file']);
|
||||
$tmpl->assign('URL', $url);
|
||||
$tmpl->assign('error', true);
|
||||
$tmpl->printPage();
|
||||
exit();
|
||||
@@ -64,7 +75,7 @@ if (isset($_GET['file']) || isset($_GET['dir'])) {
|
||||
} else if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) {
|
||||
// Prompt for password
|
||||
$tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
|
||||
$tmpl->assign('URL', OCP\Util::linkToPublic('files').'&file='.$_GET['file']);
|
||||
$tmpl->assign('URL', $url);
|
||||
$tmpl->printPage();
|
||||
exit();
|
||||
}
|
||||
@@ -138,6 +149,7 @@ if (isset($_GET['file']) || isset($_GET['dir'])) {
|
||||
}
|
||||
$list = new OCP\Template('files', 'part.list', '');
|
||||
$list->assign('files', $files, false);
|
||||
$list->assign('publicListView', true);
|
||||
$list->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.$_GET['dir'].'&path=', false);
|
||||
$list->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.$_GET['dir'].'&path=', false);
|
||||
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '' );
|
||||
|
||||
@@ -21,11 +21,11 @@ $(document).ready(function(){
|
||||
}
|
||||
,function(filename){
|
||||
// Action to perform when clicked
|
||||
if (scanFiles.scanning || !$('#dropdown').hasClass('drop-versions')){return;}//workaround to prevent additional http request block scanning feedback
|
||||
if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback
|
||||
|
||||
var file = $('#dir').val()+'/'+filename;
|
||||
// Check if drop down is already visible for a different file
|
||||
if (($('#dropdown').length > 0)) {
|
||||
if (($('#dropdown').length > 0) && $('#dropdown').hasClass('drop-versions') ) {
|
||||
if (file != $('#dropdown').data('file')) {
|
||||
$('#dropdown').hide('blind', function() {
|
||||
$('#dropdown').remove();
|
||||
@@ -45,7 +45,7 @@ function createVersionsDropdown(filename, files) {
|
||||
|
||||
var historyUrl = OC.linkTo('files_versions', 'history.php') + '?path='+encodeURIComponent( $( '#dir' ).val() ).replace( /%2F/g, '/' )+'/'+encodeURIComponent( filename );
|
||||
|
||||
var html = '<div id="dropdown" class="drop drop-versions" data-file="'+files+'">';
|
||||
var html = '<div id="dropdown" class="drop drop-versions" data-file="'+escapeHTML(files)+'">';
|
||||
html += '<div id="private">';
|
||||
html += '<select data-placeholder="Saved versions" id="found_versions" class="chzen-select" style="width:16em;">';
|
||||
html += '<option value=""></option>';
|
||||
|
||||
@@ -64,7 +64,7 @@ class Hooks {
|
||||
$abs_newpath = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$params['newpath'].'.v';
|
||||
if(Storage::isversioned($rel_oldpath)) {
|
||||
$info=pathinfo($abs_newpath);
|
||||
if(!file_exists($info['dirname'])) mkdir($info['dirname'],0700,true);
|
||||
if(!file_exists($info['dirname'])) mkdir($info['dirname'],0750,true);
|
||||
$versions = Storage::getVersions($rel_oldpath);
|
||||
foreach ($versions as $v) {
|
||||
rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);
|
||||
|
||||
@@ -1,279 +1,280 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Frank Karlitschek <frank@owncloud.org>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Versions
|
||||
*
|
||||
* A class to handle the versioning of files.
|
||||
*/
|
||||
|
||||
namespace OCA_Versions;
|
||||
|
||||
class Storage {
|
||||
|
||||
|
||||
// config.php configuration:
|
||||
// - files_versions
|
||||
// - files_versionsfolder
|
||||
// - files_versionsblacklist
|
||||
// - files_versionsmaxfilesize
|
||||
// - files_versionsinterval
|
||||
// - files_versionmaxversions
|
||||
//
|
||||
// todo:
|
||||
// - finish porting to OC_FilesystemView to enable network transparency
|
||||
// - add transparent compression. first test if it´s worth it.
|
||||
|
||||
const DEFAULTENABLED=true;
|
||||
const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp';
|
||||
const DEFAULTMAXFILESIZE=1048576; // 10MB
|
||||
const DEFAULTMININTERVAL=60; // 1 min
|
||||
const DEFAULTMAXVERSIONS=50;
|
||||
|
||||
private static function getUidAndFilename($filename)
|
||||
{
|
||||
if (\OCP\App::isEnabled('files_sharing')
|
||||
&& substr($filename, 0, 7) == '/Shared'
|
||||
&& $source = \OCP\Share::getItemSharedWith('file',
|
||||
substr($filename, 7),
|
||||
\OC_Share_Backend_File::FORMAT_SHARED_STORAGE)) {
|
||||
$filename = $source['path'];
|
||||
$pos = strpos($filename, '/files', 1);
|
||||
$uid = substr($filename, 1, $pos - 1);
|
||||
$filename = substr($filename, $pos + 6);
|
||||
} else {
|
||||
$uid = \OCP\User::getUser();
|
||||
}
|
||||
return array($uid, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* store a new version of a file.
|
||||
*/
|
||||
public function store($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$files_view = new \OC_FilesystemView('/'.$uid.'/files');
|
||||
$users_view = new \OC_FilesystemView('/'.$uid);
|
||||
|
||||
//check if source file already exist as version to avoid recursions.
|
||||
// todo does this check work?
|
||||
if ($users_view->file_exists($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if filename is a directory
|
||||
if($files_view->is_dir($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check filetype blacklist
|
||||
$blacklist=explode(' ',\OCP\Config::getSystemValue('files_versionsblacklist', Storage::DEFAULTBLACKLIST));
|
||||
foreach($blacklist as $bl) {
|
||||
$parts=explode('.', $filename);
|
||||
$ext=end($parts);
|
||||
if(strtolower($ext)==$bl) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// we should have a source file to work with
|
||||
if (!$files_view->file_exists($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check filesize
|
||||
if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval)
|
||||
if ($uid == \OCP\User::getUser()) {
|
||||
$versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
$matches=glob($versionsFolderName.'/'.$filename.'.v*');
|
||||
sort($matches);
|
||||
$parts=explode('.v',end($matches));
|
||||
if((end($parts)+Storage::DEFAULTMININTERVAL)>time()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// create all parent folders
|
||||
$dirname = dirname($filename);
|
||||
if(!$users_view->file_exists('/files_versions/'.$dirname)) {
|
||||
$users_view->mkdir('/files_versions/'.$dirname,0700,true);
|
||||
}
|
||||
|
||||
// store a new version of a file
|
||||
$users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.time());
|
||||
|
||||
// expire old revisions if necessary
|
||||
Storage::expire($filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* rollback to an old version of a file.
|
||||
*/
|
||||
public static function rollback($filename,$revision) {
|
||||
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$users_view = new \OC_FilesystemView('/'.$uid);
|
||||
|
||||
// rollback
|
||||
if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
|
||||
|
||||
return true;
|
||||
|
||||
}else{
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* check if old versions of a file exist.
|
||||
*/
|
||||
public static function isversioned($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
|
||||
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
|
||||
// check for old versions
|
||||
$matches=glob($versionsFolderName.$filename.'.v*');
|
||||
if(count($matches)>0) {
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief get a list of all available versions of a file in descending chronological order
|
||||
* @param $filename file to find versions of, relative to the user files dir
|
||||
* @param $count number of versions to return
|
||||
* @returns array
|
||||
*/
|
||||
public static function getVersions( $filename, $count = 0 ) {
|
||||
|
||||
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
|
||||
|
||||
$versionsFolderName = \OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
$versions = array();
|
||||
|
||||
// fetch for old versions
|
||||
$matches = glob( $versionsFolderName.'/'.$filename.'.v*' );
|
||||
|
||||
sort( $matches );
|
||||
|
||||
$i = 0;
|
||||
|
||||
$files_view = new \OC_FilesystemView('/'.$uid.'/files');
|
||||
$local_file = $files_view->getLocalFile($filename);
|
||||
foreach( $matches as $ma ) {
|
||||
|
||||
$i++;
|
||||
$versions[$i]['cur'] = 0;
|
||||
$parts = explode( '.v', $ma );
|
||||
$versions[$i]['version'] = ( end( $parts ) );
|
||||
|
||||
// if file with modified date exists, flag it in array as currently enabled version
|
||||
( \md5_file( $ma ) == \md5_file( $local_file ) ? $versions[$i]['fileMatch'] = 1 : $versions[$i]['fileMatch'] = 0 );
|
||||
|
||||
}
|
||||
|
||||
$versions = array_reverse( $versions );
|
||||
|
||||
foreach( $versions as $key => $value ) {
|
||||
|
||||
// flag the first matched file in array (which will have latest modification date) as current version
|
||||
if ( $value['fileMatch'] ) {
|
||||
|
||||
$value['cur'] = 1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$versions = array_reverse( $versions );
|
||||
|
||||
// only show the newest commits
|
||||
if( $count != 0 and ( count( $versions )>$count ) ) {
|
||||
|
||||
$versions = array_slice( $versions, count( $versions ) - $count );
|
||||
|
||||
}
|
||||
|
||||
return( $versions );
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// if versioning isn't enabled then return an empty array
|
||||
return( array() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erase a file's versions which exceed the set quota
|
||||
*/
|
||||
public static function expire($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
|
||||
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
|
||||
// check for old versions
|
||||
$matches = glob( $versionsFolderName.'/'.$filename.'.v*' );
|
||||
|
||||
if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) {
|
||||
|
||||
$numberToDelete = count($matches) - \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS );
|
||||
|
||||
// delete old versions of a file
|
||||
$deleteItems = array_slice( $matches, 0, $numberToDelete );
|
||||
|
||||
foreach( $deleteItems as $de ) {
|
||||
|
||||
unlink( $versionsFolderName.'/'.$filename.'.v'.$de );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erase all old versions of all user files
|
||||
* @return true/false
|
||||
*/
|
||||
public function expireAll() {
|
||||
$view = \OCP\Files::getStorage('files_versions');
|
||||
return $view->deleteAll('', true);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Frank Karlitschek <frank@owncloud.org>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Versions
|
||||
*
|
||||
* A class to handle the versioning of files.
|
||||
*/
|
||||
|
||||
namespace OCA_Versions;
|
||||
|
||||
class Storage {
|
||||
|
||||
|
||||
// config.php configuration:
|
||||
// - files_versions
|
||||
// - files_versionsfolder
|
||||
// - files_versionsblacklist
|
||||
// - files_versionsmaxfilesize
|
||||
// - files_versionsinterval
|
||||
// - files_versionmaxversions
|
||||
//
|
||||
// todo:
|
||||
// - finish porting to OC_FilesystemView to enable network transparency
|
||||
// - add transparent compression. first test if it´s worth it.
|
||||
|
||||
const DEFAULTENABLED=true;
|
||||
const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp';
|
||||
const DEFAULTMAXFILESIZE=1048576; // 10MB
|
||||
const DEFAULTMININTERVAL=60; // 1 min
|
||||
const DEFAULTMAXVERSIONS=50;
|
||||
|
||||
private static function getUidAndFilename($filename)
|
||||
{
|
||||
if (\OCP\App::isEnabled('files_sharing')
|
||||
&& substr($filename, 0, 7) == '/Shared'
|
||||
&& $source = \OCP\Share::getItemSharedWith('file',
|
||||
substr($filename, 7),
|
||||
\OC_Share_Backend_File::FORMAT_SHARED_STORAGE)) {
|
||||
$filename = $source['path'];
|
||||
$pos = strpos($filename, '/files', 1);
|
||||
$uid = substr($filename, 1, $pos - 1);
|
||||
$filename = substr($filename, $pos + 6);
|
||||
} else {
|
||||
$uid = \OCP\User::getUser();
|
||||
}
|
||||
return array($uid, $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* store a new version of a file.
|
||||
*/
|
||||
public function store($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$userHome = \OC_User::getHome($uid);
|
||||
$files_view = new \OC_FilesystemView($userHome.'/files');
|
||||
$users_view = new \OC_FilesystemView($userHome);
|
||||
|
||||
//check if source file already exist as version to avoid recursions.
|
||||
// todo does this check work?
|
||||
if ($users_view->file_exists($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if filename is a directory
|
||||
if($files_view->is_dir($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check filetype blacklist
|
||||
$blacklist=explode(' ',\OCP\Config::getSystemValue('files_versionsblacklist', Storage::DEFAULTBLACKLIST));
|
||||
foreach($blacklist as $bl) {
|
||||
$parts=explode('.', $filename);
|
||||
$ext=end($parts);
|
||||
if(strtolower($ext)==$bl) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// we should have a source file to work with
|
||||
if (!$files_view->file_exists($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check filesize
|
||||
if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval)
|
||||
if ($uid == \OCP\User::getUser()) {
|
||||
$versions_fileview = new \OC_FilesystemView($userHome.'/files_versions');
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
$matches=glob($versionsFolderName.'/'.$filename.'.v*');
|
||||
sort($matches);
|
||||
$parts=explode('.v',end($matches));
|
||||
if((end($parts)+Storage::DEFAULTMININTERVAL)>time()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// create all parent folders
|
||||
$info=pathinfo($filename);
|
||||
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) {
|
||||
mkdir($versionsFolderName.'/'.$info['dirname'],0750,true);
|
||||
}
|
||||
|
||||
// store a new version of a file
|
||||
$users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.time());
|
||||
|
||||
// expire old revisions if necessary
|
||||
Storage::expire($filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* rollback to an old version of a file.
|
||||
*/
|
||||
public static function rollback($filename,$revision) {
|
||||
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$users_view = new \OC_FilesystemView(\OC_User::getHome($uid));
|
||||
|
||||
// rollback
|
||||
if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
|
||||
|
||||
return true;
|
||||
|
||||
}else{
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* check if old versions of a file exist.
|
||||
*/
|
||||
public static function isversioned($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$versions_fileview = new \OC_FilesystemView(\OC_User::getHome($uid).'/files_versions');
|
||||
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
|
||||
// check for old versions
|
||||
$matches=glob($versionsFolderName.$filename.'.v*');
|
||||
if(count($matches)>0) {
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief get a list of all available versions of a file in descending chronological order
|
||||
* @param $filename file to find versions of, relative to the user files dir
|
||||
* @param $count number of versions to return
|
||||
* @returns array
|
||||
*/
|
||||
public static function getVersions( $filename, $count = 0 ) {
|
||||
|
||||
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$versions_fileview = new \OC_FilesystemView(\OC_User::getHome($uid).'/files_versions');
|
||||
|
||||
$versionsFolderName = \OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
$versions = array();
|
||||
|
||||
// fetch for old versions
|
||||
$matches = glob( $versionsFolderName.'/'.$filename.'.v*' );
|
||||
|
||||
sort( $matches );
|
||||
|
||||
$i = 0;
|
||||
|
||||
$files_view = new \OC_FilesystemView(\OC_User::getHome($uid).'/files');
|
||||
$local_file = $files_view->getLocalFile($filename);
|
||||
foreach( $matches as $ma ) {
|
||||
|
||||
$i++;
|
||||
$versions[$i]['cur'] = 0;
|
||||
$parts = explode( '.v', $ma );
|
||||
$versions[$i]['version'] = ( end( $parts ) );
|
||||
|
||||
// if file with modified date exists, flag it in array as currently enabled version
|
||||
( \md5_file( $ma ) == \md5_file( $local_file ) ? $versions[$i]['fileMatch'] = 1 : $versions[$i]['fileMatch'] = 0 );
|
||||
|
||||
}
|
||||
|
||||
$versions = array_reverse( $versions );
|
||||
|
||||
foreach( $versions as $key => $value ) {
|
||||
|
||||
// flag the first matched file in array (which will have latest modification date) as current version
|
||||
if ( $value['fileMatch'] ) {
|
||||
|
||||
$value['cur'] = 1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$versions = array_reverse( $versions );
|
||||
|
||||
// only show the newest commits
|
||||
if( $count != 0 and ( count( $versions )>$count ) ) {
|
||||
|
||||
$versions = array_slice( $versions, count( $versions ) - $count );
|
||||
|
||||
}
|
||||
|
||||
return( $versions );
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// if versioning isn't enabled then return an empty array
|
||||
return( array() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erase a file's versions which exceed the set quota
|
||||
*/
|
||||
public static function expire($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
list($uid, $filename) = self::getUidAndFilename($filename);
|
||||
$versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
|
||||
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
|
||||
// check for old versions
|
||||
$matches = glob( $versionsFolderName.'/'.$filename.'.v*' );
|
||||
|
||||
if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) {
|
||||
|
||||
$numberToDelete = count($matches) - \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS );
|
||||
|
||||
// delete old versions of a file
|
||||
$deleteItems = array_slice( $matches, 0, $numberToDelete );
|
||||
|
||||
foreach( $deleteItems as $de ) {
|
||||
|
||||
unlink( $versionsFolderName.'/'.$filename.'.v'.$de );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erase all old versions of all user files
|
||||
* @return true/false
|
||||
*/
|
||||
public function expireAll() {
|
||||
$view = \OCP\Files::getStorage('files_versions');
|
||||
return $view->deleteAll('', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
</field>
|
||||
|
||||
<index>
|
||||
<name>ldap_group_members</name>
|
||||
<name>ldap_group_members_index</name>
|
||||
<unique>true</unique>
|
||||
<field>
|
||||
<name>owncloudname</name>
|
||||
|
||||
@@ -34,7 +34,7 @@ $groupBE = new \OCA\user_ldap\GROUP_LDAP();
|
||||
$groupBE->setConnector($connector);
|
||||
|
||||
foreach($objects as $object) {
|
||||
$fetchDNSql = 'SELECT `ldap_dn`, `owncloud_name` FROM `*PREFIX*ldap_'.$object.'_mapping` WHERE `directory_uuid` = ""';
|
||||
$fetchDNSql = 'SELECT `ldap_dn`, `owncloud_name` FROM `*PREFIX*ldap_'.$object.'_mapping` WHERE `directory_uuid` = \'\'';
|
||||
$updateSql = 'UPDATE `*PREFIX*ldap_'.$object.'_mapping` SET `ldap_DN` = ?, `directory_uuid` = ? WHERE `ldap_dn` = ?';
|
||||
|
||||
$query = OCP\DB::prepare($fetchDNSql);
|
||||
|
||||
@@ -96,12 +96,13 @@ class GROUP_LDAP extends lib\Access implements \OCP\GroupInterface {
|
||||
if(!$this->enabled) {
|
||||
return array();
|
||||
}
|
||||
if($this->connection->isCached('getUserGroups'.$uid)) {
|
||||
return $this->connection->getFromCache('getUserGroups'.$uid);
|
||||
$cacheKey = 'getUserGroups'.$uid;
|
||||
if($this->connection->isCached($cacheKey)) {
|
||||
return $this->connection->getFromCache($cacheKey);
|
||||
}
|
||||
$userDN = $this->username2dn($uid);
|
||||
if(!$userDN) {
|
||||
$this->connection->writeToCache('getUserGroups'.$uid, array());
|
||||
$this->connection->writeToCache($cacheKey, array());
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ class GROUP_LDAP extends lib\Access implements \OCP\GroupInterface {
|
||||
));
|
||||
$groups = $this->fetchListOfGroups($filter, array($this->connection->ldapGroupDisplayName,'dn'));
|
||||
$groups = array_unique($this->ownCloudGroupNames($groups), SORT_LOCALE_STRING);
|
||||
$this->connection->writeToCache('getUserGroups'.$uid, $groups);
|
||||
$this->connection->writeToCache($cacheKey, $groups);
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,8 @@ abstract class Access {
|
||||
$ownCloudNames = array();
|
||||
|
||||
foreach($ldapObjects as $ldapObject) {
|
||||
$ocname = $this->dn2ocname($ldapObject['dn'], $ldapObject[$nameAttribute], $isUsers);
|
||||
$nameByLDAP = isset($ldapObject[$nameAttribute]) ? $ldapObject[$nameAttribute] : null;
|
||||
$ocname = $this->dn2ocname($ldapObject['dn'], $nameByLDAP, $isUsers);
|
||||
if($ocname) {
|
||||
$ownCloudNames[] = $ocname;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,13 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
|
||||
|
||||
private function updateQuota($dn) {
|
||||
$quota = null;
|
||||
if(!empty($this->connection->ldapQuotaDefault)) {
|
||||
$quota = $this->connection->ldapQuotaDefault;
|
||||
$quotaDefault = $this->connection->ldapQuotaDefault;
|
||||
$quotaAttribute = $this->connection->ldapQuotaAttribute;
|
||||
if(!empty($quotaDefault)) {
|
||||
$quota = $quotaDefault;
|
||||
}
|
||||
if(!empty($this->connection->ldapQuotaAttribute)) {
|
||||
$aQuota = $this->readAttribute($dn, $this->connection->ldapQuotaAttribute);
|
||||
if(!empty($quotaAttribute)) {
|
||||
$aQuota = $this->readAttribute($dn, $quotaAttribute);
|
||||
|
||||
if($aQuota && (count($aQuota) > 0)) {
|
||||
$quota = $aQuota[0];
|
||||
@@ -46,8 +48,9 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
|
||||
|
||||
private function updateEmail($dn) {
|
||||
$email = null;
|
||||
if(!empty($this->connection->ldapEmailAttribute)) {
|
||||
$aEmail = $this->readAttribute($dn, $this->connection->ldapEmailAttribute);
|
||||
$emailAttribute = $this->connection->ldapEmailAttribute;
|
||||
if(!empty($emailAttribute)) {
|
||||
$aEmail = $this->readAttribute($dn, $emailAttribute);
|
||||
if($aEmail && (count($aEmail) > 0)) {
|
||||
$email = $aEmail[0];
|
||||
}
|
||||
|
||||
@@ -30,6 +30,15 @@ function t(app,text){
|
||||
}
|
||||
t.cache={};
|
||||
|
||||
/*
|
||||
* Sanitizes a HTML string
|
||||
* @param string
|
||||
* @return Sanitized string
|
||||
*/
|
||||
function escapeHTML(s) {
|
||||
return s.toString().split('&').join('&').split('<').join('<').split('"').join('"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to download a file
|
||||
* @param file The filename
|
||||
|
||||
+1
-1
@@ -313,7 +313,7 @@ OC.Share={
|
||||
var file = $('#dir').val() + '/' + filename;
|
||||
}
|
||||
file = '/'+OC.currentUser+'/files'+file;
|
||||
var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+file;
|
||||
var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file);
|
||||
$('#linkText').val(link);
|
||||
$('#linkText').show('blind');
|
||||
$('#showPassword').show();
|
||||
|
||||
@@ -13,8 +13,8 @@ require_once '../../lib/base.php';
|
||||
// Someone lost their password:
|
||||
if (isset($_POST['user'])) {
|
||||
if (OC_User::userExists($_POST['user'])) {
|
||||
$token = hash("sha256", $_POST['user'].OC_Util::generate_random_bytes(10));
|
||||
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token);
|
||||
$token = hash("sha256", OC_Util::generate_random_bytes(30).OC_Config::getValue('passwordsalt', ''));
|
||||
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash("sha256", $token)); // Hash the token again to prevent timing attacks
|
||||
$email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
|
||||
if (!empty($email)) {
|
||||
$link = OC_Helper::linkToAbsolute('core/lostpassword', 'resetpassword.php', array('user' => $_POST['user'], 'token' => $token));
|
||||
|
||||
@@ -10,7 +10,7 @@ $RUNTIME_NOAPPS = TRUE; //no apps
|
||||
require_once '../../lib/base.php';
|
||||
|
||||
// Someone wants to reset their password:
|
||||
if(isset($_GET['token']) && isset($_GET['user']) && OC_Preferences::getValue($_GET['user'], 'owncloud', 'lostpassword') === $_GET['token']) {
|
||||
if(isset($_GET['token']) && isset($_GET['user']) && OC_Preferences::getValue($_GET['user'], 'owncloud', 'lostpassword') === hash("sha256", $_GET['token'])) {
|
||||
if (isset($_POST['password'])) {
|
||||
if (OC_User::setPassword($_GET['user'], $_POST['password'])) {
|
||||
OC_Preferences::deleteKey($_GET['user'], 'owncloud', 'lostpassword');
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
<input type='hidden' id='hasPostgreSQL' value='<?php echo $_['hasPostgreSQL'] ?>'></input>
|
||||
<input type='hidden' id='hasOracle' value='<?php echo $_['hasOracle'] ?>'></input>
|
||||
<form action="index.php" method="post">
|
||||
|
||||
<input type="hidden" name="install" value="true" />
|
||||
<?php if(count($_['errors']) > 0): ?>
|
||||
<ul class="errors">
|
||||
@@ -19,7 +18,20 @@
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(!$_['secureRNG']): ?>
|
||||
<fieldset style="color: #B94A48; background-color: #F2DEDE; border-color: #EED3D7;">
|
||||
<legend><strong><?php echo $l->t('Security Warning');?></strong></legend>
|
||||
<span><?php echo $l->t('No secure random number generator is available, please enable the PHP OpenSSL extension.');?></span>
|
||||
<br/>
|
||||
<span><?php echo $l->t('Without a secure random number generator an attacker may be able to predict password reset tokens and take over your account.');?></span>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
<?php if(!$_['htaccessWorking']): ?>
|
||||
<fieldset style="color: #B94A48; background-color: #F2DEDE; border-color: #EED3D7;">
|
||||
<legend><strong><?php echo $l->t('Security Warning');?></strong></legend>
|
||||
<span><?php echo $l->t('Your data directory and your files are probably accessible from the internet. The .htaccess file that ownCloud provides is not working. We strongly suggest that you configure your webserver in a way that the data directory is no longer accessible or you move the data directory outside the webserver document root.');?></span>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
<fieldset>
|
||||
<legend><?php echo $l->t( 'Create an <strong>admin account</strong>' ); ?></legend>
|
||||
<p class="infield">
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once 'Archive/Tar.php';
|
||||
require_once '3rdparty/Archive/Tar.php';
|
||||
|
||||
class OC_Archive_TAR extends OC_Archive{
|
||||
const PLAIN=0;
|
||||
|
||||
+2
-1
@@ -193,6 +193,7 @@ class OC{
|
||||
public static function checkSSL() {
|
||||
// redirect to https site if configured
|
||||
if( OC_Config::getValue( "forcessl", false )) {
|
||||
header('Strict-Transport-Security: max-age=31536000');
|
||||
ini_set("session.cookie_secure", "on");
|
||||
if(OC_Request::serverProtocol()<>'https' and !OC::$CLI) {
|
||||
$url = "https://". OC_Request::serverHost() . $_SERVER['REQUEST_URI'];
|
||||
@@ -281,7 +282,7 @@ class OC{
|
||||
ini_set('arg_separator.output', '&');
|
||||
|
||||
// try to switch magic quotes off.
|
||||
if(function_exists('set_magic_quotes_runtime')) {
|
||||
if(get_magic_quotes_gpc()) {
|
||||
@set_magic_quotes_runtime(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic {
|
||||
} else {
|
||||
OC_Util::setUpFS();//login hooks may need early access to the filesystem
|
||||
if(OC_User::login($username, $password)) {
|
||||
OC_Util::setUpFS($username);
|
||||
OC_Util::setUpFS(OC_User::getUser());
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
|
||||
+3
-2
@@ -79,7 +79,7 @@ class OC_FileCache{
|
||||
|
||||
// add parent directory to the file cache if it does not exist yet.
|
||||
if ($parent == -1 && $fullpath != $root) {
|
||||
$parentDir = substr(dirname($path), 0, strrpos(dirname($path), DIRECTORY_SEPARATOR));
|
||||
$parentDir = dirname($path);
|
||||
self::scanFile($parentDir);
|
||||
$parent = self::getParentId($fullpath);
|
||||
}
|
||||
@@ -203,7 +203,7 @@ class OC_FileCache{
|
||||
|
||||
OC_Cache::remove('fileid/'.$root.$path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return array of filenames matching the querty
|
||||
* @param string $query
|
||||
@@ -509,3 +509,4 @@ class OC_FileCache{
|
||||
OC_Hook::connect('OC_Filesystem','post_write','OC_FileCache_Update','fileSystemWatcherWrite');
|
||||
OC_Hook::connect('OC_Filesystem','post_delete','OC_FileCache_Update','fileSystemWatcherDelete');
|
||||
OC_Hook::connect('OC_Filesystem','post_rename','OC_FileCache_Update','fileSystemWatcherRename');
|
||||
OC_Hook::connect('OC_User','post_deleteUser','OC_FileCache_Update','deleteFromUser');
|
||||
|
||||
@@ -174,7 +174,9 @@ class OC_FileCache_Update{
|
||||
}else{
|
||||
$size=OC_FileCache::scanFile($path, $root);
|
||||
}
|
||||
OC_FileCache::increaseSize(dirname($path), $size-$cachedSize, $root);
|
||||
if($path !== '' and $path !== '/'){
|
||||
OC_FileCache::increaseSize(dirname($path), $size-$cachedSize, $root);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,4 +216,12 @@ class OC_FileCache_Update{
|
||||
OC_FileCache::increaseSize(dirname($newPath), $oldSize, $root);
|
||||
OC_FileCache::move($oldPath, $newPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete files owned by user from the cache
|
||||
* @param string $parameters$parameters["uid"])
|
||||
*/
|
||||
public static function deleteFromUser($parameters) {
|
||||
OC_FileCache::clear($parameters["uid"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Bjoern Schiessle
|
||||
* @copyright 2012 Bjoern Schiessle <schiessle@owncloud.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* check if standard file operations
|
||||
*/
|
||||
|
||||
class OC_FileProxy_FileOperations extends OC_FileProxy{
|
||||
static $rootView;
|
||||
|
||||
public function premkdir($path) {
|
||||
if(!self::$rootView){
|
||||
self::$rootView = new OC_FilesystemView('');
|
||||
}
|
||||
return !self::$rootView->file_exists($path);
|
||||
}
|
||||
|
||||
}
|
||||
+71
-46
@@ -46,6 +46,7 @@
|
||||
class OC_Filesystem{
|
||||
static private $storages=array();
|
||||
static private $mounts=array();
|
||||
static private $loadedUsers=array();
|
||||
public static $loaded=false;
|
||||
/**
|
||||
* @var OC_Filestorage $defaultInstance
|
||||
@@ -178,12 +179,25 @@ class OC_Filesystem{
|
||||
$internalPath=substr($path,strlen($mountPoint));
|
||||
return $internalPath;
|
||||
}
|
||||
|
||||
static private function mountPointsLoaded($user) {
|
||||
return in_array($user, self::$loadedUsers);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the storage object for a path
|
||||
* @param string path
|
||||
* @return OC_Filestorage
|
||||
*/
|
||||
static public function getStorage($path) {
|
||||
$user = ltrim(substr($path, 0, strpos($path, '/', 1)), '/');
|
||||
// check mount points if file was shared from a different user
|
||||
if ($user != OC_User::getUser() && !self::mountPointsLoaded($user)) {
|
||||
OC_Util::loadUserMountPoints($user);
|
||||
self::loadSystemMountPoints($user);
|
||||
self::$loadedUsers[] = $user;
|
||||
}
|
||||
|
||||
$mountpoint=self::getMountPoint($path);
|
||||
if($mountpoint) {
|
||||
if(!isset(OC_Filesystem::$storages[$mountpoint])) {
|
||||
@@ -194,56 +208,63 @@ class OC_Filesystem{
|
||||
}
|
||||
}
|
||||
|
||||
static public function init($root) {
|
||||
static private function loadSystemMountPoints($user) {
|
||||
if(is_file(OC::$SERVERROOT.'/config/mount.php')) {
|
||||
$mountConfig=include(OC::$SERVERROOT.'/config/mount.php');
|
||||
if(isset($mountConfig['global'])) {
|
||||
foreach($mountConfig['global'] as $mountPoint=>$options) {
|
||||
self::mount($options['class'],$options['options'],$mountPoint);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($mountConfig['group'])) {
|
||||
foreach($mountConfig['group'] as $group=>$mounts) {
|
||||
if(OC_Group::inGroup($user,$group)) {
|
||||
foreach($mounts as $mountPoint=>$options) {
|
||||
$mountPoint=self::setUserVars($mountPoint, $user);
|
||||
foreach($options as &$option) {
|
||||
$option=self::setUserVars($option, $user);
|
||||
}
|
||||
self::mount($options['class'],$options['options'],$mountPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($mountConfig['user'])) {
|
||||
foreach($mountConfig['user'] as $user=>$mounts) {
|
||||
if($user==='all' or strtolower($user)===strtolower($user)) {
|
||||
foreach($mounts as $mountPoint=>$options) {
|
||||
$mountPoint=self::setUserVars($mountPoint, $user);
|
||||
foreach($options as &$option) {
|
||||
$option=self::setUserVars($option, $user);
|
||||
}
|
||||
self::mount($options['class'],$options['options'],$mountPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mtime=filemtime(OC::$SERVERROOT.'/config/mount.php');
|
||||
$previousMTime=OC_Appconfig::getValue('files','mountconfigmtime',0);
|
||||
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
|
||||
OC_FileCache::triggerUpdate();
|
||||
OC_Appconfig::setValue('files','mountconfigmtime',$mtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public function init($root, $user = '') {
|
||||
if(self::$defaultInstance) {
|
||||
return false;
|
||||
}
|
||||
self::$defaultInstance=new OC_FilesystemView($root);
|
||||
|
||||
//load custom mount config
|
||||
if(is_file(OC::$SERVERROOT.'/config/mount.php')) {
|
||||
$mountConfig=include(OC::$SERVERROOT.'/config/mount.php');
|
||||
if(isset($mountConfig['global'])) {
|
||||
foreach($mountConfig['global'] as $mountPoint=>$options) {
|
||||
self::mount($options['class'],$options['options'],$mountPoint);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($mountConfig['group'])) {
|
||||
foreach($mountConfig['group'] as $group=>$mounts) {
|
||||
if(OC_Group::inGroup(OC_User::getUser(),$group)) {
|
||||
foreach($mounts as $mountPoint=>$options) {
|
||||
$mountPoint=self::setUserVars($mountPoint);
|
||||
foreach($options as &$option) {
|
||||
$option=self::setUserVars($option);
|
||||
}
|
||||
self::mount($options['class'],$options['options'],$mountPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($mountConfig['user'])) {
|
||||
foreach($mountConfig['user'] as $user=>$mounts) {
|
||||
if($user==='all' or strtolower($user)===strtolower(OC_User::getUser())) {
|
||||
foreach($mounts as $mountPoint=>$options) {
|
||||
$mountPoint=self::setUserVars($mountPoint);
|
||||
foreach($options as &$option) {
|
||||
$option=self::setUserVars($option);
|
||||
}
|
||||
self::mount($options['class'],$options['options'],$mountPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mtime=filemtime(OC::$SERVERROOT.'/config/mount.php');
|
||||
$previousMTime=OC_Appconfig::getValue('files','mountconfigmtime',0);
|
||||
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
|
||||
OC_FileCache::triggerUpdate();
|
||||
OC_Appconfig::setValue('files','mountconfigmtime',$mtime);
|
||||
}
|
||||
if (!isset($user)) {
|
||||
$user = OC_User::getUser();
|
||||
}
|
||||
self::loadSystemMountPoints($user);
|
||||
|
||||
self::$loaded=true;
|
||||
}
|
||||
@@ -253,8 +274,12 @@ class OC_Filesystem{
|
||||
* @param string intput
|
||||
* @return string
|
||||
*/
|
||||
private static function setUserVars($input) {
|
||||
return str_replace('$user',OC_User::getUser(),$input);
|
||||
private static function setUserVars($input, $user) {
|
||||
if (isset($user)) {
|
||||
return str_replace('$user', $user,$input);
|
||||
} else {
|
||||
return str_replace('$user',OC_User::getUser(),$input);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -531,7 +556,7 @@ class OC_Filesystem{
|
||||
if ($root) { // reduce path to the required part of it (no 'username/files')
|
||||
$fakeRootView = new OC_FilesystemView($root);
|
||||
$count = 1;
|
||||
$path=str_replace(OC_App::getStorage("files")->getAbsolutePath($path), "", $fakeRootView->getAbsolutePath($path), $count);
|
||||
$path=str_replace(OC_App::getStorage("files")->getAbsolutePath(), "", $fakeRootView->getAbsolutePath($path), $count);
|
||||
}
|
||||
|
||||
$path = self::normalizePath($path);
|
||||
|
||||
@@ -251,6 +251,9 @@ class OC_FilesystemView {
|
||||
return $this->basicOperation('filemtime', $path);
|
||||
}
|
||||
public function touch($path, $mtime=null) {
|
||||
if(!is_null($mtime) and !is_numeric($mtime)){
|
||||
$mtime = strtotime($mtime);
|
||||
}
|
||||
return $this->basicOperation('touch', $path, array('write'), $mtime);
|
||||
}
|
||||
public function file_get_contents($path) {
|
||||
|
||||
+12
-1
@@ -100,6 +100,17 @@ class OC_Helper {
|
||||
return OC_Request::serverProtocol(). '://' . OC_Request::serverHost() . $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates an url for remote use
|
||||
* @param string $service id
|
||||
* @return string the url
|
||||
*
|
||||
* Returns a url to the given service.
|
||||
*/
|
||||
public static function linkToRemoteBase( $service ) {
|
||||
return self::linkTo( '', 'remote.php') . '/' . $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates an absolute url for remote use
|
||||
* @param string $service id
|
||||
@@ -108,7 +119,7 @@ class OC_Helper {
|
||||
* Returns a absolute url to the given service.
|
||||
*/
|
||||
public static function linkToRemote( $service, $add_slash = true ) {
|
||||
return self::linkToAbsolute( '', 'remote.php') . '/' . $service . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
|
||||
return self::makeURLAbsolute(self::linkToRemoteBase($service)) . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -94,4 +94,5 @@ return array(
|
||||
'sgf' => 'application/sgf',
|
||||
'cdr' => 'application/coreldraw',
|
||||
'impress' => 'text/impress',
|
||||
'ai' => 'application/illustrator',
|
||||
);
|
||||
|
||||
@@ -326,6 +326,22 @@ class Share {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Unshare an item from all users, groups, and remove all links
|
||||
* @param string Item type
|
||||
* @param string Item source
|
||||
* @return Returns true on success or false on failure
|
||||
*/
|
||||
public static function unshareAll($itemType, $itemSource) {
|
||||
if ($shares = self::getItemShared($itemType, $itemSource)) {
|
||||
foreach ($shares as $share) {
|
||||
self::delete($share['id']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Unshare an item shared with the current user
|
||||
* @param string Item type
|
||||
|
||||
@@ -5,12 +5,19 @@ $hasMySQL = is_callable('mysql_connect');
|
||||
$hasPostgreSQL = is_callable('pg_connect');
|
||||
$hasOracle = is_callable('oci_connect');
|
||||
$datadir = OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data');
|
||||
|
||||
// Test if .htaccess is working
|
||||
$content = "deny from all";
|
||||
file_put_contents(OC::$SERVERROOT.'/data/.htaccess', $content);
|
||||
|
||||
$opts = array(
|
||||
'hasSQLite' => $hasSQLite,
|
||||
'hasMySQL' => $hasMySQL,
|
||||
'hasPostgreSQL' => $hasPostgreSQL,
|
||||
'hasOracle' => $hasOracle,
|
||||
'directory' => $datadir,
|
||||
'secureRNG' => OC_Util::secureRNG_available(),
|
||||
'htaccessWorking' => OC_Util::ishtaccessworking(),
|
||||
'errors' => array(),
|
||||
);
|
||||
|
||||
|
||||
+5
-3
@@ -159,9 +159,11 @@ class OC_Template{
|
||||
$this->vars['requestlifespan'] = OC_Util::$callLifespan;
|
||||
$parts = explode('/', $app); // fix translation when app is something like core/lostpassword
|
||||
$this->l10n = OC_L10N::get($parts[0]);
|
||||
header('X-Frame-Options: Sameorigin');
|
||||
header('X-XSS-Protection: 1; mode=block');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
|
||||
// Some headers to enhance security
|
||||
header('X-Frame-Options: Sameorigin');
|
||||
header('X-XSS-Protection: 1; mode=block');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
|
||||
$this->findTemplate($name);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class OC_TemplateLayout extends OC_Template {
|
||||
$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
|
||||
$this->assign('jsfiles', array(), false);
|
||||
if (!empty(OC_Util::$core_scripts)) {
|
||||
$this->append( 'jsfiles', OC_Helper::linkToRemote('core.js', false));
|
||||
$this->append( 'jsfiles', OC_Helper::linkToRemoteBase('core.js', false));
|
||||
}
|
||||
foreach($jsfiles as $info) {
|
||||
$root = $info[0];
|
||||
@@ -63,7 +63,7 @@ class OC_TemplateLayout extends OC_Template {
|
||||
$cssfiles = self::findStylesheetFiles(OC_Util::$styles);
|
||||
$this->assign('cssfiles', array());
|
||||
if (!empty(OC_Util::$core_styles)) {
|
||||
$this->append( 'cssfiles', OC_Helper::linkToRemote('core.css', false));
|
||||
$this->append( 'cssfiles', OC_Helper::linkToRemoteBase('core.css', false));
|
||||
}
|
||||
foreach($cssfiles as $info) {
|
||||
$root = $info[0];
|
||||
|
||||
+5
-1
@@ -210,6 +210,10 @@ class OC_User {
|
||||
}
|
||||
// Delete the user's keys in preferences
|
||||
OC_Preferences::deleteUser($uid);
|
||||
|
||||
// Delete user files in /data/
|
||||
OC_Helper::rmdirr(OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/'.$uid.'/');
|
||||
|
||||
// Emit and exit
|
||||
OC_Hook::emit( "OC_User", "post_deleteUser", array( "uid" => $uid ));
|
||||
return true;
|
||||
@@ -473,7 +477,7 @@ class OC_User {
|
||||
public static function setMagicInCookie($username, $token) {
|
||||
$secure_cookie = OC_Config::getValue("forcessl", false);
|
||||
setcookie("oc_username", $username, time()+60*60*24*15, '', '', $secure_cookie);
|
||||
setcookie("oc_token", $token, time()+60*60*24*15, '', '', $secure_cookie);
|
||||
setcookie("oc_token", $token, time()+60*60*24*15, '', '', $secure_cookie, true);
|
||||
setcookie("oc_remember_login", true, time()+60*60*24*15, '', '', $secure_cookie);
|
||||
}
|
||||
|
||||
|
||||
+65
-24
@@ -47,25 +47,13 @@ class OC_Util {
|
||||
}
|
||||
//jail the user into his "home" directory
|
||||
OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $user_root), $user);
|
||||
OC_Filesystem::init($user_dir);
|
||||
OC_Filesystem::init($user_dir, $user);
|
||||
$quotaProxy=new OC_FileProxy_Quota();
|
||||
$fileOperationProxy = new OC_FileProxy_FileOperations();
|
||||
OC_FileProxy::register($quotaProxy);
|
||||
OC_FileProxy::register($fileOperationProxy);
|
||||
// Load personal mount config
|
||||
if (is_file($user_root.'/mount.php')) {
|
||||
$mountConfig = include($user_root.'/mount.php');
|
||||
if (isset($mountConfig['user'][$user])) {
|
||||
foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
|
||||
OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
|
||||
}
|
||||
}
|
||||
|
||||
$mtime=filemtime($user_root.'/mount.php');
|
||||
$previousMTime=OC_Preferences::getValue($user,'files','mountconfigmtime',0);
|
||||
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
|
||||
OC_FileCache::triggerUpdate($user);
|
||||
OC_Preferences::setValue($user,'files','mountconfigmtime',$mtime);
|
||||
}
|
||||
}
|
||||
self::loadUserMountPoints($user);
|
||||
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
|
||||
}
|
||||
}
|
||||
@@ -74,6 +62,27 @@ class OC_Util {
|
||||
OC_Filesystem::tearDown();
|
||||
self::$fsSetup=false;
|
||||
}
|
||||
|
||||
public static function loadUserMountPoints($user) {
|
||||
$user_dir = '/'.$user.'/files';
|
||||
$user_root = OC_User::getHome($user);
|
||||
$userdirectory = $user_root . '/files';
|
||||
if (is_file($user_root.'/mount.php')) {
|
||||
$mountConfig = include($user_root.'/mount.php');
|
||||
if (isset($mountConfig['user'][$user])) {
|
||||
foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
|
||||
OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
|
||||
}
|
||||
}
|
||||
|
||||
$mtime=filemtime($user_root.'/mount.php');
|
||||
$previousMTime=OC_Preferences::getValue($user,'files','mountconfigmtime',0);
|
||||
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
|
||||
OC_FileCache::triggerUpdate($user);
|
||||
OC_Preferences::setValue($user,'files','mountconfigmtime',$mtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the current installed version of ownCloud
|
||||
@@ -81,7 +90,7 @@ class OC_Util {
|
||||
*/
|
||||
public static function getVersion() {
|
||||
// hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4.90.0. This is not visible to the user
|
||||
return array(4,90,00);
|
||||
return array(4,90,1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +98,7 @@ class OC_Util {
|
||||
* @return string
|
||||
*/
|
||||
public static function getVersionString() {
|
||||
return '4.5';
|
||||
return '4.5.1';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -554,12 +563,14 @@ class OC_Util {
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Generates random bytes with "openssl_random_pseudo_bytes" with a fallback for systems without openssl
|
||||
* Inspired by gorgo on php.net
|
||||
* @param Int with the length of the random
|
||||
* @return String with the random bytes
|
||||
* @brief Generates a cryptographical secure pseudorandom string
|
||||
* @param Int with the length of the random string
|
||||
* @return String
|
||||
* Please also update secureRNG_available if you change something here
|
||||
*/
|
||||
public static function generate_random_bytes($length = 30) {
|
||||
|
||||
// Try to use openssl_random_pseudo_bytes
|
||||
if(function_exists('openssl_random_pseudo_bytes')) {
|
||||
$pseudo_byte = bin2hex(openssl_random_pseudo_bytes($length, $strong));
|
||||
if($strong == TRUE) {
|
||||
@@ -567,9 +578,16 @@ class OC_Util {
|
||||
}
|
||||
}
|
||||
|
||||
// fallback to mt_rand()
|
||||
// Try to use /dev/urandom
|
||||
$fp = @file_get_contents('/dev/urandom', false, null, 0, $length);
|
||||
if ($fp !== FALSE) {
|
||||
$string = substr(bin2hex($fp), 0, $length);
|
||||
return $string;
|
||||
}
|
||||
|
||||
// Fallback to mt_rand()
|
||||
$characters = '0123456789';
|
||||
$characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
$characters .= 'abcdefghijklmnopqrstuvwxyz';
|
||||
$charactersLength = strlen($characters)-1;
|
||||
$pseudo_byte = "";
|
||||
|
||||
@@ -579,4 +597,27 @@ class OC_Util {
|
||||
}
|
||||
return $pseudo_byte;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Checks if a secure random number generator is available
|
||||
* @return bool
|
||||
*/
|
||||
public static function secureRNG_available() {
|
||||
|
||||
// Check openssl_random_pseudo_bytes
|
||||
if(function_exists('openssl_random_pseudo_bytes')) {
|
||||
openssl_random_pseudo_bytes(1, $strong);
|
||||
if($strong == TRUE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check /dev/urandom
|
||||
$fp = @file_get_contents('/dev/urandom', false, null, 0, 1);
|
||||
if ($fp !== FALSE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ OCP\JSON::callCheck();
|
||||
|
||||
$username = $_POST["username"];
|
||||
|
||||
// A user shouldn't be able to delete his own account
|
||||
if(OC_User::getUser() === $username) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
|
||||
$l = OC_L10N::get('core');
|
||||
OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
|
||||
@@ -20,4 +25,4 @@ if( OC_User::deleteUser( $username )) {
|
||||
}
|
||||
else{
|
||||
OC_JSON::error(array("data" => array( "message" => $l->t("Unable to delete user") )));
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,7 @@ OC_App::setActiveNavigationEntry( 'personal' );
|
||||
// calculate the disc space
|
||||
$rootInfo=OC_FileCache::get('');
|
||||
$sharedInfo=OC_FileCache::get('/Shared');
|
||||
if (!isset($sharedInfo['size'])) {
|
||||
$sharedSize = 0;
|
||||
} else {
|
||||
$sharedSize = $sharedInfo['size'];
|
||||
}
|
||||
$used=$rootInfo['size']-$sharedSize;
|
||||
$used=$rootInfo['size'];
|
||||
if($used<0) $used=0;
|
||||
$free=OC_Filesystem::free_space();
|
||||
$total=$free+$used;
|
||||
|
||||
+162
-152
@@ -1,24 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Robin Appelman
|
||||
* @copyright 2012 Robin Appelman icewind@owncloud.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
* ownCloud
|
||||
*
|
||||
* @author Robin Appelman
|
||||
* @copyright 2012 Robin Appelman icewind@owncloud.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class Test_FileStorage extends UnitTestCase {
|
||||
/**
|
||||
@@ -30,195 +30,205 @@ abstract class Test_FileStorage extends UnitTestCase {
|
||||
* the root folder of the storage should always exist, be readable and be recognized as a directory
|
||||
*/
|
||||
public function testRoot() {
|
||||
$this->assertTrue($this->instance->file_exists('/'),'Root folder does not exist');
|
||||
$this->assertTrue($this->instance->isReadable('/'),'Root folder is not readable');
|
||||
$this->assertTrue($this->instance->is_dir('/'),'Root folder is not a directory');
|
||||
$this->assertFalse($this->instance->is_file('/'),'Root folder is a file');
|
||||
$this->assertEqual('dir',$this->instance->filetype('/'));
|
||||
|
||||
$this->assertTrue($this->instance->file_exists('/'), 'Root folder does not exist');
|
||||
$this->assertTrue($this->instance->isReadable('/'), 'Root folder is not readable');
|
||||
$this->assertTrue($this->instance->is_dir('/'), 'Root folder is not a directory');
|
||||
$this->assertFalse($this->instance->is_file('/'), 'Root folder is a file');
|
||||
$this->assertEqual('dir', $this->instance->filetype('/'));
|
||||
|
||||
//without this, any further testing would be useless, not an acutal requirement for filestorage though
|
||||
$this->assertTrue($this->instance->isUpdatable('/'),'Root folder is not writable');
|
||||
$this->assertTrue($this->instance->isUpdatable('/'), 'Root folder is not writable');
|
||||
}
|
||||
|
||||
|
||||
public function testDirectories() {
|
||||
$this->assertFalse($this->instance->file_exists('/folder'));
|
||||
|
||||
|
||||
$this->assertTrue($this->instance->mkdir('/folder'));
|
||||
|
||||
|
||||
$this->assertTrue($this->instance->file_exists('/folder'));
|
||||
$this->assertTrue($this->instance->is_dir('/folder'));
|
||||
$this->assertFalse($this->instance->is_file('/folder'));
|
||||
$this->assertEqual('dir',$this->instance->filetype('/folder'));
|
||||
$this->assertEqual(0,$this->instance->filesize('/folder'));
|
||||
$this->assertEqual('dir', $this->instance->filetype('/folder'));
|
||||
$this->assertEqual(0, $this->instance->filesize('/folder'));
|
||||
$this->assertTrue($this->instance->isReadable('/folder'));
|
||||
$this->assertTrue($this->instance->isUpdatable('/folder'));
|
||||
|
||||
$dh=$this->instance->opendir('/');
|
||||
$content=array();
|
||||
while($file=readdir($dh)) {
|
||||
if($file!='.' and $file!='..') {
|
||||
$content[]=$file;
|
||||
}
|
||||
}
|
||||
$this->assertEqual(array('folder'),$content);
|
||||
|
||||
$this->assertFalse($this->instance->mkdir('/folder'));//cant create existing folders
|
||||
$this->assertTrue($this->instance->rmdir('/folder'));
|
||||
|
||||
$this->assertFalse($this->instance->file_exists('/folder'));
|
||||
|
||||
$this->assertFalse($this->instance->rmdir('/folder'));//cant remove non existing folders
|
||||
|
||||
$dh=$this->instance->opendir('/');
|
||||
$content=array();
|
||||
while($file=readdir($dh)) {
|
||||
if($file!='.' and $file!='..') {
|
||||
$content[]=$file;
|
||||
$dh = $this->instance->opendir('/');
|
||||
$content = array();
|
||||
while ($file = readdir($dh)) {
|
||||
if ($file != '.' and $file != '..') {
|
||||
$content[] = $file;
|
||||
}
|
||||
}
|
||||
$this->assertEqual(array(),$content);
|
||||
$this->assertEqual(array('folder'), $content);
|
||||
|
||||
$this->assertFalse($this->instance->mkdir('/folder')); //cant create existing folders
|
||||
$this->assertTrue($this->instance->rmdir('/folder'));
|
||||
|
||||
$this->assertFalse($this->instance->file_exists('/folder'));
|
||||
|
||||
$this->assertFalse($this->instance->rmdir('/folder')); //cant remove non existing folders
|
||||
|
||||
$dh = $this->instance->opendir('/');
|
||||
$content = array();
|
||||
while ($file = readdir($dh)) {
|
||||
if ($file != '.' and $file != '..') {
|
||||
$content[] = $file;
|
||||
}
|
||||
}
|
||||
$this->assertEqual(array(), $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* test the various uses of file_get_contents and file_put_contents
|
||||
*/
|
||||
public function testGetPutContents() {
|
||||
$sourceFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
|
||||
$sourceText=file_get_contents($sourceFile);
|
||||
|
||||
$sourceFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
|
||||
$sourceText = file_get_contents($sourceFile);
|
||||
|
||||
//fill a file with string data
|
||||
$this->instance->file_put_contents('/lorem.txt',$sourceText);
|
||||
$this->instance->file_put_contents('/lorem.txt', $sourceText);
|
||||
$this->assertFalse($this->instance->is_dir('/lorem.txt'));
|
||||
$this->assertEqual($sourceText,$this->instance->file_get_contents('/lorem.txt'),'data returned from file_get_contents is not equal to the source data');
|
||||
$this->assertEqual($sourceText, $this->instance->file_get_contents('/lorem.txt'), 'data returned from file_get_contents is not equal to the source data');
|
||||
|
||||
//empty the file
|
||||
$this->instance->file_put_contents('/lorem.txt','');
|
||||
$this->assertEqual('',$this->instance->file_get_contents('/lorem.txt'),'file not emptied');
|
||||
$this->instance->file_put_contents('/lorem.txt', '');
|
||||
$this->assertEqual('', $this->instance->file_get_contents('/lorem.txt'), 'file not emptied');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test various known mimetypes
|
||||
*/
|
||||
public function testMimeType() {
|
||||
$this->assertEqual('httpd/unix-directory',$this->instance->getMimeType('/'));
|
||||
$this->assertEqual(false,$this->instance->getMimeType('/non/existing/file'));
|
||||
|
||||
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
|
||||
$this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile,'r'));
|
||||
$this->assertEqual('text/plain',$this->instance->getMimeType('/lorem.txt'));
|
||||
|
||||
$pngFile=OC::$SERVERROOT.'/tests/data/logo-wide.png';
|
||||
$this->instance->file_put_contents('/logo-wide.png',file_get_contents($pngFile,'r'));
|
||||
$this->assertEqual('image/png',$this->instance->getMimeType('/logo-wide.png'));
|
||||
|
||||
$svgFile=OC::$SERVERROOT.'/tests/data/logo-wide.svg';
|
||||
$this->instance->file_put_contents('/logo-wide.svg',file_get_contents($svgFile,'r'));
|
||||
$this->assertEqual('image/svg+xml',$this->instance->getMimeType('/logo-wide.svg'));
|
||||
$this->assertEqual('httpd/unix-directory', $this->instance->getMimeType('/'));
|
||||
$this->assertEqual(false, $this->instance->getMimeType('/non/existing/file'));
|
||||
|
||||
$textFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
|
||||
$this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile, 'r'));
|
||||
$this->assertEqual('text/plain', $this->instance->getMimeType('/lorem.txt'));
|
||||
|
||||
$pngFile = OC::$SERVERROOT . '/tests/data/logo-wide.png';
|
||||
$this->instance->file_put_contents('/logo-wide.png', file_get_contents($pngFile, 'r'));
|
||||
$this->assertEqual('image/png', $this->instance->getMimeType('/logo-wide.png'));
|
||||
|
||||
$svgFile = OC::$SERVERROOT . '/tests/data/logo-wide.svg';
|
||||
$this->instance->file_put_contents('/logo-wide.svg', file_get_contents($svgFile, 'r'));
|
||||
$this->assertEqual('image/svg+xml', $this->instance->getMimeType('/logo-wide.svg'));
|
||||
}
|
||||
|
||||
|
||||
public function testCopyAndMove() {
|
||||
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
|
||||
$this->instance->file_put_contents('/source.txt',file_get_contents($textFile));
|
||||
$this->instance->copy('/source.txt','/target.txt');
|
||||
$textFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
|
||||
$this->instance->file_put_contents('/source.txt', file_get_contents($textFile));
|
||||
$this->instance->copy('/source.txt', '/target.txt');
|
||||
$this->assertTrue($this->instance->file_exists('/target.txt'));
|
||||
$this->assertEqual($this->instance->file_get_contents('/source.txt'),$this->instance->file_get_contents('/target.txt'));
|
||||
|
||||
$this->instance->rename('/source.txt','/target2.txt');
|
||||
$this->assertEqual($this->instance->file_get_contents('/source.txt'), $this->instance->file_get_contents('/target.txt'));
|
||||
|
||||
$this->instance->rename('/source.txt', '/target2.txt');
|
||||
$this->assertTrue($this->instance->file_exists('/target2.txt'));
|
||||
$this->assertFalse($this->instance->file_exists('/source.txt'));
|
||||
$this->assertEqual(file_get_contents($textFile),$this->instance->file_get_contents('/target.txt'));
|
||||
$this->assertEqual(file_get_contents($textFile), $this->instance->file_get_contents('/target.txt'));
|
||||
}
|
||||
|
||||
|
||||
public function testLocal() {
|
||||
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
|
||||
$this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile));
|
||||
$localFile=$this->instance->getLocalFile('/lorem.txt');
|
||||
$textFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
|
||||
$this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile));
|
||||
$localFile = $this->instance->getLocalFile('/lorem.txt');
|
||||
$this->assertTrue(file_exists($localFile));
|
||||
$this->assertEqual(file_get_contents($localFile),file_get_contents($textFile));
|
||||
|
||||
$this->assertEqual(file_get_contents($localFile), file_get_contents($textFile));
|
||||
|
||||
$this->instance->mkdir('/folder');
|
||||
$this->instance->file_put_contents('/folder/lorem.txt',file_get_contents($textFile));
|
||||
$this->instance->file_put_contents('/folder/bar.txt','asd');
|
||||
$this->instance->file_put_contents('/folder/lorem.txt', file_get_contents($textFile));
|
||||
$this->instance->file_put_contents('/folder/bar.txt', 'asd');
|
||||
$this->instance->mkdir('/folder/recursive');
|
||||
$this->instance->file_put_contents('/folder/recursive/file.txt','foo');
|
||||
$localFolder=$this->instance->getLocalFolder('/folder');
|
||||
$this->instance->file_put_contents('/folder/recursive/file.txt', 'foo');
|
||||
$localFolder = $this->instance->getLocalFolder('/folder');
|
||||
|
||||
$this->assertTrue(is_dir($localFolder));
|
||||
$this->assertTrue(file_exists($localFolder.'/lorem.txt'));
|
||||
$this->assertEqual(file_get_contents($localFolder.'/lorem.txt'),file_get_contents($textFile));
|
||||
$this->assertEqual(file_get_contents($localFolder.'/bar.txt'),'asd');
|
||||
$this->assertEqual(file_get_contents($localFolder.'/recursive/file.txt'),'foo');
|
||||
$this->assertTrue(file_exists($localFolder . '/lorem.txt'));
|
||||
$this->assertEqual(file_get_contents($localFolder . '/lorem.txt'), file_get_contents($textFile));
|
||||
$this->assertEqual(file_get_contents($localFolder . '/bar.txt'), 'asd');
|
||||
$this->assertEqual(file_get_contents($localFolder . '/recursive/file.txt'), 'foo');
|
||||
}
|
||||
|
||||
public function testStat() {
|
||||
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
|
||||
$ctimeStart=time();
|
||||
$this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile));
|
||||
$textFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
|
||||
$ctimeStart = time();
|
||||
$this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile));
|
||||
$this->assertTrue($this->instance->isReadable('/lorem.txt'));
|
||||
$ctimeEnd=time();
|
||||
$cTime=$this->instance->filectime('/lorem.txt');
|
||||
$mTime=$this->instance->filemtime('/lorem.txt');
|
||||
if($cTime!=-1) {//not everything can support ctime
|
||||
$this->assertTrue(($ctimeStart-1)<=$cTime);
|
||||
$this->assertTrue($cTime<=($ctimeEnd+1));
|
||||
}
|
||||
$this->assertTrue($this->instance->hasUpdated('/lorem.txt',$ctimeStart-1));
|
||||
$this->assertTrue($this->instance->hasUpdated('/',$ctimeStart-1));
|
||||
|
||||
$this->assertTrue(($ctimeStart-1)<=$mTime);
|
||||
$this->assertTrue($mTime<=($ctimeEnd+1));
|
||||
$this->assertEqual(filesize($textFile),$this->instance->filesize('/lorem.txt'));
|
||||
|
||||
$stat=$this->instance->stat('/lorem.txt');
|
||||
//only size, mtime and ctime are requered in the result
|
||||
$this->assertEqual($stat['size'],$this->instance->filesize('/lorem.txt'));
|
||||
$this->assertEqual($stat['mtime'],$mTime);
|
||||
$this->assertEqual($stat['ctime'],$cTime);
|
||||
|
||||
$mtimeStart=time();
|
||||
$ctimeEnd = time();
|
||||
$mTime = $this->instance->filemtime('/lorem.txt');
|
||||
$this->assertTrue($this->instance->hasUpdated('/lorem.txt', $ctimeStart - 1));
|
||||
$this->assertTrue($this->instance->hasUpdated('/', $ctimeStart - 1));
|
||||
|
||||
$this->assertTrue(($ctimeStart - 1) <= $mTime);
|
||||
$this->assertTrue($mTime <= ($ctimeEnd + 1));
|
||||
$this->assertEqual(filesize($textFile), $this->instance->filesize('/lorem.txt'));
|
||||
|
||||
$stat = $this->instance->stat('/lorem.txt');
|
||||
//only size and mtime are requered in the result
|
||||
$this->assertEqual($stat['size'], $this->instance->filesize('/lorem.txt'));
|
||||
$this->assertEqual($stat['mtime'], $mTime);
|
||||
|
||||
$mtimeStart = time();
|
||||
$supportsTouch = $this->instance->touch('/lorem.txt');
|
||||
$mtimeEnd=time();
|
||||
if($supportsTouch !== false){
|
||||
$originalCTime=$cTime;
|
||||
$cTime=$this->instance->filectime('/lorem.txt');
|
||||
$mTime=$this->instance->filemtime('/lorem.txt');
|
||||
$this->assertTrue(($mtimeStart-1)<=$mTime);
|
||||
$this->assertTrue($mTime<=($mtimeEnd+1));
|
||||
$this->assertEqual($cTime,$originalCTime);
|
||||
$mtimeEnd = time();
|
||||
if ($supportsTouch !== false) {
|
||||
$mTime = $this->instance->filemtime('/lorem.txt');
|
||||
$this->assertTrue(($mtimeStart - 1) <= $mTime);
|
||||
$this->assertTrue($mTime <= ($mtimeEnd + 1));
|
||||
|
||||
$this->assertTrue($this->instance->hasUpdated('/lorem.txt',$mtimeStart-1));
|
||||
$this->assertTrue($this->instance->hasUpdated('/lorem.txt', $mtimeStart - 1));
|
||||
|
||||
if($this->instance->touch('/lorem.txt',100)!==false) {
|
||||
$mTime=$this->instance->filemtime('/lorem.txt');
|
||||
$this->assertEqual($mTime,100);
|
||||
if ($this->instance->touch('/lorem.txt', 100) !== false) {
|
||||
$mTime = $this->instance->filemtime('/lorem.txt');
|
||||
$this->assertEqual($mTime, 100);
|
||||
}
|
||||
}
|
||||
|
||||
$mtimeStart=time();
|
||||
$fh=$this->instance->fopen('/lorem.txt','a');
|
||||
fwrite($fh,' ');
|
||||
$mtimeStart = time();
|
||||
$fh = $this->instance->fopen('/lorem.txt', 'a');
|
||||
fwrite($fh, ' ');
|
||||
fclose($fh);
|
||||
clearstatcache();
|
||||
$mtimeEnd=time();
|
||||
$originalCTime=$cTime;
|
||||
$mTime=$this->instance->filemtime('/lorem.txt');
|
||||
$this->assertTrue(($mtimeStart-1)<=$mTime);
|
||||
$this->assertTrue($mTime<=($mtimeEnd+1));
|
||||
$mtimeEnd = time();
|
||||
$mTime = $this->instance->filemtime('/lorem.txt');
|
||||
$this->assertTrue(($mtimeStart - 1) <= $mTime);
|
||||
$this->assertTrue($mTime <= ($mtimeEnd + 1));
|
||||
|
||||
$this->instance->unlink('/lorem.txt');
|
||||
$this->assertTrue($this->instance->hasUpdated('/',$mtimeStart-1));
|
||||
$this->assertTrue($this->instance->hasUpdated('/', $mtimeStart - 1));
|
||||
}
|
||||
|
||||
public function testSearch() {
|
||||
$textFile=OC::$SERVERROOT.'/tests/data/lorem.txt';
|
||||
$this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile,'r'));
|
||||
$pngFile=OC::$SERVERROOT.'/tests/data/logo-wide.png';
|
||||
$this->instance->file_put_contents('/logo-wide.png',file_get_contents($pngFile,'r'));
|
||||
$svgFile=OC::$SERVERROOT.'/tests/data/logo-wide.svg';
|
||||
$this->instance->file_put_contents('/logo-wide.svg',file_get_contents($svgFile,'r'));
|
||||
$result=$this->instance->search('logo');
|
||||
$this->assertEqual(2,count($result));
|
||||
$this->assertNotIdentical(false,array_search('/logo-wide.svg',$result));
|
||||
$this->assertNotIdentical(false,array_search('/logo-wide.png',$result));
|
||||
$textFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
|
||||
$this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile, 'r'));
|
||||
$pngFile = OC::$SERVERROOT . '/tests/data/logo-wide.png';
|
||||
$this->instance->file_put_contents('/logo-wide.png', file_get_contents($pngFile, 'r'));
|
||||
$svgFile = OC::$SERVERROOT . '/tests/data/logo-wide.svg';
|
||||
$this->instance->file_put_contents('/logo-wide.svg', file_get_contents($svgFile, 'r'));
|
||||
$result = $this->instance->search('logo');
|
||||
$this->assertEqual(2, count($result));
|
||||
$this->assertNotIdentical(false, array_search('/logo-wide.svg', $result));
|
||||
$this->assertNotIdentical(false, array_search('/logo-wide.png', $result));
|
||||
}
|
||||
|
||||
public function testFOpen() {
|
||||
$textFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
|
||||
|
||||
$fh = @$this->instance->fopen('foo', 'r');
|
||||
if ($fh) {
|
||||
fclose($fh);
|
||||
}
|
||||
$this->assertFalse($fh);
|
||||
$this->assertFalse($this->instance->file_exists('foo'));
|
||||
|
||||
$fh = $this->instance->fopen('foo', 'w');
|
||||
fwrite($fh, file_get_contents($textFile));
|
||||
fclose($fh);
|
||||
$this->assertTrue($this->instance->file_exists('foo'));
|
||||
|
||||
$fh = $this->instance->fopen('foo', 'r');
|
||||
$content = stream_get_contents($fh);
|
||||
$this->assertEqual(file_get_contents($textFile), $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,6 +264,8 @@ class Test_Share extends UnitTestCase {
|
||||
} catch (Exception $exception) {
|
||||
$this->assertEqual($exception->getMessage(), $message);
|
||||
}
|
||||
$policy = OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
|
||||
OC_Appconfig::setValue('core', 'shareapi_share_policy', 'groups_only');
|
||||
$message = 'Sharing test.txt failed, because '.$this->user1.' is not a member of the group '.$this->group2;
|
||||
try {
|
||||
OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group2, OCP\Share::PERMISSION_READ);
|
||||
@@ -271,6 +273,7 @@ class Test_Share extends UnitTestCase {
|
||||
} catch (Exception $exception) {
|
||||
$this->assertEqual($exception->getMessage(), $message);
|
||||
}
|
||||
OC_Appconfig::setValue('core', 'shareapi_share_policy', $policy);
|
||||
|
||||
// Valid share
|
||||
$this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, OCP\Share::PERMISSION_READ));
|
||||
|
||||
Reference in New Issue
Block a user