defs.php3 4.49 KB
Newer Older
1
2
3
4
<?php
#
# Standard definitions!
#
5
$TBWWW          = "<https://www.emulab.net/tbdb.html>";
6
$TBBASE         = "https://www.emulab.net/";
7
$TBMAIL_CONTROL = "Testbed Ops <testbed-ops@flux.cs.utah.edu>";
8
9
$TBMAIL_WWW     = "Testbed WWW <testbed-www@flux.cs.utah.edu>";
$TBMAIL_APPROVE = "Testbed Approval <testbed-approval@flux.cs.utah.edu>";
10
11
12
13
14
15

#$TBBASE         = "http://golden-gw.ballmoss.com:8080/src/testbed/www/";
#$TBMAIL_CONTROL = "Testbed Ops <stoller@fast.cs.utah.edu>";
#$TBMAIL_WWW     = "Testbed WWW <stoller@fast.cs.utah.edu>";
#$TBMAIL_APPROVE = "Testbed Approval <stoller@fast.cs.utah.edu>";

Leigh B. Stoller's avatar
Leigh B. Stoller committed
16
17
18
$TBDIR          = "/usr/testbed/";
$TBWWW_DIR	= "$TBDIR"."www/";
$TBBIN_DIR	= "$TBDIR"."bin/";
19
20
21
22
23

$TBLIST_DIR     = "/usr/testbed/www/maillist";
$TBLIST_LEADERS = "$TBLIST_DIR"."/leaders.txt";
$TBLIST_USERS   = "$TBLIST_DIR"."/users.txt";

Leigh B. Stoller's avatar
Leigh B. Stoller committed
24
$TBUSER_DIR	= "/users/";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
25
$TBNSSUBDIR     = "nsdir";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
26

27
28
$TBAUTHCOOKIE   = "HashCookie";
$TBAUTHTIMEOUT  = 10800;
29
$TBAUTHDOMAIN   = ".emulab.net";
30
#$TBAUTHDOMAIN   = "golden-gw.ballmoss.com";
31

32
33
34
35
36
#
# Database constants and the like.
#
include("dbdefs.php3");

37
38
39
40
41
42
43
44
45
46
47
48
49
#
# Generate the KEY from a name
#
function GENKEY ($name) {
     return crypt("TB_"."$name"."_USR", strlen($name) + 13);
}

#
# Internal errors should be reported back to the user simply. The actual 
# error information should be emailed to the list for action. The script
# should then terminate if required to do so.
#
function TBERROR ($message, $death) {
50
51
    global $TBMAIL_WWW;

52
    if (1) {
53
54
55
56
57
58
59
60
    mail($TBMAIL_WWW,
         "TESTBED ERROR REPORT",
         "\n".
         "$message\n\n".
         "Thanks,\n".
         "Testbed WWW\n",
         "From: $TBMAIL_WWW\n".
         "Errors-To: $TBMAIL_WWW");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
61
62
63
    }
    # Allow sendmail to run.
    sleep(2); 
64
65
66
67

    if ($death) {
        die("<br><br><h3>".
            "$message <p>".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
68
69
70
            "Could not continue. Please contact ".
            "<a href=\"mailto:testbed-www@flux.cs.utah.edu\">".
                "Testbed WWW (testbed-www@flux.cs.utah.edu)</a>.".
71
72
73
74
            "</h3><p>");
    }
    return 0;
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
75
76
77
78
79
80
81
82
83
84

#
# General user errors should print something warm and fuzzy
#
function USERERROR($message, $death) {
    echo "<h3><br><br>
          $message
          <br>
          </h3>";

85
86
87
88
89
    echo "<p><p>
          Please contact <a href=\"mailto:testbed-ops@flux.cs.utah.edu\"> 
          Testbed Operations (testbed-ops@flux.cs.utah.edu)</a> 
          if you feel this message is an error.";

Leigh B. Stoller's avatar
Leigh B. Stoller committed
90
91
92
93
94
95
96
    if ($death) {
        echo "</body>
              </html>";
        die("");
    }
}

97
98
99
100
101
102
103
104
#
# A form error.
#
function FORMERROR($field) {
    USERERROR("Missing field; ".
              "Please go back and fill out the \"$field\" field!", 1);
}

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#
# Is this user an admin type?
#
function ISADMIN($uid) {
    global $TBDBNAME;

    $query_result = mysql_db_query($TBDBNAME,
	"SELECT admin FROM users WHERE uid='$uid'");

    if (! $query_result) {
        $err = mysql_error();
        TBERROR("Database Error getting admin status for $uid: $err\n", 1);
    }

    $row = mysql_fetch_row($query_result);
    $admin  = $row[0];

    return $admin;
}

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
#
# Spit out a vanilla page header.
#
function PAGEHEADER($title) {
    echo "<html>
          <head>
           <title>$title</title>
           <link rel=\"stylesheet\" href=\"tbstyle.css\" type=\"text/css\">
          </head>
          <body>\n";
}

#
# Spit out a vanilla page footer.
#
function PAGEFOOTER() {
    global $TBBASE;

    echo "<br><hr>
          <center>[<a href=\"$TBBASE\">Network Testbed Home</a>]</center>
          <center>
           [<a href=\"http://www.cs.utah.edu/flux/\">Flux Research Group</a>]
           [<a href=\"http://www.cs.utah.edu/\">School of Computing</a>]
           [<a href=\"http://www.utah.edu/\">University of Utah</a>]
          </center>
         <p align=right>
         <font size=-2>
          Problems? Contact
                    <a href=\"mailto:testbed-ops@flux.cs.utah.edu\"> 
                       Testbed Operations (testbed-ops@flux.cs.utah.edu)</a>
          </body>
          </html>\n";
}

159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#
# Run a program as a user.
#
function SUEXEC($uid, $gid, $cmdandargs, $die) {
    global $TBBIN_DIR;

    $output = array();
    $retval = 0;
    $result = exec("$TBBIN_DIR/suexec $uid $gid $cmdandargs",
		   $output, $retval);

    if ($retval) {
	$foo = "";
        for ($i = 0; $i < count($output); $i++) {
	      $foo = "$foo $output[$i]";
	}
	
	TBERROR("suexec failure. Cmd was \"$cmdandargs\". Error output:\n\n".
                "$foo", $die);
    }
    return $retval;
}

182
183
184
185
#
# Beware empty spaces (cookies)!
# 
require("tbauth.php3");
186
?>