Showing posts with label Pemrograman 3D. Show all posts
Showing posts with label Pemrograman 3D. Show all posts

TUGAS CODE IGNITER UPLOAD FILE

Kali ini kami disuruh mencoba membuat sebuah form upload file dengan memanfaatkan user guide yang sudah terintegrasi di Code Igniter....

Berikut hasil dari Tugas yang saya kerjakan

Tampilan awalnya seperti ini
Tampilan jika button upload di klik tanpa choose file
Ketika di klik tombol Choose File


Ketika di Upload.....


File yang diperlukan:
upload__form.php (di folder views)
upload_sukses.php (di folder views)
upload (di folder controller)

Upload.php

<?php

class Upload extends CI_Controller {

function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}

function index()
{
$this->load->view('upload_form', array('error' => ' ' ));
}

function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|zip|doc|docs|xls|ppt|pdf|txt';
$config['max_size'] = '1000';


$this->load->library('upload', $config);

if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors('<p>','<br/>Silahkan ulang...!!!', '</p>'));

$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());

$this->load->view('upload_sukses', $data);
}
}
}
?>


upload_form.php

<html>
<head>
<title>Upload Form</title>
</head>

<body bgcolor="#4bc402">

<?php echo $error;?>

<?php echo form_open_multipart('upload/do_upload');?>

<input type="file" name="userfile" size="20" />

<br /><br />

<input type="submit" value="upload" />

</form>

</body>
</html>

upload_sukses.php

<html>
<head>
<title>Upload Form</title>
</head>

<body bgcolor="#4bc402">

<?php echo $error;?>

<?php echo form_open_multipart('upload/do_upload');?>

<input type="file" name="userfile" size="20" />

<br /><br />

<input type="submit" value="upload" />

</form>

</body>
</html>

CODE IGNITER LEVEL 3

Assalamualaiu...
Malem nie gak tidur kayaknya...
banyak sekali tugas yang belum selesai....

S E M A N G A D.....
Mengapa judul artikel saya ini CODE IGNITER LEVEL 3...?!
itu karena ini adalah ke tiga kalinya saya belajar Code Igniter,,,

Kali ini saya akan share lanjutan artikel kemarin yang untuk menampilkan data dari database ke Code Igniter....
disini saya tambahkan sedikit bumbu CSS..hehehe

Meskipun masih ada yang kurang,,, Tombol Delete-nya belum berfungsi....hehehe

langsung sajalah....

Tampilannya seperti ini:



Dan untuk form input beritanya seperti ini:

Okeh...
Untuk struktur databasenya bisa di baca di artikel sebelumnya karena disini saya hanya fokuskan untuk input datanya aja....

Buat file view_news_input.php di Application/view/news/ :

<html>
<head>
<title>My Form</title>
</head>
<body bgcolor="#999900">

<?php echo form_open('news/input'); ?>

<h5>INPUT BERITA</h5><br/>

<h5>Title</h5>
<?php echo form_error('title'); ?>
<input type="text" name="title" value="<?php echo set_value('title'); ?>" size="50" />

<h5>Content</h5>
<?php echo form_error('content'); ?>
<textarea name="content" cols="50"><?php echo set_value('content'); ?></textarea>

<div><input type="submit" value="Submit" /></div>

</form>

</body>
</html>

Selanjutnya buat file dengan nama view_sukses.php di Application/view/news/

<html>
<head>
<title>My Form</title>
</head>
<body>

<h3>Your form was successfully submitted!</h3>

<p><?php echo anchor('news/input', 'Try it again!'); ?></p>

</body>
</html>

Buat file modelnews.php di Application/models/

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class ModelNews extends CI_Model {

function __construct()
{
parent::__construct();
}

function getAllNews(){
$q="SELECT * FROM news";
return $this->db->query($q);
}
function delete(){
$q="DELETE from news where id='$id'";
return $this->db->query($q);
}
}

Buat file dengan nama news.php di Application/controller/

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News extends CI_Controller {


public function index()
{
$data = array('title' => 'WEBSITE CODE IGNITER',
'heading' => 'Copyright &copy 2012. Powered by <i>Indra Al Sasak</i>',
'message' => 'Test Message');

$this->load->view('view_header');
$this->load->view('view_news_show', $data);
$this->load->view('view_footer');;
}

public function show()
{
$data['n'] = $this->ModelNews->getAllNews();
$this->load->view('news/view_show_page', $data);
}
public function input()
{
$this->load->helper(array('form', 'url'));

$this->load->library('form_validation');
$this->form_validation->set_rules('title', 'title', 'required');
$this->form_validation->set_rules('content', 'content', 'required');

if ($this->form_validation->run() == FALSE)
{
$this->load->view('news/view_news_input');
}
else
{
$this->input->post('title');
$this->input->post('content');
$this->ModelNews->simpan();
$this->load->view('news/view_sukses');
}

}
public function delete($id)
{
$this->db->delete('news', array('id' => $id));
redirect('news/index');
$this->ModelNews->deleteByid($id);
}
public function simpan()
{
echo "tersimpan";
}
}

Semoga Bermanfaat.....

Menampilkan Data Base di Code Igniter

Selanjutnya adalah cara untuk menampilkan data yang berada di database ke Code Igniter,,,

Pertama-tama kita buat database disini saya kasi nama "d4b6",,, selanjutnya buat tabel dengan struktur sebagai berikut:



Selanjutnya, buat ModelNews

<?php if ( !
defined('BASEPATH')) exit('No direct script access allowed');
class ModelNews extends CI_Model {
 function __construct()
  {

 parent::__construct();
  }

  function
getAllNews(){
  $q="SELECT
* FROM news";
  return
$this->db->query($q);
  }
}


Jangan lupa untuk mengganti settingan di autoload,,,
Location: ./application/config/autoload.php
$autoload['model'] = array('ModelNews');
Selanjutnya Controller News
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News extends CI_Controller {

public function show(){
$data['n'] = $this->ModelNews->getAllNews();
$this->load->view('news/view_show_page', $data);
}
}

Sekarang anda tinggal membuat 1 file lage,,,
application/view/news/view_show_page.php:

<? 
print_r($n);
$sr = $n->result();
?>

<p>List News</p>

<? foreach($sr as $r){ ?>
<?=$r->id?> <br />
<?=$r->title?> <br />
<?=$r->content?> <br />
<?=$r->create?> <br /><br />
<? } ?>


Hasil akhirnya adalah Sebagai berikut:


Selamat mencoba.... ^_^


Memanipulasi Tampilan Awal Code Igniter

Buka folder view di Code Igniter, karena semua yang di tampilkan di Code Igniter adalah dari folder view ini, selanjutnya silahkan anda buka "welcome_message.php"...
Lakukan perubahan source sesuka anda, sesuai dengan selera yang anda inginkan...

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>

<style type="text/css">

::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }

body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}

a {
color: #003399;
background-color: transparent;
font-weight: normal;
}

h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}

code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}

#body{
margin: 0 15px 0 15px;
}

p.footer{
text-align: right;
font-size: 11px;
border-top: 1px solid #D0D0D0;
line-height: 32px;
padding: 0 10px 0 10px;
margin: 20px 0 0 0;
}

#container{
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
</style>
</head>
<body>

<div id="container">
<h1>Welcome to CodeIgniter!</h1>

<div id="body">
<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>

<p>If you would like to edit this page you'll find it located at:</p>
<code>application/views/welcome_message.php</code>

<p>The corresponding controller for this page is found at:</p>
<code>application/controllers/welcome.php</code>

<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
</div>

<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>

</body>
</html>

Hasilnya:






INSTAL CODE IGNITER

Alhamdulillah,,,
Aku bisa posting tulisan di blogku lagi....Di karenakan banyak tugas, tulisanku di blog menjadi terhambat....
Kemarin aku belajar cara menginstal Code Igniter dan Mensettinnya sehingga berhubungan dengan database.

Pertama-tama instal Code Igniter,,kemudian copykan foldernya ke dalam folder htdocs...


Selanjutnya masuk ke folder dan buka config.php => CodeIgniter--> Application-->Config-->config.php


<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'http://localhost/d4b6/';

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';

/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of 'AUTO' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'AUTO';

/*
|--------------------------------------------------------------------------
| URL suffix
|--------------------------------------------------------------------------
|
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
| For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/urls.html
*/

$config['url_suffix'] = '';

/*
|--------------------------------------------------------------------------
| Default Language
|--------------------------------------------------------------------------
|
| This determines which set of language files should be used. Make sure
| there is an available translation if you intend to use something other
| than english.
|
*/
$config['language'] = 'english';

/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
*/
$config['charset'] = 'UTF-8';

/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
|
| If you would like to use the 'hooks' feature you must enable it by
| setting this variable to TRUE (boolean). See the user guide for details.
|
*/
$config['enable_hooks'] = FALSE;


/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
|
| This item allows you to set the filename/classname prefix when extending
| native libraries. For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/core_classes.html
| http://codeigniter.com/user_guide/general/creating_libraries.html
|
*/
$config['subclass_prefix'] = 'MY_';


/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
|
| This lets you specify with a regular expression which characters are permitted
| within your URLs. When someone tries to submit a URL with disallowed
| characters they will get a warning message.
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
| as few characters as possible. By default only these are allowed: a-z 0-9~%.:_-
|
| Leave blank to allow all characters -- but only if you are insane.
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';


/*
|--------------------------------------------------------------------------
| Enable Query Strings
|--------------------------------------------------------------------------
|
| By default CodeIgniter uses search-engine friendly segment based URLs:
| example.com/who/what/where/
|
| By default CodeIgniter enables access to the $_GET array. If for some
| reason you would like to disable it, set 'allow_get_array' to FALSE.
|
| You can optionally enable standard query string based URLs:
| example.com?who=me&what=something&where=here
|
| Options are: TRUE or FALSE (boolean)
|
| The other items let you set the query string 'words' that will
| invoke your controllers and its functions:
| example.com/index.php?c=controller&m=function
|
| Please note that some of the helpers won't work as expected when
| this feature is enabled, since CodeIgniter is designed primarily to
| use segment based URLs.
|
*/
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd'; // experimental not currently in use

/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 0;

/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/logs/ folder. Use a full server path with trailing slash.
|
*/
$config['log_path'] = '';

/*
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
$config['log_date_format'] = 'Y-m-d H:i:s';

/*
|--------------------------------------------------------------------------
| Cache Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| system/cache/ folder. Use a full server path with trailing slash.
|
*/
$config['cache_path'] = '';

/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| If you use the Encryption class or the Session class you
| MUST set an encryption key. See the user guide for info.
|
*/
$config['encryption_key'] = 'amikom2012';

/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'sess_cookie_name' = the name you want for the cookie
| 'sess_expiration' = the number of SECONDS you want the session to last.
| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
| 'sess_expire_on_close' = Whether to cause the session to expire automatically
| when the browser window is closed
| 'sess_encrypt_cookie' = Whether to encrypt the cookie
| 'sess_use_database' = Whether to save the session data to a database
| 'sess_table_name' = The name of the session database table
| 'sess_match_ip' = Whether to match the user's IP address when reading the session data
| 'sess_match_useragent' = Whether to match the User Agent when reading the session data
| 'sess_time_to_update' = how many seconds between CI refreshing Session Information
|
*/
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path' = Typically will be a forward slash
| 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists.
|
*/
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
$config['cookie_secure'] = FALSE;

/*
|--------------------------------------------------------------------------
| Global XSS Filtering
|--------------------------------------------------------------------------
|
| Determines whether the XSS filter is always active when GET, POST or
| COOKIE data is encountered
|
*/
$config['global_xss_filtering'] = FALSE;

/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| 'csrf_token_name' = The token name
| 'csrf_cookie_name' = The cookie name
| 'csrf_expire' = The number in seconds the token should expire.
*/
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;

/*
|--------------------------------------------------------------------------
| Output Compression
|--------------------------------------------------------------------------
|
| Enables Gzip output compression for faster page loads. When enabled,
| the output class will test whether your server supports Gzip.
| Even if it does, however, not all browsers support compression
| so enable only if you are reasonably sure your visitors can handle it.
|
| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
| means you are prematurely outputting something to your browser. It could
| even be a line of whitespace at the end of one of your scripts. For
| compression to work, nothing can be sent before the output buffer is called
| by the output class. Do not 'echo' any values with compression enabled.
|
*/
$config['compress_output'] = FALSE;

/*
|--------------------------------------------------------------------------
| Master Time Reference
|--------------------------------------------------------------------------
|
| Options are 'local' or 'gmt'. This pref tells the system whether to use
| your server's local time as the master 'now' reference, or convert it to
| GMT. See the 'date helper' page of the user guide for information
| regarding date handling.
|
*/
$config['time_reference'] = 'local';


/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files. Options are TRUE or FALSE (boolean)
|
*/
$config['rewrite_short_tags'] = FALSE;


/*
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
|
| If your server is behind a reverse proxy, you must whitelist the proxy IP
| addresses from which CodeIgniter should trust the HTTP_X_FORWARDED_FOR
| header in order to properly identify the visitor's IP address.
| Comma-delimited, e.g. '10.0.1.200,10.0.1.201'
|
*/
$config['proxy_ips'] = '';


/* End of file config.php */
/* Location: ./application/config/config.php */


Selanjutny buka database.php yang juga berada di folder config, lakukan settingan sebagai berikut:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database type. ie: mysql. Currently supported:
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Active Record class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['autoinit'] Whether or not to automatically initialize the database.
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
|
| The $active_group variable lets you choose which connection group to
| make active. By default there is only one group (the 'default' group).
|
| The $active_record variables lets you determine whether or not to load
| the active record class
*/

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'd4b6';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;


/* End of file database.php */
/* Location: ./application/config/database.php */

Maka hasilnya akan menjadi seperti ini....



***Selamat Mencoba***

TUGAS 3 LATIHAN DASAR-DASAR PEMROGRAMAN WEB

Berikut adalah beberapa contoh script yang saya pilih dari tugas 3 saya tentang dasar pemrograman web, soalnya bayangin ja, sekitar 81 halaman yang harus kami coba dan buat screnshotnya...Jadi tidak bisa saya tampilkan semuanya disini, insyaallah akan saya tampilkan link downloadnya secepatmungkin...

Berikut Source Code Latihan Pemrograman Web saya:

<html>
<head>
<title>TUGAS PEMROGRAMAN 3D</title>
</head>
<body>

<h1>ITB BATCH 6</h1>
<h2>ITB BATCH 5</h2>
<h3>ITB BATCH 4</h3>
<h4>ITB BATCH 3</h4>
<h5>ITB BATCH 2</h5>
<h6>ITB BATCH 1</h6>

</body>
<div><center><b>Created by &copy Muhammad Lutfi Indrawan</b></center></div>
</html>


Source Code tersebut akan menghasilkan :

<html>
<head>
<title>TUGAS PEMROGRAMAN 3D</title>
</head>
<body>

<p>Paragraf 1 ITB BATCH 6</p>
<p>Paragraf 2 ITB BATCH 6</p>

</body>
<div><center><b>Created by &copy Muhammad Lutfi Indrawan</b></center></div>
</html>
<html>
<title>TUGAS PEMROGRAMAN 3D</title>
<head>
<style type="text/css">
thead{color:green}
tbody{color:blue}
tfoot{color:red}
</style>
</head>

<body>
<h4> Tabel satu kolom</h4>
<table border="1">
<tfoot>
<tr>
<td> ITB BATCH 6 </td>
</tr>
</tfoot>
</table>

<h4> Tabel Dua Baris dan Dua Kolom </h4>
<table border="4">
<caption>Tugas PEMROGRAMAN 3D</caption>
<thead>
<tr>
<th bgcolor="00ff00"> Nama Kolom 1 </th>
<th bgcolor="0000ff">Nama Kolom 2 </th>
</tr>
</thead>
<tbody>
<tr bgcolor="ff0000">
<td> ITB BATCH 6 baris 1, urutan ke-1</td>
<td> ITB BATCH 6 baris 1, urutan ke-2</td>
</tr>
</tbody>
<tfoot>
<tr>
<td> ITB BATCH 6 baris 2, urutan ke-1</td>
<td> ITB BATCH 6 baris 2, urutan ke-2</td>
</tr>
<tfoot>
</table>

</body>
<p></p>
<div><center><b>Created by &copy Muhammad Lutfi Indrawan</b></center></div>
</html>









TUGAS 1 PENGERTIAN PHP DAN CODEIGNITER

TENTANG PHP (HYPERTEXT PREPROCESSOR)

PHP (Hypertext Preprocessor) merupaka bahasa pemrograman yang dapat ditanamkan atau disisipkan ke dalam HTML. PHP dapat digunakan untuk membuat website dinamis selain itu kita juga dapat membuat CMS (Content Management System) dengan menggunakan bahasa pemrograman PHP.

Sejarah PHP (Hypertext Preprocessor)

Pada awalnya PHP merupakan kependekan dari Personal Home Page (Situs personal). PHP pertama kali dibuat oleh Rasmus Lerdorf pada tahun 1995. Pada waktu itu PHP masih bernama Form Interpreted (FI), yang wujudnya berupa sekumpulan skrip yang digunakan untuk mengolah data formulir dari web.

Selanjutnya Rasmus merilis kode sumber tersebut untuk umum dan menamakannya PHP/FI. Dengan perilisan kode sumber ini menjadi sumber terbuka, maka banyak pemrogram yang tertarik untuk ikut mengembangkan PHP.

Pada November 1997, dirilis PHP/FI 2.0. Pada rilis ini, interpreter PHP sudah diimplementasikan dalam program C. Dalam rilis ini disertakan juga modul-modul ekstensi yang meningkatkan kemampuan PHP/FI secara signifikan.

Pada tahun 1997, sebuah perusahaan bernama Zend menulis ulang interpreter PHP menjadi lebih bersih, lebih baik, dan lebih cepat. Kemudian pada Juni 1998, perusahaan tersebut merilis interpreter baru untuk PHP dan meresmikan rilis tersebut sebagai PHP 3.0 dan singkatan PHP diubah menjadi akronim berulang PHP: Hypertext Preprocessing.

Pada pertengahan tahun 1999, Zend merilis interpreter PHP baru dan rilis tersebut dikenal dengan PHP 4.0. PHP 4.0 adalah versi PHP yang paling banyak dipakai pada awal abad ke-21. Versi ini banyak dipakai disebabkan kemampuannya untuk membangun aplikasi web kompleks tetapi tetap memiliki kecepatan dan stabilitas yang tinggi.

Pada Juni 2004, Zend merilis PHP 5.0. Dalam versi ini, inti dari interpreter PHP mengalami perubahan besar. Versi ini juga memasukkan model pemrograman berorientasi objek ke dalam PHP untuk menjawab perkembangan bahasa pemrograman ke arah paradigma berorientasi objek.

Contoh program penggunaan PHP:



Program Hello World
Program Hello World yang ditulis menggunakan PHP adalah sebagai berikut:
<?php
echo"Hello World";
?>

Program bilangan Fibonacci

Berikut ini adalah contoh program yang relatif lebih kompleks yang ditulis dengan menggunakan PHP. Contoh program ini adalah program untuk menampilkan 20 bilangan pertama dari deret bilangan Fibonacci.

<?php 

function fibonacci_seq( $panjang ) {

for( $l = array(0,1), $i = 2, $x = 0; $i < $panjang; $i++ )

$l[] = $l[$x++] + $l[$x];

return $l;

}

fibonacci_seq(20);

// Angka "20" dapat diganti sesuai keinginan

?>



Kelebihan PHP Dari Bahasa Pemrograman Lain

Beberapa kelebihan PHP dari bahasa pemrograman web, antara lain:
'Bahasa pemrograman PHP adalah sebuah bahasa script yang tidak melakukan sebuah kompilasi dalam penggunaanya.

Web Server yang mendukung PHP dapat ditemukan dimana - mana dari mulai apache, IIS, Lighttpd, hingga Xitami dengan konfigurasi yang relatif mudah.'

Dalam sisi pengembangan lebih mudah, karena banyaknya milis - milis dan developer yang siap membantu dalam pengembangan.

Dalam sisi pemahamanan, PHP adalah bahasa scripting yang paling mudah karena memiliki referensi yang banyak. PHP adalah bahasa open source yang dapat digunakan di berbagai mesin (Linux, Unix, Macintosh, Windows) dan dapat dijalankan secara runtime melalui console serta juga dapat menjalankan perintah-perintah system.


Tipe data

PHP memiliki 8 (delapan) tipe data yaitu :
  1. Integer 
  2. Double 
  3. Boolean 
  4. String 
  5. Object 
  6. Array 
  7. Null 
  8. Nill 
  9. Resource
TENTANG CI (CODE IGNITER)


Code Igniter adalah PHP Frame Work yang dapat memudahkan anda dalam pembuatan website. Scripting akan menjadi lebih mudah, file website anda akan lebih terorganisir, lebih aman dan lebih mudah melakukan update atau perubahan website. Codeigniter merupakan salah satu framework php yang mudah dipelajari dan digunakan sehingga sangat wajar menjadi salah satu framework paling populer diantara framework php yang lain. Katakanlah, untuk orang yang ingin membangun website dengan menggunakan PHP. Dengan menggunakan arsitektur model-view-controller yang memisahkan antara bagian logic dan tampilan dari program, CI cukup “menyenangkan” untuk digunakan.Jika melihat tahun pengembangan website populer seperti kompas.com, maka sangat wajar pemilihan codeigniter sebagai framework karena pada saat itu framework yang umumnya menjadi pilihan adalah Zend Framework, Cakephp, Symfony, Codeigniter.

TUGAS 2 TENTANG HTACCESS

Pengertian File .htaccess

File .htaccess adalah file konfigurasi yang disediakan oleh web server Apache, yang biasanya digunakan untuk mengubah settingan default dari Apache. Kita ketahui bahwa sebagian besar hosting web di internet menggunakan Apache sebagai servernya sehingga bagi para pengelola web / webmaster sedikit banyak harus belajar tentang .htaccess agar kita bisa mengubah settingan default dari server.

File .htaccess merupakan file teks ASCII sederhana yang biasanya diletakkan dalam root direktori. File ini diharuskan dalam format ASCII dan bukan binary dan untuk file permission (atribut file) pada server hosting harus di set 644 (rw-r-r). Hal tersebut dimaksudkan agar server dapat mengakses file .htaccess, tapi mencegah user untuk mengakses file .htaccess dari browser mereka. File .htaccess yang diletakkan dalam root direktori dapat digunakan untuk mengubah konfigurasi dari subdirektori-subdirektori yang ada didalamnya, sehingga dalam satu website biasanya kita cukup untuk mempunyai 1 file .htaccess saja yang diletakkan dalam root direktori.

Kode perintah dalam file .htaccess harus ditempatkan dalam satu baris, jadi apabila kita membuat file .htaccess dengan menggunakan text editor seperti notepad maka kita harus mendisable fungsi word wrap (memotong baris) terlebih dahulu.

Kegunaan File .Htaccess

sebagai :
Customize Error Message
****
artinya kita dapat mengubah halaman error pada server, dengan mendefinisikan sesuai dengan keinginan kita sendiri.
*****
ErrorDocument 500 /error.html

Override SSI Settings

Secara default, hanya halaman web yang mempunyai extensi .shtml yang bisa menjalankan server-side termasuk SSI di server. Dengan menggunakan .htaccess kita dapat mengubah setting default tersebut agar SSI bisa bekerja dengan format HTML.

Untuk mengubah settingan tersebut, kita dapat menambahkan kode berikut di file .htaccess

AddType text/html .html
AddHandler server-parsed .html

Jika kita menginginkan halaman yang berekstensi .html dan .htm untuk dapat menjalankan SSI, maka file .htaccess dapat ditambahkan kode berikut :

AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm

Change Default Home Page

artinya bahwa file .htaccess dapat digunakan untuk mengubah nama default halaman depan web. Agar user bisa mengakses website kita hanya dengan nama domain saja (http://www.nama_web.com) tanpa harus menulis nama file secara jelas (http:www.nama_web.com/file.html), kita harus mempunyai file index di root direktori. Nama file yang bisa diterima antara lain index.html, index.htm, index.cgi, index.php dll. Pastikan bahwa file tsb bernama index.*

Ada tingkatan dalam pemberian nama tersebut. Jika kita punya index.cgi & index.html di root direktori maka server akan menampilkan index.cgi karena .cgi memiliki tingkatan yang lebih tinggi daripada .html

Dengan .htaccess, kita bisa mendefinisikan file index tambahan atau bisa juga mengubah urutan tingkatannya. Untuk mendefinisikan halamandepan.html sebagai halaman index, kita dapat menambahkan kode berikut ke file .htaccess

DirectoryIndex halamandepan.html

Hal ini akan membuat server mencari file bernama halamandepan.html. Jika server menemukannya maka server akan menampilkannya. Tapi bila tidak, maka server akan menampilkan error 404 Missing Page

Untuk mengubah urutan tingkatan, kita dapat memasukkan perintah DirectoryIndex dengan nama-nama file dalam satu baris. Urutan penulisan file tersebut menentukan urutan tingkatan, contohnya:

DirectoryIndex halamandepan.html index.cgi index.php index.html

Enable Directory Browsing

Untuk alasan keamanan, server Apache biasanya telah menghilangkan default setting yang memungkinkan directory indexing. Opsi inilah yang memungkinkan isi dari direktori untuk ditampilkan di browser jika direktori tersebut tidak mempunyai halaman index.

Contohnya, jika kita memasukkan sebuah UR yang tidak mempunyai halaman index seperti misalnya http://websitemu.com/images/, maka browser akan menampilkan daftar images di dalam direktori tersebut.

Block Users from Accessing Your Web Site

Jika kita menginginkan mem-blok access untuk beberapa user, dimana kita mengetahui IP / domainname yang digunakannya, kita dapat menambahkan kode berikut :

order deny,allow
deny from 123.456.789.000
deny from 456.78.90.
deny from .wwdq.com
allow from all

Pada contoh di atas, user dg IP 123.456.789.000 akan diblok. Semua user antara 456.78.90.000 sampai 456.78.90.999 akan diblok. Dan semua user yang berasal dari WWDQ.com akan diblok. Jika mereka mencoba mengakses website kita, maka akan tampil error 403 Forbidden (”You do not have permission to access this site”).

Redirect Visitors to a New Page or Directory

Misalkan kita membuat ulang seluruh website kita, me-rename halaman & direktori. Maka pengunjung halaman lama akan mendapat error 404 File Not Found. Masalah tersebut dapat diatasi dengan melakukan redirect dari halaman lama ke halaman yang baru. Contohnya bila halaman lama kita adalah oldpage.html dan halaman baru adalah newpage.html maka perintahnya adalah:

Redirect permanent /oldpage.html http://www.mydomain.com/newpage.html

Jika kita me-rename (mengganti nama) direktori, maka perintahnya adalah:

Redirect permanent /olddirectory http://www.mydomain.com/newdirectory/

Perhatikan bahwa nama direktori yang lama ditulis dengan relative path, sementara yang baru ditulis dengan URL absolut.

Prevent Hot Linking and Bandwidth Leeching

Untuk mencegah orang lain me-link secara langsung ke direktori image anda dari website mereka, biasanya ada orang mengambil gambar dari website kita, tapi tetap menggunakan link diserver host kita, ini tentu akan merugikan bagi kita karena dapat mengurangi bandwith di hosting kita, untuk mengatasi hal ini kita dapat menambahkan kode berikut:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?namadomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

Perintah tersebut akan membuat direktori image hanya bisa diakses bila user sedang mengakses www.namadomain.com

Jika kita merasa jengkel, kita bisa membuat sebuah image alternatif bila direktori image di-link oleh orang lain. Contohnya kita membuat image alternatif dengan nama nogambar.gif yang bertuliskan: “Gambar dr web lain … kunjungi http://namadomain.com untuk melihat gambar sebenarnya.” Maka kita dapat menambahkan kode berikut:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/dontsteal.gif [R,L]

Prevent viewing of .htaccess or other files

Untuk mencegah user mengakses file .htaccess, ketikkan perintah:

order allow,deny
deny from all

Bila anda ingin lebih mudah mendapatkan syntax .htaccess, silakan ke situs htaccess generator

Terima kasih sudah berkenan berkunjung di Blog kami ini.....
Setelah membaca semua ulasan diatas, apakah anda sudah mengerti tentang File .htaccess?!
Good Luck...!!!

Kategori

Kategori