»
S
I
D
E
B
A
R
«
26/11 has passed please stop jabbering……..
Nov 26th, 2009 by anand

The sole purpose of terrorism is to terrorise us. It is to create fear, gut wrenching fear, and spread panic everywhere. If terrorists can’t get that right, if they can’t whip up enough fear and hysteria, their entire purpose is defeated. All the bloodshed, all the deaths add up to nothing and people forget the tragedy as quickly as they forget a bus falling into a ravine or a train toppling over at high speed. The statistics of death don’t scare us any more. What scares us is the way it happened.

That’s the difference between an accident, an Act of God, and a terrorist strike, though some fanatics would like us to believe that a terrorist strike is an Act of God. It is not. It is just another criminal act, plotted and planned by criminals, and often executed by some foolish, misled young men who are angry with life and society. There was a time, when I would have added the word poor to describe them. No longer. The kind of people who plot, plan and execute terror acts are no more poor, illiterate, foolish people who have been misguided by criminals masquerading as religious or political leaders. As Kasab told the courts, he was sold off to the Lashkar by his father when he was a kid. He grew up indoctrinated.

Today’s terrorists are a different lot altogether. They are smart, educated, well brought up young men and women who have wilfully taken to terrorism to fight for what they see as their cause. To defeat them is not easy and, as time goes on, it will become even more difficult because they are no longer people you can easily recognise or would even suspect as potential terrorists. Many of them are white. Some come from affluent Western families. No, they are no longer recruited from poor, third world nations. Terrorists come today dressed in Armani suits, flaunting Ivy League badges. Surprise is their secret weapon. That’s how their first axiom is best served, to spread gut wrenching fear. That’s what gets them the headlines.

Headlines are what terrorists die for. Headlines and non-stop television coverage. That’s why 9/11 was such a great success for them. That’s why 12/10 in Bali, 7/7 in London, 26/11 in Mumbai were such famous strikes. The recent bomb blasts in Peshawar and Rawalpindi are no match. They were just messages to the ISI from their former protégés, to warn the Pakistan establishment that they won’t let them rest in peace as long as they play surrogate to the US army in return for billions of dollars in aid. It’s never easy to pull back the demons you unleash. Yes, people are dying in these terror attacks. There’s lots of bloodshed. Women, children, ordinary people are getting drawn into this tragic vortex of violence. But none of this is as important as headlines. Headlines create fear, panic, terror. For terrorists, headlines are everything.

So every time we revive memories of 26/11, show hours and hours of TV coverage, write long scary articles on how terrorism has destroyed our lives and liberties, we are actually encouraging the terrorists, helping them build their superstructure of fear. Terrorists do not need to celebrate the success of 9/11 or 26/11. We are doing it for them, even as we weep for the victims and tell the world that we are better prepared to face future strikes. Let’s not kid ourselves. Terrorism is the scourge of our times and no Government, no police force is ever adequately equipped to anticipate it. The more we talk about the pain, the horror, the memories of these terrible events, the more the perpetrators celebrate, the more they go down in history as villains or heroes, depending on who is providing the perspective, and to whom. In the wilds of tribal Pakistan where the Taliban is schooling its recruits, Kasab is a hero and his dead colleagues, martyrs to the Cause.

It’s important, therefore, to treat such anniversaries with caution and circumspection. We don’t really need to overload the nation with cardiac stress. 26/11 was a terrible tragedy and also a moment of amazing heroism. We lost some of our finest policemen and many innocent people who had no reason to die. But our future lies not in recalling its memories and reassuring the rascals who perpetrated it that they had struck home and caused us unforgettable pain. It’s no use crying over our failures, our mistakes. It’s important to be prepared for the future, as prepared as we can possibly be, but it’s even more critical to move on with our lives, show the world we are not afraid. Terrorism may hurt us but it cannot break our spirit, our resolve. Therein lies our courage, our wisdom as a nation.

And therein lies defeat for those who use terrorism as their weapon.

Slowloris HTTP DoS Attcak
Nov 26th, 2009 by anand




Slowloris HTTP DoS


Slowloris – the low bandwidth, yet greedy and poisonous HTTP client!

Written by RSnake with help from John Kinsella, and a dash of inspiration from Robert E Lee.

In considering the ramifications of a slow denial of service attack against particular services, rather than flooding networks, a concept emerged that would allow a single machine to take down another machine’s web server with minimal bandwidth and side effects on unrelated services and ports. The ideal situation for many denial of service attacks is where all other services remain intact but the webserver itself is completely inaccessible. Slowloris was born from this concept, and is therefore relatively very stealthy compared to most flooding tools.

Slowloris holds connections open by sending partial HTTP requests. It continues to send subsequent headers at regular intervals to keep the sockets from closing. In this way webservers can be quickly tied up. In particular, servers that have threading will tend to be vulnerable, by virtue of the fact that they attempt to limit the amount of threading they’ll allow. Slowloris must wait for all the sockets to become available before it’s successful at consuming them, so if it’s a high traffic website, it may take a while for the site to free up it’s sockets. So while you may be unable to see the website from your vantage point, others may still be able to see it until all sockets are freed by them and consumed by Slowloris. This is because other users of the system must finish their requests before the sockets become available for Slowloris to consume. If others re-initiate their connections in that brief time-period they’ll still be able to see the site. So it’s a bit of a race condition, but one that Slowloris will eventually always win – and sooner than later.

Slowloris also has a few stealth features built into it. Firstly, it can be changed to send different host headers, if your target is a virtual host and logs are stored seperately per virtual host. But most importantly, while the attack is underway, the log file won’t be written until the request is completed. So you can keep a server down for minutes at a time without a single log file entry showing up to warn someone who might watching in that instant. Of course once your attack stops or once the session gets shut down there will be several hundred 400 errors in the web server logs. That’s unavoidable as Slowloris sits today, although it may be possible to turn them into 200 OK messages instead by completing a valid request, but Slowloris doesn’t yet do that.

HTTPReady quickly came up as a possible solution to a Slowloris attack, because it won’t cause the HTTP server to launch until a full request is recieved. This is true only for GET and HEAD requests. As long as you give Slowloris the switch to modify it’s method to POST, HTTPReady turns out to be a worthless defense against this type of attack.

This is NOT a TCP DoS, because it is actually making a full TCP connection, not a partial one, however it is making partial HTTP requests. It’s the equivalent of a SYN flood but over HTTP. One example of the difference is that if there are two web-servers running on the same machine one server can be DoSed without affecting the other webserver instance. Slowloris would also theoretically work over other protocols like UDP, if the program was modified slightly and the webserver supported it. Slowloris is also NOT a GET request flooder. Slowloris requires only a few hundred requests at long term and regular intervals, as opposed to tens of thousands on an ongoing basis.

Interestingly enough, in testing this has been shown in at least one instance to lock up database connections and force other strange issues and errors to arise that can allow for fingerprinting and other odd things to become obvious once the DoS is complete and the server attempts to clean itself up. I would guess that this issue arises when the webserver is allowed to open more connections than the database is, causing the database to fail first and for longer than the webserver.

Slowloris lets the webserver return to normal almost instantly (usually within 5 seconds or so). That makes it ideal for certain attacks that may just require a brief down-time. As described in this blog post, DoS is actually very useful for certain types of attacks where timing is key, or as a diversionary tactic, etc….

This affects a number of webservers that use threaded processes and ironically attempt to limit that to prevent memory exhaustion – fixing one problem created another. This includes but is not necessarily limited to the following:

  • Apache 1.x
  • Apache 2.x
  • dhttpd
  • GoAhead WebServer
  • WebSense “block pages” (unconfirmed)
  • Trapeze Wireless Web Portal (unconfirmed)
  • Verizon’s MI424-WR FIOS Cable modem (unconfirmed)
  • Verizon’s Motorola Set-Top Box (port 8082 and requires auth – unconfirmed)
  • BeeWare WAF (unconfirmed)
  • Deny All WAF (unconfirmed)

There are a number of webservers that this doesn’t affect as well, in my testing:

This is obviously not a complete list, and there may be a number of variations on these web-servers that are or are not vulnerable. I didn’t test every configuration or variant, so your mileage may vary. This also may not work if there is an upstream device that somehow limits/buffers/proxies HTTP requests. Please note though that Slowloris only represents one variant of this attack and other variants may have different impacts on other webservers and upstream devices. This command should work on most systems, but please be sure to check the options as well:

perl slowloris.pl -dns example.com

Requirements: This is a Perl program requiring the Perl interpreter with the modules IO::Socket::INET, IO::Socket::SSL, and GetOpt::Long. Slowloris works MUCH better and faster if you have threading, so I highly encourage you to also install threads and threads::shared if you don’t have those modules already. You can install modules using CPAN:

perl -MCPAN -e ‘install IO::Socket::INET’

perl -MCPAN -e ‘install IO::Socket::SSL’

Windows users: You probably will not be able to successfuly execute a Slowloris denial of service from Windows even if you use Cygwin. I have not had any luck getting Slowloris to successfuly deny service from within Windows, because Slowloris requires more than a few hundred sockets to work (sometimes a thousand or more), and Windows limits sockets to around 130, from what I’ve seen. I highly suggest you use a *NIX operating system to execute Slowloris from for the best results, and not from within a virtual machine, as that could have unexpected results based on the parent operating system.

Version: Slowloris is currently at version 0.7 – 06/17/2009

Download: slowloris.pl

Getting started: perldoc slowloris.pl

Issues: For a complete list of issues look at the Perl documentation, which explains all of the things to think about when running this denial of service attack.



HOWTO to set-up Apple’s Darwin Streaming Server under Linux
Nov 24th, 2009 by anand


HOWTO to set-up Darwin Streaming Server under Linux

Darwin Streaming Server is the version for Linux, Solaris and FreeBSD of their free QuickTime Streaming Server, which is solely for Mac OS X. It can be used to stream live video over the RTSP protocol as well as for sending live MPEG-3 audio broadcasts. It also provides for a media server for archives, delivering video and audio in stand-alone file format or as a stream.

The main issue with the software currently is it’s licence. It is released under Apple’s Apple Public Source License, version 2.0 of which according to the Free Software Foundation is a compatible free software licence, although it is not compatible with the GNU Public Licence. Please refer to the what the Free Software Foundation has to say about the APSL 2.0 and the APSL 2.0 licence itself before proceeding to download, install and use (and possibly even modify) Darwin Streaming Server.

The benefit of the software is that it’s free to download and generally works very well. The caveat is generally heralded as being that although you use a free software platform such as Linux, FreeBSD or Darwin to run the server, you still are likely to need a Macintosh running OS X to be able to broadcast your stream. The most commonly used tool for this is Apple’s QuickTime Broadcaster, which is once again a free download, but it is a closed-source product. You are also able to send from programmes such as the open source Pure Data (Pd).

To connect to the stream, you’ll need a compatible player. This is normally QuickTime Player, but there are also a number of options for those of us who run Linux or FreeBSD. See this document for various tips on this topic.

Anyway enough said. Let’s get on with setting it up.

Downloading

I’ve found it occasionaly difficult to actually find the page for downloading the software. You also need to sign-up to the Apple Developer Connection and accept various licences before you’re allowed to.

Note: there is a new version (6.0.3) of DSS available from Apple, but they haven’t made an install for Linux yet. I am currently in the process of evalutation the install in order to update these instructions. For now I suggest you use the latest Linux supported version 5.5.5 as detailed below.

*Note: In the past, I have had good results with version 4.1.3 of the server, at least under Debian. This version is no longer available from Apple’s site, but you can download it here. Other than that, I’ve found version 5.0 to be rather poor and it did not work very well at all under Linux. So the recommendation is to use the current version 5.5.5, or if that doesn’t work for you, then 4.1.3.

Installing Darwin Streaming Server on Linux

  • Untar it: tar xfz DarwinStreamingSrvr5.5.5-Linux.tar.gz
  • Change to the new directory: cd DarwinStreamingSrvr5.5.5-Linux
  • Create group: groupadd qtss
  • Install: ./Install
  • Enter username and password
  • Start it: /usr/local/sbin/streamingadminserver.pl

First time set-up

Point your favourite web browser at http://yourserver:1220, where yourserver is the IP address or name of the server that you installed Darwin Streaming Server on in the previous step. You should get presented with the login screen:

Enter the username and password you specified when you installed and click ‘Log In’, you’ll be taken to the next screen to set-up the password for MP3 broadcast:

Enter some password here. This you will use to give to those who wish to do MP3 audio broadcasts to your streaming server, although you should consider using Icecast instead for this rôle as it also supports Ogg/Vorbis format. Click ‘Next’, and you’ll get to:

Now this screen asks you if you’re using SSL to access the server. This HOWTO doesn’t currently cover setting up SSL for Darwin Streaming Server, so for now it will suggest you don’t tick the box and that you simply click ‘Next’ to get to:

Here you should enter the directory on the server where your media archive is. This will be the location that you store your video and audio files (mov and mp3) to be streamed out by the server. It is also where the server will create it’s sdp files for both live and archived streams. The default is /usr/local/movies/. You should check that this directory exists on your server and that there is sufficient disc space for the partition where this directory is located. If not, then choose where to keep them, create the directory if necessary (the ‘qtss’ user will need write permissions) and then click ‘Next’ to get to:

Streaming on port 80 can be useful, but not if you’re running a web server as it will clash with it. If you are, then do not select this option. If you aren’t then you probably don’t want to do it anyway. It’s useful for getting through certain firewalls, but there are other ways to do it, and you can always enable it at a later date anyway. So just click ‘Finish’ and you should get to the main screen:

Congratulations you have installed and configured Darwin Streaming Server.

Further enhancements and hacks for Darwin Streaming Server 5.5

The following is a list of tricks, tips and hacks that are verified by the author to work with version 5.5 of Darwin Streaming Server:

Run alongside Icecast without a hitch

You may well be also wishing to run or already running Icecast for streaming audio. Although Darwin Streaming Server does provide the facility for MP3 streaming, I would reccommend that you use Icecast for this; Icecast supports both MP3 and OGG streaming of audio (and video using Theora).

Now Icecast by default runs on ports 8000 & 8001, but Darwin Streaming Server also expects to run on these ports by default. If you start the DSS process before Icecast on your server, DSS will grab ports 8000 and 8001 and stop Icecast from starting up. What you need to do is to stop DSS from doing this by editing the file /etc/streaming/streamingserver.xml and looking for an entry similar to:

      
	<LIST-PREF NAME="rtsp_port" TYPE="UInt16" >
	  <VALUE>554</VALUE>
	  <VALUE>7070</VALUE>
	  <VALUE>8000</VALUE>
	  <VALUE>8001</VALUE>
	</LIST-PREF>
      
    

And remove the two lines containing the entries for ‘8000′ and ‘8001′.

Disabling MP3 streaming

You may choose to run a different server, such as Icecast or Shoutcast for MP3 streaming. If you do that, you may like to disable MP3 streaming in Darwin Streaming Server. Do this by changing the option for mp3_streaming_enabled under the MODULE section for QTSSMP3StreamingModule from true to false. E.g.:

      
	<MODULE NAME="QTSSMP3StreamingModule" >
	  ...
	  <PREF NAME="mp3_streaming_enabled" TYPE="Bool16" >false</PREF>
	  ..
	</MODULE>
    
    

Disabling all authentication

You can disable all authentication for the whole of Darwin Streaming Server by editing the file /etc/streaming/streamingserver.xml and by changing the option for Authenticate under the MODULE section for QTSSAdminModule from true to false. E.g.:

      
	<MODULE NAME="QTSSAdminModule" >
	  ...
	  <PREF NAME="Authenticate" TYPE="Bool16" >false</PREF>
	  ...
      </MODULE>
      
    

Other links and downloads

Guide to Forming A Company In India
Nov 18th, 2009 by anand

Introduction – Forming A Company In India

The Companies Act of 1956 sets down rules for the establishment of both public and private companies. The most commonly used corporate form is the limited company, unlimited companies being relatively uncommon. A company is formed by registering the Memorandum and Articles of Association with the State Registrar of Companies of the state in which the main office is to be located.

Foreign companies engaged in manufacturing and trading activities abroad are permitted by the Reserve Bank of India to open branch offices in India for the purpose of carrying on the following activities in India:
# To represent the parent company or other foreign companies in various matters in India, for example, acting as buying/selling agents in India, etc.

# To conduct research work in which the parent company is engaged provided the results of the research work are made available to Indian companies

# to undertake export and import trading activities

# to promote possible technical and financial collaboration between Indian companies and overseas companies.

Application for permission to open a branch, a project office or liaison office is made via the Reserve Bank of India by submitting form FNC-5 to the Controller, Foreign Investment and Technology Transfer Section of the Reserve Bank of India. For opening a project or site office, application may be made on Form FNC-10 to the regional offices of the Reserve Bank of India. A foreign investor need not have a local partner, whether or not the foreigner wants to hold full equity of the company. The portion of the equity thus not held by the foreign investor can be offered to the public.

Incorporating a Company – Approval of Name

The first step in the formation of a company is the approval of the name by the Registrar of Companies (ROC) in the State/Union Territory in which the company will maintain its Registered Office. This approval is provided subject to certain conditions: for instance, there should not be an existing company by the same name. Further, the last words in the name are required to be “Private Ltd.” in the case of a private company and “Limited” in the case of a Public Company. The application should mention at least four suitable names of the proposed company, in order of preference. In the case of a private limited company, the name of the company should end with the words “Private Limited” as the last words. In case of a public limited company, the name of the company should end with the word “Limited” as the last word. The ROC generally informs the applicant within seven days from the date of submission of the application, whether or not any of the names applied for is available. Once a name is approved, it is valid for a period of six months, within which time Memorandum of Association and Articles of Association together with miscellaneous documents should be filed. If one is unable to do so, an application may be made for renewal of name by paying additional fees. After obtaining the name approval, it normally takes approximately two to three weeks to incorporate a company depending on where the company is registered.
Memorandum and Articles

The Memorandum of Association and Articles of Association are the most important documents to be submitted to the ROC for the purpose of incorporation of a company. The Memorandum of Association is a document that sets out the constitution of the company. It contains, amongst others, the objectives and the scope of activity of the company besides also defining the relationship of the company with the outside world.

The Articles of Association contain the rules and regulations of the company for the management of its internal affairs. While the Memorandum specifies the objectives and purposes for which the Company has been formed, the Articles lay down the rules and regulations for achieving those objectives and purposes.

The ROC will give the certificate of incorporation after the required documents are presented along with the requisite registration fee, which is scaled according to the share capital of the company, as stated in its Memorandum. A private company can commence business on receipt of its certificate of incorporation.

A public company has the option of inviting the public for subscription to its share capital. Accordingly, the company has to issue a prospectus, which provides information about the company to potential investors. The Companies Act specifies the information to be contained in the prospectus.

The prospectus has to be filed with the ROC before it can be issued to the public. In case the company decides not to approach the public for the necessary capital and obtains it privately, it can file a “Statement in Lieu of Prospectus” with the ROC.
On fulfillment of these requirements, the ROC issues a Certificate of Commencement of Business to the public company. The company can commence business immediately after it receives this certificate.

Certificate of Incorporation

After the duly stamped Memorandum of Association and Articles of Association, documents and forms are filed and the filing fees are paid, the ROC scrutinizes the documents and, if necessary, instructs the authorised person to make necessary corrections. Thereafter, a Certificate of Incorporation is issued by the ROC, from which date the company comes in to existence. It takes one to two weeks from the date of filing Memorandum of Association and Articles of Association to receive a Certificate of Incorporation. Although a private company can commence business immediately after receiving the certificate of incorporation, a public company cannot do so until it obtains a Certificate of Commencement of Business from the ROC.

Miscellaneous Documents

The documents/forms stated below are filed along with Memorandum of Association and Articles of Association on payment of filing fees (depending on the authorised capital of the company):

# Declaration of compliance, duly stamped
# Notice of the situation of the registered office of the company
# Particulars of Directors, Manager or Secretary
# Authority executed on a non-judicial stamp paper, in favour of one of the subscribers to the Memorandum of Association or any other person authorizing him to file the documents and papers for registration and to make necessary corrections, if any
# The ROC’s letter (in original) indicating the availability of the name.

Tax Registration

Businesses liable for income tax must obtain a tax identification card and number [known as Permanent Account Number (PAN)] from the Revenue Department. In addition to this, businesses liable to withhold tax must necessarily obtain a Tax Deduction Account Number (TAN). Both the PAN and the TAN must be indicated on all the returns, documents and correspondence filed with the Revenue Department. The PAN is also required to be stated in various other documents such as the documents pertaining to sale or purchase of any immovable property (exceeding Rs. five lakh), sale or purchase of a motor vehicle, time deposit (exceeding Rs. 5 lakh), contract for sale or purchase of securities (exceeding Rs. 10 lakh), to name a few.

Rules Applicable

Companies (Central Governments’) General Rules and Forms,1956

Filing Registering/Approving Authority

One copy has to be submitted along with a forwarding letter addressed to the concerned Registrar of Companies.
Enclosures

The declaration must be submitted with the following annexures
# Document evidencing payment of fee
# Memorandum and Articles of Association
# Copy of agreement if any, which the proposed company wishes to enter into with any individual for appointment as its managing or whole-time director or manager
# Form 18
# Form 32 (except for section 25 company)
# Form 29 (only in case of public companies)
# Power of Attorney from subscribers
# Letter from Registrar of Companies making names available
# No objection letters from directors/promoters
# Requisite fees either in cash or demand draft

Fees

Fee payable depends on the nominal capital of the company to be registered and may be paid in one of the following modes. Cash/postal order (upto Rs.501-), demand draft favouring Registrar of Companies/Treasury Challan should be payable into specified branches of Punjab National Bank for credit

Time-Limit / Practice Notes

Time-Limit
It should be submitted before incorporation or within 6 months of the name being made available. Top

Practice Notes
The declaration has to be signed by an advocate of Supreme Court or High Court or an attorney or pleader entitled to appear before the High Court or a secretary or chartered accountant in whole-time practice in India who is engaged in the formation of the proposed company or person named in the articles as director, manager or secretary.

The Registrar of Companies has to be satisfied that not only the requirements of section 33(1) and (2) have been complied with but be also satisfied that provisions relating to number of subscribers, lawful nature of objects and name are complied with.

The Registrar will check whether the documents have been duly stamped and also whether the requirements of other laws are met.

Any defect in any of the documents filed has to be rectified either by all the subscribers or their attorney, or by any one subscriber holding the power of attorney on behalf of other subscribers.

This form is to be presented to the Registrar of Companies within three months from the date of letter of Registrar allowing the name.

This declaration is to be given on a non-judicial stamp paper of the requisite value . The stamp paper should be purchased in the name of the person signing the declaration.

This declaration is to be given by all the companies at, the time of registration, public or private.

The place of Registration No. of the company should be filled up by mentioning New Company therein.

The Registrar of Companies will now accept computer laser printed documents for purposes of registration provided the documents are neatly and legibly printed and comply with the other requirements of the Act. This will be an additional option available to the public to use laser print besides offset printing for submitting the memorandum and articles for the registration of companies.

Where the executant of a memorandum of association is illiterate, he shall give his thumb impression or marks which should be described as such by the subscriber or person writing for him.

An agent may sign a memorandum on behalf of a subscriber if he is authorised by a power-of-attorney to do so. In the case of an illiterate subscriber to the memorandum and articles of association, the thumb impression or mark duly attested by the person writing for him should be given. The person attesting the thumb mark should make an endorsement on the document to the effect that it has been read and explained to the subscriber. The Registrar of Companies will not accept zerox copies of the memorandum and articles of association for the purposes of registration of companies.

Presented by

This declaration is to be presented by the person signing the declaration or by his bearer at the counter of the Registrar of Companies office.

Managerial Remuneration

# Any person in order to be appointed as the Managing Director of the company should be a resident of India. Any person, being a non-resident in India, must obtain an Employment Visa from the concerned Indian mission abroad at the time of their appointment as the Managing Director.

# Whereas private companies are free to pay any remuneration to its directors, public companies can remunerate their directors only within the specified limits.

# In case of public companies, in the event of absence or inadequacy of net profits in any financial year, managerial remuneration is limited to amounts varying from Rs 75,000 to Rs 2,00,000 per month, depending on the effective capital of the company. In case of an expatriate managerial person, perquisites in the form of children’s education allowance, holiday passage money and leave travel concession provided to him would not form part of the said ceiling of remuneration.

# In case of a managerial position in two companies, remuneration can be drawn from one or both companies provided that the total remuneration drawn from the companies does not exceed the higher maximum limit admissible from any one of the companies of which he is a managerial person.

With whom to be filed

With the Registrar of Companies of the State in which the company is to be registered.

Documents required to be submitted
# A printed copy each of the Memorandum and Articles of Association of the proposed company filed along with the declaration duly stamped with the requisite value of adhesive stamps from the State/ Union Territory Treasury (For value of stamps to be affixed see Schedule printed in Part III Chapter 23). Below the subscription clause the subscribers to the Memorandum should write in his own handwriting his full name and father’s, or husband’s full name in block letters, full address, occupation, e.g.,’business executive, engineer, housewife, etc. and number of equity shares taken and then put his or her signatures in the column meant for signature. Similarly at the end of the Articles Of Association the subscriber should write in his own handwriting : his full name and father’s full name in block letters, full address, occupation. The signatures of the subscribers to the Memorandum and the Article of Association should be witnessed by one person preferably by the person representing the subscribers, for registration of the proposed company before the Registrar of Companies. Under column ‘Total number of equity shares’ write the total of the shares taken by the subscribers e.g., 20 (Twenty) only. Mention date e.g. 5th day of August, 1996. Place-e.g. , ‘New Delhi’.

# With the stamped copy, one spare copy each of the Memorandum and Articles of Association of the proposed company.

# Original copy of the letter of the Registrar of Companies intimating the availability of name.

# Form No. 18 – Situation of registered office of the proposed company.

# Form No. 29-Consent to act as a director etc. Dates on the consent Form and the undertaking letters should be the same as is mentioned in the Memorandum of Association signed by the director himself. A private company and a wholly-owned Government company are not required to file Form No. 29.

# Form No. 32 (in duplicate). Particulars of proposed, directors, manager or secretary.

# Power of attorney duly typed on a non-judicial stamp paper of the requisite value. The stamp paper should be purchased in the name of the persons signing the authority.

# No objection letter from the persons whose name has been given in application for availability of name in Form No. 1-A as promoters/directors but are not interested at a later stage should be obtained filed with the Registrar at the time of submitting documents, for registration

# The agreements, if any, which the company proposes to enter with any individual for, appointment as managing or whole-time director or manager are also to be filed.

Fee payable
Cash or a bank draft/ pay order treasury challan should be drawn in the name of the Registrar of Companies of the State in which the Company is proposed to be registered as per Schedule X.

Reporting Requirements

Annual Accounts
The Indian company law does not prescribe the books of accounts required to be maintained by a company. It, however, provides that the same should be kept on accrual basis and according to the double entry system of accounting and should be such as may be necessary to give a true and fair state of affairs of the company.

The Indian company law requires every company to maintain proper books of account with respect to the following:
# All sums of money received and expended and the matters in respect of which the receipt and expenditure take place
# All sales and purchases of goods by the company
# The assets and liabilities of the company
# In case of companies engaged in manufacturing, processing, mining etc, such particulars relating to utilization of material or labour or other items of cost.

The first annual accounts of a newly incorporated company should be drawn from the date of its incorporation upto to the day not preceding the AGM date by more than 9 months. Thereafter, the accounts should be drawn from date of last account upto the day not preceding the AGM date by more than 6 months subject to the extension of the time limit in certain cases. The accounts of the company must relate to a financial year (comprising of 12 months) but must not exceed 15 months. The company can obtain an extension of the accounting period to the extent of 18 months by seeking a prior permission from the ROC.
The annual accounts must be filed with the ROC within 30 days from the date on which the Annual General Meeting (AGM) of the company was held or where the AGM is not held, then within 30 days of the last date on which the AGM was required to be held.
Books of accounts to be kept by company

Every company is required to maintain proper books of account with respect to all sums of money received and expended, all sales and purchases of goods, the assets and liabilities. Central Government may also specifically require the maintenance of certain additional particulars with respect to certain classes of Companies. The books of account relating to eight years immediately preceding the current year together with supporting vouchers are required to be preserved in good order. Every profit and loss account and balance sheet of the company (together referred to as financial statements) is required to comply with the accounting standards issued by the Institute of Chartered Accountants of India. Any deviations from the accounting standards, including the reasons and consequent financial effect, is required to be disclosed in the financial statements.

The responsibility for the preparation of financial statements on a going concern basis is that of the management. The management is also responsible for selection and consistent application of appropriate accounting policies, including implementation of applicable accounting standards along with proper explanation relating to any material departures from those accounting standards. The management is also responsible for making judgements and estimates that are reasonable and prudent so as to give a true and fair view of the state of affairs of the entity at the end of the financial year and of the profit or loss of the entity for that period.

Annual Return
Every company having a share capital is required to file an annual return with the ROC within 60 days from the date on which the AGM of the company was held or where the AGM is not held, then within 60 days of the last date on which the AGM was required to be held.

Certain Accounting related issues

Depreciation
The company law in India permits the use of depreciation rates according to the nature of the classes of assets. Assets can be depreciated either on the basis of straight-line method (based on the estimated life of the asset) or on the basis of reducing balance method. The law prescribes the minimum rates of depreciation. A company may, however, provide for a higher rate of depreciation, based on a bonafide technological evaluation of the asset. Adequate disclosure in the annual accounts must be made in this regard.

Dividend
There is no limit on the rate of dividend but there are certain conditions prescribed with regard to computation of profits that can be distributed as dividend. Generally, no dividend can be paid for any financial year except out of the profits of that year after making an adequate provision for depreciation subject to certain conditions.
Dividends may also be distributed out of accumulated profits.

Repatriation of profits
A company has to retain a maximum of 10% of the profits as reserves before the declaration of dividends. These reserves, inter alia, can be subsequently converted into equity by way of issue of bonus shares. Dividends are freely repatriable once the investment approval is granted.

Imposition of taxes
Currently, domestic companies are taxable at the rate of 35.875% (inclusive of surcharge of 2.5%) on its taxable income. Foreign companies are taxed at a marginally higher rate of 41% (including surcharge of 2.5%). However, in case where the income tax liability of the company under the provisions of the domestic tax laws works out to less than 7.5% of the book profits (derived after making the necessary adjustments), a Minimum Alternate Tax of 7.6875% (including a surcharge of 2.5%) on the book profits, would be payable. Domestic companies are required to pay a dividend distribution tax of 12.8125% (including surcharge of 2.5%) on the dividends distributed during the year.

Companies are required to withhold tax under the domestic law from certain payments including salaries paid to employees, interest, professional fee, payments to contractors, commission, winnings from games / lottery / horse races etc. Moreover, taxes have to be withheld from all payments made to non-residents at the lower of rates specified under the domestic law or under the applicable tax treaty, if any.

Penalty

# Imprisonment up to two years and fine
# Person liable for default
# Person signing the declaration.

Is Raj Thackeray Right or Wrong ? You decide ..
Nov 18th, 2009 by anand

There’s is something about the nomenclatural identity of India’s 28 states. All, except one, have names with either regional (Gujarat, Tamil Nadu, Nagaland) or geographical (Uttar Pradesh, Madhya Pradesh) significance. Maharashtra, which means ‘Greater Nation’, is an exception; its self-identification is national.
It is, therefore, distressing that certain local political formations in Maharashtra succumb to the temptation of parochialism every once in a while by projecting non-existent antagonism between ‘natives’ and ‘outsiders’. Invariably, it is Mumbai, India’s first and still the most cosmopolitan city, which bears the brunt of their insularity. In the 1960s, their target was Dakshin Bharatiyas (South Indians). Now, resentment is sought to be whipped up against Uttar Bharatiyas (North Indians).

The notion that any city or part of India belongs only to its ‘natives’ is unconstitutional, repugnant and injurious to the ideal of national unity and integration. From time immemorial, our people have freely moved from one part of the country to another, believing all of India to be their own. As far as Mumbai is concerned, although it is the capital of Maharashtra, people from every corner of the country have migrated to this city of dreams and opportunities since its inception. Mumbai is what it is today because of the contribution of diverse communities inhabiting it. In particular, the two sources of its national and international profile — business and Bollywood — would be unthinkable without a grateful recognition of the role of non-Marathi speaking communities. It would be a great misfortune if Mumbai degenerated into a provincial capital.

Therefore, Raj Thackeray, whose Maharashtra Navanirman Sena has made impressive strides in a short time after breaking away from the Shiv Sena, has done no good either to Maharashtra’s proud reputation, or to himself, by making ill-advised remarks about North Indians in Mumbai or about a national icon like Amitabh Bachchan. He has a promising political future. He would, therefore, do well to win the support of the city’s considerable population of North Indians in his inclusive political strategy, without being apologetic about espousing legitimate Marathi pride.

While one must condemn anything that weakens our unifying Indian identity, it would be hypocritical to turn a blind eye to certain harsh social and political realities of Mumbai. With 2 crore residents in the Mumbai Metropolitan Area, which includes Navi Mumbai and Thane, its population has rapidly grown to become greater than the combined population of nine Indian states. Its once-famed infrastructure is highly overstretched, lowering the quality of life for rich and poor alike. It once had the best municipal governance in India; not any more. Fifty-four per cent of its residents live in slums, most of which are so unbelievably congested and squalid that it is criminal on the part of any government to let people live in such inhuman conditions. It is well known to authorities that tens of thousands of Bangladeshis, many with voting rights, are living in Mumbai. Some 20,000 houses in the older part of the city are in a dangerously dilapidated state, the reason why every monsoon one reads about people dying in incidents of house collapse.

Mumbai is decaying. But few politicians in the city, state or country are taking a serious and comprehensive view of its chronic condition, and fewer still are willing to take the tough decisions to set things right. By tough decisions, one does not mean banning ‘outsiders’ — north Indians or Indians from any other part of India — from settling in Mumbai. That certainly is wrong. But is it wrong to hold that encroachments should be stopped, that people must not be allowed to occupy pavements and places earmarked for public utilities, or that the cut-off years for regularisation of slums must be strictly adhered to?

Indeed, some political parties have developed a vested interest in allowing unauthorised settlements to proliferate for vote-bank considerations. When illegal settlements along the lethally polluted Mithi river were sought to be cleared after the July 2005 deluge in Mumbai, which claimed nearly 500 lives, it was stoutly resisted by local politicians who felt threatened that their voter-base would shrink. Mumbaikars know of hundreds of such examples of duplicity and political muscle-flexing.

The question that Raj Thackeray and many people in Mumbai are asking is: How can slum redevelopment and rehabilitation ever succeed if there is political patronage for the creation of new slums? How can Mumbai ever see orderly urban development, with world-class infrastructure and civic amenities for all its residents, if there is deliberate and corruption-induced disorder in the use of its most scarce resource — land? Indeed, which Indian city can grow well if short-term and partisan political interests undermine a long-term and integral vision of urban renewal?

Hence, some of Raj Thackeray’s concerns are right, but he has voiced them wrongly.

RTP, RTSP, Unicast, Multicast…sheesh!
Nov 18th, 2009 by anand


UDP, TCP, RTP, RTSP, Unicast, Multicast…

It sounds a bit complex, all this network
protocol stuff!  Well, sorry, it can be intimidating.  But I promise
this will not be too painful if you read slowly.  Actually you may find
this interesting.

The best I can do is to try to make the concepts
simple.  Let’s start with an assumption that you already know how a website
does multicasting.  For a review of multicasting, see White
Papers.  

 

MPEG-1 and MPEG-2 both combine audio and video
into a series of 1’s and 0’s.  Exactly how those 1’s and 0’s are created is
defined by the MPEG standards.  So, when we say "MPEG-2 Transport
Stream", we can look at a document and agree on what we mean. MPEG-1 and
MPEG-2 are self sufficient, but they do little to specify exactly how they might
be transmitted over IP.  

MPEG-4 is also self-sufficient, but rather than
defining unique "MPEG" ways of sending video, it specifies sending the
video using existing standards.  Among those standards are IP, RTP and
RTSP, but I’m getting ahead of myself.  We must start with simple concepts.

 

Networking Concepts

TCP

It seems everyone’s heard of
"TCP/IP".  You probably know that "IP" stands for
"Internet Protocol".  The "TCP" stands for "Transmission
Control Protocol
".  Here is the deal:  to ensure a
packet arrives without errors, the sender of a packet keeps an extra copy and
waits for the receiver to say "I got it okay".  If the sender
hears this from the receiver, the sender can discard that extra copy.  If
the receiver says "I didn’t get it" or says nothing at all after
awhile, the sender resends it.  As you can see, this makes for reliable
delivery but takes time.  It also adds a great deal of overhead because
there is a dialog between the sender and receiver.  Practically all email,
web pages, and other Internet traffic is sent using TCP/IP.

TCP is a key reason why your web traffic or email
"slows down" but does not "break".  When there is too
much traffic, your packets may be discarded or lost somewhere…but not to
worry! Without you even knowing it, your packets are being resent until they
finally get through (and you thought you just had a "good"
connection).

Analogy:  TCP is like a telephone
call.  If you didn’t hear what the other person said, you say
"What?"

 

UDP

UDP stands for "User
Datagram Protocol
".  It is sometimes called "send and
pray" because there is no dialog between the sender and receiver.  If
the receiver does not get a packet, the sender will never know.  "When
the heck would I want that!" you may ask.  Well, UDP is very efficient
when there is little chance of errors (like in your LAN), or when TCP would
provide "too late" delivery.  

All video is sent via UDP.  Hey, we
are sending live video, right?  If I send you video frame #1, #2, #3 ….
#1000 and you display the video frames in real time as you receive them, and you
didn’t get frame #500, what would you do with new frame #500 if I resent it to
you?  Display it after frame #1000? That wouldn’t look too good, would it?

Video is normally send via UDP.  But there
is trouble with UDP now-adays.  Many corporate firewalls block all UDP
packets, making it impossible for streaming video to reach desktops.  This
is done to prevent hackers from getting access to the network, and is also
sometimes done to prevent excessive use of bandwidth.  More on this later.

Analogy: UDP is like a public address
system.  If you didn’t hear what was announced, you can’t hear it again.

 

RTP

RTP stands for Real-time
Transport Protocol.
  It is normally sent via UDP. It does not ensure
"real time" but is a protocol that enhances the control and
synchronization of real time stuff (like streaming video).  Here is where
it gets interesting:  with MPEG-1 and MPEG-2, RTP is unnecessary because
MPEG itself provides synchronization (see White
Paper
).   Like so many standards, there are several ways to
implement it.  For example, you can split apart the MPEG-1 stream and send
audio on one IP address and video on another, or you can send both audio &
video on the same address.  RTP provides timestamps that will provide
audio/video sync. 

In the case of MPEG-4, the only meaningful way to
send audio/video is via RTP (there is nothing like a "MPEG-1 System
Stream" nor a "MPEG-2 Transport Stream").  In other words,
for MPEG-4, a/v sync is provided via RTP.

Analogy: RTP is like an orchestra leader,
keeping all the musicians in sync.

 

RTSP

RTSP stands for Real
Time Streaming Protocol
. RTSP is control protocol, not to be confused with
IP, TCP, or UDP.  However, RTP and RTSP are linked. You could find RTP
without RTSP, but you would not find RTSP without RTP.

A good way to position RTSP in your mind is to
think of it the same way you think of "http" and
"ftp".  You know, if you want to see a web page, you will enter
"http://something".  If you want to view a video in a player, you
will enter "rtsp://something".  This is only true for unicast
streams, where each viewer receives their own stream from the server; RTSP is not used for multicast.

Analogy:  RTSP is like a "touch
tone" telephone vs. the old rotary dial telephone.  It is merely a
method of signaling.

 

HTTP

The Hyper
Text Transfer Protocol
is often confused with the Hyper Text Markup
Language.  Its description is beyond the scope of this page, and on the
surface seems out of place here.  However, because virtually all firewalls
allow the default http port (port 80) to pass, streaming video can be sent via
http "tunneling".  There is a severe penalty, since http is sent
via TCP which increases the overhead by some 30% and magnifies the delay. 

 

Unicast

Unicasting
is simply sending packets from one source to one destination.  For
example, from one web server to one (or each) person viewing a page on a web
browser.  What may be new to you is the idea that one can send video
via unicast to many viewers.  More on this in a moment.  Data (or
video) can be sent via UDP or TCP, with RTP and RTSP, and can be sent via
Unicast.  So, Unicast is a method, not a protocol.  

Analogy: Mailing a letter (although we assume
IP is faster!)

 

Multicast

Multicasting
is sending data from a sender to multiple receivers where each receiver signals
that they want to receive the data.  This is different from Unicasting, and
different from broadcasting (where everyone gets the data whether they want it
or not).  Notice that you normally have a one-way connection, thereby
ruling out TCP.  Yes, that’s right, Multicast is done via UDP.  There
are methods in use where a receiver can signal a sender that it has received a
bad packet using a different ‘reverse channel’.  This is called
"reliable multicast" and has little value for live video transmission.

Analogy: Distributing brochures with a sign
that says "Take One". Only those who want it take it.

 

SDP

The Session
Description Protocol
, for our purposes, is a file that describes a MPEG-4
stream.  SDP files are uniquely created for each stream, whether the stream
is multicast or unicast.  SDP files are put on servers to allow them to
identify a stream and replicate it to viewers.  Wow, really new
concept!  But not to worry, rediff makes it largely invisible.  But
you should know the standard exists and we support the relevant sections.

 

 

Putting It All Together

Here we go. You can send MPEG-4 video by wrapping
the video steam in a RTP packet, wrapping the audio stream in another RTP
packet, then wrapping each RTP packet in a UDP packet, then controlling the
stream using RTSP.  You can encapsulate the RTP in http if necessary (via
an external server).

You can send MPEG-1 System and MPEG-2 Transport
streams via raw UDP (this is what we normally do in LANs).  You can send
MPEG-1 System Streams and MPEG-2 transport streams via RTP over UDP (we do this
for stored video on demand).

 

 

 

 

- Anand Shah

 


Mod_Rewrite Tips and Tricks OR .htaccess rewrite examples
Nov 13th, 2009 by anand

.Htaccess rewrites, Mod_Rewrite Tricks and Tips

When the url in your browser’s location bar stays the same for a request it is an internal rewrite, when the url changes an external redirection is taking place. This is one of the first, and one of the biggest mental-blocks people have when learning about mod_rewrite… But I have a secret weapon for you to use, a new discovery from years of research that makes learning mod_rewrite drastically quicker and easier. It truly does or I wouldn’t be saying so in the introduction of this article.

Note: After years of fighting to learn my way through rewriting urls with mod_rewrite, I finally had a breakthrough and found a way to outsmart the difficulty of mod_rewrite that I just couldn’t seem to master. The Mod_Rewrite RewriteCond/RewriteRule Variable Value Cheatsheet is the one-of-a-kind tool that changed the game for me and made mod_rewriting no-harder than anything else.

So keep that mod_rewrite reference bookmarked and you will be able to figure out any RewriteRule or RewriteCond, an amazing feat considering it took me a LONG time to figure this stuff out on my own. But that was before the craziness, one of the most challenging and productive .htaccess experiments I’ve done… An experiment so ILL it’s sick like a diamond disease on your wrist! $$$. That mod_rewrite experiment/tutorial was the culmination of many different advanced mod_rewrite experiments I had done in the past and included most of my very best .htaccess tricks. With the cheatsheet it’s no longer Voodoo.. Its just what you do. Now lets dig in!

Htaccess rewrites TOC


If you really want to take a look, check out the mod_rewrite.c and mod_rewrite.h files.

Be aware that mod_rewrite (RewriteRule, RewriteBase, and RewriteCond) code is executed for each and every HTTP request that accesses a file in or below the directory where the code resides, so it’s always good to limit the code to certain circumstances if readily identifiable.

For example, to limit the next 5 RewriteRules to only be applied to .html and .php files, you can use the following code, which tests if the url does not end in .html or .php and if it doesn’t, it will skip the next 5 RewriteRules.


RewriteRule !\.(html|php)$ - [S=5]
RewriteRule ^.*-(vf12|vf13|vf5|vf35|vf1|vf10|vf33|vf8).+$ - [S=1]

.htaccess rewrite examples should begin with:

Options +FollowSymLinks
 
RewriteEngine On
RewriteBase /

Require the www

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
RewriteRule ^(.*)$ http://www.askapache.com/$1 [R=301,L]

Loop Stopping Code

Sometimes your rewrites cause infinite loops, stop it with one of these rewrite code snippets.

RewriteCond %{REQUEST_URI} ^/(stats/|missing\.html|failed_auth\.html|error/).* [NC]
RewriteRule .* - [L]
 
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

Cache-Friendly File Names

This is probably my favorite, and I use it on every site I work on. It allows me to update my javascript and css files in my visitors cache’s simply by naming them differently in the html, on the server they stay the same name. This rewrites all files for /zap/j/anything-anynumber.js to /zap/j/anything.js and /zap/c/anything-anynumber.css to /zap/c/anything.css

RewriteRule ^zap/(j|c)/([a-z]+)-([0-9]+)\.(js|css)$ /zap/$1/$2.$4 [L]

SEO friendly link for non-flash browsers

When you use flash on your site and you properly supply a link to download flash that shows up for non-flash aware browsers, it is nice to use a shortcut to keep your code clean and your external links to a minimum. This code allows me to link to site.com/getflash/ for non-flash aware browsers.

RewriteRule ^getflash/?$ http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash [NC,L,R=307]

Removing the Query_String

On many sites, the page will be displayed for both page.html and page.html?anything=anything, which hurts your SEO with duplicate content. An easy way to fix this issue is to redirect external requests containing a query string to the same uri without the query_string.

RewriteCond %{THE_REQUEST} ^GET\ /.*\;.*\ HTTP/
RewriteCond %{QUERY_STRING} !^$
RewriteRule .* http://www.askapache.com%{REQUEST_URI}? [R=301,L]

Sending requests to a php script

This .htaccess rewrite example invisibly rewrites requests for all Adobe pdf files to be handled by /cgi-bin/pdf-script.php

RewriteRule ^(.+)\.pdf$  /cgi-bin/pdf-script.php?file=$1.pdf [L,NC,QSA]

Setting the language variable based on Client

For sites using multiviews or with multiple language capabilities, it is nice to be able to send the correct language automatically based on the clients preferred language.

RewriteCond %{HTTP:Accept-Language} ^.*(de|es|fr|it|ja|ru|en).*$ [NC]
RewriteRule ^(.*)$ - [env=prefer-language:%1]

Deny Access To Everyone Except PHP fopen

This allows access to all files by php fopen, but denies anyone else.

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^.+$ [NC]
RewriteRule .* - [F,L]

If you are looking for ways to block or deny specific requests/visitors, then you should definately read Blacklist with mod_rewrite. I give it a 10/10

Deny access to anything in a subfolder except php fopen

This can be very handy if you want to serve media files or special downloads but only through a php proxy script.

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/.*\ HTTP [NC]
RewriteRule .* - [F,L]

Require no www

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^askapache\.com$ [NC]
RewriteRule ^(.*)$ http://askapache.com/$1 [R=301,L]

Check for a key in QUERY_STRING

Uses a RewriteCond Directive to check QUERY_STRING for passkey, if it doesn’t find it it redirects all requests for anything in the /logged-in/ directory to the /login.php script.

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !passkey
RewriteRule ^/logged-in/(.*)$ /login.php [L]

Removes the QUERY_STRING from the URL

If the QUERY_STRING has any value at all besides blank than the?at the end of /login.php? tells mod_rewrite to remove the QUERY_STRING from login.php and redirect.

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} .
RewriteRule ^login.php /login.php? [L]

Fix for infinite loops

An error message related to this isRequest exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.or you may seeRequest exceeded the limit,probable configuration error,Use 'LogLevel debug' to get a backtrace, orUse 'LimitInternalRecursion' to increase the limit if necessary

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

External Redirect .php files to .html files (SEO friendly)

RewriteRule ^(.*)\.php$ /$1.html [R=301,L]

Internal Redirect .php files to .html files (SEO friendly)

Redirects all files that end in .html to be served from filename.php so it looks like all your pages are .html but really they are .php

RewriteRule ^(.*)\.html$ $1.php [R=301,L]

block access to files during certain hours of the day

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# If the hour is 16 (4 PM) Then deny all access
RewriteCond %{TIME_HOUR} ^16$
RewriteRule ^.*$ - [F,L]

Rewrite underscores to hyphens for SEO URL

Converts all underscores “_” in urls to hyphens “-” for SEO benefits… See the full article for more info.

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
 
RewriteRule !\.(html|php)$ - [S=4]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]
RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]
 
RewriteCond %{ENV:uscor} ^Yes$
RewriteRule (.*) http://d.com/$1 [R=301,L]

Require the www without hardcoding

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]
RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$     [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]

Require no subdomain

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} \.([a-z-]+\.[a-z]{2,6})$ [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]

Require no subdomain

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} \.([^\.]+\.[^\.0-9]+)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Redirecting Wordpress Feeds to Feedburner

Full article:Redirecting Wordpress Feeds to Feedburner

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/feed\.gif$
RewriteRule .* - [L]
 
RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]
RewriteRule ^feed/?.*$ http://feeds.feedburner.com/apache/htaccess [L,R=302]
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Only allow GET and PUT Request Methods

Article: Request Methods

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} !^(GET|PUT)
RewriteRule .* - [F]

Prevent Files image/file hotlinking and bandwidth stealing

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]

Stop browser prefetching

RewriteEngine On
SetEnvIfNoCase X-Forwarded-For .+ proxy=yes
SetEnvIfNoCase X-moz prefetch no_access=yes
 
# block pre-fetch requests with X-moz headers
RewriteCond %{ENV:no_access} yes
RewriteRule .* - [F,L]

This module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly. It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule, to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests, of server variables, environment variables, HTTP headers, or time stamps. Even external database lookups in various formats can be used to achieve highly granular URL matching.

This module operates on the full URLs (including the path-info part) both in per-server context (httpd.conf) and per-directory context (.htaccess) and can generate query-string parts on result. The rewritten result can lead to internal sub-processing, external request redirection or even to an internal proxy throughput.

Further details, discussion, and examples, are provided in the detailed mod_rewrite documentation.

Directives

If you aren’t already comfortable using mod_rewrite then I recommend this excellent mod_rewrite guide by one of my favorite mod_rewrite gurus that I’ve seen.

Top 5 Ways to Make Money on the Internet
Nov 13th, 2009 by anand

Top 5 Ways to Make Money on the Internet

1: Domain Name Flipping
Based on luck, strategy and business savvy, domain name flipping can be one of the more lucrative ways to earn a living online. The term comes from the real estate trick that involves buying old, undervalued houses, fixing them up to make them more attractive and modern-looking and selling them for a much higher price.

In this case, the old and outdated place is not a house, but rather a domain name — the main address for a Web page. With a little bit of searching, dedicated domain flippers locate unused, poorly maintained Web sites that have generic and recognizable identifiers and buy them. They usually pay a few hundred or even a few thousand dollars, but after extensive updates that make the site more business- and user-friendly, the domain name can fetch several times more than it was originally worth. The domain bird-cage.com, for instance, was bought for a mere $1,800 in 2005 — after a redesign two years later, the site was sold for $173,000 to a bird cage vendor.

2: Freelancing
Freelancing is similar in some ways to blogging. For one thing, you get to work from your own home or office most of the time. But there are a few important distinctions. First, if you’re thinking about freelance writing, chances are you need to have more experience than the average blogger. Many freelance writing positions cover specialized topics for online publications and may require expert knowledge on a subject. However, if you’re passionate about things like travel or food and know how to write, a freelancing job can provide you with good income.

Writing’s not the only way to make money freelancing, of course — anyone with graphic design or programming experience can find contract jobs that pay well and provide challenging work, too.

3. Designing and Selling T-shirts

Darrin Klimek/Getty Images
If you come up with your own t-shirt designs, some sites will press the shirts for you and share profits when they’re sold.
As you walk around most high school and college campuses, you’re likely to come into contact with lots of words. But it won’t be material from textbooks or term papers — those are probably in backpacks or sitting unfinished at home. Instead, they’re the simple phrases or logos — most of which are ironic or amusing — printed on the T-shirts on the backs of the students.

Usually, the more unique and offbeat the design is, the more desirable the T-shirt is. The growth of the Internet has made it possible for vendors to sell T-shirts all over the world. In fact, sites like CafePress.com and SpreadShirt.com allow you to set up your own store, create your own designs and sell them yourself. If you create your own shirt design with a clever catchphrase or come up with your own unique statement and people like it, you can start making money.

4: Blogging
If you have a particular passion for something, whether it’s a hobby or an obsession, and you have something to say about it, blogging could be a profitable way to pour out your endless stream of thought. The key here, as with many other services on the Internet, is in selling advertising.

After starting up a personal blog, many writers sign up for ad services like Google AdSense, which post those familiar sponsored links you often see at the top and on the sides of Web sites. The more times your blog readers click on those ads, the more money you’ll make through the ad service. This works fine if you’re a casual blogger, and you may make some extra spending money. But if the blog is consistently interesting, well-written and really takes off, you may be approached by companies who want to reach your fan base with graphical advertising around your blog. Some of the more successful blogs, like I Can Has Cheezburger? and Boing Boing, have become pop-culture phenomena, and their creators have been able to quit their day jobs and blog full time because of the money they make from advertisers.

5: Selling Stuff on eBay

Sean Gallup/Getty Images
Finding stuff you don’t need but others are willing to pay more for is a popular way to make money over the Web.
It’s a fairly straightforward concept that most people are familiar with by now — if you have a bunch of stuff that you don’t necessarily need but others want and are willing to pay extremely inflated prices for, you can auction off the items on eBay or other online auction sites. Simply gather your goods, create a seller’s profile and start selling.

It sounds simple, but takes some practice to sell successfully. Creating persuasive and legitimate product pages for the goods you’re selling will help get buyers interested. It’s also important to set reasonable minimum bids to ensure that people will buy. And remember to deliver the kind of customer service that will garner positive feedback ratings and to communicate with buyers to let them know you’re reliable. The more positive feedback you receive, the more people will be willing to do business with you. And that, of course, means more money.

How to Install FFmpeg on Linux The Easy Way
Nov 11th, 2009 by anand


 

How to Install FFmpeg in Linux The Easy Way

FFmpeg is so important if you are planning to run a video website with streaming with conversion of video files to different video formats. This tutorial is intended for Centos/Redhat versions of Linux where any novice user can install ffmpeg without compiling the source which is a more traditional way of installing the FFmpeg software on linux servers. In this tutorial i will show you the easy way to install ffmpeg
and ffmpeg-php (php extension) with just yum rather than compiling ffmpeg from source files.

 

FFmpeg (http://ffmpeg.mplayerhq.hu)

Mplayer + Mencoder (http://www.mplayerhq.hu/design7/dload.html)

Flv2tool (http://inlet-media.de/flvtool2)

Libogg + Libvorbis (http://www.xiph.org/downloads)

LAME MP3 Encoder (http://lame.sourceforge.net)


FlowPlayer – A Free Flash Video Player – http://flowplayer.org/

Installing FFMpeg

yum install ffmpeg ffmpeg-devel

If you get package not found, then you will need to add few lines in the yum repository for dag packages installation. Create a file named dag.repo in /etc/yum.repos.d with the following contents on it

[dag]

name=Dag RPM Repository for Red Hat Enterprise Linux

baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag

gpgcheck=1

enabled=1

then

yum install ffmpeg ffmpeg-devel

If everything is fine, then the installation should proceed smoothly. If not you will get something like warning GPG public key missing.

Common Errors

To fix rpmforge GPG key warning:

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

For more information refer to this
faq
depending on Centos version

Missing Dependency Error:

If you get missing dependency error like shown below, in the middle of ffmpeg
installation

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed
by package ffmpeg

Error: Missing Dependency: libtheora.so.0(libtheora.so.1.0) is needed by package
ffmpeg

Error: Missing Dependency: rtld(GNU_HASH) is needed by package ffmpeg

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package imlib2

Error: Missing Dependency: rtld(GNU_HASH) is needed by package a52dec

Error: Missing Dependency: rtld(GNU_HASH) is needed by package imlib2

Error: Missing Dependency: rtld(GNU_HASH) is needed by package gsm

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package x264

Error: Missing Dependency: rtld(GNU_HASH) is needed by package xvidcore

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package lame

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package a52dec

Error: Missing Dependency: rtld(GNU_HASH) is needed by package faad2

Error: Missing Dependency: rtld(GNU_HASH) is needed by package x264

Error: Missing Dependency: rtld(GNU_HASH) is needed by package lame

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package xvidcore

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faac

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package faad2

Error: Missing Dependency: libgif.so.4 is needed by package imlib2

Error: Missing Dependency: rtld(GNU_HASH) is needed by package faac

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package gsm

Error: Missing Dependency: libpng12.so.0(PNG12_0) is needed by package imlib2

Error: Missing Dependency: rtld(GNU_HASH) is needed by package libmp4v2

Error: Missing Dependency: libc.so.6(GLIBC_2.4) is needed by package libmp4v2

then most commonly you have GLIB 2.3 installed instead of GLIB 2.4 version.
To check the current GLIB version installed on your server. just use

yum list glib*

and it should list the latest GLIB package version.

The reason i was getting this error was my rpmforge packages was pointed to centos 5 versions instead of centos 4.6.

To fix dependency error:

To fix this error, you might need to check your rpmforge packages compatible to the release of your existing CentOS version.

Check the file /etc/yum.repos.d/rpmforge.repo and it should look like for Centos 4.6(Final). If you have lines like http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
you might need to make changes to the rpmforge.repos
like shown below

Note: Backup the original rpmforge.repo file before you edit its content.

[rpmforge]

name = Red Hat Enterprise $releasever – RPMforge.net – dag

#baseurl = http://apt.sw.be/redhat/el4/en/$basearch/dag

mirrorlist = http://apt.sw.be/redhat/el4/en/mirrors-rpmforge

#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge

enabled = 1

protect = 0

gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag

gpgcheck = 1

To know what linux type and version you are running

cat /etc/redhat-release

Once this is done, do again yum install ffmpeg.

This trick resolved the problem in my linux box running Centos 4.6 and this is the only way i found to install ffmpeg using yum.

To check the FFmpeg working:

Finally, check the ffmpeg whether it is working or not.

> ffmpeg

> ffmpeg -formats

> ffmpeg –help

// This lists path of mpeg, its modules and other path information


ffmpeg -i Input.file Output.file

To check what audi/video formats are supported

ffmpeg -formats > ffmpeg-format.txt

Open the ffmpeg-formats.txt to see the ooutput

D means decode

E means encode

V means video

A means audio

T = Truncated

Install FFMPEG-PHP Extension

FFmpeg-php is a very good extension and wrapper for PHP which can pull useful information about video through API interface. Inorder to install it you will need to download the source file and then compile and install extension in your server. You can download the source tarball : http://ffmpeg-php.sourceforge.net/

wget /path/to/this/file/ffmpeg-php-0.5.2.1.tbz2

tar -xjf ffmpeg-0.5.2.1.tbz2

phpize

./configure

make

make install

Common Errors

1. If you get command not found error for phpize, then you will need to do yum install php-devel

2. If you get error like "ffmpeg headers not found" while configuring the source.

configure: error: ffmpeg headers not found. Make sure ffmpeg is compiled as shared libraries using the –enable-shared option

then it means you have not installed ffmpeg-devel packages.

To Fix: Just install ffmpeg-devel using

yum install ffmpeg-devel

3. If you get an error like shared libraries not found problem and the program halts in the middle, then you must specify the ffmpeg installed path explicitly to the ./configure.

configure: error: ffmpeg shared libraries not found. Make sure ffmpeg is compiled as shared libraries using the –enable-shared option

To Fix:

1. First find out the ffmpeg path with ffmpeg –help command.
The prefix default path should be like /usr/local/cpffmpeg

2. Configure the FFmpeg-php with –with-ffmpeg option

./configure –with-ffmpeg=/usr/local/cpffmpeg

That should resolve the problem!

Editing PHP.INI

Once you have done that without any problems then you will see the php extension file /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so and you will need mention that extension in php.ini file

nano /usr/local/lib/php.ini

Put the below two lines at the end of the php.ini file

[ffmpeg]

extension=ffmpeg.so

Then restart the server service httpd restart

To check whether ffmpeg enabled with php, point your browser to test.php file. It should show the confirmation of installed ffmpeg php extension

// #test.php

<?php

phpinfo()

?>

If any case the ffmpeg does not show in the phpinfo() test make sure that php.ini path to ffmpeg.so is correct. Still the problem occurs, the reason could be you might be using older versions of ffmpeg-php which is buggy. Just download the latest version of ffmpeg-php source then compile it.

Installing Mplayer + Mencoder

Just issue the following yum commands to install the rest of the packages.

yum install mplayer mencoder

Installing FlvTool2

Flvtool2 is a flash video file manipulation tool. It can calculate metadata and can cut and edit cue points for flv files.

If you are on Centos 5 try yum install flvtool2 with dag repository and if you get package not found you will need to manually download and compile the flvtool2. You can download latest version of flvtool2 here:
http://rubyforge.org/projects/flvtool2/

wget <url-link>

ruby setup.rb config

ruby setup.rb setup

sudo ruby setup.rb install

If you get command not found error, it probably means that you dont have ruby installed.

yum install ruby

Thats it! Once ffmpeg works fine with php extension, download a sample video, convert to .flv format in the command line and plug it to flowplayer to see it work on your web browser. Try also to download the video file offline and see whether the converted flv file works well with both audio and video.

Useful Links

FFmpeg (http://ffmpeg.mplayerhq.hu)

Mplayer + Mencoder (http://www.mplayerhq.hu/design7/dload.html)

Flv2tool (http://inlet-media.de/flvtool2)

Libogg + Libvorbis (http://www.xiph.org/downloads)

LAME MP3 Encoder (http://lame.sourceforge.net)


FlowPlayer – A Free Flash Video Player – http://flowplayer.org/

Install FFmpeg from Compiling Source (Tutorial
Link
)

Nice FFmpeg Installation Tutorial (click
here
)

Important Audio Codecs (http://www.mplayerhq.hu/DOCS/HTML/en/audio-codecs.html)

Common Errors & Fixes while Installing FFmpeg (click here)

You can also post comments in my blog.

Back to home


Saving and Handling Your Terminal Output
Nov 11th, 2009 by anand

One of the classic UNIX commands is the script utility. This article shows you how to use this utility.

A Common Way to Use the script Utility
The script utility simply starts a new shell and collects all the terminal input and output to a file:

# script utility starts a new shell
script /tmp/myterminal.log
pwd
ls
# and everything you see is in the /tmp/myterminal.log
….
# exit from the shell and close the log file
exit
It’s great and it’s easier to use than the following, well-known output redirection:

2>&1 | tee /tmp/command.log
What is the difference between script logging and output redirection? With script logging, all input characters, even the Backspace or the cursor moving between characters, are included in the script output. Using script logging has advantages and disadvantages. One disadvantage is that the log file is less readable, because it contains Ctrl-M and other nasty characters. Let’s look at the advantages of using script logging and the benefits that result from them!

Showing Your Terminal Window to Others
Script output can be redirected to another terminal to show what you see or what you are doing. Suppose you have a problem and you call a colleague by phone to ask for help. Your colleague is not sitting next to you. However, if both of you can log in to the same server, you can redirect your terminal output to your colleague’s terminal.

Since both of you need to log in to the same server, ask your colleague to get his or her terminal device, which can be found by using the following command:

tty
Or you can find it out yourself with the following command:

who | grep
Type the following into your terminal:

script /dev/null | tee -a
Here is an example:

script /dev/null | tee -a /dev/tty3
It’s wonderful! Everything you type, and everything you do, is shown on your colleague’s terminal. If you edit a file using vi, if you move your cursor, if you log in to another server, it’s all shown on your colleague’s terminal. One small tip: tell your colleague your terminal size and ask your colleague to resize his or her terminal to the same size. Otherwise, your colleague will lose readability in some circumstances, such as when you are working in vi.

Maybe you are wondering why you can’t simply use this command:

script /dev/tty
The previous command is OK, but if you use it, the output is cached. Therefore, your typing cannot be followed directly character by character. Instead, your typing is followed only line by line. Editing in vi is not followed either.

It is possible to save the output in a file:

script /dev/null | tee /tmp/myterminal.log
And your colleague can join you to view this later:

tail -f /tmp/myterminal.log

Logging Your Login Sessions Automatically
You can use the script utility to log an entire login session to a separate file, and you can check the file later to see what you did in the past. Create the ~/tmp/log_session directory and put following lines into your .profile file:

if [ -z $FIRST_LOGIN ]; then
FIRST_LOGIN=”no”
export FIRST_LOGIN
exec script ~/tmp/log_session/session.`date +%Y.%m.%d.%H_%M_%S_%Z`.$$
# never come here
exit;
fi

I prefer the Bash shell, but there is a small problem with it. The script utility starts whatever shell is specified by the SHELL variable. However, script starts the shell using the name sh. If you start the Bash shell with a program name of sh, Bash mimics the classic Bourne shell, as described in the bash man page. The solution is to implement the following helper script: start_bash.sh:

$cat ~/bin/start_bash.sh
#!/usr/bin/sh
exec bash
The invocation in .profile is changed to the following:

if [ -z $FIRST_LOGIN ]; then
FIRST_LOGIN=”no”
export FIRST_LOGIN
export SHELL=~/bin/start_bash.sh
exec script ~/tmp/log_session/session.`date +%Y.%m.%d.%H:%M:%S:%Z`.$$
# never come here
exit;
fi

Checking the Content of the script Utility’s Output File

If you are interested in knowing exactly what is in the file that the script utility creates, you can simply open the file using the vi editor. Nonprinting characters are displayed. To get just the output as it was executed, you can use the cat utility.

Here is a small script to play back the script utility’s output file. It copies the file character by character or line by line to your terminal window. It’s best to use the same terminal size as before.

Run the script:

play_script_command_output.pl