0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.116.49.143


Current Path : /var/www/oasis/src/
Upload File :
Current File : /var/www/oasis/src/connect.php

<?php
function connect()
{
	@session_start();
	$servername = "logisys.cluster-cv9maxyrxjgg.ap-south-1.rds.amazonaws.com";
	$username   = "admin";
	$password  = "Logisys2104";
	$FUNIVCODE = $_SESSION['univcode'];




	// $db = $_POST['db'];

	$db = $_GET["db"];
	// var_dump($db);
	// die();




	$conn= new  mysqli($servername,$username,$password);
	if(!$conn) {
         die("Connection failed: " . mysqli_connect_error());
	}
	$sql ="SHOW DATABASES"; 
	$result = $conn->query($sql);
	// var_dump($result);
	if($FUNIVCODE == '003')
	{
		$Databasename[] = 'logisys3_kus';
		$Databasename[] = 'logisys3_kusd';
		$Databasename[] = 'logisys3_uet';

	}else if($FUNIVCODE == '027')
	{
		$Databasename[] = "logisys3_rcu";

	}else if($FUNIVCODE == '008')
	{
		$Databasename[] = "logisys3_kswu";
	}
	else if($FUNIVCODE == '026')
	{
		$Databasename[] = "logisys3_vku";
	}
	else if($FUNIVCODE == '001')
	{
		$Databasename[] = "logisys3_gug";
	}
	else if($FUNIVCODE == '041')
	{
		$Databasename[] = "logisys3_bcu";
	}
	
		

	$table = '<table  width=100% border=1 cellspacing=0 cellpadding=3>
    <thead>
	<tr>
	<th>Sl No.</th>
	<th>File Name</th>
	<th> Size </th>
	<th> Last Modified </th>
	<th> Action </th>

	</tr>
    </thead>
    <tbody>';
	$i = 1;

	$files = glob($db."/backup/*.zip");

	// sort files by last modified date
	usort($files, function($x, $y) {
		return filemtime($x) < filemtime($y);
	});



	foreach ($files as $filename) 
	{
		// var_dump($filename);
		$del = basename($filename);

		$table .='<tr>';
		$table .='<td align=center>'.$i.'</td>';
		$table .='<td>'.basename($filename).'</td>';
		$table .='<td align=right>'.formatSizeUnits(filesize($filename)).'</td>';
		$table .='<td align=center>'.date_default_timezone_set("Asia/Kolkata").' '.date("d/m/Y h:i A", filemtime($filename)).'</td>';
		$table .='<td align=center> <a href="../'.$filename.'"> Download </a>&nbsp;&nbsp;&nbsp;<a href="#" style=" color: red;" onclick="delete_zip(`'.$del.'`);"> Delete </a></td>';		

		$table .='</tr>';
		$i++;
	}

	$table .='</tbody>';
	$table .='</table>';
// var_dump($table);

	$arr['database'] = $Databasename;
	$arr['table'] = $table;
	echo json_encode($arr);
}

function formatSizeUnits($bytes)
{
	if ($bytes >= 1073741824)
	{
		$bytes = number_format($bytes / 1073741824, 2) . ' GB';
	}
	elseif ($bytes >= 1048576)
	{
		$bytes = number_format($bytes / 1048576, 2) . ' MB';
	}
	elseif ($bytes >= 1024)
	{
		$bytes = number_format($bytes / 1024, 2) . ' KB';
	}
	elseif ($bytes > 1)
	{
		$bytes = $bytes . ' bytes';
	}
	elseif ($bytes == 1)
	{
		$bytes = $bytes . ' byte';
	}
	else
	{
		$bytes = '0 bytes';
	}

	return $bytes;
}
?>