-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotices.php
More file actions
123 lines (93 loc) · 3.28 KB
/
Copy pathnotices.php
File metadata and controls
123 lines (93 loc) · 3.28 KB
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
<?php
/*
Runner's Medium
http://www.runnersmedium.com/
password.php
update user password
copyright 2009 Mark Baltrusaitis <http://josieprogramme.com>
*/
require('lib/base.php');
$user->signinCheck(signin());
$friends = $nudges = $updates = null;
// check for submit action
if (isset($_POST['action']) && $_POST['action'] == 'Save') {
// get post data
if (isset($_POST['friends']) && $_POST['friends'] == '1') {
$friends = '1';
} else {
$friends = '0';
}
if (isset($_POST['nudges']) && $_POST['nudges'] == '1') {
$nudges = '1';
} else {
$nudges = '0';
}
if (isset($_POST['updates']) && $_POST['updates'] == '1') {
$updates = '1';
} else {
$updates = '0';
}
// update
$conn->query('UPDATE users SET optin_friends = '.mysql_real_escape_string($friends).',
optin_nudges = '.mysql_real_escape_string($nudges).',
optin_updates = '.mysql_real_escape_string($updates).'
WHERE id = '.mysql_real_escape_string($user->ID()).' LIMIT 1');
// success
$message = 'your notification settings have been saved';
} else {
// select current account data
$result = $conn->query("SELECT optin_friends AS friends, optin_nudges AS nudges, optin_updates AS updates
FROM users WHERE id = ".mysql_real_escape_string($user->ID())." LIMIT 1");
if ($conn->rowCount($result) == 0) {
$error = 'User session error';
} else {
// current settings
$line = $conn->fetchAssoc($result);
$friends = $line['friends'];
$nudges = $line['nudges'];
$updates = $line['updates'];
}
}
$title = 'Runner\'s Medium - Update Password';
require('header.php');
?>
<div id="content">
<ul id="tabnav">
<li><a href="<?php echo root(); ?>settings/account">Account</a></li>
<li><a href="<?php echo root(); ?>settings/editprofile">Edit Profile</a></li>
<li><a href="<?php echo root(); ?>settings/picture">Picture</a></li>
<li><a href="<?php echo root(); ?>settings/password">Password</a></li>
<li><a class="select" href="<?php echo root(); ?>settings/notices">Notices</a></li>
</ul>
<br class="clear" />
<?php messages($error, $message); ?>
<form action="" method="post" id="noticesform">
<fieldset>
<br class="clear" />
<?php if ($friends) {
echo '<input name="friends" id="friends" type="checkbox" class="check" value="1" checked="checked" />';
} else {
echo '<input name="friends" id="friends" type="checkbox" class="check" value="1" />';
} ?>
<label for="friends" class="check">Email me when someone requests my friendship</label>
<br class="clear" />
<?php if ($nudges) {
echo '<input name="nudges" id="nudges" type="checkbox" class="check" value="1" checked="checked" />';
} else {
echo '<input name="nudges" id="nudges" type="checkbox" class="check" value="1" />';
} ?>
<label for="nudges" class="check">Email me when a friend nudges me</label>
<br class="clear" />
<?php if ($updates) {
echo '<input name="updates" id="updates" type="checkbox" class="check" value="1" checked="checked" />';
} else {
echo '<input name="updates" id="updates" type="checkbox" class="check" value="1" />';
} ?>
<label for="updates" class="check">Keep me updated with Runner's Medium news</label>
<input name="action" type="submit" value="Save" class="button" />
</fieldset>
</form>
</div>
<?php
require('footer.php');
?>