CodeIgniter Forums

Full Version: Greetings everyone, opinions please on this app - can CodeIgniter do this?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Greetings all…

I have a quick question regarding using CodeIgniter in a specific non-conventional way.

I was hoping to get some opinions or suggestions on whether this is doable.

First let me say that I am NOT a developer – especially in the OOP/MVC sense. I have a few years of light PHP scripting experience and am looking to go down the road of MVC frameworks – and CodeIgniter looks awesome!

Anyways –

I wanted to build a simple app, where a user can upload an entire pre-written html page (from <html> to </html&gtWink into a form, stored in MySQL, and then be able view that page via a url such as:

So basically, create an app using standard MVC CodeIgniter coding principles:

Create a user:

Which in turn, will create their homepage:

Also, create their admin page (password resets, etc…)

When the user added the above mentioned html content to the “add_content” form – it would be called from the database as and be seen via the URL:

Obviously, per additional instructions, we could have a form to upload pictures & css - or they could do it manually - to such and such directory (perhaps views/images) – and make sure their code reference /siteroot/views/images for graphics and .css.

The caveat would be how to store and escape/sanitize the code in the database – and render it properly (certain tags to be interpreted, and others as straight text).
For example – any php code in their uploaded page would be rendered as straight text.

So, that’s about it...

Opinions/suggestions please :-)

Thanks in advance...

- Scott

El Forum

in order to create the domain listing you want, you will need to set up specific routes for every page.

To set up a route, you need to edit app/config/routes.php where you will see some lines, which are all PHP array elements.

To add a new route, do:
$route[ 'SOURCE' ] = 'TARGET';

So for your register one, you might do (assuming you use a controller named "users")
$route[ 'register' ] = 'users/register';

And then to catch the usernames, add:
$route[ '([a-zA-Z0-9]+)' ] = 'users/home/$1';

A couple of important things is that the second route I mentioned (the one using regular expressions) will catch *any* URL you throw at it other than so you need to put any other routes before it.

You might want to make it easier by making and non-username pages go to a redirect controller, by using something like:
$route[ 'page/(.+)' ] = 'page/$1';

It could get somewhat complicated at times so it would really be easier to use a controller as the first URL parameter rather than the username.

If you need some help, MSN me, my is the same as my username.

El Forum

Greetings php_penguin,

Thanks for the reply and the info… I totally forgot that the first segment of the uri is the controller – yes, I will have to find another way – or take you suggestions – which I really appreciate.

What about the putting html code into a database field? Is that doable?

I am actually about to post this - job or a portion of it (probably the registration piece) on – but I have to iron out the architectural stuff…

Either way thanks again…