I'm actually writing one right now using php and mysql!!! I will release it for free to anyone who wants it when it is done, so let me know what features you want.
The following is done: The script will set a cookie in the visitor's browser for 30 days and forward the user to your home page. Then you can include a php file at the end of your order script which will check the browser to see if there is a cookie, and record the referral for the appropriate affiliate.
Currently working on: Affiliate interface will allow affiliate to log in and view the date and time of each referral that they generated, along with the total number of visitors sent (number of times they're link was clicked). They will be able to view their outstanding balance (what is currently owed to them). They will be able to view payments that have been sent, and the date they were sent.
The affiliate owner (ie... you! ) will be able to view summary statistics for all affiliates. You will (hopefully) be able to view each domain that was referred by each client. You will be able to enter checks that have been sent to affiliates.
I am hoping to make this THE affiliate script that everyone uses, so would appreciate any input that you may have into the project!
ETA: approx. 2 weeks
Note: This script will NOT be commercial, and I am hoping to ultimately release it as open source software.