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.225.54.199


Current Path : /var/www/html/cnv/dud/src/
Upload File :
Current File : /var/www/html/cnv/dud/src/system_utility.php

<?php
function ChangeTablesToInnoDB($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

	$get_all_create_table="show TABLES";
	$lobj_get_all_create_table = $aobj_context->mobj_db->GetAll($get_all_create_table);
	foreach($lobj_get_all_create_table as $key=>$value)
			{
				foreach($value as $k=>$v)
				{
				 $table_name=$v;
				 $alter_table="alter table {$table_name} ENGINE=INNODB";
				$lobj_alter_table = $aobj_context->mobj_db->Execute($alter_table);   								
				}
			}
}
function TruncateEntryTables($aobj_context)
{
 
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

	$get_all_create_table="SELECT CONCAT(system_module_table_name,'_',system_group_table_name,'_entry') AS entry_table
							FROM s_user_schema_group ug
							INNER JOIN s_user_schema s ON s.internal_code=ug.ref_s_user_schema_code
							 WHERE multiple=1";
	$lobj_get_all_create_table = $aobj_context->mobj_db->GetAll($get_all_create_table);
	foreach($lobj_get_all_create_table as $key=>$value)
			{
				$table_name=$value['entry_table'];
				$truncate_table="truncate {$table_name}";
				$lobj_alter_table = $aobj_context->mobj_db->Execute($truncate_table);   								
				 
			}
	$get_gandhi_grid_tables="select concat('module_',internal_code,'_') as tablename
							from s_user_schema where 
							grid_type='Ggrid'";	
		$lobj_get_gandhi_grid_tables = $aobj_context->mobj_db->GetAll($get_gandhi_grid_tables);		
		foreach($lobj_get_gandhi_grid_tables as $gk=>$gv)
			{
			$drop_table_name=$gv[tablename];
			$get_show_tables="show tables like '%{$drop_table_name}%'";
			$lobj_get_show_tables = $aobj_context->mobj_db->GetAll($get_show_tables);		
				foreach($lobj_get_show_tables as $sk=>$sv)
				{
					foreach($sv as $svk=>$svv)
					{
					 $lobj_alter_table = $aobj_context->mobj_db->Execute(" drop table {$svv}");   
					}
					 
				}
			}
			DropTempTables($aobj_context);
			DeleteTempFiles($aobj_context);
		$data="Done";
		echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success"); 	
		return;	  		
}
function TruncateEntryTablesByLoginCnt($aobj_context)
{
	session_start();
	$login_cnt=$_SESSION['login_cnt'];
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

	$get_all_create_table="SELECT CONCAT(system_module_table_name,'_',system_group_table_name,'_entry') AS entry_table
							FROM s_user_schema_group ug
							INNER JOIN s_user_schema s ON s.internal_code=ug.ref_s_user_schema_code
							 WHERE multiple=1";
	$lobj_get_all_create_table = $aobj_context->mobj_db->GetAll($get_all_create_table);
	foreach($lobj_get_all_create_table as $key=>$value)
			{
				$table_name=$value['entry_table'];
				$truncate_table="delete from  {$table_name} where login_cnt={$login_cnt}";
				$lobj_alter_table = $aobj_context->mobj_db->Execute($truncate_table);   								
				 
			}
	$get_gandhi_grid_tables="select concat('module_',internal_code,'_',{$login_cnt}) as tablename
							from s_user_schema where 
							grid_type='Ggrid'";	
		$lobj_get_gandhi_grid_tables = $aobj_context->mobj_db->GetAll($get_gandhi_grid_tables);		
		foreach($lobj_get_gandhi_grid_tables as $gk=>$gv)
			{
			$drop_table_name=$gv[tablename];
			$get_show_tables="show tables like '%{$drop_table_name}%'";
			$lobj_get_show_tables = $aobj_context->mobj_db->GetAll($get_show_tables);		
				foreach($lobj_get_show_tables as $sk=>$sv)
				{
					foreach($sv as $svk=>$svv)
					{
					 $lobj_alter_table = $aobj_context->mobj_db->Execute(" drop table {$svv}");   
					}
					 
				}
			}
		 		
}
function DropTempTables($aobj_context)
{
	$temp_tables_arr=array("temp","tmp");
	foreach($temp_tables_arr as $k=>$v)
	{
			$drop_table_name=$v;
			$get_show_tables="show tables like '%{$drop_table_name}%'";
			$lobj_get_show_tables = $aobj_context->mobj_db->GetAll($get_show_tables);		
				foreach($lobj_get_show_tables as $sk=>$sv)
				{
					foreach($sv as $svk=>$svv)
					{
					 $lobj_alter_table = $aobj_context->mobj_db->Execute(" drop table {$svv}");   
					}
					 
				}
	}
}
function RepairTables($aobj_context)
{
$get_show_tables="show tables";
$lobj_get_show_tables = $aobj_context->mobj_db->GetAll($get_show_tables);		
	foreach($lobj_get_show_tables as $sk=>$sv)
	{
		foreach($sv as $svk=>$svv)
		{
		$repair_cmd="repair table {$svv}";
		$lobj_alter_table = $aobj_context->mobj_db->Execute($repair_cmd);
		
		$opt_cmd="optimize table {$svv}";
		$lobj_opt_cmd = $aobj_context->mobj_db->Execute($opt_cmd);   
		}
		 
	} 
}function DeleteTempFiles($aobj_context)
{
$folder_path=$aobj_context->main_src."/imported_files/";
 		
			$files = scandir($folder_path);
			 foreach ($files as $file)
				{
				$full_file_path=$folder_path.'//'.$file;
					if ($file != "." && $file != ".."&&$file!="Thumbs.db" && is_file($full_file_path)) 
					{
					 unlink($full_file_path);
					  
					}
				}
		 
}	
?>