Friday 25 February 2011

One of my favorite song


Elvis Presley -"Can’t Help Falling In Love"



Wise men say only fools rush in
But I can't help falling in love with you
Shall I stay
Would it be a sin
If I can't help falling in love with you

Like a river flows surely to the sea
Darling so it goes
Some things are meant to be
Take my hand, take my whole life too
For I can't help falling in love with you

Like a river flows surely to the sea
Darling so it goes
Some things are meant to be
Take my hand, take my whole life too
For I can't help falling in love with you
For I can't help falling in love with you

(words & music by george weiss - hugo peretti - luigi creatore)

Thursday 24 February 2011

Be careful while connecting a pen drive to your system !


It is easy to spread virus through pendrive ,
Precautions .
Press shift key when u connect pendive to your system. This will kill the autorun action.
Then open mycomputer and rightclick on the drive icon and select explore.
copy or paste the content and remove it
And there are other ways:
1) disable autorun globally,
2) use other than windows, operating system. 

Wednesday 23 February 2011

Sarabhai Institute of Science and Technology : This is my college

The High-tech engineering college named "SARABHAI INSTITUTE OF SCIENCE & TECHNOLOGY" is a self- financing institution established by the Space Engineers Welfare Society (SEWELS) with the approval from the Government of Kerala and affiliated to Cochin University of Science and Technology (CUSAT) .

Tuesday 22 February 2011

Generating PDF using Codeigniter


Hello friends , I have stated using codeigniter framework for php. I would recommended codeigniter for all PHP developers.
Recently i had a task to generate PDF file in my codeigniter project ,there are many libraries like FPDF, Panda, DOM-pdf, R&OS to generate PDF documents with PHP.
I found a method to integrate R&OS pdf class file with codeigniter. I am sharing you the same.
Step 1
Download latest version of Codeigniter framework.
Step 2
Download the class files for pdf integration from here. The rar folder contains 2 folders.
1. library class files
2. fonts
Extract files under class files folder to application/libraries/
Extract fonts directory to root folder of your CI application.
Step 3
Now into final stage . Create a controller named home.php and paste the following code.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

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

 function index()
 {
 $this->hello_world();
 }

 function hello_world()
 {
 $this->load->library('cezpdf');

 $this->cezpdf->ezText('Hello World', 12, array('justification' => 'center'));
 $this->cezpdf->ezSetDy(-10);

 $content = 'The quick, brown fox jumps over a lazy dog. DJs flock by when MTV ax quiz prog.
 Junk MTV quiz graced by fox whelps. Bawds jog, flick quartz, vex nymphs.';

 $this->cezpdf->ezText($content, 10);

 $this->cezpdf->ezStream();
 }

 function tables()
 {
 $this->load->library('cezpdf');

 $db_data[] = array('name' => 'Jon Doe', 'phone' => '111-222-3333', 'email' => 'jdoe@someplace.com');
 $db_data[] = array('name' => 'Jane Doe', 'phone' => '222-333-4444', 'email' => 'jane.doe@something.com');
 $db_data[] = array('name' => 'Jon Smith', 'phone' => '333-444-5555', 'email' => 'jsmith@someplacepsecial.com');

 $col_names = array(
 'name' => 'Name',
 'phone' => 'Phone Number',
 'email' => 'E-mail Address'
 );

 $this->cezpdf->ezTable($db_data, $col_names, 'Contact List', array('width'=>550));
 $this->cezpdf->ezStream();
 }

}

/* End of file welcome.php */
/* Location: ./application/controllers/home.php */



You are done .
Execute the code :
http://localhost/pdf/index.php/home/index – for basic pdf creation.
http://localhost/pdf/index.php/home/tables – for table creation.
Note: In Order to write the output as a .pdf file just change $this->cezpdf->ezStream(); to $this->cezpdf->ezOutput();
Complete Code :
create a folder named pdf in root directory of codeigniter project and replace the tables function in the above controller
[ home.php ] with the following.

function tables()
{
$this->load->helper('path');
$this->load->library('cezpdf');
 
$this->cezpdf->ezText('Hello World', 12, array('justification' => 'center'));
$this->cezpdf->ezSetDy(-10);
 
$db_data[] = array('name' => 'Jon Doe', 'phone' => '111-222-3333', 'email' => 'jdoe@someplace.com');
$db_data[] = array('name' => 'Jane Doe', 'phone' => '222-333-4444', 'email' => 'jane.doe@something.com');
$db_data[] = array('name' => 'Jon Smith', 'phone' => '333-444-5555', 'email' => 'jsmith@someplacepsecial.com');
 
$col_names = array(
'name' => 'Name',
'phone' => 'Phone Number',
'email' => 'E-mail Address'
);
 
$this->cezpdf->ezTable($db_data, $col_names, 'Contact List', array('width'=>550));
 
$directory = './pdf/';
set_realpath($directory);
 
$file = $directory.date('d-m-Y h:i:s').'.pdf';
 
$pdfcode = $this->cezpdf->ezOutput();
$fp = fopen($file,'wb');
fwrite($fp,$pdfcode);
fclose($fp);
}

You are done !

Make FckEditor Plugin In Codeigniter


I just try how to use Fckeditor as a Library in CI.It’s indeed simple but in the wiki ( http://codeigniter.com/wiki/FCKeditor/ ) it’s hard to understand witch updates to do for the last CI version (1.7.1). Here what I do step by step.


  1. Download Fckeditor.

  1. Extract the folder "fckeditor" in "system/plugins/"

  1. Open the "fckeditor" folder and copy the file "fckeditor.php"

  1. Past the file in "system/application/libraries"

  1. Edit the file you just past and add this line to the top


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


  1. In the same file now change the path of the include to have something like


if ( !function_exists('version_compare') || version_compare( phpversion(), '5',
'<' ) )
    include_once( 'system/plugins/fckeditor/fckeditor_php4.php' ) ;
else
    include_once( 'system/plugins/fckeditor/fckeditor_php5.php' ) ;


  1. Open the file "system/plugins/fckeditor/fckeditor_php5.php" and add this line to the top



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


  1. Change this part of the class

    class FCKeditor

    {

    public $InstanceName ;


    public $BasePath ;

    public $Width ;

    public $Height ;

    public $ToolbarSet ;

    public $Value ;


    public $Config ;

    public function __construct( $instanceName )

    {

    $this->InstanceName = $instanceName ;


    $this->BasePath = '/fckeditor/' ;

    $this->Width = '100%' ;

    $this->Height = '200' ;


    $this->ToolbarSet = 'Default' ;

    $this->Value = '' ;

    $this->Config = array() ;


    }

    ...

    into this





class Fckeditor
{
    var $InstanceName ;
    var $BasePath ;
    var $Width ;
    var $Height ;
    var $ToolbarSet ;
    var $Value ;
    var $Config ;
    public function __construct( $array )
     {
        $this->InstanceName = $array['instanceName'] ;
        $this->BasePath        = $array['BasePath'] ;
        $this->Width        = $array['Width'] ;
        $this->Height        = $array['Height'] ;
        $this->ToolbarSet    = $array['ToolbarSet'] ;
        $this->Value        = $array['Value'] ;
        $this->Config        = array() ;
    }

...

open the fckeditor_php4.php and add the same line to the top and rename the class name into "class Fckeditor"

  1. In your controller you should have something like


function fckeditorform(){
   $fckeditorConfig = array(
          'instanceName' => 'content',
          'BasePath' => base_url().'system/plugins/fckeditor/',
          'ToolbarSet' => 'Basic',
          'Width' => '100%',
          'Height' => '200',
          'Value' => ''
            );
   $this->load->library('fckeditor', $fckeditorConfig);
   $this->load->view('fckeditorView');
}
function fckeditorshowpost(){
        echo $this->input->post('content');
}


  1. In your view you should have something like


$this->load->helper('form');
echo '<h1>FckEditor</h1>';
echo form_open('yourcontroller/fckeditorshowpost');
echo $this->fckeditor->Create() ;
echo form_submit(array('value'=>'submit'));
echo form_close();