Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php if(isset($_POST["submit"])){ function rmdir_recursive($dir) { foreach(scandi..
Decoded Output download
<script>javascript: alert('Upload zip File')></script>
Did this file decode correctly?
Original Code
<?php
if(isset($_POST["submit"])){
function rmdir_recursive($dir) {
foreach(scandir($dir) as $file) {
if ('.' === $file || '..' === $file) continue;
if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file");
else unlink("$dir/$file");
}
rmdir($dir);
}
function deleteAll($dir) {
foreach(glob($dir . '/*') as $file) {
if(is_dir($file)){
deleteAll($file);
$parts = explode('/', $file);
$sub_dir = $parts[1];
rmdir($dir.'/'.$sub_dir);
}else{
unlink($file);
}
}
}
if($_FILES["zip_file"]["name"]) {
deleteAll('zip_folder');
$filename = $_FILES["zip_file"]["name"];
$source = $_FILES["zip_file"]["tmp_name"];
$type = $_FILES["zip_file"]["type"];
$name = explode(".", $filename);
$accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
foreach($accepted_types as $mime_type) {
if($mime_type == $type) {
$okay = true;
break;
}
}
$continue = strtolower($name[1]) == 'zip' ? true : false;
if(!$continue) {
$message = "The file you are trying to upload is not a .zip file. Please try again.";
}
/* PHP current path */
$path = dirname(__FILE__).'/zip_folder/'; // absolute path to the directory where zipper.php is in
$filenoext = basename ($filename, '.zip'); // absolute path to the directory where zipper.php is in (lowercase)
$filenoext = basename ($filenoext, '.ZIP'); // absolute path to the directory where zipper.php is in (when uppercase)
$targetdir = $path . $filenoext; // target directory
$targetzip = $path . $filename; // target zip file
/* create directory if not exists', otherwise overwrite */
/* target directory is same as filename without extension */
if (is_dir($targetdir)) rmdir_recursive ( $targetdir);
mkdir($targetdir, 0777);
/* here it is really happening */
if(move_uploaded_file($source, $targetzip)) {
$zip = new ZipArchive();
$x = $zip->open($targetzip); // open the zip file to extract
if ($x === true) {
$zip->extractTo($targetdir); // place in the directory with same name
$zip->close();
unlink($targetzip);
}
$message = "Your .zip file was uploaded and unpacked.";
} else {
$message = "There was a problem with the upload. Please try again.";
}
}
}else{
echo "<script>javascript: alert('Upload zip File')></script>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Document</title>
<link rel="stylesheet" href="css/mystyle.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript">
/**
* Basic jQuery Validation Form Demo Code
* Copyright Sam Deering 2012
* Licence: http://www.jquery4u.com/license/
*/
(function($,W,D)
{
var JQUERY4U = {};
JQUERY4U.UTIL =
{
setupFormValidation: function()
{
//form validation rules
$("#upload_form").validate({
error: function(label) {
$(this).addClass("error");
},
rules: {
zip_file: {required: true, accept: "zip"}
},
messages: {
zip_file:"Please Upload ZiP file",
},
submitHandler: function(form) {
form.submit();
}
});
}
}
//when the dom has loaded setup form validation rules
$(D).ready(function($) {
JQUERY4U.UTIL.setupFormValidation();
});
})(jQuery, window, document);
</script>
<style>
#upload_form .form-group label.error
{
color:#FF0000; /* red */
width: 100%;
margin-left: 0px;
text-align: center;
}
</style>
<!-- jQuery UI 1.10.3 -->
</head>
<body>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 section_ptn">
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12 side1">
<!---<label>people</label>-->
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 file">
<h5 class="Nric_h5">NRIC</h5>
<a type="button" id="apply_now" class="apply_now" data-toggle="modal" data-target="#myModal" data-whatever=""><i class="fas fa-folder-open"></i></a>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 search">
<input placeholder="Search Me" id="box" type="text" class="text1" />
</div>
<div id="search_detail" >
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 list">
<ul class="navList list_ul">
<?php
if(isset($_POST["submit"])){
// Read JSON file
if($_FILES["zip_file"]["name"]) {
function dirToArray($dir) {
$result = array();
$cdir = scandir($dir);
foreach ($cdir as $key => $value)
{
if (!in_array($value,array(".","..")))
{
if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
{
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
}
else
{
$result[] = $value;
}
}
}
return $result;
}
$get = dirToArray('zip_folder');
$arr_get = array_shift($get);
$jsonfile = $arr_get[0];
$json = file_get_contents(''.$targetdir.'/'.$jsonfile);
$json_data = json_decode($json,true);
if($json_data){
$arr_get = array_shift($json_data);
//print_r($arr_get);
$i = 1;
foreach($arr_get as $rows) {
// print_r($rows);
// $firstLetter = strtoupper(substr($rows['title'], 0, 1));
?>
<!---<h1 class="initial">P</h1>-->
<li class="tablinks <?php if($i == 1){ ?>active<?php } ?>" onclick="openCity(event, '<?php echo $rows['patientId']; ?>')" <?php if($i == 1){ ?>id="defaultOpen"<?php } ?> ></a href="#"><?php echo $rows['name']; ?></a></li>
<?php $i++; } } } } ?>
</ul>
</div>
</div> <div style="clear:both;"></div>
</div>
<?php
if(isset($_POST["submit"])){
if($_FILES["zip_file"]["name"]) {
// Read JSON file
$json = file_get_contents(''.$targetdir.'/'.$jsonfile);
$json_data = json_decode($json,true);
if($json_data){
$arr_get = array_shift($json_data);
//$keys = array_column($json_data, 'title');
//$result = array_multisort($keys, SORT_ASC, $json_data);
//sizeof($json_data);
$j = 1;
foreach($arr_get as $rows) {
?>
<div id="<?php echo $rows['patientId']; ?>" class="tabcontent tab_<?php echo $rows['patientId']; ?>" style="<?php if($j == 1){ ?>display:block<?php }else{ ?>display:none<?php }?>" >
<div class="col-lg-3 col-md-5 col-sm-5 col-xs-12 side2_sub1">
<div class="col-lg-12 col-md-12 dots">
<i class="fas fa-ellipsis-h"></i>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 view">
<img src="img/img2.jpg" class="view_img">
<h4 class="view_h4"><?php echo $rows['name']; ?></h4>
<hr class="hr1">
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 contact message">
<h4 class="message_h4">Identity No</h4>
<span><?php echo $rows['identityNo']; ?></span>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 contact message">
<h4 class="message_h4">Identity Type</h4>
<span><?php echo $rows['identityType']; ?></span>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 contact message">
<h4 class="message_h4">Allergy</h4>
<span><?php echo $rows['allergy']; ?></span>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 contact skype app">
<h4 class="app_h4">Mobile Number</h4>
<span><?php echo $rows['mobile']; ?></span>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 contact skype app">
<h4 class="app_h4">Gender</h4>
<span><?php echo $rows['gender']; ?></span>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 contact skype app">
<h4 class="app_h4">Date Of Birth</h4>
<span><?php echo $rows['dateOfBirth']; ?></span>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 contact skype video_call">
<h4 class="video_h4">Age In Days</h4>
<span><?php echo $rows['ageInDays']; ?></span>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 contact skype video_call">
<h4 class="video_h4">Age</h4>
<span><?php echo $rows['age']; ?></span>
</div>
</div>
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12 side3_sub1">
<div class="patient_details">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 history" style="border-left:5px solid #eeeeee; height: auto;">
<h3 class="info_h3 visit">Visit History</h3>
<div class="emrs" style="margin: 0 15px;">
<?php
$emrs = $rows['emrs'];
//echo "<pre>";
//print_r($emrs);
//echo "</pre>";
$keys = array_keys($emrs);
for($i = 0; $i < count($emrs); $i++) {
//echo $keys[$i] . "<br>";
foreach($emrs[$keys[$i]] as $key => $value) {
if($key == 'attachments' || $key == 'medicalCerts' || $key == 'invoices'){
echo "<h4>". ucfirst($key) . "</h4>";
foreach($value as $values) {
foreach($values as $p_keys => $valuess) {
echo "<p><label>".$p_keys . "</label> : " . $valuess . "<p>";
//print_r($valuess);
}
}
}else if($key == 'prescriptions'){
echo "<h4>".ucfirst($key) . "</h4>";
// echo count($values);
// print_r($values);
?>
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Quantity</th>
<th>Consume</th>
<th>Amount</th>
<th>QuantityUOM</th>
<th>Frequency</th>
</tr>
</thead>
<tbody>
<?php
$k = 1;
foreach($value as $valuess) {
//print_r($valuess);
?>
<tr>
<td><?php echo $k; ?></td>
<td><?php echo $valuess['itemName']; ?></td>
<td><?php echo $valuess['itemQuantity']; ?></td>
<td><?php echo $valuess['itemConsume']; ?></td>
<td><?php echo $valuess['itemAmount']; ?></td>
<td><?php echo $valuess['itemQuantityUOM']; ?></td>
<td><?php echo $valuess['itemFrequency']; ?></td>
</tr>
<?php $k++; } ?>
</tbody>
</table>
</div>
<?php
}else{
echo "<p><label>". $key . "</label> : " . $value . "<p>";
}
}
echo "<br>";
}
?>
<h4 class="">Documents</h4>
<?php
$documents = $rows['documents'];
// print_r($documents);
foreach($documents as $document) {
foreach($document as $d_keys => $docum) {
echo "<p class='att_p' style='word-wrap:break-word;'><label>". $d_keys . "</label> : " . $docum . "<p>";
}
}
?>
</div>
</div>
</div>
</div>
</div>
<?php $j++; } } } } ?>
</div><!-----/overall div ------->
<!------ Search script------>
<script>
$("document").ready(function () {
$("#box").on("keyup", function () {
var searchText = $(this).val();
searchText = searchText.toLowerCase();
searchText = searchText.replace(/\s+/g, '');
$('.navList > li').each(function(){
var currentLiText = $(this).text(),
showCurrentLi = ((currentLiText.toLowerCase()).replace(/\s+/g, '')).indexOf(searchText) !== -1;
$(this).toggle(showCurrentLi);
});
});
});
</script>
<!------ Div script------>
<script>
function openCity(evt, cityName) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
</script>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content upload_model">
<form enctype="multipart/form-data" method="post" id="upload_form" action="">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Upload File</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="pwd">Choose a zip file:</label>
<input type="file" class="form-control" id="zip_file" name="zip_file">
</div>
</div>
<div class="modal-footer">
<div style="text-align:right;margin-right:10px;">
<input name="submit" type="submit" class="submit_apply btn btn-primary" value="Apply">
</div>
<!---<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>--->
</div>
</form>
</div>
</div>
</div>
<!-- End Modal -->
</body>
</html>
Function Calls
| None |
Stats
| MD5 | e2909ef3f7f739ce15c8d77804437823 |
| Eval Count | 0 |
| Decode Time | 118 ms |