コード例 #1
0
    foreach ($ftpDirectories as $directory) {
        if (strtotime($directory) && strtotime($directory) < $deleteDatesBefore) {
            ftp_rmdir($ftpConnection, $directory);
        }
    }
}
//Close FTP Connection
ftp_close($ftpConnection);
/***** Connect to WHM & get the list accounts *****/
$xmlapi = new xmlapi($whmServerIp);
$xmlapi->password_auth($whmAccount, $whmPassword);
$xmlapi->set_port($whmServerPort);
$xmlapi->set_output('array');
//Convert the output to an array
/***** Get Accounts Name *****/
$listAccounts = $xmlapi->listaccts();
if ($listAccounts['status'] == '1') {
    //print_r ($listAccounts); //TEST - Enable to print received accounts list
    /***** Store accounts name in an array *****/
    $accounts = array();
    foreach ($listAccounts['acct'] as $account) {
        $accounts[] = $account['user'];
        //echo $account['user'] . "<br />"; //TEST - Enable to test storing accounts in an array
    }
    /***** Initiate The Backup *****/
    $apiArgs = array();
    foreach ($accounts as $cPanelAccount) {
        if ($useFtp === "1") {
            $apiArgs = array('passiveftp', $ftpHost, $ftpAcct, $ftpPass, $emailNotification, $ftpPort, $ftpPath . '/' . $backupDir);
        } else {
            endApp("FTP is disabled");
コード例 #2
0
# Copyright (c) 2009, cPanel, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided
# that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the
#   following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
#   following disclaimer in the documentation and/or other materials provided with the distribution.
# * Neither the name of the cPanel, Inc. nor the names of its contributors may be used to endorse or promote
#   products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
include "../xmlapi.php";
$ip = getenv('REMOTE_HOST');
# The access has can be found on your server under WHM's "Setup remote access hash" section or at /root/.accesshash
$root_hash = '__ROOT_HASH_GOES_HERE__';
$xmlapi = new xmlapi($ip);
$xmlapi->hash_auth("root", $root_hash);
$xmlapi->return_xml(1);
$xmlapi->set_debug(1);
print $xmlapi->listaccts();