Codeigniter, Links, PHP

TinyImageManager for CodeIgniter

If you use the TinyMCE Image Manager and CodeIgniter together, this class can save you a bit of work.

This package can handle TinyMCE Image Manager image uploads using CodeIgniter.
It is a port of the TinyMCE image manager plugin to integrate it with CodeIgniter framework.
This class was originally written by Andrey Antonov.
-Pablo Matias Perrone”

Codeigniter, PHP

A Setting That Many CodeIgniter Developers Miss While Taking Their Code To Production

These two settings inside the index.php file should be changed to random strings. The folder names should also be changed to match as well.

* This variable must contain the name of your "system" folder.
* Include the path if the folder is not in the same  directory
* as this file.
$system_path = 'system';

* If you want this front controller to use a different "application"
* folder then the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server.  If
* you do, use a full server path. For more info please see the user guide:
* <a href=""></a>
$application_folder = 'application';

You may be wondering to yourself: “why does it matter?”. It matters when you DO NOT want your application fingerprinted as a codeigniter application by a hacker. One of the first things some of these guys (or gals) do is run a directory fuzzer on your server. That fuzzer makes requests to your server through a list of common directory names. Believe me, the two terms ‘application’ and ‘system’ is early on in that list, I tried it.

Give a hacker as little information about the internals of your program as possible and make it a bit more secure.

Codeigniter, PHP

Path Rerouting in CodeIgniter

Rerouting in CodeIgniter is really simple if you already know how paths work in the framework. You have a controller that is used as the route redirect target. In other words, it picks up the redirected path as its own. Everything other than that is simple CodeIgniter coding. The path can be as many variables large as you may require.

Fairly complex routing systems can be set up this way without the bit of complexity you would have using straight php without a framework.  Below is a short and sweet, step by step simple example of how to accomplish a two variable reroute.

Step By Step

First Step is download CodeIgniter from their website.

Second Step is to unzip it into your server root or a subfolder.

Third Step is to create a .htaccess file that tells apache how to handle requests. This step isn’t necessary if you don’t care about index.php being in your paths. My code is installed in a subfolder named ciredir on my Xampp server in Windows:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /ciredir/index.php/$1 [L]


Fourth Step is to alter the application/config/routes.php file.


$route['default_controller'] = "welcome";
$route['404_override'] = '';
// works if .htaccess removes index.php in path
<strong>$route["go2/(:any)"] = "redir/where/$1/$2";
</strong>// if no .htaccess was used you include the index.php in path
// ex. http://localhost/index.php/go2/somevar/anothervar

I actually only added the one line to the default routes configuration file. As you can see there are two path variables defined that are used as arguments to the where() function. Below is the code for the Redir controller that acts as the redirect target. It should be located in the application/controllers folder.


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

class Redir extends CI_Controller {
public function __construct(){
public function index(){
echo 'DOES NOT work if you are using redirection';
echo 'DOES work if you are going to the controller name (/redir)';
* where
* @param $foo
* @param $bar
* @return nothing
* @desc catches the redirection from the altered config/routes.php go2 entry
public function where($foo, $bar)
// simply echo it out instead of calling a view to
// find out what's going on
echo ‘$foo = ‘ . $foo;
echo '<br/>';
echo ‘$bar = ‘ . $bar;
/* End of file redir.php */
/* Location: ./application/controllers/redir.php */

Finally try it out by going to http://localhost/go2/any/var .  Granted, all this code does is echo the variables back out to the screen (very unwise to put on a production server – because a web browser loves to see something it can interpret as something other than plain text). However, you can easily expand on the above code to whatever means you may desire.