From 0a02ee3d2c7f18221dbfbe3a8e9440c0002df4a3 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Tue, 18 Feb 2014 08:29:20 -0500
Subject: [PATCH] Implemented: FS#3346 - Add a [web_root] placeholder to cronjob command

---
 interface/web/sites/lib/lang/de_cron.lng     |    1 +
 interface/web/sites/lib/lang/en_cron.lng     |    1 +
 server/plugins-available/cron_plugin.inc.php |    7 ++++++-
 interface/web/sites/templates/cron_edit.htm  |    2 +-
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/interface/web/sites/lib/lang/de_cron.lng b/interface/web/sites/lib/lang/de_cron.lng
index e9fed68..2cb8e17 100644
--- a/interface/web/sites/lib/lang/de_cron.lng
+++ b/interface/web/sites/lib/lang/de_cron.lng
@@ -19,4 +19,5 @@
 $wb['command_error_format'] = 'Das Format für den Befehl ist nicht korrekt. Beachten Sie, dass bei einem URL Aufruf nur http und https erlaubt ist.';
 $wb['unknown_fieldtype_error'] = 'Es wurde ein unbekanntes Feld verwendet.';
 $wb['server_id_error_empty'] = 'Die Server-ID ist leer.';
+$wb['command_hint_txt'] = 'z. B. /var/www/clients/clientX/webY/myscript.sh oder http://www.mydomain.com/path/script.php. Der Platzhalter [web_root] wird durch /var/www/clients/clientX/webY/web ersetzt.';
 ?>
diff --git a/interface/web/sites/lib/lang/en_cron.lng b/interface/web/sites/lib/lang/en_cron.lng
index e6ba8ad..0430aa3 100644
--- a/interface/web/sites/lib/lang/en_cron.lng
+++ b/interface/web/sites/lib/lang/en_cron.lng
@@ -19,4 +19,5 @@
 $wb['command_error_format'] = 'Invalid command format. Please note that in case of an url call only http/https is allowed.';
 $wb['unknown_fieldtype_error'] = 'An unknown field type has been used.';
 $wb['server_id_error_empty'] = 'The server ID is empty.';
+$wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or http://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 ?>
\ No newline at end of file
diff --git a/interface/web/sites/templates/cron_edit.htm b/interface/web/sites/templates/cron_edit.htm
index 1c0cd02..9769334 100644
--- a/interface/web/sites/templates/cron_edit.htm
+++ b/interface/web/sites/templates/cron_edit.htm
@@ -47,7 +47,7 @@
             <div class="ctrlHolder">
                 <label for="command">{tmpl_var name='command_txt'}</label>
                 <input name="command" id="command" value="{tmpl_var name='command'}" size="30" maxlength="255" type="text" class="textInput" />
-                <p class="formHint">e.g. /var/www/clients/client1/myscript.sh or http://www.mydomain.com/path/script.php</p>
+                <p class="formHint">{tmpl_var name='command_hint_txt'}</p>
             </div>
             <div class="ctrlHolder">
                 <p class="label">{tmpl_var name='active_txt'}</p>
diff --git a/server/plugins-available/cron_plugin.inc.php b/server/plugins-available/cron_plugin.inc.php
index 21d72e6..af25ecc 100644
--- a/server/plugins-available/cron_plugin.inc.php
+++ b/server/plugins-available/cron_plugin.inc.php
@@ -205,15 +205,20 @@
 				if($job['type'] == 'url') {
 					$command .= "\t{$cron_config['wget']} -q -t 1 -T 7200 -O /dev/null " . escapeshellarg($job['command']) . " >/dev/null 2>&1";
 				} else {
+					$web_root = '';
 					if($job['type'] == 'chrooted') {
 						if(substr($job['command'], 0, strlen($this->parent_domain['document_root'])) == $this->parent_domain['document_root']) {
 							//* delete the unneeded path part
 							$job['command'] = substr($job['command'], strlen($this->parent_domain['document_root']));
 						}
+					} else {
+						$web_root = $this->parent_domain['document_root'];
 					}
+					$web_root .= '/web';
+					$job['command'] = str_replace('[web_root]', $web_root, $job['command']);
 
 					$command .= "\t";
-					if($job['type'] == 'chrooted' && substr($job['command'], 0, 1) != "/") $command .= $this->parent_domain['document_root'].'/';
+					if($job['type'] != 'chrooted' && substr($job['command'], 0, 1) != "/") $command .= $this->parent_domain['document_root'].'/';
 					$command .= $job['command'];
 				}
 

--
Gitblit v1.9.1