summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/database.inc.php2
-rw-r--r--inc/dictionary.inc.php4
-rw-r--r--inc/event.inc.php2
-rw-r--r--inc/taskmanager.inc.php2
-rw-r--r--inc/taskmanagercallback.inc.php5
-rw-r--r--inc/trigger.inc.php7
-rw-r--r--inc/util.inc.php21
7 files changed, 34 insertions, 9 deletions
diff --git a/inc/database.inc.php b/inc/database.inc.php
index 082b13b6..d5992795 100644
--- a/inc/database.inc.php
+++ b/inc/database.inc.php
@@ -132,7 +132,7 @@ class Database
if (!isset(self::$statements[$query])) {
self::$statements[$query] = self::$dbh->prepare($query);
} else {
- self::$statements[$query]->closeCursor();
+ //self::$statements[$query]->closeCursor();
}
$start = microtime(true);
if (self::$statements[$query]->execute($args) === false) {
diff --git a/inc/dictionary.inc.php b/inc/dictionary.inc.php
index ee196f59..fcbfdfb8 100644
--- a/inc/dictionary.inc.php
+++ b/inc/dictionary.inc.php
@@ -17,6 +17,8 @@ class Dictionary
{
self::$languages = array();
foreach (glob('lang/??', GLOB_ONLYDIR) as $lang) {
+ if (!file_exists($lang . '/name.txt') && !file_exists($lang . '/flag.png'))
+ continue;
$lang = basename($lang);
if ($lang === '..')
continue;
@@ -191,6 +193,8 @@ class Dictionary
foreach (self::$languages as $lang) {
if (file_exists("lang/$lang/name.txt")) {
$name = file_get_contents("lang/$lang/name.txt");
+ } else {
+ $name = false;
}
if (!isset($name) || $name === false) {
$name = $lang;
diff --git a/inc/event.inc.php b/inc/event.inc.php
index 66601607..fe59b2b9 100644
--- a/inc/event.inc.php
+++ b/inc/event.inc.php
@@ -111,6 +111,8 @@ class Event
public static function activeConfigChanged()
{
$task = Trigger::ldadp();
+ if ($task === false)
+ return;
TaskmanagerCallback::addCallback($task, 'ldadpStartup');
}
diff --git a/inc/taskmanager.inc.php b/inc/taskmanager.inc.php
index cdc90f55..ed64c613 100644
--- a/inc/taskmanager.inc.php
+++ b/inc/taskmanager.inc.php
@@ -210,7 +210,7 @@ class Taskmanager
private static function readReply($seq)
{
$tries = 0;
- while (($bytes = socket_recvfrom(self::$sock, $buf, 90000, 0, $bla1, $bla2)) !== false || socket_last_error() === 11) {
+ while (($bytes = @socket_recvfrom(self::$sock, $buf, 90000, 0, $bla1, $bla2)) !== false || socket_last_error() === 11) {
$parts = explode(',', $buf, 2);
// Do we have compressed data?
if (substr($parts[0], 0, 3) === '+z:') {
diff --git a/inc/taskmanagercallback.inc.php b/inc/taskmanagercallback.inc.php
index ab8affac..55e01ba2 100644
--- a/inc/taskmanagercallback.inc.php
+++ b/inc/taskmanagercallback.inc.php
@@ -22,7 +22,7 @@ class TaskmanagerCallback
if (is_array($task) && isset($task['id']))
$task = $task['id'];
if (!is_string($task)) {
- EventLog::warning("addCallback: Not a valid task id: $task");
+ EventLog::warning("addCallback: Not a valid task id: $task", print_r(debug_backtrace(), true));
return;
}
$data = array(
@@ -172,7 +172,8 @@ class TaskmanagerCallback
Property::setVmStoreConfig($args);
return;
}
- if ($task['data']['exitCode'] > 0) {
+ // If code is 99 then the script failed to even unmount -- don't change anything
+ if ($task['data']['exitCode'] != 99) {
// Manual mount failed with non-taskmanager related error - reset storage type to reflect situation
$data = Property::getVmStoreConfig();
if (isset($data['storetype'])) {
diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php
index 2af73872..f055d384 100644
--- a/inc/trigger.inc.php
+++ b/inc/trigger.inc.php
@@ -127,14 +127,21 @@ class Trigger
}
if ($storetype === 'nfs') {
$addr = $vmstore['nfsaddr'];
+ $opts = 'nfsopts';
} elseif ($storetype === 'cifs') {
$addr = $vmstore['cifsaddr'];
+ $opts = 'cifsopts';
} else {
+ $opts = null;
$addr = 'null';
}
+ if (isset($vmstore[$opts])) {
+ $opts = $vmstore[$opts];
+ }
return Taskmanager::submit('MountVmStore', array(
'address' => $addr,
'type' => 'images',
+ 'opts' => $opts,
'username' => $vmstore['cifsuser'],
'password' => $vmstore['cifspasswd']
));
diff --git a/inc/util.inc.php b/inc/util.inc.php
index 69eaf941..9f6f63db 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -179,6 +179,13 @@ SADFACE;
$location .= '&' . implode('&', self::$redirectParams);
}
}
+ if (CONFIG_DEBUG) {
+ global $global_start;
+ $duration = microtime(true) - $global_start;
+ error_log('Redirect: ' . round($duration, 3) . 's, '
+ . Database::getQueryCount() . ' queries, '
+ . round(Database::getQueryTime(), 3) . 's query time total');
+ }
Header('Location: ' . $location);
exit(0);
}
@@ -227,18 +234,22 @@ SADFACE;
*
* @param float|int $bytes numeric value of the filesize to make readable
* @param int $decimals number of decimals to show, -1 for automatic
- * @return string human readable string representing the given filesize
+ * @return string human readable string representing the given file size
*/
public static function readableFileSize($bytes, $decimals = -1)
{
+ $bytes = round($bytes);
static $sz = array('Byte', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
$factor = (int)floor((strlen($bytes) - 1) / 3);
- if ($factor == 0) {
+ if ($factor === 0) {
$decimals = 0;
- } elseif ($decimals === -1) {
- $decimals = 2 - floor((strlen($bytes) - 1) % 3);
+ } else {
+ $bytes = $bytes / pow(1024, $factor);
+ if ($decimals === -1) {
+ $decimals = 2 - floor(strlen((int)$bytes) - 1);
+ }
}
- return sprintf("%.{$decimals}f ", $bytes / pow(1024, $factor)) . $sz[$factor];
+ return sprintf("%.{$decimals}f", $bytes) . "\xe2\x80\x89" . $sz[$factor];
}
public static function sanitizeFilename($name)