Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
9c5416fe
Commit
9c5416fe
authored
Aug 15, 2013
by
kondou
Browse files
Clean up \OC\Util
- Use camelCase - Add some phpdoc - Fix some indents - Use some more spacing
parent
b9f3bb24
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
core/lostpassword/controller.php
View file @
9c5416fe
...
...
@@ -42,7 +42,7 @@ class OC_Core_LostPassword_Controller {
}
if
(
OC_User
::
userExists
(
$_POST
[
'user'
])
&&
$continue
)
{
$token
=
hash
(
'sha256'
,
OC_Util
::
generate
_r
andom
_b
ytes
(
30
)
.
OC_Config
::
getValue
(
'passwordsalt'
,
''
));
$token
=
hash
(
'sha256'
,
OC_Util
::
generate
R
andom
B
ytes
(
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'
,
''
);
...
...
core/minimizer.php
View file @
9c5416fe
...
...
@@ -5,11 +5,11 @@ OC_App::loadApps();
if
(
$service
==
'core.css'
)
{
$minimizer
=
new
OC_Minimizer_CSS
();
$files
=
OC_TemplateLayout
::
findStylesheetFiles
(
OC_Util
::
$core
_s
tyles
);
$files
=
OC_TemplateLayout
::
findStylesheetFiles
(
OC_Util
::
$core
S
tyles
);
$minimizer
->
output
(
$files
,
$service
);
}
else
if
(
$service
==
'core.js'
)
{
$minimizer
=
new
OC_Minimizer_JS
();
$files
=
OC_TemplateLayout
::
findJavascriptFiles
(
OC_Util
::
$core
_s
cripts
);
$files
=
OC_TemplateLayout
::
findJavascriptFiles
(
OC_Util
::
$core
S
cripts
);
$minimizer
->
output
(
$files
,
$service
);
}
core/setup.php
View file @
9c5416fe
...
...
@@ -33,8 +33,8 @@ $opts = array(
'hasOracle'
=>
$hasOracle
,
'hasMSSQL'
=>
$hasMSSQL
,
'directory'
=>
$datadir
,
'secureRNG'
=>
OC_Util
::
secureRNG
_a
vailable
(),
'htaccessWorking'
=>
OC_Util
::
is
h
taccess
w
orking
(),
'secureRNG'
=>
OC_Util
::
secureRNG
A
vailable
(),
'htaccessWorking'
=>
OC_Util
::
is
H
taccess
W
orking
(),
'vulnerableToNullByte'
=>
$vulnerableToNullByte
,
'errors'
=>
array
(),
);
...
...
lib/app.php
View file @
9c5416fe
...
...
@@ -73,11 +73,11 @@ class OC_App{
if
(
!
defined
(
'DEBUG'
)
||
!
DEBUG
)
{
if
(
is_null
(
$types
)
&&
empty
(
OC_Util
::
$core
_s
cripts
)
&&
empty
(
OC_Util
::
$core
_s
tyles
))
{
OC_Util
::
$core
_s
cripts
=
OC_Util
::
$scripts
;
&&
empty
(
OC_Util
::
$core
S
cripts
)
&&
empty
(
OC_Util
::
$core
S
tyles
))
{
OC_Util
::
$core
S
cripts
=
OC_Util
::
$scripts
;
OC_Util
::
$scripts
=
array
();
OC_Util
::
$core
_s
tyles
=
OC_Util
::
$styles
;
OC_Util
::
$core
S
tyles
=
OC_Util
::
$styles
;
OC_Util
::
$styles
=
array
();
}
}
...
...
lib/base.php
View file @
9c5416fe
...
...
@@ -413,7 +413,7 @@ class OC {
}
self
::
initPaths
();
OC_Util
::
is
s
etlocale
w
orking
();
OC_Util
::
is
S
etlocale
W
orking
();
// set debug mode if an xdebug session is active
if
(
!
defined
(
'DEBUG'
)
||
!
DEBUG
)
{
...
...
@@ -522,7 +522,7 @@ class OC {
}
// write error into log if locale can't be set
if
(
OC_Util
::
is
s
etlocale
w
orking
()
==
false
)
{
if
(
OC_Util
::
is
S
etlocale
W
orking
()
==
false
)
{
OC_Log
::
write
(
'core'
,
'setting locale to en_US.UTF-8/en_US.UTF8 failed. Support is probably not installed on your system'
,
OC_Log
::
ERROR
);
...
...
@@ -735,7 +735,7 @@ class OC {
if
(
in_array
(
$_COOKIE
[
'oc_token'
],
$tokens
,
true
))
{
// replace successfully used token with a new one
OC_Preferences
::
deleteKey
(
$_COOKIE
[
'oc_username'
],
'login_token'
,
$_COOKIE
[
'oc_token'
]);
$token
=
OC_Util
::
generate
_r
andom
_b
ytes
(
32
);
$token
=
OC_Util
::
generate
R
andom
B
ytes
(
32
);
OC_Preferences
::
setValue
(
$_COOKIE
[
'oc_username'
],
'login_token'
,
$token
,
time
());
OC_User
::
setMagicInCookie
(
$_COOKIE
[
'oc_username'
],
$token
);
// login
...
...
@@ -774,7 +774,7 @@ class OC {
if
(
defined
(
"DEBUG"
)
&&
DEBUG
)
{
OC_Log
::
write
(
'core'
,
'Setting remember login to cookie'
,
OC_Log
::
DEBUG
);
}
$token
=
OC_Util
::
generate
_r
andom
_b
ytes
(
32
);
$token
=
OC_Util
::
generate
R
andom
B
ytes
(
32
);
OC_Preferences
::
setValue
(
$_POST
[
'user'
],
'login_token'
,
$token
,
time
());
OC_User
::
setMagicInCookie
(
$_POST
[
"user"
],
$token
);
}
else
{
...
...
lib/public/share.php
View file @
9c5416fe
...
...
@@ -463,7 +463,7 @@ class Share {
if
(
isset
(
$oldToken
))
{
$token
=
$oldToken
;
}
else
{
$token
=
\
OC_Util
::
generate
_r
andom
_b
ytes
(
self
::
TOKEN_LENGTH
);
$token
=
\
OC_Util
::
generate
R
andom
B
ytes
(
self
::
TOKEN_LENGTH
);
}
$result
=
self
::
put
(
$itemType
,
$itemSource
,
$shareType
,
$shareWith
,
$uidOwner
,
$permissions
,
null
,
$token
);
...
...
lib/setup.php
View file @
9c5416fe
...
...
@@ -61,7 +61,7 @@ class OC_Setup {
}
//generate a random salt that is used to salt the local user passwords
$salt
=
OC_Util
::
generate
_r
andom
_b
ytes
(
30
);
$salt
=
OC_Util
::
generate
R
andom
B
ytes
(
30
);
OC_Config
::
setValue
(
'passwordsalt'
,
$salt
);
//write the config file
...
...
lib/setup/mysql.php
View file @
9c5416fe
...
...
@@ -23,7 +23,7 @@ class MySQL extends AbstractDatabase {
$this
->
dbuser
=
substr
(
'oc_'
.
$username
,
0
,
16
);
if
(
$this
->
dbuser
!=
$oldUser
)
{
//hash the password so we don't need to store the admin config in the config file
$this
->
dbpassword
=
\
OC_Util
::
generate
_r
andom
_b
ytes
(
30
);
$this
->
dbpassword
=
\
OC_Util
::
generate
R
andom
B
ytes
(
30
);
$this
->
createDBUser
(
$connection
);
...
...
lib/setup/oci.php
View file @
9c5416fe
...
...
@@ -65,7 +65,7 @@ class OCI extends AbstractDatabase {
//add prefix to the oracle user name to prevent collisions
$this
->
dbuser
=
'oc_'
.
$username
;
//create a new password so we don't need to store the admin config in the config file
$this
->
dbpassword
=
\
OC_Util
::
generate
_r
andom
_b
ytes
(
30
);
$this
->
dbpassword
=
\
OC_Util
::
generate
R
andom
B
ytes
(
30
);
//oracle passwords are treated as identifiers:
// must start with aphanumeric char
...
...
lib/setup/postgresql.php
View file @
9c5416fe
...
...
@@ -33,7 +33,7 @@ class PostgreSQL extends AbstractDatabase {
//add prefix to the postgresql user name to prevent collisions
$this
->
dbuser
=
'oc_'
.
$username
;
//create a new password so we don't need to store the admin config in the config file
$this
->
dbpassword
=
\
OC_Util
::
generate
_r
andom
_b
ytes
(
30
);
$this
->
dbpassword
=
\
OC_Util
::
generate
R
andom
B
ytes
(
30
);
$this
->
createDBUser
(
$connection
);
...
...
lib/templatelayout.php
View file @
9c5416fe
...
...
@@ -58,7 +58,7 @@ class OC_TemplateLayout extends OC_Template {
if
(
OC_Config
::
getValue
(
'installed'
,
false
)
&&
$renderas
!=
'error'
)
{
$this
->
append
(
'jsfiles'
,
OC_Helper
::
linkToRoute
(
'js_config'
)
.
$versionParameter
);
}
if
(
!
empty
(
OC_Util
::
$core
_s
cripts
))
{
if
(
!
empty
(
OC_Util
::
$core
S
cripts
))
{
$this
->
append
(
'jsfiles'
,
OC_Helper
::
linkToRemoteBase
(
'core.js'
,
false
)
.
$versionParameter
);
}
foreach
(
$jsfiles
as
$info
)
{
...
...
@@ -71,7 +71,7 @@ class OC_TemplateLayout extends OC_Template {
// Add the css files
$cssfiles
=
self
::
findStylesheetFiles
(
OC_Util
::
$styles
);
$this
->
assign
(
'cssfiles'
,
array
());
if
(
!
empty
(
OC_Util
::
$core
_s
tyles
))
{
if
(
!
empty
(
OC_Util
::
$core
S
tyles
))
{
$this
->
append
(
'cssfiles'
,
OC_Helper
::
linkToRemoteBase
(
'core.css'
,
false
)
.
$versionParameter
);
}
foreach
(
$cssfiles
as
$info
)
{
...
...
lib/user.php
View file @
9c5416fe
...
...
@@ -353,7 +353,7 @@ class OC_User {
* generates a password
*/
public
static
function
generatePassword
()
{
return
OC_Util
::
generate
_r
andom
_b
ytes
(
30
);
return
OC_Util
::
generate
R
andom
B
ytes
(
30
);
}
/**
...
...
lib/util.php
View file @
9c5416fe
This diff is collapsed.
Click to expand it.
settings/admin.php
View file @
9c5416fe
...
...
@@ -15,7 +15,7 @@ OC_App::setActiveNavigationEntry( "admin" );
$tmpl
=
new
OC_Template
(
'settings'
,
'admin'
,
'user'
);
$forms
=
OC_App
::
getForms
(
'admin'
);
$htaccessworking
=
OC_Util
::
is
h
taccess
w
orking
();
$htaccessworking
=
OC_Util
::
is
H
taccess
W
orking
();
$entries
=
OC_Log_Owncloud
::
getEntries
(
3
);
$entriesremain
=
(
count
(
OC_Log_Owncloud
::
getEntries
(
4
))
>
3
)
?
true
:
false
;
...
...
@@ -25,7 +25,7 @@ $tmpl->assign('entries', $entries);
$tmpl
->
assign
(
'entriesremain'
,
$entriesremain
);
$tmpl
->
assign
(
'htaccessworking'
,
$htaccessworking
);
$tmpl
->
assign
(
'internetconnectionworking'
,
OC_Util
::
isInternetConnectionEnabled
()
?
OC_Util
::
isInternetConnectionWorking
()
:
false
);
$tmpl
->
assign
(
'islocaleworking'
,
OC_Util
::
is
s
etlocale
w
orking
());
$tmpl
->
assign
(
'islocaleworking'
,
OC_Util
::
is
S
etlocale
W
orking
());
$tmpl
->
assign
(
'isWebDavWorking'
,
OC_Util
::
isWebDAVWorking
());
$tmpl
->
assign
(
'has_fileinfo'
,
OC_Util
::
fileInfoLoaded
());
$tmpl
->
assign
(
'backgroundjobs_mode'
,
OC_Appconfig
::
getValue
(
'core'
,
'backgroundjobs_mode'
,
'ajax'
));
...
...
tests/lib/db.php
View file @
9c5416fe
...
...
@@ -15,7 +15,7 @@ class Test_DB extends PHPUnit_Framework_TestCase {
public
function
setUp
()
{
$dbfile
=
OC
::
$SERVERROOT
.
'/tests/data/db_structure.xml'
;
$r
=
'_'
.
OC_Util
::
generate
_r
andom
_b
ytes
(
'4'
)
.
'_'
;
$r
=
'_'
.
OC_Util
::
generate
R
andom
B
ytes
(
'4'
)
.
'_'
;
$content
=
file_get_contents
(
$dbfile
);
$content
=
str_replace
(
'*dbprefix*'
,
'*dbprefix*'
.
$r
,
$content
);
file_put_contents
(
self
::
$schema_file
,
$content
);
...
...
tests/lib/dbschema.php
View file @
9c5416fe
...
...
@@ -16,7 +16,7 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
$dbfile
=
OC
::
$SERVERROOT
.
'/tests/data/db_structure.xml'
;
$dbfile2
=
OC
::
$SERVERROOT
.
'/tests/data/db_structure2.xml'
;
$r
=
'_'
.
OC_Util
::
generate
_r
andom
_b
ytes
(
'4'
)
.
'_'
;
$r
=
'_'
.
OC_Util
::
generate
R
andom
B
ytes
(
'4'
)
.
'_'
;
$content
=
file_get_contents
(
$dbfile
);
$content
=
str_replace
(
'*dbprefix*'
,
'*dbprefix*'
.
$r
,
$content
);
file_put_contents
(
$this
->
schema_file
,
$content
);
...
...
tests/lib/util.php
View file @
9c5416fe
...
...
@@ -71,8 +71,8 @@ class Test_Util extends PHPUnit_Framework_TestCase {
$this
->
assertTrue
(
\
OC_Util
::
isInternetConnectionEnabled
());
}
function
testGenerate
_r
andom
_b
ytes
()
{
$result
=
strlen
(
OC_Util
::
generate
_r
andom
_b
ytes
(
59
));
function
testGenerate
R
andom
B
ytes
()
{
$result
=
strlen
(
OC_Util
::
generate
R
andom
B
ytes
(
59
));
$this
->
assertEquals
(
59
,
$result
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment