-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmitnewissue.php
274 lines (227 loc) · 10.4 KB
/
submitnewissue.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<head>
<link rel="stylesheet" type="text/css" media="screen" href="stylesheet.css"/>
</head>
<body style='background-color: #FFFFFF;'>
<?php
require_once('../../../wp-load.php');
require_once('bug-library.php');
global $wpdb;
$blpluginpath = WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__)).'/';
$genoptions = get_option('BugLibraryGeneral');
if (isset($_GET['bugcatid']))
{
$bugcatid = $_GET['bugcatid'];
}
else
{
$bugcatid = -1;
}
$valid = -1;
if (isset($_POST['new-bug-submit']))
{
if ($_POST['new-bug-title'] != '' && $_POST['new-bug-desc'] != '')
{
if ($genoptions['showcaptcha'] == true)
{
if (empty($_REQUEST['confirm_code']))
{
$valid = 0;
$validmessage = __('Código de confirmação não preenchido', 'bug-library') . ".";
}
else
{
if ( isset($_COOKIE['Captcha']) )
{
list($Hash, $Time) = explode('.', $_COOKIE['Captcha']);
if ( md5("HFDJUJRPOSKKKLKUEB".$_REQUEST['confirm_code'].$_SERVER['REMOTE_ADDR'].$Time) != $Hash )
{
$valid = 0;
$validmessage = __('Código incorreto.', 'bug-library') . ".";
}
elseif( (time() - 5*60) > $Time)
{
$valid = 0;
$validmessage = __('Código válido por 5 minutos.', 'bug-library') . ".";
}
else
{
$valid = 1;
}
}
else
{
$valid = 0;
$validmessage = __('Cookie do código faltando. Permita cookies nas configurações de seu navegador', 'bug-library') . ".";
}
}
}
else
{
$valid = 1;
}
if ($valid == 1)
{
if ($genoptions['moderatesubmissions'] == true)
$bugvisible = 'private';
elseif ($genoptions['moderatesubmissions'] == false)
$bugvisible = 'publish';
$new_bug_data = array(
'post_status' => $bugvisible,
'post_type' => 'bug-library-bugs',
'post_author' => '',
'ping_status' => get_option('default_ping_status'),
'post_parent' => 0,
'menu_order' => 0,
'to_ping' => '',
'pinged' => '',
'post_password' => '',
'guid' => '',
'post_content_filtered' => '',
'post_excerpt' => '',
'import_id' => 0,
'comment_status' => 'open',
'post_content' => wp_specialchars(stripslashes($_POST['new-bug-desc'])),
'post_date' => date("Y-m-d H:i:s", current_time('timestamp')),
'post_date_gmt' => date("Y-m-d H:i:s", current_time('timestamp', 1)),
'post_excerpt' => '',
'post_title' => wp_specialchars(stripslashes($_POST['new-bug-title'])));
$newbugid = wp_insert_post( $new_bug_data );
$productterm = get_term_by( 'id', $_POST['new-bug-product'], "bug-library-products");
if ($productterm)
{
wp_set_post_terms( $newbugid, $productterm->name, "bug-library-products" );
}
wp_set_post_terms( $newbugid, $genoptions['defaultuserbugstatus'], "bug-library-status" );
wp_set_post_terms( $newbugid, $genoptions['defaultuserbugpriority'], "bug-library-priority" );
$typeterm = get_term_by( 'id', $_POST['new-bug-type'], "bug-library-types");
if ($typeterm)
{
wp_set_post_terms( $newbugid, $typeterm->name, "bug-library-types" );
}
if ($_POST['new-bug-version'] != '')
{
update_post_meta($newbugid, "bug-library-product-version", $_POST['new-bug-version']);
}
if ($_POST['new-bug-reporter-name'] != '')
{
update_post_meta($newbugid, "bug-library-reporter-name", $_POST['new-bug-reporter-name']);
}
if ($_POST['new-bug-reporter-email'] != '')
{
update_post_meta($newbugid, "bug-library-reporter-email", $_POST['new-bug-reporter-email']);
}
update_post_meta($newbugid, "bug-library-resolution-date", "");
update_post_meta($newbugid, "bug-library-resolution-version", "");
$uploads = wp_upload_dir();
if(array_key_exists('attachimage', $_FILES))
{
$target_path = $uploads['basedir'] . "/bug-library/bugimage-" . $newbugid. ".jpg";
$file_path = $uploads['baseurl'] . "/bug-library/bugimage-" . $newbugid . ".jpg";
if (move_uploaded_file($_FILES['attachimage']['tmp_name'], $target_path))
{
update_post_meta($newbugid, "bug-library-image-path", $file_path);
}
}
if ($genoptions['newbugadminnotify'] == true)
{
$adminmail = get_option('admin_email');
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$message = __('A user submitted a new bug to your Wordpress Bug database.', 'bug-library') . "<br /><br />";
$message .= __('Bug Title', 'bug-library') . ": " . wp_specialchars(stripslashes($_POST['new-bug-title'])) . "<br />";
$message .= __('Bug Description', 'bug-library') . ": " . wp_specialchars(stripslashes($_POST['new-bug-desc'])) . "<br />";
$message .= __('Bug Product', 'bug-library') . ": " . wp_specialchars(stripslashes($productterm->name)) . "<br />";
$message .= __('Bug Version', 'bug-library') . ": " . wp_specialchars(stripslashes($_POST['new-bug-version'])) . "<br />";
$message .= __('Bug Type', 'bug-library') . ": " . wp_specialchars(stripslashes($typeterm->name)) . "<br />";
$message .= __('Reporter Name', 'bug-library') . ": " . wp_specialchars(stripslashes($_POST['new-bug-reporter-name'])) . "<br />";
$message .= __('Reporter E-mail', 'bug-library') . ": " . $_POST['new-bug-reporter-email'] . "<br /><br />";
if ($genoptions['moderatesubmissions'] == true)
$message .= "<a href='" . WP_ADMIN_URL . "/edit.php?post_status=private&post_type=bug-library-bugs'>Moderate new bugs</a>";
elseif ($genoptions['moderatesubmissions'] == false)
$message .= "<a href='" . WP_ADMIN_URL . "/edit.php?post_type=bug-library-bugs'>View bugs</a>";
$message .= "<br /><br />" . __('Message generated by', 'bug-library') . " <a href='http://yannickcorner.nayanna.biz/wordpress-plugins/bug-library/'>Bug Library</a> for Wordpress";
if ($genoptions['bugnotifytitle'] != '')
{
$emailtitle = stripslashes($genoptions['bugnotifytitle']);
$emailtitle = str_replace('%bugtitle%', wp_specialchars(stripslashes($_POST['new-bug-title'])), $emailtitle);
}
else
{
$emailtitle = htmlspecialchars_decode(get_option('blogname'), ENT_QUOTES) . " - " . __('New bug added', 'bug-library') . ": " . htmlspecialchars($_POST['new-bug-title']);
}
wp_mail($adminmail, $emailtitle, $message, $headers);
}
}
}
else
{
$valid = 0;
$validmessage = __("Faltando campos obrigatórios. Por favor complete-os.", 'bug-library');
}
}
if (!isset($_POST['new-bug-submit']) || $valid == 0): ?>
<div id='bug-library-newissue-form'>
<?php if ($valid == 0): ?>
<div id='bug-library-invalid'><?php echo $validmessage; ?></div>
<?php endif; ?>
<form name="input" action="<?php echo $blpluginpath; ?>submitnewissue.php" enctype="multipart/form-data" method="POST">
<div id='new-bug-form-title'><h2>Relatar novo problema</h2></div>
<div id='new-bug-title-section'>Título do problema<span id='required'>*</span><br />
<input type='text' id='new-bug-title' name='new-bug-title' size='80' <?php if ($valid == 0) echo "value='" . $_POST['new-bug-title'] . "'"; ?> />
</div>
<div id='new-bug-product-section' class="hidden">Issue Product <span id='required'>*</span><br />
<?php $products = get_terms('bug-library-products', 'orderby=name&hide_empty=0');
if ($products) : ?>
<select id='new-bug-product' name='new-bug-product'>
<?php foreach ($products as $product):
if ($product->term_id == $bugcatid) { $selectedstring = " selected='selected'";} else {$selectedstring = '';} ?>
<option value="<?php echo $product->term_id; ?>" <?php echo $selectedstring; ?>><?php echo $product->name; ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>
</div>
<div id='new-bug-version-section' class="hidden">Version Number <span id='required'>*</span><br />
<input type='text' id='new-bug-version' name='new-bug-version' size='16' <?php if ($valid == 0) echo "value='" . $_POST['new-bug-version'] . "'"; ?> />
</div>
<div id='new-bug-type-section' class="hidden">Issue Type <span id='required'>*</span><br />
<?php $types = get_terms('bug-library-types', 'orderby=name&hide_empty=0');
if ($types) : ?>
<select id='new-bug-type' name='new-bug-type'>
<?php foreach ($types as $type): ?>
<option value="<?php echo $type->term_id; ?>"><?php echo $type->name; ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>
</div>
<div id='new-bug-desc-section'>
Descrição <span id='required'>*</span><br />
<textarea cols="60" rows="10" name="new-bug-desc"><?php if ($valid == 0) echo $_POST['new-bug-desc']; ?></textarea>
</div>
<div id='new-bug-name-section'> Seu nome
<?php if ($genoptions['requirename'] == false) echo " (optional)"; else echo " <span id='required'>*</span>"; ?><br />
<input type='text' id='new-bug-reporter-name' name='new-bug-reporter-name' size='60' <?php if ($valid == 0) echo "value='" . $_POST['new-bug-reporter-name'] . "'"; ?> />
</div>
<div id='new-bug-email-section'>
Seu e-mail<?php if ($genoptions['requireemail'] == false) echo " (optional, for update notifications only)"; else echo " <span id='required'>*</span>";?><br />
<input type='text' id='new-bug-reporter-email' name='new-bug-reporter-email' size='60' <?php if ($valid == 0) echo "value='" . $_POST['new-bug-reporter-email'] . "'"; ?> />
</div>
<?php if ($genoptions['allowattach']): ?> Anexar arquivo
<br />
<input type="file" name="attachimage" id="attachimage" />
<?php endif; ?>
<?php if ($genoptions['showcaptcha']): ?>
<div id='new-bug-captcha'><span id='captchaimage'><img src='<?php echo $blpluginpath . "captcha/easycaptcha.php"; ?>' /></span><br />
<?php _e('Enter code from above image', 'bug-library'); ?><input type='text' name='confirm_code' />
</div>
<?php endif; ?>
<input type="submit" id='new-bug-submit' name='new-bug-submit' value="Submit" />
</form>
</div>
<?php elseif ($valid == 1): ?>
<div id='bug-library-submissionaccepted'>
<h2>Obrigado pelo envio.</h2><br /><br />
<?php if ($genoptions['moderatesubmissions'] == 'true') echo "Seu bug aparecerá no site assim que aprovado pela moderação.<br /><br />"; ?>
Clique <a href='<?php echo $blpluginpath; ?>submitnewissue.php'>aqui</a> para enviar um novo problema ou feche a janela para continuar a navegação.
</div>
<?php endif; ?>
</body>