Skip to content

Commit cf93ca8

Browse files
author
Till Brehm
committed
Merge branch 'php-versions-api' into 'stable-3.1'
Remote API: new API call: server_get_php_versions. This function was missing in a multi ISPC server environment, so I've implemented it. It has been tested and is working with both SOAP and REST calls. The result is an array of values that are accepted in the websites 'fastcgi_php_version' parameter. See merge request !425
2 parents 2ccc5f8 + 362728d commit cf93ca8

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

interface/lib/classes/remote.d/server.inc.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,38 @@ public function server_get_app_version($session_id)
222222
return false;
223223
}
224224
}
225+
226+
public function server_get_php_versions($session_id, $server_id, $php)
227+
{
228+
global $app;
229+
if(!$this->checkPerm($session_id, 'server_get')) {
230+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
231+
}
232+
if (!empty($session_id) && !empty($server_id) && !empty($php)) {
233+
$php_versions = array();
234+
235+
$web_config[$server_id] = $app->getconf->get_server_config($server_id, 'web');
236+
$server_type = !empty($web_config[$server_id]['server_type']) ? $web_config[$server_id]['server_type'] : 'apache';
237+
238+
if ($php === 'php-fpm' || ($php === 'hhvm' && $server_type === 'nginx')) {
239+
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ? AND (client_id = 0)", $server_id);
240+
foreach ($php_records as $php_record) {
241+
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
242+
$php_versions[] = $php_version;
243+
}
244+
}
245+
if ($php === 'fast-cgi') {
246+
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ? AND (client_id = 0)", $server_id);
247+
foreach ($php_records as $php_record) {
248+
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
249+
$php_versions[] = $php_version;
250+
}
251+
}
252+
return $php_versions;
253+
} else {
254+
return false;
255+
}
256+
}
225257
}
226258

227259
?>

remoting_client/API-docs/navigation.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ <h3>O</h3>
197197
<p><a href="openvz_vm_update.html" target="content">openvz_vm_update</a></p>
198198
<h3>S</h3>
199199
<p><a href="server_get.html" target="content">server_get</a></p>
200+
<p><a href="server_get_php_versions.html" target="content">server_get_php_versions</a></p>
200201
<p><a href="server_get_serverid_by_ip.html" target="content">server_get_serverid_by_ip</a></p>
201202
<p><a href="sites_aps_available_packages_list.html" target="content">sites_aps_available_packages_list</a></p>
202203
<p><a href="sites_aps_get_package_details.html" target="content">sites_aps_get_package_details</a></p>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2+
<html><head><title>ISPCOnfig 3 remote API documentation</title>
3+
4+
5+
6+
7+
8+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9+
<link rel="stylesheet" type="text/css" href="definitionen.css">
10+
<style type="text/css">
11+
</style></head>
12+
13+
<body>
14+
<div style="padding:40px">
15+
<h1>server_get_php_versions(<span class="var">$session_id</span>, <span class="var">$server_id</span>, <span class="var">$php</span>);</h1>
16+
<br>
17+
<b>Description: </b>
18+
<p class="margin"> Returns the available PHP versions of the given server.</p><br>
19+
<b>Input Variables: </b>
20+
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$server_id</span>, <span class="var">$php</span></p>
21+
<b>Output: </b>
22+
<p class="margin"> Returns an array with the available PHP versions.</p>
23+
</div>
24+
25+
</body></html>

0 commit comments

Comments
 (0)