Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- $startMEM = memory_get_usage();
- set_time_limit(350);
- include "cpaneluapi.class.php";
- include "extras.php"; # Extra Misc functions
- $arquivoClientes = $_SERVER['argv'][1] . ".php"; # Get the arg from Cron command and insert .php extension.
- include $arquivoClientes; # Here i include the file with my array. I have several files that are loaded in different days.
- define('mTIME', tempoExecucao());
- #[Cron Command] php /home/<cpuser>/script/cpanel-backup.php # Itยดs outside public dir.
- ########################################################################################################
- if( ($arquivoClientes == "clientesLARGE1.php") || ($arquivoClientes == "clientesLARGE2.php") ){
- $dir = 'BKP-(PESADO)' . date('d-m-Y_H-i-s');
- delTree("/home/<cpuser>/public_html/ftpdir",false);
- sleep(1);
- mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir);
- }
- if( $arquivoClientes == "clientes1.php" ){
- $dir = 'BKP-' . date('d-m-Y_H-i-s')."_(1)";
- delTree("/home/<cpuser>/public_html/ftpdir",false);
- sleep(1);
- mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir);
- }
- if( $arquivoClientes == "clientes2.php" ){
- $dir = 'BKP-' . date('d-m-Y_H-i-s');
- #delTree("/home/<cpuser>/public_html/ftpdir",false);
- sleep(1);
- mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir)."_(2)";
- }
- if( $arquivoClientes == "clientes3.php" ){
- $dir = 'BKP-' . date('d-m-Y_H-i-s');
- #delTree("/home/<cpuser>/public_html/ftpdir",false);
- sleep(1);
- mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir)."_(3)";
- }
- if( $arquivoClientes == "clientes4.php" ){
- $dir = 'BKP-' . date('d-m-Y_H-i-s')."_(4)";
- #delTree("/home/<cpuser>/public_html/ftpdir",false);
- sleep(1);
- mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir)."_(4)";
- }
- ########################################################################################################
- $bkpServerFTP = array( # Backup Server
- 'variant' => 'active',
- 'username' => '',
- 'password' => '',
- 'host' => '',
- 'port' => '21',
- 'directory' => '/'.$dir.'/',
- 'email' => ''
- );
- ########################################################################################################
- $cx = array();
- $IDVAR=0;
- $RetError = 0;
- $ListClientes ='';
- $spitDebug = "";
- $spitDebug = "XMLAPI DEBUG [".$arquivoClientes."] -------------------------------------------------------------------------------";
- for ( $row = 0; $row < count( $clientes ); $row++ ) {
- $IDVAR++;
- $cPanel = new cpanelAPI($clientes[$row]['FTPuser'], $clientes[$row]['FTPpass'], $clientes[$row]['FTPhost']);
- $cPanel->scope = 'Backup';
- $cPanel->__get('uapi');
- $cPanel->fullbackup_to_ftp($bkpServerFTP);
- $status = json_decode($cPanel->json);
- if( $status->status == 1 ){
- $ListClientes .= "\n ".$clientes[$row]['FTPhost']." - [TRUE]=[".$status->errors[0]."]";
- } else {
- $ListClientes .= "\n ".$clientes[$row]['FTPhost']." - [FALSE]=[".$status->errors[0]."]";
- $RetError +=1;
- }
- sleep(1);
- }
- echo "\r\n";
- echo "Lista de Clientes";
- echo "\r\n";
- echo $ListClientes;
- echo "\r\n \r\n";
- ?>
- <?php $endMEM = memory_get_usage(); ?>
- <?php print "Total:: " . count($clientes) . " Registrados"; ?>
- <?php print "Total:: " . count($clientes) . " - " . $RetError . " Enviado(s)"; ?>
- <?php print "Total:: " . ($RetError) . " Nao Enviado(s)"; ?>
- --
- MEMORIA: <?php echo "Inicial: " . convert($startMEM) . " | Final: " . convert($endMEM) ?>
- TEMPO DE EXECUCAO:: <?php $tempo = tempoExecucao(mTIME); echo $tempo; ?>
- GET: [<? echo $_SERVER['argv'][1] ?>]
- <?php
- # Array Example.
- # array("FTPhost"=>"", "FTPuser"=>"", "FTPpass"=>""),
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement