-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathdaemonconfigadd.php
78 lines (63 loc) · 2.43 KB
/
daemonconfigadd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2012 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id$
*/
$config = isset($_POST['config']) ? $_POST['config'] : NULL;
if($config)
{
foreach($config as $idx => $key)
$config[$idx] = trim($key);
$config['instanceid'] = $_GET['id'];
if($config['var']=='' && $config['description']=='' && $config['value']=='')
{
$SESSION->redirect('?m=daemoninstanceview&id='.$config['instanceid']);
}
if($config['var'] == '')
$error['var'] = trans('Option name is required!');
elseif($DB->GetOne('SELECT id FROM daemonconfig WHERE var=? AND instanceid=?', array($config['var'], $config['instanceid'])))
$error['var'] = trans('Option with specified name exists in that instance!');
if(!$error)
{
$config['value'] = str_replace("\r\n","\n",$config['value']);
$DB->Execute('INSERT INTO daemonconfig (var, instanceid, description, value) VALUES (?,?,?,?)',
array($config['var'],
$config['instanceid'],
$config['description'],
$config['value']));
if(!isset($config['reuse']))
{
$SESSION->redirect('?m=daemoninstanceview&id='.$config['instanceid']);
}
unset($config['var']);
unset($config['value']);
unset($config['description']);
}
}
$instance = $DB->GetRow('SELECT daemoninstances.name AS name, hosts.name AS hostname FROM daemoninstances, hosts WHERE hosts.id=hostid AND daemoninstances.id=?', array($_GET['id']));
$layout['pagetitle'] = trans('New Option for Instance: $a/$b', $instance['name'], $instance['hostname']);
$SESSION->save('backto', $_SERVER['QUERY_STRING']);
$SMARTY->assign('error', $error);
$SMARTY->assign('instanceid', $_GET['id']);
$SMARTY->assign('config', $config);
$SMARTY->display('daemonconfigadd.html');
?>