3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php require(INCLUDE_URL.SEP.'phpmailer/class.phpmailer.php'); include_once("popup.php"); if(!xml2php("workorder")) { $smarty->assign('error_msg',"Error in language file"); } $login_id = $_SESSION['login_id']; $smarty->assign('login_id', $login_id); $wo_id = $VAR['wo_id']; $smarty->assign('wo_id', $wo_id); $company = $VAR['company']; $smarty->assign('company', $company); $customer_id = $VAR['customer_id']; $smarty->assign('customer_id', $customer_id); //pass message type from url $msg_type = $VAR['msg_type']; $smarty->assign('msg_type', $msg_type); $smarty->assign('msg_id', $VAR['msg_id']); $rep_date=date('D, d M Y - h:i A'); //set template for individual messages $eml_template=<<<EOF <table align="center" cellpadding="0" cellspacing="0" style="margin: 0px auto; text-align: left; color: rgb(153, 153, 153); line-height: 15pt; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; border-collapse: collapse;" width="100%"> <tbody> <tr> <td bgcolor="#ffffff" valign="top">&nbsp;</td> </tr> <tr> <td bgcolor="#ffffff" style="padding: 15px 20px; color: rgb(102, 102, 102); line-height: 15pt;"> <hr style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; border:1px solid #f3f3f3"/> <p style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><input alt="" src="[[employee_pic]]" style="width: 50px; height: 50px; float: left; margin: 0px 10px; border-width: 1px; border-style: solid;" type="image" /><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"><span style="font-size:14px;">[[fname]] [[lname]] - [[date]] @ [[time]]</span></span></p> <div> <div style="border: 0px solid rgb(255, 255, 255); padding: 5px 10px; margin-left: 70px; margin-top: -10px; background-image: initial; background-attachment: initial; background-color: rgb(255, 255, 255); background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> <p><span style="font-family: 'lucida sans unicode', 'lucida grande', sans-serif; font-size: 14px; color: rgb(102, 102, 102); line-height: 15px; background-color: rgb(255, 255, 255);"></span><span style="color: rgb(102, 102, 102); line-height: 15px; background-color: rgb(255, 255, 255);"><font face="arial, helvetica, sans-serif">[[msg]]</font></span></p> <p style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">&nbsp;</p> </div> </div> <hr style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; border:1px solid #f3f3f3"/> <p style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">&nbsp;</p> </td> </tr> <tr> <td height="20" style="line-height: 2px; font-size: 2px;"><img alt="" border="0" height="20" src="http://computergeeksrus.com/email/images/shadow620.gif" style="display: block;" width="100%" /></td> </tr> </tbody> </table> EOF; /* Get Ticket info*/ $q = "SELECT ".PRFX."TABLE_WORK_ORDER.*, ".PRFX."TABLE_CUSTOMER.* FROM ".PRFX."TABLE_WORK_ORDER LEFT JOIN ".PRFX."TABLE_CUSTOMER ON ".PRFX."TABLE_WORK_ORDER.CUSTOMER_ID = ".PRFX."TABLE_CUSTOMER.CUSTOMER_ID WHERE WORK_ORDER_ID=".$db->qstr($wo_id); if(!$rs = $db->execute($q)){ force_page('core', 'error&error_msg=MySQL Error: '.$db->ErrorMsg().'&menu=1&type=database'); exit; } else { $email_info = $rs->GetArray(); } $smarty->assign('email_info', $email_info); /* Get Company Email Address*/ $q = "SELECT COMPANY_EMAIL FROM ".PRFX."TABLE_COMPANY"; if(!$rs = $db->execute($q)) { force_page('core', 'error&error_msg=MySQL Error: '.$db->ErrorMsg().'&menu=1&type=database'); exit; } $company_email = $rs->fields['COMPANY_EMAIL']; $smarty->assign('company_email', $company_email); if($VAR['msg_type']!='new' && ($VAR['msg_type']=='reply' || $VAR['msg_type']=='forward')){ if(ctype_digit($VAR['msg_id'])){ $q = "SELECT MSG FROM ".PRFX."TABLE_WORK_ORDER_MESSAGE WHERE MSG_WORK_ORDER_ID='$wo_id' AND MSG_ID='".$VAR['msg_id']."' LIMIT 1"; } else { $q = "SELECT MSG FROM ".PRFX."TABLE_WORK_ORDER_MESSAGE WHERE MSG_WORK_ORDER_ID='$wo_id' ORDER BY MSG_ID DESC"; } if(!$rs = $db->execute($q)){ force_page('core', 'error&error_msg=Could not get Messages'); exit; } else { //$ticket_message= $rs->fields['MSG']; $ticket_message = $rs->GetArray(); } $all_messages=NULL; //loop messages foreach ($ticket_message as $m) { $this_msg=str_replace('[[msg]]', $m['MSG'], $eml_template); $this_msg=str_replace('[[employee_pic]]', get_employee_profile_pic($login_id), $this_msg); $this_msg=str_replace('[[date]]', strtotime($m['MSG_CREATED_ON']), $this_msg); $this_msg=str_replace('@ [[time]]', '', $this_msg); $all_messages.=$this_msg; } } elseif($VAR['msg_type']=='new'){ $all_messages=str_replace('[[msg]]', $VAR['ticket_msg'], $eml_template); $all_messages=str_replace('[[employee_pic]]', get_employee_profile_pic($login_id), $all_messages); $all_messages=str_replace('[[date]]', str_replace(" - ", " @ ", $rep_date), $all_messages); } if($VAR['msg_type']=='forward'){ $smarty->assign('message_content', "<br/><br/><br/><div style='text-align:center;color:#999;'>----FORWARDED EMAIL----</div><br/>".$all_messages); } /*Update Ticket message*/ if(isset($_POST['send_email'])) { //Remove Extra Slashes caused by Magic Quotes $msg = $VAR['ticket_msg']; $clean_msg = preg_replace("/<p[^>]*?>/", "", $msg); $clean_msg = str_replace("</p>", "<br />", $clean_msg); //$description_string2=("<br/><hr><u>Replied On $rep_date by $login </u><br/>$description_string"); $sql = "INSERT INTO ".PRFX."TABLE_WORK_ORDER_MESSAGE SET MSG_WORK_ORDER_ID =".$db->qstr($wo_id).", MSG_CUSTOMER_ID =".$db->qstr($customer_id).", MSG_SOURCE =". $db->qstr('System').", MSG =". $db->qstr($clean_msg).", MSG_EMPLOYEE_ID =". $db->qstr($login_id); if(!$result = $db->Execute($sql)) { force_page('core', 'error&error_msg=MySQL Error: '.$db->ErrorMsg().'&menu=1&type=database'); exit; } /*Get Full Description to send to Email*/ /*$sql = mysql_query("SELECT MSG FROM ".PRFX."TABLE_WORK_ORDER_MESSAGE WHERE MSG_WORK_ORDER_ID='$wo_id' ORDER BY MSG_ID DESC"); $sql=mysql_fetch_array($sql); //$ticket_message=$sql['MSG']; */ /*Send the email*/ $emailto=$VAR["email_to"]; $email_from="$company_email"; $email_subject=$VAR["email_subject"]; $html=$all_messages; $email_priority=$VAR["email_priority"]; $email_cc=$VAR["email_cc"]; $subject = "$email_subject"; $mailer = "$email_from"; $headers = "From: $mailer \r\n"; $headers .= "Reply-To: $mailer\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= "Importance: $email_priority\r\n"; $message = '<html><head> tyle type="text/css">body { margin:0; padding:0; background-color:#eeeeee; color:#999999; font-family:Arial, Helvetica, sans-serif; font-size:12px; -webkit-text-size-adjust: none; } h1, h2, h3, h4, h5, h6 { color:#39434d !important; margin-bottom:10px !important; } a, a:link, a:visited { color:#777777; text-decoration:none; border-bottom:1px #777777 dotted; } a:hover, a:active { text-decoration:none; color:#0f79aa !important; border-bottom:1px #0f79aa dotted !important; } p { line-height:15px; } img { border:0; } /*Hotmail and Yahoo specific code*/ .ReadMsgBody { width: 100%;} .ExternalClass {width: 100%;} .yshortcuts { color: #999999 } .yshortcuts a span { color: #777777 } </style> </head> <body style="background:#ffffff"> <table align="center" cellpadding="0" cellspacing="0" id="container" style="margin: 0px; padding: 0px; width: 100%; background-color: rgb(238, 238, 238);"><!-- Start of main container --> <tbody> <tr> <td style="padding: 0px 20px;"> '; $message .= $html; $message .= ' <tr> <td bgcolor="#ffffff" style="padding: 15px 20px; color: rgb(51, 51, 51); line-height: 15pt; font-family: Arial, Helvetica, sans-serif; font-size: 13px; border-top-color: rgb(235, 235, 235); border-top-width: 1px; border-top-style: solid;"> <p style="text-align: center;"><span style="color: rgb(169, 169, 169);"><span style="font-family: comic sans ms,cursive;">Thank you for choosing ComputerGeeksrus. Trust, Integrity and your best Interest first!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></p> </td> </tr> <!--Start of footer container--> <table align="center" cellpadding="0" cellspacing="0" style="margin: 0px auto; text-align: left; color: rgb(153, 153, 153); line-height: 15pt; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; border-collapse: collapse;" width="100%"> <tbody> <tr> </tr> <tr> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body></html>'; $headers .= "Cc: $email_cc \r\n"; /* mail($emailto, $subject, $message, $headers); */ $email = new PHPMailer(); $email->From = $email_from; $email->FromName = $mailer; $email->addReplyTo($email_from); $email->addCC($email_cc); $email->Subject = $subject; $email->Body = $message; $email->AddAddress( $emailto ); $email->isHTML(true); if($email_priority=="Medium") $email->Priority = 3; if($email_priority=="High") $email->Priority = 1; if($email_priority=="Low") $email->Priority = 5; $email->AddCustomHeader("X-MSMail-Priority: $email_priority"); $email->AddCustomHeader("Importance: $email_priority"); if(count($VAR['add_attachments'])>0){ $attachments_select="('".implode("', '", $VAR['add_attachments'])."')"; //select all attachments $q = "SELECT * FROM ".PRFX."TABLE_WORK_ORDER_ATTACHMENTS WHERE `WO_ID`=".$db->qstr($wo_id)." AND `ATTACHMENT_ID` IN $attachments_select ORDER BY `ATTACHMENT_ID` DESC"; if(!$rs = $db->execute($q)) { force_page('core', 'error&error_msg=MySQL Error: '.$db->ErrorMsg().'&menu=1&type=database'); exit; } $attachments = $rs->GetArray(); foreach($attachments as $a){ $file=$a['WO_ID']."_".$a['ATTACHMENT_NUMBER']."_".$a['ATTACHMENT_FILE']; $email->addAttachment(FILE_ROOT.'upload/message_store/'.$file, $file); } } if(!$email->send()) { force_page('core', 'error&error_msg=Mail error: '.$email->ErrorInfo.'&menu=1'); exit(); } else { force_page('workorder', 'view&wo_id='.$wo_id.'&customer_id='.$customer_id.'&company_id='.$company_id.'&page_title=Ticket# '.$wo_id.''); exit(); } } $add_attachments=NULL; foreach ($VAR['add_attachments'] as $a){ $add_attachments.="<input type='hidden' name='add_attachments[]' value='$a'/>"; } $smarty->assign('add_attachments', $add_attachments); $smarty->display('workorder'.SEP.'send_email.tpl'); ?>
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Use of undefined constant INCLUDE_URL - assumed 'INCLUDE_URL' in /in/DDjv0 on line 2 Notice: Use of undefined constant SEP - assumed 'SEP' in /in/DDjv0 on line 2 Warning: require(INCLUDE_URLSEPphpmailer/class.phpmailer.php): failed to open stream: No such file or directory in /in/DDjv0 on line 2 Fatal error: require(): Failed opening required 'INCLUDE_URLSEPphpmailer/class.phpmailer.php' (include_path='.:') in /in/DDjv0 on line 2
Process exited with code 255.
Output for hhvm-3.12.0
Notice: Use of undefined constant INCLUDE_URL - assumed 'INCLUDE_URL' in /in/DDjv0 on line 2 Notice: Use of undefined constant SEP - assumed 'SEP' in /in/DDjv0 on line 2 Fatal error: Uncaught Error: File not found: INCLUDE_URLSEPphpmailer/class.phpmailer.php in /in/DDjv0:2 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Notice: Use of undefined constant INCLUDE_URL - assumed 'INCLUDE_URL' in /in/DDjv0 on line 2 Notice: Use of undefined constant SEP - assumed 'SEP' in /in/DDjv0 on line 2 Fatal error: File not found: INCLUDE_URLSEPphpmailer/class.phpmailer.php in /in/DDjv0 on line 2
Process exited with code 255.