Ported to Codeigniter

Modiy classes to work with codeigniter