Kamis, 14 April 2016

Assignment CI

phonebook.php(ontroller)
<?php
class phonebook extends CI_controller{
    function __construct(){
        parent::__construct();
        $this->load->helper(array('url','form'));
        $this->load->model('model_phonebook');
    }

    function index(){
        $data['contacts']=$this->model_phonebook->getAll();
        $this->load->view('view_phonebook',$data);
    }
    function welcome(){
        $this->load->view('welcome_arya');
    }
}
 ?>

model_phonebook.php(model)
<?php
class model_phonebook extends CI_Model{
    function __construct(){
        parent::__construct();
        $this->load->database();
    }
    function getAll(){
        return $this->db->get('phonebook')->result();
    }
}
 ?>

view_phonebook.php(view)
<!DOCTYPE html>
<html>
<head>
    <title>Assignment</title>
</head>
<body>
<h1>Phone Book Kelas</h1>
<table border='1'>
    <thead>
        <tr>
            <th>id</th>
            <th>nama</th>
            <th>alamat</th>
            <th>HP</th>
            <th>email</th>
            <th>kelas</th>
        </tr>
    </thead>
    <tbody>
    <?php $i=1; ?>
    <?php foreach($contacts as $contact){ ?>
        <tr>
            <td><?php echo $i++ ?></td>
            <td><?php echo $contact->nama; ?></td>
            <td><?php echo $contact->alamat; ?></td>
            <td><?php echo $contact->HP; ?></td>
            <td><?php echo $contact->email; ?></td>
            <td><?php echo $contact->kelas ?></td>
        </tr>
    <?php } ?>
    </tbody>
</table>
</body>
</html>

Jumat, 01 April 2016

Link Website : hopeits.com/wp

Biaya yang dikeluarkan adalah 220 000 rupiah

Langkah-langkah yang kami lakukan dalam pengerjaan web:

  • Mencari domain dan hosting yang menurut kami sesuai dengan apa yang kami butuhkan dan terjangkau.
  • Membeli domain, membuat nama website.
  • Menginstall Wordpress.
  • Mengisi website dengan tema, plugins sesuai kebutuhan.
  • Menambah fitur website.
Fitur


Forum Page yang bisa memposting pertanyaan dan sebagainnya yang bisa dijadikan forum tanya jawab.



Login page untuk developer



Page untuk upload project yang ingin diberikan ke developer.


Page register untuk developer yang ingin join ke hopeits



Widget testimonial yang bisa digeser ke kiri dan kanan


Postingan yang bisa dibaca oleh umum




2. Buatlah program pendek untuk monitoring praktikum, dengan spesifikasi berikut
Script connect.php:

Script halaman login

Script show tabel




<?php
//$servername = "localhost";
$username = "utspw"; //tidak harus susulan1 terserah kalian
$password = "utspw"; //tidak harus susulan1 terserah kalian
$db="oci:UTSPW=XE"; //tidak harus susualan1 terserah kalian 

// Create connection
$conn = new PDO ($db, $username, $password);

// Check connection
if (!$conn) {
 $error=oci_error();
 echo "gagal connect", $error['text'];
}
else{
 echo "Masuk";
}
<head>
    <title>
        User Login
    </title>
</head>

<body>
    <form method = "post" action = "loginon.php">
        Username: <input type = "text" name = "username"/>
        <br/><br/>
        Password: <input type = "text" name = "password"/>
        <br/><br/>
        <input type = "submit" name = "submit" value = "Log In"/>
    </form>
</body>

<?php
    session_start();
    include "connect.php";
    $query = "select * from MK";
    $res = $conn->query($query)->fetchAll();
?>

<html>
    <body>
        <b>Daftar Mata Praktikum dan Jumlah Praktikan</b>
        <table border ="1" class="centered responsive-table highlight">
            <thead>
                <tr>
                    <th>KODE MK</th>
                    <th>NAMA MK</th>
                    <th>JUMLAH PRAKTIKAN</th>
                </tr>
            </thead>
            <tbody>
                <?php
                    foreach ((array)$res as $tabel) {
                ?>
                        <tr>
                        <td><?php echo $tabel['KODE_MK']?></td>
                        <td><?php echo $tabel['NAMA_MK']?></td>
                        <td><?php echo $tabel['JUMLAH_PRAKTIKAN']?></td>
                        </tr>
                    <?php
                }
                    ?>
            </tbody>
        </table>
    </body>
</html>

Kamis, 10 Maret 2016

Road to 10K Lines

     Menjadi seorang programmer website adalah bagaikan melewati suatu jalan berbatu dan berbahaya yang terjal sehingga sangat sulit dilalui. Maka dari itu diperlukan usaha extra keras bagi seorang calon developer agar bisa menjadi sesuatu yang diinginkan. Seperti pepatah dari Thomas Alfa Edison, “The three great essentials to achieve anything worthwhile are, first, hard work; second, stick-to-itiveness; third, common sense” dia mementingkan usaha dan kerja keras sebagai hal pertama yang diperlukan untuk mendapatkan segala hal yang kita inginkan.

          Maka dari itu regimen latihan yang kita butuhkan adalah code 10 ribu line menuju kesuksesan. Saya akan memulai hal ini dengan beberapa code yang simpel dan sederhana namun akan sangat berguna dipelajari untuk masa depan.

        Ini adalah salah satu contoh code sederhana yang saya buat untuk memperlihatkan salah satu langkah sederhana menjadi web programmer sejati:


Contoh Code 1

Output Code 1 di Web Browser

Code ini menampilkan kemampuan powerful dari php yaitu kehebatannya dalam menentukan tipe data yang dibutuhkan tanpa perlu spesifikasi secara langsung.

Selain penampilan biasa, php juga ternyata dapat menghandle kemampuan perhitungan seperti contohnya pada code berikut :



Contoh Code 2


Output Code 2 di Web Browser

Dari code diatas kita bisa melihat bahwa mulai dari line 13 hingga 16 terjadi operasi perhitungan dari 3 angka yang telah disediakan dan terbukti php mampu melakukan perhitungan tersebut.

Berikut adalah code yang saya kerjakan dengan coba-coba mencari cara di internet:


Contoh Code 3


Output Code 3 di Web Browser

Code 3 adalah code sederhana yang menampilkan contoh penambahan gambar ke halaman web yang akan kita desain nantinya :).

Sekian dari saya mengenai 10 ribu langkah, saya memulai dengan 68 langkah terlebih dahulu :) terima kasih.



Sabtu, 28 November 2015

Bantuan Kepada yang Membutuhkan Jilid-4(Akhir)

Kembali lagi kita berkutat ke materi yang kebetulan menarik namun penting. Kemarin kita mempelajari cara membuat game tebak-tebakan menarik menggunakan IPC pipe. Hari ini saya akan menunjukkan cara menghubungkan sebuah folder agar isi dari folder tersebut dapat ditampilkan ke folder lainnya dengan menggunakan FUSE.
Tetapi sebelum itu, seperti biasa kita perlu menyiapkan beberapa hal agar segala yang saya tulis di sini menjadi bermanfaat dan tidak disia-siakan.
-pertama siapkan sebuah komputer!
-kedua siapkan OS linux apa saja dan pastikan sudah terinstall di komputer anda!
-ketiga siapkan doa kepada tuhan agar apa yang saya jelaskan di sini berhasil diimplementasikan!
Kita mulai ya, ini nih langkah mudah teman-teman untuk membuat game tebak-tebakan sederhana.
Bag I Membuat Kodingan Utama:
1. buka gedit text editor.
2. Beri nama file new.c
3. Masukkan copy and paste tulisan di bawah ini:
#define FUSE_USE_VERSION 28
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef linux
/* For pread()/pwrite()/utimensat() */
#define _XOPEN_SOURCE 500
#endif
#include <fuse.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include <sys/time.h>
#ifdef HAVE_SETXATTR
#include <sys/xattr.h>
#include <dirent.h>
#endif

static const char *dirpath = "/home/mahope/Documents/Kuliah/Sisop/Modul4";
char cbackup[100]=".bak";
int numb=0;
char lastaccess[100],lastaccessbackup[100],accessbackup[100][100];
char lastunlink[100],lastunlinkbackup[100];
FILE *fin,*from,*to,*temp;
char buffer[BUFSIZ];
size_t sizetemp;

static int xmp_getattr(const char *path, struct stat *stbuf)
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = lstat(fpath, stbuf);
if (res == -1)
return -errno;
return 0;
}

static int xmp_access(const char *path, int mask)
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = access(fpath, mask);
if (res == -1)
return -errno;

strcpy(lastaccess,"NULL");
strcpy(lastaccessbackup,"NULL");
return 0;
}

static int xmp_readlink(const char *path, char *buf, size_t size)
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = readlink(fpath, buf, size - 1);
if (res == -1)
return -errno;
buf[res] = '\0';
return 0;
}

static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
DIR *dp;
struct dirent *de;
(void) offset;
(void) fi;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
dp = opendir(fpath);
if (dp == NULL)
return -errno;
while ((de = readdir(dp)) != NULL) {
struct stat st;
memset(&st, 0, sizeof(st));
st.st_ino = de->d_ino;
st.st_mode = de->d_type << 12;
if (filler(buf, de->d_name, &st, 0))
break;
}
closedir(dp);
return 0;
}

static int xmp_mknod(const char *path, mode_t mode, dev_t rdev)
{
int res;
/* On Linux this could just be ‘mknod(path, mode, rdev)’ but this
is more portable */
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
if (S_ISREG(mode)) {
res = open(fpath, O_CREAT | O_EXCL | O_WRONLY, mode);
if (res >= 0)
res = close(res);

else if (S_ISFIFO(mode))
res = mkfifo(fpath, mode);
else
res = mknod(fpath, mode, rdev);
if (res == -1)
return -errno;
//fprintf(fin,”mknod %s\n”,path);
//fflush(fin);
//fclose(fin);
return 0;
}

static int xmp_mkdir(const char *path, mode_t mode)
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = mkdir(fpath, mode);
if (res == -1)
return -errno;
return 0;
}

static int xmp_unlink(const char *path)
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = unlink(fpath);
if (res == -1)
return -errno;
strcpy(lastunlink,fpath);
strcpy(lastunlinkbackup,fpath);
strcat(lastunlinkbackup,cbackup);
xmp_unlink(lastunlinkbackup);

return 0;

}

static int xmp_rmdir(const char *path)
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = rmdir(fpath);
if (res == -1)
return -errno;
return 0;
}

static int xmp_symlink(const char *from, const char *to)
{
int res;
res = symlink(from, to);
if (res == -1)
return -errno;
return 0;
}

static int xmp_rename(const char *from, const char *to)
{
int res;
res = rename(from, to);
if (res == -1)
return -errno;

return 0;
}

static int xmp_link(const char *from, const char *to)
{
int res;
res = link(from, to);
if (res == -1)
return -errno;
return 0;
}

static int xmp_chmod(const char *path, mode_t mode)
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = chmod(fpath, mode);
if (res == -1)
return -errno;
return 0;
}

static int xmp_chown(const char *path, uid_t uid, gid_t gid)
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = lchown(fpath, uid, gid);
if (res == -1)
return -errno;
return 0;
}

static int xmp_truncate(const char *path, off_t size)
//Change the size of a file
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = truncate(fpath, size);
if (res == -1)
return -errno;
return 0;
}

#ifdef HAVE_UTIMENSAT
static int xmp_utimens(const char *path, const struct timespec ts[2])
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
/* don̢۪t use utime/utimes since they follow symlinks */
res = utimensat(0, fpath, ts, AT_SYMLINK_NOFOLLOW);
if (res == -1)
return -errno;
return 0;
}

#endif
static int xmp_open(const char *path, struct fuse_file_info *fi)
{
int res,len=strlen(lastaccess),num=0,flag=0;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);

strcpy(lastaccess,fpath);
strcpy(lastaccessbackup,fpath);
strcat(lastaccessbackup,cbackup);
/*//no2
while(num<numb){
if(strcmp(lastaccessbackup,accessbackup[num])==0)flag=1;
if(flag==1){
res = open(fpath, fi->flags);
if (res == -1)
return -errno;
close(res);
return 0;
break;
}
num++;
}
if(flag==0){
strcpy(accessbackup[numb],lastaccessbackup);
numb++;
}
len=strlen(lastaccess);
if ((len >= 2) && strcmp(&(lastaccess[len - 4]), ".bak") == 0){
char command[100];
        sprintf(command,"zenity --error --text='File yang anda buka adalah file backup. File tidak bisa diubah maupun disalin kembali'");
        system(command);
        return 1;
}

res = open(fpath, fi->flags);
if (res == -1)
return -errno;

int j=0, i=0, count=0;
int len2=strlen(path);
*/
//no1
int j=0, i=0, count=0, len2=strlen(path);
while(j<len2){
if(path[j]=='.') count=1;
if(count==1) break;
j++;
}

if(count==1&&flag==0)
while(i<=len){
if(lastaccess[i]=='.'){
if ((len >= 2) && strcmp(&(lastaccess[len - 4]), ".bak") != 0){
if(access(lastaccessbackup,F_OK)==0) remove(lastaccessbackup);

from=fopen(lastaccess,"rb");
to=fopen(lastaccessbackup,"wb");
char a;
while(1){
a=fgetc(from);
if(!feof(from))
fputc(a,to);
else break;
}


char command[100];
sprintf(command,"chmod 444 '%s'",lastaccessbackup);
system(command);
}
// fclose(from);
// fclose(to);
}
i++;
}

close(res);
return 0;
}

static int xmp_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
int fd;
int res;
(void) fi;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
fd = open(fpath, O_RDONLY);

if (fd == -1)
return -errno;
res = pread(fd, buf, size, offset);
if (res == -1)
res = -errno;

close(fd);
return res;
}

static int xmp_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
int fd;
int res;
(void) fi;

while((sizetemp = fread(buffer, 1, BUFSIZ, from)))
{
fwrite(buffer, 1, sizetemp, to);
}
fclose(from);
fclose(to);

char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
fd = open(fpath, O_WRONLY);
if (fd == -1)
return -errno;
res = pwrite(fd, buf, size, offset);
if (res == -1)
res = -errno;
close(fd);
return res;
}

static int xmp_statfs(const char *path, struct statvfs *stbuf)
//Get file system statistics
{
int res;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
res = statvfs(fpath, stbuf);
if (res == -1)
return -errno;
return 0;
}

static int xmp_release(const char *path, struct fuse_file_info *fi)
/*Release an open file
Release is called when there are no more references to an open file: 
all file descriptors are closed and all memory mappings are unmapped.*/
{
/* Just a stub.  This method is optional and can safely be left
unimplemented */
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
(void) fpath;
(void) fi;
return 0;
}

static int xmp_fsync(const char *path, int isdatasync,
//Synchronize file contents
struct fuse_file_info *fi)
{
/* Just a stub.  This method is optional and can safely be left
unimplemented */
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
(void) fpath;
(void) isdatasync;
(void) fi;
return 0;
}

#ifdef HAVE_POSIX_FALLOCATE
static int xmp_fallocate(const char *path, int mode,
off_t offset, off_t length, struct fuse_file_info *fi)
//Allocates space for an open file
{
int fd;
int res;
(void) fi;
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
if (mode)
return -EOPNOTSUPP;
fd = open(fpath, O_WRONLY);
if (fd == -1)
return -errno;
res = -posix_fallocate(fd, offset, length);
close(fd);
return res;
}

#endif
#ifdef HAVE_SETXATTR
/* xattr operations are optional and can safely be left unimplemented */
static int xmp_setxattr(const char *path, const char *name, const char *value,
size_t size, int flags)
//Set extended attributes 
{
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
int res = lsetxattr(fpath, name, value, size, flags);
if (res == -1)
return -errno;
return 0;
}

static int xmp_getxattr(const char *path, const char *name, char *value,
size_t size)
//Get extended attributes
{
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
int res = lgetxattr(fpath, name, value, size);
if (res == -1)
return -errno;
return res;
}

static int xmp_listxattr(const char *path, char *list, size_t size)
//List extended attributes
{
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
int res = llistxattr(fpath, list, size);
if (res == -1)
return -errno;
return res;
}

static int xmp_removexattr(const char *path, const char *name)
{
char fpath[1000];
sprintf(fpath,"%s%s",dirpath,path);
int res = lremovexattr(fpath, name);
if (res == -1)
return -errno;
return 0;
}


#endif /* HAVE_SETXATTR */

static struct fuse_operations xmp_oper = {
.getattr        = xmp_getattr,
.access         = xmp_access,
.readlink       = xmp_readlink,
.readdir        = xmp_readdir,
.mknod          = xmp_mknod,
.mkdir          = xmp_mkdir,
.symlink        = xmp_symlink,
.unlink         = xmp_unlink,
.rmdir          = xmp_rmdir,
.rename         = xmp_rename,
.link           = xmp_link,
.chmod          = xmp_chmod,
.chown          = xmp_chown,
.truncate       = xmp_truncate,
#ifdef HAVE_UTIMENSAT
.utimens        = xmp_utimens,
#endif
.open           = xmp_open,
.read           = xmp_read,
.write          = xmp_write,
.statfs         = xmp_statfs,
.release        = xmp_release,
.fsync          = xmp_fsync,
#ifdef HAVE_POSIX_FALLOCATE
.fallocate      = xmp_fallocate,
#endif
#ifdef HAVE_SETXATTR
.setxattr       = xmp_setxattr,
.getxattr       = xmp_getxattr,
.listxattr      = xmp_listxattr,
.removexattr    = xmp_removexattr,
#endif
};

int main(int argc, char *argv[])
{
umask(0);
return fuse_main(argc, argv, &xmp_oper, NULL);

}
Menjalankan Program:
1. Buka bagian terminal pada os linux anda. Dengan cara pada tombol home ketik "terminal" tanpa tanda baca.
2. Ketik gcc -Wall new.c `pkg-config fuse --cflags --libs` -o new.
3. Kemudian ketik ./new /tmp/fuse.

Saya akan menjelaskan apa yang akan dilakukan oleh program ini:
-program ini akan mengakibatkan ketika kita membuka folder fuse, kita akan langsiung di direct ke folder modul4
-setiap file (contoh:apa.c) yang di buka pada folder modul4 akan memunculkan file bernama sama namun memiliki tambahan akhiran .bak (contoh:apa.c.bak)
-file .bak ini tidak bisa dibuka, dan bila dipaksakan di buka makan akan muncul pesan error.

Selamat Bermain!!!