Exemplo n.º 1
0
function smarty_modifier_htmlall($string)
{
    $charset = \Pina\App::charset();
    if (empty($charset)) {
        $charset = 'utf-8';
    }
    return htmlentities($string, ENT_QUOTES, $charset);
}
Exemplo n.º 2
0
 public function fail()
 {
     $message = '';
     foreach ($this->messages as $k => $v) {
         $message .= $v[1] . "\r\n";
     }
     echo '<html><head><meta charset="' . App::charset() . '" /></head><body>' . $message . '</body></html>';
     $this->badRequest();
     exit;
 }
Exemplo n.º 3
0
function smarty_modifier_cut_details($string)
{
    $charset = \Pina\App::charset();
    if (empty($charset)) {
        $charset = 'utf-8';
    }
    if (($r = mb_strstr($string, '<hr class="pinacut" />', false, $charset)) !== false) {
        return $r;
    }
    return $string;
}
Exemplo n.º 4
0
function smarty_modifier_cut($string, $length = false, $etc = "...")
{
    $charset = \Pina\App::charset();
    if (empty($charset)) {
        $charset = 'utf-8';
    }
    if (($pos = mb_strpos($string, '<hr class="pinacut" />')) !== false) {
        return mb_substr($string, 0, $pos, $charset);
    }
    if ($length && mb_strlen($string, $charset) > $length) {
        $string = strip_tags($string);
        $length -= min($length, mb_strlen($etc, $charset));
        return mb_substr($string, 0, $length, $charset) . $etc;
    }
    return $string;
}
Exemplo n.º 5
0
 private static function mail()
 {
     if (empty(static::$config)) {
         return;
     }
     if (empty(static::$to)) {
         return;
     }
     $mail = new PHPMailer();
     if (static::$config['mode'] == 'smtp') {
         $mail->isSMTP();
         $mail->Host = static::$config['smtp']['host'];
         if (static::$config['smtp']['user']) {
             $mail->SMTPAuth = true;
             $mail->Username = static::$config['smtp']['user'];
             $mail->Password = static::$config['smtp']['pass'];
         }
         $mail->SMTPSecure = static::$config['smtp']['secure'];
         $mail->Port = static::$config['smtp']['port'];
     } else {
         $mail->isMail();
     }
     $mail->setFrom(static::$config['from']['address'], !empty(static::$config['from']['name']) ? static::$config['from']['name'] : '');
     foreach (static::$to as $u) {
         $mail->addAddress($u['address'], $u['name']);
     }
     if (!empty(static::$config['reply']['address'])) {
         $mail->addReplyTo(static::$config['reply']['address'], !empty(static::$config['reply']['name']) ? static::$config['reply']['name'] : '');
     }
     foreach (static::$cc as $u) {
         $mail->addCC($u['address'], $u['name']);
     }
     foreach (static::$bcc as $u) {
         $mail->addBCC($u['address'], $u['name']);
     }
     $mail->CharSet = App::charset();
     $mail->Subject = Place::get('mail_subject');
     $mail->Body = static::$content;
     $mail->AltBody = Place::get('mail_alternative');
     if ($mail->AltBody) {
         $mail->isHTML(true);
     }
     if (!$mail->send()) {
         Log::error("mail", "error send email to " . json_encode($mail, JSON_UNESCAPED_UNICODE));
         return false;
     }
     return true;
 }
Exemplo n.º 6
0
function smarty_function_meta($params, &$view)
{
    return '<meta http-equiv="Content-Type" content="text/html; charset=' . App::charset() . '" />';
}
Exemplo n.º 7
0
 public function contentType($type, $charset = false)
 {
     if (empty($charset)) {
         $charset = App::charset();
     }
     $this->header('Content-type: ' . $type . '; charset=' . $charset);
 }