| Current Path : /var/www/html/mmishra/indem/scripts/php/ |
| Current File : /var/www/html/mmishra/indem/scripts/php/unsubscribe_alumni_everyone.php |
<?php
echo "Remove Subscribers from Mailing List\n";
echo "===============================\n\n";
$cat = "alumni";
/*
echo "Course: ";
$course = trim(fgets(STDIN)); // reads one line from STDIN
echo "Specialization: ";
$spec = trim(fgets(STDIN)); // reads one line from STDIN
echo "Batch: ";
$batch = trim(fgets(STDIN)); // reads one line from STDIN
$ou = "$batch,ou=$spec,ou=$course";
*/
echo "ou=$ou,ou=$cat,dc=iiita,dc=ac,dc=in";
$ds = ldap_connect("172.31.1.42");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$sr = ldap_search($ds, "ou=$cat,dc=iiita,dc=ac,dc=in", "(uid=*)");
$info = ldap_get_entries($ds, $sr);
$count = count($info);
sort($info);
$j = 0;
for($i=0; $i < $count-1; $i++){
//echo $info[$i]['dn'];
$val = $info[$i]['uid'][0];
if ($val){
$j++;
$email = $val . "@iiita.ac.in";
$cmd = "/usr/local/bin/ezmlm/ezmlm-unsub /mail/lists/everyone/list $email 2>&1";
shell_exec($cmd);
$cmd = "/usr/local/bin/ezmlm/ezmlm-unsub /mail/lists/student/list $email 2>&1";
shell_exec($cmd);
echo $j . ". " . $email . " removed\n";
}
}
echo "\n\nRemaining subscribers...\n\n";
echo "\nProceed with everyone...";
$z = trim(fgets(STDIN)); // reads one line from STDIN
$cmd = "/usr/local/bin/ezmlm/ezmlm-list /mail/lists/everyone/list 2>&1";
$output = shell_exec($cmd);
echo $output;
echo "\n\nTotal subscribers... ";
echo "\nProceed with everyone...";
$z = trim(fgets(STDIN)); // reads one line from STDIN
$cmd = "/usr/local/bin/ezmlm/ezmlm-list /mail/lists/everyone/list | wc";
$output = shell_exec($cmd);
echo $output;
echo "\n\nProceed with student...";
$z = trim(fgets(STDIN)); // reads one line from STDIN
$cmd = "/usr/local/bin/ezmlm/ezmlm-list /mail/lists/student/list 2>&1";
$output = shell_exec($cmd);
echo $output;
echo "\n\nTotal subscribers... ";
echo "\nProceed with everyone...";
$z = trim(fgets(STDIN)); // reads one line from STDIN
$cmd = "/usr/local/bin/ezmlm/ezmlm-list /mail/lists/student/list | wc";
$output = shell_exec($cmd);
echo $output;
?>