Jump to content
MakeWebGames

Profile Page Cover Pic


Miks

Recommended Posts

**Updated**

Allow your users to upload a cover picture to there profile page.

This one is slightly fiddly to implement but if you follow my instructions you shouldnt go wrong.

1. Create a new page called coverupload.php and paste the below code

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

2. Create a new column in your users database called cover_pic

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

So we now have the upload page and the appropriate column

3. We now need to modify our viewuser.php page and add the below code

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

You may need to play with the width and height attributes to fit your own page

Thats it, you're all done!

The below code isnt needed but its an example of how I implemented it into the viewuser page

This is a basic version and I will hopefully update it in a week or two

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 
Link to comment
Share on other sites

[MENTION=70854]Truefalse[/MENTION] I wont be able to skype but if you could point out where I have gone or where it isnt secure that would be great, it will help me understand more and hopefully not make the same mistake in future

Link to comment
Share on other sites

The coverupload.php is where it is insecure.

Before you update the users table with that cover pic, you have to validate that the text that is in the textbox that the user fills out is legitimate. All you're doing right now is checking whether it is set or not, which is a start, but the text in and of itself could be anything, including SQL, which could be an easy target for SQL injection.

If [MENTION=70854]Truefalse[/MENTION] can't help you out completely, then I can help tackle this problem as well.

Until that security hole is fixed, I would not recommend using this mod.

~G7470

Link to comment
Share on other sites

This part is insecure:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

try doing something like this:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

ok, so the way you had it in the beginning leaves your database extremely vulnerable to sql injection.

you need to validate and do your best to prevent sql injection wherever possible so never input the data a user has created directly into the database as it could contain any form of malicious string: hi, money=1000000, user_level=2

your query then becomes:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

see the problem?

Also from what I can see the following is not needed

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Edited by Coly010
explanation
Link to comment
Share on other sites

I will try and secure it myself as I "think" I know how to do it now. I will upload the changes shortly and then you can take a look.

Sorry for sharing something that's not secure, I thought I had done it right. Oh well if anything this is a good learning curve! Iv picked up a lot from this site over the last few days, I guess I still have a bit more to learn!

Link to comment
Share on other sites

This part is insecure:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

try doing something like this:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

ok, so the way you had it in the beginning leaves your database extremely vulnerable to sql injection.

you need to validate and do your best to prevent sql injection wherever possible so never input the data a user has created directly into the database as it could contain any form of malicious string: hi, money=1000000, user_level=2

your query then becomes:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

see the problem?

Also from what I can see the following is not needed

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Kind of there, but totally missed the point. He only security hole isn't SQLI injection, but also stored XSS

- - - Updated - - -

 

I will try and secure it myself as I "think" I know how to do it now. I will upload the changes shortly and then you can take a look.

Sorry for sharing something that's not secure, I thought I had done it right. Oh well if anything this is a good learning curve! Iv picked up a lot from this site over the last few days, I guess I still have a bit more to learn!

 

Hey, no worries :) you're learning so that's something. It's a change from people grabbing free things from here and not giving anything in return.

I look forward to your updates.

Link to comment
Share on other sites

Kind of there, but totally missed the point. He only security hole isn't SQLI injection, but also stored XSS

I don't want to be that guy, but if you read my post, I never said that sql injection was his only problem, just that that particular part was insecure and gave him a way to minimise the risk. I am a firm believer that you can never have 100% security in a web app

- - - Updated - - -

- - - Updated - - -

 

[MENTION=70854]Truefalse[/MENTION] I see what you mean about sql injections I didn't think about it like that but it makes perfect sense

But I'm lost when you say about stored XSS

Google it, it stands for cross-sitr scripting and is a vulnerability involving malicious scripts. I believe, not 100% on that though

Edited by Coly010
Link to comment
Share on other sites

I just threw a quick script together, which could be expanded upon, but for now, it's far more stable than what you have;

Test Images for being an image

If your testing returns good most of the time, feel free to use the code;

Code

Out of curiosity do you have to check for is_string() as well as filter_var? Surely filter_var would return false should the $_POST not be valid? (out of curiosity not nitpicking).

Link to comment
Share on other sites

Out of curiosity do you have to check for is_string() as well as filter_var? Surely filter_var would return false should the $_POST not be valid? (out of curiosity not nitpicking).

None that I have come across.

If you pass an array etc to filter_var, it fails, so no it is not needed.

Quick script though, so I'm not too fussed what was in it :P

Link to comment
Share on other sites

None that I have come across.

If you pass an array etc to filter_var, it fails, so no it is not needed.

Quick script though, so I'm not too fussed what was in it :P

 

I was just curious :p. Would have asked you on Skype.... but you removed me again

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...