Sistem Informasi Berbasis Web Pada Sekolah Sma Tamansiswa Binjai

(1)

LISTING PROGRAM

1.

Index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <meta name="author" content="prastomi" />

<meta name="description" content="Tamansiswa"/> <meta name="keywords" content="sekolah menengah"/> <title>Selamat Datang di Tamansiswa Binjai</title>

<script type="text/javascript" src="../temp/art-biru/script.js"> </script>

<link rel="stylesheet" href="../temp/art-biru/style.css" type="text/css" media="screen" />

<!--[if IE 6]><link rel="stylesheet" href="../temp/art-biru/style.ie6.css" type="text/css" media="screen" /><![endif]--> <!--[if IE 7]><link rel="stylesheet" href="../temp/art-biru/style.ie7.css" type="text/css" media="screen" /><![endif]-->

<!-- script tambahan --> <style type="text/css"> #calendar_tooltip {

position: absolute; width: 130px;

border: 1px solid #FFFFFF; padding: 7px;

background-color: #CCCCCC; visibility: hidden;


(2)

filter:

progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135); font-size: 10px;

color: #000000;

font-family: MS Sans Serif, Tahoma, sans-serif; }

.flashclass { /*sample CSS class added to image slideshow container*/

width: 196px; /*a width should be defined for transition to work*/ border: 0;

padding: 2px; }

.flashclass img{ width:196px; }

.highlight {

background-color: #DEDEDE; }

.normal { }

</style>

<script type="text/javascript"

src="../temp/transitionshow.js"></script> <script type="text/javascript">

var behavior="TD"

var ns6=document.getElementById&&!document.all var ie=document.all

function changeto(e,color) {

source=ie? event.srcElement : e.target if(source.tagName=="TABLE")

return

while(source.tagName!=behavior && source.tagName!="HTML") source=ns6? source.parentNode : source.parentElement

if(source.style.backgroundColor!=color&&source.id!="ignore") source.style.backgroundColor=color

}


(3)

{

while (slave.parentNode)

if ((slave = slave.parentNode) == master) return true;

return false; }

function changeback(e,originalcolor) {

if

(ie&&(event.fromElement.contains(event.toElement)||source.contains(ev ent.toElement)||source.id=="ignore")||source.tagName=="TABLE")

return

else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore")) return

if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source) source.style.backgroundColor=originalcolor

}

function detailagen(mn) {

window.open('../functions/agenda.php?kode='+mn,'Cek','width=300,heigh t=90,resizable=no,scrollbars=no');

}

</script> <script>

function ws() {

window.status='Done'; cmd="ws()";

timerTwo=window.setTimeout(cmd,0); }

ws(); </script>

<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

PostContent"><link type="text/css" rel="stylesheet" href="../plugins/news/base.css"/>

<link type="text/css" rel="stylesheet" href="../plugins/news/theme.css"/>


(4)

<script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>

<script type="text/javascript" src="../js/jquery.accessible-news-slider.js"></script>

<table border=0>

<tr> <td height=190 width=196 valign=top> <script type="text/javascript">

var flashyshow=new flashyslideshow({ //create instance of slideshow wrapperid: "myslideshow", //unique ID for this slideshow

wrapperclass: "flashclass", //desired CSS class for this slideshow

imagearray: [

["../images/galeri/gb20.jpg", "", "", "PBB SMA Tamansiswa Binjai"],["../images/galeri/gb19.jpg", "", "", "PBB SMA Tamansiswa Binjai"],["../images/galeri/gb18.jpg", "", "", "Pramuka SMA Tamansiswa Binjai"],["../images/galeri/gb17.jpg", "", "", "Futsal SMA Tamansiswa Binjai"],["../images/galeri/gb16.jpg", "", "", "Volly SMA Tamansiswa Binjai"],["../images/galeri/gb15.jpg", "", "", "Tari SMA Tamansiswa Binjai"],["../images/galeri/gb14.jpg", "", "", "Tari SMA Tamansiswa Binjai"],["../images/galeri/gb13.jpg", "", "", "Futsal SMA Tamansiswa Binjai"],["../images/galeri/gb12.jpg", "", "", "PKS SMA Tamansiswa Binjai"],["../images/galeri/gb11.jpg", "", "", "PBB SMA Tamansiswa Binjai"]

],

pause: 3000, //pause between content change (millisec)

transduration: 1000 //duration of transition (affects only IE users)

})

</script>

</td></tr></table>

<div class="cleared"></div> </div>

</div>

<div class="cleared"></div> </div>

</div></div> <!-- tengah konten--> </div>

<div class="cleared"></div><div class="art-Footer"> <div class="art-Footer-inner">


(5)

<p>Copyright &copy; 2013.

<a href="http://http://tamansiswabinjai.besada.com /"> http://tamansiswabinjai.besada.com/</a>.

Tamansiswa Binjai <br/></p> </div>

</div>

<div class="art-Footer-background"></div> </div>

<div class="cleared"></div> </div>

</div>

<div class="cleared"></div> <p class="art-page-footer"> </p>

</div> </body> </html>

2.

profil.php

<?php

session_start();

define("tamansiswa",1);

include ("../lib/parsing.php"); require ("../lib/config.php");

include ("../functions/fungsi_gabung.php"); include ("../functions/fungsi_profil.php"); include ("../functions/fungsi_depan.php"); include ("../functions/fungsi_temp.php"); function isi($id) {

global $memberlog; switch ($id) {

case "profil":

$isi .=profile(); break;

default:

$isi .=depan('profil'); break;


(6)

}

return $isi; }

include("../functions/koneksi.php");

$sql2="select * from t_pos_menu where posisi='L' and kategori='profil' and sembunyi='t' order by urut";

if(!$query2=mysql_query($sql2)) die ("Pengambilan gagal1 menu");

while ($rows=mysql_fetch_array($query2)) { $sql1="select * from t_temp_menu where idtemp='".$rows['idtemp']."'";

if(!$query1=mysql_query($sql1)) die ("Pengambilan gagal1 menu posisi kiri");

$r=mysql_fetch_array($query1); $kiri .= $r['temp_atas']; //atas //tag tengah

$kiri .= $rows['menu'];

$kiri .= $r['temp_tengah']; //tengah

// tag awal source isi

$fungsi ="../modul/tag_".$rows['fungsi'].".php"; include ("$fungsi");

$kiri.= $tag; // bawah

$kiri.= $r['temp_bawah']; //bawah $tag="";

} ?>

3.

Guru.php

<?php

session_start();

define("tamansiswa",1);

include ("../lib/parsing.php"); require ("../lib/config.php");


(7)

include ("../functions/fungsi_guru.php"); include ("../functions/fungsi_temp.php");

function isi($id) {

$userid = $_SESSION['User']['userid']; switch ($id) {

case "data":

include ("../functions/member_status.php"); $isi .= atas_isi("Profil Guru"); if ($userid<>"") $isi .=data(); else $isi .=user_gagal();

$isi .= bawah_isi(); break;

case "homepage":

$isi .= atas_isi("Homepage"); $isi .=homepage();

$isi .= bawah_isi(); break;

case "dbguru":

$isi .= atas_isi("Direktori Guru"); $isi .=dataguru();

$isi .= bawah_isi(); break;

default:

include ("../functions/fungsi_depan.php"); $isi .=depan('guru');

break; }

return $isi; }

include("../functions/koneksi.php");

$sql2="select * from t_pos_menu where posisi='L' and kategori='guru' and sembunyi='t' order by urut";

if(!$query2=mysql_query($sql2)) die ("Pengambilan gagal1 menu");

while ($rows=mysql_fetch_array($query2)) { $sql1="select * from t_temp_menu where idtemp='".$rows['idtemp']."'";


(8)

if(!$query1=mysql_query($sql1)) die ("Pengambilan gagal1 menu posisi kiri");

if($r=mysql_fetch_array($query1)) { $kiri .= $r['temp_atas']; //atas //tag tengah

$kiri .= $rows['menu'];

$kiri .= $r['temp_tengah']; //tengah // tag awal source isi

$fungsi ="../modul/tag_".$rows['fungsi'].".php"; include ("$fungsi");

$kiri .= $tag; // bawah

$kiri .= $r['temp_bawah']; //bawah $tag="";

} }

?>

4.

Siswa.php

<?php

session_start();

define("tamansiswa",1);

include ("../lib/parsing.php"); require ("../lib/config.php");

include ("../functions/fungsi_gabung.php"); include ("../functions/fungsi_siswa.php"); include ("../functions/fungsi_temp.php"); function isi($id) {

//global $memberlog;

$userid = $_SESSION['User']['userid']; switch ($id) {

case "data":

include ("../functions/member_status.php"); $isi .= atas_isi("Profil Siswa"); if ($userid<>"") $isi .=data(); else $isi .=user_gagal();

$isi .= bawah_isi(); break;


(9)

case "homepage":

$isi .= atas_isi("Homepage Kelas"); $isi .=homepage();

$isi .= bawah_isi(); break;

case "dbsiswa":

$isi .= atas_isi("Direktori Siswa"); $isi .=datasiswa();

$isi .= bawah_isi(); break;

case "profil":

include ("../functions/fungsi_profil.php"); $isi .=profile();

break; default:

include ("../functions/fungsi_depan.php"); $isi .=depan('siswa');

//$isi .= atas_isi("Direktori Siswa"); //$isi .=datasiswa();

//$isi .= bawah_isi(); break;

}

return $isi; }

include("../functions/koneksi.php");

$sql2="select * from t_pos_menu where posisi='L' and kategori='siswa' and sembunyi='t' order by urut";

if(!$query2=mysql_query($sql2)) die ("Pengambilan gagal1 menu");

while ($rows=mysql_fetch_array($query2)) { $sql1="select * from t_temp_menu where idtemp='".$rows['idtemp']."'";

if(!$query1=mysql_query($sql1)) die ("Pengambilan gagal1 menu posisi kiri");

$r=mysql_fetch_array($query1); $kiri .= $r['temp_atas']; //atas //tag tengah

$kiri .= $rows['menu'];

$kiri .= $r['temp_tengah']; //tengah // tag awal source isi


(10)

$fungsi ="../modul/tag_".$rows['fungsi'].".php"; include ("$fungsi");

$kiri.= $tag; // bawah

$kiri.= $r['temp_bawah']; //bawah $tag="";

} ?>

5.

Admin.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>

<head>

<title> .: Login Administrator :. </title>

<link rel="stylesheet" type="text/css" href="style.css"/>

</head> <body>

<!-- This P tag shows Error mesage -->

<form method="POST" action="login.php"> <center>

<div class="display_green">

<table cellspacing="0" cellpadding="0" border ="0"> <tr>

<td colspan="3"><center>: Login Administrator :</center></td> </tr>

<tr>

<td rowspan="3"><img src="login.jpg" width="60" height="60" align="left" /></td>

<td>Username </td><td><input type="text" name="username" id="uname"/></td>

</tr> <tr>

<td>Password </td><td><input type="password" name="password" id="pass"/></td>


(11)

<tr>

<td align="left"><input type="submit" name="login" value="Login" id="submit"/> </td>

</tr> </table> </div> </center> </form> </body> </html>

6.

Script Proses Buku Tamu

<h2 class="art-PostHeader">Buku Tamu</h2> </div><script language="JavaScript"> function kirpesan() {

if(document.formpesan.komentar.value=="") { alert("Kolom komentar belum diisi"); return false;

}

if(document.formpesan.nama.value=="") { alert("Kolom nama belum diisi"); return false;

}

if(document.formpesan.email.value=="") { alert("Kolom Email belum diisi"); return false;

}

if(document.formpesan.alamat.value=="") { alert("Kolom alamat belum diisi"); return false;

}

if(document.formpesan.code.value=="") {

alert("Kolom kode vertifikasi salah belum diisi"); return false;

}

return true; }


(12)

</script><form action='index.php' method='post'

enctype='multipart/form-data' name='formpesan' onSubmit='return kirpesan();'>

<table> <tr>

<td class='bg1'>

<font class='ver10'>Nama</font> </td>

<td>

<input type='text' name='nama' maxlenght=20 size=30 class='editbox'> </td>

</tr> <tr>

<td class='bg1'>

<font class='ver10'>E-mail</font> </td>

<td>

<input type='text' name='email' maxlenght=20 size=30 class='editbox'> </td>

</tr> <tr>

<td class='bg1'>

<font class='ver10'>Alamat</font> </td>

<td>

<input type='text' class='editbox' name='alamat' maxlenght=30size=55> </td>

</tr> <tr>

<td VALIGN=TOP class='bg1'>

<font class='ver10'>Komentar</font> </td>

<td>

<textarea name='komentar' cols='55' rows='8' class='editbox'></textarea>

</td> </tr> <tr>

<td VALIGN=TOP class='bg1'> <font class='ver10'></font>


(13)

</td> <td>

<img src='../functions/spam.php'><br>

Kode Verifikasi <br><input type='text' name='code' size='12' class='editbox' >

</td> </tr>

<input type='hidden' name='id' value='sim_buku'>

</table>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;

<input type='submit' name='submit' value='Kirim' class='art-button'>&nbsp;

<input type='reset' class='art-button' name='reset' value='Ulang'> </form>

<center>| <a href='index.php?id=lih_buku' >LIHAT BUKU TAMU</a> |<br><br>

</center></div> </div>

</div> </div> <!-- tengah konten--> </div>

<div class="cleared"> </div>

<div class="art-Footer">

<div class="art-Footer-inner"> <div class="art-Footer-text">

<p>Copyright &copy; 2013. <a href=" http://http://tamansiswabinjai. besada.com/" > http://tamansiswabinjai.besada.com/</a>.

Tamansiswa Binjai <br/> </p>

</div>

<div class="art-Footer-background"></div> </div>

<div class="cleared"></div> </div>

<div class="cleared"></div>

<p class="art-page-footer"></p> </div>

</body> </html>


(14)

7.

Script Proses Login Admin

<?php

session_start();

if (isset($_SESSION['Admin'])) {

session_destroy();

echo "Anda telah melakukan login, silahkan untuk login kembali"; echo "<meta http-equiv=\"refresh\"

content=\"1;url=login.php\">\n"; }

else {

if ( !isset($_POST['username']) || !isset($_POST['password']) ) {

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>

<head>

<title> .: Login Administrator :. </title>

<link rel="stylesheet" type="text/css" href="style.css"/> </head>

<body>

<!-- This P tag shows Error mesage -->

<form method="POST" action="login.php"> <center>

<div class="display_green">

<table cellspacing="0" cellpadding="0" border ="0"> <tr>

<td colspan="3"><center>.: Login Administrator :.</center> </td>

</tr> <tr>

<td rowspan="3"><img src="login.jpg" width="60" height="60" align="left" />

</td>

<td>Username </td><td><input type="text" name="username" id="uname"/></td>


(15)

<tr>

<td>Password </td><td><input type="password" name="password" id="pass"/></td>

</tr> <tr>

<td align="left"><input type="submit" name="login" value="Login" id="submit"/></td>

</tr> <tr> </table> </div> </center> </form> </body> </html>

<?php } else {

require '../functions/koneksi.php'; include "../functions/fungsi_pass.php"; echo "<html>\n<head>\n<title>Login Administrator</title>\n

<link rel='stylesheet' type='text/css' href='style.css'> </head>\n<body>\n";

$username = addslashes($_POST['username']);

$password = hex(addslashes($_POST['password']),82); $ret = mysql_query("SELECT * FROM user WHERE username = '".mysql_escape_string($username)."' AND password = '". mysql_escape_string($password) ."' and status='1' limit 0,1");

if (@mysql_num_rows($ret) != 0) {

$ret = mysql_fetch_array($ret); $_SESSION['Admin'] = $ret; $timeout = 9000;

$_SESSION["expires_by"] = time() + $timeout; $username = $_SESSION['Admin']['username'];

$kunjung = strval($_SESSION['Admin']['kunjung']) + 1;


(16)

$q=mysql_query("update user set

waktu='$tgl',ip='".$_SERVER['REMOTE_ADDR']."',kunjung='$kunjung' where username='$username' ");

echo "Selamat Datang $username.. redirecting\n"; echo "<meta http-equiv=\"refresh\"

content=\"1;url=admin.php\">\n"; }

else {

echo '<center><div class="display_red">

<table cellspacing="0" cellpadding="0" border ="0"> <tr>

<td colspan="2"><center>.: Login Administrator :.</center></td> </tr>

<tr>

<td ><img src="login.jpg" width="60" height="60" align="left" > </td>

<td>Maaf username dan password salah</td> </tr>

</table> </div>

</center>';

echo "<meta http-equiv=\"refresh\" content=\"1;url=login.php\">\n"; }

echo "</body>\n</html>\n"; }

} ?>

8.

Script Proses Siswa

<?php

$cetakdata .= "<tr bgcolor=\"#ffffff\">";

for ( $j = 0; $j <= $ws['max_col']; $j++ ) { $cell = get ( $exc, $row[$j] );

if ($j==4) {

$tgl = str_replace(".","", substr($cell,0,2));


(17)

if (strlen($cell)==8) {

$bln=str_replace(".","",substr($cell,3,2));$thn=str_replace(".","","1 9".substr($cell,6,2));}

else

{$bln=str_replace(".","",substr($cell,2,2));$thn=str_replace(".",""," 19".substr($cell,4,3));}

if (strlen($tgl)==1) $tgl="0".$tgl; if (strlen($bln)==1) $bln="0".$bln; $tgllahir ="$tgl/$bln/$thn";

}

elseif ($j==1) $nis=$cell;

elseif ($j==2) $nama=str_replace("'","",$cell); elseif ($j==3) $kelas=$cell;

elseif ($j==5) $tmplahir=$cell;

elseif ($j==6) $kel=strtoupper($cell); elseif ($j==7) $agama=$cell;

elseif ($j==8) $alamat=str_replace("'","",$cell); elseif ($j==9) $telp=$cell;

elseif ($j==10) $wali=str_replace("'","",$cell); else $no=$cell;

}

$cetakdata .= "<td>$no</td> <td>$nis</td>

<td>$nama</td> <td>$kelas</td> <td>$tgllahir</td> <td>$tmplahir</td> <td>$kel</td> <td>$agama</td> <td>$alamat</td>";

inputdata($nis,$nama,$kelas,$tgllahir,$tmplahir,$kel,$agama,$al amat,$telp,$wali);

$cetakdata .= "</tr>"; }

$i++; }

$cetakdata .= "</table><center>

<a href='../".$folderadmin."/admin.php?mode=siswa'>Kembali ke admin </a>


(18)

</form> <br>&nbsp;";

return $cetakdata; }

function

inputdata($nis,$nama,$kelas,$tgllahir,$tmplahir,$kel,$agama,$alamat,$ telp,$wali) {

include "koneksi.php";

$query = "SELECT user_id FROM t_siswa WHERE user_id='$nis'"; $result = mysql_query ($query) or die (mysql_error());

$r = mysql_num_rows($result); if ($r==0) {

$sql="insert into t_siswa

(user_id,nama,kelas,tgl_lahir,tmp_lahir,kelamin,agama,alamat)

values('$nis','$nama','$kelas','$tgllahir','$tmplahir','$kel','$agama ','$alamat')";

$mysql_result=mysql_query($sql) or die ("Query failed - Mysql"); }

else {

$sql="update t_siswa set

nama='$nama',kelas='$kelas',tgl_lahir='$tgllahir',tmp_lahir='$tmplahi r',kelamin='$kel',agama='$agama',alamat='$alamat',telp='$telp',

wali='$wali' where user_id='$nis'";

$mysql_result=mysql_query($sql) or die ("Query failed - Mysql");

} }

function prepareTableData ( $exc, $ws, $fieldcheck, $fieldname ) {

$data = $ws['cell'];

foreach( $data as $i => $row ) { // Output data and prepare SQL instructions

if ( $i == 0 && $_POST['useheaders'] ) continue;


(19)

$SQL[$i] = "";

for ( $j = 0; $j <= $ws['max_col']; $j++ ) {

if ( isset($fieldcheck[$j]) ) {

$SQL[$i] .= $fieldname[$j]; $SQL[$i] .= "=\"";

$SQL[$i] .= addslashes ( get ( $exc, $row[$j] ) ); $SQL[$i] .= "\"";

$SQL[$i] .= ","; }

}

$SQL[$i] = rtrim($SQL[$i], ',') $i++;

}

return $SQL; }

?>

9.

Script Proses Guru

<?php

$cetakdata .= "<tr bgcolor=\"#ffffff\">";

for ( $j = 0; $j <= $ws['max_col']; $j++ ) { $cell = get ( $exc, $row[$j] );

if ($j==4) {

$tgl = str_replace(".","", substr($cell,0,2));

if (strlen($cell)==8) {

$bln=str_replace(".","",substr($cell,3,2));$thn=str_replace(".","","1 9".substr($cell,6,2));}

else

{$bln=str_replace(".","",substr($cell,2,2));$thn=str_replace(".",""," 19".substr($cell,4,3));}

if (strlen($tgl)==1) $tgl="0".$tgl; if (strlen($bln)==1) $bln="0".$bln; $tgllahir ="$tgl/$bln/$thn";


(20)

elseif ($j==1) $nip=$cell;

elseif ($j==2) $nama=str_replace("'","",$cell); elseif ($j==3) $kel=strtoupper($cell);

elseif ($j==5) $tmplahir=$cell;

elseif ($j==6) $alamat=str_replace("'","",$cell); elseif ($j==7) $telp=$cell;

elseif ($j==8) $hp=$cell; elseif ($j==9) $tugas=$cell; elseif ($j==10) $email=$cell; elseif ($j==11) $pel=$cell; elseif ($j==12) $pangkat=$cell; elseif ($j==13) $status=$cell; else $no=$cell;

}

$cetakdata .= "<td>$no</td> <td>$nip</td>

<td>$nama</td> <td>$kel</td> <td>$tgllahir</td> <td>$tmplahir</td> <td>$alamat</td> <td>$telp</td> <td>$hp</td> <td>$pel</td>";

inputdata($nip,$nama,$kel,$tgllahir,$tmplahir,$alamat,$telp);

$cetakdata .= "</tr>"; }

$i++; }

$cetakdata .= "</table><center>

<a href='../".$folderadmin."/admin.php?mode=guru'>Kembali ke admin</a>

</form> <br>&nbsp;";


(21)

}

function inputdata($nip,$nama,$kel,$tgllahir,$tmplahir,$alamat,$telp) {

include "koneksi.php";

$status=strtolower($status);

if (strtolower($status)=='guru') $status='0'; else $status='1';

$query = "SELECT user_id FROM t_staf WHERE nip='$nip'"; $result = mysql_query ($query) or die (mysql_error()); $r = mysql_num_rows($result);

if ($r==0) {

$sql="insert into t_staf

(nama,nip,kelamin,alamat,tugas,telp,hp,email,pelajaran,tgl_lahir,tmp_ lahir,kode,pangkat,kategori)

values('$nama','$nip','$kel','$alamat','$tugas','$telp','$hp','$email ','$pel','$tgllahir','$tmplahir','-','$pangkat','$status')";

$mysql_result=mysql_query($sql) or die ("Query failed - Mysql");

} else {

$sql="update t_staf set

nama='$nama',kelamin='$kel',alamat='$alamat',tugas='$tugas',

telp='$telp',hp='$hp',email='$email',pelajaran='$pel',tgl_lahir='$tgl

lahir',tmp_lahir='$tmplahir',kode='-',pangkat='$pangkat',kategori='$status' where nip='$nip'"; $mysql_result=mysql_query($sql) or die ("Query failed - Mysql");

} }

function prepareTableData ( $exc, $ws, $fieldcheck, $fieldname ) { $data = $ws['cell'];

foreach( $data as $i => $row ) { // Output data and prepare SQL instructions

if ( $i == 0 && $_POST['useheaders'] ) continue;

$SQL[$i] = "";

for ( $j = 0; $j <= $ws['max_col']; $j++ ) if ( isset($fieldcheck[$j]) ) {


(22)

$SQL[$i] .= $fieldname[$j]; $SQL[$i] .= "=\"";

$SQL[$i] .= addslashes ( get ( $exc, $row[$j] ) );

$SQL[$i] .= "\"";

$SQL[$i] .= ","; }

}

$SQL[$i] = rtrim($SQL[$i], ','); $i++;

}

return $SQL; }


(1)

if (strlen($cell)==8) {

$bln=str_replace(".","",substr($cell,3,2));$thn=str_replace(".","","1 9".substr($cell,6,2));}

else

{$bln=str_replace(".","",substr($cell,2,2));$thn=str_replace(".",""," 19".substr($cell,4,3));}

if (strlen($tgl)==1) $tgl="0".$tgl; if (strlen($bln)==1) $bln="0".$bln; $tgllahir ="$tgl/$bln/$thn";

}

elseif ($j==1) $nis=$cell;

elseif ($j==2) $nama=str_replace("'","",$cell); elseif ($j==3) $kelas=$cell;

elseif ($j==5) $tmplahir=$cell;

elseif ($j==6) $kel=strtoupper($cell); elseif ($j==7) $agama=$cell;

elseif ($j==8) $alamat=str_replace("'","",$cell); elseif ($j==9) $telp=$cell;

elseif ($j==10) $wali=str_replace("'","",$cell); else $no=$cell;

}

$cetakdata .= "<td>$no</td> <td>$nis</td>

<td>$nama</td> <td>$kelas</td> <td>$tgllahir</td> <td>$tmplahir</td> <td>$kel</td> <td>$agama</td> <td>$alamat</td>";

inputdata($nis,$nama,$kelas,$tgllahir,$tmplahir,$kel,$agama,$al amat,$telp,$wali);

$cetakdata .= "</tr>"; }

$i++; }

$cetakdata .= "</table><center>

<a href='../".$folderadmin."/admin.php?mode=siswa'>Kembali ke admin </a>


(2)

</form> <br>&nbsp;";

return $cetakdata; }

function

inputdata($nis,$nama,$kelas,$tgllahir,$tmplahir,$kel,$agama,$alamat,$ telp,$wali) {

include "koneksi.php";

$query = "SELECT user_id FROM t_siswa WHERE user_id='$nis'"; $result = mysql_query ($query) or die (mysql_error());

$r = mysql_num_rows($result); if ($r==0) {

$sql="insert into t_siswa

(user_id,nama,kelas,tgl_lahir,tmp_lahir,kelamin,agama,alamat)

values('$nis','$nama','$kelas','$tgllahir','$tmplahir','$kel','$agama ','$alamat')";

$mysql_result=mysql_query($sql) or die ("Query failed - Mysql"); }

else {

$sql="update t_siswa set

nama='$nama',kelas='$kelas',tgl_lahir='$tgllahir',tmp_lahir='$tmplahi r',kelamin='$kel',agama='$agama',alamat='$alamat',telp='$telp',

wali='$wali' where user_id='$nis'";

$mysql_result=mysql_query($sql) or die ("Query failed - Mysql");

} }

function prepareTableData ( $exc, $ws, $fieldcheck, $fieldname ) {

$data = $ws['cell'];

foreach( $data as $i => $row ) { // Output data and prepare SQL instructions

if ( $i == 0 && $_POST['useheaders'] ) continue;


(3)

$SQL[$i] = "";

for ( $j = 0; $j <= $ws['max_col']; $j++ ) {

if ( isset($fieldcheck[$j]) ) {

$SQL[$i] .= $fieldname[$j]; $SQL[$i] .= "=\"";

$SQL[$i] .= addslashes ( get ( $exc, $row[$j] ) ); $SQL[$i] .= "\"";

$SQL[$i] .= ","; }

}

$SQL[$i] = rtrim($SQL[$i], ',') $i++;

}

return $SQL; }

?>

9.

Script Proses Guru

<?php

$cetakdata .= "<tr bgcolor=\"#ffffff\">";

for ( $j = 0; $j <= $ws['max_col']; $j++ ) { $cell = get ( $exc, $row[$j] );

if ($j==4) {

$tgl = str_replace(".","", substr($cell,0,2));

if (strlen($cell)==8) {

$bln=str_replace(".","",substr($cell,3,2));$thn=str_replace(".","","1 9".substr($cell,6,2));}

else

{$bln=str_replace(".","",substr($cell,2,2));$thn=str_replace(".",""," 19".substr($cell,4,3));}

if (strlen($tgl)==1) $tgl="0".$tgl; if (strlen($bln)==1) $bln="0".$bln; $tgllahir ="$tgl/$bln/$thn";


(4)

elseif ($j==1) $nip=$cell;

elseif ($j==2) $nama=str_replace("'","",$cell); elseif ($j==3) $kel=strtoupper($cell);

elseif ($j==5) $tmplahir=$cell;

elseif ($j==6) $alamat=str_replace("'","",$cell); elseif ($j==7) $telp=$cell;

elseif ($j==8) $hp=$cell; elseif ($j==9) $tugas=$cell; elseif ($j==10) $email=$cell; elseif ($j==11) $pel=$cell; elseif ($j==12) $pangkat=$cell; elseif ($j==13) $status=$cell; else $no=$cell;

}

$cetakdata .= "<td>$no</td> <td>$nip</td>

<td>$nama</td> <td>$kel</td> <td>$tgllahir</td> <td>$tmplahir</td> <td>$alamat</td> <td>$telp</td> <td>$hp</td> <td>$pel</td>";

inputdata($nip,$nama,$kel,$tgllahir,$tmplahir,$alamat,$telp);

$cetakdata .= "</tr>"; }

$i++; }

$cetakdata .= "</table><center>

<a href='../".$folderadmin."/admin.php?mode=guru'>Kembali ke admin</a>

</form> <br>&nbsp;";


(5)

}

function inputdata($nip,$nama,$kel,$tgllahir,$tmplahir,$alamat,$telp) {

include "koneksi.php";

$status=strtolower($status);

if (strtolower($status)=='guru') $status='0'; else $status='1';

$query = "SELECT user_id FROM t_staf WHERE nip='$nip'"; $result = mysql_query ($query) or die (mysql_error()); $r = mysql_num_rows($result);

if ($r==0) {

$sql="insert into t_staf

(nama,nip,kelamin,alamat,tugas,telp,hp,email,pelajaran,tgl_lahir,tmp_ lahir,kode,pangkat,kategori)

values('$nama','$nip','$kel','$alamat','$tugas','$telp','$hp','$email ','$pel','$tgllahir','$tmplahir','-','$pangkat','$status')";

$mysql_result=mysql_query($sql) or die ("Query failed - Mysql");

} else {

$sql="update t_staf set

nama='$nama',kelamin='$kel',alamat='$alamat',tugas='$tugas',

telp='$telp',hp='$hp',email='$email',pelajaran='$pel',tgl_lahir='$tgl

lahir',tmp_lahir='$tmplahir',kode='-',pangkat='$pangkat',kategori='$status' where nip='$nip'"; $mysql_result=mysql_query($sql) or die ("Query failed - Mysql");

} }

function prepareTableData ( $exc, $ws, $fieldcheck, $fieldname ) { $data = $ws['cell'];

foreach( $data as $i => $row ) { // Output data and prepare SQL instructions

if ( $i == 0 && $_POST['useheaders'] ) continue;

$SQL[$i] = "";

for ( $j = 0; $j <= $ws['max_col']; $j++ ) if ( isset($fieldcheck[$j]) ) {


(6)

$SQL[$i] .= $fieldname[$j]; $SQL[$i] .= "=\"";

$SQL[$i] .= addslashes ( get ( $exc, $row[$j] ) );

$SQL[$i] .= "\"";

$SQL[$i] .= ","; }

}

$SQL[$i] = rtrim($SQL[$i], ','); $i++;

}

return $SQL; }