4. IMPLEMENTASI SISTEM
4.1. Implementasi Sistem
Konfigurasi dilakukan dengan menyiapkan satu unit komputer yaitu:
a. Processor : Intel Celeron® 1,7 G Mhz b. Memory : Visipro 256 MB DDR RAM c. Harddisk : Seagate 80 GB 7200 RPM d. Browser : Internet Explorer
4.1.1 Konfigurasi PHP dan MySQL
Proses konfiguraqsi ini dimulai dengan melakukan peng-install-an notebook dengan PHPTriad yang merupakan suatu paket PHP, Apache dan MySQL sekaligus.
Setelah melakukan instalasi, maka dilakukan konfigurasi lebih lanjut sebelum memakai software PHPTriad ini. Pada direktori c:\apache\php\php.ini konfigurasi session.save_path diisikan c:\apache\tmp. Pada program group PHPTriad di start menu pilih Start Apache. Sebuah windows text akan muncul bertuliskan “Apache/1.3.14(Win32) running”. Window ini tidak boleh ditutup selama masih memakai perintah atau script-script PHP. Kemudian menjalankan MySQL dengan memilih Start Menu > All Programs > MySQL / MySQL Front.
Kemudian mengisikan kolom description, Hostname/IP, dan User, kemudian klik pada button “Connect!”. Dengan demikian server MySQL telah berjalan.
Konfigurasi Apache berada berada di c:\apache\conf. Script-script PHP diletakkan di c:\apache\htdocs. Parameter koneksi database MySQL: username: ‘root’, host:
‘localhost’, password:’ ‘ (string kosong).
Jika localhost milik PHP tidak berfungsi, maka ada kemungkinan web server lain yang aktif pada saat bersamaan, misalnya IIS. Solusinya adalah dengan menghentikan IIS terlebih dahulu, dengan cara: pilih Start menu > All Programs
> Administrative Tools > Services. Stop Entry World Wide Web Publishing
Services. Juka window MySQL gagal berjalan, maka bisa menjalankan MySQL
secara manual dengan cara memilih Start Menu > Run, lalu mengetikkan:
c:\apache\mysql\bin\mysqld-console.
4.1.2 Konfigurasi Database Server
Konfigurasi database server dilakukan dengan membuat database baru pada MySQL sebagai database server dengan nama ‘ADGI’, dimana database tersebut nantinya berisikan tabel-tabel yang telah didesain pada bab sebelumnya.
Konfigurasi database server ini menggunakan PHPMyAdmin yang dijalankan menggunakan Internet Explorer.
Gambar 4.1. Konfigurasi database
4.2. Implementasi Program (Perangkat Lunak)
Sub bab ini membahas mengenai program-program pada sistem yang
merupakan halaman-halaman web yang diletakkan pada direktori
C:\apache\htdocs pada server. Pembahasan implementasi program ini meliputi
implementasi program untuk halaman utama, automatic email dan free newsletter,
serta forum.
4.2.1. Implementasi Halaman Utama 4.2.1.1. Koneksi Database
Segmen program ini digunakan untuk menghubungkan setiap halaman program dengan database yang digunakan. Segmen program ini digunakan pada halaman program yang melakukan operasi-operasi database seperti insert, update, delete dan sebagainya
Segmen program 4.1. Koneksi database
<?php
include "db.php";
?>
<?
$hostname = "localhost";
$dbname = "adgi_menu";
$userlog = "root";
$userpass = "";
$logon = mysql_pconnect($hostname, $userlog, $userpass) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($dbname) or die ( "Unable to select database!"
);
?>
Segmen program ini dapat melakukan koneksi ke server ‘localhost’
4.2.1.2. Halaman Index.php
Bagian ini merupakan halaman yang pertama kali ditampilkan apabila website ini diakses.
Segmen untuk membuat template adalah:
Segmen program 4.2. Script untuk menampilkan bagian-bagian di halaman utama
//Pengambilan image untuk logo ADGI sebelah kiri
<td width="159"><img src="images/header_left.jpg" width="159"
height="90"></td>
<td> </td>
//Pengambilan image untuk sekat antara logo ADGI dan search <td width="235" align="center" valign="top"
background="images/header_right.jpg">
//Penulisan search pada pojok kanan atas web
<tr>
<td><font color="#FFFFFF" face="Times New Roman, Times, serif"><strong>Search</strong></font></td>
<td><input type="text" name="textfield"></td>
</tr>
//Peletakan image home.jpg, about.jpg, member.jpg, calendar.php, //gallery.php
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="159"><a href="home.php"><img
src="images/button_home.jpg" width="159" height="27"
border="0"></a></td>
<td width="2"><img src="images/menu_separator.jpg" width="2"
height="28"></td>
<td width="159"><a href="about.php"><img
src="images/button_about.jpg" width="158" height="27"
border="0"></a></td>
<td width="2"><img src="images/menu_separator.jpg" width="2"
height="28"></td>
<td width="159"><a href="member.php"><img
src="images/button_member.jpg" width="158" height="27"
border="0"></a></td>
<td width="2"><img src="images/menu_separator.jpg" width="2"
height="28"></td>
<td width="159"><a href="calendar.php"><img
src="images/button_calendar.jpg" width="159" height="27"
border="0"></a></td>
<td width="2"><img src="images/menu_separator.jpg" width="2"
height="28"></td>
<td width="159"><a href="gallery.php"><img
src="images/button_gallery.jpg" width="159" height="27"
border="0"></a></td>
<td width="2"><img src="images/menu_separator.jpg" width="2"
height="28"></td>
//Peletakan image semboyan dan image ikan sura dan buaya
<table width="100%" border="0" cellpadding="0" cellspacing="0"
bgcolor="#CCCCCC">
<tr>
<td align="center" valign="top"><div align="left">
<?php
if (isset($_GET['content'])==0) {
echo '<img src="images/middle.jpg" width="800" height="286">';
}
else require ($_GET['content']);
echo $_GET['content'];
?>
//start of table luar
<table width="100%" border="0" cellpadding="0" cellspacing="0"
background="images/back_bawah3.jpg">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
<tr valign="top">
//Pembuatan sub menu dan list menu pada bagian bawah web //Pembuatan sub menu dan list menu home
<td width="20%"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td colspan="2" background="images/back_atas1.jpg"><br> </td>
</tr>
<tr>
<td background="images/back_bawah1.jpg" width="10"></td>
<td valign="top" background="images/back_bawah1.jpg">
<div align="left">
<?php
$query = "select * from menu where column_number=1";
$row = mysql_query($query);
while (($data = mysql_fetch_row($row))!=0) {
echo "<a
href=gallery.php?content=".$data[4].">".$data[3]."</a>";
echo "<br><br>";
}
?>
//Pembuatan sub menu dan list menu about
<td width="20%"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td colspan="2" background="images/back_atas2.jpg"><br> </td>
</tr>
<tr>
<td background="images/back_bawah2.jpg" width="10"> </td>
<td width="149" background="images/back_bawah2.jpg">
<div align="left">
<?php
$query = "select * from menu where column_number=2";
$row = mysql_query($query);
while (($data = mysql_fetch_row($row))!=0) {
echo "<a
href=gallery.php?content=".$data[4].">".$data[3]."</a>";
echo "<br><br>";
}
?>
//Pembuatan sub menu dan list menu member
<td width="20%"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td colspan="2" background="images/back_atas3.jpg"><br> </td>
</tr>
<tr>
<td width="10" background="images/back_bawah3.jpg"> </td>
<td background="images/back_bawah3.jpg">
<div align="left">
<?php
$query = "select * from menu where column_number=3";
$row = mysql_query($query);
while (($data = mysql_fetch_row($row))!=0) {
echo "<a
href=gallery.php?content=".$data[4].">".$data[3]."</a>";
echo "<br><br>";
}
?>
//Pembuatan sub menu dan list menu calendar
<td width="20%"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td colspan="2" background="images/back_atas4.jpg"><br> </td>
</tr>
<tr>
<td width="10" background="images/back_bawah4.jpg"> </td>
<td background="images/back_bawah4.jpg">
<div>
<?php
$query = "select * from menu where column_number=4";
$row = mysql_query($query);
while (($data = mysql_fetch_row($row))!=0) {
echo "<a
href=gallery.php?content=".$data[4].">".$data[3]."</a>";
echo "<br><br>";
}
?>
//Pembuatan sub menu dan list menu gallery
<td width="20%"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td colspan="2" background="images/back_atas5.jpg"><br> </td>
</tr>
<tr>
<td width="10" background="images/back_bawah5.jpg"> </td>
<td width="170" background="images/back_bawah5.jpg">
<div>
<?php
$query = "select * from menu where column_number=5";
$row = mysql_query($query);
while (($data = mysql_fetch_row($row))!=0) {
echo "<a
href=gallery.php?content=".$data[4].">".$data[3]."</a>";
echo "<br><br>";
}
?>
4.2.1.3. Halaman About.php
Segmen program di halaman ini hampir sama dengan index.php, namun mengalami perubahan pada script untuk menampilkan warna pada bagian bawah web, dimana untuk setiap pembuatan sub menu dan list menu menjadi:
Segmen program 4.3. Script untuk mengubah warna list menu pada menu about
<td width="20%"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td colspan="2" background="images/back_atas2.jpg"><br> </td>
</tr>
<tr>
<td width="10" background="images/back_bawah2.jpg"> </td>
<td background="images/back_bawah2.jpg">
4.2.1.4. Halaman Member.php
Segmen program di halaman ini hampir sama dengan index.php, namun
mengalami perubahan pada script untuk menampilkan warna pada bagian bawah web, dimana untuk setiap pembuatan sub menu dan list menu menjadi:
Segmen program 4.4. Script untuk mengubah warna list menu pada menu member
<td width="20%"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td colspan="2" background="images/back_atas3.jpg"><br> </td>
</tr>
<tr>
<td width="10" background="images/back_bawah3.jpg"> </td>
<td background="images/back_bawah3.jpg">
4.2.1.5. Halaman Calendar.php
Segmen program di halaman ini hampir sama dengan index.php, namun mengalami perubahan pada script untuk menampilkan warna pada bagian bawah web, dimana untuk setiap pembuatan sub menu dan list menu menjadi:
Segmen program 4.5. Script untuk mengubah warna list menu pada menu calendar
<td width="20%"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td colspan="2" background="images/back_atas4.jpg"><br> </td>
</tr>
<tr>
<td width="10" background="images/back_bawah4.jpg"> </td>
<td background="images/back_bawah4.jpg">
4.2.1.6. Halaman Gallery.php
Segmen program di halaman ini hampir sama dengan index.php, namun mengalami perubahan pada script untuk menampilkan warna pada bagian bawah web, dimana untuk setiap pembuatan sub menu dan list menu menjadi:
Segmen program 4.6. Script untuk mengubah warna list menu pada menu gallery
<td width="20%"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td colspan="2" background="images/back_atas5.jpg"><br> </td>
</tr>
<tr>
<td width="10" background="images/back_bawah5.jpg"> </td>
<td background="images/back_bawah5.jpg">
4.2.2. Implementasi Halaman Automatic Email dan Free Newsletter 4.2.2.1 Halaman Pendaftaran Email
Halaman ini berfungsi untuk menerima pendaftaran free newsletter berupa nama dan email.
Segmen program 4.7. Script untuk membuat automatic email
<?php
if (!isset($_GET['msg'])) {
echo 'Selamat datang di Free Newsletter';
}
elseif (strcmp($_GET['msg'],'oke')==0) {
echo 'Terimakasih sudah bergabung. Nantikan email dari kami.';
}
elseif (strcmp($_GET['msg'],'kirim')==0) {
echo 'Email terkirim ke member';
}
?>
Segmen program 4.8. Script untuk memasukkan hasil input kedalam database
<?php
$christian = mysql_connect("localhost","","");
$db = mysql_select_db("news",$christian);
$select = mysql_query('select kode from email order by kode desc');
$row = mysql_fetch_array($select);
$kode = $row[0] + 1;
$nama = $_POST['nama'];
$email = $_POST['email'];
$insert = mysql_query('insert into email values ("'.$kode.'","'.$nama.'","'.$email.'")');
4.2.2.2 Halaman Admin Newsletter
Halaman ini berfungsi untuk mengirimkan free newsletter oleh admin kepada member.
Segmen program 4.9. Script untuk admin newsletter adalah:
<form action="gallery.php?content=adminnews.php" method="post"
name="formmessage">
username : <input name="user" type="text"><br/>
password : <input name="password" type="password">
<input name="submit" type="submit" value="SUBMIT">
</form>
Segmen program 4.10. Script untuk mengirimkan posting adalah:
<?php
$christian = mysql_connect("localhost","","");
$db = mysql_select_db("news",$christian);
$select = mysql_query('select kode from post order by kode desc');
$row = mysql_fetch_array($select);
$kode = $row[0] + 1;
$judul = $_POST['judul'];
$isi = $_POST['isi'];
$tanggal = date("Y-m-d");
$insert = mysql_query('insert into post values ("'.$kode.'","'.$judul.'","'.$isi.'","'.$tanggal.'")');
$select_e = mysql_query('select email from email');
$row_e = mysql_fetch_array($select_e);
while ($row_e[2]) {
$to = $row_e[2];
$subject = $judul.' at '.$tanggal;
$message = $isi;
$mail($to,$subject,$message,'');
$row_e = mysql_fetch_array($select_e);
}
?>
4.2.3. Implementasi Halaman Forum 4.2.3.1 Halaman utama forum
Segmen program 4.11. Script untuk meletakkan gambar pada forum adalah:
<tr>
<td height="149"></td>
<td valign="top"><img
src="image/showimage.php%7Epid=22115&filename=hendramon_dagger.jpg .jpg" width="149" height="149"></td>
<td> </td>
<td valign="top"><img
src="image/showimage.php%7Epid=22121&filename=monsketter_gary.jpg.
jpg" width="149" height="149"></td>
<td> </td>
<td valign="top"><img
src="image/showimage.php%7Epid=35268&filename=Ruang+Santai.jpg.jpg
" width="149" height="149"></td>
<td> </td>
<td valign="top"><img
src="image/showimage.php%7Epid=37662&filename=der_peiper_glasses.j pg.jpg" width="149" height="149"></td>
<td> </td>
<td valign="top"><img
src="image/showimage.php%7Epid=16296&filename=sikereninoel_blade2.
jpg.jpg" width="149" height="149"></td>
<td> </td>
<td valign="top"><img
src="image/showimage.php%7Epid=37282&filename=Corak-The- Hunter.jpg.jpg" width="149" height="149"></td>
<td> </td>
</tr>
Segmen program 4.12. Script untuk pembentukan tabel pada forum adalah:
<!--DWLayoutTable-->
<tr>
<td width="166" rowspan="3" valign="top"><table width="100%"
border="0" cellpadding="0" cellspacing="0" bgcolor="#4F4035">
<!--DWLayoutTable-->
<tr>
<td width="8" height="10"></td>
<td width="145"></td>
<td width="13"></td>
</tr>
<tr>
<td height="16"></td>
<td valign="top" bgcolor="#9999FF" class="bgtitle"><div align="center"><span class="style6">Navigasi</span></div></td>
<td></td>
</tr>
<tr>
<td height="127"></td>
<td valign="top" class="tepi"><p class="style4"><a href="index.php">index</a></p>
<p class="style4"><a href="#">login</a></p>
<p class="style4"><a href="#">forum</a></p>
<p class="style4"><a href="#">user list</a></p>
<p class="style4"><a href="register.php">register</a></p><?
if ( isset($_COOKIE["web_user"])) {
echo "<p class=\"style4\"><a href=\"post.php\">post</a></p>";
}
?>
Segmen program 4.13. Script untuk menampilkan hasil last topic dan last message
<?
$qtmp = "select * from recent";
$topics = mysql_query($qtmp);
while ($datarecent=mysql_fetch_row($topics)) {
$dtmsg = $datarecent[2];
$dtid = $datarecent[1];
echo "<p><a href=\"viewtopic.php?msgid=$dtid\"
class=\"style4\">$dtmsg</a></p><p> </p>";
}
?>
<?
$qtmp = "select * from lastpost";
$topics = mysql_query($qtmp);
while ($datarecent=mysql_fetch_row($topics)) {
$dtmsg = $datarecent[2];
$dtid = $datarecent[1];
echo "<p><a href=\"viewtopic.php?msgid=$dtid\"
class=\"style4\">$dtmsg</a></p><p> </p>";
}
?>
Segmen program 4.14. Script untuk menghitung jumlah user adalah:
<?
$query = "select count(*) from userdat";
$hsl = mysql_query($query) or die ("Error in query
".mysql_error());
$data = mysql_fetch_array( $hsl,MYSQL_NUM);
echo ("<span
class=style4><strong>".$data[0]."</strong></span>");
?>
Segmen program 4.15. Script untuk menampilkan anggota forum terakhir adalah:
<p class="style4"><strong>Newest</strong> Member :
<?
$query = "select logname from lastusr";
$hsl = mysql_query($query) or die ("Error in query
".mysql_error());
$data = mysql_fetch_array( $hsl,MYSQL_NUM);
echo ("<span
class=style4><strong>".$data[0]."</strong></span>");
?>
4.2.3.2. Halaman register 4.2.3.2.1. Halaman peraturan
Halaman ini berisi tentang peraturan-peraturan yang harus disetujui sebelum menjadi member pada forum ini.
4.2.3.2.2. Halaman penginputan data
Halaman ini berisi daftar data yang harus dimasukkan oleh calon anggota forum ADGI
Segmen program 4.16. Script untuk membuat tabel pendaftaran adalah:
function gettgl($thn,$bln,$tgl){
switch ($bln) {
case "January":
$bul ="01";
break;
case "February":
$bul ="02";
break;
case "March":
$bul ="03";
break;
case "April":
$bul ="04";
break;
case "May":
$bul ="05";
break;
case "June":
$bul ="06";
break;
case "July":
$bul ="07";
break;
case "August":
$bul ="08";
break;
case "September":
$bul ="09";
break;
case "October":
$bul ="10";
break;
case "November":
$bul ="11";
break;
case "December":
$bul ="12";
break;
}
//end switch
return $thn."/".$bul."/".$tgl;
}
//end function
if ( $_POST["Submit"] == "Cancel") {
header ("Location: index.php");
exit;
} Else {
I f ($_POST["Submit"] == "Save"){
// session_start();
require_once ( "log_db.php" );
$msg = "";
$query1= "select * from userdat where logname =
\"".$_POST["logusr"]."\"";
$result = mysql_query($query1);
$inpok = true;
if (mysql_num_rows($result) != 0) //udah ada usernamenya {
$msg = "username udah ada, cari lagi";
$inpok = false;
} else {
//login user blum ada lanjutkan chek password if ($_POST["pass"] ==""){
$inpok = false;
$msgpass = "password tidak boleh kosong";
}
else if($_POST["pass"] != $_POST["retype"] ){
$inpok = false;
$msgpass = "password yang diketikkan harus sama";
} }
if($inpok) {
$tgllhr = gettgl($_POST["thn"],$_POST["bln"],$_POST["tgl"]);
$usrpass = md5($_POST["pass"]);
$query1 = "insert into
userdat(logname,pass,location,title,sex,tgllahir,levelusr) values (\"".$_POST["logusr"]."\",\"".$usrpass."\",\"".$_POST["loca"]."\",
\"".$_POST["tit"]."\",\"".$_POST["sex"]."\",\"".$tgllhr."\",0)";
$result = mysql_query($query1) or die("Error in writeing record");
$query1 = "delete from lastusr";
$result = mysql_query($query1);
$query1 = "insert into lastusr(logname) values (\"".$_POST["logusr"]."\")";
$result = mysql_query($query1);
header ("Location: login.php");
exit;
} } } ?>
<tr>
<td height="182" colspan="2" valign="top" class="style4"><p class="userinp">User Name </p>
<p class="userinp">Password</p>
<p class="userinp">Retype Password</p>
<p class="userinp">Title</p>
<p class="userinp">Sex</p>
<p class="userinp">Date of Birth</p>
<p class="userinp">Location</p></td>
<td width="683" valign="top" class="style4"><p>:
<input name="logusr" type="text">
<? echo ("<font class=errorinp>$msg</font");?> </p>
<p>:
<input name="pass" type="password">
<? echo ("<font class='errorinp'>$msgpass</font>");?>
</p><p>:
<input name="retype" type="password">
</p><p>:
<select name="tit">
<option>Mr.</option>
<option>Mrs.</option>
<option>Ms.</option>
</select>
</p><p>:
<select name="sex">
<option>Male</option>
<option>Female</option>
</select>
</p><p>:
<select name="tgl">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
(tgl)
<select name="bln">
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
(bln)
<input name="thn" type="text" size="6">
(thn)
</p><p>:
<select name="loca">
<option>Surabaya</option>
<option>Sidoarjo</option>
<option>Jakarta</option>
<option>Malang</option>
<option>Medan</option>
<option>Balikpapan</option>
<option>Yogyakarta</option>
</select>
4.2.3.3 Halaman Login
Halaman ini merupakan tempet bagi user untuk bisa melakukan
penginputan username dan password untuk bisa masuk ke halaman utama
Segmen program 4.17. Script untuk melakukan login pada forum adalah:
<?php
if ( isset($_COOKIE["web_user"])) {
$statusr = "<span class=\"style4\">Logged in as <strong><a href=showprofile.php?user=". $_COOKIE["web_user"] .">".
$_COOKIE["web_user"] ."</a></strong></font><br>";
$statusr .= "<span class = \"style4\"><a href=\"profile.php\">edit profile</a></font>";
} else {
$statusr = "Not Logged in";
}
if ($_POST["Submit"] == "Login"){
require_once("log_db.php");
$data_usr = $_POST["logusr"];
$q1 = "select logname,pass,levelusr from userdat where logname
= \"$data_usr\"";
$res = mysql_query($q1);
$usrdat = mysql_fetch_array($res);
if ($res == 0) { //Record Empty
$msg = " Nama user tidak ditemukan, <a href=register.php>daftar</a> dulu";
} else {
//recordnya ketemu cek passwordnya sama atau tidak if ( md5($_POST["pass"]) != $usrdat["pass"] ) {
//passwordnya salah
$msgpass = "User name atau Password yang dimasukkan salah";
} else {
// semua udah ok daftar cookiesnya
setcookie("web_user",$_POST["logusr"],time()+3600);
setcookie("leveluser",$usrdat["levelusr"],time()+3600);
header ("Location:index.php");
} } }
?>
4.2.3.4 Halaman untuk melihat user list
Halaman ini berfungsi untuk melihat daftar user yang menjadi anggota dari forum ini
Segmen program 4.18. Script untuk melihat user list pada forum adalah:
<?
include("log_db.php");
$pageLimit = 10;
$query1 = "select COUNT(*) as Tot from userdat";
$res = mysql_query($query1);
$Dat1 = mysql_fetch_array($res,MYSQL_NUM);
$totalusr = $Dat1[0];
$Query = "select * from userdat ";
if (empty($_GET["startshow"])) {
//cek apakah daftar dimulai dari awal
//Tambahkan LIMIT untuk membatasi record yang akan ditampilkan $startshow = 0; //mulai dari awal
$Query .= "limit $startshow, $pageLimit";
} Else {
$startshow = $_GET["startshow"];
$Query .= "limit $startshow, $pageLimit";
}
$resshow = mysql_query($Query) or die("Error in retreiving data".mysql_error());
$jumlahbaris = mysql_num_rows($resshow);
//proses menampilkan daftar user $high = TRUE;
if ($jumlahbaris < $pageLimit) $ulang = $jumlahbaris;
Else
$ulang = $pageLimit;
for ($a=0; $a < $ulang; $a++) {
$datatampil = mysql_fetch_array ( $resshow);
$logname = $datatampil["logname"];
$level = $datatampil["levelusr"];
switch($level) {
//user biasa case 0:
$showlevel = "<img src=\"image/reguler.gif\">";
break;
//user adalah forum leader case 1:
$showlevel = "<img src=\"image/leader.gif\">";
break;
//user adalah admin forum case 2:
$showlevel = "<img src=\"image/admin.gif\">";
break;
}
$sex = $datatampil["sex"];
$location = $datatampil["location"];
//cek jumlah post dari user yang bersangkutan
$querypost = "select COUNT(*) as total from topic where usrname
= \"$logname\"";
$respost = mysql_query($querypost);
$datapost = mysql_fetch_array ($respost);
$totpost = $datapost["total"];
echo "<tr> <td height=\"22\"> </td>";
if ($high) {
echo "<td valign=\"top\" class=\"highlist\">$showlevel</td>";
echo "<td valign=\"top\" class=\"highlist\"><a href=showprofile.php?user=$logname>$logname</a></td>";
echo "<td valign=\"top\" class=\"highlist\">$sex</td>";
echo "<td valign=\"top\" class=\"highlist\">$location</td>";
echo "<td valign=\"top\" class=\"highlist\">$totpost</td>";
} else {
echo "<td valign=\"top\"
class=\"listnonhigh\">$showlevel</td>";
echo "<td valign=\"top\" class=\"listnonhigh\"><a href=showprofile.php?user=$logname>$logname</a></td>";
echo "<td valign=\"top\" class=\"listnonhigh\">$sex</td>";
echo "<td valign=\"top\" class=\"listnonhigh\">$location</td>";
echo "<td valign=\"top\" class=\"listnonhigh\">$totpost</td>";
}
echo "<td> </td></tr>";
if ($high) $high= FALSE;
else
$high = TRUE;
}
?>
4.2.3.5 Halaman untuk mengubah profil user
Segmen program 4.19. Script untuk mengubah profil user pada forum adalah:
$qusr = "select * from userdat where logname =
\"".$_COOKIE["web_user"]."\"";
$usrdatHandel = mysql_query($qusr) or die("Error in opening database line 22 ".mysql_error());
$datauser = mysql_fetch_array($usrdatHandel);
$avatar = $datauser["avatar"];
//ambil atribut user yang tersimpan untuk diedit kalo gak ada entry baru
$qusr = "select * from attribuser where logname =
\"".$_COOKIE["web_user"]."\"";
$attribHandel = mysql_query($qusr) or die("Error in opening database line 26 ".mysql_error());
$dataattrib = mysql_fetch_array($attribHandel);
//fungsi untuk mendapatkan extension dari file yang diupload function getext($namafile)
{
$ttk = strpos($namafile,".",0);
$ext = substr($namafile,$ttk,4);
return $ext;
}
//fungsi untuk mndapatkan type dari file yang diupload function gettypefile($namafile)
{
$ttk = strpos($namafile,"/",0);
$ext = substr($namafile,0,$ttk);
return $ext;
}
//proses tombol submit
if ($_POST["Submit"]=="Save") {
//proses update attrib user if ($_POST["new"] == "no") {
//data hanya untuk update attrib user
$qusr = "update attribuser set Namalengkap
=\"".$_POST["nmlkp"]."\", website=\"".$_POST["website"]."\",";
$qusr .= "email=\"".$_POST["email"]."\", icq =
\"".$_POST["icq"]."\", ym=\"".$_POST["ym"]."\", signature=\"".$_POST["sgn"]."\"";
$qusr .= "where logname = \"".$_COOKIE["web_user"]."\"";
$attribHandel = mysql_query($qusr);
} Else {
//data attrib user seblumnya blum ada
if (gettypefile($_FILES["file"]["type"]) != "image"){
$statfile = "<span class=errorinp>File yang diupload harus file image ".$_FILES["file"]["type"]."</span>";
} Else {
//upload file image ke server dan update field avatar di userdat $namafile = $_FILES["file"]["name"];
$ext = getext($namafile);
$namafilebaru = $_COOKIE["web_user"].$ext;
copy($_FILES["file"]["tmp_name"],
"c:/apache/htdocs/forumidgi/image/avatars/".$namafilebaru);
$qusr = "update userdat set avatar = \"<img
src=image/avatars/".$namafilebaru." alt=".$_COOKIE["web_user"]."
width=75 height=75> </img>\"";
$qusr .= "where logname = \"".$_COOKIE["web_user"]."\"";
$usrdatHandel = mysql_query($qusr) or die("Error in opening database".mysql_error());
}
$qusr = "insert into
attribuser(logname,namalengkap,website,email,icq,ym,signature) ";
$qusr .= "values
(\"".$_COOKIE["web_user"]."\",\"".$_POST["nmlkp"]."\",
\"".$_POST["website"]."\",\"".$_POST["email"];
$qusr .= "\", \"".$_POST["icq"]."\", \"".$_POST["ym"]."\",
\"".$_POST["sgn"]."\")";
$attribHandel = mysql_query($qusr);
}
header("Location:index.php");
exit;
}
?>
<?
if (mysql_num_rows($attribHandel)==0 ) {
//kalao data attribut user tidak ada maka tampilkan form kosong echo'
<p><input name="nmlkp" type="text" id="nmlkp" size="60"
maxlength="65"></p>
<p><input name="website" type="text" id="website"
size="50"></p>
<p><input type="text" name="email"></p>
<p><input type="text" name="icq"></p>
<p><input type="text" name="ym"></p>
<p><textarea name="sgn" cols="60" rows="10"></textarea></p>
<input type="hidden" name="new" value="yes">';
} Else {
//kalo ada maka form diisi dengan data yang ada echo"
<p><input name=\"nmlkp\" type=\"text\" id=\"nmlkp\" size=\"60\"
maxlength=\"65\" value=\"".$dataattrib["Namalengkap"]."\"></p>
<p><input name=\"website\" type=\"text\" id=\"website\"
size=\"50\" value=\"".$dataattrib["website"]."\"></p>
<p><input type=\"text\" name=\"email\"
value=\"".$dataattrib["email"]."\"></p>
<p><input type=\"text\" name=\"icq\"
value=\"".$dataattrib["icq"]."\"></p>
<p><input type=\"text\" name=\"textfield3\"
value=\"".$dataattrib["ym"]."\"></p>
<p><textarea name=\"sgn\" cols=\"60\"
rows=\"10\">".$dataattrib["signature"]."</textarea></p>
<input type=\"hidden\" name=\"new\" value=\"no\">";
}
?>
4.2.3.6 Halaman untuk Show Profile
Halaman ini berfungsi untuk melihat profil dari user yang telah disimpan.
Segmen program 4.20. Script untuk melihat profil user pada forum adalah:
<?
require_once ( "log_db.php" );
//Tampilkan avatar
$qusr = "select * from userdat where logname =
\"".$_GET["user"]."\"";
$usrdatHandel = mysql_query($qusr) or die("Error in opening database line 22 ".mysql_error());
$datauser = mysql_fetch_array($usrdatHandel);
$avatar = $datauser["avatar"];
//ambil atribut user yang tersimpan
$qusr = "select * from attribuser where logname =
\"".$_GET["user"]."\"";
$attribHandel = mysql_query($qusr) or die("Error in opening database line 26 ".mysql_error());
$dataattrib = mysql_fetch_array($attribHandel);
?>
<?
if (isset($avatar)) {
echo $avatar;
} else {
echo "<img src=\"image/avatars/none.jpg\" width=\"75\"
height=\"75\" alt=\"".$_COOKIE["web_user"]."\">";
}
switch($datauser["levelusr"]) {
case 0:
echo "<img src=\"image/reguler.gif\" width=\"15\" height=\"15\"
alt=\"Reguler\" class=\"nobdr\"><span class=\"style4\">Position in Forum : Reguler </span></img>";
break;
case 1:
echo "<img src=\"image/leader.gif\" width=\"15\" height=\"15\"
alt=\"Reguler\" class=\"nobdr\"><span class=\"style4\">Position in Forum : Forum Leader </span></img>";
break;
case 2:
echo "<img src=\"image/admin.gif\" width=\"15\" height=\"15\"
alt=\"Reguler\" class=\"nobdr\"><span class=\"style4\">Position in Forum : Administrator Forum </span></img>";
break;
}
?>
<tr>
<td height="186"></td>
<td valign="top" class="style4"><p class="userinp">Nama Lengkap : </p>
<p class="userinp">Location :</p>
<p class="userinp">Sex :</p>
<p class="userinp">Date of Birth :</p>
<p class="userinp">Website :</p>
<p class="userinp">Email :</p>
<p class="userinp">ICQ Id :</p>
<p class="userinp">YM Id :</p>
<p class="userinp">Signature : </p>
<p> </p></td>
<td valign="top" class="style4">
<?
if (isset($dataattrib["Namalengkap"])){
echo"
<p class=userinp>".$dataattrib["Namalengkap"]."</p>
<p class=userinp>".$datauser["location"]."</p>
<p class=userinp>".$datauser["sex"]."</p>
<p class=userinp>".$datauser["tgllahir"]."</p>
<p class=userinp>".$dataattrib["website"]."</p>
<p class=userinp>".$dataattrib["email"]."</p>
<p class=userinp>".$dataattrib["icq"]."</p>
<p class=userinp>".$dataattrib["ym"]."</p>
<p><textarea name=\"sgn\" cols=\"60\"
rows=\"10\">".$dataattrib["signature"]."</textarea></p>
";
} Else {
echo"<p class=userinp>Sorry no other detail data of this user</p>";
}
?>
4.2.3.7. Halaman Post Topic
Halaman ini berfungsi untuk melakukan post topic pertama dari forum.
Segmen program 4.21. Script untuk melakukan post topic pada forum adalah:
<?
if ( isset($_COOKIE["web_user"])) {
$statusr = "<span class=\"style4\">Logged in as <strong><a href=showprofile.php?user=". $_COOKIE["web_user"] .">".
$_COOKIE["web_user"] ."</a></strong></font><br>";
$statusr .= "<span class = \"style4\"><a href=\"profile.php\">edit profile</a></font>";
$usrnya = $_COOKIE["web_user"];
} else {
$statusr = "Not Logged in";
}
function ambiltanggal() {
$tmp = getdate();
$tglskr = $tmp["mday"];
$blnskr = $tmp["mon"];
$thnskr = $tmp["year"];
$jam = $tmp["hours"];
$mnt = $tmp["minutes"];
$dtk = $tmp["seconds"];
return
$thnskr."/".$blnskr."/".$tglskr."".$jam.":".$mnt.":".$dtk;
}
function settampilan(&$tmp) {
$tmp = str_replace("\r\n","<br>", $tmp);
$tmp = str_replace("[b]","<strong>",$tmp);
$tmp = str_replace("[/b]","</strong>",$tmp);
$tmp = str_replace("[i]","<i>",$tmp);
$tmp = str_replace("[/i]","</i>",$tmp);
$tmp = str_replace("[u]","<u>",$tmp);
$tmp = str_replace("[/u]","</u>",$tmp);
$tmp = str_replace(":angel:","<img src=image/smilies/angel.gif alt=:angel: width=17 height=19 class=nobdr />",$tmp);
$tmp = str_replace(":arg:","<img src=image/smilies/arg.png alt=:arg: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":D","<img src=image/smilies/big_smile.png alt=:D width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(";)","<img src=image/smilies/blink.png alt=;) width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":blush:","<img src=image/smilies/blush.gif alt=:blush: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":cool:","<img src=image/smilies/cool.png alt=:cool: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":kuat:", "<img src=image/smilies/kuat.gif alt=:kuat: width=15 height=15 class=nobdr />", $tmp);
$tmp = str_replace(":lol:", "<img src=image/smilies/lol.gif alt=:lol: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":lol2:","<img src=image/smilies/lol2.png alt=:lol2: width=15 height=15 class=nobdr />", $tmp);
$tmp = str_replace(":love:", "<img src=image/smilies/love.gif alt=:love: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":mabok:", "<img src=image/smilies/mabok.gif alt=:mabok: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":nyerah:", "<img
src=image/smilies/nyerah.gif alt=:nyerah: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":oh:", "<img src=image/smilies/oh.gif alt=:oh: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":rock:", "<img src=image/smilies/rock.gif alt=:rock: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":(", "<img src=image/smilies/sad.png alt=:(
width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":ss:", "<img src=image/smilies/sembah.gif alt=:ss: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":)", "<img src=image/smilies/smile.png alt=:) width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":gila:", "<img src=image/smilies/stress.gif alt=:gila: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":thumb:", "<img src=image/smilies/thumb.gif alt=:thumb: width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":p", "<img src=image/smilies/wek.png alt=:p width=15 height=15 class=nobdr />",$tmp);
$tmp = str_replace(":zzz:", "<img src=image/smilies/zzz.gif alt=:zzz: width=15 height=15 class=nobdr />",$tmp);
return $tmp;
}
if ($_POST["Submit"] == "Submit") {
$tpcpos = strpos($_POST["req_message"], "\r");
$tpc = substr($_POST["req_message"],0,$tpcpos);
$tpc = settampilan($tpc);
$tglskr = ambiltanggal();
$pesan = settampilan($_POST["req_message"]);
$ortu = $_POST["parent"];
if (isset($_POST["type"])){
$typems = $_POST["type"];
}
else {
$typems = "post";
}
$Q1 = "insert into
topic(id,parent,usrname,inforum,title,message,typemsg,tglpost)";
$Q1 .= "values
(null,$ortu,\"".$usrnya."\",0,\"".$tpc."\",\"".$pesan."\",\"$typem s\",\"".$tglskr."\")";
$res = mysql_query($Q1) or die("Error while writing files");
$idmsg = mysql_insert_id();
if ($ortu!=0) {
//proses update latest post kalo yang dimasukkan adalah post biasa bukan topic
$qtemp = "select idmsg,titlemsg from lastpost where norec = 2";
$tmp = mysql_query($qtemp);
$tmprow = mysql_fetch_array ($tmp);
$tmpidmsg = $tmprow["idmsg"];
$tmptit = $tmprow["titlemsg"];
$qpost = "update lastpost set idmsg=\"$tmpidmsg\", titlemsg=\"$tmptit\" where norec = 3";
$qtemp = "select idmsg,titlemsg from lastpost where norec = 1";
$tmp = mysql_query($qtemp);
$tmprow = mysql_fetch_array ($tmp);
$tmpidmsg = $tmprow["idmsg"];
$tmptit = $tmprow["titlemsg"];
$qpost = "update lastpost set idmsg=\"$tmpidmsg\", titlemsg=\"$tmptit\" where norec = 2";
$qpost = "update lastpost set idmsg=LAST_INSERT_ID(), titlemsg=\"$tpc\" where norec = 1";
$hslpost = mysql_query($qpost) or die("Error in writing record posting new");
} else {
//proses updating recent topic....
$qtemp = "select idmsg,titlemsg from recent where norec = 2";
$tmp = mysql_query($qtemp);
$tmprow = mysql_fetch_array ($tmp);
$tmpidmsg = $tmprow["idmsg"];
$tmptit = $tmprow["titlemsg"];
$qpost = "update recent set idmsg=\"$tmpidmsg\", titlemsg=\"$tmptit\" where norec = 3";
$hslpost = mysql_query($qpost) or die("Error in writing record");
$qtemp = "select idmsg,titlemsg from recent where norec = 1";
$tmp = mysql_query($qtemp);
$tmprow = mysql_fetch_array ($tmp);
$tmpidmsg = $tmprow["idmsg"];
$tmptit = $tmprow["titlemsg"];
$qpost = "update recent set idmsg=\"$tmpidmsg\", titlemsg=\"$tmptit\" where norec = 2";
$hslpost = mysql_query($qpost) or die("Error in writing record");
$qpost = "update recent set idmsg=LAST_INSERT_ID(), titlemsg=\"$tpc\" where norec = 1";
$hslpost = mysql_query($qpost) or die("Error in writing record");
}
header("location:viewtopic.php?msgid=$idmsg");
}
if ($_POST["Submit"] == "Preview") {
$simpan = $_POST["req_message"];
$pesan = settampilan($simpan);
header("location: tampil.php?tampil=".$pesan);
}
?>
<?
if (isset($_GET["idnya"])) {
//Menampilkan topic yang akan direply $idtpc = $_GET["idnya"];
$q1 = "select * from topic where id = $idtpc";
$hdltopic = mysql_query($q1);
$datatopic = mysql_fetch_array($hdltopic);
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\"
cellspacing=\"0\" class=tepi>
?>
<?
if ($_COOKIE["leveluser"]>0) {
echo'<input name="type" type="radio" value="Post" checked> Post <input name="type" type="radio" value="News">News';
}
if (isset($_GET["idnya"])) {
echo "<input type=\"hidden\" name=\"parent\"
value=\"$idtpc\">";
} else {
echo "<input type=\"hidden\" name=\"parent\" value=0>";
}
?>
4.2.3.8. Halaman List Topic
Halaman ini berisi daftar topik yang bisa dipilih untuk diberikan komentar ataupun balasan.
Segmen program 4.22. Script untuk mellihat list topic pada forum adalah:
<?php
if ( isset($_COOKIE["web_user"])) {
$statusr = "<span class=\"style4\">Logged in as <strong><a href=showprofile.php?user=". $_COOKIE["web_user"] .">".
$_COOKIE["web_user"] ."</a></strong></font><br>";
$statusr .= "<span class = \"style4\"><a href=\"profile.php\">edit profile</a></font>";
} else {
$statusr = "Not Logged in";
}
?>
<?
include("log_db.php");
$pageLimit = 10;
$query1 = "select COUNT(*) as Tot from topic where parent=0";
$res = mysql_query($query1);
$Dat1 = mysql_fetch_array($res,MYSQL_NUM);
$totalusr = $Dat1[0];
$Query = "select * from topic where parent=0 ";
if (empty($_GET["startshow"])) {
//cek apakah daftar dimulai dari awal
//Tambahkan LIMIT untuk membatasi record yang akan ditampilkan $startshow = 0; //mulai dari awal
$Query .= "limit $startshow, $pageLimit";
} Else {
$startshow = $_GET["startshow"];
$Query .= "limit $startshow, $pageLimit";
}
$resshow = mysql_query($Query) or die("Error in retreiving data".mysql_error());
$jumlahbaris = mysql_num_rows($resshow);
//proses menampilkan daftar user $high = TRUE;
if ($jumlahbaris < $pageLimit) $ulang = $jumlahbaris;
else
$ulang = $pageLimit;
for ($a=0; $a < $ulang; $a++) {
$datatampil = mysql_fetch_array ( $resshow);
$idtpc = $datatampil["id"];
$tpc = $datatampil["title"];
$postby = $datatampil["usrname"];
$time = $datatampil["tglpost"];
//cek jumlah post dari user yang bersangkutan echo "<tr> <td height=\"22\"> </td>";
if ($high) {
echo "
<td valign=\"top\" class=\"highlist\">$idtpc</td>
<td colspan=\"2\" valign=\"top\" class=\"highlist\"><a href=viewtopic.php?msgid=$idtpc>$tpc</a></td>
<td valign=\"top\" class=\"highlist\">$postby</td>
<td colspan=\"2\" valign=\"top\" class=\"highlist\">$time</td>
<td></td>";
} else
{ echo "
<td valign=\"top\" class=\"listnonhigh\">$idtpc</td>
<td colspan=\"2\" valign=\"top\" class=\"listnonhigh\"><a href=viewtopic.php?msgid=$idtpc>$tpc</a></td>
<td valign=\"top\" class=\"listnonhigh\">$postby</td>
<td colspan=\"2\" valign=\"top\"
class=\"listnonhigh\">$time</td>
<td></td>";
}
echo "<td> </td></tr>";
if ($high) $high= FALSE;
else
$high = TRUE;
}
?>
<?
//proses untuk menampilkan navigasi halaman if ($totalusr > 0)
{
if ($startshow<$totalusr && $startshow>0) {
//untuk nampilkan PREV
$start1 = $startshow - $pageLimit;
echo "<a href=\"topicllist.php?startshow=\"".$start1."\">Prev
</a>";
}
//menghitung dan menampilkan link # halaman $pages = $totalusr/ $pageLimit;
if ($pages > 1) {
for ($b=0,$c=1; $b < $pages; $b++,$c++) {
$Res1=$pageLimit * $b;
echo "<a href=\"topicllist.php?startshow=".$Res1."\">".$c."
</a>";
} }
//menampilkan NEXT
if ($startshow>=0 && $startshow<$totalusr) {
$Res1=$startshow+$pageLimit;
if ($Res1<$totalusr) {
echo '<A HREF="topicllist.php?startshow='.$Res1.'"> Next </A>';
} } }
?>
4.2.3.9. Halaman View Topic
Halaman ini berfungsi untuk melihat isi dari topik yang telah dibuat
beserta dengan balasan yang telah dimasukkan.
Segmen program 4.23. Script untuk melakukan view topic pada forum adalah:
<?
include "log_db.php";
if (isset($_GET["msgid"])) {
$notopic = $_GET["msgid"];
$q1 = "select * from topic where id = $notopic";
$handeltpc = mysql_query($q1) or die("error in searching data msg");
$tpcdata = mysql_fetch_array($handeltpc);
$parentnya = $tpcdata["parent"];
$q2 = "select * from userdat where logname =
\"".$tpcdata["usrname"]."\"";
$handelusr = mysql_query($q2) or die("error in searching data user");
$usrdata = mysql_fetch_array($handelusr);
}
?>
<?
if ($parentnya==0) {
//topic yang akan ditampilkan adalah parent topic
echo "<table width=100% border=0 cellpadding=0 cellspacing=0 class=border>
//kalo bukan berarti tampilkan pesan dari parent topicnya...
$notopic = $tpcdata["parent"];
$qpar = "select * from topic where id = $notopic";
$parhdl = mysql_query($qpar);
$pardata = mysql_fetch_array($parhdl);
$idtopickpl = $pardata["id"];
$q2 = "select * from userdat where logname =
\"".$pardata["usrname"]."\"";
$handelusr = mysql_query($q2) or die("error in searching data user");
$usrdata = mysql_fetch_array($handelusr);
echo "<table width=100% border=0 cellpadding=0 cellspacing=0 class=border>
//display all reply of current topic....
$qanak = "select * from topic where parent = $idtopickpl";
$hdlanak = mysql_query($qanak);
while (($dataanak = mysql_fetch_row($hdlanak))!=0) {
$q2 = "select * from userdat where logname =
\"".$dataanak[2]."\"";
$handelusr = mysql_query($q2) or die("error in searching data user");
$usrdata = mysql_fetch_array($handelusr);
echo "<table width=100% border=0 cellpadding=0 cellspacing=0 class=border>
4.2.3.9. Halaman Administrator
Halaman ini berfungsi sebagai pengendali dari forum ini, dimana kita memiliki hak untuk mengetur forum ini
Segmen Program 4.24 Script untuk melakukan hak sebagai admin adalah:
<?
if ( isset($_COOKIE["web_user"])) {
$statusr = "<span class=\"style4\">Logged in as <strong><a href=showprofile.php?user=". $_COOKIE["web_user"] .">".
$_COOKIE["web_user"] ."</a></strong></font><br>";
$statusr .= "<span class = \"style4\"><a href=\"profile.php\">edit profile</a></font>";
} else {
$statusr = "<span class = \"style4\">Not Logged in</span>";
}
require_once ( "log_db.php" );
?>
<?
//mulai cetak tabel user
if ($_GET["adminpros"] == "useradm"){
//kalo yang diclik adalah user admin
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\"
cellspacing=\"0\" class=\"tepi\">
<tr><td height=\"16\" colspan=\"7\" valign=\"top\"
class=\"bgtitle\"> User Admin</td></tr>
<td height=\"18\"></td>
<td valign=\"top\" class=\"headerlist\">User Name </td>
<td valign=\"top\" class=\"headerlist\">Location</td>
<td colspan=\"3\" valign=\"top\" class=\"headerlist\">Status User </td>
</tr>";
$qusr = "select count(*) as tot from userdat where logname <>
\"".$_COOKIE["web_user"]."\"";
$userhandel = mysql_query($qusr);
$usrdat = mysql_fetch_array($userhandel);
$banyakrow = $usrdat["tot"];
$pageLimit = 10;
$qusr = "select * from userdat where logname <>
\"".$_COOKIE["web_user"]."\"";
if (empty($_GET["startshow"])){
$startshow = 0;
$qusr .=" limit $startshow, $pageLimit";
} else{
$startshow = $_GET["startshow"];
$qusr .=" limit $startshow, $pageLimit";
}
$userhandel = mysql_query($qusr) or die("Error in retreiving data".mysql_error());;
$jumlahbaris = mysql_num_rows($userhandel);
$high = TRUE;
if ($jumlahbaris < $pageLimit) $ulang = $jumlahbaris;
else
$ulang = $pageLimit;
for ( $a=0; $a < $ulang; $a++) {
$datatampil = mysql_fetch_array($userhandel);
$logname = $datatampil["logname"];
$loca = $datatampil["location"];
echo "<tr><td height=\"18\"></td>";
if ($high){
$high = FALSE;
echo "<td valign=\"top\" class=highlist>$logname</td>
<td valign=\"top\" class=highlist>$loca</td>
<td valign=\"top\" class=highlist><a
href=\"adminok.php?adminpros=useradm&startshow=0&usrset=admin&usrn ya=$logname\" target=\"_blank\">Admin</a></td>
<td valign=\"top\" class=highlist><a
href=\"adminok.php?adminpros=useradm&startshow=0&usrset=leader&usr nya=$logname\" target=\"_blank\">Leader</a></td>
<td valign=\"top\" class=highlist><a
href=\"adminok.php?adminpros=useradm&startshow=0&usrset=ban&usrnya
=$logname\" target=\"_blank\">Ban</a></td>
</tr>";
} else{
$high = TRUE;
echo "<td valign=\"top\" class=listnonhigh>$logname</td>
<td valign=\"top\" class=listnonhigh>$loca</td>
<td valign=\"top\" class=listnonhigh><a
href=\"adminok.php?adminpros=useradm&startshow=0&usrset=admin&usrn ya=$logname\" target=\"_blank\">Admin</a></td>
<td valign=\"top\" class=listnonhigh><a
href=\"adminok.php?adminpros=useradm&startshow=0&usrset=leader&usr nya=$logname\" target=\"_blank\">Leader</a></td>
<td valign=\"top\" class=listnonhigh><a
href=\"adminok.php?adminpros=useradm&startshow=0&usrset=ban&usrnya
=$logname\" target=\"_blank\">Ban</a></td>
</tr>";
} }
echo "<tr><td height=\"8\"></td>
//proses menampilkan navigasi if ($banyakrow > 0){
if ($startshow<$banyakrow && $startshow>0){
//untuk nampilkan PREV
$start1 = $startshow - $pageLimit;
echo "<a
href=\"admin.php?adminpros=useradm&startshow=".$start1."\">Prev
</a>";
}
//menghitung dan menampilkan link # halaman
$pages = $banyakrow/ $pageLimit;
if ($pages > 1){
for ($b=0,$c=1; $b < $pages; $b++,$c++) { $Res1=$pageLimit * $b;
echo "<a
href=\"admin.php?adminpros=useradm&startshow=".$Res1."\">".$c."
</a>";
} }
//menampilkan NEXT
if ($startshow>=0 && $startshow<$banyakrow) { $Res1=$startshow+$pageLimit;
if ($Res1<$banyakrow) { echo "<A
HREF=\"admin.php?adminpros=useradm&startshow=".$Res1."\"> Next
</A>";
} } } else
if ($_GET["adminpros"] == "newsadm"){
//kalo yang diclick adalah news admin
echo '<table width="100%" border="0" cellpadding="0"
cellspacing="0" class="tepi">
$news = "select count(*) as tot from topic where typemsg =
\"News\"";
$Newsdat = mysql_query($news);
$datanews = mysql_fetch_array($Newsdat);
$banyakrow = $datanews["tot"];
$pageLimit = 10;
$qnews = "select * from topic where typemsg = \"News\" ";
if (empty($_GET["startshow"])){
$startshow = 0;
$qnews .=" limit $startshow, $pageLimit";
} else{
$startshow = $_GET["startshow"];
$qnews .=" limit $startshow, $pageLimit";
}
$newshandel = mysql_query($qnews) or die("Error in retreiving data".mysql_error());;
$jumlahbaris = mysql_num_rows($newshandel);
$high = TRUE;
if ($jumlahbaris < $pageLimit) $ulang = $jumlahbaris;
else
$ulang = $pageLimit;
for ( $a=0; $a < $ulang; $a++) {
$datatampil = mysql_fetch_array($newshandel);
$idmsg = $datatampil["id"];
$title = $datatampil["title"];
echo "<tr><td height=\"18\"></td>";
if ($high){
$high = FALSE;