function makeRandomPassword() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$numberitems = $_POST['num_cart_items'];
foreach ($_POST as $key => $value)
{
$string.= "$key $value
";
}
mail("ksecor@adelphia.net","Paypal vars",$string);
$payer_email = $_POST['payer_email'];
$txn_type = $_POST['txn_type'];
$subscr_id = $_POST['subscr_id'];
$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];
$payer_email = trim(html_entity_decode($payer_email));
for ($i=1;$i<=$numberitems;$i++)
{
$item_name = "$item_name"."$i";
$item = $_POST['item_name$i'];
//if ($_POST['payment_status'] == "Completed")
$email = $_POST['payer_email'];
$user = explode("@",$email);
$membid = $user[0];
$password = makeRandomPassword();
$hash = crypt($password);
$string = "$membid:$hash\r\n";
$song = $_POST['item_name'];
$song= str_replace(" ","%20",$song);
mysql_connect("localhost","mmaaaco_ksecor","hamilton");
mysql_select_db("mmaaaco_ksecor");
$sql = mysql_query("select * from songs
where name = '$song'");
$row = mysql_fetch_array($sql);
$song = $row[name];
$id = $row[songid];
$dlink = "http://$membid:$password@mm214.com/protectmp3s/$id/$song";
$file = fopen("../../../protectmp3s/$id/.htpasswd", "a");
fwrite($file, $string);
fclose ($file);
$content .= "Right Click on the Link below to download your song
$song
";
}
$message = "Your Song is ready to download";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: MyMusic.com';
mail($email,$message,$content,$headers);
mail("ksecor@adelphia.net",$message,$content,$headers);
mail("ks422@fac.aii.edu",$message,$content,$headers);
mail("kguheen@gmail.com",$message,$content,$headers);
?>