示例#1
0
function SaveRsyncForm()
{
    $array = unserialize(base64_decode($_GET["rsync_users"]));
    if (is_array($array)) {
        while (list($index, $uid) = each($array)) {
            if ($uid == null) {
                continue;
            }
            $hash[$uid] = $uid;
        }
        if (is_array($hash)) {
            while (list($account, $user) = each($hash)) {
                $final_array[] = $user;
            }
        }
    }
    $rsync = new rsyncd_conf();
    if ($_GET["ShareName"] == null) {
        $_GET["ShareName"] = basename($_GET["SharePath"]);
    }
    $rsync->main_array[$_GET["SharePath"]]["NAME"] = $_GET["ShareName"];
    if (is_array($final_array)) {
        $rsync->main_array[$_GET["SharePath"]]["auth users"] = implode(",", $final_array);
    } else {
        $rsync->main_array[$_GET["SharePath"]]["auth users"] = null;
    }
    $rsync->save();
}
示例#2
0
function create_password_files()
{
    $rsyncd = new rsyncd_conf();
    while (list($path, $key) = each($rsyncd->main_array)) {
        if ($key["secrets file"] == null) {
            writelogs($path . " no secret path, skip", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        @mkdir(dirname($key["secrets file"]), null, true);
        $users = explode(",", $key["auth users"]);
        if (!is_array($users)) {
            continue;
        }
        while (list($index, $uid) = each($users)) {
            if ($uid == null) {
                continue;
            }
            $userClass = new user($uid);
            writelogs($path . " set secret file for {$uid}", __FUNCTION__, __FILE__, __LINE__);
            $rsyncd_secrets[] = "{$uid}:{$userClass->password}";
        }
        if (is_array($rsyncd_secrets)) {
            @file_put_contents($key["secrets file"], implode("\n", $rsyncd_secrets));
            @chmod($key["secrets file"], 0600);
            unset($rsyncd_secrets);
        }
    }
    $rsyncd->save();
}
示例#3
0
function rsync_unshare()
{
    include_once dirname(__FILE__) . "/ressources/class.rsync.inc";
    $rsync = new rsyncd_conf();
    unset($rsync->main_array[$_GET["unshare-rsync"]]);
    $rsync->save();
}