File: create_team.php

package info (click to toggle)
boinc 5.4.11-4%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 21,440 kB
  • ctags: 16,986
  • sloc: cpp: 70,682; ansic: 45,747; php: 35,513; xml: 10,487; sh: 9,324; python: 4,291; makefile: 1,958; asm: 1,258; perl: 914; sql: 395; csh: 126; pascal: 124
file content (72 lines) | stat: -rw-r--r-- 1,727 bytes parent folder | download | duplicates (2)
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
<?php

require_once("../inc/db.inc");
require_once("../inc/xml.inc");
require_once("../inc/team.inc");

db_init();

xml_header();

function reply($x) {
    echo "<create_team_reply>
    $x
</create_team_reply>
";
    exit();
}

function error($x) {
    reply("<error>$x</error>");
}

function success($x) {
    reply("<success/>\n$x");
}

$auth = process_user_text($_GET["account_key"]);
$user = lookup_user_auth($auth);
if (!$user) {
    error("no such user");
}

$name = process_user_text(strip_tags($_GET["name"]));
if (strlen($name) == 0) {
    error("must set team name");
}
$name_lc = strtolower($name);

$url = process_user_text(strip_tags($_GET["url"]));
if (strstr($url, "http://")) {
    $url = substr($url, 7);
}

$type = process_user_text(strip_tags($_GET["type"]));
if (strlen($type) == 0) {
    $type = 1;
}
$name_html = process_user_text($_GET["name_html"]);
$description = process_user_text($_GET["description"]);
$country = process_user_text($_GET["country"]);
if (!is_valid_country($country)) {
    $country = 'None';
}

$query = sprintf(
    "insert into team (userid, create_time, name, name_lc, url, type, name_html, description, country, nusers, expavg_time) values (%d, %d, '%s', '%s', '%s', %d, '%s', '%s', '%s', %d, unix_timestamp())",
    $user->id, time(), $name, $name_lc, $url, $type, $name_html, $description, $country, 0
);
$result = mysql_query($query);

if ($result) {
    $teamid = mysql_insert_id();
    $team_result = mysql_query("select * from team where id = $teamid");
    $new_team = mysql_fetch_object($team_result);
    mysql_free_result($team_result);
    user_join_team($new_team, $user);
    success("<team_id>$teamid</team_id>");
} else {
    error("could not create team");
}

?>