Marius Burkard
2016-07-01 49441bdd0f3ff75d5092d5b832b97ea722a66363
commit | author | age
b5a2f8 1 <?php
T 2 /*
3 Copyright (c) 2005, Till Brehm, projektfarm Gmbh
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without modification,
7 are permitted provided that the following conditions are met:
8
9     * Redistributions of source code must retain the above copyright notice,
10       this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright notice,
12       this list of conditions and the following disclaimer in the documentation
13       and/or other materials provided with the distribution.
14     * Neither the name of ISPConfig nor the names of its contributors
15       may be used to endorse or promote products derived from this software without
16       specific prior written permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
7fe908 30 require_once '../../lib/config.inc.php';
MC 31 require_once '../../lib/app.inc.php';
b5a2f8 32
5c4970 33 /*
V 34  * Check if the logout is forced
35  */
36 $forceLogout = false;
37 if (isset($_GET['l']) && ($_GET['l']== 1)) $forceLogout = true;
38
39 /*
40  * if the admin is logged in as client, then ask, if the admin want't to
41  * "re-login" as admin again
42  */
c6f36f 43 if ((isset($_SESSION['s_old']) && ($_SESSION['s_old']['user']['typ'] == 'admin' || $app->auth->has_clients($_SESSION['s_old']['user']['userid']))) &&
5c4970 44     (!$forceLogout)){
c6f36f 45     $utype = ($_SESSION['s_old']['user']['typ'] == 'admin' ? 'admin' : 'reseller');
0998a3 46     $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_login_as.lng';
MC 47     include $lng_file;
5c4970 48     echo '
V 49         <br /> <br />    <br /> <br />
0998a3 50         '.str_replace('{UTYPE}', $utype, $wb['login_as_or_logout_txt']).'<br />
5c4970 51         <div style="visibility:hidden">
V 52             <input type="text" name="username" value="' . $_SESSION['s_old']['user']['username'] . '" />
b79c5b 53             <input type="password" name="password" value="' . $_SESSION['s_old']['user']['passwort'] .'" />
5c4970 54         </div>
V 55         <input type="hidden" name="s_mod" value="login" />
56         <input type="hidden" name="s_pg" value="index" />
b79c5b 57         <input type="hidden" name="login_as" value="1" />
5c4970 58         <div class="wf_actions buttons">
dc4dd5 59           <button class="btn btn-default formbutton-success" type="button" value="Yes, re-login as ' . $utype . '" data-submit-form="pageForm" data-form-action="/login/index.php"><span>Yes, re-login as ' . $utype . '</span></button>
TB 60           <button class="btn btn-default formbutton-default" type="button" value="No, logout" data-load-content="login/logout.php?l=1"><span>No, logout</span></button>
5c4970 61         </div>
V 62     ';
63     exit;
64 }
65
7fe908 66 $app->plugin->raiseEvent('logout', true);
da1da4 67
b5a2f8 68 $_SESSION["s"]["user"] = null;
T 69 $_SESSION["s"]["module"] = null;
5c4970 70 $_SESSION['s_old'] = null;
b5a2f8 71
T 72 //header("Location: ../index.php?phpsessid=".$_SESSION["s"]["id"]);
73
74 if($_SESSION["s"]["site"]["logout"] != '') {
7fe908 75     echo 'URL_REDIRECT:'.$_SESSION["s"]["site"]["logout"];
b5a2f8 76 } else {
845c3e 77     if($conf["interface_logout_url"] != '') {
7fe908 78         echo 'URL_REDIRECT:'.$conf["interface_logout_url"];
845c3e 79     } else {
7fe908 80         echo 'URL_REDIRECT:index.php';
845c3e 81     }
b5a2f8 82 }
25c72d 83 // Destroy the session completely now
N 84 $_SESSION = array();
85 session_destroy();
86 session_write_close();
87 ?>