Back to description
Offering account registration and user log-ins is a great way of giving users a sense of individuality and serving tailored... more
Offering account registration and user log-ins is a great way of giving users a sense of individuality and serving tailored content. Such authentication is often at the very heart of many community-oriented and e-commerce web sites. Because this functionality is so useful, the first application I present is a user registration system.
From a functional perspective, the system will allow users to create accounts. Members must provide an e-mail address that they can use to validate their registration. Users should also be able to update their passwords and email addresses and reset forgotten passwords. This is pretty standard functionality and what the web users of today have come to expect.
From an architectural standpoint, the directory holding your code should be logically organized. For example, support and include files should be kept outside of a publically accessible directory. Also, user records should be stored in a database. Since there are a large number of tools designed to view and work with data stored in relational databases such as MySQL, this affords transparency and flexibility.
... less
In the last chapter you saw what’s necessary to put a user registration and account login system in place and came... more
In the last chapter you saw what’s necessary to put a user registration and account login system in place and came away with two pieces of reusable code: the User class and the 401.php include. In this chapter you’ll see how they can be used as part of a larger project as you build a community forum. I’ll also show you how to easily restrict different activities users can perform by incorporating permissions.
User
401.php
What you create in this chapter will not be a full-featured forum product capable of competing with other popular software available freely such as phpBB and Invision Power Board or commercially such as vBulletin. It’s a basic foundation you can build on to create a custom forum expressly tailored to your needs.
Email is one of the oldest and most prolific members of the Internet family. In fact, some estimates show over 60 billion... more
Email is one of the oldest and most prolific members of the Internet family. In fact, some estimates show over 60 billion email messages are sent every day… an estimate that I suspect is somewhat on the conservative side! Email is used by business executives to schedule meetings and close deals, by grandparents to share digital photos of their grandchildren, and by students to exchange class notes and homework assignments. There’s no denying people have found email to be a great way to exchange ideas and information regardless of whatever the exact number is.
In this chapter you’ll build an email-driven discussion list powered by PHP. The finished project is a basic implementation that you can tailor to your specific needs. Perhaps more importantly, you will come away with reusable code to connect to a POP3 server and an understanding of how PHP scripts can be run outside of the realm of web pages.
The amount of information available online today is absolutely mind-boggling. It’s no wonder why so many of us have... more
The amount of information available online today is absolutely mind-boggling. It’s no wonder why so many of us have become dependant on search engines such as Google and Yahoo! to help us find what we’re looking for. We just type in some terms and click a button and seemingly, as if by magic, the desired results appear. It’s doubtful, however, that many of us have stopped to think about what happens behind the scenes when we click that search button.
In this chapter, I will guide you through building a basic search engine, which you can implement on your own web site. The results of this project won’t make you the next Yahoo! or Google, but it serves two goals: Help visitors quickly find the information they’re looking for on your site and give you some important insight into how search engines work in the process.
Calendars are probably one of the greatest organizational inventions of all time. Although all of them serve the same... more
Calendars are probably one of the greatest organizational inventions of all time. Although all of them serve the same functionorganize and present temporal information in a grid-like fashioncalendars can come in many different styles. The most common style displays the 28 to 31 days of a given month, but some special calendars show an entire year, a given week laid out by day, or even a day broken down by hour.
Calendars have found use on the Internet as well, often as a means of navigation. For example, blogs will often show a calendar listing the dates in a month when posts were made. By clicking a date you are redirected to a page where you can view events on that date.
Navigation aside, calendars are ultimately useful for keeping appointments, notes, meetings, and so on organized so people don’t forget the events. Like most people, I use my calendar to help me remember important dates and appointments, sometimes many months in advance.
In this chapter, you’ll design a web-based calendar application to help keep yourself organized.
A file manager allows a user to do exactly what its name impliesmanage files. All graphical desktop systems come... more
A file manager allows a user to do exactly what its name impliesmanage files. All graphical desktop systems come with some type of file manager. In fact, you’re probably familiar with some of the well-known managers such as Microsoft Explorer on the Windows platform, Finder on Mac OS X, and the open-source Konqueror and Nautilus on Linux. These may not be very flashy and exciting programs, but they do help people perform essential file-related tasks never-the-less. Users quickly grow accustomed to their system’s file manager and using it quickly becomes second nature.
However, the same user who feels comfortable managing local files on his or her machine might feel uneasy downloading a new program to do the same tasks on a remote server. I doubt photo-sharing web sites like Flickr would be as popular as they are if the only way members could upload photos was by using an FTP client. Instead, sites often offer a variety of ways to transfer and manage filesone of which is a web-based file manager.
In this chapter, you will build a web-based file manager that will allow users to transfer files between the server and their computers. Users will also be able to rename and delete files and create, rename, and delete directories. The utility can be integrated into your web site to offer people more flexibility in how they manage their remote files.
Digital photography has become commonplace today. Many people snap pictures and upload them from the camera to their home... more
Digital photography has become commonplace today. Many people snap pictures and upload them from the camera to their home computers. Some cameras even capture short movie clips saved in the Apple QuickTime file format (MOV). These pictures and videos are then shared with friends and family. In this chapter you will build the front end to a basic online photo album to collect and share these memories.
The Internet started out in the late 1960s as a government research project to link computers together in a robust network.... more
The Internet started out in the late 1960s as a government research project to link computers together in a robust network. As it evolved from this packet-switching experiment to a functional network capable of transferring information between computer systems, it became an important tool in academia. Mosaic, one of the first web browsers that was released in 1993, changed the face of the Internet forever by making the World Wide Web accessible to the ordinary person. Forward-thinking businessmen saw great potential in this new and growing medium and started advertising and selling their wares online.
The term e-commerce was coined to denote such electronic commerce that takes place over the Internet. E-commerce still flourishes even though the face of the Internet has changed many times over since its early days as new technologies and applications emerge. Over the past decade or so, consumer confidence has continued to rise and more and more people are making purchases online.
The shopping cart has come to be the ubiquitous e-commerce application, so in this chapter you’ll write your own shopping cart around which you can build up an e-commerce website.
People like to collect access statistics for different reasons. Perhaps you’ve been asked by a supervisor to prepare... more
People like to collect access statistics for different reasons. Perhaps you’ve been asked by a supervisor to prepare a report showing the traffic your company’s web site receives, or maybe you’re just curious yourself as to how many people are visiting. People like to see if their site is growing in popularity. Aside from satisfying curiosity though, statistics can be used to make informed business decisions as well. Such reports can be correlated against times when new promotions were rolled out and show whether visits increase because of them. They can even provide a snapshot of a site’s state of health by showing how popular certain pages are compared to others in the site. Tracking can even be mandated by policy for a variety of reasons.
In this chapter, you’ll collect and analyze page hits to generate a web site statistic report. Such reports can be used to better understand the effectiveness of a site and to make better business decisions.
The word blog comes from a shortening of web log and since its inception, it has become synonymous with any type of... more
The word blog comes from a shortening of web log and since its inception, it has become synonymous with any type of online journal. A bloggersomeone who authors the blogposts his or her ideas or experiences and invites readers to leave comments starting a dialog around a certain topic. Few of us predicted the popularity and impact blogs would have on the web; writing blogs is an activity that has swept the Web by storm so much that few of us can recall what the Web was like before they appeared. You can find all sorts of blogs ranging from “a day in the life” type recounts to huge to pundit comments which become the impetus for political action.
With its comment feature disabled, a blog is suitable as a news system. Posts can let visitors know what’s going on behinds the scenes at the web site or summarize changes that have recently been made to the site’s content.
In this chapter, you will build a basic blog system. It will have an administrative page to allow the blog author to create new, modify and delete existing posts. A JavaScript-powered rich text edit control will be integrated so the author can easily format the entry. Visitors, however, need only be allowed to post plain text comments (although if you wanted you could just as easily allow them to format comments using BBCode mark up as discussed in Chapter 2). The system should also automatically generate an RSS feed showing the most recent posts so visitors can subscribe to the blog.
The mailing list project presented in Chapter 3 demonstrate how PHP can be used for more than just generating web pages.... more
The mailing list project presented in Chapter 3 demonstrate how PHP can be used for more than just generating web pages. Certainly that is the area where PHP shines the brightest, but PHP really is a capable language flexible enough for tackling most any programming task. In this chapter, I will discuss using PHP to write shell scripts.
The impetus for this project comes from the realization that many applications share the same basic layout. For example, the directory structure and shared code files first discussed in Chapter 1 have appeared in other projects throughout the entire book. Directories such as lib, public_files and sql keep the project organized and shared code such as common.php and db.php provide the project’s configuration.
lib
public_files
sql
common.php
db.php
The Rails framework that has gained widespread acceptance in the Ruby programming community and really put Ruby on the map offers more functionality than just setting up a common skeleton for a project, but this is often the first service it performs for the developer. Similarly, Django initially assists a Python programmer to create an application structure. Sure your’re using PHP, but there’s no reason why you can’t “borrow” good ideas just because it’s not the same language.
So in this chapter, you will be writing a shell script to help set up a well organized directory layout and copy basic code files into it to start a new application. It will run from the command line and prompt the developer for important values such as the database connection information and use them to fill in the relevant parts of the shared code. Along the way you will code a library useful for writing future shell scripts to assist reading in user input.
I’ve reserved this last chapter to discuss the topics of security and logging. The applications you write are obviously... more
I’ve reserved this last chapter to discuss the topics of security and logging. The applications you write are obviously intended to be used by others. Rarely do they exist in a vacuum and as such it is important to understand the security issues that face all PHP developers.
The aim of security is to prevent the misuse of your application in a way that could compromise data or even the system itself and minimize the effects if such a compromise were to happen. Logging can help support this by tracking usage and changes.
This chapter is a bit different from the previous ones in that I won’t provide you with much reusable code in this chapter. Instead, I offer you the background necessary to develop your own. In this chapter you will gain an understanding of the following:
Cross-site scripting (XSS)
Path traversal
Injection
Weak authentication
You will also learn how to prevent accidental deletion of records in a database and conveniently log INSERT, UPDATE and DELETE queries.
INSERT
UPDATE
DELETE
Just because this chapter has been placed last in the book, don’t think that security should be treated as an after-thought. Good programmers can protect their applications by keeping security in mind at all times.
Purchase Before purchasing this product, please be sure you have met all software and system requirements, and that you understand any limits placed upon its use.
Return Policy Wrox Chapters on Demand are non-returnable and non-refundable.
Reader Software Wrox Chapters on Demand are offered as PDFs, and they must be viewed using the Adobe Reader. If you do not have the Reader installed, it can be downloaded for free at Adobe.com.
Test Download As Wrox Chapters on Demand purchases are non-returnable, it is advisable that you test your system and software configurations with a free sample download before you place an order.
Usage Rights for a Wrox Chapter on Demand File Any Wrox Chapter on Demand product you purchase from this site will come with certain restrictions that allow Wiley to protect the copyrights of its products. After you purchase and download this title, you:
If you have any questions about these restrictions, you may contact Customer Care at (877) 762-2974 (8 a.m. - 5 p.m. EST, Monday - Friday). If you have any issues related to Technical Support, please contact us at 800-762-2974 (United States only) or 317-572-3994 (International) 8 a.m. - 8 p.m. EST, Monday - Friday).
Related Books