Advertisement
Guest User

Untitled

a guest
Mar 27th, 2019
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.07 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3.  
  4. $startMEM = memory_get_usage();
  5. set_time_limit(350);
  6. include "cpaneluapi.class.php";
  7. include "extras.php"; # Extra Misc functions
  8.  
  9. $arquivoClientes = $_SERVER['argv'][1] . ".php"; # Get the arg from Cron command and insert .php extension.
  10.  
  11. include $arquivoClientes; # Here i include the file with my array. I have several files that are loaded in different days.
  12.  
  13. define('mTIME', tempoExecucao());
  14.  
  15. #[Cron Command] php /home/<cpuser>/script/cpanel-backup.php # Itยดs outside public dir.
  16.  
  17. ########################################################################################################
  18.  
  19. if( ($arquivoClientes == "clientesLARGE1.php") || ($arquivoClientes == "clientesLARGE2.php") ){
  20.    
  21.     $dir = 'BKP-(PESADO)' . date('d-m-Y_H-i-s');
  22.     delTree("/home/<cpuser>/public_html/ftpdir",false);
  23.     sleep(1);
  24.     mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir);
  25.    
  26. }
  27.  
  28. if( $arquivoClientes == "clientes1.php" ){
  29.    
  30.     $dir = 'BKP-' . date('d-m-Y_H-i-s')."_(1)";
  31.     delTree("/home/<cpuser>/public_html/ftpdir",false);
  32.     sleep(1);
  33.     mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir);
  34.  
  35. }
  36.  
  37. if( $arquivoClientes == "clientes2.php" ){
  38.    
  39.     $dir = 'BKP-' . date('d-m-Y_H-i-s');
  40.     #delTree("/home/<cpuser>/public_html/ftpdir",false);
  41.    sleep(1);    
  42.     mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir)."_(2)";
  43.  
  44. }
  45.  
  46. if( $arquivoClientes == "clientes3.php" ){
  47.    
  48.     $dir = 'BKP-' . date('d-m-Y_H-i-s');
  49.     #delTree("/home/<cpuser>/public_html/ftpdir",false);
  50.    sleep(1);    
  51.     mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir)."_(3)";
  52.  
  53. }
  54.  
  55. if( $arquivoClientes == "clientes4.php" ){
  56.    
  57.     $dir = 'BKP-' . date('d-m-Y_H-i-s')."_(4)";
  58.     #delTree("/home/<cpuser>/public_html/ftpdir",false);
  59.    sleep(1);    
  60.     mkdir( '/home/<cpuser>/public_html/ftpdir/'.$dir)."_(4)";
  61.  
  62. }
  63.  
  64. ########################################################################################################
  65.  
  66. $bkpServerFTP = array( # Backup Server
  67.        'variant'       => 'active',
  68.         'username'      => '',
  69.         'password'      => '',
  70.         'host'          => '',
  71.         'port'          => '21',
  72.         'directory'     => '/'.$dir.'/',
  73.         'email'         => ''
  74. );
  75.  
  76. ########################################################################################################
  77.  
  78.  
  79. $cx = array();
  80. $IDVAR=0;
  81.  
  82. $RetError     = 0;
  83. $ListClientes ='';
  84. $spitDebug    = "";
  85.  
  86.  
  87. $spitDebug  = "XMLAPI DEBUG [".$arquivoClientes."] -------------------------------------------------------------------------------";
  88.  
  89. for ( $row = 0; $row < count( $clientes ); $row++ ) {
  90.      
  91.         $IDVAR++;
  92.        
  93.         $cPanel = new cpanelAPI($clientes[$row]['FTPuser'], $clientes[$row]['FTPpass'], $clientes[$row]['FTPhost']);
  94.         $cPanel->scope = 'Backup';
  95.         $cPanel->__get('uapi');
  96.         $cPanel->fullbackup_to_ftp($bkpServerFTP);
  97.        
  98.         $status = json_decode($cPanel->json);
  99.        
  100.         if( $status->status == 1 ){
  101.            
  102.            $ListClientes .= "\n  ".$clientes[$row]['FTPhost']." - [TRUE]=[".$status->errors[0]."]";
  103.            
  104.         } else {
  105.            
  106.            $ListClientes .= "\n  ".$clientes[$row]['FTPhost']." - [FALSE]=[".$status->errors[0]."]";
  107.            $RetError  +=1;
  108.            
  109.         }
  110.        
  111.         sleep(1);
  112.      
  113. }
  114.  
  115. echo "\r\n";
  116. echo "Lista de Clientes";
  117. echo "\r\n";
  118. echo $ListClientes;
  119. echo "\r\n \r\n";
  120. ?>
  121.  
  122. <?php $endMEM = memory_get_usage(); ?>
  123.  
  124. <?php print "Total:: " . count($clientes) . " Registrados"; ?>                              
  125.  
  126. <?php print "Total:: " . count($clientes) . " - " . $RetError . " Enviado(s)"; ?>
  127.  
  128. <?php print "Total:: " . ($RetError) . " Nao Enviado(s)"; ?>                                
  129.  
  130. --
  131.  
  132. MEMORIA: <?php echo "Inicial: " . convert($startMEM) . " | Final: " . convert($endMEM) ?>    
  133.  
  134. TEMPO DE EXECUCAO:: <?php  $tempo = tempoExecucao(mTIME);  echo $tempo; ?>                  
  135.  
  136.  
  137. GET: [<? echo $_SERVER['argv'][1] ?>]
  138.  
  139.  
  140. <?php
  141.  
  142. # Array Example.
  143.  
  144. # array("FTPhost"=>"", "FTPuser"=>"", "FTPpass"=>""),
  145.  
  146.  
  147. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement