-
Notifications
You must be signed in to change notification settings - Fork 1
/
localcallback.php
115 lines (96 loc) · 2.76 KB
/
localcallback.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
<?php
/*
* License: GPLv3
* Author: Paul Tagliamonte <paultag@whube.com>
* Description:
* For the email daemon.
*/
$d['errors'] = true;
$d['message'] = "Unknown Error";
$ip = $_SERVER['REMOTE_ADDR'];
include( "conf/site.php" );
include( "libs/php/globals.php" );
if ( $ip == $MY_IP ) { // check list
include( "model/bug.php" );
include( "model/user.php" );
include( "model/project.php" );
$b = new bug();
$o = new user();
$p = new project();
$meta = array();
foreach ( $_POST as $key => $value ) {
$meta[clean($key)] = clean($value);
// fuck you, user
}
if (
isset( $meta['email'] ) &&
isset( $meta['project'] ) &&
isset( $meta['title'] ) &&
isset( $meta['body'] )
) {
$o->getByCol( "email", $meta['email'] );
$submitter = $o->getNext();
if ( isset ( $submitter['uID'] ) ) { // OK to insert
$fields = array(
"reporter" => $submitter['uID'],
"owner" => $submitter['uID'],
"title" => $meta['title'],
"descr" => $meta['body']
);
$id = $b->createNew( $fields );
$d['errors'] = false;
$d['message'] = "New bug with ID '" + $id + ";";
if (
isset ( $meta['assign'] )
) {
$o->getByCol( "username", $meta['assign'] );
$row = $o->getNext();
if ( isset ( $row['uID'] ) ) {
$b->updateByPK( $id, array( "owner" => $row['uID'] ) );
$d['message'] .= "\nAssigning this bug to " . $row['real_name'];
} else {
$d['message'] .= "\nCould not find user '" . $meta['assign'] . "' in this DB.";
}
}
if (
isset ( $meta['project'] )
) {
$p->getByCol( "project_name", $meta['project'] );
$row = $p->getNext();
if ( isset ( $row['pID'] ) ) {
$b->updateByPK( $id, array( "package" => $row['pID'] ) );
$d['message'] .= "\nAssigning this bug to project " . $row['project_name'];
} else {
$d['message'] .= "\nCould not find project '" . $meta['project'] . "' in this DB.";
}
}
if (
isset ( $meta['private'] )
) {
$p->getByCol( "private", $meta['private'] );
if ( $meta['private'] ) {
$b->updateByPK( $id, array( "private" => true ) );
$d['message'] .= "\nMarking this bug private";
} else {
$b->updateByPK( $id, array( "private" => false ) );
$d['message'] .= "\nMarking this bug public";
}
}
$d['message'] .= "\n" . $SITE_PREFIX . "t/bug/" . $id;
} else {
$d['errors'] = true;
$d['message'] = "Email ( " . $meta['email'] . " ) Unknown";
}
/*
CREATE A NEW EVENT TYPE THING HERE
*/
} else {
$d['errors'] = true;
$d['message'] = "Missing fields!";
}
} else {
$d['errors'] = true;
$d['message'] = "IP Blacklisted ( " . $ip . " )";
}
echo json_encode($d);
?>