forked from Little-Ben/ChurchRota
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emails.php
109 lines (87 loc) · 3.26 KB
/
emails.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
<?php
/*
This file is part of Church Rota.
Copyright (C) 2011 David Bunce
Church Rota is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Church Rota is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Church Rota. If not, see <http://www.gnu.org/licenses/>.
*/
// Include files, including the database connection
include('includes/dbConfig.php');
include('includes/functions.php');
// Start the session. This checks whether someone is logged in and if not redirects them
session_start();
if (isset($_SESSION['is_logged_in']) || $_SESSION['db_is_logged_in'] == true) {
// Just continue the code
} else {
header('Location: login.php');
exit;
}
if (!isAdmin()) {
header('Location: error.php?no=100&page='.basename($_SERVER['SCRIPT_FILENAME']));
exit;
}
// Handle details from the header
$removeEventID = $_GET['eventID'];
$removeWholeEvent = $_GET['wholeEventID'];
$showmyevents = $_GET['showmyevents'];
$removeSkillID = $_GET['skillID'];
$notifyIndividual = $_GET['notifyIndividual'];
$notifyEveryone = $_GET['notifyEveryone'];
$skillremove = $_GET['skillremove'];
// Method to remove someone from the band
if($skillremove == "true") {
removeEvent($removeWholeEvent);
removeEventPeople($removeEventID, $removeSkillID);
}
if($notifyEveryone == "true") {
notifyEveryone($removeEventID);
}
if(isset($notifyIndividual)) {
notifyIndividual($notifyIndividual, $removeEventID, $removeSkillID);
}
// If the form has been sent, we need to handle the data.
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$editeventID = $_GET['event'];
$editskillID = $_POST['name'];
$editbandID = $_POST['band'];
if($editskillID != "") {
$sql = ("INSERT INTO cr_eventPeople (eventID, skillID) VALUES ('$editeventID', '$editskillID')");
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
// After we have inserted the data, we want to head back to the main page
header('Location: index.php');
exit;
}
if($editbandID != "") {
$sqlbandMembers = "SELECT * FROM cr_bandMembers WHERE bandID = '$editbandID'";
$resultbandMembers = mysql_query($sqlbandMembers) or die(mysql_error());
while($bandMember = mysql_fetch_array($resultbandMembers, MYSQL_ASSOC)) {
$editskillID = $bandMember['skillID'];
$sql = ("INSERT INTO cr_eventPeople (eventID, skillID) VALUES ('$editeventID', '$editskillID')");
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
}
// After we have inserted the data, we want to head back to the main page
header('Location: index.php');
exit;
}
}
$formatting = "light";
$sql = "select * FROM cr_subscriptions";
$result = mysql_query($sql) ;
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo $row['email'];
echo "<br />";
}