summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorSimon Rettberg2015-09-04 19:03:53 +0200
committerSimon Rettberg2015-09-04 19:03:53 +0200
commit5435b8d135d2003945e2361d1c82f583570dfdde (patch)
treeee324f7754e9d9fd1fe4a5b3f3def1e56b8eeb30 /inc
parentFix db update by adding missing return statement... (diff)
downloadslx-admin-5435b8d135d2003945e2361d1c82f583570dfdde.tar.gz
slx-admin-5435b8d135d2003945e2361d1c82f583570dfdde.tar.xz
slx-admin-5435b8d135d2003945e2361d1c82f583570dfdde.zip
Many changes
Diffstat (limited to 'inc')
-rw-r--r--inc/configmodule.inc.php2
-rw-r--r--inc/configtgz.inc.php5
-rw-r--r--inc/download.inc.php32
-rw-r--r--inc/trigger.inc.php9
4 files changed, 39 insertions, 9 deletions
diff --git a/inc/configmodule.inc.php b/inc/configmodule.inc.php
index 4dd7c951..5c613f1b 100644
--- a/inc/configmodule.inc.php
+++ b/inc/configmodule.inc.php
@@ -184,6 +184,7 @@ abstract class ConfigModule
* Module specific version of generate.
*
* @param string $tgz File name of tgz module to write final output to
+ * @param string $parent Parent task of this task
* @return array|boolean true if generation is completed immediately,
* a task struct if some task needs to be run for generation,
* false on error
@@ -307,6 +308,7 @@ abstract class ConfigModule
* Updating the database etc. will happen later through a callback.
*
* @param boolean $deleteOnError if true, the db entry will be deleted if generation failed
+ * @param string $parent Parent task of this task
* @param int $timeoutMs maximum time in milliseconds we wait for completion
* @return string|boolean task id if deferred generation was started,
* true if generation succeeded (without using a task or within $timeoutMs)
diff --git a/inc/configtgz.inc.php b/inc/configtgz.inc.php
index 8ddd4523..b51d2787 100644
--- a/inc/configtgz.inc.php
+++ b/inc/configtgz.inc.php
@@ -38,6 +38,11 @@ class ConfigTgz
return true;
}
+ public function isActive()
+ {
+ return readlink(CONFIG_HTTP_DIR . '/default/config.tgz') === $this->file;
+ }
+
public function getModuleIds()
{
$ret = array();
diff --git a/inc/download.inc.php b/inc/download.inc.php
index 6485ee24..5347e2ee 100644
--- a/inc/download.inc.php
+++ b/inc/download.inc.php
@@ -59,6 +59,38 @@ class Download
}
/**
+ * POST-Download file, obey given timeout in seconds
+ * Return data on success, false on failure
+ * @param string $url URL to fetch
+ * @param array $params POST params to set in body, list of key-value-pairs
+ * @param int $timeout timeout in seconds
+ * @param int $code HTTP response code, or 999 on error
+ */
+ public static function asStringPost($url, $params, $timeout, &$code)
+ {
+ $string = '';
+ foreach ($params as $k => $v) {
+ if (!empty($string)) {
+ $string .= '&';
+ }
+ $string .= $k . '=' . urlencode($v);
+ }
+ $ch = self::initCurl($url, $timeout, $head);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
+ $data = curl_exec($ch);
+ $head = self::getContents($head);
+ if (preg_match('#^HTTP/\d+\.\d+ (\d+) #', $head, $out)) {
+ $code = (int) $out[1];
+ } else {
+ $code = 999;
+ }
+ curl_close($ch);
+ return $data;
+ }
+
+ /**
* Download a file from a URL to file.
*
* @param string $target destination path to download file to
diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php
index 0b1f00c5..9062cafd 100644
--- a/inc/trigger.inc.php
+++ b/inc/trigger.inc.php
@@ -160,15 +160,6 @@ class Trigger
private static function triggerDaemons($action, $parent, &$taskids)
{
- $task = Taskmanager::submit('SyncdaemonLauncher', array(
- 'operation' => $action,
- 'parentTask' => $parent,
- 'failOnParentFail' => false
- ));
- if (isset($task['id'])) {
- $taskids['syncid'] = $task['id'];
- $parent = $task['id'];
- }
$task = Taskmanager::submit('DozmodLauncher', array(
'operation' => $action,
'parentTask' => $parent,