One Hat Cyber Team
Your IP :
172.16.0.254
Server IP :
58.26.163.33
Server :
Windows NT DGPENSV2LPKMN 10.0 build 14393 (Windows Server 2016) AMD64
Server Software :
Apache/2.4.46 (Win64) OpenSSL/1.1.1h PHP/7.3.25
PHP Version :
7.3.25
Buat File
|
Buat Folder
Eksekusi
Dir :
C:
/
xampp7
/
htdocs
/
edgpens
/
View File Name :
readtext.php
<?php include 'odbc.php'; $fp = fopen($_GET['txt'], "r+"); $bil = 1; $tot = 0; $arr = array(); $arr_t = array(); $arr_n = array(); $t_line = ""; $arr_l = array(); $comp = 0; $indnow = 0; if($_GET['typ']=='companies'){ while (($line = stream_get_line($fp, 1024 * 1024, "\n")) !== false) { $rdline = preg_split('/ +/', $line, null, PREG_SPLIT_NO_EMPTY); if($bil==1) $tot = count($rdline); if($bil==2){ for ($i=0; $i < $tot ; $i++) { array_push($arr, strlen($rdline[$i])-1); } } if($bil>2){ $tox = 0; $arr_d = array(); for ($i=0; $i < $tot ; $i++) { array_push($arr_d, substr($line,$tox,$arr[$i])); $tox+=$arr[$i]; } $id = trim(substr($line,0,11)); $int_id = (int)$id; if(is_numeric($id)){ $xline=$line; $arr_l[$indnow]=$xline; $comp = $indnow; }else{ $xline.=$line; $arr_l[$comp]=$xline; } $indnow++; } $bil++; } fclose($fp); $sql = "INSERT INTO kod_syarikat (nama,alamat,noTel,noFax,idJenisSyarikat,oldid,flagAktif,flagApprove) VALUES "; $arx = []; foreach ($arr_l as $key => $value) { $tox = 0; $arr_d = array(); for ($i=0; $i < $tot ; $i++) { $val = strtoupper(substr($value,$tox,$arr[$i])); array_push($arr_d, $val); $tox+=$arr[$i]; } $sql .= "(?,?,?,?,?,?,'Y','Y'),"; array_push($arx,trim($arr_d[1])); array_push($arx,trim($arr_d[2])); array_push($arx,trim($arr_d[4])); array_push($arx,trim($arr_d[5])); array_push($arx,trim($arr_d[6])); array_push($arx,trim($arr_d[0])); } }else if($_GET['typ']=='vessels'){ $sql = "INSERT INTO kod_kapal_test (nama,IMO,idSyarikat,Flag,CallSign,idJenisKapal,GT,flagAktif,flagApprove) VALUES "; $arx = []; $fp = fopen("vessel2.txt", "r+"); // $fp = mb_convert_encoding($fp, "UTF-8"); // print_r($fp); // mb_convert_encoding($line, "UTF-8"); while (($line = stream_get_line($fp, 1024 * 1024, "\n")) !== false) { // $rdline = preg_split("/[|]/i",utf8_decode($line)); $rdline = preg_split("/[|]/i",$line); // str_split(string) // echo ; // print_r($rdline); // echo "<br>"; // print_r($rdline); if($bil==1) $tot = count($rdline); // if($bil>2){ // $tox = 0; // $arr_d = array(); // for ($i=0; $i < $tot ; $i++) { // array_push($arr_d, substr($line,$tox,$arr[$i])); // $tox+=$arr[$i]; // } // } // $arr_d == $rdline; print_r($rdline); $id = trim($rdline[0]); if($bil>2 && $id != ''){ echo $id."<br>"; $sql .= "(?,?,?,?,?,?,?,'Y','Y'),"; array_push($arx,trim($rdline[1])); array_push($arx,trim($rdline[2])); array_push($arx,trim($rdline[3])); array_push($arx,trim($rdline[4])); array_push($arx,trim($rdline[5])); array_push($arx,trim($rdline[6])); array_push($arx,trim($rdline[7])); } $bil++; } // echo mb_detect_encoding(feof($fp)); // $fp = mb_convert_encoding($fp, "UTF-8"); // while(!feof($fp)) { // $line = fgets($fp); // echo utf8_decode($line); // echo $line; // echo 'xyz'; // echo utf8_decode(html_entity_decode($line, ENT_QUOTES, 'UTF-8')); // echo html_entity_decode($line, ENT_QUOTES, 'UTF-8'); // echo "<br>xxxx"; // echo "<br>"; // } fclose($fp); }else if($_GET['typ']=='dg'){ while (($line = stream_get_line($fp, 1024 * 1024, "\n")) !== false) { $rdline = preg_split('/ +/', $line, null, PREG_SPLIT_NO_EMPTY); if($bil==1) $tot = count($rdline); if($bil==2){ for ($i=0; $i < $tot ; $i++) { array_push($arr, strlen($rdline[$i])-1); } } if($bil>2){ $tox = 0; $arr_d = array(); for ($i=0; $i < $tot ; $i++) { array_push($arr_d, substr($line,$tox,$arr[$i])); $tox+=$arr[$i]; } $id = trim(substr($line,0,11)); $int_id = (int)$id; if(is_numeric($id)){ $xline=$line; $arr_l[$indnow]=$xline; $comp = $indnow; }else{ $xline.=$line; $arr_l[$comp]=$xline; } $indnow++; } $bil++; } fclose($fp); $sql = "INSERT INTO kod_dg (UNNumber,IMOClass,nama,KPAGroup,properties,flagAktif) VALUES "; $arx = []; foreach ($arr_l as $key => $value) { $tox = 0; $arr_d = array(); for ($i=0; $i < $tot ; $i++) { $val = strtoupper(substr($value,$tox,$arr[$i])); array_push($arr_d, $val); $tox+=$arr[$i]; } $sql .= "(?,?,?,?,?,'Y'),"; array_push($arx,(trim($arr_d[3])=='NULL') ? '' : trim($arr_d[3])); array_push($arx,(trim($arr_d[2])=='NULL') ? '' : trim($arr_d[2])); array_push($arx,(trim($arr_d[1])=='NULL') ? '' : trim($arr_d[1])); array_push($arx,(trim($arr_d[4])=='NULL') ? '' : trim($arr_d[4])); array_push($arx,(trim($arr_d[5])=='NULL') ? '' : trim($arr_d[5])); // array_push($arx,trim($arr_d[0])); } }else if($_GET['typ']=='vtype'){ while (($line = stream_get_line($fp, 1024 * 1024, "\n")) !== false) { $rdline = preg_split('/ +/', $line, null, PREG_SPLIT_NO_EMPTY); if($bil==1) $tot = count($rdline); if($bil==2){ for ($i=0; $i < $tot ; $i++) { array_push($arr, strlen($rdline[$i])-1); } } if($bil>2){ $tox = 0; $arr_d = array(); for ($i=0; $i < $tot ; $i++) { array_push($arr_d, substr($line,$tox,$arr[$i])); $tox+=$arr[$i]; } $id = trim(substr($line,0,11)); $int_id = (int)$id; if(is_numeric($id)){ $xline=$line; $arr_l[$indnow]=$xline; $comp = $indnow; }else{ $xline.=$line; $arr_l[$comp]=$xline; } $indnow++; } $bil++; } fclose($fp); $sql = "INSERT INTO kod_jenis_kapal (nama,flagAktif,oldid) VALUES "; $arx = []; foreach ($arr_l as $key => $value) { $tox = 0; $arr_d = array(); for ($i=0; $i < $tot ; $i++) { $val = strtoupper(substr($value,$tox,$arr[$i])); array_push($arr_d, $val); $tox+=$arr[$i]; } $sql .= "(?,'Y',?),"; array_push($arx,(trim($arr_d[1])=='NULL') ? '' : trim($arr_d[1])); array_push($arx,(trim($arr_d[0])=='NULL') ? '' : trim($arr_d[0])); } print_r($arx); }else if($_GET['typ']=='port'){ while (($line = stream_get_line($fp, 1024 * 1024, "\n")) !== false) { $rdline = preg_split('/ +/', $line, null, PREG_SPLIT_NO_EMPTY); if($bil==1) $tot = count($rdline); if($bil==2){ for ($i=0; $i < $tot ; $i++) { array_push($arr, strlen($rdline[$i])-1); } } if($bil>2){ $tox = 0; $arr_d = array(); for ($i=0; $i < $tot ; $i++) { array_push($arr_d, substr($line,$tox,$arr[$i])); $tox+=$arr[$i]; } $id = trim(substr($line,0,11)); $int_id = (int)$id; if(is_numeric($id)){ $xline=$line; $arr_l[$indnow]=$xline; $comp = $indnow; }else{ $xline.=$line; $arr_l[$comp]=$xline; } $indnow++; } $bil++; } fclose($fp); $sql = "INSERT INTO kod_pelabuhan_imp (nama,hadMasa,flagAktif,namaNegara,oldid) VALUES "; $arx = []; foreach ($arr_l as $key => $value) { $tox = 0; $arr_d = array(); for ($i=0; $i < $tot ; $i++) { $val = strtoupper(substr($value,$tox,$arr[$i])); array_push($arr_d, $val); $tox+=$arr[$i]; } $sql .= "(?,?,'Y',?,?),"; array_push($arx,(trim($arr_d[1])=='NULL') ? '' : trim($arr_d[1])); array_push($arx,(trim($arr_d[3])=='NULL') ? '' : trim($arr_d[3])); array_push($arx,(trim($arr_d[2])=='NULL') ? '' : trim($arr_d[2])); array_push($arx,(trim($arr_d[0])=='NULL') ? '' : trim($arr_d[0])); } } $mysqli->set_charset("utf8"); $sql = substr($sql, 0, -1); $types = str_repeat('s', count($arx)); $stmt = $mysqli->stmt_init(); $stmt->prepare($sql); $stmt->bind_param($types, ...$arx); $stmt->execute() or die(mysqli_error($mysqli)); $stmt->close(); echo "DONE!";