if ( !($_POST['status']) || ($_POST['status']=="notsent") ) {
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ip = getenv(HTTP_X_FORWARDED_FOR);
}
else {
$ip = getenv(REMOTE_ADDR);
}
?>
CTIO Network connection request
Network connection request
If you are planning to bring your laptop to CTIO, please take a minute to
fill the following form. For each field the form has, type only the info
we request. If you don't know what are we asking for, please take a look at
the bottom of this page for some hints.
It's very important to:
Do this before you arrive CTIO
Remember to give both MAC addresses for the WIFI and for the ethernet cable port, otherwise one of them won't work
Give accurate data
as failing to comply with any of these points will mean that you won't be able
to connect your laptop to our network when you arrive.
As soon as you press the submit button, you'll be redirected to this page.
Check your email account, the one specified in the form before submitting the
data, as you should receive an email confirmation from us.
In case of problems, please send an email to pgaragorri@ctio.noao.edu
* MAC address: short for Media Access Control address. It's a unique
identifier attached to most forms of networking equipment. It can be easily obtained by
executing the following commands:
| On Windows |
:
| go to Start -> Run . Type cmd to get a command prompt, and type ipconfig /a or ipconfig /all A MAC address should look like this 00-00-FF-06-13-2A |
| On Linux (and MAC also) |
: |
open a terminal, and type /sbin/ifconfig or ifconfig -a A MAC address should look like this 00:00:FF:06:13:2A |
If you have more than one network card on your laptop, please add the other MAC addresses to the MAC address list. Just type the first one, press the <Enter> key, type the second one (and so on).
}
else {
$mymail = "ciss@ctio.noao.edu";
$subject = "CTIO network access request";
$basecommand = "do_ctiodhcp check";
$hostname = "";
# We recover the values, entered by the user, in the form
@extract($_POST);
$fname = preg_replace('/\s+/','',$fname);
$fname = stripslashes($fname);
$lname = preg_replace('/\s+/','',$lname);
$lname = stripslashes($lname);
$email = stripslashes($email);
$macadd = stripslashes($macadd);
# We create the host's name based on the user's email
$temparr = split("@",$email);
$hostname = $temparr[0];
unset($temparr);
# workaround for ghost linebreak in textarea
# bof workaround
$filename = $fname."_dhcpform-request.txt";
$fp = fopen($filename,'w');
fwrite($fp,$macadd);
fclose($fp);
$macadd = "";
$filtercommand = "dos2unix $filename";
$rmcommand = "rm $filename";
exec($filtercommand);
$macadd_arr=file("$filename");
exec($rmcommand);
# eof workaround
if ( sizeof($macadd_arr) > 0 ) {
for ($counter=0; $counter < sizeof($macadd_arr); $counter++) {
$macadd_arr[$counter] = preg_replace('/\s/','',$macadd_arr[$counter]);
$macadd_arr[$counter] = preg_replace('/\n/','',$macadd_arr[$counter]);
$macadd_arr[$counter] = preg_replace('/-/',':',$macadd_arr[$counter]);
$macadd = $macadd.$macadd_arr[$counter]."\n";
}
}
$text = "
The following user is requesting access to our network
\n
Name : $fname $lname
Email : $email
\nMAC adress(es) :
$macadd
Execute the following command(s) on ctiosj:/CTIO/DHCP to check if the user data
already exists in our database:\n
";
if ( sizeof($macadd_arr) > 0 ) {
for ($counter=0; $counter < sizeof($macadd_arr); $counter++) {
$basecommand = "$basecommand \"$fname $lname\" \"$hostname$counter\" \"$email\" \"$macadd_arr[$counter]\"";
$text = $text."\n$basecommand";
$basecommand = "do_ctiodhcp check";
}
}
$_POST['status']="notsent";
mail($mymail,$subject,$text,"From: $fname $lname <$email>");
############################################################
## mail the confirmation
############################################################
$subject = "CTIO: Your access request has been sent!!";
$text = "
Your information was sent to our system administrators. Thanks for letting us know in advance.\n
\n
As you might expect, we would request that you please make sure that your laptop is running the latest security patches and opens up only the minimal number of ports to the outside...\n
\n
Please let us know if you have any problems.";
mail($email,$subject,$text,"From: $mymail");
echo "\n\n\n";
echo "Success\n";
echo "
\n";
echo "Data sent succesfully. Please Check the specified email account for confirmation
\n";
echo "";
echo "";
#header("location:dhcpform.php");
}
?>