Exemple #1
0
/**
 * Send response emails to the appropriate recipients.
 *
 * Sends an email to the scripts owner as well as the end-user
 * if appropriate.  If the sending of mail fails, an error
 * message will be printed out to the screen.
 * 
 * @param string $owner_email_response the message to mail to the owner.
 * @param string $user_email_response the message to mail to the user.
 * @param array $preferences the CoffeeCup Flash Form Builder Preferences.
 */
function sendResponseEmails($owner_email_response, $user_email_response, $preferences)
{
    // If the program is unregistered, add the unregistered message.
    if ($_POST['unreg']) {
        $unreg = "------------------------\n" . "This Form was sent to you using CoffeeCup Form Builder." . "\nPlease tell a friend about us: " . "http://www.coffeecup.com/form-builder/";
    }
    // Set up the CC field if necessary
    if (CC_FB_CC_EMAIL != '') {
        $cc = 'Cc: ' . CC_FB_CC_EMAIL . CC_FB_SENDMAIL_EOL;
    }
    // Set up the BCC field if necessary
    if (CC_FB_BCC_EMAIL != '') {
        $bcc = 'Bcc: ' . CC_FB_BCC_EMAIL . CC_FB_SENDMAIL_EOL;
    }
    // Use the alternative email if one is provided
    $mail_to = $_POST['_ALT_EMAIL'] != '' ? $_POST['_ALT_EMAIL'] : CC_FB_TO_EMAIL;
    // Set a default subject if one is not provided
    $subject = $_POST['subject'] != '' ? parseMessage($_POST['subject'], $preferences) : 'Form Submission';
    // Set up the default mail headers
    $headers = 'MIME-Version: 1.0' . CC_FB_SENDMAIL_EOL . 'Content-Type: text/plain; charset=utf-8' . CC_FB_SENDMAIL_EOL . 'Content-Transfer-Encoding: 7bit' . CC_FB_SENDMAIL_EOL;
    // Set up the default owner message if on is not provided
    if (CC_FB_OWNER_MESSAGE == '[FORMOWNERMSG]') {
        $form_owner_msg = 'Here is the information submitted to ' . "{$_SERVER['SERVER_NAME']}{$_SERVER['PHP_SELF']} from " . "{$_SERVER['REMOTE_ADDR']} on " . date("l, F dS, Y \\a\\t g:i a") . ".\n------------------------\n{$owner_email_response}{$unreg}";
    } else {
        $form_owner_msg = parseMessage(CC_FB_OWNER_MESSAGE, $preferences);
    }
    // Add the uploaded file as an attachment if the user has
    // request we do so
    if (CC_FB_ATTACHMENT_ADDTOEMAIL && $_POST['Uploaded_File'] != '') {
        if (!($contents = file_get_contents(CC_FB_UPLOADS_DIRECTORY . "/{$_POST['Uploaded_File']}"))) {
            printMessage('Unable To Open Attachment File', "We're sorry but " . 'we were unable to open your uploaded file to attatch it for ' . 'email. Please be sure that you have the proper permissions.');
        }
        $attachment = chunk_split(base64_encode($contents));
        // Setup the unique mime boundary
        $mime_boundary = md5(time());
        // Set up the form owner mail headers
        $form_owner_headers = 'MIME-Version: 1.0' . CC_FB_SENDMAIL_EOL . 'Content-Type: multipart/mixed; ' . "boundary=\"{$mime_boundary}\"" . CC_FB_SENDMAIL_EOL;
        // Set up the new form owner message
        $form_owner_msg = CC_FB_SENDMAIL_EOL . "--{$mime_boundary}" . CC_FB_SENDMAIL_EOL . 'Content-Type: text/plain; charset=utf-8' . CC_FB_SENDMAIL_EOL . 'Content-Transfer-Encoding: 7bit' . CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL . $form_owner_msg . CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL . "--{$mime_boundary}" . CC_FB_SENDMAIL_EOL . 'Content-Type: application/octet-stream ' . "name=\"{$_POST['Uploaded_File']}\"" . CC_FB_SENDMAIL_EOL . "Content-Transfer-Encoding: base64" . CC_FB_SENDMAIL_EOL . "Content-Description: {$_POST['Uploaded_File']}" . CC_FB_SENDMAIL_EOL . "Content-Disposition: attachment; " . "filename=\"{$_POST['Uploaded_File']}\"" . CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL . "{$attachment}" . CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL;
        "--{$mime_boundary}--" . CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL;
    } else {
        $form_owner_headers = $headers;
    }
    // If we collected the end-user's email
    if ($_POST['eM']) {
        // Get all the headers without the From: portion
        // so that we can do something fancy if the first
        // attempt to send the message fails
        $headers_without_from = "Reply-To: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL . "Return-Path: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL . "{$cc}{$bcc}" . 'Message-ID: <' . time() . "-{$_POST['eM']}>" . CC_FB_SENDMAIL_EOL . 'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL . $form_owner_headers;
        // Send a message to the form's owner with the end-user's email
        // as the reply-to address.
        if (CC_FB_DO_EMAIL && !mail($mail_to, $subject, $form_owner_msg, "From: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL . $headers_without_from) && !mail($mail_to, $subject, $form_owner_msg, 'From: CoffeeCup Flash Form Builder ' . "<formbuilder@{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL . $headers_without_from)) {
            printMessage('Unable To Send E-Mail', "We're sorry but we were unable to send your e-mail. " . 'If you are sure that you entered all your email ' . 'addresses properly, you should contact your server ' . 'administrator.');
        }
        // If necesarry, send a message to the end-user as well.
        if (CC_FB_AUTO_REPLY) {
            $form_user_msg = parseMessage('', $preferences);
            $form_user_subject = parseMessage(CC_FB_AUTO_REPLY_SUBJECT, $preferences);
            if (CC_FB_AUTO_REPLY_FORM_RESULTS) {
                $form_user_msg = CC_FB_AUTO_REPLY_POSITION == 'top' ? "{$form_user_msg}\n\n{$user_email_response}" : "{$user_email_response}\n\n{$form_user_msg}";
            }
            // Get all the headers without the From: portion
            // so that we can do something fancy if the first
            // attempt to send the message fails
            $headers_without_from = "Reply-To: {$mail_to}" . CC_FB_SENDMAIL_EOL . "Return-Path: {$mail_to}" . CC_FB_SENDMAIL_EOL . 'Message-ID: <' . time() . "-{$mail_to}>" . CC_FB_SENDMAIL_EOL . 'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL . $headers;
            mail($_POST['eM'], $form_user_subject, "{$form_user_msg}{$unreg}", "From: {$mail_to}" . CC_FB_SENDMAIL_EOL . $headers_without_from) || mail($_POST['eM'], $form_user_subject, "{$form_user_msg}{$unreg}", "From: {$_SERVER['SERVER_NAME']} Form " . "<forms@{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL . $headers_without_from);
        }
    } elseif (CC_FB_DO_EMAIL && !mail($mail_to, $subject, $form_owner_msg, 'From: CoffeeCup Flash Form Builder ' . "<formbuilder@{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL . "{$cc}{$bcc}" . 'Message-ID: <' . time() . "-formbuilder@{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL . 'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL . $form_owner_headers)) {
        printMessage('Unable To Send E-Mail', "We're sorry but we were unable to send your e-mail. " . 'If you are sure that you entered all your email ' . 'addresses properly, you should contact your server ' . 'administrator.');
    }
}
/**
 * FUNCTION TO SEND THE EMAIL
 * ==================================================================
 *
 */
function sendEmailToSiteOwner()
{
    global $files, $options, $mail, $fdata, $translations, $lang, $is_ajax;
    // if we're using SMTP
    if ($options['use_smtp']) {
        $mail->isSMTP();
        $mail->Host = $options['smtp_host'];
        $mail->SMTPAuth = $options['smtp_auth'];
        $mail->Username = $options['smtp_username'];
        $mail->Password = $options['smtp_password'];
        $mail->SMTPSecure = $options['smtp_secure'];
        $mail->Port = $options['smtp_port'];
    }
    // character encoding
    $mail->CharSet = 'UTF-8';
    // mail format
    $mail->isHTML = true;
    // from
    $mail->From = $options['from_address'];
    $mail->FromName = $options['from_name'];
    // to
    foreach ($options['to_addresses'] as $address) {
        $mail->addAddress($address);
    }
    // bcc
    foreach ($options['bcc_addresses'] as $address) {
        $mail->addBCC($address);
    }
    // reply to
    $mail->addReplyTo($fdata['email']);
    // add files to the email
    if ($files['name'][0] !== '') {
        for ($i = 0; $i < count($files['name']); $i++) {
            // define file path
            $path = __DIR__ . '/' . $options['attachment_dir'] . $files['name'][$i];
            // add the attachment to the mail
            $mail->addAttachment($path);
        }
    }
    // set subject
    $mail->Subject = parseMessage($translations->email->subject->{$lang}, array($fdata['name'], $fdata['subject']));
    // set content
    $mail->Body = getHtmlEmailContent();
    $mail->AltBody = getPlainEmailContent();
    // successfully sent email
    if ($mail->send()) {
        emailSuccessfullySent();
    } else {
        if ($is_ajax) {
            echo json_encode(array('errors' => array(parseMessage($translations->email->error->{$lang}, array($mail->ErrorInfo)))));
        } else {
            echo parseMessage($translations->email->error->{$lang}, $mail->ErrorInfo);
        }
    }
    // remove uploaded files from the server
    removeUploadsFromServer();
}
             $apos = chr(92) . chr(92) . chr(92);
         } else {
             $apos = chr(92) . chr(92);
         }
         $posterNameJs = str_replace('&#039;', $apos . '&#039;', $cols[1]);
     }
     $posterNameJs = str_replace(' ', '%20', $posterNameJs);
     if (!isset($preModerationType) or $preModerationType == 0) {
         $posterText = $cols[3];
     } elseif ($preModerationType > 0 and isset($premodPosts) and in_array($cols[6], $premodPosts)) {
         $posterText = $l_postQueued;
     } else {
         $posterText = $cols[3];
     }
     if (function_exists('parseMessage')) {
         parseMessage();
     }
     $listPosts .= ParseTpl($tpl);
     $i = -$i;
     if ($ii == 0) {
         $ii++;
         $description = trim(substr(strip_tags(str_replace(array("\r\n", "\r", '<br />', '&amp;', '&quot;', '&#039;', "\n", '"'), ' ', $cols[3])), 0, 400));
     }
     $anchor++;
     $anchor2++;
 } while ($cols = db_simpleSelect(1));
 unset($result);
 unset($countRes);
 //
 if ($logged_admin == 1 or $isMod == 1 or isset($userDeleteMsgs) and $userDeleteMsgs == 2 and $user_id != 0 and $user_id == $topicPoster and ($useredit == 0 or time() - strtotime($topicTime) < $useredit) and $topicStatus == 0) {
     $deleteTopic = "{$l_sepr} <a href=\"JavaScript:confirmDelete({$topic},1)\" onmouseover=\"window.status='{$l_deleteTopic}'; return true;\" onmouseout=\"window.status=''; return true;\">{$l_deleteTopic}</a>";
    echo file_get_contents($cachefile);
    exit;
}
ob_start();
$url = 'http://www.metrovias.com.ar/V2/InfoSubteSplash.asp';
$data = file_get_contents_utf8($url);
//pausecontent[\d+]\s=\s(.*);
// pausecontent[0] = '&nbsp;&nbsp;<b>L?nea A:</b>&nbsp; Servicio normal.';pausecontent[1] =
$results = preg_match_all('/pausecontent\\[[\\d+]\\]\\s=\\s\'([^\']+)\';/', $data, $matches);
$json = array();
foreach ($matches[1] as $line) {
    // echo $line . "\n";
    // $line = str_replace(array('&nbsp;', 'á', 'é', 'í', 'ó', 'ú'), array(' ', '&aacute;', '&eacute;', '&iacute;', '&oacute;', '&uacute;'), $line);
    $line = str_replace(array('&nbsp;'), array(' '), $line);
    // echo $line;
    // $line = str_replace(array('&nbsp;'), array(' '), $line);
    $line = strip_tags(html_entity_decode($line, ENT_QUOTES, 'UTF-8'));
    // preg_match('/nea\s([A-Z]{1}):.*(\s)([A-Za-z]+)\.?$/', $line, $data);
    preg_match('/nea\\s([A-Z]{1}):\\s\\s?(.*)/', $line, $data);
    // echo $line . "\n";
    $json[$data[1]] = array('status' => parseMessage($data[2]), 'message' => htmlentities($data[2], ENT_QUOTES, 'UTF-8'));
    // var_dump($data);
}
echo json_encode($json);
file_put_contents($cachefile, ob_get_contents());
// or var_dump(error_get_last());
ob_end_flush();
if (@$_GET['callback']) {
    echo ');';
}
// echo $data;;