forked from joepie91/tasks.php
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit_profile.php
166 lines (121 loc) · 5.21 KB
/
edit_profile.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php require("login.php"); ?>
<!DOCTYPE html>
<html><head>
<title>Shotz - Edit Profile</title>
<meta charset="UTF-8">
<meta name="description" content="Web platform for short movie production tracking">
<meta name="keywords" content="production, management, task, shot, animation, film, movie">
<meta name="author" content="openlab3" >
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" type="text/css" href="css/shotz.css" media="all" />
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="icon" href="favicon.ico" type="image/ico" sizes="64x64">
<style type="text/css">
<?php echo $style; ?>
</style>
</head>
<body style="background-color: #FFF;">
<!-- Fixed navbar -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">Shotz</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="index.php"><i class="fa fa-tasks"></i> Home</a></li>
<li><a href="finished.php"><i class="fa fa-check-square-o"></i> Finished</a></li>
<li><a href="stats.php"><i class="fa fa-bar-chart"></i> Stats</a></li>
<li><a href="admin.php"><i class="fa fa-cogs"></i> Admin</a></li>
<li><a href="trash.php"><i class="fa fa-trash-o"></i> Trash</a></li>
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img class="img-circle" style="margin-top: -15px;margin-bottom: -15px;" src="http://www.gravatar.com/avatar/<?php echo md5(strtolower(trim($_SESSION['ls_email']))); ?>?size=32" alt=""> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="edit_profile.php"><i class="fa fa-user"></i> Edit Profile</a></li>
<li class="divider"></li>
<li><a href="<?php $_SERVER['PHP_SELF']; ?>?ls_logout" rel=""><i class="fa fa-sign-out"></i> Logout</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<div class="row">
<div class="page-header">
<h1>Your Profile</h1>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<form name="form" class="form-signin" method="post">
<p><img class="img-circle" src="http://www.gravatar.com/avatar/<?php echo md5(strtolower(trim($_SESSION['ls_email']))); ?>?size=128" alt=""></p>
<h4><strong><i class="fa fa-user"></i> Username</strong> <?php echo $_SESSION['ls_user'] ?></h4>
<h4><strong><i class="fa fa-envelope-o"></i> Email</strong> <?php echo $_SESSION['ls_email']; ?></h4>
</form>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<form name="form" class="form-signin" method="post">
<h2 class="form-signin-heading">Change Password</h2>
<div class="form-group">
<label class="">New Password</label>
<div class="input-group"><div class="input-group-addon"><i class="fa fa-lock"></i></div>
<input type="text" id="NEW PASSWORD" name="new_pass" value="" class="form-control" placeholder="Enter new password"/>
</div>
</div>
<button class="btn btn-lg btn-danger btn-block" name="submit" value="Submit" type="submit">Change Password</button>
</form>
<?php
$file = file($data);
$name = $_SESSION['ls_user'];
$email = $_SESSION['ls_email'];
$encodename = encode($name,$keyCode);
$encodeemail = encode($email,$keyCode);
$new = $_POST['new_pass'];
$ecodenew = sha1($new);
$break = '||';
if(isset($_POST['submit'])){
$found = false;
foreach ($file as $lineNumber => $line) {
if (strpos($line,$name) !== false) {
$found = true;
$lineNumber++;
break;
}
}
$reading = fopen($data, 'r');
$writing = fopen('myfile.tmp', 'w');
$replaced = false;
while (!feof($reading)) {
$line = fgets($reading);
if (stristr($line,$encodename)) {
$line = "$lineNumber$break$encodename$break$encodeemail$break$ecodenew\n";
$replaced = true;
}
fputs($writing, $line);
}
fclose($reading); fclose($writing);
// might as well not overwrite the file if we didn't replace anything
if ($replaced)
{
echo "Password was successfully changed to <b>$new</b>, Please write/remember your new password";
rename('myfile.tmp', $data);
} else {
unlink('myfile.tmp');
}
}
?>
<div class="form-signin">
<small>To change email address or username, please create a new user.</small>
</div>
</div>
</div>
</div> <!-- /container -->
<?php include 'footer.php';?>