Add SPOTA core PHP application
Add the main admin, dosen, mahasiswa, API, and service code needed to run the core legacy application with configurable upload storage.
This commit is contained in:
126
mahasiswa/page/user/act.user.php
Normal file
126
mahasiswa/page/user/act.user.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
if ($_POST) {
|
||||
include '../../../inc/helper.php';
|
||||
include '../../../inc/konfigurasi.php';
|
||||
include '../../../inc/db.pdo.class.php';
|
||||
|
||||
$db = new dB($dbsetting);
|
||||
|
||||
switch ($_POST['act']) {
|
||||
case 'updatemyprofile':
|
||||
$id = $_POST['mhs'];
|
||||
if($_POST['noHP'] == $_POST['noHPOrtu']){
|
||||
echo json_encode(['result' => false, 'msg' => 'Nomor HP Mahasiswa tidak boleh sama dengan orang tua']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$noHP = $_POST['noHP'];
|
||||
$noHPOrtu = $_POST['noHPOrtu'];
|
||||
|
||||
$e = "SELECT * FROM tbmhs WHERE idmhs != '$id' AND (noHP = '$noHP' OR noHPOrtu = '$noHP' OR noHP = '$noHPOrtu' OR noHPOrtu = '$noHPOrtu')";
|
||||
$db->runQuery($e);
|
||||
if ($db->dbRows() > 0) {
|
||||
echo json_encode(['result' => false, 'msg' => 'Nomor HP Mahasiswa atau Orang Tua Telah digunakan oleh orang lain']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (ctype_digit($id)) {
|
||||
if (!isset($_FILES['foto']) || !is_uploaded_file($_FILES['foto']['tmp_name'])) {
|
||||
if ($_POST['password'] != '') {
|
||||
$pass = "password='".md5(trim($_POST['password']))."', ";
|
||||
} else {
|
||||
$pass = '';
|
||||
}
|
||||
$msg = 'Profil telah disimpan.';
|
||||
|
||||
$queryupdate = "UPDATE tbmhs
|
||||
SET
|
||||
nmLengkap='".$_POST['nmLengkap']."',
|
||||
noHP='".$_POST['noHP']."',
|
||||
noHPOrtu='".$_POST['noHPOrtu']."',
|
||||
$pass
|
||||
email='".$_POST['email']."'
|
||||
WHERE idmhs='$id'
|
||||
";
|
||||
} else {
|
||||
$ThumbSquareSize = 200; //Thumbnail will be 150x150
|
||||
$BigImageMaxSize = 200; //Image Maximum height or width
|
||||
$ThumbPrefix = 'thumb_'; //Normal thumb Prefix
|
||||
$DestinationDirectory = DIR_GAMBAR; //Upload Directory ends with / (slash)
|
||||
$Quality = 90;
|
||||
|
||||
$RandomNumber = rand(0, 9999999999);
|
||||
|
||||
$ImageName = str_replace(' ', '-', strtolower($_FILES['foto']['name']));
|
||||
$ImageSize = $_FILES['foto']['size']; // Obtain original image size
|
||||
$TempSrc = $_FILES['foto']['tmp_name']; // Tmp name of image file stored in PHP tmp folder
|
||||
$ImageType = $_FILES['foto']['type']; //Obtain file type, returns "image/png", image/jpeg, text/plain etc.
|
||||
|
||||
switch (strtolower($ImageType)) {
|
||||
case 'image/png':
|
||||
$CreatedImage = imagecreatefrompng($_FILES['foto']['tmp_name']);
|
||||
break;
|
||||
case 'image/gif':
|
||||
$CreatedImage = imagecreatefromgif($_FILES['foto']['tmp_name']);
|
||||
break;
|
||||
case 'image/jpeg':
|
||||
case 'image/pjpeg':
|
||||
$CreatedImage = imagecreatefromjpeg($_FILES['foto']['tmp_name']);
|
||||
break;
|
||||
default:
|
||||
echo json_encode(['result' => false, 'msg' => 'File gambar yang didukung hanya *.jpg,*.png,*.gif']);
|
||||
exit;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
list($CurWidth, $CurHeight) = getimagesize($TempSrc);
|
||||
$ImageExt = substr($ImageName, strrpos($ImageName, '.'));
|
||||
$ImageExt = str_replace('.', '', $ImageExt);
|
||||
|
||||
$ImageName = 'mhs';
|
||||
|
||||
$NewImageName = $ImageName.'_'.$RandomNumber.'.'.$ImageExt;
|
||||
$thumb_DestRandImageName = $DestinationDirectory.$NewImageName; //Thumb name
|
||||
if (!resizeImage($CurWidth, $CurHeight, $BigImageMaxSize, $thumb_DestRandImageName, $CreatedImage, $Quality, $ImageType)) {
|
||||
echo json_encode(['result' => false, 'msg' => 'Upload Gambar gagal']);
|
||||
exit;
|
||||
} else {
|
||||
$msg = 'Profil telah disimpan.';
|
||||
|
||||
if ($_POST['password'] != '') {
|
||||
$pass = "password='".md5(trim($_POST['password']))."', ";
|
||||
} else {
|
||||
$pass = '';
|
||||
}
|
||||
|
||||
$queryupdate = "UPDATE tbmhs
|
||||
SET
|
||||
nmLengkap='".$_POST['nmLengkap']."',
|
||||
$pass
|
||||
email='".$_POST['email']."',
|
||||
noHP='".$_POST['noHP']."',
|
||||
noHPOrtu='".$_POST['noHPOrtu']."',
|
||||
foto='".$NewImageName."'
|
||||
WHERE idmhs='$id'
|
||||
";
|
||||
@unlink(DIR_GAMBAR.$_POST['img']);
|
||||
}
|
||||
}
|
||||
if ($db->runQuery($queryupdate)) {
|
||||
echo json_encode(['result' => true, 'msg' => $msg]);
|
||||
$_SESSION['login-mhs']['nama_lengkap'] = $_POST['nmLengkap'];
|
||||
} else {
|
||||
//if($_POST['slider']=="Y"){
|
||||
@unlink($DestRandImageName);
|
||||
@unlink($thumb_DestRandImageName);
|
||||
//}
|
||||
echo json_encode(['result' => false, 'msg' => 'Aksi Gagal DbError']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
140
mahasiswa/page/user/my-profile.php
Normal file
140
mahasiswa/page/user/my-profile.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php $db = new dB($dbsetting);
|
||||
|
||||
$id = $_SESSION['login-mhs']['id'];
|
||||
$e = "SELECT * FROM tbmhs WHERE idmhs='$id' LIMIT 1";
|
||||
$db->runQuery($e);
|
||||
if ($db->dbRows() > 0) {
|
||||
$edit = $db->dbFetch();
|
||||
} else {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<i class="clip-home-3"></i>
|
||||
<a href="<?php echo MHS_PAGE; ?>">
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="active">
|
||||
Profil Saya
|
||||
</li>
|
||||
<li class="search-box">
|
||||
<label><?php echo tanggalIndo(date('Y-m-d H:i:s'), 'j F Y, H:i'); ?></label>
|
||||
</li>
|
||||
</ol>
|
||||
<div class="page-header">
|
||||
<h1>Profil Mahasiswa <small><strong><?php echo $edit['nmLengkap']; ?> </strong></small></h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="updateprofil" method="POST" enctype="multipart/form-data" action="page/user/act.user.php">
|
||||
<input type="hidden" name="act" value="updatemyprofile" />
|
||||
<input type="hidden" name="mhs" value="<?php echo $id; ?>" />
|
||||
<input type="hidden" name="img" value="<?php echo $edit['foto']; ?>" />
|
||||
<div class="row">
|
||||
<?php if(isset($_GET['kosong'])){ ?>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
Anda belum mengupdate nomor HP anda dan orang tua anda
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if(isset($_GET['sama'])){ ?>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
Nomor HP anda dan orang tua anda tidak boleh sama
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if(isset($_GET['pendek'])){ ?>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
Nomor HP anda atau orang tua anda terlalu pendek
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if(isset($_GET['terdaftar'])){
|
||||
$e = "SELECT * FROM tbmhs WHERE idmhs != '$id' AND (noHP = '$noHPIdent' OR noHPOrtu = '$noHPIdent' OR noHP = '$noHPIdentOrtu' OR noHPOrtu = '$noHPIdentOrtu')";
|
||||
$res = $db->runQuery($e);
|
||||
|
||||
$listMahasiswaSama = "";
|
||||
while($row=$db->dbFetch($res)){
|
||||
$listMahasiswaSama .= $row['nmLengkap'].'/'.$row['nim'].'<br>';
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
nomor HP anda atau orang tua anda terdaftar di mahasiswa lain, yaitu :<br><?php echo $listMahasiswaSama; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
NIM *
|
||||
</label>
|
||||
<input type="text" readonly class="form-control" id="nim" value="<?php echo $edit['nim']; ?>" name="nim"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
Nama Lengkap *
|
||||
</label>
|
||||
<input type="text" class="form-control" id="nmLengkap" value="<?php echo $edit['nmLengkap']; ?>" name="nmLengkap" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
Alamat Email
|
||||
</label>
|
||||
<input type="email" class="form-control" value="<?php echo $edit['email']; ?>" id="email" name="email" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
No. WA Mahasiswa (08XXXXXXXXX)
|
||||
</label>
|
||||
<input type="text" class="form-control" value="<?php echo $edit['noHP']; ?>" id="noHP" name="noHP" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
No. WA Orang Tua (08XXXXXXXXX)
|
||||
</label>
|
||||
<input type="text" class="form-control" value="<?php echo $edit['noHPOrtu']; ?>" id="noHPOrtu" name="noHPOrtu" />
|
||||
</div>
|
||||
<!-- <div class="form-group">
|
||||
<label class="control-label">
|
||||
No Telp
|
||||
</label>
|
||||
<input type="text" class="form-control" value="<?php echo $edit['nohp']; ?>" id="nohp" name="nohp" />
|
||||
</div> -->
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
Password * <sup>Abaikan Jika tidak mengganti password</sup>
|
||||
</label>
|
||||
<input type="password" class="form-control" name="password" id="password" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
Konfirmasi Password
|
||||
</label>
|
||||
<input type="password" class="form-control" id="password_again" name="password_again" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
Foto <sup>*Abaikan jika tidak mengganti foto</sup>
|
||||
</label>
|
||||
<div class="fileupload-new thumbnail" style="width: 150px; height: 150px;">
|
||||
<img src="../img/<?php echo $edit['foto']; ?>" alt="">
|
||||
</div><br/>
|
||||
<input type="file" class="form-control" id="foto" name="foto" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-teal btn-block" type="submit">
|
||||
Simpan Data
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
11
mahasiswa/page/user/user.php
Normal file
11
mahasiswa/page/user/user.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
switch ($_GET['menu']) {
|
||||
case 'my-profile':
|
||||
include "my-profile.php";
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "<script>location.href='".MHS_PAGE."dashboard.php?page=user&menu=my-profile'</script>";
|
||||
break;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user