Monday, November 30, 2009

How to convince a potential client?

If you want to use PHP in your company and your manager favours another solution, or if you are trying to convince a potential client that PHP really is a superior choice for the web, you're going to need to have a clear-cut set of reasons why you believe PHP is the superior language. This short list should help you get started:
  • PHP is cross-platform. It can run on Windows, Linux, BSD, Mac OS X, and Solaris, as well as a variety of other platforms.
  • PHP is free. You can download the source code, use it, and even make changes to it without ever having to pay any licensing costs. You can even give away your own modified version of PHP.
  • PHP is fast. In the majority of scripts beyond basic benchmarks, PHP will easily compete with both Perl and Python, and usually match Microsoft's ASP.NET. Add to that the fact that PHP code can be cached for execution, and PHP's performance is first-class.
  • PHP is capable and reliable. There are thousands of pre-written functions to perform a wide variety of helpful tasks - handling databases of all sorts (MySQL, Oracle, MS SQL, PostgreSQL, and many others), file uploads, FTP, email, graphical interfaces, generating Flash movies, and more. It is already running on millions of servers around the world making it reliable in most demanding situations
  • PHP is extendable. Writing your own extension to PHP is a common and easy way to implement speed-critical functionality, and PHP's extension API is a particularly rich and flexible system.
  • PHP is easy to debug. There are a number of debuggers, both commercial and freeware, that make debugging PHP a snap.
  • PHP is advancing. With the release of PHP 5, PHP has introduced features that have long been waited for, including more comprehensive error handling, better object orientation, and, of course, more speed.

The base of the PHP language is very simple, having just enough to set and retrieve variables, work with loops, and check whether a statement is true or not. The real power behind PHP comes with its extensions - add-ons to the base language that give it more flexibility. There are hundreds of extensions to PHP, and they can be broken down into five distinct types: core, bundled, PECL, third party, and DIY.
  • Core extensions are extensions that are bundled with PHP itself, and enabled by default. For all intents and purposes they are part of the base language, because, unless you explicitly disable them (few people do, and sometimes you cannot), they are available inside PHP. For example, the mechanism to handle reading and saving files in PHP is actually handled by an extension that is automatically compiled into PHP.
  • Bundled extensions are extensions that are bundled with PHP, but not enabled by default. These are commonly used, which is why they are bundled, but they are not available to you unless you specifically enable them. For example, the mechanism to handle graphics creation and editing is handled by an extension that is bundled with PHP, but not enabled by default.
  • PECL(pronounced "pickle") stands for "PHP Extension Community Library", and is as a subset of the PHP Extension and Application Repository, PEAR.
  • Third-party extensions are written by programmers who wanted to solve a particular problem that was unsolvable without them creating a new extension. There is a variety of third-party extensions available out there.
  • Finally, Do-It-Yourself (DIY) extensions are simply extensions you created yourself. PHP has a remarkably rich extension creation system that makes it quite simple to add your own code as long as you know C.

Monday, November 16, 2009

Technologies of Web2.0

Next we will examine some of the technological components commonly employed by many Web 2.0 companies when developing and delivering applications. They are also highly portable and can scale very well on commodity-based hardware platforms. Some shared characteristics which make their use appealing to Web 2.0 developers is that they are all free, open source, highly interoperable and perfect for use with dynamic database-backed websites and applications.

The Benefits of Open Source

As mentioned, many of the components that Web 2.0 companies rely on to deliver their applications and services are built on open source components. There are a couple of key benefits that are derived by these companies leveraging software components which are open source in nature.
  • Lower Total Cost of Ownership. This enables lower up front and long-term costs associated with the development, delivery and execution of new business models.
  • Component & Application Freedom: Choosing open source software prevents vendor lock in to specific hardware or software stacks. This high degree of interoperability across hardware and software platforms can also be leveraged against the abundance of tools and applications for use throughout the development cycle, from design and modeling, to testing, versioning and day to day operations management.

LAMP:

Fortunately, there is a proven open source stack which has been consistently leveraged by companies big and small to deliver scalable, cost effective, and interoperable applications. This has been achieved by leveraging the tight integration of Linux – Operating System, Apache – Web Server, MySQL – Database, PHP Programming & Scripting.

Support:

Support for open source components can usually be obtained at no cost from a community of users and developers. It can also be purchased in the form of professional consulting and technical support, which is available by most of the open source vendors, as well as from both large and small ISVs.

Linux

Linux is a Unix-like operating system which is free and open source. All of the source code is available for anyone to use, modify and redistribute. This is in contrast to proprietary operating systems like Windows. Linux has been around since the early 1990’s and has at this point become the fastest growing operating system in the world. Much of this success can be attributed to the fact it is a low-cost, secure, scalable and highly interoperable alternative to proprietary operating systems. Linux can be found running on everything from hand-held devices to hardware components, desktop computers to massive computing clusters. All of these characteristics make it an excellent choice for Web 2.0 applications.

Linux shares a long tradition of compatibility with MySQL and other open source components by serving as the operating system component of the LAMP (Linux, Apache, MySQL, & PHP) technology stack.

Apache

The Apache HTTP Server Project is an open-source Web server. It is known for being secure, highly portable across many operating systems, efficient in utilizing resources and extensible. According to a Web Survey, the Apache Web Server continues to be the world’s most popular web server with over 70% of websites leveraging it within their technology stacks. Apache has been extend with compiled modules for interfacing with Perl, Python and PHP.

MySQL

Within the LAMP stack, MySQL comprises the database component. The database component serves as the critical piece of software which manages the data leveraged by the applications and web servers. MySQL is a multithreaded, multi-user, SQL Database Management System (DBMS) with over six million installations. MySQL is the database of choice for consistently delivering lower TCO, reliability, performance and ease of use.

Many of the largest and fasting growing Web 2.0 companies are designing,developing and going into production using MySQL. As their needs grow in terms of capacity, availability and performance, MySQL continues to assist in satisfying these requirements.

PHP

PHP comprise the dynamic programming and scripting language components of the LAMP stack. PHP Hypertext Preprocessor or simply, PHP, is an open-source language for producing dynamic web content mainly in server-side applications. PHP typically runs on a web server, using PHP code as its input and rendering Web pages as output. PHP is a very popular server-side alternative to Microsoft’s ASP.NET and Adobe’s ColdFusion. PHP works extremely well with all the components within the LAMP stack. According to php.net, it is estimated that over 20 million domains on the internet make use of the language.

Ajax

Asynchronous Javascript and XML or Ajax is it is more commonly known, is a development technique for creating rich, visual appealing and interactive web applications. Web pages which leverage Ajax are more responsive because they exchange smaller amounts of data with the web server. This means that the entire web page does not have to be “refreshed” or completely reloaded in user’s browser after each interaction. This results in web pages which have increased interactivity, speed and usability. These are all key components to help Web 2.0 companies deliver applications which are highly interactive and deliver rich end user experiences which rival those of desktop applications. For these reasons, Ajax is already being widely leveraged in both consumer and business applications.
The core components of the Ajax technique include:
  • XHTML (or HTML) and CSS leveraged for mark up and style information.
  • The description of how an HTML or XML document is represented in a tree structure (otherwise known as DOM), is accessed with a client-side scripting language, usually JavaScript.
  • The XMLHttpRequest object is used to exchange data asynchronously with the web server.
  • XML as the format to transfer data between the server and client.

memcached

memcachced is a popular open source distributed memory caching system originally developed by Danga Interactive for the blogging website LiveJournal. It is traditionally leveraged to enhance the performance and responsiveness of dynamic content websites backed by databases. This is achieved by caching data and objects in memory, thereby reducing the amount of data that needs to be read from the database. The performance characteristics it can deliver are faster page loading for users, more efficient resource utilization, and faster database access times in the event of a memcached miss.

In more technical detail, memcached acts as a large hash table, caching data as it is being requested by clients. Although it was originally designed to improve the performance of database queries, it has been extended to cache server-side objects as well. In essence, any operation which is resource or time intensive can benefit from the use of memcached. It goes without saying that this technology is of great advantage to Web 2.0 applications, who by definition are very dynamic and data driven. This is in contrast to the static non-interactive web sites characteristic of the early years of the Web.

Many websites who make use of memcached, such as LiveJournal, Slashdot and Wikipedia, also make use of MySQL.

Monday, November 2, 2009

Webmaster Tools - website verification

If you use Webmaster Tools, you're probably familiar with verifying ownership of your sites. Simply add a specific meta tag or file to your site, click a button, and you're a verified owner. Some websites and software have features that help you verify ownership by adding the meta tag or file for you. Google recently made a few small improvements to the process that google think will make it easier and more reliable for you.

The first change is an improvement to the meta tag verification method. In the past, your verification meta tag was partially based on the email address of your Google Account. That meant that if you changed the email address in your account settings, your meta tags would also change (and you'd become unverified for any sites you had used the old tag on). Now Google created a new version of the verification meta tag which is unrelated to your email address. Once you verify with a new meta tag, you'll never become unverified by changing your email address.

Google also revamped the HTML file verification. Previously, if your website returned an HTTP status code other than 404 for non-existent URLs, you would be unable to use the file verification method. A properly configured web server will return 404 for non-existent URLs, but it turns out that a lot of sites have problems with this requirement. Now Google have simplified the file verification process to eliminate the checks for non-existent URLs. Now, you just download the HTML file from the webmaster tools section and upload it to your site without modification. Google will check the contents of the file, and if they're correct, you're done.

If you've already verified using the old methods, don't worry! Your existing verifications will continue to work. These changes only affect new verifications.

In future, Google will begin showing the email addresses of all verified owners of a given site to the other verified owners of that site. However, if you're using an email address you wouldn't want the other owners of your site to see, now might be a good time to change it.

For complete details, visit Google Webmaster Central Blog

Monday, October 26, 2009

AJAX based sites crawlable

As a SEO person, i always find it difficult to do search engine optimization for AJAX based sites. Today google proposal comes as blessing when Google proposes to make AJAX based sites crawlable. While AJAX-based websites are popular with users, search engines are not able to access any of the content on them

Here's how search engines would crawl and index AJAX based sites:

Slightly modify the URL fragments for stateful AJAX pages

Stateful AJAX pages display the same content whenever accessed directly. These are pages that could be referred to in search results. Instead of a URL like http://example.com/page?query#state we would like to propose adding a token to make it possible to recognize these URLs: http://example.com/page?query#[FRAGMENTTOKEN]state . Based on a review of current URLs on the web, we propose using "!" (an exclamation point) as the token for this. The proposed URL that could be shown in search results would then be: http://example.com/page?query#!state.

Use a headless browser that outputs an HTML snapshot on your web server

The headless browser is used to access the AJAX page and generates HTML code based on the final state in the browser. Only specially tagged URLs are passed to the headless browser for processing. By doing this on the server side, the website owner is in control of the HTML code that is generated and can easily verify that all JavaScript is executed correctly. An example of such a browser is HtmlUnit, an open-sourced "GUI-less browser for Java programs.

Allow search engine crawlers to access these URLs by escaping the state

As URL fragments are never sent with requests to servers, it's necessary to slightly modify the URL used to access the page. At the same time, this tells the server to use the headless browser to generate HTML code instead of returning a page with JavaScript. Other, existing URLs - such as those used by the user - would be processed normally, bypassing the headless browser. We propose escaping the state information and adding it to the query parameters with a token. Using the previous example, one such URL would be http://example.com/page?query&[QUERYTOKEN]=state . Based on our analysis of current URLs on the web, we propose using "_escaped_fragment_" as the token. The proposed URL would then become http://example.com/page?query&_escaped_fragment_=state

Show the original URL to users in the search results

To improve the user experience, it makes sense to refer users directly to the AJAX-based pages. This can be achieved by showing the original URL (such as http://example.com/page?query#!state from our example above) in the search results. Search engines can check that the indexable text returned to Googlebot is the same or a subset of the text that is returned to users.



For complete proposal, visit Google webmaster central blog

Sunday, October 18, 2009

What is web2.0?

The Internet continues to evolve at an accelerated rate, with new technological innovations being introduced all the time. This is constantly forcing us to rethink not only how we currently use the web, but also in what new possibilities lie in the future. The rapid adoption in which these new technologies and services are being integrated into our lives, are dramatically changing the way we communicate, socialize, share and locate information, entertain ourselves and shop for goods and services. This rapidly evolving landscape of “next generation” technologies and companies, are being categorized as Web 2.0.

Because these applications predominately “live” online, a strong collaborative and collective nature is being harnessed. Where the web was once a static and passively consumed experience, it is now dynamic, transactional and interactive, where participation is not optional, it is mandatory.

It is no surprise a common characteristic of many Web 2.0 websites, applications and companies, is their use of the LAMP (Linux, Apache, MySQL, PHP) open source stack. This allows fast-growing sites to deliver performance, scalability and reliability to millions of users. MySQL enables up-and-coming Web 2.0 sites like Wikipedia, FeedBurner and digg, - as well as established web properties like Craigslist, Google and Yahoo! - to scale out and meet the ever-increasing volume of users, transactions and data.

What is Web 2.0?

Web 2.0 can generally be thought of as the technologies and web sites who leverage users and developers in a socially collaborative manner in order to rapidly develop data and applications with a high level of integration across platforms and other services.

The term Web 2.0 was first coined back in 2004 during a brainstorming session between Tim O’Reilly of O’Reilly Media and MediaLive International, a company which puts on technology tradeshows. The term was originally intended for use as the name to describe an upcoming conference showcasing new web-based companies and technologies that had emerged post dot-com bubble. The term “Web 2.0” has since been dismissed as a marketing buzzword, co-opted and validated several times over by various individuals and companies. It has typically been used as a way to describe the new technologies and companies that are revolutionizing the way we use and think about the World Wide Web.

Tim O’Reilly expands further on the definition of the term, in his article What is Web 2.0:
Web 2.0 applications are those that make the most of the intrinsic advantages of that platform: delivering software as a continually updated service that gets better the more people use it, consuming and remixing data from multiple sources, including individual users, while providing their own data and services in a form that allows remixing others, creating network effects through an architecture of participation and going beyond the page metaphor of Web 1.0 to deliver rich user experiences.

In the following sections we delve deeper into four ideas central to the discussion of Web 2.0, which O’Reilly and others have elaborated on since the initial emergence of the term. They include:
  • Characteristics and Core Competencies of Web 2.0
  • The Web is the Platform
  • An Architecture of Participation
  • Hierarchy of “Web 2.0-ness

Characteristics and Core Competencies

Seven characteristics and core competencies of Web 2.0 are as follows:
  • They should be in the business of providing services not packaged software, while enabling cost effective scalability.
  • They should also exercise control over unique, difficult to replicate data sources which get richer the more individuals use and contribute to them.
  • Trusting users as co-developers.
  • Harnessing collective intelligence.
  • Leveraging the long tail through customer self service.
  • Software above the level of a single device.
  • Lightweight user interfaces, development models, AND business models.

The Web is the Platform

The Web has become the destination where it all happens. The exchange and distribution of ideas, how we socialize, conduct business, work, and play is increasingly finding its way on to the Web. Of course, at the heart of these interactions are the people, applications and the data that drive them.

Not many years ago it would have been hard to imagine the Web as a strategically important platform for many of the things that are now common place, like trading stocks, booking travel, conducting commerce, bartering for goods and services, finding new/old friends or even a potential life mate. This perception was often due to the fact that the applications making use of the web as a platform, were often sluggish, had few security controls, were graphically uninteresting, or were held captive by the speed of the end-users internet connection. When comparing these characteristics against the existing desktop applications of the day, it is no wonder some people found it hard to imagine that the web could ever be considered a viable platform over the desktop.

Fast forward a few years and web applications are now beginning to provide close to if not better end-user experiences. The evolution we are witnessing is that of the web quickly becoming the next “desktop”, or more specifically, the next operating platform on which applications are being designed to run on exclusively.

An Architecture of Participation

The concept of an architecture of participation is typically used to describe companies, technologies and projects, intentionally designed for contribution from developer communities and individual users with an emphasis on empowerment and openness. Often times this concept is closely linked to open source projects and companies.

It may be worth noting that a technology or company that is open source does not necessarily mean it automatically exhibits an architecture of participation. However, it is often much easier for open source companies and projects, as they will likely have a devout and often vibrant developer community. Many times proprietary products find it difficult to cultivate a participatory quality without heavy subsidization. This can be further complicated if the source code is closed, or the exposed APIs are complex, making even peripheral contributions difficult.

A “release early and release often” development cycle, characteristic of open source software, is an excellent way to include a community of volunteers and parties with vested interests in the software, to test and help debug code. Often the introduction of new features is done in strategic locations on a website or within an application to help ascertain its popularity or usability. This helps developers understand if the feature should be more widely employed and enhanced, or abandoned all together.

An architecture of participation also relates to the idea of users creating meaningful and valuable data for themselves. Often times the application simply provides the framework and tools to empower users in this capacity. A practical manifestation of this may include seller ratings, user recommendations and restaurant reviews.

Some examples of applications which typify this concept include:
  • Feeds: Users and applications allow their content to be picked up for distribution to subscribers
  • Blogs: Users create site content and drive traffic
  • Social Networking: Users create site content and through their social channels to build a network
  • Wikis: Users contribute articles and manage the content for accuracy and relevance

Hierarchy of “Web 2.0-ness”

O’Reilly also articulated a “hierarchy” of degrees to which an application possesses or typifies Web 2.0 attributes.
  • Level 3: Could ONLY exist on the Web and draws its essential power from the network and the connections it makes possible between people and applications.
  • Level 2: Could exist offline, but has unique advantages by being online.
  • Level 1: Can and does exist offline, but gains additional functionality by being online.
  • Level 0: The application has primarily taken hold online, but it would work just as well offline if you had all the data in a local cache.

Monday, October 12, 2009

Facebook Manners

Do you have good Facebook manners? Timmy and Alice don't. Watch their bad behavior to learn the dos and don'ts of Facebook breakups.

Monday, October 5, 2009

How to promote a group on facebook

Success of any group is based on what kind of posts (NOT people) are there on that group. I have seen groups where there are more than 500 people on that group but there is hardly any post / topic e.g. search for Pune group and you will see what i mean. If you look at those people's profile who have joined that group, they have mentioned that they love that city ...etc. but they hardly participate in any topic or discussion and there is hardly any activity since months.

Things to take into consideration while forming a group:
  • Whenever you create any group try to encourage people to talk by either starting some topic/discussion or let other to start.
  • Make sure all the group sections are used to their fullest potential. When you first start the group, you'll see sections for Recent News, Discussion Board, The Wall, Photos, Links and Video. Put something new and relevant in all these sections.
  • Put the link for the group in most if not all your other communications.
  • Make it very easy for group members to share the group with their Facebook friends. Other people, with whom you are not directly connected will automatically join your group.

Monday, September 28, 2009

Does Google use the "Keywords" meta tag?

I have been telling this to my clients for really long time but still there are many who insists that "Keywords" SHOULD be the top priority, so have decided to put an article.

Google doesn't use the "keywords" meta tag in their web search ranking. Google web search (the well-known search at Google.com that hundreds of millions of people use each day) disregards keyword metatags completely. They simply don't have any effect in search ranking.

Matt Cutts, have now officially confirmed that "Keyword" meta tag does not hold any value, and have explained this on google web master central blog.

He said too many people has spammed with this meta tag so much, that we dont use it anymore. But that doesnt mean we dont use any of the meta tag. We use "Description" meta tag, if you have a good "Description" meta tag, you will be placed higher or maybe on first page of google as this screenshot shows



For more information, which meta tags google uses, click here

Listen to what Matt Cutts says:



In the end, I will say, CONTENT is the Key for best ranking.

Wednesday, September 23, 2009

Google: growing the display advertising

The new DoubleClick Ad Exchange helps to open the ecosystem and establish a new marketplace for buyers and sellers. Google's plans to make display advertising more useful to users, advertisers, and publishers.

This is what, Google wrote in its official blog

We've been working hard to put these principles into practice, and today we're excited to announce the new DoubleClick Ad Exchange, a step towards creating a more open display advertising ecosystem for everyone. The Ad Exchange is a real-time marketplace that helps large online publishers on one side; and ad networks and agency networks on the other, buy and sell display advertising space.

These publishers and ad networks manage and represent large volumes of ads and ad space from lots of advertisers and websites. By bringing them together in an open marketplace in which prices are set in a real-time auction, the Ad Exchange enables display ads and ad space to be allocated much more efficiently. This improves returns for advertisers and enables publishers to get the most value out of their online content.


For a large publisher managing multiple sales channels and ad networks, the Ad Exchange provides real-time yield management to maximize returns. The small-time advertiser or business can now buy targeted display ads on thousands of DoubleClick ad-serving websites. In other words, this could be a major boom to marketers as highly targeted ad campaigns can reach everywhere. It will also increases Google's competition with Yahoo.

An explanation of the Ad Exchange is here (PDF).

Tuesday, September 8, 2009

Google News - how does it work

How do these articles appear - Google gather these articles by
1) Crawling,
2) Grouping and
3) Ranking them


1) Crawling:
  • Discover crawls - Google bot visits your URL more than once, so that it can show you updated content.
  • News site maps - What are the benefits of submitting a news sitemap?
    It provides greater control over which of your articles appear on google news. Furthermore, it allows specification of meta information for each individual articles -
    a) Publication date
    b) Keywords
  • Robots.txt file - Robot.txt file will help you with -
    Which article you want Google bots to crawl or which document you want to exclude from crawling.
2) Grouping - Grouping is done according to:
  • Individual article content
  • By region
3) Ranking - Google rank stories by Aggregate Editorial Interest
  • Story Ranking - how important do editors think the story is?
    A small story has a small effect on publishing activity, whereas A big story causes rapid, independent, publishing activity worldwide.
  • Article Ranking -
    a) Fresh and New - Recent, substantial, original and focused on the topic
    b) Duplicate and Novelty Detection - Credit to Original and Novel content
    c) Local and Personal Relevancy - Weighted by section and story and more credit to local sources
    d) Trusted Sources - Boosts for trusted sources for each edition and section via various signals
Best Practices for better results for News Search-
  • Unique, permanent URL with atleast 3digits - if you dont have 3 digits in your news URL then best is to submit to news sitemap
  • Dont breakup article body
  • Put dates between Title and the body
  • Titles Matter - Good HTML as well as article title
  • Separate original content from press releases
  • Publish Informative and Unique content

Tuesday, September 1, 2009

Google Analytics - Interpreting Your Data

If you’ve just started to use Google Analytics and aren’t sure which reports to look at, this video provides a helpful 1st-time analysis walk through. You’ll learn how to interpret what you see in these key reports and what actions you should take as a result.

 

Sunday, August 9, 2009

How to retain employees

From the day businesses has started, retaining employees have been the MOST talked about topic.

I see there are 2 aspect, why employees leave any company, which are as follows:
1) Monetary aspect
2) Monotonous aspect

1) Monetary aspect - everybody works for money, though this is important but still can be manageable if you are able to provide reasonable/fair amount of money to the employees.

2) Monotonous aspect - this is very very important aspect even bigger than the monetary aspect. Nobody wants to do the same thing over n over again thru out his/her life. How we can overcome this aspect, is as follows:-

a) Work Environment - this plays very vital role in retaining employees, friendlier the work environment, bigger the success of retaining employees. Treat your employees as if they are your friends, talk to them nicely, have parties at regular interval of time

b) Learning and implementing New things - this is motivational factor, when you tell your employees to learn new things which they will be implementing in the company, Employees feel their importance in the company and take great enthusiasm at work. Learning always give a new approach to your personal growth. Like said in the beginning nobody wants to keep on doing the same thing for forever, everybody wants to learn new things and when you give them the liberty to implement what they have learnt, you are giving them a sense of belongingness to the company.

I have interviewed so many candidates and almost everybody said that they dont see any scope for their growth in their previous company so they want to leave. In other words it had become so monotonous for the employees that finally they have to take this drastic step of leaving the company.

If we take care of these things, i'm sure any company will have less iteration and have more retention.

Monday, August 3, 2009

Great Testimonial

They say - Hard work always pays and today we got another Great testimonial from Nicolas and Ahlmeirah, UK. It feels so nice when you see that your work is appreciated and you get the reward in testimonial which speak by itself. We come across many people who first go to those people, who without understanding the concept start working on the site and the final outcome of that is, people loose faith and interest. You can see this from Nicolas and Ahlmeirah testimonial -

Before we started to work with Ravinder Nikhil & Shola at Globalworldtech, our website had been a quickly cobbled together affair that had lots of good content but didn't really transmit the energy of love & service that is the heart of the Center For Conscious Ascension. We realised we needed professionals to work on this for us who were on the spiritual path and were in alignment with us and who could understand and feel where we were coming from. We found them with GlobalWorldTech.

Shola felt the energy we were wanting to transmit with the site immediately and developed the graphical concept for the site and it was exactly what we had been looking for. Ravinder Nikhil has given us the look and feel that makes the site such a pleasure to use. We found working with Global World Tech easy and pleasurable. They have a lot of integrity and real passion for this word, and work well to deadlines. They are also very good value for money compared to Western prices.

All our users are telling us they just love our new website. We are very happy with the result as it has given us the professional feel we were looking for with the right pitch of spiritual energy at the same time. A resounding success!


A resounding SUCCESS.

Same story with Laurie Handlers, USA. She spend few thousands $$$$ to couple of american developers who simply messed with the site. This is what she wrote -

After working with two previous web designers, I love working with GlobalWorld Tech. I have had nothing but great response from them. They aim to please and they produce results. My web ranking and optimization is higher than ever and we have only just begun. This is the place to get it done with people who are responsive. If you've ever driven a BMW, you know what responsive is. Global World Tech is the BMW of website design and development.


BMW of website design and development, doesnt they speak by themselves?

Wednesday, July 29, 2009

SALE SALE SALE

In this season, where everywhere SALE is going on, GWT presents an exciting opportunity for ALL those people who are holding back their Development and QA and Software Testing work.

If you start your development work now with GWT, you will get FREE QA Testing and 3 months of customer support.

If you start your QA and Testing work now, you will get additional 1 month as FREE, meaning thereby, 3+1, you pay for 3 months and get 1 month of extra work done for FREE.

So what are you waiting for??

Come early, start early and avail this exciting opportunity.

Wednesday, May 13, 2009

how to create a site with joomla

How to Create Sections:-

Login to admin and go to section manager. The Section Manager (Content > Section Manager), we see that it is blank. This is because we installed our site with no content in the installation process.

Here we created a section About us
After we have set up the section we now have

- About us
- Services
- Testimonials
- FAQ

How to Create Category:-


We go to the Category Manager (Content > Category Manager) and set up the categories we need. Notice we have to make sure we put it in the correct section (Services in this case) and save it as before.

Then following categories created are:-
- What we are
- What we offer
- Benefits
- Projects
- History
- Leadership and team
- Why India?
- Contact us
- Faq

How to Create Articles:-


Let's go to the Article Manager (Content > Article Manager) and open the About us content article

You will see here the title is About us which is the page title, the section selected is About us and the category What we are. Also note that to display the content of this page we FrontPage so that it should be shown on the front page.

Similarly create all the required article content for each respective category to their respective sections.

Now that we have all the content ready the question is how to assemble it and link it .
So now we start with Creating Menu and Menu Items.

As per are Web Needs We need Main Menu, Top Menu and Footer Menu and we create this in the Menu Manger as shown below,

How we create Main Menu:-


First let's go to the main menu (Menu Manager > main menu) and create a link to About Us. Here we get first option to select the article content from the Menu Items page, so now for about us we need to select the Articles and under this we have article Article Layout and select that , then we have a page.

In the figure you will see that Article layout is selected for Main Menu Type you can change that as per you layout needs, you will also see options to add menu item title and on the right you option to select the article we just created here we select company article content to our needs. You will also see the option to select where to display in the drop down here we selected Main Menu and the parent item as the TOP if it has any sub items we can do that by creating a new Menu Item and selecting the about us we already see a example Our Services.

Similarly we create Top Menu and Footer menu items.
Note that for each Menu type in the Module manager a module is created and see how they are related. In this case for Main Menu a Module Main Menu is created in the module manger. So you understand how a module is related to Menu Type .

We can also extend Joomla. There are extensions available, you can use this http://extensions.joomla.org/ to download various extensions, Plug-ins, Modules and also themes

I have use Testimonials extension in my site I will show how to add to Joomla
Downloaded the Extension from http://www.rswebsols.com/downloads/category/14-download-rsmonials-all

Installing Extensions


All extensions will come in the form of compressed zip files and are installed via the same process. To install, you simply use the Extension Manager. Go to Extensions>Install/Uninstall. This will show the Extension Manager,

If it’s a successful installation it will say so .It it is you will see a link Rsmonial where it allows you to add any testimonials from admin.
Earlier for the front end we created a section Testimonial for this section we will add this extension as we need the testimonials to be displayed on each and every page we create a Menu Type Testimonial Select the Rsmonial the menu item type and for that respective Menu Typea module will be created in the Module Manger Enable it.

So you see the Testimonial in the Menu Type here you also get option to add testimonials from the front end and done.

Finally we our complete website up and Running.

Friday, April 17, 2009

Creating site with Joomla

Creating GWT SITE with Joomla



Joomla is Content Management System (CMS) .With Joomla you for sure can build a really powerful site. So what does CMS means? To tell you in a simple it’s a system that controls each and every element of your site right from pictures to file , from alignment to placement , from header to footer , so it’s a software that helps to build a site even if you do not have any coding knowledge simply clicks will do .
Let’s start with Installation of Joomla:-
Download it from: - http://www.joomla.org/download.html
Joomla installation is very easy just extract the contents of file to new root folder let say Joomla and extract in this folder once done go to the url let say http://localhost/joomla/ and follow the simple instruction on each page and make sure you do as they say, click next and next until it takes you to the final page where you get options to click on either your sites main page or the admin page and done.

Now how to customize the Joomla according to our needs with our designs so let’s begin

you always starts with analyzing how the structure of my site should be what should it display in the header , main menu , front page , footer and any additional functionality so here advantage is Joomla gives you the option for dividing the thing so that you gets chance to work on each one at a time . Begin with our structure and it would be:
The sections are:-
1) About us.
2) Testimonial.
3) Contact us.
4) FAQ.
So here each section does have some task to do here,
Under about us sections we have tasks divided by categories,

The categories are:-
1) What we are
2) What we offer
3) Benefits
4) Projects
5) History
6) Leadership and team
7) Why India?
8) Contact us
9) Faq

So what each categories do:
Now the categories listed have articles which actually help to build the page for its respective category so here articles which finally holds the content for each of its category.
So here the articles for each category are:
1) What we are (Category) –

About us page (Article) –

- This page tells about the company

2) What we offer (Category) –

Services page (Article) –

- This tells about all services as a company we offer to our clients right from technology to project dispatch

3) Benefits (Category) –

Benefits page (Article) –

- Benefits page this tells about the benefits the clients get from our services


4) Projects (Category) –

Projects page (Article) –

- Projects page list all the projects done by our company

5) History (Category) –

History page (Article) –

- History page tells about the company when it got started how what motive and how we grow

6) Leadership and Team (Category) –

Leadership and Team page (Article) –

- This page tells about the leaders in Our company leading the way to success

7) Why India? (Category) –

Why India? (Article) –
- This page tells about why choose India for the outsourcing.

8) Contact Us (Category) –

Contact us page (Article) –
- This page has the contact details about our company

9) FAQ (Category) –

FAQ page (Article) –
- This page has the question answered for all those frequently asked questions.

So this is how the structure is organized.

We already know that in CMS we have everything in the front end is controlled by admin so let’s understand how to create Sections, Category and Articles

Monday, March 30, 2009

Progress bar using PHP

Upload progress bar



An extension to track progress of a file uploads. It is only known to work on Apache and at least PHP 5.2 is needed.

To Install

In windows it’s quite easy just copy and paste the uploadprogress.dll extension and enables the extension in the php configuration file and that’s it.

However in linux or unix, installation is different you need to either install it from the site http://pecl.php.net/package/uploadprogress via a pear or pecl in the server or download the stable release from the site and then install.

What to configure in php.ini

[uploadprogress]

extension=uploadprogress.dll

uploadprogress.file.contents_template = "c:\temp\upl_%s.txt" uploadprogress.file.filename_template = "c:\temp\upl_%s.txt"

uploadprogress.file.upload_identifier="UPLOAD_IDENTIFIER"

uploadprogress.update_interval=500

uploadprogress.delete_finished=1

(please set the path as per linux where it says c:\temp\upl_%s.txt)

after adding this lines in php.ini create a folder temp in a location set in the above php.ini

That’s all … and start running the progressbar

The progress bar is tested in firefox and IE and is working fine.

Friday, March 20, 2009

Integrating Paypal Shopping cart

The PayPal Shopping Cart – Add to Cart

With the PayPal Shopping Cart, you can let buyers select multiple items on your website and Pay for them with a single payment. Buyers click Add to Cart buttons to add items to their Virtual PayPal Shopping Carts, and they click View Cart buttons to review the items in their Carts before they check out and make their payments.

Sample HTML Code for a Basic Add to Cart Button. The sample HTML code below illustrates a basic Add to Cart button with these features:
An item named “QA Testing”.
An item price of $990.95 USD.
􀁺 PayPal calculates tax and shipping based on rates that you set up in your PayPal account.
􀁺 The buyer’s PayPal Shopping Cart opens in a separate browser window or tab.

form target=paypal action=https://www.paypal.com/cgi-bin/webscr method=post

Identify your business so that you can collect the payments.
input type=hidden name=business value=abc@abc.com

Specify a PayPal Shopping Cart Add to Cart button.
input type=hidden name=cmd value=_cart
input type=hidden name=add value=1

Specify details about the item that buyers will purchase.
input type=hidden name=item_name Value=QA and Software Testing
input type=hidden name=amount value=990.95
input type=hidden name=currency_code value=USD

Continue shopping on the current webpage of the merchant site.
The below value is replaced when buyers click Add to Cart
input type=hidden name=shopping_url value=http://www.globalworldtech.com/services.html
input type=hidden name=shipping value=4
input type=hidden name=handling_cart value=24

Display the payment button.
input type=image name=submit border=0 src=https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif
alt=PayPal - The safer, easier way to pay online
img alt="" border=0 width="1" height="1" src=https://www.paypal.com/en_US/i/scr/pixel.gif

form

Variables required to tell PayPal the type of form it is are:

1) cmd
The cmd variable is always required in a FORM. Its value determines which Website Payments Standard checkout experience you are using to obtain payment.

Allowed Values for cmd Variable
Value of cmd Description
a) _xclick The button that the person clicked was a Buy Now button
b) _donations The button that the person clicked was a Donate button
c) _xclick- subscriptions the button that the person clicked was a Subscribe button.
d) _cart For shopping cart purchases; these additional variables specify the Kind of shopping cart button or command:
􀁺 add – Add to Cart buttons this must be set to 1
􀁺 display – View Cart buttons other alternative to add
􀁺 upload – The Cart Upload command tells it’s a third party cart must be set to1.

2) shopping_url
Use the shopping_url variable to let PayPal control which page buyers return to when they click the Continue Shopping button.

3) handling_cart

Single handling fee to be charged cart-wide. If handling_cart is used in multiple Add to Cart buttons, the handling_cart value of the first item is used.

4) amount
Required Price of the item or the total price of all items in the shopping
Cart.

5) business
Required Your PayPal ID or an email address associated with your PayPal
account. Email addresses must be confirmed

6) item_name
Required Name of the item or a name for the entire Shopping Cart

7) currency_code
The currency of the payment. The default is USD.

8) shipping
The cost of shipping the item. This use of the shipping variable is valid only for Buy Now and Add to Cart buttons.

There are few other additional html variables like tax, tax_rate ,undefined_quantity,weight,weight_unit also can defined if required you can check the url
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables for all html variables.

Sunday, March 1, 2009

Abstract Class
An abstract class is a class with or without data members that provides some functionality and leaves the remaining functionality for its child class to implement. The child class must provide the functionality not provided by the abstract class or else the child class also becomes abstract.
Objects of an abstract and interface class cannot be created i.e. only objects of concrete class can be created.
To define a class as Abstract, the keyword abstract is to be used e.g. abstract class ClassName { }
Eg :
abstract class Furniture {
private $height, width, length;

public function setData($h, $w, $l) {
$this->height = $h;
$this->width = $w;
$this->length = $l;
}

//this function is declared as abstract and hence the function
//body will have to be provided in the child class
public abstract function getPrice();

}


class BookShelf extends Furniture {

private $price;

public setData($h, $w, $l, $p) {
parent::setData($h, $w, $l);
$this->price = $p;
}


//this is the function body of the parent abstract method
public function getPrice() {
return $this->price;
}
}
In the above example, the method getPrice() in class Furniture has been declared as Abstract. This means that its the responsibility of the child class to provide the functionality of getPrice(). The BookShelf class is a child of the Furniture class and hence provides the function body for getPrice().
Private methods cannot be abstract
If a method is defined as abstract then it cannot be declared as private (it can only be public or protected). This is because a private method cannot be inherited.

Interface Class
Interface is a class with no data members and contains only member functions and they lack its implementation. Any class that inherits from an interface must implement the missing member function body.
Interfaces is also an abstract class because abstract class always require an implementation.
In PHP 5, interfaces may declare only methods. An interface cannot declare any variables. To extend from an Interface, keyword implements is used. PHP5 supports class extending more than one interface.
Eg:
interface employee
{
function setdata($empname,$empage);
function outputData();
}

class Payment implements employee
{
function setdata($empname,$empage)
{
//Functionality
}

function outputData()
{
echo "Inside Payment Class";
}
}

$a = new Payment();
$a->outputData();

Wednesday, February 18, 2009

Polymorphism

Polymorphism is derived from two Greek words. Poly (meaning many) and morph (meaning forms). Polymorphism means many forms. In C you have two methods with the same name that have different function signatures and hence by passing the correct function signature you can invoke the correct method.
The meaning with Object Oriented languages changes. With Object Oriented language polymorphism happens:
When the decision to invoke a function call is made by inspecting the object at runtime it is called Polymorphism
Method polymorphism cannot be achieved in PHP :
The reason why polymorphism for methods is not possible in PHP is because you can have a method that accepts two parameters and call it by passing three parameters. This is because PHP is not strict and contains methods like func_num_args() and func_get_arg() to find the number of arguments passed and get a particular parameter.
Because PHP is not type strict and allows variable arguments, this is why method polymorphism is not possible.
PHP 5 Polymorphism
Since PHP 5 introduces the concept of Type Hinting, polymorphism is possible with class methods. The basis of polymorphism is Inheritance and overridden methods.
Eg:

class BaseClass {
public function myMethod() {
echo "BaseClass method called";
}
}

class DerivedClass extends BaseClass {
public function myMethod() {
echo "DerivedClass method called";
}
}

function processClass(BaseClass $c) {
$c->myMethod();
}

$c = new DerivedClass();
processClass($c);

In the above example, object $c of class DerievedClass is executed and passed to the processClass() method. The parameter accepted in processClass() is that of BassClass. Within the processClass() the method myMethod() is being called. As per the definition “When the decision to invoke a function call is made by inspecting the object at runtime it is called Polymorphism”, myMethod() will be called on object DerievedClass. The reason why this happens is because the object of DerievedClass is being passed and hence the method myMethod() of DerievedClass will be called.

Final Class and Methods
Final Class :

A final class is a class that cannot be extended. To declare a class as final, you need to prefix the ‘class’ keyword with ‘final’.
Eg:
final class BaseClass {
public function myMethod() {
echo "BaseClass method called";
}
}

//this will cause Compile error
class DerivedClass extends BaseClass {
public function myMethod() {
echo "DerivedClass method called";
}
}

$c = new DerivedClass();
$c->myMethod();

In the above example, BaseClass is declared as final and hence cannot be extended (inherited). DerivedClass tries to extend from BaseClass and hence the compiler will throw a compile error.
Final Method :
A final method is a method that cannot be overridden. To declare a method as final, you need to prefix the function name with the ‘final’ keyword.
Eg:
class BaseClass {
final public function myMethod() {
echo "BaseClass method called";
}
}

class DerivedClass extends BaseClass {
//this will cause Compile error
public function myMethod() {
echo "DerivedClass method called";
}
}

$c = new DerivedClass();
$c->myMethod();
In the above example, DerivedClass extends from BaseClass. BaseClass has the method myMethod() declared as final and this cannot be overridden. In this case the compiler causes a compile error.

Static Data Member :
A data member that is commonly available to all objects of a class is called a static member. static members share the memory space between all objects of the same class.

Defining static data members in PHP5
To define a static member in PHP5 you need to prefix the class member name with the keyword ’static’.
Eg:
class Customer {

private $first_name; // regular member
static public $instance_count; //static data member

}
Accessing static data members in PHP5
A static member data can be accessed using the name of the class along with the scope resolution operator (::) i.e. you don’t need to create an instance of that class
Eg:
class Customer {

static public $instance_count = 0; //static data member

public function __construct() {
Customer::$instance_count++;
}

public function __destruct() {
Customer::$instance_count--;
}

public function getFirstName() {
//body of method
}

static public function getInstanceCount() {
//body of method
}
}

$c1 = new Customer();
$c2 = new Customer();

echo Customer::$instance_count;

Output:
2
In the above example, $instance_count is a static data member. Every time a new object is created the constructor is executed and the $instance_count variable is incremented by one. To echo the value contained in $instance_count variable, we use the :: (scope resolution) operator.

Static Method :
A static method is a class method that can be called without creating an instance of a class. Such methods are useful when creating utility classes.
Defining static methods in PHP5
To define a static data methods in PHP5 you need to prefix the class method name with the keyword ’static’.
Eg:
class Customer {

public function getFirstName() {
//body of method
}

static public function getInstanceCount() {
//body of method
}
}
Accessing static method in PHP5
A static method can be accessed using the name of the class along with the scope resolution operator (::) i.e. you don’t need to create an instance of that class. However, you can also access it with an instance variable.
Eg:

class Customer {

static public $instance_count = 0; //static data member

public function __construct() {
Customer::$instance_count++;
}

public function __destruct() {
Customer::$instance_count--;
}

public function getFirstName() {
//body of method
}

static public function getInstanceCount() {
return Customer::$instance_count;
}
}

$c1 = new Customer();
$c2 = new Customer();

echo Customer::getInstanceCount(); //this is using the scope resolution operator
echo $c1->getInstanceCount(); //this is using the instance variable
Output:
2
2
Rules to keep in mind for static methods

  • A static method can only access static data members

  • A static method does not have access to the $this variable

Thursday, February 12, 2009

Access specifiers:
Access specifiers are used to identify access rights for the data and member functions of the class. Access specifiers specify the level of access that the outside world (i.e. other class objects, external functions and global level code) have on the class methods and class data members. There are three main types of access specifiers in PHP.

  • private

  • public

  • protected


1) Private
A private access specifier is used to hide the data member or member function to the outside world. This means that only the class that defines such data member and member functions have access them.
Eg:

class Customer {
private $name;

public function setName($name) {
$this->name = $name;
}

public function getName() {
return $this->name;
}
}

$c = new Customer();
$c->setName("Sunil Bhatia");
echo $c->name; //error, $name cannot be accessed from outside the class
//$name can only be accessed from within the class

echo $c->getName(); //this works, as the methods of the class have access
//to the private data members or methods

In the above example, echo $c->name will give you an error as $name in class Customer has been declared private and hence only be accessed by its member functions internally.

2) Public
A public access specifier provides the least protection to the internal data members and member functions. A public access specifier allows the outside world to access/modify the data members directly unlike the private access specifier.
Eg:
class Customer {
public $name;

public function setName($name) {
$this->name = $name;
}

public function getName() {
return $this->name;
}
}

$c = new Customer();
$c->setName("Sunil Bhatia");
echo $c->name; // this will work as it is public.
$c->name = "New Name" ; // this does not give an error.

In the above example, echo $c->name will work as it has been declared as public and hence can be accessed by class member functions and the rest of the script.
3) Protected :
A protected access specifier is mainly used with inheritance. A data member or member function declared as protected will be accessed by its class and its base class but not from the outside world (i.e. rest of the script). We can also say that a protected data member is public for the class that declares it and it’s child class; but is private for the rest of the program (outside world).
Eg:
class Customer {
protected $name;

public function setName($name) {
$this->name = $name;
}

public function getName() {
return $this->name;
}
}

class DiscountCustomer extends Customer {

private $discount;

public function setData($name, $discount) {
$this->name = $name; //this is storing $name to the Customer
//class $name variable. This works
// as it is a protected variable

$this->discount = $discount;
}
}

$dc = new DiscountCustomer();
$dc->setData("Sunil Bhatia",10);
echo $dc->name; // this does not work as $name is protected and hence
// only available in Customer and DiscountCustomer class

In the above example, echo $dc->name will not work work $name has been defined as a protected variable and hence it is only available in Customer and DiscountCustomer class.
Important Note of Access Specifier in PHP5
In PHP5, access specifiers are public by default. This means that if you don’t specify an access specifier for a data member or method then the default ‘public’ is applicable.

Tuesday, February 10, 2009

Bit about OOP

OOP is the common abbreviation for Object-Oriented Programming. Object-Oriented Programming (OOP) is different from procedural programming languages (C, Pascal, etc.). OOPS is a type of programming in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure . In this way, the data structure becomes an object that includes both data and functions. In addition, programmers can create relationships between one object and another. For example, objects can inherit characteristics from other objects.
One of the principal advantages of object-oriented programming techniques over procedural programming techniques is that they enable programmers to create modules that do not need to be changed when a new type of object is added. A programmer can simply create a new object that inherits many of its features from existing objects. This makes object-oriented programs easier to modify.

What is an Object

Object is a instance of a class. An object is a bunch of variables and functions all encapsulated into a single entity. The object can then be called rather than calling the variables or functions themselves. Within an object there are methods and properties. The methods are functions that manipulate data within the object. The properties are variables that hold information about the object.

What is a Class
A class is the blueprint for your object. The class contains the methods and properties, or the characteristics of the object. It defines the object.
The class holds the definition, and the object holds the value.
The syntax is used for writing the class is as follows. We declare class in PHP by using the class keyword.

class vehicle
{
/*** define public properties ***/

public $color;
public $price;
public function showPrice(){
echo 'This vehicle costs '.$this->price.'.
';
}

} /** end of class **/
?>
This is the class definition for class vehicle. we can now create one, or many, vehicle objects from that class definition. To create a new object from the class definition we use the new keyword.
/*** create a new vehicle object ***/
$vehicle = new vehicle;
$vehicle->price =100000;

/*** call the showPrice method ***/
$vehicle->showPrice();
?>
What is the difference between an object and a class?
1) class:class is an abstract data type in which both Member
functions and member variable are declared that means
a class is user defined data type in which we will be able to
declare both methods and variable.
object : Object is an Instance of the class. The class is a
valid one when object is created.

2) Class is a static entity, while object is a dynamic entity.
class is the template for members and methods
Object is the physical reality to access the members and
Methods.
For one class we will have more number of Objects.
3) Class is just a template. It does not allocate memory
space. When instantiate the object, allocates the memory
space.

Constructors

Constructors are functions in a class that are automatically called when you create a new instance of a class with new.
Constructors are used for initialization of an object.
In PHP4 we called to constructor with the same name as a class. So, if you have a class named MyClass, constructor is a function named MyClass.
In PHP5 we call to constructor with the function name __construct.
If you inherit the class, The constructor of the inherited class is executed implicitly. The constructor of the parent class will not be executed implicitly. If you want to execute parent constructor you have to call it explicitly in a subclass constructor with:
parent::ClassName
or
parent::__construct

Destructor
Destructor is a function which is called right after you release an object. Releasing object means that you do not need it or use it anymore. This makes destructor suitable for any final actions you want to perform.
Destructor is a PHP5 feature. PHP4 does not have destructors at all.
Destructor is a function called __destruct(). As a constructor, this function can not be called directly. It will be called implicitly when you release your object.

eg:

Class Animal
{
public $type;
public $sound;

/* Constructor in PHP5 */
public function _construct($type,$sound)
{
$this->type = $type;
$this->sound = $sound;
}

/* Constructor in PHP4 */
public function Animal($type,$sound)
{
$this->type = $type;
$this->sound = $sound;
}

}

class Cat extends Animal
{
public $name;


// this is consructor
public function __construct($name,$type,$sound)
{
$this->name = $name;
parent::__construct($type,$sound);
}

// this is destructor
function __destruct()
{
echo "Cat Object Released\n";
}

}


$cat = new Cat("Sweety", ”Cat”,” meeoow!”);


$this
$this is a pseudo-variable. Within a class definition, you do not know under which name the object will be accessible in your program. So we used $this to access the variable and function of an object in the class definition. $this is referred to the ‘current object’.

Inheritance
Definition of Inheritance:
Inheritance is the mechanism of deriving a new class from an existing class. It allows a sub-class / child class to share/inherit the attributes and behaviors of a base-class or parent class.
PHP5 Inheritance :
To inherit in PHP5, you should use the keyword ‘extends’ in the class definition. In PHP5 only single inheritance is allowed. The base class called the parent class and extended class called the child class or derived class. Child class has all the properties and method of the parent class which are public or protected.
Eg :-
class Person {
private $name;
private $address;

public function getName() {
return $this->name;
}
}

class Customer extends Person {
private $customer_id;
private $record_date;

public getCustomerId() {
return $this->customer_id;
}

public getCustomerName() {
return $this->getName();// getName() is in Person
}
}

In the above example, class Customer extends from the Person class. This means that Customer class is the child class and the Person base class. The child class Customer extends the method getName() and calls it in the getCustomerName() method of the Customer class.

Tuesday, January 27, 2009

FTP Upload via cURL :

FTP hosting is often much cheaper than regular web hosting. The upload with an ftp client is for sure the most common way, but could be a problem for people behind a firewall or without enough rights (capabilities) to install a FTP client. For those a upload via a web form is the best solution.
Using cURL for file transmissions
In this example we want to upload a file to some (password protected) remote FTP server via a web form.
The form is simple and has only one file field and the submit button. Don’t forget to protect this kind of pages. we need some PHP code to handle the upload and opens a stream to send the file via cURL to the remote FTP server.
if (isset($_POST['Submit'])) {
if (!empty($_FILES['upload']['name'])) {
$ch = curl_init();
$localfile = $_FILES['upload']['tmp_name'];
$fp = fopen($localfile, 'r');
curl_setopt($ch, CURLOPT_URL, 'ftp://ftp_login:password@ftp.domain.com/'.$_FILES['upload']['name']);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_exec ($ch);
$error_no = curl_errno($ch);
curl_close ($ch);
if ($error_no == 0) {
$error = 'File uploaded successfully.';
} else {
$error = 'File upload error.';
}
} else {
$error = 'Please select a file.';
}
}
?>
start form action="" method="post" enctype="multipart/form-data"

input name="upload" type="file"
input type="submit" name="Submit" value="Upload"
end form

After the user has selected a file, the data is uploaded to the web server. We open the temp file with fopen and the cURL session is initialized. Together with the URL for the remote FTP server, we send the FTP login and password to the target location. The other cURL settings are required to send the file via the FTP protocol to the target server. If the returned error code is equal “0″, the upload was successful.
This small PHP snippet is responsible for the upload to some remote FTP server.

Monday, January 26, 2009

What options we set here?
First we set the connection timeout to 30 seconds, so we don’t have our script waiting indefinitely if the remote server fails to respond.
Then we set how cURL will identify itself to the remote server. Some servers will return different content for different browsers (or agents, such as spiders of the search engines), so we want our request to look like it is coming from a popular browser.

CURLOPT_RETURNTRANSFER set to true forces cURL not to display the output of the request, but return it as a string.

Then we set CURLOPT_SSL_VERIFYPEER option to false, so the request will not trigger an error in case of an invalid, expired or not signed SSL certificate.
Finally, we set CURLOPT_FOLLOWLOCATION to 1 to instruct cURL to follow “Location:” redirects found in the headers sent by the remote site.
Now we must prepare the data that we want to post. We can first store this in an array, with the key of an element being the same as the input name of a regular form, and the value being the value that we want to post for that field.

For example, if in a regular form we would have:



we add this to our array like this:
$post_data['firstName'] = ‘Name’;
$post_data['action'] = ‘Register’;
Do the same for every form field.
Data will be posted in the following format:
key1=value1&key2=value2

In order to format the data like this, we are going to create strings for each key-value pair (for example key1=value1), put them in another array ($post_items) then combine them in one string using PHP function implode() .
foreach ( $post_data as $key => $value) {
$post_items[] = $key . ‘=’ . $value;
}
$post_string = implode (’&’, $post_items);
Next, we need to tell cURL which string we want to post. For this, we use the CURLOPT_POSTFIELDS option.

curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
Finally, we execute the post, then close the connection.
$result = curl_exec($curl_connection);
curl_close($curl_connection);
By now, the data should have been posted to the remote URL. Go check this, and if it did not work properly, use curl_getinfo() function to see any errors that might have occurred.
print_r(curl_getinfo($curl_connection));
This line displays an array of information regarding the transfer. This must be used before closing the connection with curl_close();
You can also see number and description of the error by outputting curl_errno($curl_connection) and curl_error($curl_connection).
So let’s put everything together. Here is our code:

//create array of data to be posted
$post_data['firstName'] = ‘Name’;
$post_data['action'] = ‘Register’;
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . ‘=’ . $value;
}
//create the final string to be posted using implode()
$post_string = implode (’&’, $post_items);
//create cURL connection
$curl_connection = curl_init(’http://www.domainname.com/target_url.php’);
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)”);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . ‘-’ . curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
?>

Friday, January 23, 2009

1) Getting the contents of files on remote servers with CURL : CURL is a powerful way to interact with remote servers with PHP. With CURL, it is possible to download files from remote servers
We’re coding a simple CURL function that can be used over and over. This function is simply for getting the contents of files on remote servers

2) File Handling With CURL : Using PHP's CURL module to fetch the example.com homepage and write the content in example_homepage.txt.

CURLOPT_FILE is an option for a CURL session identified by the ch parameter. $fp is a value set to the file that the transfer should be written to. The default is STDOUT (the browser window).
CURLOPT_HEADER is an option for a CURL session . It has Boolean value. Set TRUE to include the header in the output. Set False is not include the header in the output.

3) Submit A Form With CURL :
Here we’re going to learn how to submit a form using PHP and CURL.
So how do I use cURL to post data?
Begin by creating a new connection.
$curl_connection = curl_init('http://www.domainname.com/target_url.php');
A new connection is created using curl_init() function, which takes as parameter the target URL where we want to post our data. The target URL is the same as the “action” parameters of a normal form, which would look like this:

form start ("form action="http://www.domainname.com/target_url.php" method="post")
Now let’s set some options for our connection.
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);

end of form

Thursday, January 22, 2009

What are cURL and libcurl?

cURL stands for "Client URLs" is a function library, and was developed by Daniel Stenberg in 1998 as a command line tool. PHP supports it through libcurl. libcurl is a portable library that provides an easy interface to the cURL functionality. It is thread safe, IPv6 compatible, and supports persistent connections. The libcurl PHP binding was added by Sterling Hughes.

PHP supports libcurl, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.
Requirements
In order to use PHP's CURL functions you need to install the libcurl package. PHP requires that you use libcurl 7.0.2-beta or higher. In PHP 4.2.3, you will need libcurl version 7.9.0 or higher. From PHP 4.3.0, you will need a libcurl version that's 7.9.8 or higher. PHP 5.0.0 requires a libcurl version 7.10.5 or greater.

The following are the basic steps when we process with libcurl from within PHP
Initialize the cURL session : - we initialize a CURL session using the curl_init().
Set the cURL options (The order of the options is not important) : - Then we can set all our options for the transfer via the curl_setopt(),
Execute the options in the cURL session : - we execute the session with the curl_exec()
Close the curl session : - we finish session using the curl_close().


There are more number of functions associated with this libcurl library. Which are
curl_close -- Close a CURL session
curl_copy_handle -- Copy a cURL handle along with all of its preferences
curl_errno -- Return the last error number
curl_error -- Return a string containing the last error for the current session
curl_exec -- Perform a CURL session
curl_getinfo -- Get information regarding a specific transfer
curl_init -- Initialize a CURL session
curl_multi_add_handle -- Add a normal cURL handle to a cURL multi handle
curl_multi_close -- Close a set of cURL handles
curl_multi_exec -- Run the sub-connections of the current cURL handle
curl_multi_getcontent -- Return the content of a cURL handle if CURLOPT_RETURNTRANSFER is set
curl_multi_info_read -- Get information about the current transfers
curl_multi_init -- Returns a new cURL multi handle
curl_multi_remove_handle -- Remove a multi handle from a set of cURL handles
curl_multi_select -- Get all the sockets associated with the cURL extension, which can then be "selected"
curl_version -- Return the current CURL version
curl_setopt -- Set an option for a CURL transfer