Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
commit | author | age
bbc657 1 <?php
MC 2 /*
3 Copyright (c) 2012, ISPConfig UG
4 Contributors: web wack creations,  http://www.web-wack.at
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
b1a6a5 31 require_once '../../lib/config.inc.php';
MC 32 require_once '../../lib/app.inc.php';
bbc657 33 $app->load('aps_guicontroller');
MC 34
35 // Check the module permissions
36 $app->auth->check_module_permissions('sites');
37
38 $gui = new ApsGUIController($app);
39
40 // An action and ID are required in any case
41 if(!isset($_GET['action'])) die('No action');
42
43 // List of operations which can be performed
44 if($_GET['action'] == 'change_status')
45 {
b1a6a5 46     // Only admins can perform this operation
MC 47     if($_SESSION['s']['user']['typ'] != 'admin') die('For admin use only.');
48
49     // Make sure a valid package ID is given
50     if(!$gui->isValidPackageID($_GET['id'], true)) die($app->lng('Invalid ID'));
51
52     // Change the existing status to the opposite
cc7a82 53     $get_status = $app->db->queryOneRecord("SELECT package_status FROM aps_packages WHERE id = ?", $_GET['id']);
b1a6a5 54     if($get_status['package_status'] == strval(PACKAGE_LOCKED))
MC 55     {
cc7a82 56         $app->db->query("UPDATE aps_packages SET package_status = ? WHERE id = ?", PACKAGE_ENABLED, $_GET['id']);
b1a6a5 57         echo '<div class="swap" id="ir-Yes"><span>'.$app->lng('Yes').'</span></div>';
MC 58     }
59     else
60     {
cc7a82 61         $app->db->query("UPDATE aps_packages SET Package_status = ? WHERE id = ?", PACKAGE_LOCKED, $_GET['id']);
b1a6a5 62         echo '<div class="swap" id="ir-No"><span>'.$app->lng('No').'</span></div>';
MC 63     }
bbc657 64 }
MC 65 else if($_GET['action'] == 'delete_instance')
b1a6a5 66     {
MC 67         // Make sure a valid package ID is given (also corresponding to the calling user)
68         $client_id = 0;
69         $is_admin = ($_SESSION['s']['user']['typ'] == 'admin') ? true : false;
70         if(!$is_admin)
71         {
cc7a82 72             $cid = $app->db->queryOneRecord("SELECT client_id FROM client WHERE username = ?", $_SESSION['s']['user']['username']);
b1a6a5 73             $client_id = $cid['client_id'];
MC 74         }
75
76         // Assume that the given instance belongs to the currently calling client_id. Unimportant if status is admin
77         if(!$gui->isValidInstanceID($_GET['id'], $client_id, $is_admin)) die($app->lng('Invalid ID'));
78
79         // Only delete the instance if the status is "installed" or "flawed"
80         $check = $app->db->queryOneRecord("SELECT id FROM aps_instances
cc7a82 81         WHERE id = ? AND
MC 82         (instance_status = ? OR instance_status = ?)", $_GET['id'], INSTANCE_SUCCESS, INSTANCE_ERROR);
b1a6a5 83         if($check['id'] > 0) $gui->deleteInstance($_GET['id']);
MC 84         //echo $app->lng('Installation_remove');
85         @header('Location:aps_installedpackages_list.php');
86     }
bbc657 87 ?>