Thursday, February 17, 2011

Mail in PhP

I have started and stopped working with PhP several times. Security and mail were my reasons. Today I actually got the sample code for w3schools working. In particular, the code with the form in it with the action mailform.php.  I searched and I searched, looking for this code called mailform.php and could not find it. Then I had an epiphany. What if the process was recursive and the file I was editing had to be called mailform.php? An hour later, after correcting errors which seemed to come out of nowhere, I got it to work.

Independent of my discussion above, is the mail which is used by my OS. I initially used sendmail, for lack of any other ideas. I got the simple mail php code working by changing the email addresses from rose@domain to rose in the code. When I typed mail at the command line, I was able to see the message after exactly one minute.  I thought this odd and searched around and tried some other things. I reached one responder who simply said, stop using sendmail and use postfix instead. The writer sounded so sure that I  just tried it and it worked. (Alas, I cannot find the link, I had on the order of 10 tags open with the same number of google search combinations). The only problem after that was to stop the sendmail process. For some reason, my tried and true "sudo kill -9 processid" refused to work. and I had to "sudo /etc/init.d/sendmail stop". 

On to security.

Wednesday, February 16, 2011

jUploadr and Flickr

Many of my recent photographs have a resolution of 3264x1832, which is twice the size of the monitor at which I am sitting. So, I am going to use jUploadr preferences to limit the size of the longest edge to 400 or so pixels. Here is a sample at 100 percent. There's a message from jUploadr that the photos are being rescaled.




Tuesday, February 15, 2011

Flickr

Well, it has been a while since I have added anything to this blog. I have recently tried using php to create a travel journal for Flickr. I have recently added a serious of landscape photographs and I wanted to make some sort of php-based viewer. I got sidetracked by several irritating things that I am going to write here because I am sure that I will forget which notebook I wrote them down in (linux from scratch notebook).

So, to start, I am working with Ubuntu 10 and apache/php.  First, I added ServerName=localhost to the httpd.conf file, to get rid of that message about "reliable determination". Then I changed all the permissions until I removed the 403 error. I ran into an odd php problem with my subdirectories, where files with the name index.php were being opened by an editor instead of in the browser. Actually, it turns out that I just had a few typos (symbols outside of html tags) that for some reason were preventing proper opening of the webpage.

I am using  phpflickr as described by Paul Burgess in his tutorial. I am still using the 3.0 version so that I can follow the tutorial. Since I asked for an API key awhile ago, I went in search of where I might find it. (you-> your account->sharing and extending ->your API keys, at the bottom). I have two of them but will use the one associated with my landscape photos. This I put key and ID into the config.php file. I am asked to upload this, but since I am working on Apache  localhost, I should just leave it in the working directory.

The tutorial is a bit unclear in some places, especially since I unpacked the code  a few months ago. The thing that surprised me is that the php code started at the top and the html code followed underneath. For the first tutorial, there is index.php, which calls phpflickr.php and config.php. Opening index.php in the browser produces a grid of thu http://localhost/vacation_2010/index.phpmbnail photographs. Nice. This is the address:

 http://localhost/vacation_2010/index.php

When I click on one image, a larger image appears with  paging through the gallery, this appears in the web address window:

http://localhost/vacation_2010/photo.php?id=5416188716

I think that I will have to scale the images because they are quite large. But this is already a nice success.

Made by index.php
Made by photo.php