Internet Methodologies Journal And News

Let's explore internet with imran

CURL PHP: Email this page to a friend

Using curl to take snapshots of the current page for emailing the HTML is a clever little idea. (ie: Email this page to a friend)

<?php
//to be explained below!
session_write_close();

$pageurl = "http://www.site.com/content.php?PHPSESSID=123XYZ
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ch, CURLOPT_URL, $pageurl );
$html = curl_exec ( $ch );
curl_close($ch);

//then you need to fix pathing to absolute
$search = "/(src|href|background)="[^:,^>,^\"]*\"/i";

preg_match_all ( $search, $html, $a_matches );

//you can figure out the rest ! but thought the reg expression is useful as well
?>

But here is the catch, you may want to make sure curl connects to the server under the same session as the browser. So naturally you pass the session cookie through the curl system either by the cookie jar system, or through the query string in the path.

This is where you will get stuck. PHP will need write access to the same session file simultaneously!! causing serious hanging issues!

This is why you should close off your session before you make curl take a page snapshot!

  • Share/Bookmark


How AJAX can Work for you

If you’ve been in the internet world for sometime, you might have bumped in the word AJAX. No, it’s not the European Soccer team but it’s a new web development tool that has been the craze for millions of web developers.

Every training center and computer schools are scrambling to learn this new software so that it can be offered in courses. Proficiency in this web technique means potential thousands of revenues.

If you’re just starting to learn some web programming techniques, better culminate them with AJAX. AJAX is short for Asynchronous JavaScript and XML. That sound’s really complicated and it really is. So that we will understand them let’s take a look at the first word: “asynchronous”.

Asynchronous in the computer world is something really revolutionary. Before AJAX, the page or the action will just load because of the communication of your computer to the server.

For example, when you click on menu, it will communicate with the server so that it will load the menu to your computer. That could cause some delay since there are so many things to consider. First, the server should be online; second, you should have a fast internet connection and third the possibility of serving more than one requests at the same time.

Imagine you have a good computer and very fast internet connection but you can’t really access the website because it can’t handle the number of requests at the same time. For the page to load, it will basically need the assistance of the server to make them work. But with “Asynchronous” it doesn’t need any action from the server once it has started. If you have a very fast PC, you don’t need to worry about the internet connection.

A simple broadband connection will be just enough to load the pages faster. If we’re just a regular internet surfer who just wanted to watch videos, this sounds very good. There will be online tools that will load faster so that we can watch the videos faster and better. Among the websites that are using AJAX right now is Google. You may notice that the homepage of Google is really fast to load no matter what your internet connection is. Yahoo is also following this trend.

Everyone now wants to have this technique in their websites to lift the burden from the servers and place it to the customers. Google is on top of this right now as it uses AJAX for their search engines, Google Maps, Google Earth, Gmail and other Google based applications.

As consumers, it could pose some threat especially to those who have poor computers and poor internet connection. But I think it’s not a reality right now. Most computers who can run Windows XP in their computer smoothly will have the ability to have the benefits of Google. This revolutionary technique is taking the world by storm. Even though you don’t know what exactly is happening in the internet, it surely is making things work smoothly for all of us.

  • Share/Bookmark


Why use Ajax and why not

Advantages to using AJAX

There are quite a few advantages to AJAX, but all of them center around the above point: usability. AJAX provides a way for the user to interact with a website without refreshing, and furthermore, without any browser plug-ins.

There’s currently a war going on, many people may be missing this, but it’s a war none the less. The war is between Adobe and Microsoft, namely Flash and Silverlight. These two technologies require the browser to have a “plug-in” in the browser, much like Java, in order to run their interactive applets. While this was a big thing in the 90s to get an interactive webpage, AJAX only requires a browser as it relies on the Javascript DOM which is present in all major browsers already. So, why develop an application that can only work on X% of the browser population, when it can work on 100%? Of course, this is a bit of a discussion because Flash has been put on almost all computers nowadays. I’ll leave that discussion alone.

The next advantage to AJAX is bandwidth saving. When an application uses AJAX to communicate with the server, only the required information is transmitted to/from the server instead of a full transmission, or “post back”, which would post the full contents of the HTML form back to the server. While bandwidth considerations are currently not a huge issue, it does help to save what you can.

Disadvantages of using AJAX

One big disadvantage of using AJAX is security. Often times developers do not put checks on the data coming into the server – they assume that it’s coming from their own website. Unfortunately, this is subject to injection attacks. Furthermore, there is several ways to “fake” how the data is coming in, making detection all but impossible.

  • Share/Bookmark


5 Disadvantages of AJAX

The disadvantages of AJAX are:

  • Search engines would not be able to index an AJAX application.
  • The server information can not be accessed within AJAX.
  • AJAX is not well integrated with any browser.
  • ActiveX requests are enabled only in IE 5 and IE6
  • Data of all requests is URL-encoded which increases the size of the request

  • Share/Bookmark


Advantages and Disadvantages of Ajax

While there are a number of advantages to using Ajax, there are also some disadvantages as well. One of the main reasons why people support it is the interface. Those who use pages with Ajax will find that they operate more like an application rather than a standalone program. With normal web pages, users will have to click on a link if they wish to refresh the page.

This can become tedious and inefficient. With Ajax, the page can be refreshed dynamically. The response of the interface to the actions of the user is much faster. Even though Ajax has not yet reached its full capabilities, it is easy to see what is is capable of.

Another issue that surrounds Ajax is the use of bandwidth. When HTML is generated within a browser via JavaScript, the Ajax pages can seem to load much faster. The reason for this is because the payload is much smaller. One example of this is a set in which numerous pages exist. When Ajax is used, the table structure connected to TD can be produced in a browser, and it doesn’t have to be initiated with the first part of the document. It should also be noted that some web applications will load pieces of event handlers as the program operates. This technique is useful because it reduces the demand for bandwidth. Since more applications have become complex, this is an issue that must be addressed in the future.

The separation of data and formats is also important. When Ajax is used, it allows programmers to make a separation between the methods and formats they use to deliver information via the Internet. While many people simply consider Ajax to be a bundle of languages when they first encounter it, it is the development process that makes it so popular. Some of the things that will be separated are the content that will be placed within XML, and the structure of the web page. In addition to this, the style elements of the page will also be taken into consideration. This is important because it allows the web applications to be much more efficient.

At the same time, there are a number of disadvantages to Ajax. These disadvantages must be overcome if the technique is to be a success. One of the biggest problems is the integration of browsers. The page that is dynamically created will not automatically register with the history engine of the browser, so pressing the “back” button might now allow them to get what they want. There are a number of solutions that developers have used for this problem. They may sometimes use IFRAMEs that are invisible to create changes that will be connected to the history of the “back” browser button.

One good example of a system that uses invisible IFRAMEs is Google Maps. Once they perform a search using this system, the results will be pulled back into an element that may be visible to the user. It should be noted that the World Wide Web Consortium prefers to use objects rather than iframes. Another problem that Ajax developers are having is bookmarks. When Ajax is used, it is hard for the user to bookmark the state of the web page. There are a number of solutions that have been proposed for this problem, and some utilize the URL fragment identifier. This will allow the users to return to the web page or application at any state.

While the URL fragment identifier has been useful in solving many of these problems, it is not a complete answer. Another area in which problems have occured with Ajax are response time issues. The latency within networks must be heavily considered when developers are building applications with Ajax. If there is not feedback to the user that is clear, the user may see a delay within the interface of the web program. When they first encounter this, they may not undestand the situation. When a whole page is rendered, there is a short time in which the content on the page will be altered. If there is not re-adjustment will the small parts of the screen, latency will become obvious to the user. Ajax developers are working with a number of solutions to alleviate these problems.

  • Share/Bookmark


About Ajax !

AJAX is a term used to describe an approach to designing and implementing web applications. It is an acronym for Asynchronous JavaScript and XML. The term was first introduced in an article by Jesse James Garrett of Adaptive Path, a web-design firm based out of San Francisco. He conceived of the term when he realized the need for an easy, sellable way to pitch a certain style of design and building to clients.

The primary purpose of AJAX is to help make web applications function more like desktop applications. HyperText Markup Language (HTML), the language that drives the World-Wide Web, was designed around the idea of hypertext – pages of text that could be linked within themselves to other documents. For HTML to function, most actions that an end-user takes in his or her browser send a request back to the web server. The server then processes that request, perhaps sends out further requests, and eventually responds with whatever the user requested.

While this approach may have worked well in the early days of the Internet, for modern web applications, the constant waiting between clicks is frustrating for users and serves to dampen the entire experience. Users have become accustomed to blazing-fast responses in their desktop applications and are unhappy when a website can’t offer the same immediate response. By adding an additional layer between the user interface and the communication with the server, AJAX applications remove a great deal of the lag between user interaction and application response. As AJAX becomes more common in popular web applications, users become more and more accustomed to this immediate response, helping to drive more businesses to adopt AJAX methodologies.

An AJAX application consists of a number of applications used in conjunction to create a more seamless experience. This includes Extensible HTML (XHTML) and Cascading Style Sheets (CSS) for building the underlying page structure and its visual style, respectively; some sort of interaction suite using the Document Object Model; data manipulation using Extensible Markup Language (XML); data retrieval using XMLHttpRequest; and JavaScript to help these different elements interact with one another. AJAX is spreading quickly throughout the web, with examples visible at many major sites. Google Maps, for example, in many ways epitomizes the ethos of the AJAX model, with its complex functionality and virtually seamless interactivity.

Like most emerging philosophies of web development, AJAX has its share of detractors. One commonly leveled argument against AJAX is that in many cases it breaks some expected functionality, such as the use of the Back button, causing confusion. While some fixes exist for many of these breaks, they are rarely implemented to the extent that the behavior of an AJAX application conforms to the expected behavior of the larger browser.

  • Share/Bookmark


What is Ajax?

What is Ajax?

Ajax is a way of developing Web applications that combines:

In the traditional Web application, the interaction between the customer and the server goes like this:

  1. Customer accesses Web application
  2. Server processes request and sends data to the browser while the customer waits
  3. Customer clicks on a link or interacts with the application
  4. Server processes request and sends data back to the browser while the customer waits
  5. etc….

There is a lot of customer waiting.

Ajax

Ajax Acts as an Intermediary

The Ajax engine works within the Web browser (through JavaScript and the DOM) to render the Web application and handle any requests that the customer might have of the Web server. The beauty of it is that because the Ajax engine is handling the requests, it can hold most information in the engine itself, while allowing the interaction with the application and the customer to happen asynchronously and independently of any interaction with the server.

Asynchronous

This is the key. In standard Web applications, the interaction between the customer and the server is synchronous. This means that one has to happen after the other. If a customer clicks a link, the request is sent to the server, which then sends the results back.

With Ajax, the JavaScript that is loaded when the page loads handles most of the basic tasks such as data validation and manipulation, as well as display rendering the Ajax engine handles without a trip to the server. At the same time that it is making display changes for the customer, it is sending data back and forth to the server. But the data transfer is not dependent upon actions of the customer.

Ajax is Not New Technology

Ajax is instead a new way of looking at technology that is already mature and stable. If you’re designing Web applications right now, why aren’t you using Ajax? Your customers will thank you, and frankly, it’s just fun!

  • Share/Bookmark


How many values can the SET function of MySQL take?

MySQL set can take zero or more values but at the maximum it can

  • Share/Bookmark


Explain the difference between BOOL, TINYINT and BIT

Prior to MySQL 5.0.3: those are all synonyms.

After MySQL 5.0.3: BIT data type can store 8 bytes of data and should be used for binary data.

  • Share/Bookmark