#!/usr/bin/perl ######################################################################## # SellWide Affiliate Manager for ClickBank - Version: 2.0 # # Copyright 2002 SellWide Corporation # # Last modified 06/11/2002 # # Authors: Andrew Kolobikhin and Vadim Rachkowan # # Available at http://www.sellwide.net # ######################################################################## # COPYRIGHT NOTICE # # Copyright 2002 SellWide Corporation. All Rights Reserved. # # # # This script may be used as long as you don't change this header or # # any of the parts that give Vadim Rachkowan, SellWide Corporation, # # or it's Employees credit for writing this script. # # # # By using this script you agree to indemnify me from any liability # # that might arise from its use. # # # # Redistributing and or selling the code for this program without # # prior written consent is expressly forbidden. # # # # Use of the Affiliate Manager for ClickBank for any unauthorized # # purpose is expressly prohibited by law, and may result in severe # # civil and criminal penalties. Violators will be prosecuted to the # # maximum extent possible. # # # # YOU MAY NOT RESELL OR RELEASE THIS PROGRAM TO OTHERS # # IT IS FOR YOUR PERSONAL USE ONLY. # # # ######################################################################## ################################################################# # CHANGE THESE VARIABLES: # ################################################################# # Type the URL address of the swres.cgi $scriptpath="http://www.easyseo.com/affiliates/swres.cgi"; # Type the full path to your Mail program. # If you're not sure of this, ask your server administrator $mailprog="/usr/sbin/sendmail"; # Type your email address. Make sure # to place a \ in front of the @ # As an example: admin\@sellwide.net $fromaddr="admin\@easyseo.com"; # Type your name. It will appear as a "From" # name in all of your emails. $frname="EasySEO Customer Service"; # Type your ClickBank nickname $mynick="easyseo"; # Enter the Admin password (case sensetive 8 chars max) $pass="lion2304"; ################################################################# ##-------------------------------------------------------------## ##-- !!! DO NOT EDIT ANYTHING BELOW !!! --## ##-------------------------------------------------------------## # Removing or altering the code below will void your # # acceptance of the terms and conditions and consequently # # you will no longer be able to use the program. # #---------------------------------------------------------------# ################################################################# $htmlpath="$ENV{'DOCUMENT_ROOT'}"; $usersfile="users.rdb"; $mailprog=$mailprog." -t"; $scriptpath=~/http:\/\/([^\/]+)/; $dirname="html"; $host1="http://$1/$dirname"; @months=("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); &readparse; if("$FORM{'frame'}" eq 'top'){ if ($FORM{'password'} eq "$pass"){ &top } else { error("Password wrong!") } } if($FORM{'mode'} eq 'register'){ if (($FORM{'name'} ne "") && ($FORM{'nick'} ne "") && ($FORM{'email'} ne "")){ my($username)=$FORM{'name'}; my($secname); $username=~/^\s*(\w{1,20})\s*(\w{0,20}).*$/; $secname=$2;$secname=~tr/A-Z/a-z/;$secname="\u$secname"; $username=$1;$username=~tr/A-Z/a-z/;$username="\u$username"; $FORM{'email'} =~ tr/A-Z/a-z/; $FORM{'nick'} =~ tr/A-Z/a-z/; if ($secname ne ""){$secname=" ".$secname}; $FORM{'name'}="$username$secname"; if (checkuser($FORM{'nick'})){ &adduser; &afterreg; sendreport("$fromaddr","Affiliate registration","\nYou have a new affiliate:\n\nName: $FORM{'name'}\nEmail: $FORM{'email'}\nNick: $FORM{'nick'}\nIP addr: $ENV{'REMOTE_ADDR'}\n"); &makepage; } else { @message=getfile("letter.txt"); $subject=shift(@message); $letter=join("\n",@message); &afterreg; &sendmail; sendreport("$fromaddr","Affiliate registration repeated","\nYou have a new affiliate:\n\nName: $FORM{'name'}\nEmail: $FORM{'email'}\nNick: $FORM{'nick'}\nIP addr: $ENV{'REMOTE_ADDR'}\n"); } } else { error("You have to fill all fields!"); } } elsif($FORM{'mode'} eq 'delete'){ &deluser; &editprosp } elsif($FORM{'mode'} eq 'foradmin'){ &foradmin } elsif($FORM{'mode'} eq 'editprosp'){ &editprosp } elsif($FORM{'mode'} eq 'conf'){ letterbody("letter.txt"); } elsif($FORM{'mode'} eq 'mass'){ letterbody("letter1.txt"); } elsif($FORM{'mode'} eq 'savelet'){ &savelet; $red="http://www.sellwide.net/remote/swresnews.shtml"; letterbody($file); } elsif($FORM{'mode'} eq 'preview'){ &savelet; &preview; } elsif($FORM{'mode'} eq 'mailing'){ &mailer; print "Content-type:text/html\n\n"; print <<_html2;




Congratulations!

The mailing has been started.

You will receive a confirmation e-mail
when the mailing has been completed.

_html2 } elsif(keys(%FORM)){ @asss=keys(%FORM); &addclick } else { &showform }; sub savelet{ $subject=$FORM{'subject'}; $body=$FORM{'body'}; $body=~s/\r\s/\n/g; $file=$FORM{'file'}; open(FILE,">$file"); flock(FILE,2); print FILE "$subject\n$body\n"; close(FILE); } sub top{ print "Content-type:text/html\n\n"; print<<_html_; menu bar
Edit the list of affiliates Edit confirmation email Send broadcast email
_html_ } sub foradmin{ print "Content-type: text/html\n\n"; print<<_html_; Affiliate Manager for ClickBank by SellWide.Net <body> <p>This page uses frames, but your browser doesn't support them.</p> </body> _html_ } sub afterreg{ $nick=$FORM{'nick'}; if (open(FILE3,"tools.html")){ print "Content-type: text/html\n\n"; flock(FILE3,2); while($str=){ chomp($str); $str=~s/\[NAME\]/$FORM{'name'}/ge; $str=~s/\[NICKNAME\]/$nick/ge; $str=~s/\[LINK\]/"$host1\/$nick.html"/ge; $str=~s/\[EMAIL\]/$FORM{'email'}/ge; print "$str"; } close(FILE3); } else { print "Location: http://www.sellwide.net\n\n" }; } sub addclick{ my($param)=(keys(%FORM))[0]; @users=(getfile($usersfile)); for($i=0;$i<=$#users;$i++){ @users[$i]=~/(.*)\|(.*)\|(.*)\|(.*)\|(.*)/; $clicks=$5; if ($3 eq $param) { $clicks++; @users[$i]="$1|$2|$3|$4|$clicks" }; }; savefile($usersfile); error("@asss"); }; sub deluser{ @users=(getfile($usersfile)); for($i=0;$i<=$#users;$i++){ @users[$i]=~/(.*)\|(.*)\|(.*)\|(.*)\|(.*)/; $nick=$3; foreach(keys(%FORM)){ if (/sub/){ if (($nick eq $FORM{$_})&&($nick ne "")){ @users[$i]=""; unlink("$htmlpath/$dirname/$nick.html"); } }; }; }; savefile($usersfile) }; sub savefile{ if (open(UFILE,">@_[0]")){ flock(UFILE,2); foreach(@users){ if($_ ne ""){ print UFILE "$_\n" } } close(UFILE); } } sub readparse { if ($ENV{'REQUEST_METHOD'} eq 'GET') { $input=$ENV{'QUERY_STRING'} } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read (STDIN, $input, $ENV{'CONTENT_LENGTH'}); } @pairs = split(/&/, $input); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\n/ /g; $FORM{$name} = $value; }; if (($FORM{'nick'} eq "admin")&&($FORM{'name'} eq "$pass")){ &foradmin; exit; }; if (($FORM{'mode'}=~/register/)||("$FORM{'mode'}" eq "")){ } else { if ($FORM{'password'} ne $pass){ &showform; } } } sub getfile{ my(@list); if (open(FILE,"@_[0]")){ flock(FILE,$LOCK_EX); while(defined($str=)){ chomp($str); push(@list,$str) }; flock(FILE,$LOCK_UN); close(FILE); } else { if (-e "@_[0]") { error("Cannot open @_[0]!") } }; return @list; } sub checkmail{ if (@_[0] =~/^[a-zA-Z0-9_\.-][a-zA-Z0-9_\.-\d]*\@[a-zA-Z\.-\d]+\.[a-zA-Z]{2,4}/) { return 1 } else { return 0 } } sub checkuser{ unless(($FORM{'nick'}=~/(^[A-Za-z0-9]{5,10})/)&&($FORM{'nick'}!=~/\s+/)){ error('Bad nickname (5 - 10 letters and digits)!') }; unless(checkmail($FORM{'email'})){ error('Bad E-mail address!') }; if ($FORM{'name'} eq ""){ error("The name field was not entered!") }; my(@users)=(getfile($usersfile)); #error("@users"); my($result)=1; foreach(@users){ $_=~/(.*)\|(.*)\|(.*)\|(.*)\|(.*)/; if ($3 eq $FORM{'nick'}) {$result=0}; }; return $result; } sub ltime{ my($sec,$min,$hour,$mday,$mon,$year) = localtime(); $year+=1900;$mon++; if ($mday<10) {$mday="0$mday"}; if ($mon<10) {$mon="0$mon"}; return ($mday,$mon,$year); } sub adduser{ my($day,$month,$year)=(ltime()); if(open(FILE,">>$usersfile")){ flock(FILE,2); print FILE "$FORM{'name'}|$FORM{'email'}|$FORM{'nick'}|$year$month$day|0\n"; close(FILE); @message=getfile("letter.txt"); $subject=shift(@message); $letter=join("\n",@message); &sendmail; } else { error("Cannot write $userfile!") } } sub showform{ print "Content-type:text/html\n\n"; print<<_html_;
ClickBank NickName:
Your Name:
Email Address:
Fill in the form to generate your own personalized affiliate links and banners.
You will also be sent a welcome e-mail.

EasySEO Home

_html_ exit; } sub sendreport{ my($email1); ($email1,$subject,$letter)=(@_); $FORM{'email'}="$email1"; $FORM{'name'}="admin"; &sendmail } sub sendmail{ my($name,$email,$nick)=($FORM{'name'},$FORM{'email'},$FORM{'nick'}); $letter=~s/\[NAME\]/"$FORM{'name'}"/ge; $letter=~s/\[EMAIL\]/"$FORM{'email'}"/ge; $letter=~s/\[NICKNAME\]/"$nick"/ge; $letter=~s/\[LINK\]/"$host1\/$nick.html"/ge; $subject=~s/\[NAME\]/"$FORM{'name'}"/ge; $subject=~s/\[NICKNAME\]/"$nick"/ge; $subject=~s/\[EMAIL\]/"$FORM{'email'}"/ge; $email=~s/@/\@/; open(SM,"|$mailprog"); print SM "From: $frname <$fromaddr>\n"; print SM "To: $name <$email>\n"; print SM "Subject:$subject\n"; print SM "Content-Type: text/plain\n"; print SM "\n"; print SM "$letter\n"; print SM "\n__________________________________________________________________"; print SM "\nEasySEO :: Search Engine Reverse Engineering and Submission\n"; close(SM); } sub error { my($errmsg) = @_; print "Content-type: text/html\n\n"; print <


Attention!

$errmsg

Back
HTML exit; } sub makepage{ chdir($htmlpath); unless(-e "$dirname") { mkdir($dirname,0777); } chdir($dirname); if (open(FILE,">$FORM{'nick'}.html")){ print FILE<<_html_; EasySEO :: Search Engine Reverse Engineering and Submission
Click here if you are not automatically redirected







O n e    m o m e n t   p l e a s e . . .
_html_ close(FILE); } } sub editprosp{ my($subscribers)=0; # &sorthem; my($sperpage)=30; if ("$FORM{'ppage'}" eq ""){ $FORM{'ppage'}='001'; } open(FILES,"$usersfile") || error "Cannot open $userdir!"; flock(FILES,$LOCK_EX); print <

Edit the list of affiliates
HTML while (!eof(FILES)) { $subscribers++; $record=; if(($subscribers>($FORM{'ppage'}-1)*$sperpage) && ($subscribers<=($FORM{'ppage'})*$sperpage)){ $record=~/(.*)\|(.*)\|(.*)\|(.*)\|(.*)/; $name=$1; $email=$2; $nick=$3; $date=$4; $clicks=$5; $date=~/(\d{4})(\d{2})(\d{2})/; $date="$3 "."@months[$2-1]"." $1"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } } flock(FILES,$LOCK_UN); close(FILES); print "
Delete Name E-mail Address NickName Registration Date Clicks
$name$email $nick $date $clicks
\n"; for($page=1;$page<=$subscribers;$page=$page+$sperpage){ $j++; $j1="$j"; for($prom=1;$prom<(4-length("$j"));$prom++){ $j1="0"."$j1"; }; print " $j1"; if (($j%20)==0){print "
"} } print "

There are $subscribers affiliates.

Admin Password:
\n"; print "\n"; print "\n"; print "


\n"; } sub letterbody{ if (@_[0] ne "letter.txt") { $msgt="Broadcast"; } else { $msgt="Confirmation"; } @message=getfile(@_[0]); $subject=shift(@message); $body=join("\n",@message); if("$red" ne ""){ print "Location: $red\n\n"; }; print "Content-type:text/html\n\n"; print <<_html;

Edit $msgt Message
Subject:
Body:
_html print ""; print ""; print ""; print " "; if (@_[0] ne "letter.txt") { print ""; } else { print ""; } print <<_html;

There are four pre-set merge words you may use in Body or Subject to personalize your message.

  • [NAME] will extract your affiliate's name (i.e. 'Hi [NAME]' will print 'Hi Mike!', if your affiliate's name is Mike).
  • [NICKNAME] will print your affiliate's ClickBank nickname (i.e. '[NICKNAME],' will print 'sellwide', if your affiliate's nickname is sellwide).
  • [EMAIL] will extract your affiliate's e-mail address (i.e. 'Your e-mail address is [EMAIL]' will output 'Your e-mail address is mikejsn\@aol.com', if your affiliate's e-mail address is mikejsn\@aol.com.
  • [LINK] will print your affiliate's link.
_html print "

"; } sub preview{ @message=getfile($FORM{'file'}); $subject=shift(@message); $body=join("\n",@message); %replace=(' '," ",'<',"<",'>',">"); $body=~s/( |\<|\>)/$replace{$1}/ge; $body=~s/[\n\r]/
/g; print "Content-type: text/html\n\n"; print ""; print "

"; print "
"; print ""; print ""; print ""; print "
"; print ""; print "From: $frname <$fromaddr>
"; print "To: Affiliates
"; print "Subject: $subject
0-------10--------20--------30--------40--------50--------60--------70
"; print "$body
0-------10--------20--------30--------40--------50--------60--------70
"; print "
"; if ($FORM{'file'} ne "letter.txt"){ print "


Are you sure you want to send a broadcast message?
"; print "

"; }; print "


"; } sub mailer{ my($total)=0; unless(-e "mailer.lock"){ open(FILE,">mailer.lock");close(FILE); @message=getfile($FORM{'file'}); $subject1=$subject=shift(@message); $body=join("\n",@message); $letter=$body; my(@users)=(getfile($usersfile)); foreach $myone(@users){ $myone=~/(.*)\|(.*)\|(.*)\|(.*)\|(.*)/; $FORM{'name'}="$1"; $FORM{'email'}="$2"; $FORM{'nick'}="$3"; &sendmail; $total++; $report.="$FORM{'name'} $FORM{'email'} $FORM{'nick'}\n"; $subject=$subject1; $letter=$body; }; unlink("mailer.lock"); my($day,$month,$year)=(ltime()); $report="Broadcast email has been sent to $total affiliates at $day @months[$month-1] $year :\n$report"; sendreport($fromaddr,"AFFILIATE MAILING REPORT for $day @months[$month-1] $year","$report"); } else { error("Mailing in progress!!!") } }