Server IP : 103.119.228.120 / Your IP : 3.149.251.64 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/Core/ |
Upload File : |
<?php //error_reporting('E_ALL'); class GeneralAction extends Controller { protected static $isAdmin = false; protected static $rowPage = 20; protected static $table; protected static $joinTable = array(); protected static $joinTableLeft = array(); protected static $joinTableRight = array(); protected static $mapping = array(); protected static $addMapping = array(); protected static $unsetMapping = array(); protected static $setWhere = ""; protected static $prefix = ""; protected static $validate = array(); protected static $setGroup = ""; protected static $setOrder = ""; protected static $width = 200; protected static $height = 200; //====== for detail ====== protected static $tableDetail; protected static $joinTableDetail = array(); protected static $joinTableLeftDetail = array(); protected static $joinTableRightDetail = array(); protected static $mappingDetail = array(); protected static $prefixDetail = ""; protected static $validateDetail = array(); protected static $setWhereDetail = ""; //====== for upload ====== protected static $setWhereUpload; protected static $tableUpload; protected static $mapping_upload = array(); protected static $typeUpload; protected static $pathupload; protected static $prefixUpload; function beforeExec () { return; } function load_action($action) { session_start(); /*IF user tidak dapat akses*/ if(isset($_SESSION['userId'])) { $menuLink = substr(str_replace("/show", "", $_SERVER['PATH_INFO']), 1); $cekMenu = Database::build()->getAllDbOne("SELECT count(1) as total FROM menu WHERE menuLink = '".$menuLink."'"); if(!empty($cekMenu['total'])) { if(preg_match("/show/", $_SERVER['PATH_INFO'])) { $access = Database::build()->getAllDbOne("SELECT count(1) as total FROM user_access LEFT JOIN menu ON (menuId = udacAccess) WHERE udacUdafId = '".$_SESSION['userId']."' AND menuLink = '" . $menuLink . "'"); if(empty($access['total'])) { die("Maaf anda tidak dapat mengakses halaman ini"); } } } } /*=====================*/ $this->beforeExec(); if (self::$isAdmin == false) { if (strtolower($action) == 'do_show') { echo $this->$action(); } elseif(strtolower($action) == 'do_view') { echo $this->$action(); } else { $data = $this->$action(); if (is_array($data)) { echo json_encode($data, JSON_FORCE_OBJECT); } } } else { if (strtolower($action) == 'do_show') { $check = $this->check_session(); if ($check['status'] == 'error') { header('Location:' . parent::$_livepath."/Admin"); } else { $this->beforeExec(); echo $this->$action(); } } else { $check = $this->check_session(); if ($check['status'] == 'error') { echo json_encode($check, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); } else { $this->beforeExec(); $data = $this->$action(); $data['session'] = true; echo json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); } } } } private function check_session() { //session_start(); $err = ''; if (!isset($_SESSION['user']) && empty($_SESSION['user'])) { $err = 'Please login'; } if (empty($err)) { return array('status' => 'ok'); } else { return array('status' => 'error', 'session' => false, 'error' => $err); } } private function joinTable() { $table = static::$table; foreach (static::$joinTable as $key => $val) { if (!empty($key)) { $table .= " JOIN " . $key . " " . $val . ""; } } foreach (static::$joinTableLeft as $key => $val) { if (!empty($key)) { $table .= " LEFT JOIN " . $key . " " . $val . ""; } } foreach (static::$joinTableRight as $key => $val) { if (!empty($key)) { $table .= " RIGHT JOIN " . $key . " " . $val . ""; } } return $table; } private function joinTableDetail() { $table = static::$tableDetail; foreach (static::$joinTableDetail as $key => $val) { if (!empty($key)) { $table .= " JOIN " . $key . " " . $val . ""; } } foreach (static::$joinTableLeftDetail as $key => $val) { if (!empty($key)) { $table .= " JOIN " . $key . " " . $val . ""; } } foreach (static::$joinTableRightDetail as $key => $val) { if (!empty($key)) { $table .= " JOIN " . $key . " " . $val . ""; } } return $table; } protected function do_view() { $_document_root = Config::load()->root(); require $_document_root . '/Additional/smarty3/Smarty.class.php'; $tpl = New Smarty; $tpl->Assign('documentRoot', $_document_root); $tpl->Assign('username', "Ageng"); $tpl->Assign('livepath', parent::$_livepath); $tpl->Assign('redirectBack', $_SERVER['REDIRECT_URL']); if(isset($_SESSION['clientId']) && !empty($_SESSION['clientId'])) { $user = Database::build()->getAllDbOne("SELECT * FROM client WHERE clieId = '".$_SESSION['clientId']."' "); $tpl->Assign('user', $user); } return $tpl; } protected function do_show() { $_document_root = Config::load()->root(); require $_document_root . '/Additional/smarty3/Smarty.class.php'; require $_document_root . '/Additional/Mobile_Detect.php'; $detect = new Mobile_Detect; $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer'); $getMenu = $this->getMenu(); $menu = GeneralFunction::build()->createMenu($getMenu); /*if(!isset($_SESSION['userProductList']) && empty($_SESSION['userIsA'])) { $menu = ""; }*/ $comboFilter = GeneralFunction::build()->convCombo(static::$mapping, 'slFilter'); $tpl = New Smarty; $tpl->Assign('device', $deviceType); $sourcePath = parent::$_livepath . "/Modules" . $_SERVER['PATH_INFO']; $explode = explode("show/", $_SERVER['PATH_INFO']); $menuactive = explode("/",$explode[0]); $active = $menuactive[1]; $tpl->Assign('active', $active); $navigasi = ucwords(str_replace("/", " ",str_replace("/show", "", $explode[0]))); $path = parent::$_livepath . "/Modules" . str_replace("/show", "", $explode[0]); $param = (!empty($explode[1]) ? "/".$explode[1] : ""); foreach($_SESSION as $key => $val) { $tpl->Assign($key, (isset($_SESSION[$key]) && !empty($_SESSION[$key])) ? $_SESSION[$key] : ''); } $img = Generaldb::instance()->dbgetone("SELECT udafImage FROM user WHERE udafId= '".$_SESSION['userId']."'"); if(!empty($img['udafImage'])) { $tpl->Assign('pp', $img['udafImage']); } $tpl->Assign('menu', $menu); $tpl->Assign('isAdmin', (!empty($_SESSION['userIsA']) ? 'true': 'false')); $tpl->Assign('breadcrumb', $navigasi); $tpl->Assign('slFilter', $comboFilter); $tpl->Assign('documentRoot', $_document_root); $tpl->Assign('livepath', parent::$_livepath); $tpl->Assign('sourcePath', $sourcePath); $tpl->Assign('path', $path); $tpl->assign('param', $param); $tpl->assign('get', $menuactive); $tpl->assign('btnnew', true); $tpl->assign('btnremove', true); $tpl->assign('btnupdate', true); $tpl->assign('btnsave', true); $tpl->assign('addnew', true); return $tpl; } function getMenu ($access = false) { $cond = ""; if($access == false) { $menuacc = Database::build()->getAllDb("SELECT * FROM user_access WHERE udacUdafId = '".$_SESSION['userId']."'"); $menuId = array(); foreach($menuacc as $key => $val) { $menuId[] = $val['udacAccess']; } $menuId = implode(",", $menuId); $cond = empty($menuId) ? "WHERE menuId IN ('')" : "WHERE menuId IN (".$menuId.")"; } $menu = Database::build()->getAllDb("SELECT * FROM menu " . $cond); $array = array(); foreach($menu as $key => $val) { $array[$val['menuId']] = $val; } return $array; } /* ===================== Grid Data ======================*/ protected function do_data() { if(!empty($_POST['order'])) { $order = $this->searchForId($_POST['order'], static::$mapping, 'name'); $orderby = $order ." ".$_POST['sort']; }else{ $orderby = empty(static::$setOrder) ? static::$prefix . "Id Desc" : static::$setOrder; } foreach(static::$unsetMapping as $val) { unset(static::$mapping[$val]); } //print_r(static::$mapping); //$orderby = empty(static::$setOrder) ? static::$prefix . "Id Desc" : static::$setOrder; $data = Grid::load()->setField(static::$mapping) ->setPrefix(static::$prefix . "Id") ->setTable($this->joinTable()) ->setWhere(static::$setWhere) ->setGroup(static::$setGroup) ->setOrder($orderby) ->setRowpage(static::$rowPage) ->execute(); foreach(static::$mapping as $key => $val) { if(isset($val['class'])) { $data['class'][$val['field']] = $val['class']; } } return $data; } protected function do_datadetail() { $data = Grid::load()->setField(static::$mappingDetail) ->setPrefix(static::$prefixDetail . "Id") ->setTable($this->joinTableDetail()) ->setWhere(static::$prefixDetail . ucfirst(static::$prefix) . "Id = '".parent::getParam(1)."'") ->setOrder(static::$prefixDetail . "Id Desc") ->setRowpage(static::$rowPage) ->execute(); foreach(static::$mappingDetail as $key => $val) { if(isset($val['class'])) { $data['class'][$val['field']] = $val['class']; } } return $data; } /* =======================================================*/ /* ===================== Insert Data ======================*/ protected function do_save($post = false, $createTimeBy = false) { $arrNotUpload = array(); $mapping = static::$mapping; foreach(static::$unsetMapping as $val) { if(isset($mapping[$val])) { $arrNotUpload[] = $mapping[$val]['field']; unset($mapping[$val]); } } $post = ($post) ? $post : $_POST; $valid = Validation::check_data(static::$validate, $post, $mapping); if ($valid['status'] == 'ok') { $imgPost = array(); if (!empty($_FILES)) { foreach ($_FILES as $key => $val) { if($_FILES[$key]['type'] == "application/pdf") { $output_dir = static::$pathupload; $upload = $_FILES[$key]["name"]; $type = $_FILES[$key]["type"]; $fileName = time() . "_" . $upload; move_uploaded_file($_FILES[$key]["tmp_name"], $output_dir . $fileName); $imgPost = $imgPost + array($key => $fileName); }else{ if(!in_array($key, $arrNotUpload)) { if (!empty($val['name'])) { $img = $this->generateImage($key, static::$width, static::$height); $imgPost = $imgPost + $img['data']; } $imgDefault = array($key => ""); $imgPost = $imgPost + $imgDefault; } } } } if(!empty($_FILES)) { if(isset($img) && $img['status'] == 'error') { $valid = array('status' => 'error', 'error' => $img['msg']); }else{ $post = $post + $imgPost; $data = Database::build() ->setInsert($mapping, $post, static::$prefix, $createTimeBy) ->insert(static::$table); $valid['id'] = $data; } }else{ $data = Database::build() ->setInsert($mapping, $post, static::$prefix, $createTimeBy) ->insert(static::$table); $valid['id'] = $data; } return $valid; } else { return $valid; } } protected function do_savedetail($post = false, $createTimeBy = false) { $arrNotUpload = array(); $post = ($post) ? $post : $_POST; $valid = Validation::check_data(static::$validateDetail, $post, static::$mappingDetail); if ($valid['status'] == 'ok') { $imgPost = array(); if (!empty($_FILES)) { foreach ($_FILES as $key => $val) { if($_FILES[$key]['type'] == "application/pdf") { $output_dir = static::$pathupload; $upload = $_FILES[$key]["name"]; $type = $_FILES[$key]["type"]; $fileName = time() . "_" . $upload; move_uploaded_file($_FILES[$key]["tmp_name"], $output_dir . $fileName); $imgPost = $imgPost + array($key => $fileName); }else{ if(!in_array($key, $arrNotUpload)) { if (!empty($val['name'])) { $img = $this->generateImage($key, static::$width, static::$height); $imgPost = $imgPost + $img['data']; } $imgDefault = array($key => ""); $imgPost = $imgPost + $imgDefault; } } } } if(!empty($_FILES)) { if(isset($img) && $img['status'] == 'error') { $valid = array('status' => 'error', 'error' => $img['msg']); }else{ $post = $post + $imgPost; $data = Database::build() ->setInsert(static::$mappingDetail, $post, static::$prefixDetail, $createTimeBy) ->insert(static::$tableDetail); $valid['id'] = $data; } }else{ $data = Database::build() ->setInsert(static::$mappingDetail, $post, static::$prefixDetail, $createTimeBy) ->insert(static::$tableDetail); $valid['id'] = $data; } return $valid; } else { return $valid; } } /* =======================================================*/ /* ==================== Select Data ======================*/ protected function do_select() { $class = ""; $data = Generaldb::instance() ->prefix(static::$prefix. 'Id') ->column(static::$mapping) ->table($this->joinTable()) ->where(static::$prefix . 'Id = ' . $_POST['id']) ->executeArr(); foreach(static::$mapping as $key => $val) { if(isset($val['class'])) { $class[$val['field']] = $val['class']; } } return array('data' => $data, 'class' => $class); } protected function do_selectDetail() { $class = ""; $data = Generaldb::instance() ->prefix(static::$prefixDetail. 'Id') ->column(static::$mappingDetail) ->table(static::$tableDetail) ->where(static::$prefixDetail . 'Id = ' . $_POST['id']) ->executeArr(); foreach(static::$mappingDetail as $key => $val) { if(isset($val['class'])) { $class[$val['field']] = $val['class']; } } return array('data' => $data, 'class' => $class); } /* =======================================================*/ /* ================== Update Data ========================*/ protected function do_update($post = false, $id = false) { $arrImg = array(); $arrNotUpload = array(); $mapping = static::$mapping; foreach(static::$unsetMapping as $val) { if(isset($mapping[$val])) { $arrNotUpload[] = $mapping[$val]['field']; unset($mapping[$val]); } } //print_r($mapping);die; $post = ($post) ? $post : $_POST; $id = ($id) ? $id : $post['txtId']; $valid = Validation::check_data(static::$validate, $post, $mapping); if ($valid['status'] == 'ok') { if (!empty($_FILES)) { $imgPost = array(); foreach ($_FILES as $key => $val) { if($_FILES[$key]['type'] == "application/pdf") { $output_dir = static::$pathupload; $upload = $_FILES[$key]["name"]; $type = $_FILES[$key]["type"]; $fileName = time() . "_" . $upload; move_uploaded_file($_FILES[$key]["tmp_name"], $output_dir . $fileName); $imgPost = $imgPost + array($key => $fileName); }else{ if(!in_array($key, $arrNotUpload)) { if (!empty($val['name'])) { $img = $this->generateImage($key, static::$width, static::$height); $imgPost = $imgPost + $img['data']; } /*$imgDefault = array($key => ""); $imgPost = $imgPost + $imgDefault;*/ } } } } if(!empty($_FILES)) { if(isset($img) && $img['status'] == 'error') { $valid = array('status' => 'error', 'error' => $img['msg']); } else { //$post = $post + $arrImg['data']; $post = $post + $imgPost; $data = Database::build()->setUpdate($mapping, $post, static::$prefix) ->setWhere(static::$prefix . "Id = '" . $id . "'") ->update(static::$table); if ($data['status'] == 'ok') { $valid = array('status' => 'ok', 'id' => $id); } else { $valid = array('status' => 'error', 'error' => $data['msg']); } } }else{ $data = Database::build()->setUpdate($mapping, $post, static::$prefix) ->setWhere(static::$prefix . "Id = '" . $id . "'") ->update(static::$table); if ($data['status'] == 'ok') { $valid = array('status' => 'ok', 'id' => $id); } else { $valid = array('status' => 'error', 'error' => $data['msg']); } } return $valid; } else { return $valid; } } protected function do_updatedetail($post = false) { $arrNotUpload = array(); $post = ($post == false) ? $_POST : $post; $valid = Validation::check_data(static::$validateDetail, $post, static::$mappingDetail); if ($valid['status'] == 'ok') { if (!empty($_FILES)) { $imgPost = array(); foreach ($_FILES as $key => $val) { if($_FILES[$key]['type'] == "application/pdf") { $output_dir = static::$pathupload; $upload = $_FILES[$key]["name"]; $type = $_FILES[$key]["type"]; $fileName = time() . "_" . $upload; move_uploaded_file($_FILES[$key]["tmp_name"], $output_dir . $fileName); $imgPost = $imgPost + array($key => $fileName); }else{ if(!in_array($key, $arrNotUpload)) { if (!empty($val['name'])) { $img = $this->generateImage($key, static::$width, static::$height); $imgPost = $imgPost + $img['data']; } /*$imgDefault = array($key => ""); $imgPost = $imgPost + $imgDefault;*/ } } } } if (!empty($_FILES)) { if (isset($img) && $img['status'] == 'error') { $valid = array('status' => 'error', 'error' => $img['msg']); } else { //$post = $post + $img['data']; $post = $post + $imgPost; $data = Database::build()->setUpdate(static::$mappingDetail, $post, static::$prefixDetail) ->setWhere(static::$prefixDetail . "Id = '" . $post['txtIdDetail'] . "'") ->update(static::$tableDetail); if ($data['status'] == 'ok') { $valid = array('status' => 'ok', 'id' => $post['txtIdDetail']); } else { $valid = array('status' => 'error', 'msg' => $data['msg']); } } }else{ $data = Database::build()->setUpdate(static::$mappingDetail, $post, static::$prefixDetail) ->setWhere(static::$prefixDetail . "Id = '" . $post['txtIdDetail'] . "'") ->update(static::$tableDetail); if ($data['status'] == 'ok') { $valid = array('status' => 'ok', 'id' => $post['txtIdDetail']); } else { $valid = array('status' => 'error', 'msg' => $data['msg']); } } return $valid; } else { return $valid; } } /* =======================================================*/ /* ================= Delete Data =========================*/ protected function do_delete($where = false) { if(!$where) { $data = Database::build()->setWhere(static::$prefix . "Id='" . $_POST['txtId'] . "'") ->delete(static::$table); }else{ $data = Database::build()->setWhere($where) ->delete(static::$table); } if ($data['status'] == 'ok') { $valid = array('status' => 'ok'); } else { $valid = array('status' => 'error', 'msg' => $data['msg']); } return $valid; } protected function do_deletedetail() { $data = Database::build()->setWhere(static::$prefixDetail . "Id='" . $_POST['txtId'] . "'") ->delete(static::$tableDetail); if ($data['status'] == 'ok') { $valid = array('status' => 'ok'); } else { $valid = array('status' => 'error', 'msg' => $data['msg']); } return $valid; } /* =======================================================*/ protected function do_dataupload() { //echo static::$setWhereUpload; $data = Generaldb::instance() ->column(static::$mapping_upload) ->table(static::$tableUpload) ->where(static::$setWhereUpload) ->executeArr(); $i = 0; foreach ($data as $key => $val) { foreach (static::$mapping_upload as $key2 => $val2) { if (isset($val2['name'])) { $data[$i][$val2['name']] = $data[$i][$key2]; $data[$i]['path'] = str_replace("../", "", static::$pathupload) . 'thumb/'; } } $i++; } return $data; } /* private function generateColumn($mapping) { $column = array(); foreach($mapping as $key => $val){ $column[] = $key; } return $column; } */ function generateImage($name, $width, $height) { $output_dir = static::$pathupload; $upload = $_FILES[$name]["name"]; $type = $_FILES[$name]["type"]; $post = array(); if (!is_array($upload)) { //single file if (preg_match('/jpg|jpeg|gif|png/', $type)) { $fileName = time() . "_" . $upload; //$_POST['upload_type'] = static::$typeUpload; $post[$name] = $fileName; move_uploaded_file($_FILES[$name]["tmp_name"], $output_dir . $fileName); /*if (preg_match('/jpg|jpeg|png/', $type)) { Upload::resize_image($output_dir . $fileName, $output_dir . '/thumb/' . $fileName, $width, $height, $type); Upload::compress_image($output_dir . $fileName, $type); }*/ return array('status' => 'ok', 'data' => $post); }else{ return array('status' => 'error', 'msg' => 'Format Image Not Valid'); } } else { $fileCount = count($upload); for ($i = 0; $i < $fileCount; $i++) { if (preg_match('/jpg|jpeg|gif|png/', $type[$i])) { $typeData = $type[$i]; $fileName = time() . "_" . $upload[$i]; $_POST['upload_type'] = static::$typeUpload; $_POST[$name] = $fileName; $data = Database::build() ->setInsert(static::$mapping_upload, $_POST) ->insert(static::$tableUpload); $ret['img'][] = $fileName; move_uploaded_file($_FILES[$name]["tmp_name"][$i], $output_dir . $fileName); /*Upload::resize_image($output_dir . $fileName, $output_dir . '/thumb/' . $fileName, 200, 200, $typeData); Upload::compress_image($output_dir . $fileName, $type);*/ } else { $ret = array('status' => 'error', 'msg' => 'Format Not Valid'); } } return $ret; } } protected function do_upload() { $output_dir = static::$pathupload; $upload = $_FILES["upload_file"]["name"]; $type = $_FILES["upload_file"]["type"]; if (!is_array($upload)) { //single file $filename = time() . "_" . $upload; $_POST['upload_type'] = static::$typeUpload; $_POST['upload_file'] = $fileName; $data = Database::build() ->setInsert(static::$mapping_upload, $_POST) ->insert(static::$tableUpload); move_uploaded_file($_FILES["upload_file"]["tmp_name"], $output_dir . $filename); //echo "<br> Error: ".$_FILES["myfile"]["error"]; $ret['img'][] = $filename; return $ret; } else { $fileCount = count($upload); for ($i = 0; $i < $fileCount; $i++) { if (preg_match('/jpg|jpeg|gif|png/', $type[$i])) { $typeData = $type[$i]; $fileName = time() . "_" . $upload[$i]; $_POST['upload_type'] = static::$typeUpload; $_POST['upload_file'] = $fileName; $data = Database::build() ->setInsert(static::$mapping_upload, $_POST) ->insert(static::$tableUpload); $ret['img'][] = $fileName; move_uploaded_file($_FILES["upload_file"]["tmp_name"][$i], $output_dir . $fileName); Upload::resize_image($output_dir . $fileName, $output_dir . '/thumb/' . $fileName, 200, 200, $typeData); } else { $ret = array('status' => 'error', 'msg' => 'Format Not Valid'); } } return $ret; } } protected function do_deleteImage() { $path = static::$pathupload; $paththumb = $path . 'thumb/'; $unlink = Database::build()->dbgetone('SELECT CONCAT("' . $path . '",msugFileName) as unlink, CONCAT("' . $paththumb . '",msugFileName) as unlinkthumb FROM ' . static::$tableUpload . ' WHERE ' . static::$prefixUpload . ' = ' . $_POST['id'] . ''); $data = Database::build()->setWhere(static::$prefixUpload . "='" . $_POST['id'] . "'") ->delete(static::$tableUpload); if ($data['status'] == 'ok') { unlink($unlink['unlink']); unlink($unlink['unlinkthumb']); $valid = array('status' => 'ok'); } else { $valid = array('status' => 'error', 'msg' => $data['msg']); } return $valid; } function searchForId($id, $array, $name) { foreach ($array as $key => $val) { if (trim($val[$name]) === trim($id)) { return $key; } } return null; } function generateMapping($name, $type = 0) { $arrMapping = Database::build()->getAllDb('SELECT master_mapping_detail.* FROM master_mapping_header LEFT JOIN master_mapping_detail ON (mmphId = mmpdMmphId) WHERE mmphName = "' . $name. '" AND mmphType = "' . $type . '" ORDER BY mmpdSort ASC'); return $this->generateArrMap($arrMapping); } /* Belum kelar */ function generateArrMap($array) { $data = array(); foreach ($array as $key => $val) { if(!empty($val['mmpdData'])) { if(preg_match("/[|]/", $val['mmpdData'])) { $arrData = $val['mmpdData']; }else{ parse_str(html_entity_decode($val['mmpdData']), $arrData); } }else{ $arrData = ''; } $data[$val['mmpdFieldDb']] = array( 'type' => $val['mmpdType'], 'field' => $val['mmpdFieldName'], 'name' => $val['mmpdLabel'], 'validation' => $val['mmpdValidation'], 'grid' => $val['mmpdGrid'], 'class' => $val['mmpdClass'], 'display' => $val['mmpdDisplay'], 'disable' => $val['mmpdDisable'], 'event' => $val['mmpdEvent'], 'desc' => $val['mmpdDescription'], 'data' => $arrData ); } return $data; } protected function do_report() { return array('status' => 'ok'); } }