| Current Path : /var/www/html/mmishra/indem/old/indem/ |
| Current File : /var/www/html/mmishra/indem/old/indem/club_registration.php |
<?php
$tbl = 'club_registration';
$club_arr=array("Literary", "Dramatics", "Music", "Sports", "Dance", "Audio and Lights", "Program Management and Publicity");
$role_arr=array("President", "Secretary", "Treasurer", "Member");
$submit = $_REQUEST["submit"];
$club = $_REQUEST["club"];
$role = $_REQUEST["role"];
$skill = $_REQUEST["skill"];
$url = $_REQUEST["url"];
$login = $user;
$ip = $_SERVER["REMOTE_IP"];
//echo "<center><b>Membership Registration has been closed from 15/01/07 </b></center>";
if ($url == "list"){
echo "<b>Submitted Applications</b>";
echo "<div align='right'><a href='?pg=clubreg'>Application form</a></div>";
$rs = mysql_query("select * from $tbl order by club,role,dated");
$ds = ldap_connect("ldap.iiita.ac.in"); // must be a valid LDAP server!
if ($ds) {
while ($o = mysql_fetch_object($rs)){
if ($club != $o->club){
$i = 0;
if ($club != "") echo "</table>";
$club = $o->club;
echo "<u><b>" . $o->club . "</b></u>
<table class=normal border='1' bgcolor='white' cellspacing='0' width='100%'>
<tr valign='top' bgcolor='#AE9506'>
<td width='2%'>Sr.</td><td width='16%'>Name</td>
<td width='7%'>RollNo</td><td width='10%'>Email</td>
<td width='5%'>Position</td><td width='60%'>Information in support and position</td>
<td>Dated</td></tr>";
}
$i++;
$login = $o->login;
echo "<tr valign='top'><td width='2%'>$i</td>";
$r = @ldap_bind($ds, "uid=$login,dc=iiita,dc=ac,dc=in", $pwd);
if ($r){
$sr = ldap_search($ds, "dc=iiita,dc=ac,dc=in", "(&(uid=$login)(objectclass=posixAccount)(|(host=\*)))");
//if (($e = ldap_get_entries($ds, $sr)) && $e["count"] > 0) $r = 1;
$info = ldap_get_entries($ds, $sr);
$name = ucwords(strtolower(strtr($info[0]["cn"][0],"-"," ")));
$email = $info[0]["mail"][0];
echo "<td width='16%'>" . substr($name,0,strrpos($name," ")) . "</td>
<td>" . substr($name,strrpos($name," ")) . "</td>";
}
echo "<td width='10%'>$email<br><br>IP: $o->remoteip</td>
<td width='5%'>$o->role</td><td width='60%'>$o->skill</td><td>$o->dated</td></tr>";
}
}
if ($i > 0) echo "</table>";
} else {
echo "<b>Application Form</b> (Registration open till 15th Dec, 2007.)";
echo "<div align='right'><a href='inner.php?conf=clubreg&url=list'>Submitted Applications</a></div>";
echo "<form method='post' action='inner.php?conf=clubreg'>";
if ($user){
$ds = @ldap_connect("ldap.iiita.ac.in");
$z = @ldap_bind($ds);
$a = @ldap_search($ds,"dc=iiita,dc=ac,dc=in","uid=$user");
$b = @ldap_get_entries($ds, $a);
$c = $b[0]["dn"];
$name = $b[0]["cn"][0];
@ldap_close($ds);
echo "Hi! " . str_replace("-"," ",$name);
}
echo "<table class=normal><tr><td>Select Club & Position</td><td nowrap><select name='club'>";
foreach ($club_arr as $c)
{
echo "<option value='$c'";
if ($c == $club) echo " selected";
echo ">$c</option>";
}
echo "</select>";
echo "<select name='role'>";
foreach ($role_arr as $r)
{
echo "<option value='$r'";
if ($r == $role) echo " selected";
echo ">$r</option>";
}
echo "</select></td></tr>";
?>
<tr valign='top'><td>Information in support of<br>joining the club and position</td><td><textarea name='skill' rows='10' cols='50'><?=$skill?></textarea></td></tr>
<?php
if ($user){
echo "<tr><td></td><td><input class=btn1 type='submit' name='submit' value='Apply'></td></tr>";
}else{
echo "<tr><th colspan='2'>Please sign in to My IIITA first in order to submit your registration form for the year 2008.</th></tr>";
}
echo "</table><br>";
echo "Only one application will be accepted from an individual for a club where as one may apply for several clubs.";
echo "</form>";
}
if ($submit == "Apply"){
if ($login && $skill){
$rset = mysql_query("select * from club_members where login='$login' and club='$club'");
if (mysql_num_rows($rset)){
echo "<b>Alert...</b> Already applied";
}else{
mysql_query("insert into club_members(login,club,role,skill,dated,remoteip) values('$login','$club','$role','$skill',now(),'".$_SERVER['REMOTE_ADDR']."')");
echo "<b>Thanks $name!</b>";
}
}
}
?>