forked from BSteelooper/enhanced_contactform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enhanced_contactform.admin.php
154 lines (122 loc) · 5.01 KB
/
enhanced_contactform.admin.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
<?php
/*
* This file is part of pluck, the easy content management system
* Copyright (c) pluck team
* http://www.pluck-cms.org
* Pluck 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.
* See docs/COPYING for the complete license.
*/
//Make sure the file isn't accessed directly.
defined('IN_PLUCK') or exit('Access denied!');
function enhanced_contactform_pages_admin() {
global $lang;
$module_page_admin[] = array(
'func' => 'Main',
'title' => $lang['enhanced_contactform']['main']
);
$module_page_admin[] = array(
'func' => 'activate',
'title' => $lang['enhanced_contactform']['adminpage']
);
return $module_page_admin;
}
function enhanced_contactform_page_admin_main() {
global $lang;
if (!file_exists('data/settings/modules/enhanced_contactform')) {
mkdir('data/settings/modules/enhanced_contactform', 0775, true);
}
//Define some variables.
if (isset($_POST['contactform_name']))
$name = $_POST['contactform_name'];
if (isset($_POST['contactform_email']))
$email = $_POST['contactform_email'];
//If the the contactform was submitted.
if (isset($_POST['submit'])) {
//Check if all fields were filled.
if ($name && $sender) {
//Sanitize the fields and set extra haders.
//N.B. strstr would be neater, but needs PHP >= 5.3 for $before_needle param
if(strpos($name, "\r\n"))
$name = substr($name, 0, strpos($name, "\r\n"));
if(strpos($email, "\r\n"))
$email = substr($email, 0, strpos($sender, "\r\n"));
//Set email headers.
}
//If not all fields were filled.
else
echo '<p class="error">'.$lang['enhanced_contactform']['fields'].'</p>';
}
//Then show the contactform.
?>
<?php
showmenudiv($lang['enhanced_contactform']['adminpage'],$lang['enhanced_contactform']['adminpage'],'data/image/note.png','admin.php?module=enhanced_contactform&page=activate',false);
if (isset($_GET['delete'])) {
unlink ('data/settings/modules/enhanced_contactform/'.$_GET['delete']);
echo $_GET['delete'] . $lang['enhanced_contactform']['deleted'];
redirect ('?module=enhanced_contactform','0');
}
$dir = opendir('data/settings/modules/enhanced_contactform/');
while (false !== ($file = readdir($dir))) {
if(($file !== ".") and ($file !== "..") and ($file != "new")) {
include ('data/settings/modules/enhanced_contactform/'.$file);
echo '
<div class="menudiv" style="margin: 10px;">
<table width="100%">
<tr>
<td width="20"><img src="data/image/website_small.png"></td>
<td>
<span>'.$emailname.'</a></span><br/>
<p>'.$email.'</p>
</td>
<td align="right">
<a href="?module=enhanced_contactform&delete='.$file.'"><img src="data/image/trash_small.png" border="0" title="'.$lang['enhanced_contactform']['delete'].'" alt="'.$lang['enhanced_contactform']['delete'].'"></a>
</td>
</tr>
</table>
</div>';
}
}
}
function enhanced_contactform_page_admin_activate(){
global $lang;
showmenudiv($lang['enhanced_contactform']['backlink'],false,'data/image/restore.png','?module=enhanced_contactform',false);
?>
<div class="menudiv" style="margin: 10px;">
<form method="post" action="" style="margin-top: 5px; margin-bottom: 15px;">
<?php echo $lang['enhanced_contactform']['name']; ?> <br /><input name="name" type="text" value="" /><br />
<?php echo $lang['enhanced_contactform']['email']; ?> <br /><input name="email" type="text" value="" /><br />
<input type="submit" name="Submit" value="<?php echo $lang['enhanced_contactform']['send']; ?>" />
</form>
</div> <?php
if (isset($_POST['Submit'])) {
//Check if everything has been filled in
if((!isset($_POST['name'])) || (!isset($_POST['email']))) { ?>
<span style="color: red;"><?php echo $lang['enhanced_contactform']['fillall']; ?></span>
<?php
// exit;
}
else {
//Then fetch our posted variables
$name = $_POST['name'];
$email = $_POST['email'];
//Check for HTML, and eventually block it
if ((preg_match('/</', $name)) || (preg_match('/>/', $name)) || (preg_match('/</', $email)) || (preg_match('/>/', $email))) { ?>
<span style="color: red;"><?php echo $lang['enhanced_contactform']['nohtml']; ?></span>
<?php } else {
$file=str_replace(" ", "_", $name);
$file=date ("dmY"). '-' . $file;
$fp = fopen ('data/settings/modules/enhanced_contactform/' . $file . '.php',"w");
fputs ($fp, '<?php'."\n"
.'$emailname = "'.$name.'";'."\n"
.'$email = "'.$email.'";'."\n"
.'');
fclose ($fp);
}
}
redirect('?module=enhanced_contactform','0');
}
}
?>