Commit 9c5416fe authored by kondou's avatar kondou
Browse files

Clean up \OC\Util

 - Use camelCase

 - Add some phpdoc

 - Fix some indents

 - Use some more spacing
parent b9f3bb24
......@@ -42,7 +42,7 @@ class OC_Core_LostPassword_Controller {
}
if (OC_User::userExists($_POST['user']) && $continue) {
$token = hash('sha256', OC_Util::generate_random_bytes(30).OC_Config::getValue('passwordsalt', ''));
$token = hash('sha256', OC_Util::generateRandomBytes(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', '');
......
......@@ -5,11 +5,11 @@ OC_App::loadApps();
if ($service == 'core.css') {
$minimizer = new OC_Minimizer_CSS();
$files = OC_TemplateLayout::findStylesheetFiles(OC_Util::$core_styles);
$files = OC_TemplateLayout::findStylesheetFiles(OC_Util::$coreStyles);
$minimizer->output($files, $service);
}
else if ($service == 'core.js') {
$minimizer = new OC_Minimizer_JS();
$files = OC_TemplateLayout::findJavascriptFiles(OC_Util::$core_scripts);
$files = OC_TemplateLayout::findJavascriptFiles(OC_Util::$coreScripts);
$minimizer->output($files, $service);
}
......@@ -33,8 +33,8 @@ $opts = array(
'hasOracle' => $hasOracle,
'hasMSSQL' => $hasMSSQL,
'directory' => $datadir,
'secureRNG' => OC_Util::secureRNG_available(),
'htaccessWorking' => OC_Util::ishtaccessworking(),
'secureRNG' => OC_Util::secureRNGAvailable(),
'htaccessWorking' => OC_Util::isHtaccessWorking(),
'vulnerableToNullByte' => $vulnerableToNullByte,
'errors' => array(),
);
......
......@@ -73,11 +73,11 @@ class OC_App{
if (!defined('DEBUG') || !DEBUG) {
if (is_null($types)
&& empty(OC_Util::$core_scripts)
&& empty(OC_Util::$core_styles)) {
OC_Util::$core_scripts = OC_Util::$scripts;
&& empty(OC_Util::$coreScripts)
&& empty(OC_Util::$coreStyles)) {
OC_Util::$coreScripts = OC_Util::$scripts;
OC_Util::$scripts = array();
OC_Util::$core_styles = OC_Util::$styles;
OC_Util::$coreStyles = OC_Util::$styles;
OC_Util::$styles = array();
}
}
......
......@@ -413,7 +413,7 @@ class OC {
}
self::initPaths();
OC_Util::issetlocaleworking();
OC_Util::isSetlocaleWorking();
// 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::issetlocaleworking() == false) {
if (OC_Util::isSetlocaleWorking() == 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_random_bytes(32);
$token = OC_Util::generateRandomBytes(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_random_bytes(32);
$token = OC_Util::generateRandomBytes(32);
OC_Preferences::setValue($_POST['user'], 'login_token', $token, time());
OC_User::setMagicInCookie($_POST["user"], $token);
} else {
......
......@@ -463,7 +463,7 @@ class Share {
if (isset($oldToken)) {
$token = $oldToken;
} else {
$token = \OC_Util::generate_random_bytes(self::TOKEN_LENGTH);
$token = \OC_Util::generateRandomBytes(self::TOKEN_LENGTH);
}
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions,
null, $token);
......
......@@ -61,7 +61,7 @@ class OC_Setup {
}
//generate a random salt that is used to salt the local user passwords
$salt = OC_Util::generate_random_bytes(30);
$salt = OC_Util::generateRandomBytes(30);
OC_Config::setValue('passwordsalt', $salt);
//write the config file
......
......@@ -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_random_bytes(30);
$this->dbpassword=\OC_Util::generateRandomBytes(30);
$this->createDBUser($connection);
......
......@@ -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_random_bytes(30);
$this->dbpassword=\OC_Util::generateRandomBytes(30);
//oracle passwords are treated as identifiers:
// must start with aphanumeric char
......
......@@ -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_random_bytes(30);
$this->dbpassword=\OC_Util::generateRandomBytes(30);
$this->createDBUser($connection);
......
......@@ -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_scripts)) {
if (!empty(OC_Util::$coreScripts)) {
$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_styles)) {
if (!empty(OC_Util::$coreStyles)) {
$this->append( 'cssfiles', OC_Helper::linkToRemoteBase('core.css', false) . $versionParameter);
}
foreach($cssfiles as $info) {
......
......@@ -353,7 +353,7 @@ class OC_User {
* generates a password
*/
public static function generatePassword() {
return OC_Util::generate_random_bytes(30);
return OC_Util::generateRandomBytes(30);
}
/**
......
This diff is collapsed.
......@@ -15,7 +15,7 @@ OC_App::setActiveNavigationEntry( "admin" );
$tmpl = new OC_Template( 'settings', 'admin', 'user');
$forms=OC_App::getForms('admin');
$htaccessworking=OC_Util::ishtaccessworking();
$htaccessworking=OC_Util::isHtaccessWorking();
$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::issetlocaleworking());
$tmpl->assign('islocaleworking', OC_Util::isSetlocaleWorking());
$tmpl->assign('isWebDavWorking', OC_Util::isWebDAVWorking());
$tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded());
$tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax'));
......
......@@ -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_random_bytes('4').'_';
$r = '_'.OC_Util::generateRandomBytes('4').'_';
$content = file_get_contents( $dbfile );
$content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content );
file_put_contents( self::$schema_file, $content );
......
......@@ -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_random_bytes('4').'_';
$r = '_'.OC_Util::generateRandomBytes('4').'_';
$content = file_get_contents( $dbfile );
$content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content );
file_put_contents( $this->schema_file, $content );
......
......@@ -71,8 +71,8 @@ class Test_Util extends PHPUnit_Framework_TestCase {
$this->assertTrue(\OC_Util::isInternetConnectionEnabled());
}
function testGenerate_random_bytes() {
$result = strlen(OC_Util::generate_random_bytes(59));
function testGenerateRandomBytes() {
$result = strlen(OC_Util::generateRandomBytes(59));
$this->assertEquals(59, $result);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment