issue 2119. supporting php 5.4. mail and mobile classes.

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12690 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2013-02-05 01:49:13 +00:00
parent 7305cebf38
commit 9aa87c343f
2 changed files with 70 additions and 60 deletions

View file

@ -1,4 +1,5 @@
<?php <?php
if(version_compare(PHP_VERSION, '5.0.0', '>=')) if(version_compare(PHP_VERSION, '5.0.0', '>='))
{ {
require_once _XE_PATH_ . "libs/phpmailer/phpmailer.php"; require_once _XE_PATH_ . "libs/phpmailer/phpmailer.php";
@ -15,6 +16,7 @@ else
*/ */
class Mail extends PHPMailer class Mail extends PHPMailer
{ {
/** /**
* Sender name * Sender name
* @var string * @var string
@ -85,7 +87,7 @@ class Mail extends PHPMailer
* Content attachements * Content attachements
* @var array * @var array
*/ */
var $cidAttachments = array(); var $cidAttachments = array();
/** /**
* ??? * ???
@ -136,6 +138,7 @@ class Mail extends PHPMailer
*/ */
function Mail() function Mail()
{ {
} }
/** /**
@ -178,10 +181,10 @@ class Mail extends PHPMailer
function useSMTP($auth = NULL, $host = NULL, $user = NULL, $pass = NULL, $secure = NULL, $port = 25) function useSMTP($auth = NULL, $host = NULL, $user = NULL, $pass = NULL, $secure = NULL, $port = 25)
{ {
$this->SMTPAuth = $auth; $this->SMTPAuth = $auth;
$this->Host = $host; $this->Host = $host;
$this->Username = $user; $this->Username = $user;
$this->Password = $pass; $this->Password = $pass;
$this->Port = $port; $this->Port = $port;
if($secure == 'ssl' || $secure == 'tls') if($secure == 'ssl' || $secure == 'tls')
{ {
@ -438,7 +441,7 @@ class Mail extends PHPMailer
*/ */
function getHTMLContent() function getHTMLContent()
{ {
return chunk_split(base64_encode($this->content_type != 'html' ? nl2br($this->content):$this->content)); return chunk_split(base64_encode($this->content_type != 'html' ? nl2br($this->content) : $this->content));
} }
/** /**
@ -449,7 +452,7 @@ class Mail extends PHPMailer
*/ */
function setContentType($mode = 'html') function setContentType($mode = 'html')
{ {
$this->content_type = $mode == 'html' ? 'html':''; $this->content_type = $mode == 'html' ? 'html' : '';
} }
/** /**
@ -483,12 +486,7 @@ class Mail extends PHPMailer
"Content-Description: %s" . $this->eol . "Content-Description: %s" . $this->eol .
"Content-Disposition: attachment;" . $this->eol . "Content-Disposition: attachment;" . $this->eol .
"\tfilename=\"%s\"" . $this->eol . $this->eol . "\tfilename=\"%s\"" . $this->eol . $this->eol .
"%s" . $this->eol . $this->eol, "%s" . $this->eol . $this->eol, $type, $filename, $filename, $filename, $chunks);
$type,
$filename,
$filename,
$filename,
$chunks);
$res[] = $tempBody; $res[] = $tempBody;
} }
$this->body = implode("", $res); $this->body = implode("", $res);
@ -536,13 +534,7 @@ class Mail extends PHPMailer
"Content-ID: <%s>" . $this->eol . "Content-ID: <%s>" . $this->eol .
"Content-Description: %s" . $this->eol . "Content-Description: %s" . $this->eol .
"Content-Location: %s" . $this->eol . $this->eol . "Content-Location: %s" . $this->eol . $this->eol .
"%s" . $this->eol . $this->eol, "%s" . $this->eol . $this->eol, $type, $filename, $cid, $filename, $filename, $chunks);
$type,
$filename,
$cid,
$filename,
$filename,
$chunks);
$res[] = $tempBody; $res[] = $tempBody;
} }
$this->body = implode("", $res); $this->body = implode("", $res);
@ -574,13 +566,8 @@ class Mail extends PHPMailer
"Content-Disposition: inline" . $this->eol . $this->eol . "Content-Disposition: inline" . $this->eol . $this->eol .
"%s" . "%s" .
"--%s--" . "--%s--" .
"", "", $boundary, $this->getPlainContent(), $boundary, $this->getHTMLContent(), $boundary
$boundary, );
$this->getPlainContent(),
$boundary,
$this->getHTMLContent(),
$boundary
);
$this->procCidAttachments(); $this->procCidAttachments();
$this->procAttachments(); $this->procAttachments();
$headers = sprintf( $headers = sprintf(
@ -589,13 +576,8 @@ class Mail extends PHPMailer
"%s" . "%s" .
"%s" . "%s" .
"%s" . "%s" .
"MIME-Version: 1.0" . $this->eol . "", "MIME-Version: 1.0" . $this->eol . "", $this->getSender(), $this->messageId ? ("Message-ID: <" . $this->messageId . ">" . $this->eol) : "", $this->replyTo ? ("Reply-To: <" . $this->replyTo . ">" . $this->eol) : "", $this->bcc ? ("Bcc: " . $this->bcc . $this->eol) : "", $this->references ? ("References: <" . $this->references . ">" . $this->eol . "In-Reply-To: <" . $this->references . ">" . $this->eol) : ""
$this->getSender(), );
$this->messageId ? ("Message-ID: <" . $this->messageId . ">" . $this->eol):"",
$this->replyTo ? ("Reply-To: <" . $this->replyTo . ">" . $this->eol):"",
$this->bcc ? ("Bcc: " . $this->bcc . $this->eol):"",
$this->references ? ("References: <" . $this->references . ">" . $this->eol . "In-Reply-To: <" . $this->references . ">" . $this->eol):""
);
$headers .= $this->header; $headers .= $this->header;
if($this->additional_params) if($this->additional_params)
{ {
@ -739,6 +721,7 @@ class Mail extends PHPMailer
return "unknown/" . trim($fileSuffix[0], "."); return "unknown/" . trim($fileSuffix[0], ".");
} }
} }
} }
/* End of file Mail.class.php */ /* End of file Mail.class.php */
/* Location: ./classes/mail/Mail.class.php */ /* Location: ./classes/mail/Mail.class.php */

View file

@ -5,21 +5,27 @@
* *
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
*/ */
class Mobile { class Mobile
{
/** /**
* Whether mobile or not mobile mode * Whether mobile or not mobile mode
* @var bool * @var bool
*/ */
var $ismobile = null; var $ismobile = NULL;
/** /**
* Get instance of Mobile class(for singleton) * Get instance of Mobile class(for singleton)
* *
* @return Mobile * @return Mobile
*/ */
function &getInstance() { function &getInstance()
{
static $theInstance; static $theInstance;
if(!isset($theInstance)) $theInstance = new Mobile(); if(!isset($theInstance))
{
$theInstance = new Mobile();
}
return $theInstance; return $theInstance;
} }
@ -28,8 +34,9 @@ class Mobile {
* *
* @return bool If mobile mode returns true or false * @return bool If mobile mode returns true or false
*/ */
function isFromMobilePhone() { function isFromMobilePhone()
$oMobile =& Mobile::getInstance(); {
$oMobile = & Mobile::getInstance();
return $oMobile->_isFromMobilePhone(); return $oMobile->_isFromMobilePhone();
} }
@ -38,11 +45,16 @@ class Mobile {
* *
* @return bool * @return bool
*/ */
function _isFromMobilePhone() { function _isFromMobilePhone()
if($this->ismobile !== null) return $this->ismobile; {
if($this->ismobile !== NULL)
{
return $this->ismobile;
}
$db_info = Context::getDBInfo(); $db_info = Context::getDBInfo();
if($db_info->use_mobile_view != "Y" || Context::get('full_browse') || $_COOKIE["FullBrowse"]) { if($db_info->use_mobile_view != "Y" || Context::get('full_browse') || $_COOKIE["FullBrowse"])
{
return ($this->ismobile = false); return ($this->ismobile = false);
} }
@ -52,19 +64,28 @@ class Mobile {
$this->ismobile = FALSE; $this->ismobile = FALSE;
$m = Context::get('m'); $m = Context::get('m');
if(strlen($m)==1) { if(strlen($m) == 1)
if($m == "1") { {
$this->ismobile = true; if($m == "1")
} elseif($m == "0") { {
$this->ismobile = false; $this->ismobile = TRUE;
} }
} elseif(isset($_COOKIE['mobile'])) { elseif($m == "0")
{
$this->ismobile = FALSE;
}
}
elseif(isset($_COOKIE['mobile']))
{
if($_COOKIE['user-agent'] == md5($_SERVER['HTTP_USER_AGENT'])) if($_COOKIE['user-agent'] == md5($_SERVER['HTTP_USER_AGENT']))
{ {
if($_COOKIE['mobile'] == 'true') { if($_COOKIE['mobile'] == 'true')
$this->ismobile = true; {
} else { $this->ismobile = TRUE;
$this->ismobile = false; }
else
{
$this->ismobile = FALSE;
} }
} }
else else
@ -111,7 +132,7 @@ class Mobile {
if($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT'])) if($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
{ {
setcookie("user-agent",md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path); setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path);
} }
} }
@ -126,10 +147,13 @@ class Mobile {
function isMobileCheckByAgent() function isMobileCheckByAgent()
{ {
static $UACheck; static $UACheck;
if(isset($UACheck)) return $UACheck; if(isset($UACheck))
{
return $UACheck;
}
$oMobile =& Mobile::getInstance(); $oMobile = Mobile::getInstance();
$mobileAgent = array('iPod','iPhone','Android','BlackBerry','SymbianOS','Bada','Tizen','Kindle','Wii','SCH-','SPH-','CANU-','Windows Phone','Windows CE','POLARIS','Palm','Dorothy Browser','Mobile','Opera Mobi','Opera Mini','Minimo','AvantGo','NetFront','Nokia','LGPlayer','SonyEricsson','HTC'); $mobileAgent = array('iPod', 'iPhone', 'Android', 'BlackBerry', 'SymbianOS', 'Bada', 'Tizen', 'Kindle', 'Wii', 'SCH-', 'SPH-', 'CANU-', 'Windows Phone', 'Windows CE', 'POLARIS', 'Palm', 'Dorothy Browser', 'Mobile', 'Opera Mobi', 'Opera Mini', 'Minimo', 'AvantGo', 'NetFront', 'Nokia', 'LGPlayer', 'SonyEricsson', 'HTC');
if($oMobile->isMobilePadCheckByAgent()) if($oMobile->isMobilePadCheckByAgent())
{ {
@ -157,12 +181,15 @@ class Mobile {
function isMobilePadCheckByAgent() function isMobilePadCheckByAgent()
{ {
static $UACheck; static $UACheck;
if(isset($UACheck)) return $UACheck; if(isset($UACheck))
$padAgent = array('iPad','Android','webOS','hp-tablet','PlayBook'); {
return $UACheck;
}
$padAgent = array('iPad', 'Android', 'webOS', 'hp-tablet', 'PlayBook');
// Android with 'Mobile' string is not a tablet-like device, and 'Andoroid' without 'Mobile' string is a tablet-like device. // Android with 'Mobile' string is not a tablet-like device, and 'Andoroid' without 'Mobile' string is a tablet-like device.
// $exceptionAgent[0] contains exception agents for all exceptions. // $exceptionAgent[0] contains exception agents for all exceptions.
$exceptionAgent = array(0 => array('Opera Mini','Opera Mobi'),'Android' => 'Mobile'); $exceptionAgent = array(0 => array('Opera Mini', 'Opera Mobi'), 'Android' => 'Mobile');
foreach($padAgent as $agent) foreach($padAgent as $agent)
{ {
@ -202,9 +229,9 @@ class Mobile {
*/ */
function setMobile($ismobile) function setMobile($ismobile)
{ {
$oMobile =& Mobile::getInstance(); $oMobile = Mobile::getInstance();
$oMobile->ismobile = $ismobile; $oMobile->ismobile = $ismobile;
} }
}
}
?> ?>