index.php 4.87 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

//

class login_index {

pedro_morgan's avatar
pedro_morgan committed
35
36
public $status = '';
private $target = '';
37

pedro_morgan's avatar
pedro_morgan committed
38
39
40
public function render() {
	if(isset($_SESSION['s']['user']) && is_array($_SESSION['s']['user']) && is_array($_SESSION['s']['module'])) {
		die('HEADER_REDIRECT:'.$_SESSION['s']['module']['startpage']);
41
42
43
44
	}
	
	global $app;
	$app->uses('tpl');
pedro_morgan's avatar
pedro_morgan committed
45
46
47
	$app->tpl->newTemplate('form.tpl.htm');
    
    $error = '';    
48
49


pedro_morgan's avatar
pedro_morgan committed
50
	//* Login Formular wurde abgesandt
51
52
53
	if(count($_POST) > 0) {
	//die('Hier');
        // importiere Variablen
pedro_morgan's avatar
pedro_morgan committed
54
55
        $username = $app->db->quote($_POST['username']);
        $passwort = $app->db->quote($_POST['passwort']);
56
57
58
59

        if($username != '' and $passwort != '') {
                $sql = "SELECT * FROM sys_user WHERE USERNAME = '$username' and ( PASSWORT = '".md5($passwort)."' or PASSWORT = password('$passwort') )";
                if($user = $app->db->queryOneRecord($sql)) {
pedro_morgan's avatar
pedro_morgan committed
60
                        if($user['active'] == 1) {
61
62
                                $user = $app->db->toLower($user);
                                $_SESSION = array();
pedro_morgan's avatar
pedro_morgan committed
63
64
65
                                $_SESSION['s']['user'] = $user;
                                $_SESSION['s']['user']['theme'] = $user['app_theme'];
                                $_SESSION['s']['language'] = $user['language'];
66
								
pedro_morgan's avatar
pedro_morgan committed
67
68
69
								if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
									include_once($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php');
									$_SESSION['s']['module'] = $module;
70
71
								}

pedro_morgan's avatar
pedro_morgan committed
72
                                // TODO: What is all this - pedro
73
74
75
76
77
78
79
80
81
82
83
84
85
                                //$site = $app->db->queryOneRecord("SELECT * FROM mb_sites WHERE name = '".$user["site_preset"]."'");
                                //$_SESSION["s"]["site"] = $site;
																
								//header ("HTTP/1.0 307 Temporary redirect");
								//header("Location: http://localhost:8080/ispconfig3_export/interface/web/admin/index.php");
																
                                /*header("Location: ../capp.php?mod=".$user["startmodule"]."&phpsessid=".$_SESSION["s"]["id"]);*/
								//header('Content-type: text/javascript');
								/*echo "<script language=\"javascript\" type=\"text/javascript\">loadContent('admin/users_list.php','')</script>";*/
								//$this->status = 'REDIRECT';
								//$this->target = 'admin:index';
								//return '';
								
pedro_morgan's avatar
pedro_morgan committed
86
								echo 'HEADER_REDIRECT:'.$_SESSION['s']['module']['startpage'];
87
88
89
90
91
92
								//echo 'HEADER_REDIRECT:content.php?s_mod=admin&s_pg=index';
                                exit;
                        } else {
                                $error = $app->lng(1003);
                        }
                } else {
pedro_morgan's avatar
pedro_morgan committed
93
                        //* Incorrect login - Username and password incorrect
94
                        $error = $app->lng(1002);
pedro_morgan's avatar
pedro_morgan committed
95
                        if($app->db->errorMessage != '') $error .= '<br>'.$app->db->errorMessage != '';
96
97
                }
        } else {
pedro_morgan's avatar
pedro_morgan committed
98
                //* Username or password empty
99
100
101
102
                $error = $app->lng(1001);
        }
	}
	if($error != ''){
pedro_morgan's avatar
pedro_morgan committed
103
  		$error = '<table class="error">
104
		<tr>
pedro_morgan's avatar
pedro_morgan committed
105
		<td><strong>Error:</strong><br>'.$error.'</td>
106
107
108
109
110
111
		</tr>
		</table>';
	}



pedro_morgan's avatar
pedro_morgan committed
112
	$app->tpl->setVar('error', $error);
113
114
115
116
117
118
119
120
	$app->tpl->setInclude('content_tpl','login/templates/index.htm');
	$app->tpl_defaults();
	//$app->tpl->pparse();
	
	$this->status = 'OK';
	
	return $app->tpl->grab();
	
pedro_morgan's avatar
pedro_morgan committed
121
} // << end function
122

pedro_morgan's avatar
pedro_morgan committed
123
} // << end class
124

tbrehm's avatar
tbrehm committed
125
?>