Welcome Guest, Not a member yet? Register   Sign In
Greetings everyone, opinions please on this app - can CodeIgniter do this?
#1

[eluser]Unknown[/eluser]
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:

http://www.domain.com/username/

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

Create a user:

http://www.domain.com/register/

Which in turn, will create their homepage:

http://www.domain.com/username/

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

http://www.domain.com/username/admin/
http://www.domain.com/username/admin/reset_password
http://www.domain.com/username/admin/change_address
http://www.domain.com/username/admin/add_content

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:

http://www.domain.com/username/

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
#2

[eluser]richthegeek[/eluser]
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:
Code:
$route[ 'SOURCE' ] = 'TARGET';

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

And then to catch the usernames, add:
Code:
$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 http://www.domain.com/ 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:
Code:
$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 @hotmail.com is the same as my username.
#3

[eluser]Unknown[/eluser]
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 Rent-A-Coder.com – but I have to iron out the architectural stuff…

Either way thanks again…

Cheers….




Theme © iAndrew 2016 - Forum software by © MyBB