Exemple #1
0
function SSHD_KEYS_SERVER_FORM($error=null){
	$sock=new sockets();
	$ldap=new clladp();
	$hash=$ldap->Hash_GetALLUsers();
	$users=unserialize(base64_decode($sock->getFrameWork("cmd.php?unixLocalUsers=yes")));
	
	$page=CurrentPageName();
	while (list ($uid, $mail) = each ($hash) ){
		if(strpos($uid,"$")>0){continue;}
		$users[$uid]=$uid;
	}
	$users[null]="{select}";
	ksort($users);	
		$userF=Field_array_Hash($users,"uid",$_POST["uid"],null,null,0,"font-size:13px;padding:3px");
	$html="
	<div style='color:red;font-size:14px;font-weight:bold'>$error</div>
	<form method=\"post\" enctype=\"multipart/form-data\" action=\"$page\">
	<table style='width:100%'>
	<tr>
		<td class=legend style='font-size:13px' nowrap>{ArticaProxyServerUsername}:</td>
		<td>$userF</td>	
	</tr>	
	</table>
	$hidden
	<p>
	<input type=\"file\" name=\"id_rsa\" size=\"30\">
	<input type='submit' name='upload' value='{upload_a_file}&nbsp;&raquo;' style='width:190px'>
	</p>
	</form>
	
	";
	$tpl=new templates();
	echo iframe($tpl->_ENGINE_parse_body($html),0,0);
	
}
Exemple #2
0
function export_openvpn_users()
{
    $users = new usersMenus();
    if (!$users->OPENVPN_INSTALLED) {
        events("OpenVPN is not installed", __FUNCTION__, __FILE__, __LINE__);
        return null;
    }
    $sock = new sockets();
    if ($sock->EnableOPenVPNServerMode != 1) {
        events("This server is not an OpenVPN server", __FUNCTION__, __FILE__, __LINE__);
    }
    $ldap = new clladp();
    $users = $ldap->Hash_GetALLUsers();
    while (list($uid, $email) = each($users)) {
        _export_openvpn_single_user($uid);
    }
}
}
if ($argv[1] == "--calendar") {
    plugin_calendar();
    die;
}
if ($argv[1] == "--database") {
    check_databases($bd);
    die;
}
if (!$_GLOBAL["roundcube_installed"]) {
    die("Roundcube is not installed, aborting");
}
$mailhost = $_GLOBAL["fqdn_hostname"];
echo "Get user list....\n";
$ldap = new clladp();
$users = $ldap->Hash_GetALLUsers();
echo count($users) . " user(s) to scan\n";
$q = new mysql();
while (list($num, $val) = each($users)) {
    $user_id = GetidFromUser($bd, $num);
    echo " user \"{$num}\" {$val} user_id={$user_id}\n";
    $sql = "UPDATE identities SET `email`='{$val}', `reply-to`='{$val}' WHERE name='{$num}';";
    echo $sql . "\n";
    $q->QUERY_SQL($sql, $bd);
    if (!$q->ok) {
        echo "{$sql} \n{$q->mysql_error}\n";
    }
    if ($user_id == 0) {
        CreateRoundCubeUser($bd, $num, $val, '127.0.0.1');
        $user_id = GetidFromUser($bd, $num);
    }
Exemple #4
0
function ActiveDirectorySync()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $cache_file = "/etc/artica-postfix/pids/mailboxes.sync.ad.cache";
    $sock = new sockets();
    $unix = new unix();
    $users = new usersMenus();
    if (!$users->cyrus_imapd_installed) {
        echo "Sync client:: Cyrus-imapd is not installed\n";
        return;
    }
    $CyrusToAD = $sock->GET_INFO("CyrusToAD");
    if (!is_numeric($CyrusToAD)) {
        echo "Sync client:: Connexion to Active Directory is not enabled\n";
        return;
    }
    if ($CyrusToAD == 0) {
        echo "Sync client:: Connexion to Active Directory is not enabled\n";
        return;
    }
    $oldpid = @file_get_contents($pidfile);
    if ($unix->process_exists($oldpid)) {
        echo "Sync client:: Already {$oldpid} process executed\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $CyrusToADSyncTime = $sock->GET_INFO("CyrusToADSyncTime");
    if (!is_numeric($CyrusToADSyncTime)) {
        $CyrusToADSyncTime = 10;
    }
    if ($CyrusToADSyncTime < 3) {
        $CyrusToADSyncTime = 3;
    }
    if (!$GLOBALS["FORCE"]) {
        $time = file_time_min($cache_file);
        if ($time < $CyrusToADSyncTime) {
            echo "Sync client:: {$time}Mn, need {$CyrusToADSyncTime}Mn, aborting\n";
            return;
        }
    }
    @unlink($cache_file);
    $ldap = new clladp();
    $hashUsers = $ldap->Hash_GetALLUsers();
    if (!is_array($hashUsers)) {
        echo "Sync client:: no users\n";
    }
    $failed = 0;
    while (list($uid, $emailaddr) = each($hashUsers)) {
        if ($emailaddr == null) {
            echo "Sync client:: {$uid} skip (no email address set)\n";
            continue;
        }
        $cyrus = new cyrus();
        if ($cyrus->MailBoxExists($uid)) {
            echo "Sync client:: {$uid} Mailbox already exists\n";
            continue;
        }
        echo "Sync client:: {$uid} Creating mailbox\n";
        if ($cyrus->CreateMailbox($uid)) {
            $array[$uid] = "OK";
        } else {
            $array[$uid] = "Failed";
            $failed++;
        }
    }
    if (count($array) > 0) {
        while (list($uid, $rr) = each($array)) {
            $result[] = "{$uid}:{$rr}";
        }
        $unix = new unix();
        if ($failed > 0) {
            $failed_text = " {$failed} failed";
        }
        $unix->send_email_events(count($array) . " new created mailboxes {$failed_text} ", @implode("\n", $result), "mailboxes");
    }
}
Exemple #5
0
function popuplate()
{
    $unix = new unix();
    if (!is_dir($unix->LOCATE_ROUNDCUBE_WEBFOLDER())) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Not installed\n";
        }
        die;
    }
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Already pid running {$pid}\n";
        }
        die;
    }
    $timExc = $unix->file_time_min($pidTime);
    if (!$GLOBALS["FORCE"]) {
        if ($timExc < 120) {
            return;
        }
        @unlink($pidTime);
        @file_put_contents($pidTime, time());
    }
    $pid = getmypid();
    @file_put_contents($pidfile, $pid);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Get user list....\n";
    }
    $ldap = new clladp();
    $GLOBALS["LDAP_USERS"] = $ldap->Hash_GetALLUsers();
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: " . count($GLOBALS["LDAP_USERS"]) . " user(s) to scan\n";
    }
    if (!is_array($GLOBALS["LDAP_USERS"])) {
        writelogs("No users stored in local database, aborting ", "MAIN", __FILE__, __LINE__);
        die;
    }
    popuplate_db();
    $q = new mysql();
    $sql = "SELECT mysql_database FROM freeweb WHERE groupware='ROUNDCUBE'";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        popuplate_db($ligne["mysql_database"]);
    }
}