Skip to content

Instantly share code, notes, and snippets.

@novalagung
Created November 9, 2012 02:13
Show Gist options
  • Save novalagung/4043288 to your computer and use it in GitHub Desktop.
Save novalagung/4043288 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<style>
html, body {
height: 100%;
width: 100%;
overflow: hidden;
}
.center-middle {
display: table;
height: 100%;
width: 100%;
}
.center-middle > div {
display: table-cell;
height: 100%;
width: 100%;
vertical-align: middle;
}
#main {
height: 500px;
width: 500px;
margin: 0px auto;
background-color: #FDFDFD;
}
textarea[name=file-content] {
width: 693px;
height: 300px;
}
</style>
</head>
<body>
<?php
$is_file_uploaded = false;
$file_target_name = '';
if (isset($_POST['submit']) && $_POST['submit'] == 'Read') {
$file_target_name = basename($_FILES['file-target']['name']);
if (move_uploaded_file($_FILES['file-target']['tmp_name'], $file_target_name)) {
$is_file_uploaded = true;
/**
* friska, tinggal masukin ke database,
* taruh aja koding nya di baris ini. tambahin sendiri ya
*/
}
}
?>
<div class="center-middle">
<div>
<div id="main">
<form enctype="multipart/form-data" method="post">
<div>
<label>Choose a file</label>
<input type="file" required name="file-target" />
<input type="submit" name="submit" value="Read" />
</div>
<div>
<textarea name="file-content">
<?php
if ($is_file_uploaded) {
$file_target_handler = fopen($file_target_name, "r");
$i = 0;
$cloned_target = array();
if (!feof($file_target_handler)) {
while ($row = fgets($file_target_handler)) {
$i++;
$cloned_target [] = $row;
}
$e = $i;
fclose($file_target_handler);
$i = 0;
echo "\n";
foreach ($cloned_target as $row) {
$i++;
if ($i > 15 && $i < $e - 12) {
if (strpos($row, 'HST') !== false) {
$row1 = trim(str_replace('HST', '', $row));
$row1 = explode('QUAL', $row1);
$row1 = str_replace(')', '),', trim($row1[0])) . ", " . trim($row1[1]);
echo $row1 . "\n";
}
if (strpos($row, '**') !== false || strpos($row, '..') !== false) {
$row2 = trim(str_replace('**', '', $row));
$row2 = trim(str_replace('..', '', $row2));
echo $row2 . "\n";
}
if (strpos($row, '3G_') !== false) {
$row3 = trim($row);
echo $row3 . "\n\n";
}
}
}
}
}
?>
</textarea>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment