Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/indem/old/indem/
Upload File :
Current File : /var/www/html/mmishra/indem/old/indem/groupmailid.inc

<span id='title'>Personal Mailing List</span><br><br>
<?php
if (!isset($_SESSION["uid"])) {
        login($pg);
} else {
        $uid = $_SESSION["uid"];
	$gmid = htmlsafe($_REQUEST["gmid"]);
        $description = htmlsafe($_POST["description"]);
        $emails = htmlsafe($_POST["emails"]);
	$cn = "Mailing-list-owner-$uid"; 

	$ds = ldap_connect("ldap.iiita.ac.in");
        //check for duplicacy
	$q = ldap_search($ds, "ou=PersonalList,dc=iiita,dc=ac,dc=in", "uid=$gmid");
	$attr0 = ldap_get_entries($ds, $q);
        $no = $attr0["count"];
	if ($no && ($attr0[0]["cn"][0] <> $cn)) 
		echo "Mailing list $gmid@iiita.ac.in already exists (" . $attr0[0]["cn"][0] . ")";
	else if ($gmid) {
		//count number for uidnumber
		$q = ldap_search($ds, "ou=PersonalList,dc=iiita,dc=ac,dc=in", "(&(uid=*)(objectclass=posixAccount))");
		$attr0 = ldap_get_entries($ds, $q);
		$counter = 7001 + $attr0["count"];
       		//if post then delete/create entry in ldap
		if ($submit == 'SAVE' && $gmid) {
			$info["uid"] = $gmid;
        		$info["cn"] = $cn;
        		$info["description"] = substr($description, 1, strpos($description,'.')) . '(dated ' . date('d-m-Y') . ')';
        		$fmails = explode(",",$emails);
        		$info["gecos"] = "$gmid mailing list";
        		$info["deliveryMode"]= 'nolocals';
        		$info["gidNumber"] = '7001';
        		$info["homeDirectory"] = "/home/$gmid";
        		$info["mail"] = "$gmid@iiita.ac.in";
        		$info["mailHost"] = "mail.iiita.ac.in";
			$no = 0;
        		foreach ($fmails as $email) {
                		$info["mailForwardingAddress"][$no] = $email;
                		$no++;
        		}
        		$info["objectClass"][0] = 'top';
        		$info["objectClass"][1] = 'person';
        		$info["objectClass"][2] = 'posixAccount';
        		$info["objectClass"][3] = 'shadowAccount';
        		$info["objectClass"][4] = 'inetOrgPerson';
        		$info["objectClass"][5] = 'organizationalPerson';
        		$info["objectClass"][6] = 'ibm-auxAccount';
        		$info["objectClass"][7] = 'qmailUser';

        		$info["sn"] = $gmid;
        		$info["uidNumber"] = $counter;
        		$info["userPassword"] = '{CRYPT}' . crypt('iiita');

        		$bd = ldap_bind($ds, "cn=Manager,dc=iiita,dc=ac,dc=in","\$dollfinn");
        		$dn = "uid=$gmid,ou=PersonalList,dc=iiita,dc=ac,dc=in";
			ldap_delete($ds, $dn);
        		if ($emails) ldap_add($ds, $dn, $info);
		
        		if (ldap_error($ds) != 'Success') { 
				foreach ($info as $inf) {
        				echo $inf."<br>";
        			}
				echo "Sorry <b id='alert'>$uid!</b>, there is an error in your posting.<br>";
			} else 
				echo "Thanks <b id='alert'>$uid!</b>, your mailing list $gmid@iiita.ac.in is now ready.<br>";
        		
		}
	}
	//show existing lists
	echo "Mailing list already owned<br>";
       	$q = ldap_search($ds, "dc=iiita,dc=ac,dc=in", "(&(cn=$cn)(objectclass=posixAccount))");
	$attr1 = ldap_get_entries($ds, $q);
	$no = $attr1["count"];
	if (!$gmid) echo "<br><b>[ <u>New</u> ]</b>";
	else echo "<br>[ <a href='?pg=groupmailid&gmid='>New</a> ]";
	for ($i=0; $i < $no; $i++) {
		if ($attr1[$i]["uid"][0] == $gmid) {
			$description = $attr1[0]["description"][0];
			$sr = $attr1[0]["mailforwardingaddress"]["count"];
			for ($j=0; $j < $sr; $j++) {
				$fma .= ',' . $attr1[0]["mailforwardingaddress"][$j];
			}
			echo "<b>[ <u>" . $attr1[$i]["mail"][0] . "</u> ]</b>";
		} else 
			echo "[ <a href='?pg=groupmailid&gmid=" . $attr1[$i]["uid"][0] . "'>" . $attr1[$i]["mail"][0] . '</a> ]';
	}
	if (!$no) echo "[ None ]";
	if (!$emails) $emails = substr($fma,1);	
	echo "<br><hr width='50%'>
	<table class=normal border='0' bgcolor='white' cellspacing='0' width='100%'>
       	<tr><td>Group Name</td><td><input type='text' name='gmid' value='$gmid' size='20'>@iiita.ac.in (no spacial characters pl.)</td></tr>
       	<tr><td>Description</td><td><input type='text' name='description' value='$description' size='50'></td></tr>
       	<tr><td>Members Email</td><td><input type='text' name='emails' value='$emails' size='50'>(separated by , commas)</td></tr>
       	<tr><td></td><td><input type='submit' name='submit' value='SAVE'> To delete a mailing list, clear Members Email and press SAVE</td></tr>
       	</table></form>Press SAVE button to create/update your mailing list.<br>
	<ol>
      	<li>Blank fields may cause problem in list creation.</li>
      	<li>More than one emails in this list can be mentionedseparated by comma.</li>
      	<li>Mailing lists of ALUMNI shall be discarded at due course of time.</li>
      	</ol>";
	ldap_close($ds);
}
?>