Friday, November 7, 2008

Class 07 assignment -5 - Well...

http://onepotcooking.com/davidbone/class07/3/

I updated the above
  • I added the Lightbox2 functionality to the gallery page. Click on an image and you'll see what it does... well, after the page loads.
  • In implementing the lightbox I only wanted to update one page so coded the header into a more template friendly fashion and added a footer for each page. Also coded a dynamic class for each page which would be very helpful in the CSS if needed.
I asked some friends to waste some time in the office and test it and sadly I realize this only works in Firefox. Well the uploader doesn't work in IE and I'm not sure why yet.

UPDATE:
I was able to get the uploader to work by putting back in a file type I didn't think was supposed to be there and that is "image/pjpeg"

Class 07 assignment - 4 - It's all workin'

There is always more to do... but for now I'm happy. Especially happy to be finished after yesterday I completed the project then promptly proceeded to delete all of my work. That's right I pulled a Homer and had to go back a days work! You would think I could have just whipped up the code again after completing it once but no I still didn't quite understand. I think I do now :o)

For you to test (please) onepotcooking.com/davidbone/class07/3/

My toDo list since last post:
  • Get the home page working with gallery
  • Limit the view to last 50 (thanks JackP, who also alerted me to array_reverse)
  • Design the layout + figure out thumbnails
  • Work on security which is non-existent at the moment.
  • Test the limit on file size upload. I don't believe it is working. I was able to restrict the size of file and type of file
  • Template the error messages onto one location like I saw Jonathan do... good idea.
  • + Figure out true thumbnails. Creating and saving on the fly.
Assignment 07 Notes:

page_login.php
  • Checks to see if you have a cookie that has you logged in. This cookie expires in 24hrs.
  • Post form for entering in username and password.
  • On form submit with values: reads the data txt file for username and password and if matched then sends user on to gallery page. If no match then there is an error message. Also sets two cookies. One for loggedin and one with the username.
  • On form submit with no values: error message
page_newmember.php
  • Checks to see if you have a cookie that has you logged in. If so, on to gallery page.
  • Post form for entering in new usernames and passwords.
  • On form submit with values: writes entries to a txt file in a comma delimited fashion. (no security on this yet). On success of writing to file, send user back to login page w/ message.
  • There are other error messages (alerts) related to txt file but most likely will never be called unless there is an error on the server.
  • On form submit with no values: error message
page_home.php
  • Checks to see if you don't have the needed cookie. Send user to login if failed.
  • Personal message to user from username cookie.
  • Gallery of images. Showing only latest 50. Showing last entry first.
  • Thumbnail size controlled by CSS.
  • All images link to the full size.
  • Alert message when successfully uploaded an image
page_uploader.php
  • Checks to see if you don't have the needed cookie. Send user to login if failed.
  • Post form data entry. Writes the file path, caption, username and date to a txt file for gallery page to read.
  • File upload field is limiting file size to 2M by a hidden form field and php. The php also restricts file type to gif, jpeg, jpg or png. (The method from Amos, restricting the file size, didn't work for me)
  • Only the image is required.
Coding Observations:
I feel like I'm in the Matrix movie where all those lines of "code" are on the screen and to the learned eye, you can visualize what's going on. Still at low resolution though.

File management was a desire for me with folders for includes, functions, style... Because of this I came across path issues. When a function writes to a file it would have a different path than the other function that would read.

Testing is where it's at! Many examples of me learning through testing but the last run through revealed I forgot to check for empty form fields when entering the site. This resulted in one of my cookies being set and letting the user in but it didn't set the second one. Because this second one wasn't 'on' I saw behavior from my code that I didn't realize was there.

I learned a ton, especially since I did just about everything repeatedly. I still see myself looking for answers out on the web but now it's more for reference than for stealing.

Syntax is still an issue for me... that is where practice comes in.

Wednesday, November 5, 2008

Class 07 assignment - 3 - Did I say, "Almost Done?"

Moving along but like the Tortoise.

Working files at this point are here onepotcooking.com/davidbone/class07/2/

Coding Observations
  • I like my file management to be consistent. Because of this I had some issue with file paths and in particular the image path for this project. I was looking for a way to set a base directory for the whole project and have all links start from that point. I didn't figure that out but I did break out the paths in the variable definitions because there was a different path for moving the image file compared to writing the image file's path to be read later from a file at a different folder level.
  • Arrays are huge and very important in the loop. I need to understand these better as I needed to look at other's code to get it... thanks again Jonathan.

My toDo list since last post:
  • Get the home page working with gallery
  • Limit the view to last 50
  • Design the layout + figure out thumbnails
  • Work on security which is non-existent at the moment.
  • Test the limit on file size upload. I don't believe it is working.
  • Template the error messages onto one location like I saw Jonathan do... good idea.
I'm doomed - HA!

Tuesday, November 4, 2008

Class 07 assignment - 2 - Almost Done

onepotcooking.com/davidbone/class07/

I have the home page gallery listing left to code. All else is working pretty good but wouldn't use it on a live site.

Would like to do still:
  • Get the home page working with gallery
  • Limit the view to last 50
  • Design the layout
  • Work on security which is non-existent at the moment.
  • Test the limit on file size upload. I don't believe it is working.
  • Template the error messages onto one location like I saw Jonathan do... good idea.
Hope I can get this completed tonight... I've got real work to do ;-)

Where to code : Appending the upload content

I could use a suggestion:
I'm to the stage where I'm trying to get my image path, username and caption to write to a txt file. I'm able to print those variables to screen but not to the file. I'm more than certain it isn't a file permission thing because I created an else in the loop that would state an error but the code isn't getting to that point.

Right now my result is a blank screen and I know it is due to the highlighted code in the following image.

Is this the correct place to try to code in a fwrite?
I figured if the image file could be moved to also write to the txt file in the same move_uploaded_file function but maybe that is incorrect.

Does anyone have some incite?

File Size Converter - I need a Byte

thebyteconverter.com

I found myself needing it for assignment 7.

Class 07 assignment - 1 - Progress

I've probably put in 9 - 10 hours already. Designing the XHTML & CSS as well as learning php for this assignment.

My files are temporarily working at this location www.bonestructure.com/webdev/

So far I've created the functionality for all pages but the uploader. I have had each element working at one point but now I find some weird behavior I can't explain. When I write to the text file on the Become a Member page, it is always writing "david" as the username and writing in the correct password. This is very bazzar as I've never hard coded my name even in testing any elements. I'm at a loss and will come back to it. Not sure how well it will test for you but go for it if you so desire. I do know "david" and "bone" work for the username and password.

Still to complete
  • Fix the writing to the text file.
  • Figure out the uploader (have had tests working but my current build isn't working)
  • Figure out the Home page (gallery of uploads) from the uploaded data. How to write to the page in a formated style and repeating. I would like to keep the uploaded images to a max width and height in the display grid.
  • Figure out how to show only 50 of the latest elements.
  • ...
Coding Observations
  • There seem to be these two ananomous session cookies ("PHPSESSID") that I can't figure out where they are from and if they are affecting the functionality. The show even if you only hit the submit button.
  • I've been using isset for checking if the Cookie is there and I thought unset would turn the Cookie off and delete it just like setting the Cookie again by writing over any previous values. Well I found the unset will return a false for the cookie but it won't delete it. So on that page I used unset, the Cookie would return false and I would see the desired results but if I knew a link and just jumped to it (say I jumped over the login page and pasted in the home page link) the Cookie that was floating around would still work on that page I jumped to.
  • In the progression of building I came across a procedure I liked by accident. I have the "become a member" page passing a username and password, that username is used on the Home page but the home page also checks for a true Cookie which is only set on the Login page, so then the user is automatically sent to the Login page. In short, the new member will submit and then sees the login page. It happens so fast and the two pages are designed so similarly that I didn't even notice the behavior at first... I'm going to have to redesign the Become a Member page a little.
I have to get some Zzzz so I can vote bright and early tomorrow.
L8r - dbone

Saturday, November 1, 2008

A Pumpkin for Us

http://chergaoui.com/wp-content/uploads/2008/10/jack-o-lantern-4.jpg

DOM Stylesheet Library

On my way in this morning I saw a tweet by Smashing Magazine about this site sheetup.com. Checked it when I got to class and it looks like a great resource to check out.