public function send($to, $subject, $message, $from = NULL, $attachments = NULL)
 {
     if ($attachments != NULL) {
         throw new ServiceException("INVALID_CONFIGURATION", "Default mailer does not support sending attachments");
     }
     if (Logging::isDebug()) {
         Logging::logDebug("Sending mail to [" . Util::array2str($to) . "]: [" . $message . "]");
     }
     if (!$this->enabled) {
         return;
     }
     $isHtml = stripos($message, "<html>") !== FALSE;
     $f = $from != NULL ? $from : $this->env->settings()->setting("mail_notification_from");
     $validRecipients = $this->getValidRecipients($to);
     if (count($validRecipients) === 0) {
         Logging::logDebug("No valid recipient email addresses, no mail sent");
         return;
     }
     $toAddress = '';
     $headers = $isHtml ? 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=utf-8' . "\r\n" : 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n";
     $headers .= 'From:' . $f;
     if (count($validRecipients) == 1) {
         $toAddress = $this->getRecipientString($validRecipients[0]);
     } else {
         $headers .= PHP_EOL . $this->getBccHeaders($validRecipients);
     }
     mail($toAddress, $subject, $isHtml ? $message : str_replace("\n", "\r\n", wordwrap($message)), $headers);
 }
 function send_notification_email($to_email, $subject, $message, $reply_to = '', $reply_to_name = '', $plain_text = true, $attachments = array())
 {
     $content_type = $plain_text ? 'text/plain' : 'text/html';
     $reply_to_name = $reply_to_name == '' ? wp_specialchars_decode(get_option('blogname'), ENT_QUOTES) : $reply_to_name;
     //senders name
     $reply_to = ($reply_to == '' or $reply_to == '[admin_email]') ? get_option('admin_email') : $reply_to;
     //senders e-mail address
     if ($to_email == '[admin_email]') {
         $to_email = get_option('admin_email');
     }
     $recipient = $to_email;
     //recipient
     $header = "From: \"{$reply_to_name}\" <{$reply_to}>\r\n Reply-To: \"{$reply_to_name}\" <{$reply_to}>\r\n Content-Type: {$content_type}; charset=\"" . get_option('blog_charset') . "\"\r\n";
     //optional headerfields
     $subject = wp_specialchars_decode(strip_tags(stripslashes($subject)), ENT_QUOTES);
     $message = do_shortcode($message);
     $message = wordwrap(stripslashes($message), 70, "\r\n");
     //in case any lines are longer than 70 chars
     if ($plain_text) {
         $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES);
     }
     $header = apply_filters('frm_email_header', $header, compact('to_email', 'subject'));
     if (!wp_mail($recipient, $subject, $message, $header, $attachments)) {
         $header = "From: \"{$reply_to_name}\" <{$reply_to}>\r\n";
         mail($recipient, $subject, $message, $header);
     }
     do_action('frm_notification', $recipient, $subject, $message);
 }
Exemple #3
0
 public static function write($image, $fontfile, $x, $y, $text, $color, $maxwidth, $size = 11, $spacingx = 2, $spacingy = 2, $mx = 1, $my = 1, $angle = 0)
 {
     if (!Common::isFile($fontfile)) {
         echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array(htmlspecialchars($fontfile)));
         return false;
     }
     $dim = GWF_GDText::getFontSize($fontfile, $size, $angle);
     $fontwidth = $dim->w;
     $fontheight = $dim->h;
     if ($maxwidth != NULL) {
         // 			die(''.$maxwidth);
         $maxcharsperline = floor($maxwidth / $fontwidth);
         $text = wordwrap($text, $maxcharsperline, "\n", 1);
         // 			die($text);
     }
     // 		die(var_dump($color));
     $lines = explode("\n", $text);
     $x += $mx;
     $y += $my;
     foreach ($lines as $line) {
         $y += $fontheight + $spacingy;
         imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $line);
     }
     return true;
 }
Exemple #4
0
function printevent($record, $prettydate)
{
    print "\n" . strtoupper($record["title"]) . "\n";
    $again = repeatfirstinstance($record, $prettydate);
    if ($again) {
        print "See {$again[date]} for details\n";
    } else {
        print hmmpm($record["eventtime"]) . "\n";
        if ($record["locname"]) {
            print "{$record[locname]}, {$record[address]}\n";
        } else {
            print "{$record[address]}\n";
        }
        print wordwrap($record["printdescr"], 68) . "\n";
        if (!$record["hideemail"]) {
            $email = preg_replace("/@/", " at ", $record["email"]);
            $email = preg_replace("/\\./", " dot ", $email);
            if ($record["weburl"] != "") {
                print "{$email}, {$record[weburl]}\n";
            } else {
                print "{$email}\n";
            }
        } else {
            if ($record["weburl"] != "") {
                print "{$record[weburl]}\n";
            }
        }
    }
}
Exemple #5
0
 /**
  * Formats a message as a block of text.
  *
  * @param string|array $messages The message to write in the block
  * @param string|null $type The block type (added in [] on first line)
  * @param string|null $style The style to apply to the whole block
  * @param string $prefix The prefix for the block
  * @param bool $padding Whether to add vertical padding
  */
 public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
 {
     $this->autoPrependBlock();
     $messages = is_array($messages) ? array_values($messages) : array($messages);
     $lines = array();
     // add type
     if (null !== $type) {
         $messages[0] = sprintf('[%s] %s', $type, $messages[0]);
     }
     // wrap and add newlines for each element
     foreach ($messages as $key => $message) {
         $message = OutputFormatter::escape($message);
         $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - Helper::strlen($prefix), PHP_EOL, true)));
         if (count($messages) > 1 && $key < count($messages) - 1) {
             $lines[] = '';
         }
     }
     if ($padding && $this->isDecorated()) {
         array_unshift($lines, '');
         $lines[] = '';
     }
     foreach ($lines as &$line) {
         $line = sprintf('%s%s', $prefix, $line);
         $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
         if ($style) {
             $line = sprintf('<%s>%s</>', $style, $line);
         }
     }
     $this->writeln($lines);
     $this->newLine();
 }
Exemple #6
0
 /**
  * Returns syntax highlighted SQL command.
  * @param  string
  * @return string
  */
 public static function dumpSql($sql)
 {
     static $keywords1 = 'SELECT|(?:ON\\s+DUPLICATE\\s+KEY)?UPDATE|INSERT(?:\\s+INTO)?|REPLACE(?:\\s+INTO)?|DELETE|CALL|UNION|FROM|WHERE|HAVING|GROUP\\s+BY|ORDER\\s+BY|LIMIT|OFFSET|SET|VALUES|LEFT\\s+JOIN|INNER\\s+JOIN|TRUNCATE';
     static $keywords2 = 'ALL|DISTINCT|DISTINCTROW|IGNORE|AS|USING|ON|AND|OR|IN|IS|NOT|NULL|LIKE|RLIKE|REGEXP|TRUE|FALSE';
     // insert new lines
     $sql = " {$sql} ";
     $sql = preg_replace("#(?<=[\\s,(])({$keywords1})(?=[\\s,)])#i", "\n\$1", $sql);
     // reduce spaces
     $sql = preg_replace('#[ \\t]{2,}#', " ", $sql);
     $sql = wordwrap($sql, 100);
     $sql = preg_replace("#([ \t]*\r?\n){2,}#", "\n", $sql);
     // syntax highlight
     $sql = htmlSpecialChars($sql);
     $sql = preg_replace_callback("#(/\\*.+?\\*/)|(\\*\\*.+?\\*\\*)|(?<=[\\s,(])({$keywords1})(?=[\\s,)])|(?<=[\\s,(=])({$keywords2})(?=[\\s,)=])#is", function ($matches) {
         if (!empty($matches[1])) {
             // comment
             return '<em style="color:gray">' . $matches[1] . '</em>';
         }
         if (!empty($matches[2])) {
             // error
             return '<strong style="color:red">' . $matches[2] . '</strong>';
         }
         if (!empty($matches[3])) {
             // most important keywords
             return '<strong style="color:blue">' . $matches[3] . '</strong>';
         }
         if (!empty($matches[4])) {
             // other keywords
             return '<strong style="color:green">' . $matches[4] . '</strong>';
         }
     }, $sql);
     return '<pre class="dump">' . trim($sql) . "</pre>\n";
 }
 /**
  *  Create a cache file from the given list of files and return the cache file name
  *  @name   combine
  *  @type   method
  *  @access public
  *  @param  array file list
  *  @return string cache file name
  */
 public function combine($fileList)
 {
     if (count($fileList) > 0) {
         $cacheFile = '';
         $alphabet = array_map('chr', array_merge(range(48, 57), range(97, 122), range(65, 90)));
         //  a lot is going on on this line; first we take the md5 checksums of the files in the list, then this goes into a json blob, which is m5'd on its own and then wordwrapped at every 3rd character and lastly, the result gets exploded on the wordwrap added newlines. Leaving us with a 11 item array.
         $checksum = explode(PHP_EOL, wordwrap(md5(json_encode(array_map('md5_file', $fileList))), 3, PHP_EOL, true));
         while (count($checksum)) {
             $cacheFile .= $alphabet[hexdec(array_shift($checksum)) % count($alphabet)];
         }
         $cacheFile = $this->_cachePath . '/' . $cacheFile . '.' . pathinfo($fileList[0], PATHINFO_EXTENSION);
         //  if the cache file exists, we gently push the modification time to now (this should make removing old obselete files easier to find)
         if (realpath($cacheFile) && touch($cacheFile)) {
             return basename($cacheFile);
         }
         //  as no cache file was found (or we couldn't push the modification time), we need to generate it
         $fp = fopen($cacheFile, 'w+');
         if ($fp) {
             foreach ($fileList as $file) {
                 $source = trim(file_get_contents($file)) . PHP_EOL;
                 if (substr($file, 0, strlen($this->_cachePath)) == $this->_cachePath) {
                     $source = '/*' . basename($file) . '*/' . $source;
                 }
                 fputs($fp, $source);
             }
             return basename($cacheFile);
         }
     }
     return false;
 }
Exemple #8
0
 /**
  * splits item into new lines if necessary
  * @param string $item
  * @return CalendarStream
  */
 public function addItem($item)
 {
     $line_breaks = array("\r\n", "\n", "\r");
     $item = str_replace($line_breaks, '\\n', $item);
     $this->stream .= wordwrap($item, 70, Constants::CRLF . ' ', true) . Constants::CRLF;
     return $this;
 }
Exemple #9
0
 public function sendNewPassword($email, $newPassword)
 {
     $msg = "Here is your new password " . $newPassword . " Have fun!!!";
     $msg = wordwrap($msg, 70);
     #send mail
     mail($email, "Your new password", $msg, 'From: ' . WEBMASTER_EMAIL);
 }
Exemple #10
0
function lbf_report($pid, $encounter, $cols, $id, $formname)
{
    require_once $GLOBALS["srcdir"] . "/options.inc.php";
    $arr = array();
    $shrow = getHistoryData($pid);
    $fres = sqlStatement("SELECT * FROM layout_options " . "WHERE form_id = ? AND uor > 0 " . "ORDER BY group_name, seq", array($formname));
    while ($frow = sqlFetchArray($fres)) {
        $field_id = $frow['field_id'];
        $currvalue = '';
        if ($frow['edit_options'] == 'H') {
            if (isset($shrow[$field_id])) {
                $currvalue = $shrow[$field_id];
            }
        } else {
            $currvalue = lbf_current_value($frow, $id, $encounter);
            if ($currvalue === FALSE) {
                continue;
            }
            // should not happen
        }
        // For brevity, skip fields without a value.
        if ($currvalue === '') {
            continue;
        }
        // $arr[$field_id] = $currvalue;
        // A previous change did this instead of the above, not sure if desirable? -- Rod
        $arr[$field_id] = wordwrap($currvalue, 30, "\n", true);
    }
    echo "<table>\n";
    display_layout_rows($formname, $arr);
    echo "</table>\n";
}
 public function feedbackAction()
 {
     $this->view->disable();
     if ($this->request->isPost()) {
         $name = $this->request->getPost('name');
         $email = $this->request->getPost('email');
         $comment = $this->request->getPost('comment');
         if (empty($name)) {
             return;
         }
         if (empty($email)) {
             return;
         }
         if (empty($comment)) {
             return;
         }
         $headers = 'From: noreply@kladr-api.ru' . "\n" . 'Reply-To: ' . $email . "\n" . 'Content-Type: text/html; charset="utf-8"';
         $subject = 'Новое сообщение в форме обратной связи';
         $subject = '=?utf-8?B?' . base64_encode($subject) . '?=';
         $message = 'Новое сообщение в форме обратной связи от ' . $name . '(' . $email . '):' . "<br/><br/>" . $comment;
         $message = wordwrap($message, 70);
         mail('*****@*****.**', $subject, $message, $headers);
         print 'y';
     }
 }
Exemple #12
0
 /**
  * modify the value
  *
  * @access	public
  * @param	string		value
  * @return	string		modified value
  */
 function modify($value, $params = array())
 {
     /**
      * width
      */
     if (!isset($params['width'])) {
         $params['width'] = 72;
     }
     settype($params['width'], 'integer');
     /**
      * character used for linebreaks
      */
     if (!isset($params['break'])) {
         $params['break'] = "\n";
     }
     /**
      * cut at the specified width
      */
     if (!isset($params['cut'])) {
         $params['cut'] = 'no';
     }
     $params['cut'] = $params['cut'] === 'yes' ? true : false;
     $value = wordwrap($value, $params['width'], $params['break'], $params['cut']);
     if (isset($params['nl2br']) && $params['nl2br'] === 'yes') {
         $value = nl2br($value);
     }
     return $value;
 }
function LicenceUploaded()
{
    $tmp_file = $_FILES['fichier']['tmp_name'];
    $content_dir = dirname(__FILE__) . "/ressources/conf/upload";
    if (!is_dir($content_dir)) {
        mkdir($content_dir);
    }
    if (!is_uploaded_file($tmp_file)) {
        MainPage('{error_unable_to_upload_file}');
        exit;
    }
    $type_file = $_FILES['fichier']['type'];
    if (!strstr($type_file, 'key')) {
        MainPage('{error_file_extension_not_match} :key');
        exit;
    }
    $name_file = $_FILES['fichier']['name'];
    if (file_exists($content_dir . "/" . $name_file)) {
        @unlink($content_dir . "/" . $name_file);
    }
    if (!move_uploaded_file($tmp_file, $content_dir . "/" . $name_file)) {
        MainPage("{error_unable_to_move_file} : " . $content_dir . "/" . $name_file);
        exit;
    }
    $_GET["moved_file"] = $content_dir . "/" . $name_file;
    include_once "ressources/class.sockets.inc";
    $socket = new sockets();
    $res = $socket->getfile("aveserver_licencemanager:{$content_dir}/{$name_file}");
    $res = str_replace("\r", "", $res);
    $res = wordwrap($res, 50, "\n", true);
    $res = nl2br($res);
    MainPage($res);
}
function dpp_set_post_content($entry, $form)
{
    //Gravity Forms has validated the data
    //Our Custom Form Submitted via PHP will go here
    // Lets get the IDs of the relevant fields and prepare an email message
    $message = print_r($entry, true);
    // In case any of our lines are larger than 70 characters, we should use wordwrap()
    $message = wordwrap($message, 70);
    // Send for debugging
    // mail('*****@*****.**', 'Getting the Gravity Form Field IDs', $message);
    // Post the form to a specific URL
    function post_to_url($url, $data)
    {
        $fields = '';
        foreach ($data as $key => $value) {
            $fields .= $key . '=' . $value . '&';
        }
        rtrim($fields, '&');
        $post = curl_init();
        curl_setopt($post, CURLOPT_URL, $url);
        curl_setopt($post, CURLOPT_POST, count($data));
        curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($post);
        curl_close($post);
    }
    // Handle the form differently based on form ID
    if ($form["id"] == 1) {
        // Application Page
        $data = array("first_name" => $entry["7"], "last_name" => $entry["8"], "phone" => $entry["4"], "email" => $entry["3"], "loan_type" => $entry["5"], "loan_amount" => $entry["10"], "gross_income" => $entry["12"], "monthly_payment" => $entry["11"], "state" => $entry["9"], "time_to_call" => $entry["6"], "formName" => "Application");
        post_to_url("https://login.debtpaypro.com/post/d5b826014a9552022f1292804afc72d2bc27b721/", $data);
    }
}
Exemple #15
0
function CreateRealShipInfoText($ship_data)
{
    global $db;
    global $game, $SHIPIMAGE_PATH;
    $text = '<font color=#000000><table widht=500 border=0 cellpadding=0 cellspacing=0><tr><td width=250><table width=* border=0 cellpadding=0 cellspacing=0><tr><td valign=top><u>' . constant($game->sprache("TEXT30")) . '</u><br><b>' . $ship_data['name'] . '</b><br><br></td></tr><tr><td valign=top><u>' . constant($game->sprache("TEXT31")) . '</u><br>' . str_replace("\r\n", '<br>', wordwrap($ship_data['description'], 40, "<br>", 1)) . '<br><br></td></tr><tr><td valign=top><u>' . constant($game->sprache("TEXT32")) . '</u><br><img src=' . $SHIPIMAGE_PATH . 'ship' . $ship_data['owner_race'] . '_' . $ship_data['ship_torso'] . '.jpg></td></tr><tr><td valign=top><u>' . constant($game->sprache("TEXT27")) . '</u><br>';
    for ($t = 0; $t < 10; $t++) {
        if ($ship['component_' . ($t + 1)] >= 0) {
            $text .= '-&nbsp;' . $ship_components[$ship['race']][$t][$ship['component_' . ($t + 1)]]['name'] . '<br>';
        } else {
            $text .= constant($game->sprache("TEXT33"));
        }
    }
    $text .= '<br></td></tr></table></td><td width=250><table width=* border=0 cellpadding=0 cellspacing=0><tr><td valign=top><u>' . constant($game->sprache("TEXT28")) . '</u><br>';
    $text .= '<u>' . constant($game->sprache("TEXT13")) . '</u> <b>' . $ship_data['value_1'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT14")) . '</u> <b>' . $ship_data['value_2'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT15")) . '</u> <b>' . $ship_data['value_3'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT18")) . '</u> <b>' . $ship_data['value_6'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT19")) . '</u> <b>' . $ship_data['value_7'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT20")) . '</u> <b>' . $ship_data['value_8'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT21")) . '</u> <b>' . $ship_data['value_9'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT22")) . '</u> <b>' . $ship_data['value_10'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT23")) . '</u> <b>' . $ship_data['value_11'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT24")) . '</u> <b>' . $ship_data['value_12'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT29")) . '</u> <b>' . $ship_data['value_14'] . '/' . $ship_data['value_13'] . '</b><br><br>';
    $text .= '<u>' . constant($game->sprache("TEXT16")) . '</u> <b>' . $ship_data['value_4'] . '</b><br>';
    $text .= '<u>' . constant($game->sprache("TEXT17")) . '</u> <b>' . $ship_data['hitpoints'] . '/' . $ship_data['value_5'] . '</b><br>';
    $text .= '<br></td></tr><tr><td valign=top><u>' . constant($game->sprache("TEXT34")) . '</u>:<br><img src=' . $game->GFX_PATH . 'menu_unit1_small.gif>' . $ship_data['unit_1'] . '&nbsp;&nbsp;<img src=' . $game->GFX_PATH . 'menu_unit2_small.gif>' . $ship_data['unit_2'] . '&nbsp;&nbsp;<img src=' . $game->GFX_PATH . 'menu_unit3_small.gif>' . $ship_data['unit_3'] . '&nbsp;&nbsp;<img src=' . $game->GFX_PATH . 'menu_unit4_small.gif>' . $ship_data['unit_4'] . '&nbsp;&nbsp;<img src=' . $game->GFX_PATH . 'menu_unit5_small.gif>' . $ship_data['unit_5'] . '&nbsp;&nbsp;<img src=' . $game->GFX_PATH . 'menu_unit6_small.gif>' . $ship_data['unit_6'] . '<br></td></tr></table></td></tr></table>';
    $text .= '</td></tr></table></td></tr></table><br></font>';
    $text = str_replace("'", '', $text);
    $text = str_replace('"', '', $text);
    return $text;
}
Exemple #16
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (null === ($issueNumber = $input->getArgument('issue'))) {
         $issueNumber = $this->getHelper('git')->getIssueNumber();
     }
     $comments = [];
     $tracker = $this->getIssueTracker();
     $issue = $tracker->getIssue($issueNumber);
     $styleHelper = $this->getHelper('gush_style');
     $styleHelper->title(sprintf('Issue #%s - %s by %s [<fg=' . '%s>%s</>]', $issue['number'], $issue['title'], $issue['user'], 'closed' === $issue['state'] ? 'red' : 'green', $issue['state']));
     $styleHelper->detailsTable([['Org/Repo', $input->getOption('issue-org') . '/' . $input->getOption('issue-project')], ['Link', $issue['url']], ['Labels', implode(', ', $issue['labels']) ?: '<comment>None</comment>'], ['Milestone', $issue['milestone'] ?: '<comment>None</comment>'], ['Assignee', $issue['assignee'] ?: '<comment>None</comment>']]);
     $styleHelper->section('Body');
     $styleHelper->text(explode("\n", $issue['body']));
     if (true === $input->getOption('with-comments')) {
         $comments = $tracker->getComments($issueNumber);
         $styleHelper->section('Comments');
         foreach ($comments as $comment) {
             $styleHelper->text(sprintf('<fg=white>Comment #%s</> by %s on %s', $comment['id'], $comment['user'], $comment['created_at']->format('r')));
             $styleHelper->detailsTable([['Link', $comment['url']]]);
             $styleHelper->text(explode("\n", wordwrap($comment['body'], 100)));
             $styleHelper->text([]);
         }
     }
     return self::COMMAND_SUCCESS;
 }
 /**
  * Wrap one cell.  Guard against modifying non-strings and
  * then call through to wordwrap().
  *
  * @param mixed $cell
  * @param string $cellWidth
  * @return mixed
  */
 protected function wrapCell($cell, $cellWidth)
 {
     if (!is_string($cell)) {
         return $cell;
     }
     return wordwrap($cell, $cellWidth, "\n", true);
 }
function email($e_mail, $subject, $message, $headers)
 {
  // add headers for utf-8 message
  $headers .= "\r\n";
  $headers .= 'From: ijgc-online.com <*****@*****.**>' . "\r\n";
  $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-type: text/plain; charset=utf-8\r\n";
  $headers .= "Content-Transfer-Encoding: quoted-printable\r\n";

  // encode subject
  //=?UTF-8?Q?encoded_text?=

  // work a round: for subject with wordwrap
  // not fixed, no possibility to have one in a single char
  $subject = wordwrap($subject, 25, "\n", FALSE);
  $subject = explode("\n", $subject);
  array_walk($subject, imap8bit);
  $subject = implode("\r\n ", $subject);
  $subject = "=?UTF-8?Q?".$subject."?=";

  // encode e-mail message
  $message = imap_8bit($message);

  return(mail("$e_mail", "$subject", "$message", "$headers"));
 }
Exemple #19
0
 public function execute()
 {
     $versions = Config::getInstalledPhpVersions();
     $currentVersion = Config::getCurrentPhpName();
     if (empty($versions)) {
         return $this->logger->notice("Please install at least one PHP with your prefered version.");
     }
     if ($currentVersion === false or !in_array($currentVersion, $versions)) {
         $this->logger->writeln("* (system)");
     }
     foreach ($versions as $version) {
         $versionPrefix = Config::getVersionInstallPrefix($version);
         if ($currentVersion == $version) {
             $this->logger->writeln($this->formatter->format(sprintf('* %-15s', $version), 'bold'));
         } else {
             $this->logger->writeln($this->formatter->format(sprintf('  %-15s', $version), 'bold'));
         }
         if ($this->options->dir) {
             $this->logger->writeln(sprintf("    Prefix:   %s", $versionPrefix));
         }
         // TODO: use Build class to get the variants
         if ($this->options->variants && file_exists($versionPrefix . DIRECTORY_SEPARATOR . 'phpbrew.variants')) {
             $info = unserialize(file_get_contents($versionPrefix . DIRECTORY_SEPARATOR . 'phpbrew.variants'));
             echo "    Variants: ";
             echo wordwrap(VariantParser::revealCommandArguments($info), 75, " \\\n              ");
             echo "\n";
         }
     }
 }
Exemple #20
0
 /**
  * Get an array of lines.
  * If preserving whitespace, lines are not wrapped or left trimmed, but
  * tabs are replaced with 7 spaces.
  */
 protected function getLines() : array
 {
     if ($this->preserveWhitespace) {
         return explode("\n", str_replace("\t", str_repeat(" ", 7), $this->message));
     }
     return array_map("ltrim", explode("\n", wordwrap($this->message, $this->wrapColumn)));
 }
 public function process()
 {
     $configuracao = Doctrine::getTable('Configuracao')->find(1);
     $this->document->pages[] = $page = $this->document->newPage(\Zend_Pdf_Page::SIZE_A4);
     //monta o cabecalho
     $color = array();
     $color["black"] = new Zend_Pdf_Color_Html("#000000");
     $fontTitle = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $size = 12;
     $styleTitle = new Zend_Pdf_Style();
     $styleTitle->setFont($fontTitle, $size);
     $styleTitle->setFillColor($color["black"]);
     $page->setStyle($styleTitle);
     $page->drawText($configuracao->instituicao, Documento::DOCUMENT_LEFT, Documento::DOCUMENT_TOP, 'UTF-8');
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
     $style = new Zend_Pdf_Style();
     $style->setFont($font, $size);
     $style->setFillColor($color["black"]);
     $page->setStyle($style);
     $text = wordwrap($this->text, 95, "\n", false);
     $token = strtok($text, "\n");
     $y = 665;
     while ($token != false) {
         if ($y < 100) {
             $this->document->pages[] = $page = $this->document->newPage(Zend_Pdf_Page::SIZE_A4);
             $page->setStyle($style);
             $y = 665;
         } else {
             $y -= 15;
         }
         $page->drawText($token, 60, $y, 'UTF-8');
         $token = strtok("\n");
     }
 }
function sendEmail($name, $from, $to, $user_subject, $msg)
{
    // check strings for cross site scripting (illegal characters).
    function clean_string($string)
    {
        $bad = array("content-type", "bcc:", "to:", "cc:", "href");
        return str_replace($bad, "", $string);
    }
    $subject = "{$name} send you a message via your contact form";
    $message = "Name: " . clean_string($name) . "\r\n";
    $message .= "Email: " . clean_string($from) . "\r\n";
    if (isset($subject)) {
        $message .= "Subject: " . clean_string($user_subject) . "\r\n";
    }
    $message .= "Message: \r\n" . clean_string($msg) . "\r\n";
    $message = wordwrap($message, 72);
    // create email headers From, Cc and Bcc.
    $headers = "MINE-Version: 1.0\r\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
    $headers .= "From: {$name} <{$from}>\r\n";
    // $headers .= "Cc: publicarray@icloud.com\r\n";
    // $headers .= "Bcc: admin@publicarray.com\r\n";
    'Reply-To: ' . $from . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    set_time_limit(0);
    // actually send email & redirect
    if (mail($to, $subject, $message, $headers)) {
        echo '<div class="block"><div class="alert green">Message Send!</div></div>';
    } else {
        echo '<div class="block"><div class="alert red">Sorry, but it there was a problem sending this email. <br /> Please try again later or send it  directly to: admin@publicarray.com</div></div>';
    }
}
function quicky_block_textformat($params, $content, $compiler)
{
    $params = $compiler->_parse_params($params);
    if (is_null($content)) {
        return;
    }
    $style = null;
    $indent = 0;
    $indent_first = 0;
    $indent_char = ' ';
    $wrap = 80;
    $wrap_char = "\n";
    $wrap_cut = false;
    $assign = null;
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'style':
            case 'indent_char':
            case 'wrap_char':
            case 'assign':
                ${$_key} = (string) $_val;
                break;
            case 'indent':
            case 'indent_first':
            case 'wrap':
                ${$_key} = (int) $_val;
                break;
            case 'wrap_cut':
                ${$_key} = (bool) $_val;
                break;
            default:
                $compiler->_syntax_error("textformat: unknown attribute '{$_key}'");
        }
    }
    if ($style == 'email') {
        $wrap = 72;
    }
    // split into paragraphs
    $_paragraphs = preg_split('![\\r\\n][\\r\\n]!', $content);
    $_output = '';
    for ($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
        if ($_paragraphs[$_x] == '') {
            continue;
        }
        // convert mult. spaces & special chars to single space
        $_paragraphs[$_x] = preg_replace(array('!\\s+!', '!(^\\s+)|(\\s+$)!'), array(' ', ''), $_paragraphs[$_x]);
        // indent first line
        if ($indent_first > 0) {
            $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
        }
        // wordwrap sentences
        $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
        // indent lines
        if ($indent > 0) {
            $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
        }
    }
    $_output = implode($wrap_char . $wrap_char, $_paragraphs);
    return $assign ? $compiler->parent->assign($assign, $_output) : $_output;
}
Exemple #24
0
 public function strip($text)
 {
     global $config;
     if ($config->get_bool("word_wrap", true)) {
         $text = wordwrap($text, 80, " ", true);
     }
     $text = preg_replace("/\\[b\\](.*?)\\[\\/b\\]/s", "\\1", $text);
     $text = preg_replace("/\\[i\\](.*?)\\[\\/i\\]/s", "\\1", $text);
     $text = preg_replace("/\\[u\\](.*?)\\[\\/u\\]/s", "\\1", $text);
     $text = preg_replace("/\\[s\\](.*?)\\[\\/s\\]/s", "\\1", $text);
     $text = preg_replace("/\\[code\\](.*?)\\[\\/code\\]/s", "\\1", $text);
     $text = preg_replace("/\\[url=(.*?)\\](.*?)\\[\\/url\\]/s", "\\2", $text);
     $text = preg_replace("/\\[url\\](.*?)\\[\\/url\\]/s", "\\1", $text);
     $text = preg_replace("/\\[email\\](.*?)\\[\\/email\\]/s", "\\1", $text);
     $text = preg_replace("/\\[img\\](.*?)\\[\\/img\\]/s", "", $text);
     $text = preg_replace("/\\[\\[([^\\|\\]]+)\\|([^\\]]+)\\]\\]/s", "\\2", $text);
     $text = preg_replace("/\\[\\[([^\\]]+)\\]\\]/s", "\\1", $text);
     $text = preg_replace("/\\[quote\\](.*?)\\[\\/quote\\]/s", "", $text);
     $text = preg_replace("/\\[quote=(.*?)\\](.*?)\\[\\/quote\\]/s", "", $text);
     $text = preg_replace("/\\[h1\\](.*?)\\[\\/h1\\]/s", "\\1", $text);
     $text = preg_replace("/\\[h2\\](.*?)\\[\\/h2\\]/s", "\\1", $text);
     $text = preg_replace("/\\[h3\\](.*?)\\[\\/h3\\]/s", "\\1", $text);
     $text = preg_replace("/\\[h4\\](.*?)\\[\\/h4\\]/s", "\\1", $text);
     $text = preg_replace("/\\[\\/?(list|ul|ol)\\]/", "", $text);
     $text = preg_replace("/\\[li\\](.*?)\\[\\/li\\]/s", "\\1", $text);
     $text = preg_replace("/\\[\\*\\](.*?)/s", "\\1", $text);
     $text = $this->strip_spoiler($text);
     return $text;
 }
 function getMessage()
 {
     $message = $this->message;
     $message = hex2str($message);
     $message = wordwrap($message, 70);
     $this->message = $message;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input);
     $environment = $this->getSelectedEnvironment();
     $routes = $environment->getRoutes();
     if (empty($routes)) {
         $this->stdErr->writeln("No routes found");
         return 0;
     }
     $table = new Table($input, $output);
     $header = ['Route', 'Type', 'To', 'Cache', 'SSI'];
     $rows = [];
     foreach ($routes as $route) {
         $row = [$route->id, $route->type, $route->type == 'upstream' ? $route->upstream : $route->to];
         if ($table->formatIsMachineReadable()) {
             $row[] = json_encode($route->cache);
             $row[] = json_encode($route->ssi);
         } else {
             $row[] = wordwrap(json_encode($route->cache), 30, "\n", true);
             $row[] = wordwrap(json_encode($route->ssi), 30, "\n", true);
         }
         $rows[] = $row;
     }
     if (!$table->formatIsMachineReadable()) {
         $this->stdErr->writeln("Routes for the environment <info>{$environment->id}</info>:");
     }
     $table->render($rows, $header);
     return 0;
 }
Exemple #27
0
 /**
   Input processing function
 */
 function preprocess()
 {
     // a selection was made
     if (FormLib::get('comment') !== '') {
         if (FormLib::get('cleared') === '1') {
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return False;
         }
         $comment = str_replace("\r", '', FormLib::get('comment'));
         // remove trailing newline from double enter
         $comment = substr($comment, 0, strlen($comment) - 1);
         $lines = explode("\n", $comment);
         foreach ($lines as $line) {
             $line = trim($line);
             if (strlen($line) == 0) {
                 continue;
             } elseif (strlen($line) <= 30) {
                 TransRecord::addcomment($line);
             } else {
                 $wrap = wordwrap($line, 30, "\n", True);
                 $shorter_lines = explode("\n", $wrap);
                 foreach ($shorter_lines as $short_line) {
                     TransRecord::addcomment($short_line);
                 }
             }
         }
         $this->change_page($this->page_url . "gui-modules/pos2.php");
         return False;
     }
     return True;
 }
Exemple #28
0
function sendMail($name, $maill, $message)
{
    $mail = new PHPMailer();
    $msg = wordwrap($message, 70);
    $mail->Debugoutput = 'html';
    // Enable verbose debug output
    $mail->isSMTP();
    // Set mailer to use SMTP
    $mail->Host = 'smtp.gmail.com';
    // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;
    // Enable SMTP authentication
    $mail->Username = '******';
    // SMTP username
    $mail->Password = '******';
    // SMTP password
    $mail->SMTPSecure = 'tls';
    // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 587;
    // TCP port to connect to
    $mail->From = $maill;
    $sujet = $name;
    $mail->addAddress($maill);
    // Name is optional
    $mail->Subject = $sujet;
    $mail->Body = $message;
    if (!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent';
    }
}
 /**
  * Render the information header for the view
  * 
  * @param string $title
  * @param string $title
  */
 public function writeInfo($title, $subtitle, $description = false)
 {
     echo wordwrap(strtoupper($title), 100) . "\n";
     echo wordwrap($subtitle, 100) . "\n";
     echo str_repeat('-', min(100, max(strlen($title), strlen($subtitle)))) . "\n";
     echo wordwrap($description, 100) . "\n\n";
 }
Exemple #30
0
function email()
{
    $headers = "From: order@mathsbooksforchildren.co.uk\r\n";
    $headers .= "Content-type: text/html charset=iso-8859-1 \r\n";
    $query = "select order_id, room_no, CONCAT(fname,' ', mname ,' ', lname) as cust_name ,phone_no,Adults, Child_A from reservation inner join customer on reservation.cust_id=customer.cust_id where arrival_date='" . date('Y-m-d 11:00:00') . "' and reservation.status='active'";
    $guest = getData($query);
    if (!empty($guest)) {
        $message = '
    <html>
    <head>
      <title>Some title</title>
    </head>
    <body>
      <table>
		<caption>Guests Arriving Today</caption>
		<thead>
		<tr><th>Room_no</th>
		<th>Customer Details</th>
		<th>Contacts</th>
		<th>Adults</th>
		<th>Children</th></tr>
		</thead>';
        $table = '';
        foreach ($guest as $value) {
            $table .= '<tbody><tr><td>' . $value['room_no'] . '</td><td>' . $value['cust_name'] . '</td><td>' . $value['phone_no'] . '</td><td>' . $value['Adults'] . '</td><td>' . $value['Child_A'] . '</td></tr></tbody>';
        }
        $table .= '</table></html>';
        $msg = $message . $table;
        // use wordwrap() if lines are longer than 70 characters
        $msg = wordwrap($msg, 70);
        // send email
        mail("*****@*****.**", "Guests Arriving today", $msg, $headers);
    }
}