summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorUdo Walter2017-11-21 17:52:04 +0100
committerUdo Walter2017-11-21 17:52:04 +0100
commit653851f35d0eea172c2302e9f1b6f0d03c70096c (patch)
tree42f267c360104b98d2e3199273adba62a1e2023b /inc
parent[internetaccess] reworked permission system from "click and you get error" to... (diff)
parent[statistics] Also adapt MAC-UUID fixing code to mltk changes (diff)
downloadslx-admin-653851f35d0eea172c2302e9f1b6f0d03c70096c.tar.gz
slx-admin-653851f35d0eea172c2302e9f1b6f0d03c70096c.tar.xz
slx-admin-653851f35d0eea172c2302e9f1b6f0d03c70096c.zip
Merge remote-tracking branch 'origin/master' into permission-manager
# Conflicts: # modules-available/backup/templates/_page.html # style/default.css
Diffstat (limited to 'inc')
-rw-r--r--inc/download.inc.php34
-rw-r--r--inc/event.inc.php4
-rw-r--r--inc/module.inc.php14
-rw-r--r--inc/taskmanager.inc.php2
4 files changed, 28 insertions, 26 deletions
diff --git a/inc/download.inc.php b/inc/download.inc.php
index b3496e85..e5764d37 100644
--- a/inc/download.inc.php
+++ b/inc/download.inc.php
@@ -3,29 +3,36 @@
class Download
{
+ private static $curlHandle = false;
+
/**
* Common initialization for download and downloadToFile
* Return file handle to header file
*/
private static function initCurl($url, $timeout, &$head)
{
- $ch = curl_init();
- if ($ch === false)
- Util::traceError('Could not initialize cURL');
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, ceil($timeout / 2));
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_AUTOREFERER, true);
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
- curl_setopt($ch, CURLOPT_MAXREDIRS, 6);
+ if (self::$curlHandle === false) {
+ self::$curlHandle = curl_init();
+ if (self::$curlHandle === false) {
+ Util::traceError('Could not initialize cURL');
+ }
+ curl_setopt(self::$curlHandle, CURLOPT_CONNECTTIMEOUT, ceil($timeout / 2));
+ curl_setopt(self::$curlHandle, CURLOPT_TIMEOUT, $timeout);
+ curl_setopt(self::$curlHandle, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt(self::$curlHandle, CURLOPT_AUTOREFERER, true);
+ curl_setopt(self::$curlHandle, CURLOPT_BINARYTRANSFER, true);
+ curl_setopt(self::$curlHandle, CURLOPT_MAXREDIRS, 6);
+ }
+
+ curl_setopt(self::$curlHandle, CURLOPT_URL, $url);
+
$tmpfile = tempnam('/tmp/', 'bwlp-');
$head = fopen($tmpfile, 'w+b');
unlink($tmpfile);
if ($head === false)
Util::traceError("Could not open temporary head file $tmpfile for writing.");
- curl_setopt($ch, CURLOPT_WRITEHEADER, $head);
- return $ch;
+ curl_setopt(self::$curlHandle, CURLOPT_WRITEHEADER, $head);
+ return self::$curlHandle;
}
/**
@@ -55,7 +62,6 @@ class Download
} else {
$code = 999;
}
- curl_close($ch);
return $data;
}
@@ -89,7 +95,6 @@ class Download
} else {
$code = 999;
}
- curl_close($ch);
return $data;
}
@@ -111,7 +116,6 @@ class Download
curl_setopt($ch, CURLOPT_FILE, $fh);
$res = curl_exec($ch);
$head = self::getContents($head);
- curl_close($ch);
fclose($fh);
if ($res === false) {
@unlink($target);
diff --git a/inc/event.inc.php b/inc/event.inc.php
index a16be97b..66601607 100644
--- a/inc/event.inc.php
+++ b/inc/event.inc.php
@@ -31,10 +31,6 @@ class Event
$ldadpId = Trigger::ldadp();
$ipxeId = Trigger::ipxe();
- Taskmanager::submit('DozmodLauncher', array(
- 'operation' => 'start'
- ));
-
// Check status of all tasks
// Mount vm store
if ($mountId === false) {
diff --git a/inc/module.inc.php b/inc/module.inc.php
index 7211c68c..ec3d095b 100644
--- a/inc/module.inc.php
+++ b/inc/module.inc.php
@@ -29,12 +29,14 @@ class Module
* @param string $moduleId module to check
* @return bool true if module is available and activated
*/
- public static function isAvailable($moduleId)
+ public static function isAvailable($moduleId, $activate = true)
{
$module = self::get($moduleId);
if ($module === false)
return false;
- $module->activate();
+ if ($activate) {
+ $module->activate();
+ }
return !$module->hasMissingDependencies();
}
@@ -56,7 +58,7 @@ class Module
$mod->depsChecked = true;
foreach ($mod->dependencies as $dep) {
if (!self::resolveDepsByName($dep)) {
- error_log("Disabling module {$mod->name}: Dependency $dep failed.");
+ trigger_error("Disabling module {$mod->name}: Dependency $dep failed.", E_USER_WARNING);
$mod->depsMissing = true;
return false;
}
@@ -75,9 +77,9 @@ class Module
foreach (self::$modules as $module) {
if (self::resolveDeps($module)) {
$ret[] = $module;
- }
- if ($sortById) {
- $sort[] = $module->name;
+ if ($sortById) {
+ $sort[] = $module->name;
+ }
}
}
if ($sortById) {
diff --git a/inc/taskmanager.inc.php b/inc/taskmanager.inc.php
index 1920190f..dcf54448 100644
--- a/inc/taskmanager.inc.php
+++ b/inc/taskmanager.inc.php
@@ -96,7 +96,7 @@ class Taskmanager
/**
* Wait for the given task's completion.
*
- * @param type $task task to wait for
+ * @param array $task task to wait for
* @param int $timeout maximum time in ms to wait for completion of task
* @return array result/status of task, or false if it couldn't be queried
*/