forked from staktrace/bugmash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.php
More file actions
55 lines (47 loc) · 1.53 KB
/
common.php
File metadata and controls
55 lines (47 loc) · 1.53 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
<?php
if (get_magic_quotes_gpc()) {
foreach ($_POST AS $key => $value) {
$_POST[$key] = stripslashes($value);
}
foreach ($_GET AS $key => $value) {
$_GET[$key] = stripslashes($value);
}
foreach ($_COOKIE AS $key => $value) {
$_COOKIE[$key] = stripslashes($value);
}
}
function fail( $message ) {
header( 'HTTP/500 Error!' );
print $message;
exit( 0 );
}
$BUGMASH_DIR = $_SERVER['DOCUMENT_ROOT'] . '/../mailfilters/' . $_SERVER['SERVER_NAME'] . '/bugmash';
include_once( $BUGMASH_DIR . '/bugmash.config.php' );
function updateTags( $newTags ) {
global $_DB;
$stmt = $_DB->prepare( 'DELETE FROM tags WHERE bug=?' );
if ($_DB->errno) fail( 'Error preparing tag deletion: ' . $_DB->error );
foreach ($newTags AS $bug => $tagList) {
$stmt->bind_param( 'i', $bug );
$stmt->execute();
}
$stmt->close();
$stmt = $_DB->prepare( 'INSERT INTO tags (bug, tag) VALUES (?, ?)' );
if ($_DB->errno) fail( 'Error preparing tag insertion: ' . $_DB->error );
foreach ($newTags AS $bug => $tagList) {
foreach (explode( ',', $tagList ) AS $tag) {
$tag = trim( $tag );
if (strlen( $tag ) > 0) {
$stmt->bind_param( 'is', $bug, $tag );
$stmt->execute();
}
}
}
$stmt->close();
}
function escapeHTML( $stuff ) {
$stuff = str_replace( '&', '&', $stuff );
$stuff = str_replace( array( '<', '>', '"' ), array( '<', '>', '"' ), $stuff );
return $stuff;
}
?>