forked from ivannovak/jpmaster77-s-Login-System-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.php
executable file
·140 lines (129 loc) · 4.45 KB
/
main.php
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* Main.php
*
* This is an example of the main page of a website. Here
* users will be able to login. However, like on most sites
* the login form doesn't just have to be on the main page,
* but re-appear on subsequent pages, depending on whether
* the user has logged in or not.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: June 15, 2011 by Ivan Novak
*/
include("include/session.php");
$page = "main.php";
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Jpmaster77's Login Script</title>
<link rel="stylesheet" href="-css/960/reset.css" type="text/css" />
<link rel="stylesheet" href="-css/960/960.css" type="text/css" />
<link rel="stylesheet" href="-css/960/text.css" type="text/css" />
<link rel="stylesheet" href="-css/style.css" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($){
<?php
if(isset($_GET['hash'])){
$hash = $_GET['hash'];
} else {
$hash = '';
}
?>
jp_hash = ('<?php echo $hash; ?>'.length)?'<?php echo $hash; ?>':window.location.hash;
if(jp_hash){
$.ajax({
type: "POST",
url: 'process.php',
data: 'login_with_hash=1&hash='+jp_hash,
success: function(msg){
if(msg){
alert(msg);
window.location.href = "main.php";
} else {
alert("Invalid Hash");
}
}
});
}
});
</script>
</head>
<body>
<div id="main" class="container_12">
<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
if(MAIL){
$q = "SELECT mail_id FROM ".TBL_MAIL." WHERE UserTo = '$session->username' and status = 'unread'";
$numUnreadMail = $database->query($q) or die(mysql_error());
$numUnreadMail = mysql_num_rows($numUnreadMail);
echo "<div class='grid_5'><p class='right'>[<a href=\"mail.php\">You have $numUnreadMail Unread Mail</a>] </p></div>";
}
?>
<h1 class="clear">Logged In</h1>
<p>Welcome <b><?php echo $session->username; ?></b>, you are logged in.</p>
<p>[<a href="userinfo.php?user=<?php echo $session->username; ?>">My Account</a>] [<a href="useredit.php">Edit Account</a>]
<?php
if($session->isAdmin()){
echo "[<a href=\"admin/admin.php\">Admin Center</a>] ";
}
echo "[<a href=\"process.php\">Logout</a>]";?></p><?php
}
else{
?>
<div id="login">
<h1>Login</h1>
<?php
/**
* User not logged in, display the login form.
* If user has already tried to login, but errors were
* found, display the total number of errors.
* If errors occurred, they will be displayed.
*/
if($form->num_errors > 0){
echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?>
<form action="process.php" method="POST">
<p class="textinput">Username: </p><p><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"><?php echo $form->error("user"); ?></p>
<p class="textinput">Password: </p><p><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"><?php echo $form->error("pass"); ?></p>
<p>
<input type="checkbox" name="remember" <?php if($form->value("remember") != ""){ echo "checked"; } ?>>Remember me next time
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login">
</p>
<p><br />[<a href="forgotpass.php">Forgot Password?</a>]</p>
<p>Not registered? <a href="register.php">Sign-Up!</a></p>
<?php
if(EMAIL_WELCOME){
echo "<p>Do you need a Confirmation email? <a href='valid.php'>Send!</a></p>";
}
?>
</form>
</div><!-- #login -->
<?php
}
/**
* Just a little page footer, tells how many registered members
* there are, how many users currently logged in and viewing site,
* and how many guests viewing site. Active users are displayed,
* with link to their user information.
*/
?>
<div id="footer"><br />
<p><b>Member Total:</b><?php echo $database->getNumMembers(); ?>
<br>There are <?php echo $database->num_active_users; ?> registered members and <?php $database->num_active_guests; ?> guests viewing the site.<br><br>
<?php
include("include/view_active.php");
?>
</p>
</div><!-- #footer -->
</div><!-- #main -->
</body>
</html>