Newer
Older
<?php
include_once("../lib/date.php");
// Config options
$inform="treasurer@sucs.org";
$permission="staff";
// Enable and disable database updating
$enable=TRUE;
// Set next payment date
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
// Only staff can use this page
if (isset($session->groups[$permission])) {
$smarty->assign("staff", TRUE);
// connect to sucs database
$sucsDB = NewADOConnection('postgres8');
$sucsDB->Connect('dbname=sucs');
$sucsDB->SetFetchMode(ADODB_FETCH_ASSOC);
// $sucsDB->debug = true;
// handle updates
if(isset($_POST['uid']) && isset($_POST['lastupdate'])){
// Check data hasn't changed and that nothing is broked
$query = "SELECT * FROM members WHERE uid=? AND lastupdate=?";
$array = array($_POST['uid'], $_POST['lastupdate']);
$data = $sucsDB->GetAll($query,$array);
// If there is only one record then everything is fine
if(sizeof($data)==1){
// get info on currently logged in user
$user = posix_getpwnam($session->username);
// Update record
$record = $data[0];
$query = "UPDATE members";
$query .= " SET paid = ?, lastupdate = DEFAULT, lastedit = ?";
$query .= " WHERE uid = ?";
$array = array($paydate,$user['uid'],$_POST['uid']);
if($enable){
$sucsDB->query($query,$array);
}
// emailing contact (tresurer)
$message = "Account renewal notification\n\n";
$message .= "Account : ".$record['username']."\n";
$message .= "Renewed by: ".$user[name]."\n\n";
$message .= "Regards\n eclipse's script";
mail($inform,"Account Renewal",$message);
// emailing user
$message = "Your Swansea University Computer Society (SUCS) membership has been renewed\n\n";
$message .= "Username: ".$record['username']."\n";
$message .= "If you do not know or have forgotten your password, please email admin@sucs.org to arrange for it to be changed.\n\n";
$message .= "Regards\n The SUCS admin";
$header = "From: admin@sucs.org\r\n";
$header .= "Reply-To: admin@sucs.org";
// Personal account
mail($record['email'],"SUCS account renewal",$message,$header);
// sucs account
mail($record['username']."@sucs.org","SUCS account renewal",$message,$header);
message_flash("Renewed account for: ".htmlentities($record['username']));
}
else{
trigger_error("Number of recored returned: ".sizeof($data).". Expected: 1.", E_USER_ERROR);
}
}
// if sort is specified in GET
if(isset($_GET["sort"])){
$sortoptions = array("username","sid","realname");
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
// and is a valid option
if(in_array($_GET["sort"],$sortoptions,TRUE)){
// use it
$sort=$_GET["sort"];
}
// else use username
else{
$sort='username';
}
$getsort=$sort;
}
//else use username
else{
$sort='username';
}
//Get members details
$query = "SELECT * FROM members, member_type";
$query .= " WHERE paid != ?";
$query .= " AND (type = 1 OR type = 2 OR type = 5)";
$query .= " AND type=member_type.id";
$query .= " ORDER BY type,".$sort;
$array = array($paydate);
$data = $sucsDB->GetAll($query, $array);
$smarty->assign("members", $data);
// set refresh rate
$autorefresh=$_GET["autorefresh"];
// if autorefresh is not 'n'
if($autorefresh!="n"){
// and is a decimal value
if(ctype_digit($autorefresh)){
// use it
$refreshval=$autorefresh;
// set passthrough
$getrefresh=$refreshval;
}
else{
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
$refreshval="10";
}
$optrefresh=$refreshval;
$smarty->assign("refresh", $refreshval);
}
else{
// set passthrough
$getrefresh='n';
$optrefresh='n';
}
// compile passthrough url
// sort
if(isset($getsort)){
$getout="?sort=".$getsort;
}
// autorefresh
if(isset($getrefresh)){
if(isset($getout)){
$getout .= "&autorefresh=".$getrefresh;
}
else{
$getout = "?autorefresh=".$getrefresh;
}
}
// set smarty variables
$smarty->assign("self",$baseurl.$path.$getout);
$smarty->assign("optionrefresh",$optrefresh);
$smarty->assign("optionsort",$sort);
$smarty->assign("paydate",$paydate);
}
$side = $smarty->fetch('membershiprenew-options.tpl');
$body = $smarty->fetch('membershiprenew.tpl');
$smarty->assign('secondary',$side);
$smarty->assign('title', "Renew Memberhip");
$smarty->assign('body', $body);
?>