Sistem Pakar Mendiagnosa Hama dan Penyakit Tanaman Karet Menggunakan Metode Dempster Shafer Dan Forward Chaining
LAMPIRAN A
Listing Program /*index.php/*
<title></title> <link rel="stylesheet" type="text/css" href="css/index.css"> <link rel="shortcut icon" href="image/rubber.png"/>
</head> <body>
<div class="wrapper-body"> <div id="body">
<div class="wrapper-menu"> <div id="menu">
<div class="wrapper-menu-vertical"> <?php error_reporting(0); if ($_GET['m']=="depan"){ include"menu_depan.php"; } elseif ($_GET['n']=="admin_masuk") { include"menu_admin.php";
} else{ include"menu_depan.php";
<html> <head>
</div> <span id="title-footer">&copy; 2015. Sistem Pakar Mendiagnosa Hama dan Penyakit Tanaman Karet ~ Damora Azri Mohara</span> elseif ($_GET['m']=="pertanyaan") { include"menu/diagnosa/pertanyaan.php"; } elseif ($_GET['m']=="hasil") { include"menu/diagnosa/hasil.php";
</div> </div> <div class="content">
<img src="image/rubber.png" id="img-title"> <span class="title-web1">Sistem Pakar</span> <span class="title-web2">Mendiagnosa Hama Dan
Penyakit Tanaman Karet</span> <div id="content-pengubah">
<?php error_reporting(0); if ($_GET['m']=="beranda") { include"menu/beranda/index.php"; } elseif ($_GET['m']=="penggunaan") { include"menu/penggunaan/index.php";
} elseif ($_GET['m']=="diagnosa") { include"menu/diagnosa/data_diri.php";
}
} ?>
} elseif ($_GET['m']=="admin") { include"menu/admin/login.php";
</li> <li><a href="?m=diagnosa">
<img src="image/logout1.png" id="img-menu">Keluar</a> </li>
<img src="image/input2.png" id="img-menu">Masukkan Data</a> </li> <li><a href="menu/admin/keluar/index.php">
<ul class="menu-vertical"> <li><a href="?n=admin_masuk&d=input" class="menu-vertical-border">
/*menu_admin.php/*
</ul>
<img src="image/admin3.png" id="img-menu">Admin</a> </li>
<img src="image/consul1.png" id="img-menu">Diagnosa</a> </li> <li><a href="?m=admin">
<img src="image/panduan2.png" id="img-menu">Cara Penggunaan</a>
} elseif ($_GET['d']=="beranda") { include"menu/admin/beranda/index.php";
<ul class="menu-vertical"> <li><a href="?m=penggunaan" class="menu-vertical-border">
/*menu_depan.php/*
</div> </body> </html>
</div> </div>
</div> </div> </div>
} ?>
} else{ include"menu/beranda/index.php";
} elseif ($_GET['d']=="input") { include"menu/admin/input/index.php";
</ul>
/*koneksi.php/*
<?php mysql_connect('localhost','root',''); mysql_select_db('pakar'); ?
/*login.php/*
<?php session_start(); error_reporting(0); $_SESSION['user']=$user; if(!empty($user)){ header('location:index.php?m=admin');
} else{ ?> <div class="masuk">
<span class="title-masuk">Login Admin</span> <form action="menu/admin/proses_login.php" method="post">
<div class="masuk1"> <img src="image/user.png" class="img-user-masuk"> <input type="text" name="username" placeholder="Nama
Pengguna" class="form-masuk" required> </div> <div class="masuk2">
<img src="image/password.png" class="img-user-masuk"> <input type="password" name="password" placeholder="Kata Sandi" class="form-masuk" required>
</div> <input type="submit" name="masuk" value="Masuk" class="button-masuk">
</form> </div> <?php } ?>
/*proses_login.php/*
<?php error_reporting(0); session_start(); $user=$_POST['username']; $password=$_POST['password']; include"koneksi.php"; $tampil=mysql_query("select * from login where username='$user' and password='$password'"); $row = mysql_num_rows($tampil); if ($row<1) { header('location:../../index.php?m=admin&g=gagal'); } else{ $_SESSION['user']=$user; header('location:../../index.php?n=admin_masuk&d=beranda'); } ?>
/*akarmerah.php/* Kelola Data
<span class="title-jenis">Penyakit Jamur Akar Merah</span> <div class="tambah"><img src="image/tambah.png" class="img-tambah"><a href="?n=admin_masuk&d=input&gejala=jam&gejala=tambah_jam" class="tambah-gejala">Tambah Gejala </a></div>
<form action="menu/admin/input/akarmerah/proses_tambah_gejala.php" method="post"> <div class="table"> <table class="table-aku">
<tr> <th>No.</th> <th>Hama atau Penyakit</th> <th>Gejala</th> <th>Bobot</th> <th>Aksi</th>
</tr> <?php error_reporting(0); include"koneksi.php"; $sql=mysql_query("select * from hama_penyakit where nama_hama_penyakit='Penyakit Jamur Akar Merah'"); $no=1; while ($data=mysql_fetch_array($sql)) { echo"<tr><td>".$no.".</td>
<td>$data[nama_hama_penyakit]</td> <td>$data[gejala]</td> <td>$data[bobot]</td> <td><a href='?n=admin_masuk&d=input&gejala=jam&gejala=edit_jam&id=$data[id]' class='edit'>Edit</a> ||
<a href='menu/admin/input/akarmerah/proses_hapus_jam.php?id=$data[id]' class='hapus'>Hapus</a>
</td> </tr>"; $no++;
} ?>
</table> </div>
</form>
/*edit.php/* Jamur Akar Merah
<span class="title-jenis">Penyakit Jamur Akar Merah</span> <span class="title-edit-gejala">Untuk mengubah gejala dan bobot, silahkan masukkan gejala dan bobot yang baru</span> <div class="wrapper-edit"> <?php include"koneksi.php"; $id=$_GET['id']; $sql=mysql_query("select * from hama_penyakit where id='$id'"); $data=mysql_fetch_array($sql); echo"<form action='menu/admin/input/akarmerah/proses_edit_gejala.php?id=$id' method='post'>
<table class='table-edit'> <tr>
<td class='title-hama_penyakit'>Nama Hama atau Penyakit</td>
<td><input type='text' name='nama_hama_penyakit' value='$data[nama_hama_penyakit]' class='form-hama_penyakit'></td> </tr> <tr>
<td class='title-gejala'>Gejala</td> <td><textarea rows='3' name='gejala' class='form- gejala'>$data[gejala]</textarea></td>
</tr> <tr>
<td class='title-belief'>Bobot</td> <td><input type='text' name='bobot' value='$data[bobot]' class='form-belief'></td>
</tr> <tr>
<td colspan='2'><input type='reset' value='Reset' class='button-reset-tambah'> <input type='submit' value='Simpan' class='button- simpan-tambah'></td>
</tr> </table>"; ?>
</form> </div>
/*proses_edit_gejala.php/* Jamur Akar Merah
<?php include"koneksi.php"; $id=$_GET['id']; $nama_hama_penyakit=$_POST['nama_hama_penyakit']; $gejala=$_POST['gejala']; $bobot=$_POST['bobot']; mysql_query("update hama_penyakit set nama_hama_penyakit='$nama_hama_penyakit',gejala='$gejala',bobot='$bobot' where id='$id'"); header('location:../../../../index.php?n=admin_masuk&d=input&gejala=jam' ); ?>
/*tambah.php/* Jamur Akar Merah
<span class="title-jenis">Penyakit Jamur Akar Merah</span> <span class="title-tambah-gejala">Untuk menambah gejala dan bobot, silahkan masukkan nama hama atau penyakit, gejala dan bobot</span> <div class="wrapper-tambah"> <form action="menu/admin/input/akarmerah/proses_tambah_gejala.php" method="post">
<table class="table-tambah"> <tr>
<td class="title-hama_penyakit">Nama Hama atau Penyakit</td>
<td><input type="text" name="nama_hama_penyakit" class="form-hama_penyakit"></td> </tr> <tr>
<td class="title-gejala">Gejala</td> <td><textarea rows="3" name="gejala" class="form- gejala"></textarea></td>
</tr> <tr>
<td class="title-belief">Bobot</td> <td><input type="text" name="bobot" class="form- belief"></td>
</tr> <tr>
<td colspan="2"><input type="reset" value="Reset" class="button-reset-tambah"> <input type="submit" value="Simpan" class="button- simpan-tambah"></td>
</tr> </table>
</form> </div>
/*prose_tambah_gejala.php/* Jamur Akar Merah
<?php include"koneksi.php"; $nama_hama_penyakit=$_POST['nama_hama_penyakit']; $gejala=$_POST['gejala']; $bobot=$_POST['bobot']; $sql=mysql_query("insert into hama_penyakit values('','$gejala','$nama_hama_penyakit','$bobot')"); if ($sql) { header('location:../../../../index.php?n=admin_masuk&d=input&gejala=jam' ); } ?>
/*proses_hapus.php/* Jamur Akar Merah
<?php mysql_connect('localhost','root',''); mysql_select_db('pakar'); $id=$_GET['id']; $hapus=mysql_query("delete from hama_penyakit where id='$id'"); if($hapus){ header('location:../../../../index.php?n=admin_masuk&d=input&gejal a=jam');
} ?>
/*data_diri.php/*
<div class="wrap-form-data"> <span id="title-form-data">Untuk melakukan diagnosa, silahkan isi terlebih dahulu data diri anda pada form dibawah ini.</span> <div id="form-data">
<form action="menu/diagnosa/proses_data.php" method="post"> <table>
<tr> <td class="title-form">Nama</td> <td><input type="text" name="nama" class="text-form" required title="Harap Isi Nama Anda!!!" placeholder="cth:Damora Azri Mohara"></td>
</tr> <tr>
<td class="title-form">Umur</td> <td><input type="text" name="usia" class="text-form-umur" required title="Harap Isi Umur Anda!!!" placeholder="cth:25"><span class="text-tahun">Tahun</span></td>
</tr> <tr>
<td class="title-form-jk">Jenis Kelamin</td>
<td><input type="radio" name="kelamin" value="Laki-laki" class="radio-form"><span class="radio-title- form">Laki-laki</span>
<input type="radio" name="kelamin" value="Perempuan" class="radio-form2"><span class="radio-title- form">Perempuan</span></td>
</tr> <tr>
<td class="title-form">Alamat</td> <td><textarea rows="3" name="alamat" class="text-form2" required title="Harap Isi Alamat Anda!!!" placeholder="cth:JL.Raya Menteng, Medan"></textarea></td>
</tr> <tr>
<td colspan="2"><input type="reset" value="Reset" class="button-form1"> <input type="submit" value="Simpan" class="button-form2"></td>
</tr> </table> </form></div></div>
/*proses_data.php/*
<?php session_start(); include"koneksi.php"; $nama=$_POST['nama']; $usia=$_POST['usia']; $kelamin=$_POST['kelamin']; $alamat=$_POST['alamat']; $sql=mysql_query("insert into pengguna values('','$nama','$usia','$kelamin','$alamat')"); $a=mysql_query("select max(id_pengguna) as id_maksimal from pengguna"); while($b=mysql_fetch_array($a)){
$id = $b['id_maksimal']; }
$_SESSION['id_maksimal']=$id; header('location: ../../index.php?m=pertanyaan'); ?>
/*pertanyaan.php/*
div class="wrap-pertanyaan"> <span class="title-pertanyaan">Diagnosa Hama dan Penyakit Tanaman
Karet</span> <span id="text-pertanyaan">Dihalaman diagnosa ini, anda dapat melakukan diagnosa terhadap hama dan penyakit tanaman karet dengan menjawab Ya atau Tidak terhadap pertanyaan- pertanyaan yang berhubungan dengan gejala-gejala yang muncul pada tanaman karet. Setelah itu akan ditampilkan hasil atau laporan.</span> <span class="title-pertanyaan2">Jawablah pertanyaan berikut ini dengan benar untuk mendapatkan hasil yang sesuai</span> <div id="wrap-pertanyaan2">
<?php session_start(); error_reporting(0); include"koneksi.php"; $id_session = $_SESSION['id_maksimal']; echo"<form action='menu/diagnosa/proses_pertanyaan.php?id=$id_session' method='POST'>
<table class='table-pertanyaan'> <tr>
<th>No.</th> <th>Pertanyaan</th> <th>Jawaban</th>
</tr>"; $sql=mysql_query("select * from hama_penyakit"); $no=1; while($data=mysql_fetch_array($sql)) { echo"<tr>
<td>".$no.".</td>
<td>$data[gejala]</td> <td><input type='radio' name='jwb$no' value='$data[id]' class='radio-jawaban'><span class='radio-title- jawaban'>Ya</span>
<input type='radio' name='jwb$no' value='tidak' class='radio-jawaban2'><span class='radio-title- jawaban'>Tidak</span></td>
</tr>"; $no++;
} ?>
</table> <tr>
<td><input type="submit" value="Lanjut" class="button-jawaban"></td> </tr>
</form> </div>
</div>
/*proses_pertanyaan/*
<?php ob_start(); session_start(); include"koneksi.php"; date_default_timezone_set("Asia/Jakarta"); $date = date('y-m-d'); $no = 1; while ($no <= 30) {
$id = $_POST["jwb$no"]; // $id_pertanyaan = $_POST['id']; if (!(empty($id)) and $id != 'tidak') { mysql_query("insert into jawaban values('".$_SESSION['id_maksimal']."','$id','YA','$date')");
} $no++;
} header("location:../../index.php?m=hasil"); ?>
/*jamurakarmerah/* Dempster Shafer
<?php // session_start(); error_reporting(0); include"koneksi.php"; $PTS = mysql_query("select * from hama_penyakit, jawaban where jawaban.id_pengguna='$X' and jawaban.tanggal='$date' and hama_penyakit.kode_hama_penyakit ='AM' and hama_penyakit.id = jawaban.id_pertanyaan"); $cba = 1;
$gf_yes = 0; while ($ijh = mysql_fetch_array($PTS)) { if ($ijh['jawaban']=="YA") {
$mkl =mysql_query("select * from hama_penyakit where id='".$ijh['id']."'"); $ijhDS = mysql_fetch_array($mkl); $nm[$cba] = $ijhDS['bobot']; $po[$cba] = $ijhDS['id']; $rq[$cba] = 1 - $nm[$cba]; // echo $nm[$gf_yes]." >> $gf_yes"."</br>"; $gf_yes++; $cba++;
$rti[$qwr] = $rq[$qwr] * $nm[$qwr];
// echo $hgf; $qsd = substr($po[$hgf], 0,1); $jh = substr($po[$hgf], 0,1); $ut = 0; if ($qsd != $jh) {
} }elseif($hgf > 2){
} $O[$hgf] += $rti[$hgf];
$rq[$qwr]; } $O[$hgf] += $gty[$qwr]; $yO[$hgf] += $nml[$qwr]; $qwr++;
$rq[$qwr-1]; $nml[$qwr] = $rq[$qwr-1] *
}else{ $gty[$qwr] = $nm[$qwr-1] *
$gty[$qwr] = $nm[$qwr] * $nm[$qwr+1];
} // echo $nm[7]."</br>";
$qwr = 1; while($qwr <= 2){ if ($qwr < 2) {
$ut[$hgf] = $nm[$hgf] + $nm[$hgf+1]; }else{
$qsd = substr($po[$hgf], 0,1); $jh = substr($po[$hgf], 0,1); $ut = 0; if ($qsd != $jh) {
}else{ $hgf = 1; while ($hgf < $cba) { if ($hgf < 2) {
$jam = $nm[1]; //echo $jam;
} // echo $gf_yes; if ($gf_yes == 1) {
$ut[$hgf] = $nm[$hgf] + $nm[$hgf+1]; }else{
$qwr = 1; while($qwr <= $hgf){ // echo $hgf; if ($qwr < 2) {
$gty[$qwr] = $O[$hgf-2] * $nm[$hgf];
$rti[$qwr] = $rq[$hgf] * $O[$hgf-2];
$edi = $gty[$qwr] + $rti[$qwr];
}else{ $gty[$qwr] = $yO[$hgf-2] *
$nm[$hgf]; $nml[$qwr] = $yO[$hgf-2] *
$rq[$hgf]; } $yO[$hgf] += $nml[$qwr]; $qwr++;
} $O[$hgf-1] = $edi + $gty[$hgf]; $yO[$hgf-1] = $nml[$hgf-1]; // echo $hgf;
} }
$jam = $O[$hgf-1]."</br>"; $hgf++;
} } ?>
/*hasil/*
<div class="hasil"> <span class="title-hasil">Hasil Diagnosa Hama atau Penyakit
Tanaman Karet </span> <span id="text-hasil"> Dari laporan diagnosis ini, anda dapat mengetahui jenis hama dan penyakit apa yang dialami tanaman karet, sehingga anda dengan cepat dapat menanganinya dan melakukan pengendalian lebih lanjut.</span> <div id="hasil2">
<form action="menu/diagnosa/proses_hasil.php" method="post"> <?php session_start(); include"koneksi.php"; date_default_timezone_set("Asia/Jakarta"); $date = date('y-m-d'); $X = $_SESSION['id_maksimal']; include"jamurakarmerah.php"; include"jamurakarputih.php"; include"hamakutu.php"; include"hamarayap.php"; // include"kankergaris.php"; // include"mouldyrot.php"; // include"brownblast.php"; if ($rayap >= $kutu and $rayap >= $jam and $rayap >= $jap and $rayap >= $kanker and $rayap >=$mouldy and $rayap >= $brown) {
$kode = "R"; $HP = "Hama Rayap"; $nilai = $rayap;
}elseif ($kutu >= $rayap and $kutu >= $jam and $kutu >= $jap and $kutu >= $kanker and $kutu >= $mouldy and $kutu >= $brown) { $kode = "K"; $HP = "Hama Kutu"; $nilai = $kutu;
} elseif($jam >= $kutu and $jam >= $rayap and $jam >= $jap and $jam >= $kanker and $jam >= $mouldy and $jam >= $brown){
$kode = "AM"; $HP = "Penyakit Jamur Akar Merah"; $nilai = $jam;
} elseif ($jap >= $jam and $jap >= $rayap and $jap >= $kutu and $jap >= $kanker and $jap >= $mouldy and $jap >=$brown ) {
$kode = "AP"; $HP = "Penyakit Jamur Akar Putih"; $nilai = $jap;
} elseif ($kanker >= $kutu and $kanker >= $rayap and $kanker >= $jap and $kanker >= $jam and $kanker >= $mouldy and $kanker >= $brown) {
$kode = "KG"; $HP = "Penyakit Kanker Garis"; $nilai = $kanker;
} elseif ($mouldy >= $kutu and $mouldy >= $rayap and $mouldy >= $jap and $mouldy >= $jam and $mouldy >= $kanker and $mouldy >= $brown) {
$kode = "MR"; $HP = "Penyakit Mouldy Rot"; $nilai = $mouldy;
} elseif ($brown >= $kutu and $brown >= $rayap and $brown >= $jap and $brown >= $jam and $brown >= $kanker and $brown >= $mouldy) {
$kode = "BB"; $HP = "Penyakit Brown Blast"; $nilai = $brown;
} $sql=mysql_query("select * from pengguna where id_pengguna='".$X."'"); $data=mysql_fetch_array($sql); echo"
<table> <tr>
<td class='title-hasil2'>Nama Pengguna</td>
<td class='titikdua-hasil'>:</td> <td class='text-hasilnya'>$data[nama]</td>
</tr> <tr>
<td class='title-hasil2'>Umur</td> <td class='titikdua-hasil'>:</td> <td class='text-hasilnya'>$data[umur]
Tahun</td> </tr> <tr>
<td class='title-hasil2'>Jenis Kelamin</td>
<td class='titikdua-hasil'>:</td> <td class='text- hasilnya'>$data[kelamin]</td>
</tr> <tr>
<td class='title-hasil2'>Alamat</td> <td class='titikdua-hasil'>:</td> <td class='text- hasilnya'>$data[alamat]</td>
</tr> <tr>
<td class='title-hasil2'>Nama Hama atau Penyakit</td>
<td class='titikdua-hasil'>:</td> <td class='text-hasilnya'>$HP</td>
</tr> <tr>
<td class='title-hasil2'>Gejala</td> <td class='titikdua-hasil'>:</td> <td class='text-hasilnya'>";
$sqlGej = mysql_query("select * from hama_penyakit where kode_hama_penyakit = '".$kode."'"); $no = 1; while
($data=mysql_fetch_array($sqlGej)) { echo $no.". ".$sol = $data['gejala'],"</br>";
$no++; } echo"</td>
</tr> <tr>
<td class='title-hasil2'>Densitas</td> <td class='titikdua-hasil'>:</td> <td class='text-hasilnya'> $nilai</td>
</tr> <tr>
<td class='title-hasil2'>Solusi</td> <td class='titikdua-hasil'>: </td> <td class='text-hasilnya'>";
$sqlSol = mysql_query("select * from solusi where kode_hama_penyakit = '".$kode."'"); $no=1; while
($data=mysql_fetch_array($sqlSol)) { echo $no.". ".$sol = $data['solusi'];
} echo "</td> </tr> <tr>
<td colspan='5'><input type='submit' value='Diagnosa Lagi' class='button-diagnosa1'></td> <td><a href='menu/diagnosa/selesai.php' class='button-diagnosa2'> <span class='selesai'>Selesai</span> </a></td>
</tr> </table>"; ?>
</form> </div>
</div>
/*proses_hasil.php/*
<?php header('location:../../index.php?m=diagnosa'); ?>