Config.php
<?php
$host = "localhost";
$username = "root";
$password = "";
$databasename = "dbmoodle";
$connection = mysql_connect($host, $username, $password) or
die("Kesalahan Koneksi … !!");
mysql_select_db($databasename, $connection) or
die("Databasenya Error");
?>
Berita.php
<?php?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>BERITA</title>
<description></description>
<language>id</language>
<managingEditor>Mobile Learning</managingEditor>
<copyright>Copyright 2011 Mobile Learning</copyright>
<?php
include "config.php";
$query = "SELECT subject, message from mdl_forum_posts
";
$run = mysql_query($query);
while($b=mysql_fetch_array($run)){
?>
<item>
<title><?php echo "$b[subject]";
?></title>
<description><?php echo "$b[message]";
?></description>
</item>
<?php } ?>
</channel>
</rss>
<?php mysql_close(); ?>
Course.php
<?php ?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>COURSE YANG DI AMBIL</title>
<link>http://m-learning.com/</link>
<description></description>
<language>id</language>
<managingEditor>Mobile Learning</managingEditor>
<copyright>Copyright 2011 Mobile
Learning</copyright>
<?php
include "config.php";
$query = "SELECT a.course, b.fullname, b.id,
c.username, a.userid from mdl_course_display
as a inner join
mdl_course as b on b.id=a.course inner join mdl_user as c on c.id=a.userid and
c.username='".$_GET['uname']."' ";
$run =
mysql_query($query);
while($b=mysql_fetch_array($run)){
?>
<item>
<title><?php echo "$b[fullname]";
?></title>
<pubDate><?php echo "$b[userid]";
?></pubDate>
<link><?php echo "$b[id]";
?></link>
<description><?php echo "$b[username]";
?></description>
</item>
<?php } ?>
</channel>
</rss>
<?php mysql_close(); ?>
courseDetailTopikJson.php
<?php
include
"config.php";
$idc=
$_REQUEST['idc'];
$un=
$_REQUEST['un'];
if($idc &&
$un){
$sqlString =
"SELECT a.course, b.fullname, b.id, c.username, a.userid, d.id, d.name,
d.type, d.alltext, d.reference from mdl_course_display
as a inner join
mdl_course as b on b.id=a.course inner join mdl_user as c on c.id=a.userid
inner join
mdl_resource as d on d.course=a.course and d.type='text' and
b.id='".$_GET['idc']."' and d.id='".$_GET['idr']."' and
a.userid='".$_GET['un']."'";
}else{
$sqlString = "SELECT a.course,
b.fullname, b.id, c.username, a.userid, d.name, d.type, d.alltext, d.reference
from mdl_course_display
as a inner join
mdl_course as b on b.id=a.course inner join mdl_user as c on c.id=a.userid
inner join
mdl_resource as d on d.course=a.course and d.type='text'";
}
$rs =
mysql_query($sqlString);
if($rs){
while($objRs =
mysql_fetch_assoc($rs)){
$output[] =
$objRs;
}
echo
json_encode($output);
}
mysql_close();
?>
courseTopik.php
<?php ?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>TOPIK COURSE</title>
<link>http://m-learning.com/</link>
<description>Silahkan Klik Topik yang
Ada</description>
<language>id</language>
<managingEditor>Mobile Learning</managingEditor>
<copyright>Copyright 2011 Mobile
Learning</copyright>
<?php
include "config.php";
$query = "SELECT a.course, b.fullname, c.username,
a.userid, d.id, d.name, d.type, d.alltext, d.reference from mdl_course_display
as a inner join
mdl_course as b on b.id=a.course inner join mdl_user as c on c.id=a.userid
inner join
mdl_resource as d on d.course=a.course and d.type='text' and
b.id='".$_GET['idc']."' and c.id='".$_GET['idu']."' ";
$run = mysql_query($query);
while($b=mysql_fetch_array($run)){
?>
<item>
<title><?php echo "$b[name]";
?></title>
<pubDate><?php echo "$b[course]";
?></pubDate>
<link><?php echo "$b[id]";
?></link>
<category><?php echo "$b[alltex]";
?></category>
<description><?php echo "$b[userid]";
?></description>
</item>
<?php } ?>
</channel>
</rss>
<?php mysql_close(); ?>
downloadFile.php
<?php ?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>DOWNLOAD FILE</title>
<link>http://m-learning.com/</link>
<description>Silahkan Klik Untuk Menuju Lnk
Download</description>
<language>id</language>
<managingEditor>Mobile Learning</managingEditor>
<copyright>Copyright 2011 Mobile
Learning</copyright>
<?php
include "config.php";
$query = "SELECT a.course, b.fullname, b.id,
c.username, a.userid, d.name, d.type, d.alltext, d.reference from
mdl_course_display
as a inner join
mdl_course as b on b.id=a.course inner join mdl_user as c on c.id=a.userid
inner join
mdl_resource as d on d.course=a.course and d.type='file' and
b.id='".$_GET['idc']."' and c.id='".$_GET['idu']."' ";
$run = mysql_query($query);
while($b=mysql_fetch_array($run)){
?>
<item>
<title><?php echo "$b[name]";
?></title>
<link><?php echo "$b[id]";
?></link>
<description><?php echo "$b[reference]";
?></description>
</item>
<?php } ?>
</channel>
</rss>
<?php mysql_close(); ?>
Login.php
<?php
include "config.php";
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
$passwordhash = md5($password);
// query untuk mendapatkan record dari username
$query = "SELECT * from mdl_user where username =
'$username' and password = '$passwordhash' ";
$numRow = mysql_num_rows(mysql_query($query));
// cek kesesuaian password
if ($numRow >= 1)
echo 1;
else
echo 0;
?>
Nilai.php
<?php ?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>NILAI TUGAS</title>
<link>http://m-learning.com/</link>
<description>Silahkan Klik Untuk Melihat Nilai Tugas
yang Ada</description>
<language>id</language>
<managingEditor>Mobile Learning</managingEditor>
<copyright>Copyright 2011 Mobile
Learning</copyright>
<?php
include "config.php";
$query = "select c.id, c.fullname,a.userid, d.username,
b.name, a.id, a.assignment,a.grade from mdl_assignment_submissions as a
inner join mdl_assignment as b on
b.id=a.assignment inner join mdl_course as c on c.id=b.course
inner join mdl_user as d on d.id=a.userid and
c.id='".$_GET['idc']."' and
a.userid='".$_GET['idu']."'";
$run = mysql_query($query);
while($b=mysql_fetch_array($run)){
?>
<item>
<title><?php echo "$b[name]";
?></title>
<pubDate><?php echo "$b[id]";
?></pubDate>
<link><?php echo "$b[userid]";
?></link>
<description><?php echo "$b[assignment]";
?></description>
</item>
<?php } ?>
</channel>
</rss>
<?php mysql_close(); ?>
nilaiDetailJson.php
<?php
include
"config.php";
$idu=
$_REQUEST['idu'];
$ida=
$_REQUEST['ida'];
if($idu &&
$ida){
$sqlString =
"SELECT a.course,b.fullname, c.username, a.userid, d.id, d.name, e.id,
e.assignment, e.grade FROM `mdl_course_display` as a inner
join
mdl_course as b on b.id=a.course inner
join mdl_user as c on c.id=a.userid inner join mdl_assignment as d on
d.course=a.course
inner join mdl_assignment_submissions as e on e.assignment=d.id
and
a.userid='".$_GET['idu']."'
and
e.assignment='".$_GET['ida']."'
and
e.id='".$_GET['idsub']."'";
}else{
$sqlString =
"SELECT a.course,b.fullname, c.username, a.userid, d.id, d.name, e.id,
e.assignment, e.grade FROM `mdl_course_display` as a inner
join
mdl_course as b on b.id=a.course inner
join mdl_user as c on c.id=a.userid inner join mdl_assignment as d on
d.course=a.course
inner join mdl_assignment_submissions as e on e.assignment=d.id";
}
$rs =
mysql_query($sqlString);
if($rs){
while($objRs =
mysql_fetch_assoc($rs)){
$output[] =
$objRs;
}
echo
json_encode($output);
}
mysql_close();
?>
Tugas.php
<?php?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>TUGAS</title>
<link>http://m-learning/</link>
<description>Silahkan Klik Tugas yang
Ada</description>
<language>id</language>
<managingEditor>Mobile Learning</managingEditor>
<copyright>Copyright 2011 Mobile
Learning</copyright>
<?php
include "config.php";
$query = "SELECT a.course,b.fullname, c.username,
a.userid, d.id, d.name, d.description FROM `mdl_course_display` as a inner
join mdl_course as b
on b.id=a.course inner join mdl_user as
c on c.id=a.userid inner join mdl_assignment as d on
d.course=a.course and
b.id='".$_GET['idc']."' and c.id='".$_GET['idu']."'";
$run = mysql_query($query);
while($b=mysql_fetch_array($run)){
?>
<item>
<title><?php echo "$b[name]";
?></title>
<pubDate><?php echo "$b[course]";
?></pubDate>
<link><?php echo "$b[id]";
?></link>
<description><?php echo "$b[userid]";
?></description>
</item>
<?php } ?>
</channel>
</rss>
<?php mysql_close(); ?>
tugasDetailJson.php
<?php
include
"config.php";
$idc=
$_REQUEST['idc'];
$idu=
$_REQUEST['idu'];
if($idc &&
$idu){
$sqlString =
"SELECT a.course, b.fullname, b.id, c.username, a.userid, d.id, d.name,
d.description from mdl_course_display
as a inner join
mdl_course as b on b.id=a.course inner join mdl_user as c on c.id=a.userid
inner join
mdl_assignment d on d.course=a.course and b.id='".$_GET['idc']."' and
d.id='".$_GET['ida']."' and
a.userid='".$_GET['idu']."'";
}else{
$sqlString =
"SELECT a.course, b.fullname, b.id, c.username, a.userid, d.id, d.name,
d.type, d.description from mdl_course_display
as a inner join
mdl_course as b on b.id=a.course inner join mdl_user as c on c.id=a.userid
inner join
mdl_assignment d on d.course=a.course";
}
$rs =
mysql_query($sqlString);
if($rs){
while($objRs =
mysql_fetch_assoc($rs)){
$output[] = $objRs;
}
echo
json_encode($output);
}
mysql_close();
?>
tugasKirimTeks.php
<?php
include "config.php";
$idtgs=$_REQUEST['idtgs'];
$iduser=$_REQUEST['idu'];
$jawaban=$_REQUEST['jawab'];
$timezone = "Asia/Jakarta";
date_default_timezone_set($timezone);
$waktu
= time();
$q2 =
"SELECT timedue from mdl_assignment where id ='$idtgs'";
$hq2 =
mysql_query($q2);
$data2
= mysql_fetch_array($hq2);
//echo
$data2['timedue'];
$t =
$data2['timedue']; ;
$y = intval($t);
$ts =
date("Y-m-d H:i",$y);
$te =
date("Y-m-d H:i");
$q1 = "SELECT count(*) as jum FROM
mdl_assignment_submissions WHERE data1 = '$jawaban'";
$hasil = mysql_query($q1);
$data =
mysql_fetch_array($hasil);
if (($data['jum'] > 0) || ($te > $ts))
{
echo "SAMA ATAU TELAT";
} else
$query = "INSERT INTO
mdl_assignment_submissions(assignment,userid,timemodified,data1)
VALUES('$idtgs','$iduser','$waktu','$jawaban')";
$result = mysql_query($query);
if ($result >= 1)
echo 1;
else
echo 0;
?>
tugasKirimTeksUpdate.php
<?php
include "config.php";
$idtgs=$_REQUEST['idtgs'];
$iduser=$_REQUEST['idu'];
$idas=$_REQUEST['idas'];
$jawaban=$_REQUEST['jawab'];
$timezone =
"Asia/Jakarta";
date_default_timezone_set($timezone);
//echo
date('l, j F Y, h:i A');
$waktu
= time();
//echo
$waktu;
$q2 =
"SELECT timedue from mdl_assignment where id ='$idtgs'";
$hq2 =
mysql_query($q2);
$data2
= mysql_fetch_array($hq2);
//echo
$data2['timedue'];
$t =
$data2['timedue']; ;
$y = intval($t);
$ts =
date("Y-m-d H:i",$y);
$te =
date("Y-m-d H:i");
$q1 = "SELECT count(*) as jum FROM
mdl_assignment_submissions WHERE data1 = '$jawaban';";
$hasil = mysql_query($q1);
$data =
mysql_fetch_array($hasil);
if (($data['jum'] > 0) || ($te > $ts))
{
echo "MAAF DATA YANG ANDA MASUKAN SAMA ATAU WAKTU ANDA
TELAH HABIS";
} else
$query = "UPDATE mdl_assignment_submissions SET
timemodified = '$waktu', data1 = '$jawaban' WHERE id = '$idas'";
$result = mysql_query($query);
if ($result >= 1)
echo 1;
else
echo 0;
?>
tugasUpdate.php
<?php ?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>TUGAS</title>
<link>http://m-learning.com/</link>
<description>Silahkan Klik Tugas Untuk
Update</description>
<language>id</language>
<managingEditor>Mobile Learning</managingEditor>
<copyright>Copyright 2011 Mobile
Learning</copyright>
<?php
include "config.php";
$query = "select c.id as course, c.fullname,a.userid,
d.username, b.name, a.id as id_sub, a.assignment,a.grade from
mdl_assignment_submissions as a
inner join mdl_assignment as b on
b.id=a.assignment inner join mdl_course as c on c.id=b.course
inner join mdl_user as d on d.id=a.userid and
c.id='".$_GET['idc']."' and
a.userid='".$_GET['idu']."'";
$run = mysql_query($query);
while($b=mysql_fetch_array($run)){
?>
<item>
<title><?php echo "$b[name]";
?></title>
<pubDate><?php echo "$b[course]";
?></pubDate>
<link><?php echo "$b[assignment]";
?></link>
<category><?php echo "$b[id_sub]";
?></category>
<description><?php echo "$b[userid]";
?></description>
</item>
<?php } ?>
</channel>
</rss>
<?php mysql_close(); ?>
uploadProses.php
<?php
//
setting nama folder tempat upload
include
"config.php";
$dirPath
= '../../htdocs';
$idcourse=$_REQUEST['idc'];
$idtgs=$_REQUEST['idtgs'];
$iduser=$_REQUEST['idu'];
if
($handle = opendir($dirPath)){
if(!is_dir("../moodledata")){
mkdir("../moodledata");
}
$dirpath2="../moodledata";
if(opendir($dirpath2)){
if(!is_dir("../moodledata/".$idcourse)){
mkdir("../moodledata/".$idcourse);
}
$dirpath3="../moodledata/".$idcourse;
if(opendir($dirpath3)){
if(!is_dir($dirpath3."../moddata")){
mkdir($dirpath3."../moddata");
}
$dirpath4=$dirpath3."../moddata";
if(opendir($dirpath4)){
if(!is_dir($dirpath4."../assignment")){
mkdir($dirpath4."../assignment");
}
$dirpath5=$dirpath4."../assignment";
if(opendir($dirpath5)){
if(!is_dir($dirpath5."../".$idtgs)){
mkdir($dirpath5."../".$idtgs);
}
$dirpath6=$dirpath5."../".$idtgs;
if(opendir($dirpath6)){
if(!is_dir($dirpath6."../".$iduser)){
mkdir($dirpath6."../".$iduser);
}
}
}
}
}
}
}
$timezone
= "Asia/Jakarta";
date_default_timezone_set($timezone);
//echo
date('l, j F Y, h:i A');
$waktu
= time();
//echo
$waktu;
$dirtujuan=$dirpath6."/".$iduser;
//echo
$uploaddir;
//
membaca nama file yang diupload
$fileName
= $_FILES['userfile']['name'];
// nama
file temporary yang akan disimpan di server
$tmpName = $_FILES['userfile']['tmp_name'];
//
membaca ukuran file yang diupload
$fileSize
= $_FILES['userfile']['size'];
//
membaca jenis file yang diupload
$fileType
= $_FILES['userfile']['type'];
//$tgl=date('Y-m-d');
$uploadfile
= $fileName;
$q2 =
"SELECT timedue from mdl_assignment where id ='$idtgs'";
$hq2 =
mysql_query($q2);
$data2
= mysql_fetch_array($hq2);
//echo
$data2['timedue'];
$t =
$data2['timedue']; ;
$y = intval($t);
$ts =
date("Y-m-d H:i",$y);
$te =
date("Y-m-d H:i");
//
proses upload file ke folder 'data'
if((file_exists("$dirtujuan/".$uploadfile))
|| ($te > $ts)){
//echo
"<script>";
echo"File
Sudah Ada,Silahkan Ganti Nama File ATAU ANDA TELAT, SILAHKAN PERIKSA
LAGI";
//echo"</script>";
}else
if
(move_uploaded_file($_FILES['userfile']['tmp_name'],"$dirtujuan/".$uploadfile))
{
$sqlmateri=mysql_query("INSERT
INTO mdl_assignment_submissions(assignment,userid,timemodified)
VALUES('$idtgs','$iduser','$waktu')");
//echo
"<script>";
echo"File..."
.$fileName. "...Berhasil Diupload";
//echo"</script>";
}else {
//echo
"<script>";
echo"File
Gagal Diupload";
//echo"</script>";
}
?>
uploadUpdate.php
<?php
//
setting nama folder tempat upload
include
"config.php";
$dirPath
= '../../htdocs';
$idas=$_REQUEST['idas'];
$idcourse=$_REQUEST['idc'];
$idtgs=$_REQUEST['idtgs'];
$iduser=$_REQUEST['idu'];
if
($handle = opendir($dirPath)){
if(!is_dir("../moodledata")){
mkdir("../moodledata");
}
$dirpath2="../moodledata";
if(opendir($dirpath2)){
if(!is_dir("../moodledata/".$idcourse)){
mkdir("../moodledata/".$idcourse);
}
$dirpath3="../moodledata/".$idcourse;
if(opendir($dirpath3)){
if(!is_dir($dirpath3."../moddata")){
mkdir($dirpath3."../moddata");
}
$dirpath4=$dirpath3."../moddata";
if(opendir($dirpath4)){
if(!is_dir($dirpath4."../assignment")){
mkdir($dirpath4."../assignment");
}
$dirpath5=$dirpath4."../assignment";
if(opendir($dirpath5)){
if(!is_dir($dirpath5."../".$idtgs)){
mkdir($dirpath5."../".$idtgs);
}
$dirpath6=$dirpath5."../".$idtgs;
if(opendir($dirpath6)){
if(!is_dir($dirpath6."../".$iduser)){
mkdir($dirpath6."../".$iduser);
}
}
}
}
}
}
}
$timezone
= "Asia/Jakarta";
date_default_timezone_set($timezone);
//echo
date('l, j F Y, h:i A');
$waktu
= time();
//echo
$waktu;
$dirtujuan=$dirpath6."/".$iduser;
//echo
$uploaddir;
//
membaca nama file yang diupload
$fileName
= $_FILES['userfile']['name'];
// nama
file temporary yang akan disimpan di server
$tmpName = $_FILES['userfile']['tmp_name'];
//
membaca ukuran file yang diupload
$fileSize
= $_FILES['userfile']['size'];
//
membaca jenis file yang diupload
$fileType
= $_FILES['userfile']['type'];
//$tgl=date('Y-m-d');
$uploadfile
= $fileName;
$query = "UPDATE
mdl_assignment_submissions SET timemodified = '$waktu' WHERE id =
'$idas'";
mysql_query($query);
// proses upload file ke folder 'data'
if
(move_uploaded_file($_FILES['userfile']['tmp_name'],"$dirtujuan/".$uploadfile))
{
echo "File telah
diupdate";
} else {
echo "File
gagal diupdate";
}
?>
Project di adt eclipse
Koneksi di java
package mobile.config;
public class koneksi {
//String
urlMobileLearning= "https://127.0.0.1/";
String
urlMobileLearning= "http://10.0.2.2/";
public koneksi(String
urlml){
urlMobileLearning = urlMobileLearning+urlml;
}
public String getUrl(){
return urlMobileLearning;
}
}
Sigin.xml
<?xml version="1.0"
encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#ffffff"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/kepala"
android:text="MOBILE
LEARNING LOGIN"
android:layout_marginTop="5px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20px"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
></TextView>
</LinearLayout>
<EditText
android:layout_marginTop="20px"
android:id="@+id/uname"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="left"
android:hint="USERNAME"
android:layout_gravity="left"></EditText>
<EditText
android:layout_marginTop="20px"
android:id="@+id/passwd"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="left"
android:hint="PASSWORD"
android:password="true"
android:layout_gravity="left"></EditText>
<Button
android:id="@+id/login"
android:layout_width="120px"
android:layout_height="50px"
android:text="L O G I N"
android:layout_gravity="right"
android:textStyle="bold"
></Button>
</LinearLayout>
</ScrollView>
Login.php
package com.mobile.learning;
import mobile.config.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class login extends Activity {
public
koneksi linkurl;
String
SERVER_URL;
private
Button login;
private
EditText username, password;
public
ProgressDialog progressDialog;
//
private TextView notif;
/**
Called when the activity is first created. */
@Override
public
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.signin);
login
= (Button) findViewById(R.id.login);
username
= (EditText) findViewById(R.id.uname);
password
= (EditText) findViewById(R.id.passwd);
//
final TextView notif = (TextView) findViewById(R.id.tv_error);
login.setOnClickListener(new
OnClickListener() {
public
void onClick(View v) {
//
TODO Auto-generated method stub
String
Re;
String
mUsername = username.getText().toString();
String
mPassword = password.getText().toString();
Re
= tryLogin(mUsername, mPassword);
Log.d("Check",
"Here");
Log.d("Re",
Re);
String
temp_check = Re.trim();
if
(temp_check.equals("1")) {
String
nama = username.getText().toString();
Intent
newIntent = new Intent(login.this,
halamanUtama.class);
String
txtnama = String.valueOf(nama);
//
membuat Bundle
Bundle
bundle = new Bundle();
//
menentukan parameter Bundle (id,isi) --> id=nama dan
//
isinya adalah variabel dari txtnama
bundle.putString("nama",
txtnama);
//
menambahkan bundle pada intent
newIntent.putExtras(bundle);
startActivityForResult(newIntent,
0);
//
notif.setText("SUKSES");
}
else {
createDialog("Maaf",
"Username Atau Password Salah !");
}
}
});
}
protected
String tryLogin(String mUsername, String mPassword) {
Log.d("
TryLoginCheck ", "Here");
HttpURLConnection
connection;
OutputStreamWriter
request = null;
URL
url = null;
String
response = null;
String
temp = null;
String
parameters = "username=" + mUsername + "&password=" +
mPassword;
System.out.println("UserName"
+ mUsername + "\n" + "password"
+
mPassword);
Log.d("Parameters",
parameters);
try
{
;
// linkurl
= new koneksi("mobile/login.php");
// SERVER_URL
= linkurl.getUrl();
//
http://182.6.232.37:8080/mobile/login.php
//
http://127.0.0.1/;
// url
= new URL(SERVER_URL);
url = new
URL("http://10.0.2.2/mobile/login.php");
connection
= (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
connection.setRequestMethod("POST");
request
= new OutputStreamWriter(connection.getOutputStream());
request.write(parameters);
request.flush();
request.close();
String
line = "";
InputStreamReader
isr = new InputStreamReader(
connection.getInputStream());
BufferedReader
reader = new BufferedReader(isr);
StringBuilder
sb = new StringBuilder();
while
((line = reader.readLine()) != null) {
sb.append(line
+ "\n");
}
temp
= sb.toString();
Log.d("Temp",
temp);
//
Response from server after login process will be stored in
//
response variable.
response
= sb.toString();
Log.d("Response",
response);
Log.d("Sb
Value", sb.toString());
isr.close();
reader.close();
}
catch (IOException e) {
Toast.makeText(this,
e.toString(), 0).show();
}
//
Log.d("Response",response);
return
response;
}
private
void createDialog(String title, String text) {
AlertDialog
ad = new AlertDialog.Builder(this)
.setPositiveButton("Ok",
null).setTitle(title).setMessage(text)
.create();
ad.show();
}
}
Welcome.xml
<?xml version="1.0"
encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:background="#ffffff"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/logOut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="LogOut"
android:textColor="#FF3333"
android:textStyle="bold"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/welText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="te"
android:textColor="#000000"
android:textStyle="bold"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/textView3"
android:textColor="#ffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="-" />
</LinearLayout>
<RelativeLayout
android:id="@+id/relativeLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/ibBerita"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="62dp"
android:background="@drawable/news"
/>
<Button
android:id="@+id/ibKonten"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="63dp"
android:background="@drawable/konten"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/tvKonten"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="64dp"
android:text="
MATERI"
android:textColor="#000000"
android:textStyle="bold"
/>
<TextView
android:id="@+id/tvBerita"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="62dp"
android:text="BERITA
"
android:textColor="#000000"
android:textStyle="bold"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/textView2"
android:textColor="#ffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="-" />
</LinearLayout>
<RelativeLayout
android:id="@+id/relativeLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/ibTugas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="64dp"
android:background="@drawable/tugas"
/>
<Button
android:id="@+id/ibNilai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="60dp"
android:background="@drawable/nilai"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/tvTugas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="67dp"
android:text=" TUGAS"
android:textColor="#000000"
android:textStyle="bold"
/>
<TextView
android:id="@+id/tvNilai"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="61dp"
android:text="
NILAI"
android:textColor="#000000"
android:textStyle="bold"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/textView1"
android:textColor="#ffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="-" />
</LinearLayout>
<RelativeLayout
android:id="@+id/relativeLayout7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/ibDonlot"
android:layout_width="77dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="56dp"
android:background="@drawable/download"
/>
<Button
android:id="@+id/ibAbout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="58dp"
android:background="@drawable/about"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/tvDonlot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="62dp"
android:text="DOWNLOAD"
android:textColor="#000000"
android:textStyle="bold"
/>
<TextView
android:id="@+id/tvAbout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="60dp"
android:text="ABOUT
"
android:textColor="#000000"
android:textStyle="bold"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</LinearLayout>
</LinearLayout>
</ScrollView>
Halamanutama.php
package com.mobile.learning;
import mobile.course.*;
import mobile.berita.*;
import mobile.download.*;
import mobile.tugas.*;
import mobile.nilai.*;
import mobile.about.*;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class halamanUtama extends Activity {
public void
onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
Button ibCourse
= (Button) findViewById(R.id.ibKonten);
Button ibDonlot
= (Button) findViewById(R.id.ibDonlot);
Button ibTugas =
(Button) findViewById(R.id.ibTugas);
Button ibNilai =
(Button) findViewById(R.id.ibNilai);
Button ibBerita
= (Button) findViewById(R.id.ibBerita);
Button ibAbout =
(Button) findViewById(R.id.ibAbout);
Bundle bundle =
this.getIntent().getExtras();
//Mengambil
parameter 1 yaitu kode = nama
final String
param1 = bundle.getString("nama");
TextView tv =
(TextView)findViewById(R.id.welText);
TextView
tv_logOut = (TextView) findViewById(R.id.logOut);
tv.setText("Selamat Datang -" +param1+ "- di
M-Learning");
tv_logOut.setOnClickListener(new OnClickListener() {
public
void onClick(View v) {
//
TODO Auto-generated method stub
Intent
logout = new Intent(halamanUtama.this, login.class);
startActivity(logout);
}
});
ibCourse.setOnClickListener(new OnClickListener() {
public
void onClick(View v) {
//
TODO Auto-generated method stub
String
namauser = param1;
Intent
newIntent = new Intent(halamanUtama.this, course.class);
String
txtnama = String.valueOf(namauser);
//membuat
Bundle
Bundle
bundle = new Bundle();
//menentukan parameter Bundle (id,isi) --> id=nama dan isinya adalah
variabel dari txtnama
bundle.putString("namauser", txtnama);
//menambahkan bundle pada intent
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
}
});
ibDonlot.setOnClickListener(new OnClickListener() {
public
void onClick(View v) {
//
TODO Auto-generated method stub
String
namauser = param1;
Intent
newIntent = new Intent(halamanUtama.this, download.class);
String
txtnama = String.valueOf(namauser);
//membuat
Bundle
Bundle
bundle = new Bundle();
//menentukan parameter Bundle (id,isi) --> id=nama dan isinya adalah
variabel dari txtnama
bundle.putString("namauser", txtnama);
//menambahkan bundle pada intent
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
}
});
ibTugas.setOnClickListener(new OnClickListener() {
public
void onClick(View v) {
//
TODO Auto-generated method stub
String
namauser = param1;
Intent
newIntent = new Intent(halamanUtama.this, pilihTugas.class);
String
txtnama = String.valueOf(namauser);
//membuat
Bundle
Bundle
bundle = new Bundle();
//menentukan parameter Bundle (id,isi) --> id=nama dan isinya adalah
variabel dari txtnama
bundle.putString("namauser", txtnama);
//menambahkan bundle pada intent
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
}
});
ibNilai.setOnClickListener(new OnClickListener() {
public
void onClick(View v) {
//
TODO Auto-generated method stub
String
namauser = param1;
Intent
newIntent = new Intent(halamanUtama.this, nilai.class);
String
txtnama = String.valueOf(namauser);
//membuat
Bundle
Bundle
bundle = new Bundle();
//menentukan parameter Bundle (id,isi) --> id=nama dan isinya adalah
variabel dari txtnama
bundle.putString("namauser", txtnama);
//menambahkan bundle pada intent
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
}
});
ibBerita.setOnClickListener(new OnClickListener() {
public
void onClick(View v) {
//
TODO Auto-generated method stub
Intent
intentBerita = new Intent(halamanUtama.this, berita.class);
startActivity(intentBerita);
}
});
ibAbout.setOnClickListener(new
OnClickListener() {
public
void onClick(View v) {
//
TODO Auto-generated method stub
Intent
intentAbout = new Intent(halamanUtama.this, about.class);
startActivity(intentAbout);
}
});
}
}
Bersambung….
