CodeIgniter: Check Authentication and Fail

Very often, when developing a site using CodeIgniter, I use a base Controller to check common functions such as authentication. This is easiest to do in the Controller’s __construct method. Usually you can simply use a redirect to your login page:

redirect( "/user/login" );

But sometimes you simply want to stop the Controller and output the fact that they are not authorised or that a certain error has occurred. I was just doing this with a REST API on a site, and simply wanted to fail if the wrong API Key was passed. I’ve found it’s easiest to do via a “show_error” call:

show_error('Not authorized', 401 );

Delphi Starter XE2: Installing ZEOS

Delphi Starter XE2 does not come with many options to connect to databases. You can however install the Zeos database components, so that you can connect to most common database engines. As per the ZEOS portal you should be able to connect to:

  • ADO
  • Mysql 4.1 to 6.0,
  • Interbase 5 / 6
  • Firebird 1.0 to 2.1
  • Postgres 7 to 8
  • SQLite 2.8 to 3

Continue reading