For the first part I would imagine they use something that passes the affiliate info through or you could just set them up the same way as hosted galleries using ccbills &html= crap.
I rather see a pass through of the number though to keep the page clean as well as to track stats correctly.
Code:
The affiliate links to the free site like this:
Gallery: http://www.yoursite.com/freesite/index.php?id=123456
link to:
http://refer.ccbill.com/cgi-bin/clicks.cgi?CA=1111111-0000&PA=<?=$_GET["id"]?>
and <?=$_GET["id"]?> will be replaced with 123456...
All <?= ?> does is print a php variable, in this case you are printing the GET
variable specified in the url (?variable=value), so if you wanted to use
?aff=123456 you'd use <?=$_GET["aff"]?>
So when you edit the file it should look like:
Visit <a
href="http://refer.ccbill.com/cgi-bin/clicks.cgi?CA=1111111-0000&PA=<?=$_GET["id"]?>">www.yoursite.com</a>