Welcome Guest, Not a member yet? Register   Sign In
First CodeIgniter application
#1

[eluser]Massimiliano Sgarra[/eluser]
Hi guys,
after i have read all users guide and make many example app i just try to develop my first Application.

This is a Photogallery, with simple backend to CRUD Album (with your cover) and many thumb to attach on every album.

This is the url where you can download my app an test: Gallery

I accept tips, suggestion, correction ecc.ecc

During developing i find that i have many difficult to choose well the Controller, at the end i have a "User" controller of more 300 line code.....

Tnx a lot to all!!!

ps: the appa doesn't finisih 100% yet, but i need to know if developing well until now !!!!

Max
#2

[eluser]Dam1an[/eluser]
I've not had a proper look at it, but one thing I notices straight away, is the fact you capitalize some of your method names, some mix seperation with underscores, others are CamelCase. They should all be lower case with underscores (apart from the contructor which should be the same as the class name)
#3

[eluser]Massimiliano Sgarra[/eluser]
Tnx Dam1an,
yes i wrote method name sometime CamelCased and sometime with underscore...

i correct this on my next release Smile

I appreciate much if you can check my app more more in details!!!

I love CodeIgniter and i try to learn more quickly i can!!! Smile
#4

[eluser]n0xie[/eluser]
A few notes after evaluating your code:

1. Stick to the CI coding standards. They will make your life easier and prevent weird bugs from creeping in your application. You can read about them here

2. Always check and validate input, especially from the URL.
Code:
// Gallery Controller
        $id = $this->uri->segment(2);

        $data = array(
            'album' => $this->gallery_model->GetAlbum($id),
            'photos' => $this->gallery_model->GetPhotos($id)
        );
What if $this->uri->segment(2) is not an integer? You're passing an uri segment directly into your database. This can and will lead to sql injection, although AR will protect you from it most of the time. Be very wary of these kinds of structures. (I know that you explicitly forced :num in your routing rules, so the damage is minimal, but these kind of structures will set off red flags with any developer.)

3. Always check if your query in your model returns a valid resultset.
Code:
// Gallery_model
    function GetAlbum($id)
    {
        $this->db->where('id',$id);
        $query = $this->db->get('albums');

        return $query->row();
    }
What will happen if you pass an id that doesn't exist, is not an integer or worse, is an SQL injection attempt?

4. CI has a vary nice way to work with URL's. You already added this rewrite rule:
Code:
$route['album/:num'] = 'gallery/Show_album';

You might want to change it to:
Code:
$route['album/(:num)'] = 'gallery/show_album/$1';

And in your controller:
Code:
function show_album($id)

Basically code defensively. Be paranoid about user input and try to anticipate things that might go wrong, and write code to handle or check this.

Other then that a pretty good try if this was your first time.
#5

[eluser]Massimiliano Sgarra[/eluser]
Tnx a lot n0xie,

security is very important!!! Smile

I read well all the naming convention now !!!

What do you think about separation of controller that i have used?

because one of my big initial difficult was to differentiate class and methods correctly Smile

Just last thing...have i correctly set the Route????
#6

[eluser]n0xie[/eluser]
[quote author="Massimiliano Sgarra" date="1244732740"]
What do you think about separation of controller that i have used?
[/quote]
It looks good to me.

[quote author="Massimiliano Sgarra" date="1244732740"]
Just last thing...have i correctly set the Route????
[/quote]
Yes there isn't anything 'wrong' with it. I just showed an easier way to get the $id without having to resort to $this->uri->...
#7

[eluser]Massimiliano Sgarra[/eluser]
Hi guys,
i just finish to developing my photogallery app Smile

But now i need help...

i have this domain: http://www.industriecologiche.it with a old site loaded.

there you can see php config for this domain: PhpInfo

i load my "gallery" folder (with index.php, system folder and upload folder) by ftp but when i load url: http://www.industriecologiche.it/gallery i recive a blank page Sad

can you help me??
#8

[eluser]Dam1an[/eluser]
Have you tried all the URI protocols in config?
#9

[eluser]Massimiliano Sgarra[/eluser]
[quote author="Dam1an" date="1244752275"]Have you tried all the URI protocols in config?[/quote]

Can you explain better pls...i'm a newbie in CodeIgniter developing!!! Smile
tnnnnnnnxxxxxxx

ps: i have attached my config.php file uploaded on ftp.
#10

[eluser]Dam1an[/eluser]
On line 44 of the config file, you set the URI protocol to AUTO, try changing it to each of the other ones listed in the comment block. Hopefully one of those will work




Theme © iAndrew 2016 - Forum software by © MyBB