Friday, September 26, 2008
Configure PHP to Send fax
Need a working installation of the following:
* HylaFAX 4.4 or HylaFAX EE 3
* PHP 5
* PHP PEAR 5 including MDB2_driver_mysql, Mail and Mail_Mime
* PECL FileInfo
* PHP mbstring - for improved UTF-8 sorting support (optional)
* PHP MySQL 5
* MySQL server 4.1.12 or better (see Important Notes below)
* Apache
* ImageMagick
* ghostscript
* libtiff
* netpbm-progs
* libungif
* sudo
* sendmail/postfix/exim/qmail or use an external SMTP server
* cups/lpr and psutils
* expect
Follow the installation instruction from below link.
Refrence : http://www.avantfax.com/install.php
http://www.hylafax.org/
HylaFAX is designed to be very robust and reliable. The fax server is designed to guard against unexpected failures in the software, in the configuration, in the hardware and in general use. HylaFAX can support multiple modems and a heavy traffic load.
HylaFAX supports:
* sending facsimile
* receiving facsimile
* polled retrieval of facsimile
* transparent shared data use of the modem
* sending alpha-numeric pages
Hylafax can be use to send SMS.
Wednesday, September 24, 2008
Installing SMTP serve on Linux
sudo apt-get install postfix
Want to change configuration settings :
sudo dpkg-reconfigure postfix
Reference : http://my.opera.com/Contrid/blog/show.dml/478684
Wednesday, September 3, 2008
Common PHP design patterns
The core concept behind design patterns, presented in the introduction, was simple.
Using design patterns in PHP code is one way to make code more readable and maintainable. By using established patterns, We benefit from common design constructs that allow other developers on a team to understand our code's purpose. It also allows us to benefit from the work done by other designers, so we don't have to learn the hard lessons of design ideas that don't work out.
Common patterns for PHP.
The factory pattern The factory pattern is a class that has some methods that create objects for you. Instead of using new directly, you use the factory class to create objects. That way, if you want to change the types of objects created, you can change just the factory. All the code that uses the factory changes automatically.
sometimes such patterns can seem like overkill in small situations.
The singleton pattern
Some application resources are exclusive in that there is one and only one of this type of resource. For example, the connection to a database through the database handle is exclusive. You want to share the database handle in an application because it's an overhead to keep opening and closing connections, particularly during a single page fetch.
The singleton pattern covers this need. An object is a singleton if the application can include one and only one of that object at a time.
The observer pattern
The observer pattern gives you another way to avoid tight coupling between components. This pattern is simple: One object makes itself observable by adding a method that allows another object, the observer, to register itself. When the observable object changes, it sends a message to the registered observers. What those observers do with that information isn't relevant or important to the observable object. The result is a way for objects to talk with each other without necessarily understanding why.
This pattern isn't limited to objects in memory. It's the underpinning of the database-driven message queuing systems used in larger applications.
The chain-of-command pattern
Building on the loose-coupling theme, the chain-of-command pattern routes a message, command, request, or whatever you like through a set of handlers. Each handler decides for itself whether it can handle the request. If it can, the request is handled, and the process stops. You can add or remove handlers from the system without influencing other handlers.
The chain-of-command pattern can be valuable in creating an extensible architecture for processing requests, which can be applied to many problems.
The strategy pattern
In this pattern, algorithms are extracted from complex classes so they can be replaced easily. For example, the strategy pattern is an option if you want to change the way pages are ranked in a search engine. Think about a search engine in several parts -- one that iterates through the pages, one that ranks each page, and another that orders the results based on the rank. In a complex example, all those parts would be in the same class. Using the strategy pattern, you take the ranking portion and put it into another class so you can change how pages are ranked without interfering with the rest of the search engine code.
The strategy pattern is great for complex data-management systems or data-processing systems that need a lot of flexibility in how data is filtered, searched, or processed.
The adapter pattern
Use the adapter pattern when you need to convert an object of one type to an object of another type. The adapter pattern is a nice way to clean this type of code up and reuse all your assignment code in other places. Also, it hides the assignment code, which can simplify things quite a bit if you're also doing some formatting along the way.
The iterator pattern
The iterator pattern provides a way to encapsulate looping through a collection or array of objects. It is particularly handy if you want to loop through different types of objects in the collection.
The decorator pattern
The delegate pattern
The delegate pattern provides a way of delegating behavior based on different criteria.
The state pattern
http://www.ibm.com/developerworks/library/os-php-designptrns/
Friday, August 29, 2008
Install Lampp In ubuntu
1. Download file to Desktop.
2. Type in terminal :
sudo tar xvfz Desktop/xampp-linux-1.6.4.tar.gz -C /opt
3. put to startup (Auto run ) : sudo gedit /etc/init.d/rc.local
When the text editor opens, paste the following just below the “#! /bin/sh” line:
/opt/lampp/lampp start
Reference:
http://alanedwardes.com/posts/installing-and-configuring-lampp-the-simple-guide/
Monday, July 7, 2008
HTTP vs. HTTPS
This may sound silly to technophiles, but plenty of people don’t understand how secure Web sites work.
People often ask how they can shop on a Web site, giving out personal information, and feel even remotely safe? After all, you’re sending identifying data, without guide or guard, into the vast expanse of cyberspace. Expecting your data to arrive at the right place at all, let alone safely, seems like putting your faith in a miracle. How does it work? The secret lies in a trusted third party and good encryption.
The HyperText Transfer Protocol is an application layer protocol, which means it focuses on how information is presented to the user of the computer but doesn’t care a whit about how data gets from Point A to Point B. It is stateless, which means it doesn’t attempt to remember anything about the previous Web session. This is great because there is less data to send, and that means speed. And HTTP operates on Transmission Control Protocol (TCP) Port 80 by default, meaning your computer must send and receive data through this port to use HTTP. Not just any old port will do.
Secure HyperText Transfer Protocol (HTTPS) is for all practical purposes HTTP. The chief distinction is that it uses TCP Port 443 by default, so HTTP and HTTPS are two separate communications. HTTPS works in conjunction with another protocol, Secure Sockets Layer (SSL), to transport data safely. Remember, HTTP and HTTPS don’t care how the data gets to its destination. In contrast, SSL doesn’t care what the data looks like. People often use the terms HTTPS and SSL interchangeably, but this isn’t accurate. HTTPS is secure because it uses SSL to move data.
Going Through the Process
With HTTP, you sit at your browser and interact with data. HTTP’s job is to present that data to you, and browsers are the means of doing so. Mozilla’s Firefox browser, for example, understands HTTP instructions and arranges the data as the site’s designer intended. The browser knows what to do when you click. It uses HTTP to do this. But HTTP cannot do much beyond that. How the data travels from Point A to Point B, or even if it travels at all, is none of HTTP’s concern. This is a great compromise if you want speed and elegance and couldn’t care less about security. One does not require security to view BizTech’s latest online articles, for instance.
With HTTPS, the story is quite the same. But when security is a must, HTTPS differentiates one sender and receiver from another. SSL takes the data, going or coming, and encrypts it. This means that SSL uses a mathematical algorithm to hide the true meaning of the data. The hope is that this algorithm is so complex it is either impossible or prohibitively difficult to crack.
The encryption begins when the owner of the Web site purchases a time-sensitive certificate from a trusted certificate authority such as VeriSign. You can get a certificate anywhere, or even make your own, but is it trusted? Your browser will let you know. This certificate is a security code created specifically for that one user, or even for that one Web site. The code is so complex that no one else on Earth should have a duplicate.
Getting a certificate can be an involved task. All types of information must be recorded so the issuer of the certificate can be a reliable authority on the certificate’s owner. Information that must be provided includes the name of the site and even the name of the server that hosts the site. Complexity makes counterfeiting incredibly difficult.
This makes the issuer a trusted third party. When your browser sees the secure Web site, it uses the information in the certificate to verify that the site is what it claims to be. Browsers commonly indicate security by presenting a picture of a shiny closed lock at the bottom of the screen. This process is not always perfect because of human error. Maybe 53.com is a valid banking site, but 53RD.com is not. We call that phishing. Unscrupulous people phish for careless people. So be cautious. After the identity of the Web site is accepted, the encryption is negotiated between the browser and the Web server, and the data is all but locked up tight.
Knowing the difference between HTTP and HTTPS can help users buy with confidence and help businesses get started in electronic commerce.
Smart HTTP and HTTPS RewriteRule Redirects
Setting HTTP/HTTPS Environment Variable
Old method for HTTP to HTTPS Redirection
This is the old way I would have to use to redirect /index.html to / and urls with // to /.
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.html\ HTTP/ [NC]
RewriteRule ^.*$ http://%{SERVER_NAME}/%1 [R=301,L]
RewriteCond %{HTTPS} =on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.html\ HTTP/ [NC]
RewriteRule ^.*$ https://%{SERVER_NAME}/%1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)//(.*)\ HTTP/ [NC]
RewriteRule ^.*$ http://%{SERVER_NAME}/%1/%2 [R=301,L]
RewriteCond %{HTTPS} =on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)//(.*)\ HTTP/ [NC]
RewriteRule ^.*$ https://%{SERVER_NAME}/%1/%2 [R=301,L]
New HTTPS to HTTP Redirection
First I set the environment variable ps to have the value “http” for HTTP requests, or “https” for HTTPS requests. Once that is accomplished, I can use %{ENV:ps} in all of my rewriterules and it will result in https for SSL requests and http for non-ssl requests!
RewriteCond %{HTTPS} =on
RewriteRule ^(.+)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.+)$ - [env=ps:http]
# redirect urls with index.html to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.html\ HTTP/ [NC]
RewriteRule ^.*$ %{ENV:ps}://%{SERVER_NAME}/%1 [R=301,L]
# change // to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)//(.*)\ HTTP/ [NC]
RewriteRule ^.*$ %{ENV:ps}://%{SERVER_NAME}/%1/%2 [R=301,L]
Even Newer HTTP/HTTPS Rewrite Code
The top guru I have ever seen in my lengthy .htaccess related web travels is a moderator on the WebmasterWorld.com Apache Forum, jdMorgan. Upon seeing the above solution that I came up with, jdMorgan instantly provided an improvement, resulting in being able to set the environment variable in 1 rewrite block instead of 2. This is truly Sweet.
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.+)$ - [env=askapache:%2]
# redirect urls with index.html to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http%{ENV:askapache}://%{HTTP_HOST}/$1 [R=301,L]
# change // to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)//(.*)\ HTTP/ [NC]
RewriteRule ^.*$ http%{ENV:askapache}://%{HTTP_HOST}/%1/%2 [R=301,L]
Wednesday, June 18, 2008
HTML Purifier 3.0
What is HTML Purifier?
HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications.
What's new in 3.0?
Release 3.0.0 is the first release of 2008 and also HTML Purifier's first PHP 5 only release.
The 2.1 series will still be supported for bug and security fixes, but will not get new features. This release a number of improvements in CSS handling, including the filter
HTMLPurifier_Filter_ExtractStyleBlocks
which integrates HTML Purifier with
CSSTidy for cleaning style sheets (see the source code file for more information on usage), contains experimental support for proprietary CSS properties with %CSS. Proprietary, case-insensitive CSS properties, and more lenient hexadecimal color codes. Also, all code has been upgraded to full PHP 5 and isE_STRICT
clean for all versions of PHP 5 (including the 5.0 series, which previously had parse-time errors).
You can run a live demo to see it at work.