Skip to content

Commit 6bd166e

Browse files
author
Dominik Müller
committed
Added APS-Funktions to remote API
Removed possibility of reinstalling Instances
1 parent 1ecc750 commit 6bd166e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+696
-200
lines changed

interface/lib/classes/aps_guicontroller.inc.php

Lines changed: 104 additions & 116 deletions
Large diffs are not rendered by default.
Lines changed: 318 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,318 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
--UPDATED 01.2015--
31+
Created by Dominik Müller <info@profi-webdesign.net>
32+
Copyright (c) Profi Webdesign Dominik Müller
33+
34+
*/
35+
36+
class remoting_aps extends remoting {
37+
//* Functions for APS
38+
public function sites_aps_update_package_list($session_id)
39+
{
40+
global $app;
41+
42+
if(!$this->checkPerm($session_id, 'sites_aps_update_package')) {
43+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
44+
return false;
45+
}
46+
47+
$app->load('aps_crawler');
48+
$aps = new ApsCrawler($app, false); // true = Interface mode, false = Server mode
49+
$aps->startCrawler();
50+
$aps->parseFolderToDB();
51+
$aps->fixURLs();
52+
53+
return true;
54+
}
55+
56+
public function sites_aps_available_packages_list($session_id, $params)
57+
{
58+
global $app;
59+
60+
if(!$this->checkPerm($session_id, 'sites_aps_available_packages_list')) {
61+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
62+
return false;
63+
}
64+
65+
$app->load('aps_base');
66+
67+
if (isset($params['all_packages']) && ($params['all_packages'] == true)) {
68+
$where = '(aps_packages.package_status = '.PACKAGE_ENABLED.' OR aps_packages.package_status = '.PACKAGE_LOCKED.')';
69+
}
70+
else {
71+
$where = 'aps_packages.package_status = '.PACKAGE_ENABLED;
72+
}
73+
74+
$sql = 'SELECT * FROM aps_packages WHERE '.$where.' ORDER BY aps_packages.name, aps_packages.version';
75+
return $app->db->queryAllRecords($sql);
76+
}
77+
78+
public function sites_aps_get_package_details($session_id, $primary_id)
79+
{
80+
global $app;
81+
82+
if(!$this->checkPerm($session_id, 'sites_aps_get_package_details')) {
83+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
84+
return false;
85+
}
86+
87+
$app->load('aps_guicontroller');
88+
$gui = new ApsGUIController($app);
89+
90+
// Package-ID Check
91+
if (isset($primary_id))
92+
{
93+
$newest_pkg_id = $gui->getNewestPackageID($pkg_id);
94+
if($newest_pkg_id != 0) $primary_id = $newest_pkg_id;
95+
}
96+
97+
// Make sure an integer ID is given
98+
if (!isset($primary_id) || !$gui->isValidPackageID($primary_id, true)) {// always adminflag
99+
$this->server->fault('package_error', 'The given Package ID is not valid.');
100+
return false;
101+
}
102+
103+
// Get package details
104+
$details = $gui->getPackageDetails($primary_id);
105+
if (isset($details['error'])) {
106+
$this->server->fault('package_error', $details['error']);
107+
return false;
108+
}
109+
110+
// encode all parts to ensure SOAP-XML-format
111+
array_walk_recursive($details, function(&$item, &$key) { $item = utf8_encode($item); } );
112+
// Special handling for license-text because of too much problems with soap-transport
113+
$details['License content'] = base64_encode($details['License content']);
114+
115+
return $details;
116+
}
117+
118+
public function sites_aps_get_package_file($session_id, $primary_id, $filename) {
119+
global $app;
120+
121+
if(!$this->checkPerm($session_id, 'sites_aps_get_package_file')) {
122+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
123+
return false;
124+
}
125+
126+
$app->load('aps_guicontroller');
127+
$gui = new ApsGUIController($app);
128+
129+
// Package-ID Check
130+
if (isset($primary_id))
131+
{
132+
$newest_pkg_id = $gui->getNewestPackageID($pkg_id);
133+
if($newest_pkg_id != 0) $primary_id = $newest_pkg_id;
134+
}
135+
136+
// Make sure an integer ID is given
137+
if (!isset($primary_id) || !$gui->isValidPackageID($primary_id, true)) {// always adminflag
138+
$this->server->fault('package_error', 'The given Package ID is not valid.');
139+
return false;
140+
}
141+
142+
// Get package details
143+
$details = $gui->getPackageDetails($primary_id);
144+
if (isset($details['error'])) {
145+
$this->server->fault('package_error', $details['error']);
146+
return false;
147+
}
148+
149+
// find file in details
150+
$found = false;
151+
if (basename($details['Icon']) == $filename) $found = true;
152+
if (!$found && isset($details['Screenshots']) && is_array($details['Screenshots']))
153+
foreach ($details['Screenshots'] as $screen) { if (basename($screen['ScreenPath']) == $filename) { $found = true; break; } }
154+
155+
if (!$found) {
156+
$this->server->fault('package_error', 'File not found in package.');
157+
return false;
158+
}
159+
160+
return base64_encode(file_get_contents(ISPC_ROOT_PATH.'/web/sites/aps_meta_packages/'.$details['path'].'/'.$filename));
161+
}
162+
163+
public function sites_aps_get_package_settings($session_id, $primary_id)
164+
{
165+
global $app;
166+
167+
if(!$this->checkPerm($session_id, 'sites_aps_get_package_details')) {
168+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
169+
return false;
170+
}
171+
172+
$app->load('aps_guicontroller');
173+
$gui = new ApsGUIController($app);
174+
175+
// Package-ID Check
176+
if (isset($primary_id))
177+
{
178+
$newest_pkg_id = $gui->getNewestPackageID($pkg_id);
179+
if($newest_pkg_id != 0) $primary_id = $newest_pkg_id;
180+
}
181+
182+
// Make sure an integer ID is given
183+
if (!isset($primary_id) || !$gui->isValidPackageID($primary_id, true)) {// always adminflag
184+
$this->server->fault('package_error', 'The given Package ID is not valid.');
185+
return false;
186+
}
187+
188+
// Get package settings
189+
$settings = $gui->getPackageSettings($primary_id);
190+
if (isset($settings['error'])) {
191+
$this->server->fault('package_error', $settings['error']);
192+
return false;
193+
}
194+
195+
// encode all parts to ensure SOAP-XML-format
196+
array_walk_recursive($settings, function(&$item, &$key) { $item = utf8_encode($item); } );
197+
198+
return $settings;
199+
}
200+
201+
public function sites_aps_install_package($session_id, $primary_id, $params)
202+
{
203+
global $app;
204+
205+
if(!$this->checkPerm($session_id, 'sites_aps_install_package')) {
206+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
207+
return false;
208+
}
209+
210+
$app->load('aps_guicontroller');
211+
$gui = new ApsGUIController($app);
212+
213+
// Package-ID Check
214+
if (isset($primary_id))
215+
{
216+
$newest_pkg_id = $gui->getNewestPackageID($primary_id);
217+
if($newest_pkg_id != 0) $primary_id = $newest_pkg_id;
218+
}
219+
220+
// Make sure an integer ID is given
221+
if (!isset($primary_id) || !$gui->isValidPackageID($primary_id, true)) {// always adminflag
222+
$this->server->fault('package_error', 'The given Package ID is not valid.');
223+
return false;
224+
}
225+
226+
// Get package details
227+
$details = $gui->getPackageDetails($primary_id);
228+
if (isset($details['error'])) {
229+
$this->server->fault('package_error', $details['error']);
230+
return false;
231+
}
232+
$settings = $gui->getPackageSettings($primary_id);
233+
if (isset($settings['error'])) {
234+
$this->server->fault('package_error', $settings['error']);
235+
return false;
236+
}
237+
238+
// Check given Site/VHostDomain
239+
if (!isset($params['main_domain'])) {
240+
$this->server->fault('invalid parameters', 'No valid domain given.');
241+
return false;
242+
}
243+
244+
$sql = "SELECT * FROM web_domain WHERE domain = '".$app->db->quote($params['main_domain'])."'";
245+
$domain = $app->db->queryOneRecord($sql);
246+
247+
if (!$domain) {
248+
$this->server->fault('invalid parameters', 'No valid domain given.');
249+
return false;
250+
}
251+
252+
$domains = array($domain['domain']); // Simulate correct Domain-List
253+
$result = $gui->validateInstallerInput($params, $details, $domains, $settings);
254+
if(empty($result['error']))
255+
{
256+
return $gui->createPackageInstance($result['input'], $primary_id);
257+
}
258+
259+
$this->server->fault('invalid parameters', implode('<br />', $result['error']));
260+
return false;
261+
}
262+
263+
public function sites_aps_instance_get($session_id, $primary_id)
264+
{
265+
global $app;
266+
267+
if(!$this->checkPerm($session_id, 'sites_aps_instance_get')) {
268+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
269+
return false;
270+
}
271+
272+
$sql = "SELECT * FROM aps_instances WHERE id = ".$app->functions->intval($primary_id);
273+
$result = $app->db->queryOneRecord($sql);
274+
return $result;
275+
}
276+
277+
public function sites_aps_instance_settings_get($session_id, $primary_id)
278+
{
279+
global $app;
280+
281+
if(!$this->checkPerm($session_id, 'sites_aps_instance_get')) {
282+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
283+
return false;
284+
}
285+
286+
$sql = "SELECT * FROM aps_instances_settings WHERE instance_id = ".$app->functions->intval($primary_id);
287+
$result = $app->db->queryAllRecords($sql);
288+
return $result;
289+
}
290+
291+
public function sites_aps_instance_delete($session_id, $primary_id, $params = array())
292+
{
293+
global $app;
294+
295+
if(!$this->checkPerm($session_id, 'sites_aps_instance_delete')) {
296+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
297+
return false;
298+
}
299+
300+
$app->load('aps_guicontroller');
301+
$gui = new ApsGUIController($app);
302+
303+
// Check if Instance exists
304+
$sql = "SELECT * FROM aps_instances WHERE id = ".$app->functions->intval($primary_id);
305+
$result = $app->db->queryOneRecord($sql);
306+
307+
if (!$result) {
308+
$this->server->fault('instance_error', 'No valid instance id given.');
309+
return false;
310+
}
311+
312+
$gui->deleteInstance($primary_id, (isset($params['keep_database']) && ($params['keep_database'] === true)));
313+
314+
return true;
315+
}
316+
}
317+
318+
?>

interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ function sites_web_vhost_domain_edit($event_name, $page_form) {
212212
if(is_array($records) && !empty($records)){
213213
foreach($records as $rec){
214214
$app->db->datalogUpdate('aps_instances_settings', "value = '".$app->db->quote($page_form->dataRecord["domain"])."'", 'id', $rec['id']);
215-
// Reinstall of package needed?
216-
//$app->db->datalogUpdate('aps_instances', "instance_status = '1'", 'id', $rec['instance_id']);
217215
}
218216
}
219217
unset($records);

interface/web/sites/aps_do_operation.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84,29 +84,4 @@
8484
//echo $app->lng('Installation_remove');
8585
@header('Location:aps_installedpackages_list.php');
8686
}
87-
else if($_GET['action'] == 'reinstall_instance')
88-
{
89-
// Make sure a valid package ID is given (also corresponding to the calling user)
90-
$client_id = 0;
91-
$is_admin = ($_SESSION['s']['user']['typ'] == 'admin') ? true : false;
92-
if(!$is_admin)
93-
{
94-
$cid = $app->db->queryOneRecord("SELECT client_id FROM client WHERE username = '".$app->db->quote($_SESSION['s']['user']['username'])."';");
95-
$client_id = $cid['client_id'];
96-
}
97-
// Assume that the given instance belongs to the currently calling client_id. Unimportant if status is admin
98-
if(!$gui->isValidInstanceID($_GET['id'], $client_id, $is_admin)) die($app->lng('Invalid ID'));
99-
100-
// We've an InstanceID, so make sure the package is not enabled and InstanceStatus is still "installed"
101-
$check = $app->db->queryOneRecord("SELECT aps_instances.id FROM aps_instances, aps_packages
102-
WHERE aps_instances.package_id = aps_packages.id
103-
AND aps_instances.instance_status = ".INSTANCE_SUCCESS."
104-
AND aps_packages.package_status = ".PACKAGE_ENABLED."
105-
AND aps_instances.id = ".$app->db->quote($_GET['id']).";");
106-
if(!$check) die('Check failed'); // normally this might not happen at all, so just die
107-
108-
$gui->reinstallInstance($_GET['id']);
109-
//echo $app->lng('Installation_task');
110-
@header('Location:aps_installedpackages_list.php');
111-
}
11287
?>

interface/web/sites/aps_installedpackages_list.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@
125125
else $ils = $rec['install_location'];
126126
$rec['install_location_short'] = $ils;
127127

128-
// Also set a boolean-like variable for the reinstall button (vlibTemplate doesn't allow variable comparisons)
129-
// For a reinstall, the package must be already installed successfully and (still be) enabled
130-
if($rec['instance_status'] == INSTANCE_SUCCESS && $rec['package_status'] == PACKAGE_ENABLED)
131-
$rec['reinstall_possible'] = 'true';
132128
// Of course an instance can only then be removed when it's not already tagged for removal
133129
if($rec['instance_status'] != INSTANCE_REMOVE && $rec['instance_status'] != INSTANCE_INSTALL)
134130
$rec['delete_possible'] = 'true';

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ $wb['customer_txt'] = 'Client';
66
$wb['status_txt'] = 'Status';
77
$wb['install_location_txt'] = 'Install location';
88
$wb['pkg_delete_confirmation'] = 'Do you really want to delete this installation?';
9-
$wb['pkg_reinstall_confirmation'] = 'Do you really want to reinstall this package with the same settings?';
109
$wb['filter_txt'] = 'Search';
1110
$wb['delete_txt'] = 'Delete';
12-
$wb['reinstall_txt'] = 'Reinstall';
1311
?>

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ $wb['customer_txt'] = 'Client';
66
$wb['status_txt'] = 'Status';
77
$wb['install_location_txt'] = 'Install location';
88
$wb['pkg_delete_confirmation'] = 'Do you really want to delete this installation?';
9-
$wb['pkg_reinstall_confirmation'] = 'Do you really want to reinstall this package with the same settings?';
109
$wb['filter_txt'] = 'Search';
1110
$wb['delete_txt'] = 'Delete';
12-
$wb['reinstall_txt'] = 'Reinstall';
1311
?>

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ $wb['customer_txt'] = 'Client';
66
$wb['status_txt'] = 'Status';
77
$wb['install_location_txt'] = 'Install location';
88
$wb['pkg_delete_confirmation'] = 'Do you really want to delete this installation?';
9-
$wb['pkg_reinstall_confirmation'] = 'Do you really want to reinstall this package with the same settings?';
109
$wb['filter_txt'] = 'Search';
1110
$wb['delete_txt'] = 'Delete';
12-
$wb['reinstall_txt'] = 'Reinstall';
1311
?>

0 commit comments

Comments
 (0)