Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-04-14 18:28:36 +0400
committerRobin Appelman <icewind@owncloud.com>2012-04-14 18:29:11 +0400
commit721311c9099780ecc22b6b186ed79dc5c9c92271 (patch)
tree9e26f111433d33834d3cc741f56a9eb0ef105915
parent926b2b78fe444f5facfb21a625a6cd01123d2fb2 (diff)
some minor optimizations
-rw-r--r--lib/db.php38
-rw-r--r--lib/l10n.php13
2 files changed, 32 insertions, 19 deletions
diff --git a/lib/db.php b/lib/db.php
index 9364b9e0015..d2552bff8f6 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -36,8 +36,26 @@ class OC_DB {
static private $affected=0;
static private $result=false;
static private $inTransaction=false;
+ static private $prefix=null;
+ static private $type=null;
/**
+ * check which backend we should use
+ * @return BACKEND_MDB2 or BACKEND_PDO
+ */
+ private static function getDBBackend(){
+ $backend=self::BACKEND_MDB2;
+ if(class_exists('PDO') && OC_Config::getValue('installed', false)){//check if we can use PDO, else use MDB2 (instalation always needs to be done my mdb2)
+ $type = OC_Config::getValue( "dbtype", "sqlite" );
+ if($type=='sqlite3') $type='sqlite';
+ $drivers=PDO::getAvailableDrivers();
+ if(array_search($type,$drivers)!==false){
+ $backend=self::BACKEND_PDO;
+ }
+ }
+ }
+
+ /**
* @brief connects to the database
* @returns true if connection can be established or nothing (die())
*
@@ -48,15 +66,7 @@ class OC_DB {
return;
}
if(is_null($backend)){
- $backend=self::BACKEND_MDB2;
- if(class_exists('PDO') && OC_Config::getValue('installed', false)){//check if we can use PDO, else use MDB2 (instalation always needs to be done my mdb2)
- $type = OC_Config::getValue( "dbtype", "sqlite" );
- if($type=='sqlite3') $type='sqlite';
- $drivers=PDO::getAvailableDrivers();
- if(array_search($type,$drivers)!==false){
- $backend=self::BACKEND_PDO;
- }
- }
+ $backend=self::getDBBackend();
}
if($backend==self::BACKEND_PDO){
self::connectPDO();
@@ -423,8 +433,14 @@ class OC_DB {
private static function processQuery( $query ){
self::connect();
// We need Database type and table prefix
- $type = OC_Config::getValue( "dbtype", "sqlite" );
- $prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
+ if(is_null(self::$type)){
+ self::$type=OC_Config::getValue( "dbtype", "oc_" );
+ }
+ $type = self::$type;
+ if(is_null(self::$prefix)){
+ self::$prefix=OC_Config::getValue( "dbtableprefix", "oc_" );
+ }
+ $prefix = self::$prefix;
// differences in escaping of table names ('`' for mysql) and getting the current timestamp
if( $type == 'sqlite' || $type == 'sqlite3' ){
diff --git a/lib/l10n.php b/lib/l10n.php
index 636326f9864..00bff08bf7f 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -261,17 +261,14 @@ class OC_L10N{
public static function findAvailableLanguages($app=null){
$available=array('en');//english is always available
$dir = self::findI18nDir($app);
- if(file_exists($dir)){
- $dh = opendir($dir);
- while(($file = readdir($dh)) !== false){
- if(substr($file, -4, 4) == '.php' and (strlen($file) == 6 || strlen($file) == 9)){
+ if(is_dir($dir)){
+ $files=scandir($dir);
+ foreach($files as $file){
+ if(substr($file, -4, 4) == '.php'){
$i = substr($file, 0, -4);
- if($i != ''){
- $available[] = $i;
- }
+ $available[] = $i;
}
}
- closedir($dh);
}
return $available;
}