Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Ezilon Directory   ClickBooth Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 04-12-2007, 02:40 PM   #21 (permalink)
Contributing Member
 
Arenlor's Avatar
 
Join Date: 01-02-07
Location: PA, USA
Posts: 194
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
I pull the username and blog_num each time to prevent the possibility of someone accessing any of the misplaced posts or anything like that, blog_num 0 doesn't exist and is meant to trash spam. It's of course a multi-user blogging system, which is why more than one blog_num, and I try to keep a little more hacker free with using weird words and names as my variables, such as mfa, and I never use $query or $result, I've seen the results of that at a hacker's hands. My code is meant to be somewhat unreadable, those people who I use the for() loop as a marking with are all fellow hackers from a computer summer school, if they can't read my database then they can't hack it. I've only ever used one primary key, and never actually understood how to use the other types of indexes (and my teacher didn't ever use them either, so he forgot about them) And this is just the all index page, you can flip through my site see how it is now, I'm just working on an upload script for images and files now. Oh and I MD5 anything that I don't SHA1 which I don't need to read or have read. I normally would have SHA1'd the username actually. I'm not sure why I didn't this time. And my host for some reason refuses to think that at $1/G harddrive, 10G bandwidth, and a mysql db of unlimted size that we deserve to have the MD5 php function. ^_^ I can live with that truly.
__________________
Need a page made? Draw a diagram, I suggest using Paint, show the picture with your post, it'll help a lot more than you think. Other questions? Draw a diagram for that too!
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-12-2007, 02:59 PM   #22 (permalink)
Contributing Member
 
exam's Avatar
 
Join Date: 04-20-06
Posts: 310
iTrader: 0 / 0%
Latest Blog:
None

exam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web pro
Quote:
Originally Posted by Arenlor View Post
I pull the username and blog_num each time to prevent the possibility of someone accessing any of the misplaced posts or anything like that
Hmmmm, my code does the same thing but avoids the inner join, reducing CPU cycle usage on the MySQL server.

Quote:
Originally Posted by Arenlor View Post
It's of course a multi-user blogging system, which is why more than one blog_num, and I try to keep a little more hacker free with using weird words and names as my variables, such as mfa, and I never use $query or $result, I've seen the results of that at a hacker's hands. My code is meant to be somewhat unreadable, those people who I use the for() loop as a marking with are all fellow hackers from a computer summer school, if they can't read my database then they can't hack it.
Sounds like you don't know a lot about hacking When I was talking about code readability, I was referring to your own ability to read the code and maintain it. If you're concerned about hacking, the least of your worries are the names of your variables.

Quote:
Originally Posted by Arenlor View Post
I've only ever used one primary key, and never actually understood how to use the other types of indexes
Indices make it "quicker" for the database to find a row. You should generally use an index on any column that you're using for a lookup. Use with caution, as indices make writes more expensive.

Quote:
Originally Posted by Arenlor View Post
(and my teacher didn't ever use them either, so he forgot about them)
Maybe you should look for a new teacher.

Quote:
Originally Posted by Arenlor View Post
And this is just the all index page, you can flip through my site see how it is now, I'm just working on an upload script for images and files now. Oh and I MD5 anything that I don't SHA1 which I don't need to read or have read. I normally would have SHA1'd the username actually. I'm not sure why I didn't this time. And my host for some reason refuses to think that at $1/G harddrive, 10G bandwidth, and a mysql db of unlimted size that we deserve to have the MD5 php function. ^_^ I can live with that truly.
I didn't quite get all of that, but if I were you, I'd go to my local bookstore and read a couple of books on SQL, and then enroll in a few more coding courses.

Best of luck mate.
exam is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-12-2007, 04:40 PM   #23 (permalink)
Contributing Member
 
Arenlor's Avatar
 
Join Date: 01-02-07
Location: PA, USA
Posts: 194
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
The course I had was free, sadly... I was one of the people chosen out of my state as the top of 11th graders who were interested in computers. And I was had a mysql database hacked because I used assoc. Thing is though I code for usability, not readability, if I can use it, then that's all I need. I also have short term memory loss and would have to look at my db structure to get the name for assoc anyway.

PHP Code:
{
$loc "images/";
$loc $loc basename($_FILES['upimg']['name']);
if(
move_uploaded_file($_FILES['upimg']['tmp_name'], $loc)) {
    echo 
"<p>The image ".basename$_FILES['upimg']['name'])." has been uploaded!</p>";
} else{
    echo 
"<p>There was an error uploading the file, please try again.</p>";
}
}
echo 
"<form enctype=\"multipart/form-data\" action=\"$PHP_SELF\" method=\"post\">
<fieldset><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"102400\" />
<label for=\"pass\">Password: <input type=\"password\" value=\"password\" id=\"pass\" name=\"pass\" /></label><input name=\"upimg\" type=\"file\" accept=\"image/bmp,image/gif,image/jpeg,image/tiff,image/png\" /></fieldset>
<p><input type=\"submit\" value=\"Upload\" /></p>
</form>"

Any idea why that's allowing me to upload any file type?
__________________
Need a page made? Draw a diagram, I suggest using Paint, show the picture with your post, it'll help a lot more than you think. Other questions? Draw a diagram for that too!
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-13-2007, 10:33 AM   #24 (permalink)
Contributing Member
 
exam's Avatar
 
Join Date: 04-20-06
Posts: 310
iTrader: 0 / 0%
Latest Blog:
None

exam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web pro
You need to check filetype on the server side after the file has been uploaded.

$_FILES['userfile']['type']
exam is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-14-2007, 06:59 PM   #25 (permalink)
Contributing Member
 
Arenlor's Avatar
 
Join Date: 01-02-07
Location: PA, USA
Posts: 194
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
So like, if($_FILE['upimg']['type'] == blah)
__________________
Need a page made? Draw a diagram, I suggest using Paint, show the picture with your post, it'll help a lot more than you think. Other questions? Draw a diagram for that too!
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-14-2007, 07:49 PM   #26 (permalink)
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
I like, if(!in_array($_FILE['upimg']['type'],$acceptable_types)) better.

Last edited by StupidScript : 04-14-2007 at 07:54 PM.
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-14-2007, 08:00 PM   #27 (permalink)
Contributing Member
 
Arenlor's Avatar
 
Join Date: 01-02-07
Location: PA, USA
Posts: 194
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
That looks better lol, was just seeing what he meant when he suggested using it. What the heck is accept for then btw?
__________________
Need a page made? Draw a diagram, I suggest using Paint, show the picture with your post, it'll help a lot more than you think. Other questions? Draw a diagram for that too!
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-14-2007, 09:24 PM   #28 (permalink)
Contributing Member
 
Arenlor's Avatar
 
Join Date: 01-02-07
Location: PA, USA
Posts: 194
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
Still wondering what accept is meant for, but this is my new coding and it works.
PHP Code:
$loc "images/".basename($_FILES['upimg']['name']);
if(!
ereg("^image/(bmp|gif|jpeg|tiff|png)$",$_FILES['upimg']['type'])){
    echo 
"<p>You may only upload bitmap, gif, jpeg, tiff, and png file formats, if you want a different file allowed send an email to <a href=\"mailto:***@arenblogs.com\">***@arenblogs.com</a></p>";
}
else if(
move_uploaded_file($_FILES['upimg']['tmp_name'], $loc)) {
    echo 
"<p>The image ".basename$_FILES['upimg']['name'])." has been uploaded!</p>";
}
else{
    echo 
"<p>There was an error uploading the file, please try again.</p>";

Any simpler ways? Ereg seemed the most correct for what I was doing.
__________________
Need a page made? Draw a diagram, I suggest using Paint, show the picture with your post, it'll help a lot more than you think. Other questions? Draw a diagram for that too!
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-14-2007, 10:08 PM   #29 (permalink)
Contributing Member
 
exam's Avatar
 
Join Date: 04-20-06
Posts: 310
iTrader: 0 / 0%
Latest Blog:
None

exam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web pro
ereg works, but is a more costly operation than calling in_array, as SmartScript suggested. In a practical sense, it doesn't matter for your script, but if you needed to make the comparison 5000 times, say, then ereg will take maybe 1/10 of a second and the in_array version would take maybe 1/100 of a second.

Also, you might want to accept 'image/jpg' as well.
exam is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-15-2007, 12:41 AM   #30 (permalink)
Contributing Member
 
Arenlor's Avatar
 
Join Date: 01-02-07
Location: PA, USA
Posts: 194
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
image/jpeg allows .jpg tiff allows tiff and tif also. That's their official names, we only have the TLA(Three Letter Acronym) because of how the old machines only allowed three letter extensions why did you think .html and .htm were the same thing but .htm was somehow accepted? .html didn't exist, .txt also. /history less
__________________
Need a page made? Draw a diagram, I suggest using Paint, show the picture with your post, it'll help a lot more than you think. Other questions? Draw a diagram for that too!
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-15-2007, 02:34 PM   #31 (permalink)
Empress™
 
chicgeek's Avatar
 
Join Date: 08-19-04
Location: York, UK
Posts: 17,965
iTrader: 0 / 0%
Latest Blog:
My Favourite Poem

chicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest order
Just a note that (while I don't understand all of it) this thread makes me smile. People helping people. (AWWW!)

Greenies all around! (Except for Exam, who I've given too much to lately.. ha!)
__________________
laura / chicgeek
soprano & web designer
laurakishimoto.ca
chıcgeeĸ @ flickr
chicgeek is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone mess with MX Record? Radnor Domain Name Forum 1 04-20-2006 09:57 AM
A CSS Mess Charles French Coding Forum 3 07-04-2004 05:18 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 03:39 PM.
© Copyright 2008 V7 Inc