示例#1
0
function zapi_ftpaccount_edit($filezilla_root, $username, $newpassword)
{
    if (ShowServerPlatform() == "Windows") {
        # Reset the account password for the FTP account!
        $filezilla_reload = "\"" . $filezilla_root . "FileZilla server.exe\" /reload-config";
        $fzpath = $filezilla_root . "FileZilla Server.xml";
        $fzfile = file_get_contents($fzpath) or die("Can't Open FileZilla configuration file!");
        $startpos = strpos($fzfile, "<User Name=\"" . $username . "\">");
        $endpos = strpos($fzfile, "</User>");
        $endposlength = "</User>";
        $endposlength = strlen($endposlength);
        $fzrecord = substr($fzfile, $startpos, $endpos - $startpos + $endposlength);
        $replacement = "<Option Name=\"Pass\">" . md5($newpassword) . "</Option>";
        $newfzrecord = preg_replace('/<Option Name=\\"Pass\\">.*?<\\/Option>/', $replacement, $fzrecord);
        $fzfile = substr_replace($fzfile, $newfzrecord, $startpos, $endpos - $startpos + $endposlength);
        $filehandle = fopen($fzpath, 'w') or die("Can't Open FileZilla configuration file!");
        if (!fwrite($filehandle, $fzfile)) {
            return false;
        } else {
            return true;
        }
        fclose($filehandle);
    } else {
        # Server is POSIX based - Lets use ProFTPd
        $proftpd_config = "/etc/zpanel/conf/ftp/zftpd.passwd";
        $auto_salt = GenerateRandomPassword(8);
        $ftp_password = crypt($newpassword, '$1$' . $auto_salt . '$');
        $filein = file_get_contents($proftpd_config);
        $startpos = strpos($filein, "# USER:"******"");
        $endpos = strpos($filein, "# END USER:"******"");
        $endposlength = "# END USER:"******"";
        $endposlength = strlen($endposlength);
        $record = substr($filein, $startpos, $endpos - $startpos + $endposlength);
        $split = explode(":1010:1010::", $record);
        $split1 = explode($username . ":", $split[0]);
        $split1[1] = $ftp_password;
        $newrecord = $split1[0] . " " . $username . ":" . $split1[1] . ":1010:1010::" . $split[1];
        $fileout = substr_replace($filein, $newrecord, $startpos, $endpos - $startpos + $endposlength);
        $fh = fopen($proftpd_config, 'w') or die(TriggerLog(1, $b = "zpanel_kernel - cant open proftp config"));
        $write = fwrite($fh, $fileout);
        if ($write) {
            TriggerLog(1, $b = "zpanel_kernel - write to proftp config successful");
        } else {
            TriggerLog(1, $b = "zpanel_kernel - write to proftp config FAILED");
        }
        fclose($fh);
    }
}
示例#2
0
    <form id="frmClients" name="frmClients" method="post" action="runner.php?load=obj_clients">
        <table class="zform">
            <tr>
                <th><?php 
    echo $lang['109'];
    ?>
:</th>
                <td><input type="text" name="inUserName" id="inUserName" maxlength="10" /></td>
            </tr>
            <tr>
                <th><?php 
    echo $lang['116'];
    ?>
:</th>
                <td><input type="text" name="inPassword" id="inPassword" value="<?php 
    echo GenerateRandomPassword(9, 4);
    ?>
" /></td>
            </tr>
            <tr>
                <th><?php 
    echo $lang['110'];
    ?>
:</th>
                <td><select name="inPackage" id="inPackage">
                        <option value="" selected="selected">-- <?php 
    echo $lang['114'];
    ?>
 --</option>
    <?php 
    do {
示例#3
0
function ForgotPassword($name, $email)
{
    $newPwd = GenerateRandomPassword();
    $res = "-1";
    $updatePwd = UpdatePassword($email, $newPwd);
    if ($updatePwd == "A" || $updatePwd == "B" || $updatePwd == "C" || $updatePwd == "D") {
        // write the mail here.
        ForgotPasswordUserMail($email, $name, $newPwd);
        $res = "1";
        // if( == "1") {
        // 	$res = "1";
        // }
        // else {
        // 	$res = "2";
        // }
    } else {
        if ($updatePwd == "-A" || $updatePwd == "-B" || $updatePwd == "-C" || $updatePwd == "-D" || $updatePwd == "0") {
            // could not find the email address in the database.
            $res = "0";
        } else {
            if ($updatePwd == "2") {
                // user has not signed up yet.
                $res = "-2";
            } else {
                // error condition.
                $res = "-1";
            }
        }
    }
    echo $res;
}