PHP - Imap_fetchstructure Issues With Attachment In Exchange 2010 Imap Server
imap_fetchstructure is not returing information about attachments for certain e-mails after the mailbox is migrated to exchange 2010. Using IMAP protocol and was working fine until the migration from exchange 2007 to 2010. 99% of emails with attachments works fine, but few don't. I can replicate the issue when an attachment is sent from gmail accounts or some xerox devices to exchange 2010. The output of imap_fetchstructure (message has no body, only attachment) looks like below, as you can see, parts is returning null. I have tested it using imap-2006e and imap-4.7b libraries and produces same issues. Any ideas how to resolve the issue or debug this issue? Can also replicate the problem in Thunderbird 2.0.0.24
stdClass Object ( [type] => 1 [encoding] => 5 [ifsubtype] => 1 [subtype] => MIXED [ifdescription] => 0 [ifid] => 0 [ifdisposition] => 0 [ifdparameters] => 0 [ifparameters] => 1 [parameters] => Array ( => stdClass Object ( [attribute] => boundary [value] => AHNKAKBLDCDIDAGCDHGDAAAKACAK ) ) [parts] => Array ( ) ) Similar TutorialsI seem to be having a difficult time saving the attachments to a folder on the server, all the examples I see show it to the browser, what I need to do is copy the attachment to a separate folder and do some processing on it. So far everything I get, then ftp to my desktop appears corrupt. It works I just can't seem to unzip the zipped attachments, any ideas? My Code: (Not mine, I used examples from the web and put it into a function) function get_attachments($message_number){ global $connection; $structure = imap_fetchstructure($connection, $message_number); $attachments = array(); if(isset($structure->parts) && count($structure->parts)) { for($i = 0; $i < count($structure->parts); $i++) { $attachments[$i] = array( 'is_attachment' => false, 'filename' => '', 'name' => '', 'attachment' => '' ); if($structure->parts[$i]->ifdparameters) { foreach($structure->parts[$i]->dparameters as $object) { if(strtolower($object->attribute) == 'filename') { $attachments[$i]['is_attachment'] = true; $attachments[$i]['filename'] = $object->value; } } } if($structure->parts[$i]->ifparameters) { foreach($structure->parts[$i]->parameters as $object) { if(strtolower($object->attribute) == 'name') { $attachments[$i]['is_attachment'] = true; $attachments[$i]['name'] = $object->value; } } } if($attachments[$i]['is_attachment']) { $attachments[$i]['attachment'] = imap_fetchbody($connection, $message_number, $i+1); if($structure->parts[$i]->encoding == 3) { // 3 = BASE64 $attachments[$i]['attachment'] = base64_decode($attachments[$i]['attachment']); } elseif($structure->parts[$i]->encoding == 4) { // 4 = QUOTED-PRINTABLE $attachments[$i]['attachment'] = quoted_printable_decode($attachments[$i]['attachment']); } } } } return $attachments; } Calling Code: $a = get_attachments(6); $fp = fopen($a[1]['filename'], 'w'); fwrite($fp, $a); fclose($fp); I have spent nearly all day scouring Google for help on this and after trying numerous scripts unsuccessfully and reading up on imap functions but still getting nowhere as well as frying my brain l have had to accept defeat unless anyone of the many gifted coders here can help me out with a script they might have written and used. many thanks Callum I wish to know how i can convert this date 24-09-2010 to this format 2010-09-24 Hello Guys, I want to extract the attachment from an email. I searched and I found the following link below and many similar ones useful. http://garrettstjohn.com/entry/extracting-attachments-from-emails-with-php/ I am able to get the name of the attachments too.. but.. what after getting the file names? .. How do i actually access the file and move it to a location to my server?.. that part is unclear to me.. Please share me your views on this.. or point me in some direction as to how to accomplish this task. Thank you, Rakesh. Hi all, Here's the code I'm using, after opening an IMAP stream to an inbox. The code previous to this opens the inbox, grabs the emails and iterates through them. This bit is checking an individual mail for attachments. Code: [Select] <?php $structure = imap_fetchstructure($mbox, $email_number); $parts = $structure->parts; $fpos=2; for($i = 1; $i < count($parts); $i++) { $message["pid"][$i] = ($i); $part = $parts[$i]; if($part->disposition == 'ATTACHMENT') { // Save the attachment locally to the server // Find the file extension // Save the attachment to DB code here $fpos+=1; } } ?> When I run the script, I get a load of the following reply: Notice: Undefined property: stdClass::$parts in /var/www/html/site/public_html/cron/cron_email_import.php on line XXX Would this mean that there are no actual attachments in the email being processed? Has anyone ever dealt with this function before? All input appreciated. WoolyG Hi. I'm having some problem with my form. I want to create a booking form with the attachment. Its done but have a few error. Anyone can help me? If the form goes to my email, I can download the attachment. but if i want to open it, it will show this error.'Unable to upen the file. Not a valid PDF file.' Beside that, after i submit the form, this error will come out at my form. Warning: fclose(): supplied argument is not a valid stream resource in D:\xampplite\htdocs\borneotours02\booking2.php on line 268 This is my code: <? require_once("Connections/pamconnection.php"); $cart_id=session_id(); if($_POST['Submit']=='Submit'){ if(mysql_query("INSERT INTO inquiry_log1 (id, session_id, tour, name, contact, email02, phone, fax, travel, adult, children, p_requirement, foc, pdf_title, itinerary,, status, date_posted, time) VALUES ('', '".$cart_id."', '".mysql_real_escape_string($_POST['tour'])."', '".mysql_real_escape_string($_POST['name'])."', '".mysql_real_escape_string($_POST['contact'])."', '".mysql_real_escape_string($_POST['email02'])."', '".mysql_real_escape_string($_POST['phone'])."', '".mysql_real_escape_string($_POST['fax'])."', '".mysql_real_escape_string($_POST['travel'])."', '".mysql_real_escape_string($_POST['no_adult'])."', '".mysql_real_escape_string($_POST['no_children'])."', '".mysql_real_escape_string($_POST['product_requirement'])."', '".mysql_real_escape_string($_POST['foc_allocation'])."', '".mysql_real_escape_string($_POST['pdf_file'])."', '".mysql_real_escape_string($_POST['itinerary'])."', 1, '".date("Y-m-d")."', '".date("g:i a")."')")) if($_FILES['pdf_file']!='') { $fileatt = $HTTP_POST_FILES['pdf_file']['tmp_name']; $fileatt_type = $HTTP_POST_FILES['pdf_file']['type']; $file_name = $HTTP_POST_FILES['pdf_file']['name']; $ext = substr(strrchr($fileatt_type, "/"), 1); switch ( $ext ) { case 'pdf': $fileatt_name = $file_name; break; case 'msword': $fileatt_name = $file_name; break; case 'vnd.openxmlformats-officedocument.wordprocessingml.document': $fileatt_name = $file_name; break; } } $email_from = $_POST['email02']; // Who the email is from $email_subject = "Outbound Booking Form"; // The Subject of the email $email_message.='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <!--<style> .title{ font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; } .content{ font-family:Verdana, Arial, Helvetica, sans-serifl; font-size:12px;} </style>--> <body> <table width="600" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000"> <tr><td> <table width="100%" border="0" align="center" cellpadding="4" cellspacing="6" bgcolor="#DCE1E9" class="content"> <tr> <td colspan="2" class="title">Online Booking Form</td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" align="right">'.date("jS F Y").'</td> </tr> <tr class="style9"> <td> </td> </tr>'; if($_POST['tour']!=''){ $email_message.='<tr class="style9"> <td width="32%" class="title02">Tour Package Name</td> <td width="68%" class="email_message">'.$_POST['tour'].'</td> </tr>';} //if($_POST['title']!=''){ //$email_message.='<tr class="style9"> //<td width="32%" class="title02">Title</td> //<td width="68%" class="email_message">'.$_POST['title'].'</td> //</tr>';} $email_message.=' <tr class="style9"><td colspan="2" class="title" bgcolor="#FFFFFF"><strong>CONTACT DETAILS</strong></td></tr>'; if($_POST['name']!=''){ $email_message.='<tr class="style9"> <td width="32%" class="title02">Name</td> <td width="68%" class="email_message">'.$_POST['name'].'</td> </tr>';} if($_POST['contact']!=''){ $email_message.='<tr class="style9"> <td class="title02">Contact Person</td> <td class="email_message">'.$_POST['contact'].'</td> </tr>';} if($_POST['email02']!=''){ $email_message.='<tr class="style9"> <td class="title02">Email Address</td> <td class="email_message">'.$_POST['email02'].'</td> </tr>';} if($_POST['phone']!=''){ $email_message.='<tr class="style9"> <td class="title02">Phone Number</td> <td class="email_message">'.$_POST['phone'].'</td> </tr>';} if($_POST['fax']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">Fax Number</td> <td class="email_message">'.$_POST['fax'].'<br><br></td> </tr>';} $email_message.=' <tr class="style9"><td colspan="2" class="title" bgcolor="#FFFFFF"><strong>TRIP REQUIREMENTS</strong></td></tr>'; if($_POST['travel']!=''){ $email_message.='<tr class="style9"> <td class="title02">Date Of Travel</td> <td class="email_message">'.$_POST['travel'].'</td> </tr>';} $email_message.=' <tr class="style9"><td colspan="2" class="title02">No.Of Travellers :</td></tr>'; if($_POST['adult']!=''){ $email_message.='<tr class="style9"> <td class="title02">Adults</td> <td class="email_message">'.$_POST['adult'].'</td> </tr>';} if($_POST['children']!=''){ $email_message.='<tr class="style9"> <td width="32%" valign="top" class="title02">Children</td> <td width="68%" class="email_message">'.$_POST['children'].'</td> </tr>';} if($_POST['s_interest']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">Special Interest</td> <td class="email_message">'.$_POST['s_interest'].'</td> </tr>';} if($_POST['p_requirement']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">Product Requirement</td> <td class="email_message">'.$_POST['p_requirement'].'</td> </tr>';} if($_POST['foc']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">FOC Allocation</td> <td class="email_message">'.$_POST['foc'].'<br><br></td> </tr>';} $email_message.=' <tr class="style9"><td colspan="2" class="title02">Room Types Required:</td></tr>'; if($_POST['single']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">Single</td> <td class="email_message">'.$_POST['single'].'</td> </tr>';} if($_POST['double']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">Double</td> <td class="email_message">'.$_POST['double'].'</td> </tr>';} if($_POST['triple']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">Triple</td> <td class="email_message">'.$_POST['triple'].'</td> </tr>';} if($_POST['s_requirement']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">Special Requirement</td> <td class="email_message">'.$_POST['s_requirement'].'<br><br></td> </tr>';} $email_message.=' <tr class="style9"><td colspan="2" class="title" bgcolor="#FFFFFF"><strong>ITINERARY</strong></td></tr>'; if($_POST['pdf_file']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">Itinerary File</td> <td class="email_message">'.$_POST['pdf_file'].'</td> </tr>';} if($_POST['itinerary']!=''){ $email_message.='<tr class="style9"> <td valign="top" class="title02">Itinerary</td> <td class="email_message">'.$_POST['itinerary'].'<br><br></td> </tr>';} $email_message.='<tr class="style9"> <td colspan="2" valign="top"><div align="center"> </div></td> </tr> </table> </td></tr></table></body> </html>'; $email_to = "ee_elizebert@hotmail.com"; // Who the email is to ini_set(SMTP, "mail.sarawakhost.com"); ini_set(smtp_port, "587"); ini_set(sendmail_from, $email); $headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); //$data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message .= "\n\n"; $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data .= "\n\n" . "--{$mime_boundary}--\n"; $ok = mail($email_to, $email_subject, $email_message, $headers); if($ok) { $send='<font color=#336600>Feedback sent</font>'; } else { $send='<font color=#CC3300>Failed to send. Please try again.</font>'; } }?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Outbound Booking Form</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style1 {color: #FF0000} body { background-image: url(images/booking.jpg); background-repeat:repeat-x; } --> </style> </head> <script> function booknow() { if(document.form1.name.value==''){alert("Please enter your name. Thank You."); document.form1.name.focus(); return false;} if(document.form1.contact.value==''){alert("Please enter the contact person. Thank You."); document.form1.contact.focus(); return false;} if(document.form1.email02.value==''){alert("Please enter your email address. Thank You."); document.form1.email02.focus(); return false;} if(document.form1.email02.value.indexOf('@')==-1){alert("Invalid email address. Please enter a valid email address. Thank You."); document.form1.email02.focus(); return false;} if(document.form1.email02.value.indexOf('.')==-1){alert("Invalid email address. Please enter a valid email address. Thank You."); document.form1.email02.focus(); return false;} } //<![CDATA[ window.addEvent('domready', function() { myCal2 = new Calendar({ date02: 'd/m/Y' }, { classes: ['dashboard'], direction: 1, tweak: {x: 3, y: -3} }); }); window.addEvent('domready', function() { myCal2 = new Calendar({ date03: 'd/m/Y' }, { classes: ['dashboard'], direction: 1, tweak: {x: 3, y: -3} }); }); //]]> </script> <script type="text/javascript" src="mootools.v1.11.js"></script> <script type="text/javascript" src="DatePicker.js"></script> <script type="text/javascript"> window.addEvent('domready', function(){ $$('input.DatePicker').each( function(el){ new DatePicker(el); }); }); </script> </script> <link rel="stylesheet" type="text/css" href="DatePicker.css" media="screen" /> <link rel="stylesheet" type="text/css" href="css/iframe.css" media="screen" /> <link rel="stylesheet" type="text/css" href="css/dashboard.css" media="screen" /> <link href="css.css" rel="stylesheet" type="text/css" /> <? if($send!=''){?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><? echo $send?></td> </tr> </table> <? }?> <form name="form1" method="post" action="booking2.php" enctype="multipart/form-data"> <table width="100%" border="0" cellspacing="4" cellpadding="2"> <tr> <td align="left" valign="middle" colspan="2"><p class="title3"><? echo $send;?></td> </tr> <tr> <td align="left" valign="middle" colspan="2"><? include("form_feature_tools.php");?></td> </tr> <table width="100%" border="0"> <tr> <td width="17%"><div align="right" class="title6"><strong>Tour Package Name</strong></div></td> <td width="28%"><span class="heading4"><? echo $_GET['tour']; if($_GET['code']!='') echo " (".$_GET['code'].")";?> <input type="hidden" name="tour" value="<? echo $_GET['tour']; if($_GET['code']!='') echo " (".$_GET['code'].")";?>" /> </span></td> <td width="16%"> </td> <td width="39%"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><div align="right"><strong class="title6">CONTACT DETAILS</strong></div></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><div align="right"><span class="title6">Name</span> <span class="content_text3">*</span></div></td> <td><div align="left"><span class="title6"> <input name="name" type="text" class="style7" id="name" size="30" value="<? echo $_POST['name']?>" /> </span></div></td> <td> </td> <td> </td> </tr> <tr> <td><div align="right"><span class="title6">Contact Person</span><span class="content_text3">*</span></div></td> <td><div align="left"><span class="title6"> <input name="contact" type="text" class="style7" id="contact" size="30" value="<? echo $_POST['contact']?>"/> </span></div></td> <td> </td> <td> </td> </tr> <tr> <td><div align="right" class="title6">Email Address <span class="content_text3">*</span></div></td> <td><div align="left"> <input name="email02" type="text" class="style7" id="email02" size="30" value="<? echo $_POST['email02']?>" /> </div></td> <td> </td> <td> </td> </tr> <tr> <td><div align="right" class="title6">Phone Number</div></td> <td><div align="left"> <input type="text" name="phone" id="phone" class="style7" value="<? echo $_POST['phone']?>"/> </div></td> <td> </td> <td> </td> </tr> <tr> <td><div align="right" class="title6">Fax Number</div></td> <td><div align="left"> <input type="text" name="fax" id="fax" class="style7" value="<? echo $_POST['fax']?>"/> </div></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><div align="right"><strong class="title6">TRIP REQUIREMENTS</strong></div></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><div align="right" class="title6">Date Of Travel : </div></td> <td><? echo '<input id="travel" name="travel" style="width:50%" type="text" class="DatePicker" tabindex="1" value="'.date("m/d/Y", $tomorrow).'"/>';?></td> <td> </td> <td> </td> </tr> <tr> <td><div align="right" class="title6" valign="top">No Of Travellers: </div></td> <td><table width="100%" border="0"> <tr> <td width="19%" class="title6"><div align="right">Adult:</div></td> <td width="81%"><div align="left"> <input type="text" name="no_adult" id="no_adult" value="<? echo $_POST['adult']?>" /> </div></td> </tr> <tr> <td><div align="right" class="title6">Children:</div></td> <td><div align="left"> <input type="text" name="no_children" id="no_children" value="<? echo $_POST['children']?>"/> </div></td> </tr> </table></td> <td><div align="right" class="title6" valign="top">Product Requirement: </div></td> <td> <table width="41%" border="0"> <tr> <td width="8%"><input type="radio" name="product_requirement" id="air" value="air and land" <? if($_POST['p_requirement']=="air"){?> selected="selected"<? }?>/></td> <td width="92%" class="title6"><div align="left">Air & Land</div></td> </tr> <tr> <td><input type="radio" name="product_requirement" id="land" value="land only" <? if($_POST['p_requirement']=="land"){?> selected="selected"<? }?> /></td> <td class="title6"><div align="left">Land Only</div></td> </tr> </table></td> </tr> <tr> <td class="title6"><div align="right">Special Interest:</div></td> <td><div align="left"> <textarea name="special_interest" id="special_interest" cols="30" rows="3"><? echo $_POST['s_interest']?></textarea> </div></td> <td><div align="right" valign="top" class="title6">FOC Allocation</div></td> <td><div align="left"> <input type="text" name="foc_allocation" id="foc_allocation" value="<? echo $_POST['foc']?>"/> </div></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td class="title6"><div align="right"><strong>ITINERARY</strong></div></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><div align="right" class="title6">Upload Itinerary</div></td> <td><div align="left"> <input name="pdf_file" enctype="multipart/form-data" type="file" id="pdf_file"> <br> <span class="content_text">Browse for file (.doc or .pdf only)</span></div></td> <td> </td> <td> </td> </tr> <tr> <td><div align="right" class="title6">or ENTER Itinerary Here;</div></td> <td> <label> <div align="left"> <textarea name="itinerary" id="itinerary" cols="30" rows="3"><? echo $_POST['itinerary']?></textarea> </div> </label></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><div align="right"> <input name="reset" type="reset" id="reset" value="Reset"/> </div></td> <td><div align="left"> <input type="Submit" name="Submit" value="Submit" onClick="return booknow();" /> </div></td> <td> </td> </tr> </table> </body> </html> Hello everyone. I'm trying to learn php here on the fly because i've been tasked with moving an existing internal website to a new server because the old one is failing fast. The failing server is very old and running a much older version of php. This form when submitted should send an email but the submit button doesn't even show when running the form on the new server. Also, right now all the text fields are showing the VALUE= value. I notice if I remove VALUE= from each part that removes the text but I'm not sure if that's the proper way to fix it.
Also, after the "Please wait for confirmation..." message, there is one text box prepopulated with \"ds\", then one below it with \"Click, then it appears to dump the rest of the code after </FORM> up to the last ?> onto the webpage as text.
I'm guessing some coding methods changed between php4 and whatever the newest version of php is that comes with a fresh linux server install. Can anyone offer any tips or fixes? Thanks in advance.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Update My Phone Number</title> </head> <body bgcolor="White" > <table width="640"> <tr><td><hr width="640" size="2" color="Red" align="left"></td></tr> <tr><td align="left"><font size="+3"><strong>Update Employee Telephone Numbers</strong></font></td></tr> <tr><td><hr width="640" size="2" color="gray" align="left"></td></tr> </table> <br> <? $form_block = " <FORM METHOD=\"post\" ACTION=\"$PHP_SELF\"> <p><strong>Employee name: <font size=\"-1\"><em>(Exactly as it should be listed)</em></font> <font color=\"#FF0000\">**Required</font></strong><br> <INPUT TYPE=\"text\" NAME=\"employee\" VALUE=\"$employee\" SIZE=\"75\" MAXLENGTH=\"100\"></p> <p><strong>Department: <font size=\"-1\"><em>(Exactly as it should be listed)</em></font> <font color=\"#FF0000\">**Required</font></strong><br> <INPUT TYPE=\"text\" NAME=\"department\" VALUE=\"$department\" SIZE=\"75\" MAXLENGTH=\"50\"></p> <p><strong>Work Phone Number <font color=\"#FF0000\">**Required</font></strong><br> <INPUT TYPE=\"text\" NAME=\"work\" VALUE=\"$work\" SIZE=\"15\" MAXLENGTH=\"15\"></p> <p><strong>Cell Phone Number <font color=\"#FF0000\">**Required -- enter \"na\" for not applicable</font></strong><br> <INPUT TYPE=\"text\" NAME=\"cell\" VALUE=\"$cell\" SIZE=\"15\" MAXLENGTH=\"15\"></p> <p><strong>Home Phone Number <font color=\"#FF0000\">**Required -- enter \"na\" for not applicable</font></strong><br> <INPUT type=\"text\" Name=\"home\" VALUE=\"$home\" SIZE=15 \" MAXLENGTH=\"15\"> </p> <p><strong>Pager Number <font color=\"#FF0000\">**Leave blank if you don't have a pager</font></strong><br> <INPUT type=\"text\" Name=\"pager\" VALUE=\"$pager\" SIZE=15 MAXLENGTH=\"15\"> </p> <p><strong>Comments:</strong><br> <TEXTAREA NAME=\"message\" ROWS=5 COLS=50 WRAP=virtual>$message</TEXTAREA></p> <br> <p><em>Please wait for confirmation - this may take a few seconds.</em></p> <INPUT type=\"hidden\" name=\"op\" value=\"ds\"> <p><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Click here to send this report\"></p> <br> </FORM> "; if ($op != "ds") { //they need to see the form echo "$form_block"; } else if ($op == "ds") { if ($employee == "") { $employee_err = "<font color=red>Please enter employee name! **REQUIRED</font><br>"; $send = "no"; } if ($department == "") { $department_err = "<font color=red>Please enter your department! **REQUIRED</font><br>"; $send = "no"; } if ($work == "") { $work_err = "<font color=red>Please enter your work phone! **REQUIRED</font><br>"; $send = "no"; } if ($cell == "") { $cell_err = "<font color=red>Please enter your cell phone! ** REQUIRED, enter \"na\" for not applicable</font><br>"; $send = "no"; } if ($home == "") { $home_err = "<font color=red>Please enter your home phone! *REQUIRED, enter \"na\" for not applicable!</font><br>"; $send = "no"; } if ($send != "no") { // it's okay to send $msg = "Please update the following phone numbers for: \t$employee\n\n"; $msg .= "Employee name:\t$employee\n\n"; $msg .= "Department:\t$department\n\n"; $msg .= "Work:\t$work\n\n"; $msg .= "Cell:\t$cell\n\n"; $msg .= "Home:\t$home\n\n"; $msg .= "Pager:\t$pager\n\n"; $msg .= "Comments:\t$message\n\n"; $to = "me@me.com"; $subject = "Phone Update: \t$employee, - \t$department\n"; $mailheaders = "From: UpdateMyPhone\n\n"; mail($to, $subject, $msg, $mailheaders); echo "<h1><font color=blue>Thank you! Your phone update has been filed. </font></h1><br> $form_block "; } else if ($send == "no") { echo "$employee_err"; echo "$department_err"; echo "$work_err"; echo "$cell_err"; echo "$home_err"; echo "$pager_err"; echo "$message_err"; echo "$form_block"; } } ?> </body> </html> Hi, Any other way to import the native xlsx excel file into PHPmyadmin. I know this function was supported in the older versions prior to phpMyAdmin 3.4.5. I don't want to convert the excel file to csv format. Thanks Hi guys, New to PHP but learning every day. This is probably a really newbie error but I've tried multiple different ways and can't get it to work. $tableData = ''; if(mysql_num_rows($result)==0) { $tableData = "<tr><td colspan=\"4\">No results returned.</td></tr>\n"; } else { while($row = mysql_fetch_assoc($result)) { $tableData .= " <tr bgcolor='#FFFFFF' align='center'>\n"; $tableData .= " <td>{$rank}</td>\n"; $tableData .= " </tr>\n"; $rank = ($row['rank']); if ($rank == 0) { print "Cadet"; } if ($rank == 1) { print "Sergeant"; } if ($rank == 2) { print "2nd Lieutenant"; } if ($rank == 3) { print "1st Lieutenant"; } if ($rank == 4) { print "Captain"; } if ($rank == 5) { print "Major"; } if ($rank == 6) { print "Lt. Colonel"; } if ($rank == 7) { print "Colonel"; } } } ?> <table class="tables" cellspacing="0" cellpadding="0"> <tr> <th>Rank</th> </tr> <?php echo $tableData; ?> </table> When this script is run the $rank variable shows the numbers 1,2,3,4,5,6,7 instead of the textual translations for example if 0 is displayed then "cadet" should be shown instead. The current script shows the numbers in the table but prints the accurate translations at the top outside the table tag..... Can anyone show me what I've done wrong here? Thank you in advance. Hello, I have tried to figure it out on my own for two months, but just don't get it. My goal is to have automated data exchange to my e-shop. It is in Estonian. http://www.elnetsec.ee/pood/ And the place I have to get the data from is a e-shop called Acme. acc.acme.lt All they gave me was a php document and told me to use it. I'll copy it here, so maybe someone can give me advice, which lines do I have to add and which to change. <?php class Filter { public $Name; public $Value; } class ArrayOfFilter { public $Filter; } class GetProductListRequest { public $Filters; } class GetProductList { public $GetProductListRequest; } class GetInvoiceListRequest { public $Filters; } class GetInvoiceList { public $GetInvoiceListRequest; } class GetInvoiceDetailsRequest { public $Filters; } class GetInvoiceProductSerialList { public $GetInvoiceProductSerialListRequest; } class GetInvoiceProductSerialListRequest { public $Filters; } class GetInvoiceDetails { public $GetInvoiceDetailsRequest; } class GetProductSpecification { public $GetProductSpecificationRequest; } class GetProductSpecificationRequest { public $Filters; } class GetProductResourcesRequest { public $Filters; } class GetProductResources { public $GetProductResourcesRequest; } class GetProductBarcodeList { public $GetProductBarcodeListRequest; } class GetProductBarcodeListRequest { public $Filters; } class GetAddressList { public $GetAddressListRequest; } class GetAddressListRequest { public $Filters; } class GetCustomerUserList { public $GetCustomerUserListRequest; } class GetCustomerUserListRequest { public $Filters; } class GetInvoiceShipments { public $GetInvoiceShipmentsRequest; } class GetInvoiceShipmentsRequest { public $Filters; } class GetOrderDetails { public $GetOrderDetailsRequest; } class GetOrderDetailsRequest { public $Filters; } class PurchaseProducts { public $PurchaseProductsRequest; } class PurchaseProductsRequest { public $Filters; public $PurchaseLines; } class ProductPurchaseLine { public $ProductPurchaseLineId; public $SupplierCode; public $Quantity; public $DeliveryTypeId; public $DeliveryAddress; public $Note; } class Address { public $AddressId; public $Street; public $City; public $PostalCode; public $CountryCode; } class AcmeAPI { public $licenseKey = '498ec72c-e8e7-48f2-b300-d95666aeb141'; private $soapClient = null; private $soapHeader = null; private $wsdl = 'https://api.acme.lt/1.0/commerce.asmx?WSDL'; private function init () { $map = array( "Filter"=>"Filter", "ArrayOfFilter" => "ArrayOfFilter", "GetProductListRequest"=>"GetProductListRequest", "GetProductList"=>"GetProductList", "GetInvoiceList"=>"GetInvoiceList", "GetInvoiceListRequest"=>"GetInvoiceListRequest", "GetProductSpecification"=>"GetProductSpecification", "GetProductSpecificationRequest"=>"GetProductSpecificationRequest", "GetProductResources"=>"GetProductResources", "GetInvoiceDetails"=>"GetInvoiceDetails", "GetInvoiceDetailsRequest"=>"GetInvoiceDetailsRequest", "GetInvoiceProductSerialList"=>"GetInvoiceProductSerialList", "GetInvoiceProductSerialListRequest"=>"GetInvoiceProductSerialListRequest", "GetAddressList" => "GetAddressList", "GetAddressListRequest" => "GetAddressListRequest", "GetCustomerUserList" => "GetCustomerUserList", "GetCustomerUserListRequest" => "GetCustomerUserListRequest", "GetInvoiceShipments" => "GetInvoiceShipments", "GetInvoiceShipmentsRequest" => "GetInvoiceShipmentsRequest", "GetOrderDetails" => "GetOrderDetails", "GetOrderDetailsRequest" => "GetOrderDetailsRequest", "PurchaseProducts" => "PurchaseProducts", "PurchaseProductsRequests" => "PurchaseProductsRequest", "ProductPurchaseLine" => "ProductPurchaseLine", "DeliveryAddress" => "Address" ); $this->soapClient = new SoapClient($this->wsdl,array('classmap'=> $map ,'trace' => 1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS )); $this->soapHeader = new SoapHeader('http://schemas.acme.eu/', 'LicenseHeader', array('LicenseKey'=>$this->licenseKey), false); $this->soapClient->__setSoapHeaders(array($this->soapHeader)); } public function getVendors() { try { $this->init(); $result = $this->soapClient->GetVendorList(); foreach ($result->GetVendorListResult->VendorList->Vendor as $b) { print $b->VendorId." ".$b->VendorName."<br />"; } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getInvoiceList() { try { $this->init(); $request = new GetInvoiceListRequest(); $request->Filters = new ArrayOfFilter(); $datefrom = new Filter(); $datefrom->Name = "InvoiceDateFrom"; $datefrom->Value= "2008.01.01"; $dateTo = new Filter(); $dateTo->Name = "InvoiceDateTo"; $dateTo->Value = "2009.03.16"; $parameters = $request->Filters->Filter = array( $datefrom,$dateTo); $params = new GetInvoiceList(); $params->GetInvoiceListRequest = $request; $result = $this->soapClient->GetInvoiceList($params); if(isset($result->GetInvoiceListResult->InvoiceHeaderList->InvoiceHeader)) { foreach ($result->GetInvoiceListResult->InvoiceHeaderList->InvoiceHeader as $inv) { print $inv->InvoiceNumber." ".$inv->InvoiceDate."</br>"; } } else { print "no invoices found"; } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getInvoiceDetails() { try { $this->init(); $request = new GetInvoiceDetailsRequest(); $request->Filters = new ArrayOfFilter(); $invoice = new Filter(); $invoice->Name = "InvoiceNumber"; $invoice->Value= "ACC-01722223"; $parameters = $request->Filters->Filter = array($invoice); $params = new GetInvoiceDetails(); $params->GetInvoiceDetailsRequest = $request; $result = $this->soapClient->GetInvoiceDetails($params); foreach ($result->GetInvoiceDetailsResult->InvoiceList as $inv) { print $inv->InvoiceHeader->InvoiceNumber." ".$inv->InvoiceHeader->InvoiceDate."</br>"; foreach($inv->InvoiceLine as $line) { print $line->SupplierCode." | ".$line->ShortName." | ".$line->LineAmount."<br />"; } } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getInvoiceProductSerials() { try { $this->init(); $request = new GetInvoiceProductSerialListRequest(); $request->Filters = new ArrayOfFilter(); $invoice = new Filter(); $invoice->Name = "InvoiceNumber"; $invoice->Value= "ACC-00761335"; $parameters = $request->Filters->Filter = array($invoice); $params = new GetInvoiceProductSerialList(); $params->GetInvoiceProductSerialListRequest = $request; $result = $this->soapClient->GetInvoiceProductSerialList($params); foreach ($result->GetInvoiceProductSerialListResult->ProductSerialList->ProductSerial as $ps) { print $ps->SupplierCode." ".$ps->SerialNumber."</br>"; } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getProductSpecification() { try { $this->init(); $request = new GetProductSpecificationRequest(); $request->Filters = new ArrayOfFilter(); $language = new Filter(); $language->Name = "Language"; $language->Value= "en-us"; $product = new Filter(); $product->Name = "SupplierCode"; $product->Value= "032016"; $parameters = $request->Filters->Filter = array($language, $product); //$parameters = $request->Filters->Filter = array($language); $params = new GetProductSpecification(); $params->GetProductSpecificationRequest = $request; $result = $this->soapClient->GetProductSpecification($params); foreach ($result->GetProductSpecificationResult->ProductSpecification as $spec) { print $spec->SupplierCode." "; foreach($spec->ProductProperty as $property) { print $property->PropertyName.": ".$property->PropertyValue."<br />" ; } } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getProductResources() { try { $this->init(); $request = new GetProductResourcesRequest(); $request->Filters = new ArrayOfFilter(); $language = new Filter(); $language->Name = "Language"; $language->Value= "en-us"; $product = new Filter(); $product->Name = "SupplierCode"; $product->Value= "025348"; $parameters = $request->Filters->Filter = array($language, $product); //$parameters = $request->Filters->Filter = array($language); // all resources will be returned if no product filter supplied $params = new GetProductResources(); $params->GetProductResourcesRequest = $request; $result = $this->soapClient->GetProductResources($params); foreach ($result->GetProductResourcesResult->ProductResources as $res) { print $res->SupplierCode." "; if(isset($res->ProductResource)) { foreach($res->ProductResource as $r) { print $r->ResourceName.": ".$r->ResourceURL."<br />" ; } } } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getProductBarcodes() { try { $this->init(); $request = new GetProductBarcodeListRequest(); $params = new GetProductBarcodeList(); $params->GetProductBarcodeListRequest = $request; $result = $this->soapClient->GetProductBarcodeList($params); if($result->GetProductBarcodeListResult->ProductBarcodeList->ProductBarcode) { foreach ($result->GetProductBarcodeListResult->ProductBarcodeList->ProductBarcode as $b) { print $b->SupplierCode." ".$b->Barcode."<br />"; } } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getProductClassification () { try { $this->init(); $result = $this->soapClient->GetProductClassification(); // segments print "Segments list:<br />"; foreach ($result->GetProductClassificationResult->SegmentList->Segment as $b) { print $b->SegmentId." ".$b->SegmentName."<br />"; } print "-----------------------------------------------<br />"; // Groups print "Group list:<br />"; foreach ($result->GetProductClassificationResult->GroupList->Group as $b) { print $b->GroupId." ".$b->GroupName."<br />"; } print "-----------------------------------------------<br />"; // Classes print "Class list:<br />"; foreach ($result->GetProductClassificationResult->ClassList->Class as $b) { print $b->ClassId." ".$b->ClassName."<br />"; } print "-------------------------------------------------<br />"; // Series print "Series list:<br />"; foreach ($result->GetProductClassificationResult->SeriesList->Series as $b) { print $b->SeriesId." ".$b->SeriesName."<br />"; } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getProductList () { try { $this->init(); $request = new GetProductListRequest(); $request->Filters = new ArrayOfFilter(); $language = new Filter(); $language->Name = "Language"; $language->Value= "lt-lt"; $currency = new Filter(); $currency->Name = "Currency"; $currency->Value = "LTL"; $request->Filters->Filter = array( $language,$currency); $params = new GetProductList(); $params->GetProductListRequest = $request; $result = $this->soapClient->GetProductList($params); foreach ($result->GetProductListResult->ProductList->Product as $p) { print $p->SupplierCode." ".$p->Name."<br />"; } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getInvoiceShipments() { try { $this->init(); $request = new GetInvoiceShipmentsRequest(); $request->Filters = new ArrayOfFilter(); $invoice = new Filter(); $invoice->Name = "InvoiceNumber"; $invoice->Value= "ACC-00761335"; // set invoice number here $parameters = $request->Filters->Filter = array($invoice); $params = new GetInvoiceShipments(); $params->GetInvoiceShipmentsRequest = $request; $result = $this->soapClient->GetInvoiceShipments($params); foreach ($result->GetInvoiceShipmentsResult->ShipmentList->Shipment as $ps) { print $ps->CarrierId." ".$ps->Number."</br>"; } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getOrderDetails() { try { $this->init(); $request = new GetOrderDetailsRequest(); $request->Filters = new ArrayOfFilter(); $parameters = $request->Filters->Filter = array(); $params = new GetOrderDetails(); $params->GetOrderDetailsRequest = $request; $result = $this->soapClient->GetOrderDetails($params); if(isset($result->GetOrderDetailsResult->OrderList->Order)) { foreach ($result->GetOrderDetailsResult->OrderList->Order as $o) { print "OrderId: ".$o->OrderHeader->OrderId." <br />"; foreach($o->OrderLine as $line) { print "OrderLineId: ".$line->OrderLineId." SupplierCode: ".$line->SupplierCode." LineAmount: ".$line->LineAmount." <br />"; } print "----------------------------------------------------<br />"; } } else { print "no orders found"; } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function purchaseProducts() { try { $this->init(); $request = new PurchaseProductsRequest(); $request->Filters = new ArrayOfFilter(); $request->Filters->Filter = array(); $line = new ProductPurchaseLine(); $line->ProductPurchaseLineId = "demo"; $line->SupplierCode = "003315"; $line->Quantity = 1; $line->DeliveryTypeId = 0; $line->Note = "test order"; $address = new Address(); $address->AddressId = "ecommtest-001"; $line->DeliveryAddress = $address; $request->PurchaseLines = array($line); $params = new PurchaseProducts(); $params->PurchaseProductsRequest = $request; $result = $this->soapClient->PurchaseProducts($params); foreach ($result->PurchaseProductsResult->StatusList->ProductPurchaseStatus as $st) { print $st->ProductPurchaseLineId." ".$st->Status."<br />"; } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getAddressList() { try { $this->init(); $request = new GetAddressListRequest(); $request->Filters = new ArrayOfFilter(); $request->Filters->Filter = array(); $params = new GetAddressList(); $params->GetAddressListRequest = $request; $result = $this->soapClient->GetAddressList($params); foreach ($result->GetAddressListResult->AddressList->Address as $b) { print $b->AddressId." ".$b->Street." ".$b->City."<br />"; } //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } public function getCustomerUserList() { try { $this->init(); $request = new GetCustomerUserListRequest(); $request->Filters = new ArrayOfFilter(); $request->Filters->Filter = array(); $params = new GetCustomerUserList(); $params->GetCustomerUserListRequest = $request; $result = $this->soapClient->GetCustomerUserList($params); if(isset($result->GetCustomerUserListResult->UserList->User)) { foreach ($result->GetCustomerUserListResult->UserList->User as $b) { print $b->UserId." ".$b->FirstName." ".$b->LastName."<br />"; } } // uncomment this line to see raw result of this method response //echo "<pre>". print_r($result,1) . '</pre>'; } catch(SoapFault $e) { echo '<xmp>' . $this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest() . '</xmp>'; echo "<pre>". print_r($e,1) . '</pre>'; } } } $client = new AcmeAPI() ; $client->getVendors(); //$client->getProductClassification(); //$client->getProductList(); //$client->getProductBarcodes(); //$client->getInvoiceList(); //$client->GetInvoiceDetails(); //$client->GetInvoiceProductSerials(); //$client->getProductSpecification(); //$client->getProductResources(); //$client->getAddressList(); //$client->getCustomerUserList(); //$client->getInvoiceShipments(); //$client->getOrderDetails(); //$client->purchaseProducts(); ?> Thanks! Hi .. i have an array format like (mysql result array) $new_array=Array ( [0] => Array ( [quantity] => 5 ) [1] => Array ( [quantity] => 25 ) [2] => Array ( [quantity] => 20 ) ) I have to convert this array into the following format $new_array['quantity'][0]=5 $new_array['quantity'][1]=25 $new_array['quantity'][2]=20 How to convert this array format using any standard array method. Hi, I making a banner exchange script. Members will have to place a banner code on their sites to make banners appear. Some members might cheat by using bots to refresh the page to gain impressions and to waste other members impressions so i wanted to know if bots have ip addresses? because i want to only give member impressions if their visitors have ip. What are the other things i can do to check if members are cheating?. Thanks
$ip=$_SERVER['REMOTE_ADDR']; $html = @file_get_contents($urlw) or problem('Can\'t open Your Remote URL!'); $html = strtolower($html); $site_url = strtolower($set['site_url']); if (preg_match_all('/<a\s[^>]*href=([\"\']??)([^" >]*?)\\1([^>]*)>/siU', $html, $matches, PREG_SET_ORDER)) { foreach($matches as $match) { if ($match[2] == $set['site_url'] || $match[2] == $set['site_url'].'/') { $found = 1; if (strstr($match[3],'nofollow')) { $nofollow = 1; } break; } } } if ($found == 0) { echo "<center><h2>Our URL Not FOund on your page please submit or check again</h2></center>"; } else next proceggerr.... in $html we getting the content of that page which that user give where he put our link what is this actually this all code is doing infact i was making a link exchange site where on a page people can submit their link for exchange and give their site link and the that page link where they have put our link this code verify at the sPot did they have put our code or not but m facing some problem.. beacuse it's not working good Hi All, Its been a while since i've posted, its good to be back. I am currently trying to pull two exchange rates against the $ using YQL's restful url. Unfortunately I am having a huge problem returning the results correct.... currently my array will only output a single rate (instead of two) and the hash array returns with the base rate name rather than the expected currency code. I hope someone can help me sort this as it's given me quite a headache! Please see the code below: Code: [Select] <?php require_once('uwe_proxy.php'); /* * To change this template, choose Tools | Templates * and open the template in the editor. */ # use the yahoo YQL rest service to return any number of rates in a hash function get_yahoo_rest_rate ($base, $curr_arr) { $params = ''; $rates = array(); # define the YQL rest url head & tail $yql_base_uri = "http://query.yahooapis.com/v1/public/yql"; $yql_tail_uri = '&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys'; # build up the $params value foreach($curr_arr as $curr) { $params .= $curr.$base.','; } #strip last comma $params = substr($params, 0, -1); # build the query with the params as comma sep. string eg. USDGBP,USDBOB,.. $yql_query = "select * from yahoo.finance.xchange where pair IN ('{$params}')"; # build the the complete YQL query $yql_query_url = $yql_base_uri . "?q=" . urlencode($yql_query) . $yql_tail_uri; # send the query via proxy and get as string and load as simplexml object $yql_response = @simplexml_load_string(file_get_contents_proxy($yql_query_url)); Print_r($yql_query_url); //- debugging only # process simplexml object and return a sorted hash of rates or FALSE on error if ($yql_response) { foreach($yql_response->results->rate as $rate) { if ((float)$rate->Rate>0) { $rates[substr((string)$rate->attributes()->id, -3)] = (float)$rate->Rate; } } ksort($rates); return $rates; } else { return FALSE; }// print_r($yql_response); - debugging only } /////// - debugging only $curr_arr = array('GBP','GBP'); $rates = get_yahoo_rest_rate ('USD', $curr_arr); //PRINT_R($yql_response); print_r($rates); ?> Sorry about dumping the whole lot - but I really don't know where this is going wrong! Thanks in Advance for any help or pointers in the right direction! Hi, am trying without much luck, (I am new), to define an exchange rate on the page and then mutiplying it by a value I am extracting from a mysql db. I write the value as below normally but having trouble writing this entry and multiplying it by my defined exchanged rate of say 2.22. <?php if(!empty($row['Band_1_Price'])) {echo "<div class=pricing_box_right2>£".$row['Band_1_Price']."</div></div>"; } ?> Thanks so much. Hello php Freaks, before i start , let me tell you ; BY GOD, i googled, i used countless search functions on several websites and forums, i even called some friends that told me once, they are good with php, but guess what : No Results , AT ALL! So here i am, sorta desperate and hungry for a solution. I need to admit, and somehow its obvious, i am not much of a Programmer, or Coder of some kind. I be more the gfx type of Guy ! Well, here we go : I bought a php Script, and ran a first test on a free web host ( like always ) to check if all looks fine, works well and runs like a charm. And it did. So i went over to my paid space account, bought a domain, and installed the Script on my new domain. All was fine, until i registered a test account. The Script suppose to send an activation email , with an activation link in it. As i said before, on the FREE web space , it worked just fine, even though i entered a gmail Admin Email. (not like i planed to do support@newdomain.com) After a lot of research and 3 re-installations i contacted the Support to tell them that my script dont work on their Server. And here it comes : They don`t allow php Mail for Spamming Reasons. And they are not willing to make an exception. But, they gave me the advice to implement an authenticated smpt script in order to get the job done. The Vendor, is not willing to help me, and i am to much of a php noob to actually know or understand what to do now. Basically i need to know how i pull of a switch from php mail() to authenticate smpt. Here the original Code, with the mail function : Code: [Select] <?php include('header.php'); if(isset($_POST['register'])){ foreach($_POST as $key => $value) { $sec[$key] = filter($value); } $verificare1 = mysql_query("SELECT * FROM `users` WHERE `login`='{$sec['user']}' OR `email`='{$sec['email']}'"); $verificare = mysql_num_rows($verificare1); if ($verificare > 0) { $mesaj = "<div class=\"error\">ERROR: Username or email already registered!</div>"; }else if (!isUserID($sec['user'])) { $mesaj = "<div class=\"error\">ERROR: Username is incorrect!</div>"; }else if(!isEmail($sec['email'])) { $mesaj = "<div class=\"error\">ERROR: Enter a valid email address!</div>"; }else if (!checkPwd($sec['password'],$sec['password2'])) { $mesaj = "<div class=\"error\">ERROR: Passwords do not match!</div>"; }else{ if(isset($_COOKIE['PlusREF'])){ $ref = $_COOKIE['PlusREF']; $user1 = mysql_query("SELECT * FROM `users` WHERE `id`='{$ref}'"); $user = mysql_fetch_object($user1); mysql_query("INSERT INTO `referals`(user,referal,date) values('{$user->login}','{$sec['user']}',NOW())"); } $activare = rand(000000000, 999999909); mail($sec['email'],"Activate your account"," Hello, Thank you for your signup on our site. Click on this link to activate your account: {$site->site_url}/activate.php?cod={$activare} Best Regards!","From: Site Admin <{$site->site_email}>"); $final = VisitorIP(); $passa = $sec['password']; $passc = MD5($passa); mysql_query("INSERT INTO `users`(email,login,IP,pass,passdecoded,ref,signup,activate) values('{$sec['email']}','{$sec['user']}','$final','$passc','$passa','{$ref}',NOW(),'{$activare}')")or die(mysql_error()); $mesaj = "<div class=\"success\">Registered! You need to confirm your email address now!</div>"; }} ?> <div class="block medium right"> <div class="top"> <h1>Register</h1> </div> <div class="content"><div class="msg"><?echo $mesaj;?></div> <form action="" method="post"> <fieldset> <p> <label>Username</label><br/> <input class="text big" type="text" value="" name="user"/> </p> <p> <label>Email</label><br/> <input class="text big" type="email" value="" name="email"/> </p> <p> <label>Password</label> <br/> <input class="password" type="password" value="" name="password"/> </p> <p> <label>Repeat Password</label> <br/> <input class="password" type="password" value="" name="password2"/> </p> <p> <input type="submit" class="button gray small" value="Register" name="register" /> </p> </fieldset> </form> </div> </div> <?include('footer.php');?> The imap code below displays the date like this: Sat, 18 Feb 2012 19:22:02 +0100 I want the date to be displayed like this instead: 2012-02-18 Any idea how I can achieve this? Thanks in advance Code: [Select] <?php date_default_timezone_set ("Europe/Stockholm"); /* connect to mail */ $hostname = '{xxx.xxxx.com:143/notls}INBOX'; $username = 'xxxxx@xxxxx.com'; $password = 'xxxxxx'; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die('Anslutning till mail misslyckades: ' . imap_last_error()); /* grab emails */ $emails = imap_search($inbox,'ALL'); /* if emails are returned, cycle through each... */ if($emails) { /* begin output var */ $output = ''; /* put the newest emails on top */ rsort($emails); /* for every email... */ foreach($emails as $email_number) { /* get information specific to this email */ $overview = imap_fetch_overview($inbox,$email_number,0); $message = imap_fetchbody($inbox,$email_number,2); $date = date('d m Y'); $swedate = $overview[0]->date; /* output the email information */ $output.= '<li>'; $output.= '<a href="#"><strong>'.$swedate.'</strong> '; $output.= ''.$overview[0]->subject.'<br> '; $output.= '<small> Från: '.$overview[0]->from.'</small></a>'; $output.= '</li>'; } echo $output; } /* close the connection */ imap_close($inbox); ?> Hey guys, Been developing a bespoke "helpdesk" system for work and, while it works well on the whole, I am having major problems with base64 encoded email bodies. Admittedly, this might be due to my misunderstanding of imap body parts. It seems in my current setup, the system thinks that all mails are either "type" 0 or 4. As a result, base64 emails don't get decoded and display as an unreadable long string. Here is what my code for the body decoding looks like just now - can provide more on request. $from=$overview[0]->from; $subject=$overview[0]->subject; $subdb=mysql_real_escape_string($subject); $lookingfor=explode("~#",$body); $result=$from; $find=strrpos($ir, $lookingfor[1]); $findreplystream=mysql_query("SELECT * FROM tickets WHERE ticket_md5='$lookingfor[1]'") or die(''.mysql_error().''); $stream=mysql_fetch_array($findreplystream); $now=time(); if($structure->encoding == 0){ $arr1=array("=A3", "=80"); $arr2=array("£", "€"); $newcontent=$explodeunder[0]; define("CHARSET", "ISO-8859-1"); $dbcontenta=str_replace($arr1, $arr2, $newcontent); $r=mb_detect_encoding($dbcontenta); if($r=="UTF-8"){ $dbcontents=mb_convert_encoding($dbcontenta, "ISO-8859-1", "UTF-8"); $dbcontent1=addslashes($dbcontents); $dbcontent2=strip_tags($dbcontent1); } elseif($r=="ASCII"){ $dbcontentb=mb_convert_encoding($dbcontenta, "UTF-8", "ASCII"); $dbcontents=mb_convert_encoding($dbcontentb, "ISO-8859-1", "UTF-8"); $dbcontent1=addslashes($dbcontents); $dbcontentf=strip_tags($dbcontent1); $dbcontent2=quoted_printable_decode($dbcontentf); } } elseif($structure->encoding == 4) { $dbcontent=$explodeunder[0]; $dbcontentf=quoted_printable_decode($dbcontent); $dbcontent2=mb_convert_encoding($dbcontentf, "ISO-8859-1", "UTF-8"); } elseif($structure->encoding == 3) { $dbcontent2=imap_base64($explodeunder[0]); } elseif($structure->encoding == 1){ $dbcontent3=imap_8bit($explodeunder[0]); $dbcontent2=quoted_printable_decode($dbcontent3); } Can anyone advise me with this? I'd be greatful for any assistance at all, as it's causing me nightmares! All the best How do u work with .jpg file attachments using the IMAP mail functions... i already know how to read the body text from an e-mail with IMAP but I haven't worked with attachments and don't know where to start... i basically want to get the .jpg attachment and save it to a folder on my server. I'm using imap_open and when I use imap_headerinfo and output the info, I want to be able to have an array of words to match the fromaddress to.... case-insensitive. I tried ton of different ways... array_search array_filter stripos stristr And tried adding strtolower in a few Tried setting the object as a var and comparing it that way... but it either chokes on the object or the array... Or ignores it completely For example setting an array like this: Code: [Select] $blacklist_array = array("wl_partners@cupid.com", "Replica Shop", "CJ Adams", "eharmony", "Dr.Maxman", "Credit Check"); And the fromaddress has this in it: Credit Check <check@iamaspammer.com> I can't get it to work to match the Credit Check only part. I got it to work if I do a foreach through the messages and then a foreach through the array then process a good or bad result, but it takes too long if there are a ton of messages to process... The code is a mess right now with all the trial and errors. Any ideas? I'm kinda brain dead at this point and have been up way to long... Thanks... |