Skip to content

Commit 3d74e93

Browse files
committed
Fixed jquery controlled chroot/full placeholders
1 parent cb23b73 commit 3d74e93

29 files changed

+79
-45
lines changed

interface/web/sites/ajax_get_json.php

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,33 +251,49 @@
251251

252252
if($type == 'getcronplaceholders') {
253253

254-
$web = $app->db->queryOneRecord("SELECT `domain`, `document_root`, `php_cli_binary`
255-
FROM `web_domain`
256-
LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id
257-
WHERE `domain_id` = ? AND ".$app->tform->getAuthSQL('r'), $web_id);
254+
$web_docroot_client = '';
258255

256+
if($web_id > 0) {
257+
$web = $app->db->queryOneRecord("SELECT wd.sys_groupid, wd.domain, wd.document_root, sp.php_cli_binary
258+
FROM web_domain wd
259+
LEFT JOIN server_php sp ON wd.server_php_id = sp.server_php_id
260+
WHERE wd.domain_id = ? AND ".$app->tform->getAuthSQL('r'), $web_id);
259261

262+
$php_cli_binary = $web['php_cli_binary'];
260263

261-
if($cron_type != 'chrooted') {
262-
$web_docroot_client = $web['document_root'];
263-
} else {
264-
$web_docroot_client = '';
265-
}
264+
$domain = $web['domain'];
266265

267-
if(empty($web['php_cli_binary'])) {
268-
$web['php_cli_binary'] = "/usr/bin/php";
266+
$domain_owner = $app->db->queryOneRecord("SELECT limit_cron_type FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $web["sys_groupid"]);
267+
268+
//* True when the site is assigned to a client
269+
if(isset($domain_owner["limit_cron_type"])) {
270+
if($domain_owner["limit_cron_type"] == 'full') {
271+
$cron_type = 'full';
272+
} else {
273+
$cron_type = 'chrooted';
274+
}
275+
} else {
276+
//* True when the site is assigned to the admin
277+
$cron_type = 'full';
278+
}
279+
280+
if($cron_type != 'chrooted') {
281+
$web_docroot_client = $web['document_root'];
282+
}
269283
}
270284

271285
$web_docroot_client .= '/web';
272286

287+
if(empty($web['php_cli_binary'])) {
288+
$php_cli_binary = "/usr/bin/php";
289+
}
290+
273291
$json = json_encode(array(
274-
'php_cli_binary' => $web['php_cli_binary'],
292+
'php_cli_binary' => $php_cli_binary,
275293
'docroot_client' => $web_docroot_client,
276-
'domain' => $web['domain']
294+
//'cron_type' => $cron_type,
295+
'domain' => $domain
277296
));
278-
279-
280-
281297
}
282298

283299
header('Content-type: application/json');

interface/web/sites/cron_edit.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,30 @@ function onShowEnd() {
8383
LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id
8484
WHERE `domain_id` = ?", $this->dataRecord["parent_domain_id"]);
8585

86+
$php_cli_binary = $parent_domain['php_cli_binary'];
87+
$domain = $parent_domain['domain'];
8688

8789
if($this->dataRecord['type'] != 'chrooted') {
8890
$web_docroot_client = $parent_domain['document_root'];
8991
} else {
9092
$web_docroot_client = '';
9193
}
9294

93-
//TODO: Fix cron type detection
94-
$app->tpl->setVar("cron_type", $this->dataRecord['type']);
95+
if(empty($parent_domain['php_cli_binary'])) {
96+
$php_cli_binary = "/usr/bin/php";
97+
}
98+
99+
if(empty($parent_domain['domain'])) {
100+
$domain = $app->tform->wordbook["domain_not_selected_placeholder_txt"];
101+
}
95102

96103
// web folder is hardcoded to /web:
97104
$web_docroot_client .= '/web';
98105

99106
// Example values for placeholders.
100-
$app->tpl->setVar("php_cli_binary", $parent_domain['php_cli_binary']);
107+
$app->tpl->setVar("php_cli_binary", $php_cli_binary);
101108
$app->tpl->setVar("docroot_client", $web_docroot_client);
102-
$app->tpl->setVar("domain", $parent_domain['domain']);
109+
$app->tpl->setVar("domain", $domain);
103110

104111
parent::onShowEnd();
105112
}

interface/web/sites/lib/lang/ar_cron.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
2323
$wb['command_error_empty'] = 'Command is empty.';
2424
$wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
2525
$wb['log_output_txt'] = 'Log output';
26+
$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
2627
?>

interface/web/sites/lib/lang/bg_cron.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
2323
$wb['command_error_empty'] = 'Command is empty.';
2424
$wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
2525
$wb['log_output_txt'] = 'Log output';
26+
$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
2627
?>

interface/web/sites/lib/lang/br_cron.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ $wb['log_output_txt'] = 'Gravar saída do log';
2424
$wb['limit_cron_url_txt'] = 'Somente URL no Cron. Por favor insira uma URL iniciando com https:// como um comando no Cron.';
2525
$wb['command_error_empty'] = 'Comando a executar está vazio.';
2626
$wb['Cron Job'] = 'Tarefas no Cron';
27+
$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';

interface/web/sites/lib/lang/ca_cron.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'Cron de type URL seulement. Merci d\'introduire une
2323
$wb['command_error_empty'] = 'Le champ Commande à exécuter est vide.';
2424
$wb['command_hint_txt'] = 'par exemple /var/www/clients/clientX/webY/monscript.sh ou https://www.mondomaine.com/chemin/script.php, vous pouvez utiliser la constante [web_root] qui sera remplacée par /var/www/clients/clientX/webY/web.';
2525
$wb['log_output_txt'] = 'Journaliser la sortie du cron';
26+
$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
2627
?>

interface/web/sites/lib/lang/cn_cron.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ $wb['command_hint_txt'] = '例如,/var/www/clients/clientX/webY/myscript.sh
2323
$wb['log_output_txt'] = '记录输出';
2424
$wb['limit_cron_url_txt'] = '仅限 URL 计划任务。请将以 https:// 开头的 URL 作为计划任务命令输入。';
2525
$wb['command_error_empty'] = '命令为空。';
26+
$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
2627
?>

interface/web/sites/lib/lang/cz_cron.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
2323
$wb['command_error_empty'] = 'Command is empty.';
2424
$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.';
2525
$wb['log_output_txt'] = 'Log output';
26+
$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';

interface/web/sites/lib/lang/de_cron.lng

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ $wb['log_output_txt'] = 'Ausgabe loggen';
2424
$wb['limit_cron_url_txt'] = 'Es sind nur URL cronjobs möglich. Der Cron-Befehl muss mit https:// beginnen.';
2525
$wb['command_error_empty'] = 'Befehl ist leer.';
2626
$wb['variables_txt'] = 'Variablen';
27-
?>
27+
$wb['domain_not_selected_placeholder_txt'] = 'Bitte wähle eine Domain aus';
28+

interface/web/sites/lib/lang/dk_cron.lng

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
2323
$wb['command_error_empty'] = 'Command er tom.';
2424
$wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
2525
$wb['log_output_txt'] = 'Log output';
26-
?>
26+
$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';

0 commit comments

Comments
 (0)