YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Bah! much help needed Options
Tim_Myth
#1 Posted : Sunday, April 10, 2005 9:10:11 PM
Rank: Starting Member

Groups: Registered

Joined: 4/10/2005
Posts: 5
Location: ,
This should make it pretty obvious that I don't know what I'm doing. Any help would be appreciated. #!/usr/bin/perl use LWP::Simple; use Net::FTP; use LWP::UserAgent; use Socket; use strict; #### INITIALIZE VARIABLES #### my $host="customdj.us"; my $directory="pub"; my $path = "/var/www/html/dir"; my $paypal_email = 'tim_myth@hotmail.com'; # THIS SHOULD BE THE EMAIL ADDRESS YOU SIGNED UP WITH PAYPAL $ua = new LWP::UserAgent; $SEND_MAIL = "/usr/lib/sendmail -t"; #### Start Printing HTML Page #### print "Content-type: text/html\n\n"; print <<ENDHTML; <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Web Directory</title> </head> <body bgcolor="#d0d0d0" link="#000040" vlink="#000040" alink="#000040"> <h1>Custom DJ Link Directory</h1> ENDHTML ; #### Get Query String #### $buffer = $ENV{'QUERY_STRING'}; #### Evaluate Buffer (Query String) #### # Buffer options # add # postit # addnew if ($buffer eq 'add') { &addlink(); } if ($buffer eq 'postit') { &postnewsite(); } if ($buffer eq 'addnew') { &addnew(); } else { print <<ENDHTML; <h1>Hmmm...something has gone wrong.</h1> <p>If you have already made your payment, send an email to <a mailto:"tim_myth@hotmail.com">tim_myth@hotmail.com</a> with the following details:</p> <ul> <li>Your Name</li> <li>Your PayPal email address</li> <li>The URL you were trying to add</li> <li>The Site's Name</li> <li>and The Site's Description</li> </ul> ENDHTML ; &printfoot(); exit; } sub addlink{ print <<ENDHTML; <form action="directory.cgi?postit" method="post"> <table width="595"> <tr><td width="165">Title of your site:</td><td width="425"><input type="text" name="title" size="50"></td></tr> <tr><td width="165">Url of your site:</td><td width="425"><input type="text" name="url" value="http://" size="50"></td></tr> <tr><td width="165">Description of your site:</td><td width="425"><input type="text" name="desc" size="60"></td></tr> <tr><td width="165">Your e-mail:</td><td width="425"><input type="text" name="email" size="50"></td></tr> <tr><td width="165">Category:</td><td> <select name="cat"> <option selected>Please Choose a Category</option> <option value="djs.html">Disc Jockeys</option> <option value="kjs.html">Karaoke Jockeys</option> <option value="equipment.html">Audio Equipment</option> <option value="software.html">Software</option> <option value="venues.html">Venues</option> </select></td></tr></table> <input type="submit" value="Submit"><input type="reset" value="Reset"></form> ENDHTML ; &printfoot(); exit; } sub postnewsite{ if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } if ($FORM{title} eq ''){ print "Your link title is blank<br>"; &printfoot(); exit; } if ($FORM{url} eq ''){ print "Your URL is blank<br>"; &printfoot(); exit; } if ($FORM{desc} eq ''){ print "Your description was left blank<br>"; &printfoot(); exit; } if ($FORM{email} eq ''){ print "Your e-mail was left blank.<br>"; &printfoot(); exit; } $string='https://www.paypal.com/xclick/business=tim_myth%40hotmail%2ecom&item_name=Link%20Directory%20Submission&amount=10%2e00&shipping=0%2e00&no_shipping=1&return=http%3a%2f%2fwww%2ecustomdj%2eus%2fpaidlink%2ecgi%3faddnew&cancel_return=http%3a%2f%2fwww%2ecustomdj%2eus&no_note=1¤cy_code=USD&on0=on0&os0=%3cp%3e%3cb%3e%3ca%20href%3d$form{url}%3e$form{title}%3c/a%3e%3c/b%3e%20%2d%20&custom=$form{desc}&on1=on1&os1=$form{cat}'; $string =~s/(\W)/sprintf("%%%02X",unpack("C",$1))/eg; $req = new HTTP::Request 'POST',$string; $req->content_type('application/x-www-form-urlencoded'); $req->content($query); $res = $ua->request($req); &printfoot(); exit; } sub addnew{ # READ DATA POSTED FROM PAYPAL read (STDIN, $query, $ENV{'CONTENT_LENGTH'}); $query .= '&cmd=_notify-validate'; # SEND DATA BACK TO PAYPAL TO VALIDATE THE PAYMENT $req = new HTTP::Request 'POST','http://www.paypal.com/cgi-bin/webscr'; $req->content_type('application/x-www-form-urlencoded'); $req->content($query); $res = $ua->request($req); %form = &parse; $receiver_email = $form{'receiver_email'}; $item_name = $form{'item_name'}; $item_number = $form{'item_number'}; $item_quantity = $form{'quantity'}; $pending_reason = $form{'pending_reason'}; $payment_status = $form{'payment_status'}; $payment_amount = $form{'mc_gross'}; $payment_currency = $form{'mc_currency'}; $payment_date = $form{'payment_date'}; $first_name = $form{'first_name'}; $last_name = $form{'last_name'}; $address_street = $form{'address_street'}; $address_city = $form{'address_city'}; $address_state = $form{'address_state'}; $address_zip = $form{'address_zip'}; $address_country = $form{'address_country'}; $txn_id = $form{'txn_id'}; $payer_email = $form{'payer_email'}; if ($res->is_error) { &error("An HTTP error occured"); } elsif ($res->content eq 'VERIFIED') { if ($receiver_email ne $paypal_email){&error("Your payment has been made but it was paid into the wrong paypal account")}; if ($payment_status eq 'Completed'){ # PUT CODE HERE TO CHECK $txn_id HAS NOT BEED PROCESSED BEFORE (SEE BELOW) # YOU NEED TO KEEP A FILE THAT STORES ALL TRANSACTIONS ($txn_id) AND COMPARE THEM WITH # THE CURRENT $txn_id TO CHECK IT DOESN'T ALREADY EXIST. IM NOT SURE WHAT YOU DO IF # IT DOES EXIST??? # PAYMENT WAS SUCCESSFUL print "Content-type: text/html\n\n"; print "<h2>YOUR PAYMENT WAS ACCEPTED - Thank you</h2>\n"; open(IN,"$FORM{cat}") || die $!; @text = <IN>; close(IN); open(OUT,">$FORM{cat}") || die $!; foreach $line (@text){ if ($line =~ /<!--Begin Links-->/){ print OUT "<p><b><a href=$FORM{url}>$FORM{title}</a></b> - $FORM{desc}</p>\n"; print OUT "<!--Begin Links-->\n" } else { print OUT "$line"; } } close(OUT); $msgtext = ""; $msgtext .= "From Host: $ENV{'REMOTE_ADDR'}\n"; $msgtext .= "URL: $FORM{url}\n"; $msgtext .= "TITLE: $FORM{title}\n"; $msgtext .= "DESCRIPTION: $FORM{desc}\n"; $msgtext .= "CATEGORY: $FORM{cat}\n"; chomp($FORM{email}); open (SENDMAIL,"|$SEND_MAIL"); print SENDMAIL "To: tim_myth\@hotmail.com\n"; print SENDMAIL "From: $FORM{email}\n"; print SENDMAIL "Reply-to: $FORM{email}\n"; print SENDMAIL "X-Mailer: Perl Powered Socket Mailer\n"; print SENDMAIL "Subject: Directory Submission\n\n"; print SENDMAIL "$msgtext"; print SENDMAIL "\n.\n"; close(SENDMAIL); print "<p>Thank you! You're link has been added.</p>"; print "<p>Here's what you submitted: $msgtext</p>"; &printfoot(); exit; }elsif ($payment_status eq 'Pending'){ # TO MAKE THINGS SAFE WE SHOULD CHECK IF THE PAYMENT IS PENDING # IF THE PAYMENT IS CLEARED AFTER A FEW DAYS AND BECOMES COMPLETE THEN THE # SCRIPT WILL BE CALLED AGAIN WITH A 'COMPLETE' STATUS AND THE FUNDS WILL BE ADDED TO YOUR ACCOUNT # SO IT WOULD BE BEST TO LET THE CUSTOMER KNOW ABOUT THE PAYMENT PENDING &error("YOUR PAYMENT IS PENDING - As soon as it is completed you will recieve confirmation via email"); }else{ # THIS WILL ONLY HAPPEN IF THE PAYMENT IS VERIFIED BUT THE STATUS OF THE PAYMENT # IS ANYTHING ELSE BUT 'COMPLETE' OR 'PENDING' &error("Your payment was not accepted"); } } elsif ($res->content eq 'INVALID') { # PAYPAL DECLINED THE PAYMENT &error("Your payment was not accepted"); } else { # YOU GUESSED IT - UNKNOWN ERROR &error("An unknown error occurred"); } sub error { $error=$_[0]; print "<h2>$error</h2>\n"; print "<p>Please send the details of this transaction to <a mailto=tim_myth@hotmail.com>tim_myth@hotmail.com</a>\n"; exit; } ############################################################### ###################### PARSE FORM DATA ######################## ############################################################### sub parse { my $temp; my @data; foreach $temp (split(/&|=/,$query)) { $temp =~ tr/+/ /; $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge; $temp =~ s/[\r\n]/ /g; push @data, $temp; } return @data; } #### Print the rest of the HTML page #### sub printfoot{ print <<ENDHTML; </body> </html> ENDHTML ; exit; } Yesterday's Traditions, Tomorrow's Technology
Sponsor  
 
wowwieholmes
#2 Posted : Wednesday, November 05, 2008 9:33:37 PM
Rank: Starting Member

Groups: Registered

Joined: 11/3/2008
Posts: 2
Location: ,
free ps3
free playstation 3
<a href="http://www.free-ps3-rewards.com">free ps3</a>
<a href="http://www.free-ps3-rewards.com">free playstation 3</a>
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.3 | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.555 seconds.