-
Notifications
You must be signed in to change notification settings - Fork 9
/
help_vol.php
221 lines (210 loc) · 6.38 KB
/
help_vol.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
<?php
require_once("../inc/util.inc");
require_once("../inc/help_funcs.inc");
require_once("../inc/help_db.inc");
$volid = get_int('volid');
$vol = vol_lookup($volid);
if (!$vol || $vol->hide) {
error_page("No such volunteer");
}
function show_info($vol) {
$x = "Country: $vol->country\n";
if ($vol->availability) {
$x .= "<br>Usual hours: $vol->availability";
}
if ($vol->specialties) {
$x .= "<br>Specialties: $vol->specialties";
}
if ($vol->projects) {
$x .= "<br>Projects: $vol->projects";
}
if ($vol->lang2) {
$x .= "<br>Primary language: $vol->lang1";
$x .= "<br>Secondary language: $vol->lang2";
}
$x .= "<p>";
return $x;
}
function live_contact($vol) {
$skypeid = $vol->skypeid;
echo "
<script>
if (navigator.userAgent.indexOf('MSIE') != -1) {
document.write(
\"<br>If requested, please enable ActiveX controls for this site.<br>\"
);
}
</script>
<p>
<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
";
if ($vol->voice_ok) {
echo "<a href=skype:$skypeid?call onclick=\"return skypeCheck();\"><img align=top border=0 src=images/help/phone_icon_green.gif> Call (voice)</a>
";
}
if ($vol->text_ok) {
echo "<p><a href=skype:$skypeid?chat onclick=\"return skypeCheck();\"><img align=top border=0 src=images/help/skype_chat_icon.png> Chat (text)</a>
";
}
echo " <p>";
help_warning();
echo " <hr> ";
}
function show_rating($vol, $rating) {
echo "
If $vol->name has helped you, please give us your feedback:
<form action=help_vol.php>
<input type=hidden name=volid value=\"$vol->id\">
";
start_table();
row2(
"Rating<br><span class=note>Would you recommend $vol->name to people seeking help with BOINC?</span>",
star_select("rating", $rating->rating)
);
row2("Comments", textarea("comment", $rating->comment));
row2("", "<input type=submit name=rate value=OK>");
end_table();
echo "
</form>
";
}
function email_contact($vol) {
echo "
<form action=help_vol.php>
<input type=hidden name=volid value=\"$vol->id\">
";
start_table();
row2(
"Your email address",
input("email_addr", "")
);
row2("Subject<br><small>Include 'BOINC' in the subject so $vol->name will know it's not spam</small>", input("subject", ""));
row2("Message<br><small>Please include a detailed description of the problem you're experiencing. Include the contents of BOINC's event log if relevant.</small>",
textarea("message", "")
);
row2("", "<input type=submit name=send_email value=OK>");
end_table();
echo "</form>
";
}
$send_email = get_str('send_email', true);
$rate = get_str('rate', true);
$uid = false;
if ($send_email) {
$volid = $_GET['volid'];
$subject = stripslashes($_GET['subject']);
$vol = vol_lookup($volid);
if (!$vol || $vol->hide) {
error_page("No such volunteer $volid");
}
$msg = stripslashes($_GET['message']);
if (!$msg) {
error_page("You must supply a message");
}
$email_addr = $_GET['email_addr'];
$body = "The following message was sent by a BOINC Help user with email address $email_addr.\n";
if (!is_valid_email_syntax($email_addr)) {
error_page("You must specify a valid email address");
}
$reply = "\r\nreply-to: $email_addr";
$body .= "\n\n";
$body .= $msg;
if (!$subject) $subject = "BOINC Help request";
mail($vol->email_addr, $subject, $body, "From: BOINC".$reply);
page_head("Message sent");
echo "Your message has been sent to $vol->name";
page_tail();
} else if ($rate) {
$volid = $_GET['volid'];
$vol = vol_lookup($volid);
if (!$vol) {
error_page("No such volunteer $volid");
}
$x = get_int('rating', true);
if ($x===null) {
error_page("You must supply a rating (0-5 stars)");
}
$rating = (int) $x;
if ($rating < 0 || $rating > 5) {
error_page("bad rating");
}
$comment = stripslashes($_GET['comment']);
$r = null;
$r->volunteerid = $volid;
$r->rating = $rating;
$r->timestamp = time();
$r->comment = $comment;
$r->auth = $uid;
if ($uid) {
$oldr = rating_lookup($r);
if ($oldr) {
$retval = rating_update($r);
if ($retval) vol_update_rating($vol, $oldr, $r);
} else {
$retval = rating_insert($r);
if ($retval) vol_new_rating($vol, $rating);
}
} else {
$retval = rating_insert($r);
if ($retval) vol_new_rating($vol, $rating);
}
if (!$retval) {
echo mysql_error();
error_page("database error");
}
page_head("Feedback recorded");
echo "Your feedback has been recorded. Thanks.
<p>
<a href=help.php>Return to BOINC Help</a>.
";
page_tail();
} else {
page_head("Help Volunteer: $vol->name");
skype_script();
echo show_info($vol);
if (false) {
$status = skype_status($vol->skypeid);
if ($status != $vol->status) {
$vol->status = $status;
$vol->last_check = time();
if (online($vol->status)) {
$vol->last_online = time();
}
vol_update_status($vol);
}
$image = button_image($status);
echo "
<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
<img src=images/help/$image><p>
";
echo "<table class=box cellpadding=8 width=100%><tr><td width=40%>";
if (online($status)) {
live_contact($vol);
}
}
if ($vol->voice_ok || $vol->text_ok) {
echo "<p>";
//echo "<h2>Contact $vol->name by Skype</h2>\n";
skype_call_button($vol);
echo "<p>... or contact $vol->name by email:<p>";
} else {
echo "Contact $vol->name by email:<p>";
}
email_contact($vol);
echo "</td></tr></table><p>\n";
echo "<hr>";
echo "<table class=box cellpadding=8 width=100%><tr><td>";
$rating = null;
if ($uid) {
$rating = rating_vol_auth($vol->id, $uid);
}
if (!$rating) {
$rating = new StdClass;
$rating->rating = -1;
$rating->comment = "";
}
show_rating($vol, $rating);
echo "</td></tr></table>\n";
page_tail();
}
?>