Minggu, 01 Oktober 2023

Bahasa Arab Tentan Aktivitas Harian

أَعْمَالِيْ اليَّوْمِيَّةِ
(My Activity)

Rabu, 02 April 2014

how to create a simple login function

how to create a simple login function

I'm designing database for Yii web application and I'm not sure I'm doing it right way.

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(100) NOT NULL AUTO_INCREMENT,
  `username` varchar(100) NOT NULL,
  `password` varchar(100) NOT NULL,
  `level` int(11) NOT NULL,
  PRIMARY KEY (`id`)

) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

and INSERT INTO table users, Example:
INSERT INTO users (username , password, level) VALUES ('sam',md5('sam'),1);
INSERT INTO users (username , password, level) VALUES ('jan',md5('jan'),2);
INSERT INTO users (username , password, level) VALUES ('bud',md5('bud'),2);
You should be taken to the login screen, where you just enter the Gii password (established in the configuration file), and click Enter. Assuming you entered the correct password, you’ll see a splash page and a list of options (as links).


  1. Enter users as the Table Name.
  1. Enter User  as the Model Class. You’ll notice that the form automatically copies the table name as the Model name.
  2. Click Preview. You’ll see a table appear at the bottom of the form, indicating the files to be generated (just one in this case).
  3. Click Generate.



open the model in user.php  and add the script like this:
//valadation
protected function afterValidate() {
     parent::afterValidate();
            
     //melakukan enkripsi pada passwod yang di input
     $this->password = $this->encrypt($this->password);
}
        
//encrypt
public function encrypt($value){
     return md5($value);
}


/**
 * UserIdentity represents the data needed to identity a user.
 * It contains the authentication method that checks if the provided
 * data can identity the user.
 */
class UserIdentity extends CUserIdentity
{
    private $_id;
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
                $model = new User;
  $user= $model->findByAttributes(array('username'=>$this->username));
                if($user===null){
                    $this->errorCode=self::ERROR_USERNAME_INVALID;
                }else{
                    if($user->password !== $user->encrypt($this->password)){
                        $this->errorCode=self::ERROR_PASSWORD_INVALID;
                    }else{
                        $this->_id = $user->id;
                        $this->errorCode=self::ERROR_NONE;
                    }
                }
  return !$this->errorCode;
 }
        
        public function getId() {
            return $this->_id;
        }
}

Finally, Test:
open your browser, example : http://localhost/cobaweb/index.php?r=site/login/

Finish, congratulations

how to create a simple login function

I'm designing database for Yii web application and I'm not sure I'm doing it right way.

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(100) NOT NULL AUTO_INCREMENT,
  `username` varchar(100) NOT NULL,
  `password` varchar(100) NOT NULL,
  `level` int(11) NOT NULL,
  PRIMARY KEY (`id`)

) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

and INSERT INTO table users, Example:
INSERT INTO users (username , password, level) VALUES ('sam',md5('sam'),1);
INSERT INTO users (username , password, level) VALUES ('jan',md5('jan'),2);
INSERT INTO users (username , password, level) VALUES ('bud',md5('bud'),2);
You should be taken to the login screen, where you just enter the Gii password (established in the configuration file), and click Enter. Assuming you entered the correct password, you’ll see a splash page and a list of options (as links).


  1. Enter users as the Table Name.
  1. Enter User  as the Model Class. You’ll notice that the form automatically copies the table name as the Model name.
  2. Click Preview. You’ll see a table appear at the bottom of the form, indicating the files to be generated (just one in this case).
  3. Click Generate.



open the model in user.php  and add the script like this:
//valadation
protected function afterValidate() {
     parent::afterValidate();
            
     //melakukan enkripsi pada passwod yang di input
     $this->password = $this->encrypt($this->password);
}
        
//encrypt
public function encrypt($value){
     return md5($value);
}


/**
 * UserIdentity represents the data needed to identity a user.
 * It contains the authentication method that checks if the provided
 * data can identity the user.
 */
class UserIdentity extends CUserIdentity
{
    private $_id;
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
                $model = new User;
  $user= $model->findByAttributes(array('username'=>$this->username));
                if($user===null){
                    $this->errorCode=self::ERROR_USERNAME_INVALID;
                }else{
                    if($user->password !== $user->encrypt($this->password)){
                        $this->errorCode=self::ERROR_PASSWORD_INVALID;
                    }else{
                        $this->_id = $user->id;
                        $this->errorCode=self::ERROR_NONE;
                    }
                }
  return !$this->errorCode;
 }
        
        public function getId() {
            return $this->_id;
        }
}

Finally, Test:
open your browser, example : http://localhost/cobaweb/index.php?r=site/login/

Finish, congratulations

Senin, 17 September 2012

Widget Gratis Untuk Menampilkan Statistik Blog, Jumlah Pengunjung dan Halaman Blog Yang Dilihat Per Hari, Pengunjung yang Sedang Online


Salah satu situs yang menyediakan widget gratis untuk menampilkan stastistik blog dengan banyak pilihan tampilan widget adalah Histats.com. Widget gratis yang ditawarkan dapatmenampilkan data statistik blog (total jumlah page view dan pengunjung), halaman blog yang dilihat per hari, jumlah pengunjung per hari, dan juga pengunjung yang sedang online. Beberapa tampilan widgetnya dapat dilihat pada gambar dibawah ini:

Statistik blog widget gratis dari histats
Gambar dibawah ini menampilkan klaim situs tentang widgetnya.
Statistik blog widget gratis dari histats 01
Untuk mendapatkan kode widgetnya, klik link
Histats.com ini, lalu masukan alamat URL blog dan pilihan bahasa yang digunakan (sayangnya tidak ada pilihan bahasa Indonesia ya), lalu klik tombol Register.
Statistik blog widget gratis dari histats 02
Setelah itu akan muncul halaman untuk memasukan data-data untuk membuat akun baru. Masukan semua data yang diperlukan, lalu klik tombol Continue.
Statistik blog widget gratis dari histats 03
Setelah itu akan muncul halaman untuk memilih kategori widget yang ingin ditampilkan. Tentukan pilihan klik tombolnya.
Statistik blog widget gratis dari histats 04
Setelah itu akan muncul hamlaman untuk menentukan bentuk tampilan widget yang ingin ditampilkan. Pilihlah, lalu klik tombol Continue.
Statistik blog widget gratis dari histats 05
Langkah berikutnya adalah menentukan informasi yang ingin ditampilkan di widget. Setelah menentukan data-data yang ingin ditampilkan, lalu klik tombol Continue.
Statistik blog widget gratis dari histats 06
Setelah itu akan keluar halaman untuk mendapatkan kode widget yang kita inginkan. Kopi kode tersebut.
Statistik blog widget gratis dari histats 07
Login ke Blogspot –> Tata Letak –> Elemen Halaman, lalu klik link Tambah gadget di lokasi yang kita inginkan.
elemen halaman lay out
Pilihlah HTML/JavaScript Gadget dan masukan kode yang tadi didapat dari Histats.com, lalu klik tombol simpan.
tambah gadget HTML/javascript
Sekarang blog telah memiliki widget akan yang menampilkan data statistik blog (total jumlah page view dan pengunjung), halaman blog yang dilihat per hari, jumlah pengunjung per hari, dan juga pengunjung yang sedang online.
O ya jangan lupa cek email dan klik link yang diberikan oleh Histats.com untuk mengaktifkan akun histats yang dibuat.
UPDATE: Tampilan Histats.com telah mengalami perubahan ya, tidak lagi seperti yang ditampilkan pada gambar-gambar diatas.
sumber:http://fadli84.wordpress.com/

Kamis, 04 Juni 2009

MEMBANGUN KEKUATAN DIRI

Jadilah dirimu sendiri, demikian kata-kata bijak yang mesti kita renungkan. Berbagai presoalan hidup manusia muncul dan mengiringi setiap aktivitasnya. Adakalanya berat dan adakalanya ringan. Bersambung.......