Merge branch 'master' into pr/manager-scopes

This commit is contained in:
Kijin Sung 2024-10-27 23:09:40 +09:00
commit 2620049b4e
18 changed files with 136 additions and 202 deletions

View file

@ -151,5 +151,7 @@ return array(
],
'use_rewrite' => true,
'use_sso' => false,
'other' => array(),
'other' => [
'proxy' => null,
],
);

View file

@ -209,9 +209,10 @@ class HTTP
];
// Add proxy settings.
if (defined('__PROXY_SERVER__'))
$proxy = config('other.proxy') ?: (defined('__PROXY_SERVER__') ? constant('__PROXY_SERVER__') : '');
if ($proxy !== '')
{
$proxy = parse_url(constant('__PROXY_SERVER__'));
$proxy = parse_url($proxy);
$proxy_scheme = preg_match('/^(https|socks)/', $proxy['scheme'] ?? '') ? ($proxy['scheme'] . '://') : 'http://';
$proxy_auth = (!empty($proxy['user']) && !empty($proxy['pass'])) ? ($proxy['user'] . ':' . $proxy['pass'] . '@') : '';
$settings['proxy'] = sprintf('%s%s%s:%s', $proxy_scheme, $proxy_auth, $proxy['host'], $proxy['port']);

View file

@ -7,15 +7,6 @@ namespace Rhymix\Framework\Drivers\Mail;
*/
class MailFunction extends Base implements \Rhymix\Framework\Drivers\MailInterface
{
/**
* Direct invocation of the constructor is not permitted.
*/
protected function __construct()
{
include_once \RX_BASEDIR . 'common/libraries/swift_mail.php';
$this->_mailer = new \Swift_Mailer(new \Swift_MailTransport);
}
/**
* Get the human-readable name of this mail driver.
*
@ -58,6 +49,12 @@ class MailFunction extends Base implements \Rhymix\Framework\Drivers\MailInterfa
*/
public function send(\Rhymix\Framework\Mail $message)
{
if ($this->_mailer === null)
{
include_once \RX_BASEDIR . 'common/libraries/swift_mail.php';
$this->_mailer = new \Swift_Mailer(new \Swift_MailTransport);
}
try
{
$errors = [];

View file

@ -7,23 +7,6 @@ namespace Rhymix\Framework\Drivers\Mail;
*/
class SMTP extends Base implements \Rhymix\Framework\Drivers\MailInterface
{
/**
* Direct invocation of the constructor is not permitted.
*/
protected function __construct(array $config)
{
$security = in_array($config['smtp_security'], ['ssl', 'tls']) ? $config['smtp_security'] : null;
$transport = new \Swift_SmtpTransport($config['smtp_host'], $config['smtp_port'], $security);
$transport->setUsername($config['smtp_user']);
$transport->setPassword($config['smtp_pass']);
$local_domain = $transport->getLocalDomain();
if (preg_match('/^\*\.(.+)$/', $local_domain, $matches))
{
$transport->setLocalDomain($matches[1]);
}
$this->mailer = new \Swift_Mailer($transport);
}
/**
* Get the list of configuration fields required by this mail driver.
*
@ -56,9 +39,32 @@ class SMTP extends Base implements \Rhymix\Framework\Drivers\MailInterface
*/
public function send(\Rhymix\Framework\Mail $message)
{
if ($this->_mailer === null)
{
if (isset($this->_config['smtp_security']) && in_array($this->_config['smtp_security'], ['ssl', 'tls']))
{
$security = $this->_config['smtp_security'];
}
else
{
$security = null;
}
$transport = new \Swift_SmtpTransport($this->_config['smtp_host'], $this->_config['smtp_port'], $security);
$transport->setUsername($this->_config['smtp_user']);
$transport->setPassword($this->_config['smtp_pass']);
$local_domain = $transport->getLocalDomain();
if (preg_match('/^\*\.(.+)$/', $local_domain, $matches))
{
$transport->setLocalDomain($matches[1]);
}
$this->_mailer = new \Swift_Mailer($transport);
}
try
{
$result = $this->mailer->send($message->message, $errors);
$errors = [];
$result = $this->_mailer->send($message->message, $errors);
}
catch(\Exception $e)
{

View file

@ -1,141 +0,0 @@
<?php
namespace Rhymix\Framework\Drivers\SMS;
/**
* The ApiStore SMS driver.
*/
class ApiStore extends Base implements \Rhymix\Framework\Drivers\SMSInterface
{
/**
* API specifications.
*/
protected static $_spec = array(
'max_recipients' => 500,
'sms_max_length' => 90,
'sms_max_length_in_charset' => 'CP949',
'lms_supported' => true,
'lms_supported_country_codes' => array(82),
'lms_max_length' => 2000,
'lms_max_length_in_charset' => 'CP949',
'lms_subject_supported' => true,
'lms_subject_max_length' => 60,
'mms_supported' => false,
'delay_supported' => true,
);
/**
* Config keys used by this driver are stored here.
*/
protected static $_required_config = array('api_user', 'api_key');
/**
* Check if the current SMS driver is supported on this server.
*
* This method returns true on success and false on failure.
*
* @return bool
*/
public static function isSupported()
{
return true;
}
/**
* Store the last response.
*/
protected $_last_response = '';
/**
* Send a message.
*
* This method returns true on success and false on failure.
*
* @param array $messages
* @param object $original
* @return bool
*/
public function send(array $messages, \Rhymix\Framework\SMS $original)
{
$status = true;
foreach ($messages as $i => $message)
{
$data = array();
$data['send_phone'] = $message->from;
$data['dest_phone'] = implode(',', $message->to);
$data['msg_body'] = strval($message->content);
if ($message->type !== 'SMS' && $message->subject)
{
$data['subject'] = $message->subject;
}
$result = $this->_apiCall(sprintf('message/%s', strtolower($message->type)), $data);
if (!$result)
{
$message->errors[] = 'ApiStore API returned invalid response: ' . $this->_getLastResponse();
$status = false;
}
if ($result->result_message !== 'OK')
{
$message->errors[] = 'ApiStore API error: ' . $result->result_code . ' ' . $result->result_message;
}
}
return $status;
}
/**
* API call.
*
* @param string $url
* @param array $data
* @param string $method (optional)
* @return object|false
*/
protected function _apiCall(string $url, array $data, string $method = 'POST')
{
// Build the request URL.
if ($data['version'])
{
$version = $data['version'];
unset($data['version']);
}
else
{
$version = 1;
}
$url = sprintf('http://api.apistore.co.kr/ppurio/%d/%s/%s', $version, trim($url, '/'), $this->_config['api_user']);
// Set the API key in the header.
$headers = array(
'x-waple-authorization' => $this->_config['api_key'],
);
// Send the API reqeust.
if ($method === 'GET')
{
if ($data)
{
$url .= '?' . http_build_query($data);
}
$this->_last_response = \FileHandler::getRemoteResource($url, null, 5, $method, null, $headers) ?: '';
}
else
{
$this->_last_response = \FileHandler::getRemoteResource($url, $data, 5, $method, null, $headers) ?: '';
}
$result = @json_decode($this->_last_response);
return $result ?: false;
}
/**
* Fetch the last API response.
*
* @return string
*/
protected function _getLastResponse()
{
return $this->_last_response;
}
}

View file

@ -33,6 +33,7 @@ else
}
// Get queue configuration set by the administrator.
$display_errors = config('queue.display_errors') === false ? false : true;
$timeout = (config('queue.interval') ?? 1) * 60;
$process_count = config('queue.process_count') ?? 1;
@ -41,6 +42,14 @@ if (PHP_SAPI !== 'cli')
{
ignore_user_abort(true);
set_time_limit(max(60, $timeout));
if ($display_errors)
{
ini_set('display_errors', true);
}
if (Rhymix\Framework\Session::checkStart())
{
Rhymix\Framework\Session::close();
}
}
// Create multiple processes if configured.
@ -89,3 +98,9 @@ else
{
Rhymix\Framework\Queue::process($timeout);
}
// If called over the network, display a simple OK message to indicate success.
if (PHP_SAPI !== 'cli')
{
echo "OK\n";
}

View file

@ -7,11 +7,12 @@
<meta charset="utf-8">
<meta name="generator" content="Rhymix">
<meta name="viewport" content="{{ config('mobile.viewport') ?? HTMLDisplayHandler::DEFAULT_VIEWPORT }}" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@foreach (Context::getMetaTag() as $val)
<meta http-equiv="{{ $val['name'] }}"|if="$val['is_http_equiv']" name="{{ $val['name'] }}"|if="!$val['is_http_equiv']" content="{{ $val['content'] }}" />
@endforeach
<meta name="csrf-token" content="{!! \Rhymix\Framework\Session::getGenericToken() !!}" />
@foreach (Context::getMetaTag() as $val)
@if ($val['is_before_title'])
<meta http-equiv="{{ $val['name'] }}"|if="$val['is_http_equiv']" name="{{ $val['name'] }}"|if="!$val['is_http_equiv']" content="{!! $val['content'] !!}" />
@endif
@endforeach
<!-- TITLE -->
<title>{{ Context::getBrowserTitle() }}</title>
@ -55,6 +56,11 @@
@endforeach
<!-- OTHER HEADERS -->
@foreach (Context::getMetaTag() as $val)
@if (!$val['is_before_title'])
<meta http-equiv="{{ $val['name'] }}"|if="$val['is_http_equiv']" name="{{ $val['name'] }}"|if="!$val['is_http_equiv']" content="{!! $val['content'] !!}" />
@endif
@endforeach
@foreach (Context::getOpenGraphData() as $og_metadata)
<meta property="{{ $og_metadata['property'] }}" content="{{ $og_metadata['content'] }}" />
@endforeach