403Webshell
Server IP : 103.119.228.120  /  Your IP : 3.149.235.66
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /home/hendraso/public_html/Modules/Controller/Admin/Master/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/hendraso/public_html/Modules/Controller/Admin/Master/Mapping.php
<?php
Class Controller_Admin_Master_Mapping extends GeneralAction {

    function beforeExec() {
		parent::beforeExec();
		parent::$moduleName = "Mapping";
        parent::$isAdmin = true;
		parent::$mapping = parent::generateMapping('mapping');
        parent::$prefix = 'mmph';
        parent::$table = 'master_mapping_header';
		parent::$validate = array(
            'check_empty'   => array('txtName', 'txtDbName', 'txtDbPrefix', 'txtModuleName')
        );

        /* For Detail */
		parent::$mappingDetail = parent::generateMapping('mapping detail');
        parent::$prefixDetail = 'mmpd';
        parent::$tableDetail = 'master_mapping_detail';
		parent::$validateDetail = array(
            'check_empty'   => array('txtFieldDb', 'txtLabel', 'txtTypeFieldDb')
        );
	}
	
	protected function do_show() {
		$form = GenerateForm::load()->buildForm(static::$mapping); 
		$addJs = "
		var lastNum = '';
		function afterLoadDataApi(data) {
			if(data.lastnum != undefined) {
				lastNum = data.lastnum;
			}
		}
		function afterSelect(obj){
			$('#txtName, #txtDbPrefix, #txtDbName').attr('readonly', true);
		}
		function afterMainSave() {
			$('#txtName, #txtDbPrefix, #txtDbName').attr('readonly', true);
		}
		function afterNewForm(){
			$('.errMsgDesc').remove();
			$('input, select, textarea').removeClass('errMsg');
			$('#txtName, #txtDbPrefix, #txtDbName').attr('readonly', false);
		}
		function afterNewFormDetail(){
			$('.errMsgDesc').remove();
			$('input, select, textarea').removeClass('errMsg');
			$('#txtSort').val(lastNum);
			$('#txtFieldDb').val($('#txtDbPrefix').val());
		}
		";
		$addTpl = array("addJs" => $addJs);
		parent::do_show('/Templates/Admin/default2Grid.html', $addTpl);
	}
	
	protected function do_save() {
		$save = parent::do_save();
		if($save["status"] == "ok") {
			$prefix = strtolower($_POST['txtDbPrefix']);
			$table  = $_POST['txtDbName'];
			if(empty($_POST['slTypeGrid'])) {
				Database::build()->insertArray("master_mapping_detail", "mmpd", array(
													"mmpdMmphId" 	=> $save['id'],
													"mmpdFieldDb"	=> "{$prefix}Id",
													"mmpdTypeDb"	=> "INT",
													"mmpdLengthDb"	=> "0",
													"mmpdType"		=> "hidden",
													"mmpdLabel"		=> "ID",
													"mmpdFieldName"	=> "txtId",
													"mmpdGrid"		=> "true",
													"mmpdSort"		=> 1
												)
											);
				if(!empty($_POST['slCreateTable'])) {							
					$createTable = "CREATE TABLE IF NOT EXISTS {$table}(  
								`{$prefix}Id` INT NOT NULL AUTO_INCREMENT,
								`{$prefix}CreateBy` INT,
								`{$prefix}CreateTime` DATETIME,
								`{$prefix}UpdateBy` INT,
								`{$prefix}UpdateTime` DATETIME,
							  PRIMARY KEY (`{$prefix}Id`)
							);";			
					Database::build()->directlyQuery($createTable);	
				}
			}else{
				Database::build()->insertArray("master_mapping_detail", "mmpd", array(
													"mmpdMmphId" 	=> $save['id'],
													"mmpdFieldDb"	=> "{$prefix}Id",
													"mmpdTypeDb"	=> "INT",
													"mmpdLengthDb"	=> "0",
													"mmpdType"		=> "hidden",
													"mmpdLabel"		=> "ID",
													"mmpdFieldName"	=> "txtIdDetail",
													"mmpdGrid"		=> "true",
													"mmpdSort"		=> 1
												)
											);
											
				$getHeader = Database::build()->getAllDbOne("SELECT mmphDbPrefix FROM master_mapping_header WHERE mmphId = '".$_POST['slTypeGrid']."'");							
				Database::build()->insertArray("master_mapping_detail", "mmpd", array(
													"mmpdMmphId" 	=> $save['id'],
													"mmpdFieldDb"	=> $prefix . ucfirst($getHeader['mmphDbPrefix']) . "Id",
													"mmpdTypeDb"	=> "INT",
													"mmpdLengthDb"	=> "0",
													"mmpdType"		=> "hidden",
													"mmpdLabel"		=> "ID Header",
													"mmpdFieldName"	=> "txtIdHeader",
													"mmpdGrid"		=> "true",
													"mmpdSort"		=> 2
												)
											);	
				
				if(!empty($_POST['slCreateTable'])) {	
					$createTable = "CREATE TABLE IF NOT EXISTS {$table}(  
								`{$prefix}Id` INT NOT NULL AUTO_INCREMENT,
								`{$prefix}".ucfirst($getHeader['mmphDbPrefix'])."Id` INT,
								`{$prefix}CreateBy` INT,
								`{$prefix}CreateTime` DATETIME,
								`{$prefix}UpdateBy` INT,
								`{$prefix}UpdateTime` DATETIME,
							  PRIMARY KEY (`{$prefix}Id`)
							);";			
					Database::build()->directlyQuery($createTable);		
				}
			}
			if(!empty($_POST['slCreateScript'])) {
				$this->readyToScript($_POST);
			}
		}
	 	return $save;
	}
	
	protected function do_update() {
		$getCreateScript = Database::build()->getAllDbOne("SELECT mmphDbDefault, mmphDbPrefix, mmphCreateScript, mmphType FROM master_mapping_header WHERE mmphId = '".$_POST['txtId']."'");
		$update = parent::do_update();
		if($update['status'] == "ok") {
			$table = $getCreateScript['mmphDbDefault'];
			$prefix = $getCreateScript['mmphDbPrefix'];
			if(!empty($_POST['slCreateTable'])) {							
				$createTable = "CREATE TABLE IF NOT EXISTS {$table}(  
							`{$prefix}Id` INT NOT NULL AUTO_INCREMENT,
							`{$prefix}CreateBy` INT,
							`{$prefix}CreateTime` DATETIME,
							`{$prefix}UpdateBy` INT,
							`{$prefix}UpdateTime` DATETIME,
						  PRIMARY KEY (`{$prefix}Id`)
						);";			
				Database::build()->directlyQuery($createTable);	
			}
			if($getCreateScript['mmphType'] != (!empty($_POST['slTypeGrid']) ? $_POST['slTypeGrid'] : 0)) {
				if(!empty($_POST['slTypeGrid'])) {
					if(!empty($getCreateScript['mmphType'])) {
						if(!empty($_POST['slCreateTable'])) {	
							$getHeaderOld = Database::build()->getAllDbOne("SELECT mmphDbPrefix FROM master_mapping_header WHERE mmphId = '".$getCreateScript['mmphType']."'");
							if(!empty($getHeaderOld['mmphDbPrefix'])) {
								$removeColumn = "ALTER TABLE {$table} DROP COLUMN {$prefix}".ucfirst($getHeaderOld['mmphDbPrefix'])."Id";
								Database::build()->directlyQuery($removeColumn);
							}
						}
						Database::build()->delete_data("master_mapping_detail", "mmpd", "mmpdFieldName = 'txtIdHeader' AND mmpdMmphId = '".$update['id']."'");
					}
					
					$getHeader = Database::build()->getAllDbOne("SELECT mmphDbPrefix FROM master_mapping_header WHERE mmphId = '".$_POST['slTypeGrid']."'");
					if(!empty($_POST['slCreateTable'])) {	
						$addColumn = "ALTER TABLE `{$table}` ADD COLUMN {$prefix}".ucfirst($getHeader['mmphDbPrefix'])."Id INT AFTER {$prefix}Id";
						Database::build()->directlyQuery($addColumn);
					}
					
					Database::build()->updateArray("master_mapping_detail", "mmpd", array("mmpdFieldName" => "txtIdDetail"), "mmpdFieldName = 'txtId' AND mmpdMmphId = '".$update['id']."'");
					Database::build()->insertArray("master_mapping_detail", "mmpd", array(
													"mmpdMmphId" 	=> $update['id'],
													"mmpdFieldDb"	=> $prefix . ucfirst($getHeader['mmphDbPrefix']) . "Id",
													"mmpdType"		=> "hidden",
													"mmpdLabel"		=> "ID Header",
													"mmpdFieldName"	=> "txtIdHeader",
													"mmpdGrid"		=> "true",
													"mmpdSort"		=> 2
												)
											);	
					
				}else{
					if(!empty($_POST['slCreateTable'])) {	
						$getHeader = Database::build()->getAllDbOne("SELECT mmphDbPrefix FROM master_mapping_header WHERE mmphId = '".$getCreateScript['mmphType']."'");
						if(!empty($getHeader['mmphDbPrefix'])) {
							$removeColumn = "ALTER TABLE {$table} DROP COLUMN {$prefix}".ucfirst($getHeader['mmphDbPrefix'])."Id";
							Database::build()->directlyQuery($removeColumn);
						}
					}
					
					Database::build()->updateArray("master_mapping_detail", "mmpd", array("mmpdFieldName" => "txtId"), "mmpdFieldName = 'txtIdDetail' AND mmpdMmphId = '".$update['id']."'");
					Database::build()->delete_data("master_mapping_detail", "mmpd", "mmpdFieldName = 'txtIdHeader' AND mmpdMmphId = '".$update['id']."'");
				}
				
				if(!empty($_POST['slCreateScript'])) {
					$this->readyToScript($_POST);
				}
			}
			
			if(!empty($_POST['slCreateScript']) && empty($getCreateScript['mmphCreateScript'])) {
				$this->readyToScript($_POST);
			}
		}
		return $update;	
	}
	
	protected function do_savedetail() {
		$savedetail = parent::do_savedetail();
		if($savedetail['status'] == "ok") {
			$getHeader = Database::build()->getAllDbOne("SELECT mmphDbDefault, mmphDbPrefix FROM master_mapping_header WHERE mmphId = '".$_POST['txtIdHeader']."'");
			$getCustomField = Database::build()->getAllDbOne("SELECT mmpdFieldDb FROM master_mapping_detail WHERE mmpdId != '".$savedetail['id']."' AND mmpdMmphId = '".$_POST['txtIdHeader']."' AND mmpdSort < '".$_POST['txtSort']."' ORDER BY mmpdSort DESC LIMIT 1");
			$column = $_POST['txtFieldDb'] . " " . (($_POST['txtTypeFieldDb'] == "VARCHAR") ? $_POST['txtTypeFieldDb'] ."(".$_POST['txtTypeLengthDb'].")": $_POST['txtTypeFieldDb']);
			$addColumn = "ALTER TABLE `".$getHeader['mmphDbDefault']."` ADD COLUMN {$column} AFTER ".$getCustomField['mmpdFieldDb'];
			Database::build()->directlyQuery($addColumn);
		}	
		return $savedetail;
	}
	
	protected function do_updatedetail() {
		$getDetail = Database::build()->getAllDbOne("SELECT mmphDbDefault, mmpdFieldDb, mmpdTypeDb, mmpdLengthDb FROM master_mapping_detail LEFT JOIN master_mapping_header ON mmphId = mmpdMmphId WHERE mmpdId = '".$_POST['txtIdDetail']."'");
		$updatedetail = parent::do_updatedetail();
		if($_POST['txtFieldDb'] != $getDetail['mmpdFieldDb'] || $_POST['txtTypeFieldDb'] != $getDetail['mmpdTypeDb'] || $_POST['txtTypeLengthDb'] != $getDetail['mmpdLengthDb']) {
			$column = $_POST['txtFieldDb'] . " " . (($_POST['txtTypeFieldDb'] == "VARCHAR") ? $_POST['txtTypeFieldDb'] ."(".$_POST['txtTypeLengthDb'].")": $_POST['txtTypeFieldDb']);
			$changeColumn = "ALTER TABLE `".$getDetail['mmphDbDefault']."` CHANGE `".$getDetail['mmpdFieldDb']."` ".$column;
			Database::build()->directlyQuery($changeColumn);
		}
		return $updatedetail;
	}

	protected function do_datadetail() {
		$data = parent::do_datadetail();
		$getSeq = Database::build()->getAllDbOne("SELECT MAX(mmpdSort) + 1 as lastnum FROM master_mapping_detail WHERE mmpdMmphId = '".parent::getParam(1)."'");
		$data["lastnum"] = $getSeq['lastnum'];
		return $data;
	}	
	
	function readyToScript($post) {
		$filename = ucfirst(str_replace(" ", "", strtolower($post['txtName'])));
		$file = "Controller/Admin/Master/" . $filename . ".php";
		$pf = fopen ($file, "w");
		if (!$pf)
		{
			echo "cannot create $file\n";
			return;
		}
		
		if(empty($post['slTypeGrid'])) {
			$createFile = $this->createScript(1, $filename, $post);
		}else{
			$createFile = $this->createScript(2, $filename, $post);
		}
		
		fwrite ($pf, $createFile);
		fclose ($pf);
	}
	
	function createScript($type = 1, $filename, $post) {
		if($type == 1) {
			$createFile = '<?php
	Class Controller_Admin_Master_'.$filename.' extends GeneralAction {
		function beforeExec() {
			parent::beforeExec();
			parent::$moduleName = "'.$post['txtModuleName'].'";
			parent::$isAdmin = true;
			parent::$btnAction = true;
			parent::$mapping = parent::generateMapping("'.$post['txtName'].'");
							
			parent::$prefix = "'.$post['txtDbPrefix'].'";
			parent::$table = "'.$post['txtDbName'].'";
			parent::$pathupload = "../Assets/img/";
		}
		protected function do_show() {
			parent::do_show("/Templates/Admin/default1Grid.html");
		}
	}';
		}else{
			$getHeader = Database::build()->getAllDbOne("SELECT mmphName, mmphDbDefault, mmphDbPrefix FROM master_mapping_header WHERE mmphId = '".$post['slTypeGrid']."'");
			$createFile = '<?php
	Class Controller_Admin_Master_'.$filename.' extends GeneralAction {
		function beforeExec() {
			parent::beforeExec();
			parent::$moduleName = "'.$post['txtModuleName'].'";
			parent::$isAdmin = true;
			parent::$btnAction = true;
			parent::$mapping = parent::generateMapping("'.$getHeader['mmphName'].'");
			parent::$prefix = "'.$getHeader['mmphDbPrefix'].'";
			parent::$table = "'.$getHeader['mmphDbDefault'].'";
			
			parent::$mappingDetail = parent::generateMapping("'.$post['txtName'].'");
			parent::$prefixDetail = "'.$post['txtDbPrefix'].'";
			parent::$tableDetail = "'.$post['txtDbName'].'";
			
			parent::$pathupload = "../Assets/img/";
		}
		protected function do_show() {
			parent::do_show("/Templates/Admin/default2Grid.html");
		}
	}';
		}
		return $createFile;
	}
	
	function generateField($field, $datatype, $type){
		switch($datatype) {
			case 'input' :
				$tb_type = "INT";
				if($type == 1) {
					$tb_type = "VARCHAR(200)";
				}
				$return = "`" . $field . "` " . $tb_type;
			break;
			case 'hidden' :
				$return = "`" . $field . "` INT";
			break;
			case 'combo' :
				$return = "`" . $field . "` VARCHAR(50)";
			break;
			case 'rbutton' :
				$return = "`" . $field . "` VARCHAR(10)";
			break;
			case 'mcombo' :
				$return = "`" . $field . "` VARCHAR(200)";
			break;
			case 'dpicker' :
				$return = "`" . $field . "` DATE";
			break;
			case 'tpicker' :
				$return = "`" . $field . "` TIME";
			break;
			case 'ufile' :
				$return = "`" . $field . "` VARCHAR(255)";
			break;
			case 'uimg' :
				$return = "`" . $field . "` VARCHAR(255)";
			break;
			case 'cbox' :
				$return = "`" . $field . "` VARCHAR(150)";
			break;
			case 'txtarea' :
				$return = "`" . $field . "` TEXT";
			break;
			case 'tiny' :
				$return = "`" . $field . "` TEXT";
			break;
		}
		return $return;
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit