Skip to content

Commit 994b0cf

Browse files
committed
php api update set
1 parent 7aa157d commit 994b0cf

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

web/vesta/api/DNS.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,12 @@ public function changeRecordsExecute(Request $request)
366366

367367
return $this->reply($this->status, '');
368368
}
369+
370+
public function getTemplateInfoExecute($request)
371+
{
372+
$spell = $request->getParameter('spell');
373+
$result = Vesta::execute('v_list_sys_user_packages', null, self::TEXT);
374+
return $this->reply(true, $result['data']);
375+
}
376+
369377
}

web/vesta/api/MAIN.class.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ public function getWebDomainParams($data, $global_data)
152152
$ips[$sys_ip] = $sys_ip;
153153
}
154154

155+
if (empty($ips)) {
156+
$ips['No available IP'] = 'No available IP';
157+
}
158+
155159
return array(
156160
'TPL' => array('default' => 'default'),
157161
'ALIAS' => array(),
@@ -260,10 +264,16 @@ public function getDBTypes()
260264
*/
261265
public function getUsersParams($data = array())
262266
{
267+
$pckg = array();
268+
// json
269+
$result = Vesta::execute('v_list_sys_user_packages', null, self::JSON);
270+
foreach ($result['data'] as $pckg_name => $pckg_data) {
271+
$pckg[$pckg_name] = $pckg_name;
272+
}
263273
return array(
264274
'ROLE' => array('user' => 'user'),
265275
'OWNER' => $data['user_names'],
266-
'PACKAGE' => array('default' => 'default'),
276+
'PACKAGE' => $pckg,
267277
'SHELL' => array(
268278
'sh' => 'sh',
269279
'bash' => 'bash',

web/vesta/api/USER.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public function getListExecute(Request $request)
7171
"DATE" => $details['DATE'],
7272
"U_MAIL_BOXES" => rand(1, 10), // TODO: skid
7373
"U_MAIL_FORWARDERS" => rand(1, 10), // TODO: skid
74-
"REPORTS_ENABLED" => $report
74+
"REPORTS_ENABLED" => $report,
75+
"U_WEB_DOMAINS" => $details['U_WEB_DOMAINS']
7576
);
7677
$reply[$user] = array_merge($user_details, $nses);
7778
}
@@ -105,7 +106,7 @@ public function addExecute(Request $request)
105106
$enable_reports = Utils::getCheckboxBooleanValue($spell['REPORTS_ENABLED']);
106107
$reports_result = $this->setUserReports($spell['LOGIN_NAME'], $spell['REPORTS_ENABLED']);
107108
// NS
108-
$ns_result = $this->setNSentries($spell['LOGIN_NAME'], $spell);
109+
//$ns_result = $this->setNSentries($spell['LOGIN_NAME'], $spell);
109110
// Set SHELL
110111
$this->setShell($spell['LOGIN_NAME'], $spell['SHELL']);
111112

web/vesta/app.init.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
<?php
22

3+
$url = "http://dev.vestacp.com:8083/dispatch.php";
4+
$useragent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
5+
$ch = curl_init();
6+
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
7+
curl_setopt($ch, CURLOPT_POST, 1);
8+
curl_setopt($ch, CURLOPT_URL,$url);
9+
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_POST));
10+
$result= curl_exec ($ch);
11+
curl_close ($ch);
12+
die();
13+
14+
315
define('V_ROOT_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
416

517
require_once V_ROOT_DIR . 'config/Config.class.php';

web/vesta/core/Vesta.class.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,22 @@ static function execute($cmd_command, $parameters=array(), $reply = '')
126126
if (!isset($cmd_command)) {
127127
throw new ProtectionException('No function name passed into Vesta::execute'); // TODO: move msg to Messages::
128128
}
129+
130+
$reply_type = $reply;
131+
if ($reply != AjaxHandler::JSON) {
132+
$reply = '';
133+
}
129134

130135
$params = array(
131136
'sudo' => Config::get('sudo_path'),
132137
'functions' => Config::get('vesta_functions_path'),
133138
'parameters' => is_array($parameters) ? "'".implode("' '", $parameters)."'" : $parameters,
134139
'reply' => $reply
135140
);
136-
141+
137142
// e.g.: /usr/bin/sudo /usr/local/vesta/bin/v_list_sys_users vesta json
138143
$cmd = "{$params['sudo']} {$params['functions']}{$cmd_command} {$params['parameters']} {$params['reply']}";
139144
exec($cmd, $output, $return);
140-
141145
$result = 0;
142146
$result = array(
143147
'status' => TRUE,
@@ -169,7 +173,7 @@ static function execute($cmd_command, $parameters=array(), $reply = '')
169173
return $result;
170174
}
171175

172-
if ($reply == 'text') {
176+
if ($reply_type == 'text') {
173177
$result['data'] = implode('', $output);
174178
}
175179
else {

0 commit comments

Comments
 (0)