3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); ini_set('display_errors', 'On'); include ("../../conf.php"); error_reporting(-1); ini_set('display_errors', 'On'); $dblink = mysql_connect($DB_HOST, $DB_USER, $DB_PASS); if(!$dblink) { } mysql_select_db($dbname); function clean($str){ return mysql_real_escape_string($str); } function extract_numbers($string){ preg_match_all('/([\d]+)/', $string, $match); return $match[0]; } /* Get settings from the Database*/ $sql = mysql_query("SELECT * FROM ".PRFX."EMAIL_CONNECTOR_SETTINGS"); $sql=mysql_fetch_array($sql); $eml_server=$sql['EMAIL_SERVER']; $eml_server_port=$sql['EMAIL_SERVER_PORT']; $eml_con_type=$sql['CONNECTION_TYPE']; $eml_account=$sql['EMAIL_ACCOUNT']; $eml_account_uname=$sql['EMAIL_ACCOUNT_USERNAME']; $eml_account_pword=$sql['EMAIL_ACCOUNT_PASSWORD']; $eml_service_control=$sql['SERVICE_CONTROL']; $eml_en_flood_control=$sql['ENABLE_EMAIL_FLOOD_CONTROL']; $eml_flood_control=$sql['EMAIL_FLOOD_CONTROL']; $eml_from=$sql['FETCH_EMAIL_FROM']; /* Assign mailbox credentials */ $hostname = "{{$eml_server}:$eml_server_port/$eml_con_type}$eml_from"; $username = "$eml_account_uname"; $password = "$eml_account_pword"; if($eml_service_control =="1"){ /* try to connect to the mailbox*/ $inbox = $connection = imap_open($hostname,$username,$password) or die('Cannot connect: ' . imap_last_error()); } elseif($eml_service_control =="0") { echo 'Email to Tickets Service has been disabled by the system Administrator'; } /* If all goes well then let us grab the emails */ $emails = imap_search($inbox,'UNSEEN'); /* if emails are returned, cycle through each... */ if($emails) { /* begin output var */ $output = ''; /* put the newest emails on top */ rsort($emails); /* Process Each email Seperately */ foreach($emails as $email_number){ /*Set Flood Control if($eml_en_flood_control==1 && $fetch_eml==$eml_flood_control){ die(); }elseif($eml_en_flood_control==0 && $fetch_eml=="15"){die();}*/ $overview = imap_fetch_overview($inbox,$email_number,0); $message = imap_fetchbody($inbox,$email_number,2); $seen=$overview[0]->seen; $rep_date= date('D, d M Y - h:i A', strtotime($overview[0]->date)); $date=$overview[0]->date; $date2=$overview[0]->udate; $from_email=imap_rfc822_parse_adrlist($overview[0]->from, 'localhost');$from_email=$from_email[0]; $from_email=clean($from_email->mailbox."@".$from_email->host); $subject=clean($overview[0]->subject); $eml_subject=$overview[0]->subject; preg_match("/Ticket#([0-9]+)/", $eml_subject, $res); $wo_id=extract_numbers($overview[0]->subject); $wo_id=$wo_id[0]; $wo_id=clean($res[1]); if(!$wo_id){ $wo_id="";} libxml_use_internal_errors(true); require_once 'JSLikeHTMLElement.php'; $doc = new DOMDocument(); $doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement'); $doc->loadHTML($message); //$elem = $doc->getElementById('closed_bus_wo')->item(0); $elem = $doc->getElementsByTagName('section')->item(0); $elem->innerHTML = '<!-- template replaced -->'; $message= $doc->saveXML(); $message=strip_tags($message, "<br><p><u><span><hr>"); $message=preg_replace("/(<br\ ?\/?>)+/", "<br/>", $message); $message=preg_replace( "/\s+/", " ", $message ); $message=nl2br($message); $message=clean("<br/><hr><u>Received On $rep_date / $from_email</u><br/>$message"); $message = str_replace('=', '', $message); /* Check if customer exists and get the ID*/ $q=mysql_query("SELECT * FROM `".PRFX."TABLE_CUSTOMER` WHERE CUSTOMER_EMAIL='$from_email'"); if(mysql_num_rows($q)==1){ $customer_id=mysql_fetch_array($q); $customer_id=$customer_id['CUSTOMER_ID']; } else { $customer_id=""; } /* Check for Blacklist Emails*/ $p=mysql_query("SELECT * FROM ".PRFX."EMAIL_CONTROL WHERE BLACKLIST_EMAIL='$from_email'"); $blacklist=mysql_num_rows($p); /* Assign the customer ID to the Work order*/ $r=mysql_query("SELECT * FROM ".PRFX."TABLE_WORK_ORDER WHERE WORK_ORDER_ID='$wo_id'") or die(mysql_error()); $n=mysql_num_rows($r); $r=mysql_fetch_array($r); $wo_status=$r['WORK_ORDER_CURRENT_STATUS']; $date2=date("H:i:s", $date2); $priority="1"; /*Insert work order if a customer is found*/ if($customer_id!=0 && $n==0 && $blacklist==""){ mysql_query("INSERT INTO `".PRFX."TABLE_WORK_ORDER` (WORK_ORDER_SCOPE, WORK_ORDER_DESCRIPTION, PRIORITY_ID, CREATED_TIME, WORK_ORDER_OPEN_DATE, WORK_ORDER_CURRENT_STATUS, CUSTOMER_ID) VALUES ('$subject', '$message','$priority', '$date2', '$date', '0', '$customer_id')"); /*Insert work order if no customer is found*/ } elseif($customer_id==0 && $n==0 && $blacklist=="") { mysql_query("INSERT INTO `".PRFX."TABLE_WORK_ORDER` (WORK_ORDER_SCOPE, WORK_ORDER_DESCRIPTION, PRIORITY_ID, CREATED_TIME, WORK_ORDER_OPEN_DATE, WORK_ORDER_CURRENT_STATUS, TEMP_EMAIL_ADDRESS, TEMP_EMAIL_NAME) VALUES ('$subject', '$message','$priority', '$date2', '$date', '0', '$from_email', '$from_email')"); } $new_wo_id = $db->Insert_ID(); /*IF Work order is found and not closed then, update it's description'*/ if($n==1 && $wo_status!=6) { mysql_query("UPDATE ".PRFX."TABLE_WORK_ORDER SET WORK_ORDER_DESCRIPTION = CONCAT('$message',WORK_ORDER_DESCRIPTION) WHERE WORK_ORDER_ID='$wo_id'"); /*Update and Chaange Closed Work Orders Status to Reopen*/ } elseif($n==1 && $wo_status==6) { mysql_query("UPDATE ".PRFX."TABLE_WORK_ORDER SET WORK_ORDER_DESCRIPTION = CONCAT('$message',WORK_ORDER_DESCRIPTION), WORK_ORDER_CURRENT_STATUS =11 WHERE WORK_ORDER_ID='$wo_id'") or die(mysql_error()); } if($n==1){ $existing=true; } /*Get Attachments*/ $message_number=$email_number; $structure = imap_fetchstructure($inbox, $email_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']); } } } } foreach($attachments as $a){ if($a['is_attachment']==1){ $filename=$a['filename']; $raw_data=$a['attachment']; if($existing) { $woid=$wo_id; } else { $woid=$new_wo_id; } // Get Recent Attachment number $q = mysql_query("SELECT * FROM `".PRFX."TABLE_WORK_ORDER_ATTACHMENTS` WHERE WO_ID='".$woid."' ORDER BY ATTACHMENT_ID DESC") or print(mysql_error()); $rs=mysql_fetch_array($q); $a_n=$rs['ATTACHMENT_NUMBER']; if($a_n!=0){ $recent_attachment = $rs['ATTACHMENT_NUMBER']+1; } else { $recent_attachment=1; } //This is the directory where Files will be saved $target = "../../upload/message_store/".$woid."_".$recent_attachment."_"; $target = $target . basename( $filename ); //This gets all the other information from the form $date=date('Y-m-d'); $file=basename($filename); //Writes the information to the database mysql_query("INSERT INTO `".PRFX."TABLE_WORK_ORDER_ATTACHMENTS` VALUES ('$id', '$recent_attachment', '$date', '$woid', '$file' , '$file' , '$login_id')") ; //Writes the File to the server if(file_put_contents($target, $raw_data)) { //Tells you if its all ok echo "The file ". basename( $filename ). " has been uploaded to $target, and information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem saving file."; } } } /*Flag the email as Read to prevent reinsert*/ $status = imap_setflag_full($inbox, $email_number, "\\Seen \\Flagged", ST_UID); /*Delete the email from the inbox*/ imap_delete($inbox, $email_number); $fetch_eml++; } echo $output; } else { echo "<!-- debug -->"; } /* close the connection */ imap_close($inbox); ?>
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: include(): open_basedir restriction in effect. File(../../conf.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/rBOA5 on line 4 Warning: include(../../conf.php): Failed to open stream: Operation not permitted in /in/rBOA5 on line 4 Warning: include(): Failed opening '../../conf.php' for inclusion (include_path='.:') in /in/rBOA5 on line 4 Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/rBOA5:7 Stack trace: #0 {main} thrown in /in/rBOA5 on line 7
Process exited with code 255.
Output for 8.0.13
Warning: include(../../conf.php): Failed to open stream: No such file or directory in /in/rBOA5 on line 4 Warning: include(): Failed opening '../../conf.php' for inclusion (include_path='.:') in /in/rBOA5 on line 4 Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/rBOA5:7 Stack trace: #0 {main} thrown in /in/rBOA5 on line 7
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.2.0, 7.3.32 - 7.3.33, 7.4.33
Warning: include(../../conf.php): failed to open stream: No such file or directory in /in/rBOA5 on line 4 Warning: include(): Failed opening '../../conf.php' for inclusion (include_path='.:') in /in/rBOA5 on line 4 Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/rBOA5:7 Stack trace: #0 {main} thrown in /in/rBOA5 on line 7
Process exited with code 255.
Output for 7.2.29 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.32
Warning: include(): open_basedir restriction in effect. File(../../conf.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/rBOA5 on line 4 Warning: include(../../conf.php): failed to open stream: Operation not permitted in /in/rBOA5 on line 4 Warning: include(): Failed opening '../../conf.php' for inclusion (include_path='.:') in /in/rBOA5 on line 4 Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/rBOA5:7 Stack trace: #0 {main} thrown in /in/rBOA5 on line 7
Process exited with code 255.
Output for 7.1.20, 7.2.6
Warning: include(): open_basedir restriction in effect. File(../../conf.php) is not within the allowed path(s): (/tmp:/in) in /in/rBOA5 on line 4 Warning: include(../../conf.php): failed to open stream: Operation not permitted in /in/rBOA5 on line 4 Warning: include(): Failed opening '../../conf.php' for inclusion (include_path='.:') in /in/rBOA5 on line 4 Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/rBOA5:7 Stack trace: #0 {main} thrown in /in/rBOA5 on line 7
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.25
Warning: include(../../conf.php): failed to open stream: No such file or directory in /in/rBOA5 on line 4 Warning: include(): Failed opening '../../conf.php' for inclusion (include_path='.:') in /in/rBOA5 on line 4 Fatal error: Call to undefined function mysql_connect() in /in/rBOA5 on line 7
Process exited with code 255.

preferences:
188.85 ms | 402 KiB | 301 Q