| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/laragon/www/_sakip/modules/ |
Upload File : |
<?php
$alert = '';
if (isset($_POST['kirim'])) {
if (@$_POST['id'] == '') {
$data = array(
'judul' => @$_POST['judul'],
'kategori' => @$_POST['kategori'],
'tahun' => @$_POST['tahun'],
'file_sakip' => new CURLFILE($_FILES['file_sakip']['tmp_name'], $_FILES['file_sakip']['type'], $_FILES['file_sakip']['name']),
);
//disini menggunakan link demo
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sakip.lumajangkab.go.id/api-sakip/create',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13',
CURLOPT_HTTPHEADER => array(
'Token-Opd: ' . $token_anda,
'Content-Type:multipart/form-data',
),
));
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response, true);
if ($json['error'] === false) {
$alert = '<div class="alert alert-success">' . $json['message'] . '</div>';
unset($_POST);
} else {
$alert = '<div class="alert alert-danger">' . $json['message'] . '</div>';
}
} else {
$data = array(
'judul' => @$_POST['judul'],
'kategori' => @$_POST['kategori'],
'tahun' => @$_POST['tahun'],
'id_sakip' => @$_POST['id'],
);
if ($_FILES['file_sakip']['name'] != '' && $_FILES['file_sakip']['size'] > 0) {
$data['file_sakip'] = new CURLFILE($_FILES['file_sakip']['tmp_name'], $_FILES['file_sakip']['type'], $_FILES['file_sakip']['name']);
}
//disini menggunakan link demo
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sakip.lumajangkab.go.id/api-sakip/update',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13',
CURLOPT_HTTPHEADER => array(
'Token-Opd: ' . $token_anda,
'Content-Type:multipart/form-data',
),
));
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response, true);
if ($json['error'] === false) {
$alert = '<div class="alert alert-success">' . $json['message'] . '</div>';
unset($_POST);
} else {
$alert = '<div class="alert alert-danger">' . $json['message'] . '</div>';
}
}
}
$curl = curl_init();
$curl2 = curl_init();
$data = array(
'nama_opd' => $nama_opd,
'id_sakip' => (int) @$_GET['id'],
);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sakip.lumajangkab.go.id/api-sakip/read',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
));
curl_setopt_array($curl2, array(
CURLOPT_URL => 'https://sakip.lumajangkab.go.id/api-sakip/api-katsakip',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
));
$response = curl_exec($curl);
$response2 = curl_exec($curl2);
curl_close($curl);
curl_close($curl2);
$json = json_decode($response, true);
$json2 = json_decode($response2, true);
$satu = @$json['data'][0];
?>
<div class="row" style="margin-top: 50px">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading" style="height:50px">Form SAKIP
<a href="index.php?p=b_daftar_sakip" class="btn btn-sm btn-warning pull-right">
<i class="glyphicon glyphicon-arrow-left"></i> Kembali
</a>
</div>
<div class="panel-body">
<?=$alert?>
<form method="post" class="form-horizontal" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?=@$satu['id']?>">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="" class="col-md-3">Judul</label>
<div class="col-md-8">
<input type="text" name="judul" class="form-control" required="" value="<?=@$satu['judul']?>">
</div>
</div>
<div class="form-group">
<label for="" class="col-md-3">Kategori</label>
<div class="col-md-8">
<select name="kategori" class="form-control" required>
<option value="">Pilih</option>
<?php foreach ($json2['data'] as $key => $value) {
$selected = ($value['nama_katsakip'] == @$satu['kategori']) ? 'selected' : '';
?>
<option value="<?=$value['id_katsakip']?>" <?=$selected?> ><?=$value['nama_katsakip']?></option>
<?php }?>
</select>
</div>
</div>
<div class="form-group">
<label for="" class="col-md-3">Tahun SAKIP</label>
<div class="col-md-2">
<input type="text" class="form-control" name="tahun" required value="<?=@$satu['tahun']?>">
</div>
</div>
<div class="form-group">
<label for="" class="col-md-3">Upload File</label>
<div class="col-md-8">
<input type="file" name="file_sakip" class="form-control" <?=@$satu['id'] == '' ? 'required' : ''?> >
<span class="help-block">Maksimal 20 MB dan file yang diperbolehkan pdf</span>
<?php if(@$satu['id'] != ''){ ?>
<a href="<?=@$satu['link_file']?>" class="btn btn-sm btn-primary" target="_blank">Lihat File</a>
<?php } ?>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<button class="btn btn-success" name="kirim" value="1">Simpan</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>