Home > Articles > Web Development

How Joomla! Works

From the Rough Cut

From the Rough Cut

Web Programming vs. "Normal" Programming

Web Programming vs. "Normal" Programming

Two important factors distinguish dynamic web programing, like we see in Joomla, from what we'll call "normal" programming, like a typical desktop application such as a spreadsheet program. These have to do with how the state of the program is maintained and what type of command validation is required.

Maintaining the State of the Program

The first difference is how the state of the program is maintained during the execution of the program. By state, we mean what the program knows about itself and it's environment as stored in the working memory of the computer. We can think of state as a software program's version of consciousness – it's awareness of who it is and what has been going on. Let's compare how a desktop spreadsheet program works with how Joomla works with respect to how it maintains state.

Let's illustrate this by thinking of our software programs as Aladdin with his magic lamp. Imagine that, when we issue a software command, inside the computer Aladdin is actually getting a software genie to do the work. The important difference is that the spreadsheet genie is happy to do as many wishes as we like. By contrast, the Joomla genie only grants one wish each time.

With our spreadsheet program, the first thing we do is load the software by clicking on a desktop icon. Aladdin sees this and rubs the lamp to make the genie appear. The genie comes out of the lamp and Aladdin commands "Display the spreadsheet software on the user's screen!". The genie does this and awaits Aladdin's next command.

Next, we tell the software to open the "budget" file. Aladdin transmits this command to the genie and the file is opened. This process continues until we close the program. At this time, Aladdin tells the genie "You are no longer needed. Go back into the lamp!", and the spreadsheet genie disappears back into the lamp.

Now let's see how this works with Aladdin and the Joomla genie. We start the process by loading the URL for our home page into our browser. Aladdin sees this and rubs the lamp. The Joomla genie appears and Aladdin commands "Display the URL!". The genie does his magic and our home page shows in the browser. However, since the Joomla genie only does one command at a time, he immediately disappears back into the bottle!

Now, we click on a menu item in the home page to display the "Parks" article. Aladdin has to rub the lamp again, and again the genie appears. Aladdin commands "Load the "Parks" article!". The genie loads the new page into the browser and then immediately disappears back in the lamp.

This process continues until eventually we close down the browser or navigate out of the Joomla site. At that time, Aladdin doesn't have to do anything, since the genie is already back in the lamp. This is very important. With web programming, we can't rely on the user to nicely close down the program. Fortunately, we don't need to.

The tables below show these examples step by step. (Note to editor: It might be very cool to show these as cartoon strips with illustrations.)

User

Aladdin

Spreadsheet Genie

Clicks spreadsheet icon

Rubs lamp and says "Open the spreadsheet program!"

Comes out of the lamp, opens the spreadsheet program, and awaits next command.

Selects the "budget-1" file to open.

Tells genie "Open the "budget-1" file!"

Opens the file and waits.

Issues more commands.

Transmits commands to genie.

Executes each command and waits.

Selects the exit command.

"Close the program and return to the lamp!"

Closes the program and disappears back into the lamp.

Figure 15: Command Sequence with Spreadsheet Genie

User

Aladdin

Joomla Genie

Enters home page URL into browser

Rubs lamp and tells genie "Load the home page URL!"

Comes out of the lamp, displays the URL in the browser, and disappears back into the lamp.

Clicks on the Parks article link.

Rubs the lamp and tells genie "Open the Parks article!".

Comes out of the lamp, opens the file, and goes back into the lamp.

Issues more commands.

Rubs lamp and transmits each command to genie.

Comes out of the lamp, executes each command, and goes back into the lamp.

Closes the browser.

No action needed.

No action needed.

Figure 16: Command Sequence with Joomla Genie

With a web program like Joomla, each time you click a link or a form submit button, you are starting what we call a new request or command cycle. The URL, any form data, and other information related to the request is packages up by the browser and sent to the web server.

With Joomla (or any other web program), nothing is remembered in the computer's working memory between request cycles. Each cycle has to start over to create all of the program objects. The Joomla genie starts from scratch each time.

Given this, how does the Joomla genie "remember" important information from one request cycle to the next? For example, he needs to know who the user is, so he can check what actions he is allowed to do. If his mind is a complete blank at the start of each cycle, how can he do this?

The answer is that we have several ways to store data across cycles. The most common one is the session variable. This is maintained on the server and is specific to the user for this session. It is stored on the server's disk and is available to Joomla. Normally, the session file is automatically deleted or disabled after a period of inactivity (for example, 15 minutes). From the session, for example, the Joomla genie can identify the current user without requiring that the user log in each time. It can also "remember" where the user was in the last command cycle, what options the user might have entered (for example, how a column was sorted in a screen).

The database is another way to save information from one command cycle to the next. It is updated as we make changes to the site, for example, by adding articles or other component items, or by changing our user profile. When we access the database in future cycles, we will see the updated information.

Using the session and the database allows Joomla to find information from previous command cycles. This allows the user to experience the different command cycles as a continuous program flow. However, it is important to keep in mind that each request cycle has to stand alone. We will see as we go along that this has important consequences for how things are done in the code.

Controlling and Checking the Commands

There is another difference between these two types of programming that has important consequences for security. With a self-contained desktop program, all of the possible commands are typically predefined in the program. Commands are typically entered via a mouse click from a list. Even if commands can be typed in directly, they are normally validated against a fixed list of possible commands and an error shows if the command is not valid.

With a web program like Joomla, we have two challenges that a desktop program normally doesn't have. First of all, we are exposing our site to the entire on-line world, which unfortunately includes people with bad intentions. We have to expect that someone will try to "hack" our web site. This could include someone trying to steal our administrative password, to deface the site (perhaps by putting in their own file for one of ours), or to try to bring the site down by altering the database. We need to practice defensive programming to guard against this.

The second challenge is that we cannot control or limit the the commands that come in as part of the request. Normally, the command will be a combination of a URL and possibly some field values from an HTML form. Most users will enter commands simply by clicking a link or a form submit button and will therefore always enter valid commands.

It is possible, however, that a user has deliberately entered a command to try to do something that they shouldn't do, for example by manually typing in a URL or altering the HTML form inside their browser. Unfortunately, there is no way for the web server to tell whether a user has clicked a link or manually entered in a URL. Likewise, there is no across-the-board way to tell whether a user has simply filled out the form and pressed submit or whether they have modified the form to submit some malicious data.

To be safe, we must always assume that commands coming in with the request could be designed to attack or hack the site and we must examine them accordingly before we execute them.

We will talk more about security and defensive programming as we go along. However, the subject is important enough to warrant an example now to illustrate the point.

Let's say we have a simple comments system where users can enter comments about articles. We let anyone submit a comment, but we only allow authorized users to approve comments. A comment is not shown on the site unless it is approved, so we protect against inappropriate comments being shown on the site.

For this example, we have two fields, the comment and whether or not it is approved. We might implement this as follows. When we display the form, we check if a user is authorized or not. If they are, we show the form like this:

Figure 17: Example Comments Form

Before we show the form, we check whether the current user is authorized to approve the comments. If they are not authorized, we simply omit the Approved field on the form and only show the Comment field. So unauthorized users will never see the Approved field and therefore won't be able to check the box.

Now, we might think that, with this design, we have prevented unauthorized users from approving comments. But we have not. Someone with knowledge about how the application works could very easily use a program like Firebug or Web Developer to edit the HTML on the page to include the missing Approved field and set its value to approved. Then, when the form is submitted, it would be approved as if the user was authorized. The web server doesn't know whether the form was altered before the submit button was pressed. It just sees the form data in the request information.

So, this design has a serious security hole. How can we fix it?

One way would be to add a check before the database is updated. Even though normally a non-authorized user would not submit the form with the approved field set to yes, we would nevertheless check this again before posting the comment to the database. In this example, before we update the database we would test that the user is authorized. If not, we would always set the Approved to "No" and then save the data. That way, even if an unauthorized user adds the approved field to the form, the invalid data won't get saved in the database, so no harm will be done.

We will discuss other examples of security issues and how to fix them as we go along.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020