Archive for February, 2006
Using the iis 6 ftp service

By Justin Silverton
Install Internet Information Services and the FTP Service
Because FTP depends on Microsoft Internet Information Services (IIS), IIS and the FTP Service must be installed on the computer. To install IIS and the FTP Service, follow these steps.
NOTE: In Windows Server 2003, the FTP Service is not installed by default when you install IIS. If you already installed IIS on the computer, you must use the Add or Remove Programs tool in Control Panel to install the FTP Service.
1. Click Start, point to Control Panel, and then click Add or Remove Programs.
2. Click Add/Remove Windows Components.
3. In the Components list, click Application Server, click Internet Information Services (IIS) (but do not select or clear the check box), and then click Details.
4. Click to select the following check boxes (if they are not already selected):
Common Files
File Transfer Protocol (FTP) Service
Internet Information Services Manager
5. Click to select the check boxes next to any other IIS-related service or subcomponent that you want to install, and then click OK.
6. Click Next.
7. When you are prompted, insert the Windows Server 2003 CD-ROM into the computer’s CD-ROM or DVD-ROM drive or provide a path to the location of the files, and then click OK.
8. Click Finish.
IIS and the FTP service are now installed. You must configure the FTP Service before you can use it.
Configure The FTP Service
To configure the FTP Service to allow only anonymous connections, follow these steps: 1. Start Internet Information Services Manager or open the IIS snap-in.
2. Expand Server_name, where Server_name is the name of the server.
3. Expand FTP Sites
4. Right-click Default FTP Site, and then click Properties.
5. Click the Security Accounts tab.
6. Click to select the Allow Anonymous Connections check box (if it is not already selected), and then click to select the Allow only anonymous connections check box.
When you click to select the Allow only anonymous connections check box, you configure the FTP Service to allow only anonymous connections. Users cannot log on by using user names and passwords.
7. Click the Home Directory tab.
8. Click to select the Read and Log visits check boxes (if they are not already selected), and then click to clear the Write check box (if it is not already cleared).
9. Click OK.
10. Quit Internet Information Services Manager or close the IIS snap-in.
The FTP server is now configured to accept incoming FTP requests. Copy or move the files that you want to make available to the FTP publishing folder for access. The default folder is drive:\Inetpub\Ftproot, where drive is the drive on which IIS is installed.
adding a virtual directory
This is probably one of the most confusing issues with the IIS ftp service. To create a virtual directory, do the following:
1) right click your new ftp server that you created from above (in iis manager) and go to new->virtual directory.
2) it will ask you for the alias (how people will access this directory and the location (which is the actual physical directory on your harddrive).
3) after this is created, you may try to login to your ftp server and see if your directories are listed. They won’t be there.
4) Most FTP server use the actual file structure of your system to determine what directories to display to the user.
To allow your virtual directories to be seen, go into the home directory of your ftp site and create an empty directory with same name as your virtual one (the alias).
This works virtual directories take precidence over file-system directories.
No commentsusing php and smarty templates
By Justin Silverton
Why use smarty templates?
One of Smartys primary design goals is to facilitate the separation of application code from presentation. Typically, the application code contains the business logic of your application, written and maintained in PHP code. This code is maintained by programmers. The presentation is the way your content is presented to the end user, which is written and maintained in template files. The templates are maintained by template designers.
At its most basic function, the application code collects content, assigns it to the template engine and displays it. The content might be something like the headline, tagline, author and body of a newspaper article. The application code has no concern how this content will be presented in the template. The template designer is responsible for the presentation. They edit the template files, adding markup and bringing it to completion. This typically involves things like HTML tags, cascading style sheets and other tools provided by the template engine.
This paradigm serves several purposes:
*) Designers can’t break application code. They can mess with the templates all they want, but the code stays intact. The code will be tighter, more secure and easier to maintain.
*) Errors in the templates are confined to the Smartys error handling routines, making them as simple and intuitive as possible for the designer.
*) With presentation on its own layer, designers can modify or completely redesign it from scratch, all without intervention from the programmer.
*) Programmers aren’t messing with templates. They can go about maintaining the application code, changing the way content is acquired, making new business rules, etc. without disturbing the presentation layer.
*) Templates are a close representation of what the final output will be, which is an intuitive approach. Designers don’t care how the content got to the template. If you have extraneous data in the template such as an SQL statement, this opens the risk of breaking application code by accidental deletion or alteration by the designer.
*) You are not opening your server to the execution of arbitrary PHP code. Smarty has many security features built in so designers won’t breach security, whether intentional or accidental. They can only do what they are confined to in the templates.
Although application code is separated from presentation, this does not necessarily mean that logic is separated. The application code obviously has logic, but the templates may have logic based on the condition that it is for presentation only. For example, if the designer wants to alternate table row colors or upper-case some assigned content, they can. This is presentation logic, something the programmer should not be concerned with. How often have you had some presentation displayed in a single column and then you wanted it in two or three columns, so the application code needs adjusting to accomodate this? A better approach is to assign the content in one single array and let the template handle the presentation. This will simplify your application and keep your templates flexible. Smarty supplies the tools to handle this kind of situation.
Getting Started with smarty
The first step is to download the smarty template engine Here
1. copy the following to a new file named “smartywrapper.php
// require the Smarty class
require_once(’Smarty.class.php’);
// extend the Smarty class
class smartywrapper extends Smarty {
//this will only work with php 5.X
function function __construct() {
// create the Smarty object
$this->Smarty();
// make sure these folders exist and the permissions are set accordingly
$this->template_dir = ‘/www/example.com/webapp/template/’;
$this->compile_dir = ‘/www/example.com/webapp/compile/’;
$this->config_dir = ‘/www/example.com/webapp/config/’;
$this->cache_dir = ‘/www/example.com/webapp/cache/’;
}
}
2. copy the following to a file named “smartytest.php”
// require the new wrapper class we just created from above
require_once(’smartywrapper.php’);
// create the Smarty_WebApp object
$smarty = new smartywrapper();
// assign a variable, first parameter is the var name, second is the value
$smarty->assign(’test_var_1′,’this is a test’);
//display the template file (all html can now be placed here instead of in your php files)
$smarty->display(’my_template.tpl’);
create a file called my_template.tpl and place it in the directory in $this->template_dir = ‘/www/example.com/webapp/template/’; from above:
This is a test page from smarty, my variable is: {$test_var_1}
launch smartytest.php from you webbrowser and if it is successful, you should see the following
output:
This is a test page from smarty, my variable is: this is a test
Conclusion
Smarty templates can not only be used to increase the overall speed of your php scripts through caching (more about caching can be found Here), but make it easier to develop large-scale applications through the separation of HTML code and php script.
No commentsphp 5.0 and iis - authentication issues
by Justin Silverton
I installed php 5.0/iis 6 (the isapi dll manually) today on one of my new development servers, following the directions from the install.txt (and using the steps that I wrote about in a previous article). After I created a test php file and attempted to launch it from a web-browser, I was shown a username and password box.

if you are getting the message box above, it is most likely a permission problem.
The following can be done to fix it:
1) make sure the path has c:\php (where your php is installed)
-this can be done by going to start->settings->control panel->system, then clicking on the advanced tab, and finally clicking on “environment variables”. The path variable is located within the second box on the page.
2) the following files need to have their permissions set to read by the user account IIS uses to launch files (typically IUSR_(your server name):
php.ini
php5ts.dll
Is the End of Microsoft Near?
By Justin Silverton
Microft has had a pretty good run. They have gone from a small development shop in the late 1970s and early 80s to the largest software company in the world.
One of the reasons the windows operating system can now be seen on 80% of the world’s computers is because of developer support. Any programmer from novice to expert has the ability to write an application and release it on the windows platform.
Recently, an article appeared over at boing boing: (http://www.boingboing.net/2006/01/30/msft_our_drm_licensi.html)
Here is an excerpt:
“Microsoft’s DRM requires that device makers pay Microsoft a license fee for each device that plays back video encoded with its system. it also requires every such vendor to submit to a standardized, non-negotiable license agreement that spells out how the player must be implemented. This contract contains numerous items that limit the sort of business you’re allowed to pursue, notably that you may not implement a Microsoft player in open source software.
The bombshell was Amir’s explanation of the reason that his employer charges fees to license its DRM. According to Amir, the fee is not intended to recoup the expenses Microsoft incurred in developing their DRM, or to turn a profit. The intention is to reduce the number of licensors to a manageable level, to lock out “hobbyists” and other entities that Microsoft doesn’t want to have to trouble itself with.”
This is a step in the wrong direction and it really makes me wonder why in their right mind they would even consider doing this.
I guess it shouldn’t come as a surprise. With Microsoft’s track record as a convicted monopolist and their blatent strongarm tactics in the hardware and software industry, another step towards world domination of total domination is only inevitable.
what alternatives do we have?
1) Linux
I started using linux back in 96, when there was no such thing as kde (I believe KDE was just starting out as a project) or gnome and most people you ask would have no idea what linux even is. It has come a long way in 10 years, but I don’t think it is ready to take the place of windows yet.
Don’t get me wrong. Linux is a great operating system. I wish I could throw away all of my insecure and buggy windows machines tomorrow and never look back, but it’s just not possible at this point. I think one of the main reasons I’m still using microsoft products, is driver support.
This isn’t the fault of the developing force behind linux, but of the sheer force of windows. Most manufacturers don’t want to put research and development into writing a driver for linux. The end result is a constant battle to keep up with the many pieces of hardware that need to be supported. Many drivers are created by reverse-engineering an existing driver.
If more manufacurers started supporting linux (at least 90%) It could be a Microsoft killer.
interested in linux? find a distro Here
2) OS X
OS X could very well be the next windows killer. In the past year or so, apple announced their compatibility with OS X and the intel platform. Although in its current state, os x cannot run on an out of the box PC, what’s to stop it from doing so in the future? This could all be in apple’s plan.
1) release intel version of os x
2) get driver support from manufacturers and fix compatiblity issues
3) profit
an interesting link about macs booting windows XP
more info on intel mac os x
6 commentsusing php and imagemagick
by justin silverton
What is imagemagick and why do i need it?
image magick is a free and useful tool that can do the following:
1) Convert an image from one format to another (e.g. PNG to JPEG
2) Resize, rotate, sharpen, color reduce, or add special effects to an image
3) Create a montage of image thumbnails
4) Create a transparent image suitable for use on the Web
5) Turn a group of images into a GIF animation sequence
6) Create a composite image by combining several separate image
7) Draw shapes or text on an image
8) Decorate an image with a border or frame
9) Describe the format and characteristics of an image
Accessing it from PHP
In my experience, image magick is most likely installed here (on *nix systems) (it also may be in a different area on your system) : /usr/bin/convert
as an example of how I used it, I needed to automatically create thumbnails of images that were being uploaded through and administrative interface for a photo gallery.
exec (”/usr/local/bin/convert -geometry 480X -quality 70 $sourcepath $destpath”);
?>
notes: change /usr/local/bin to the directory on your system where it is installed.
$sourcepath: source image we want to convert (including image name)
$destpath: destination image name (including image name)
command line options
-adjoin join images into a single multi-image file
-affine matrix drawing transform matrix
-antialias remove pixel-aliasing
-append append an image sequence
-average average an image sequence
-background color background color
-blur geometry blur the image
-border geometry surround image with a border of color
-bordercolor color border color
-box color color for annotation bounding box
-cache threshold megabytes of memory available to the pixel cache
-gaussian geometry gaussian blur an image
-geometry geometry perferred size or location of the image
a full list can be found by executing convert –?
Download
Don’t have imagemagick on your system? download it for free Here
It’s free and licensed under the GNU





