ivite codes, text changes, mailcannon as mail service
This commit is contained in:
parent
c53b4e3b6b
commit
c192125174
9
democracy/api/sql/BETA_CODE_DELETE.php
Normal file
9
democracy/api/sql/BETA_CODE_DELETE.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace SQL;
|
||||
|
||||
class BETA_CODE_DELETE extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
'DELETE FROM `beta_code` WHERE code = ?;';
|
||||
}
|
||||
}
|
||||
9
democracy/api/sql/BETA_EMAIL_DELETE.php
Normal file
9
democracy/api/sql/BETA_EMAIL_DELETE.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace SQL;
|
||||
|
||||
class BETA_EMAIL_DELETE extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
'DELETE FROM `beta` WHERE LOWER(email) = LOWER(?)';
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,6 @@
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'UA-109296340-1');
|
||||
</script>
|
||||
|
||||
@ -64,7 +63,7 @@
|
||||
<div id="code" code="${code}" valid="${code_valid}"></div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 no-gutters" style="text-align: center;">
|
||||
<div class="col-10 offset-1 no-gutters" style="text-align: center;">
|
||||
<img src="../files/invite/group@3x.png" alt="DEMOCRACY Logo" style="width: 120px; margin-top: 25px">
|
||||
<h1>DEMOCRACY</h1>
|
||||
<h2>prototyp_access</h2>
|
||||
@ -116,6 +115,8 @@
|
||||
<div id="final_ios" class="row step">
|
||||
<div class="col-10 col-md-8 offset-1 offset-md-2" style="padding: 0; font-size: 24px;">
|
||||
Sobald Du im AppStore freigeschaltet wurdest, erhälst Du eine EMail mit einer genauen Anleitung von uns.<br>
|
||||
<br>
|
||||
<span style="color: red;">Bitte überprüfe auch Deinen Spam-Ordner!</span>
|
||||
</div>
|
||||
<div class="col-10 col-md-8 offset-1 offset-md-2" style="padding: 0; font-size: 22px; margin-top: 25px;">
|
||||
<ol style="line-height: 2; text-align: left;">
|
||||
@ -131,6 +132,8 @@
|
||||
<div id="final_android" class="row step">
|
||||
<div class="col-10 col-md-8 offset-1 offset-md-2" style="padding: 0; font-size: 24px;">
|
||||
Sobald Du im PlayStore freigeschaltet wurdest, erhälst Du eine EMail mit einer genauen Anleitung von uns.<br>
|
||||
<br>
|
||||
<span style="color: red;">Bitte überprüfe auch Deinen Spam-Ordner!</span>
|
||||
</div>
|
||||
<div class="col-10 col-md-8 offset-1 offset-md-2" style="padding: 0; font-size: 22px; margin-top: 25px;">
|
||||
<ol style="line-height: 2; text-align: left;">
|
||||
|
||||
@ -3,3 +3,4 @@ require_once dirname(__FILE__).'/sql/autoload.inc';
|
||||
// \SYSTEM\autoload::registerFolder(dirname(__FILE__).'/sql','SQL');
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__),'SAI');
|
||||
\SYSTEM\SAI\sai::register('\SAI\saimod_beta');
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__).'/cannon');
|
||||
4
democracy/sai/saimod_beta/cannon/Pear/Mail/.gitignore
vendored
Normal file
4
democracy/sai/saimod_beta/cannon/Pear/Mail/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# composer related
|
||||
composer.lock
|
||||
composer.phar
|
||||
vendor
|
||||
19
democracy/sai/saimod_beta/cannon/Pear/Mail/.travis.yml
Normal file
19
democracy/sai/saimod_beta/cannon/Pear/Mail/.travis.yml
Normal file
@ -0,0 +1,19 @@
|
||||
language: php
|
||||
sudo: false
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- nightly
|
||||
install:
|
||||
- pear list
|
||||
- pear channel-update pear.php.net
|
||||
- pear upgrade --force pear/pear
|
||||
- pear list
|
||||
- pear upgrade --force xml_util
|
||||
- pear install --force --alldeps package.xml
|
||||
- pear list
|
||||
script:
|
||||
- pear run-tests -d tests/
|
||||
29
democracy/sai/saimod_beta/cannon/Pear/Mail/LICENSE
Normal file
29
democracy/sai/saimod_beta/cannon/Pear/Mail/LICENSE
Normal file
@ -0,0 +1,29 @@
|
||||
Copyright (c) 1997-2017, Chuck Hagenbuch
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
267
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail.php
Normal file
267
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail.php
Normal file
@ -0,0 +1,267 @@
|
||||
<?php
|
||||
/**
|
||||
* PEAR's Mail:: interface.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 1997-2017, Chuck Hagenbuch & Richard Heyes
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 1997-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
//require_once 'PEAR.php';
|
||||
|
||||
/**
|
||||
* PEAR's Mail:: interface. Defines the interface for implementing
|
||||
* mailers under the PEAR hierarchy, and provides supporting functions
|
||||
* useful in multiple mailer backends.
|
||||
*
|
||||
* @version $Revision$
|
||||
* @package Mail
|
||||
*/
|
||||
class Mail
|
||||
{
|
||||
/**
|
||||
* Line terminator used for separating header lines.
|
||||
* @var string
|
||||
*/
|
||||
public $sep = "\r\n";
|
||||
|
||||
/**
|
||||
* Provides an interface for generating Mail:: objects of various
|
||||
* types
|
||||
*
|
||||
* @param string $driver The kind of Mail:: object to instantiate.
|
||||
* @param array $params The parameters to pass to the Mail:: object.
|
||||
*
|
||||
* @return object Mail a instance of the driver class or if fails a PEAR Error
|
||||
*/
|
||||
public static function factory($driver, $params = array())
|
||||
{
|
||||
$driver = strtolower($driver);
|
||||
@include_once 'Mail/' . $driver . '.php';
|
||||
$class = 'Mail_' . $driver;
|
||||
if (class_exists($class)) {
|
||||
$mailer = new $class($params);
|
||||
return $mailer;
|
||||
} else {
|
||||
return PEAR::raiseError('Unable to find class for driver ' . $driver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail::send() function using php's built-in mail()
|
||||
* command.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*
|
||||
* @deprecated use Mail_mail::send instead
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$result = $this->_sanitizeHeaders($headers);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// if we're passed an array of recipients, implode it.
|
||||
if (is_array($recipients)) {
|
||||
$recipients = implode(', ', $recipients);
|
||||
}
|
||||
|
||||
// get the Subject out of the headers array so that we can
|
||||
// pass it as a seperate argument to mail().
|
||||
$subject = '';
|
||||
if (isset($headers['Subject'])) {
|
||||
$subject = $headers['Subject'];
|
||||
unset($headers['Subject']);
|
||||
}
|
||||
|
||||
// flatten the headers out.
|
||||
list(, $text_headers) = Mail::prepareHeaders($headers);
|
||||
|
||||
return mail($recipients, $subject, $body, $text_headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize an array of mail headers by removing any additional header
|
||||
* strings present in a legitimate header's value. The goal of this
|
||||
* filter is to prevent mail injection attacks.
|
||||
*
|
||||
* @param array $headers The associative array of headers to sanitize.
|
||||
*/
|
||||
protected function _sanitizeHeaders(&$headers)
|
||||
{
|
||||
foreach ($headers as $key => $value) {
|
||||
$headers[$key] =
|
||||
preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
|
||||
null, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Take an array of mail headers and return a string containing
|
||||
* text usable in sending a message.
|
||||
*
|
||||
* @param array $headers The array of headers to prepare, in an associative
|
||||
* array, where the array key is the header name (ie,
|
||||
* 'Subject'), and the array value is the header
|
||||
* value (ie, 'test'). The header produced from those
|
||||
* values would be 'Subject: test'.
|
||||
*
|
||||
* @return mixed Returns false if it encounters a bad address,
|
||||
* otherwise returns an array containing two
|
||||
* elements: Any From: address found in the headers,
|
||||
* and the plain text version of the headers.
|
||||
*/
|
||||
protected function prepareHeaders($headers)
|
||||
{
|
||||
$lines = array();
|
||||
$from = null;
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
if (strcasecmp($key, 'From') === 0) {
|
||||
include_once 'Mail/RFC822.php';
|
||||
$parser = new Mail_RFC822();
|
||||
$addresses = $parser->parseAddressList($value, 'localhost', false);
|
||||
if (is_a($addresses, 'PEAR_Error')) {
|
||||
return $addresses;
|
||||
}
|
||||
|
||||
$from = $addresses[0]->mailbox . '@' . $addresses[0]->host;
|
||||
|
||||
// Reject envelope From: addresses with spaces.
|
||||
if (strstr($from, ' ')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lines[] = $key . ': ' . $value;
|
||||
} elseif (strcasecmp($key, 'Received') === 0) {
|
||||
$received = array();
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $line) {
|
||||
$received[] = $key . ': ' . $line;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$received[] = $key . ': ' . $value;
|
||||
}
|
||||
// Put Received: headers at the top. Spam detectors often
|
||||
// flag messages with Received: headers after the Subject:
|
||||
// as spam.
|
||||
$lines = array_merge($received, $lines);
|
||||
} else {
|
||||
// If $value is an array (i.e., a list of addresses), convert
|
||||
// it to a comma-delimited string of its elements (addresses).
|
||||
if (is_array($value)) {
|
||||
$value = implode(', ', $value);
|
||||
}
|
||||
$lines[] = $key . ': ' . $value;
|
||||
}
|
||||
}
|
||||
|
||||
return array($from, join($this->sep, $lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a set of recipients and parse them, returning an array of
|
||||
* bare addresses (forward paths) that can be passed to sendmail
|
||||
* or an smtp server with the rcpt to: command.
|
||||
*
|
||||
* @param mixed Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid.
|
||||
*
|
||||
* @return mixed An array of forward paths (bare addresses) or a PEAR_Error
|
||||
* object if the address list could not be parsed.
|
||||
*/
|
||||
protected function parseRecipients($recipients)
|
||||
{
|
||||
include_once 'Mail/RFC822.php';
|
||||
|
||||
// if we're passed an array, assume addresses are valid and
|
||||
// implode them before parsing.
|
||||
if (is_array($recipients)) {
|
||||
$recipients = implode(', ', $recipients);
|
||||
}
|
||||
|
||||
// Parse recipients, leaving out all personal info. This is
|
||||
// for smtp recipients, etc. All relevant personal information
|
||||
// should already be in the headers.
|
||||
$Mail_RFC822 = new Mail_RFC822();
|
||||
$addresses = $Mail_RFC822->parseAddressList($recipients, 'localhost', false);
|
||||
|
||||
// If parseAddressList() returned a PEAR_Error object, just return it.
|
||||
if (is_a($addresses, 'PEAR_Error')) {
|
||||
return $addresses;
|
||||
}
|
||||
|
||||
$recipients = array();
|
||||
if (is_array($addresses)) {
|
||||
foreach ($addresses as $ob) {
|
||||
$recipients[] = $ob->mailbox . '@' . $ob->host;
|
||||
}
|
||||
}
|
||||
|
||||
return $recipients;
|
||||
}
|
||||
|
||||
}
|
||||
929
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/RFC822.php
Normal file
929
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/RFC822.php
Normal file
@ -0,0 +1,929 @@
|
||||
<?php
|
||||
/**
|
||||
* RFC 822 Email address list validation Utility
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2001-2017, Chuck Hagenbuch & Richard Heyes
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Richard Heyes <richard@phpguru.org>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org
|
||||
* @copyright 2001-2017 Richard Heyes
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/**
|
||||
* RFC 822 Email address list validation Utility
|
||||
*
|
||||
* What is it?
|
||||
*
|
||||
* This class will take an address string, and parse it into it's consituent
|
||||
* parts, be that either addresses, groups, or combinations. Nested groups
|
||||
* are not supported. The structure it returns is pretty straight forward,
|
||||
* and is similar to that provided by the imap_rfc822_parse_adrlist(). Use
|
||||
* print_r() to view the structure.
|
||||
*
|
||||
* How do I use it?
|
||||
*
|
||||
* $address_string = 'My Group: "Richard" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
|
||||
* $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', true)
|
||||
* print_r($structure);
|
||||
*
|
||||
* @author Richard Heyes <richard@phpguru.org>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @version $Revision$
|
||||
* @license BSD
|
||||
* @package Mail
|
||||
*/
|
||||
class Mail_RFC822 {
|
||||
|
||||
/**
|
||||
* The address being parsed by the RFC822 object.
|
||||
* @var string $address
|
||||
*/
|
||||
var $address = '';
|
||||
|
||||
/**
|
||||
* The default domain to use for unqualified addresses.
|
||||
* @var string $default_domain
|
||||
*/
|
||||
var $default_domain = 'localhost';
|
||||
|
||||
/**
|
||||
* Should we return a nested array showing groups, or flatten everything?
|
||||
* @var boolean $nestGroups
|
||||
*/
|
||||
var $nestGroups = true;
|
||||
|
||||
/**
|
||||
* Whether or not to validate atoms for non-ascii characters.
|
||||
* @var boolean $validate
|
||||
*/
|
||||
var $validate = true;
|
||||
|
||||
/**
|
||||
* The array of raw addresses built up as we parse.
|
||||
* @var array $addresses
|
||||
*/
|
||||
var $addresses = array();
|
||||
|
||||
/**
|
||||
* The final array of parsed address information that we build up.
|
||||
* @var array $structure
|
||||
*/
|
||||
var $structure = array();
|
||||
|
||||
/**
|
||||
* The current error message, if any.
|
||||
* @var string $error
|
||||
*/
|
||||
var $error = null;
|
||||
|
||||
/**
|
||||
* An internal counter/pointer.
|
||||
* @var integer $index
|
||||
*/
|
||||
var $index = null;
|
||||
|
||||
/**
|
||||
* The number of groups that have been found in the address list.
|
||||
* @var integer $num_groups
|
||||
* @access public
|
||||
*/
|
||||
var $num_groups = 0;
|
||||
|
||||
/**
|
||||
* A variable so that we can tell whether or not we're inside a
|
||||
* Mail_RFC822 object.
|
||||
* @var boolean $mailRFC822
|
||||
*/
|
||||
var $mailRFC822 = true;
|
||||
|
||||
/**
|
||||
* A limit after which processing stops
|
||||
* @var int $limit
|
||||
*/
|
||||
var $limit = null;
|
||||
|
||||
/**
|
||||
* Sets up the object. The address must either be set here or when
|
||||
* calling parseAddressList(). One or the other.
|
||||
*
|
||||
* @param string $address The address(es) to validate.
|
||||
* @param string $default_domain Default domain/host etc. If not supplied, will be set to localhost.
|
||||
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
|
||||
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
|
||||
*
|
||||
* @return object Mail_RFC822 A new Mail_RFC822 object.
|
||||
*/
|
||||
public function __construct($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
|
||||
{
|
||||
if (isset($address)) $this->address = $address;
|
||||
if (isset($default_domain)) $this->default_domain = $default_domain;
|
||||
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
|
||||
if (isset($validate)) $this->validate = $validate;
|
||||
if (isset($limit)) $this->limit = $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the whole process. The address must either be set here
|
||||
* or when creating the object. One or the other.
|
||||
*
|
||||
* @param string $address The address(es) to validate.
|
||||
* @param string $default_domain Default domain/host etc.
|
||||
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
|
||||
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
|
||||
*
|
||||
* @return array A structured array of addresses.
|
||||
*/
|
||||
public function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
|
||||
{
|
||||
if (!isset($this) || !isset($this->mailRFC822)) {
|
||||
$obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
|
||||
return $obj->parseAddressList();
|
||||
}
|
||||
|
||||
if (isset($address)) $this->address = $address;
|
||||
if (isset($default_domain)) $this->default_domain = $default_domain;
|
||||
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
|
||||
if (isset($validate)) $this->validate = $validate;
|
||||
if (isset($limit)) $this->limit = $limit;
|
||||
|
||||
$this->structure = array();
|
||||
$this->addresses = array();
|
||||
$this->error = null;
|
||||
$this->index = null;
|
||||
|
||||
// Unfold any long lines in $this->address.
|
||||
$this->address = preg_replace('/\r?\n/', "\r\n", $this->address);
|
||||
$this->address = preg_replace('/\r\n(\t| )+/', ' ', $this->address);
|
||||
|
||||
while ($this->address = $this->_splitAddresses($this->address));
|
||||
|
||||
if ($this->address === false || isset($this->error)) {
|
||||
require_once 'PEAR.php';
|
||||
return PEAR::raiseError($this->error);
|
||||
}
|
||||
|
||||
// Validate each address individually. If we encounter an invalid
|
||||
// address, stop iterating and return an error immediately.
|
||||
foreach ($this->addresses as $address) {
|
||||
$valid = $this->_validateAddress($address);
|
||||
|
||||
if ($valid === false || isset($this->error)) {
|
||||
//require_once 'PEAR.php';
|
||||
return PEAR::raiseError($this->error);
|
||||
}
|
||||
|
||||
if (!$this->nestGroups) {
|
||||
$this->structure = array_merge($this->structure, $valid);
|
||||
} else {
|
||||
$this->structure[] = $valid;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits an address into separate addresses.
|
||||
*
|
||||
* @param string $address The addresses to split.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _splitAddresses($address)
|
||||
{
|
||||
if (!empty($this->limit) && count($this->addresses) == $this->limit) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($this->_isGroup($address) && !isset($this->error)) {
|
||||
$split_char = ';';
|
||||
$is_group = true;
|
||||
} elseif (!isset($this->error)) {
|
||||
$split_char = ',';
|
||||
$is_group = false;
|
||||
} elseif (isset($this->error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Split the string based on the above ten or so lines.
|
||||
$parts = explode($split_char, $address);
|
||||
$string = $this->_splitCheck($parts, $split_char);
|
||||
|
||||
// If a group...
|
||||
if ($is_group) {
|
||||
// If $string does not contain a colon outside of
|
||||
// brackets/quotes etc then something's fubar.
|
||||
|
||||
// First check there's a colon at all:
|
||||
if (strpos($string, ':') === false) {
|
||||
$this->error = 'Invalid address: ' . $string;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now check it's outside of brackets/quotes:
|
||||
if (!$this->_splitCheck(explode(':', $string), ':')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We must have a group at this point, so increase the counter:
|
||||
$this->num_groups++;
|
||||
}
|
||||
|
||||
// $string now contains the first full address/group.
|
||||
// Add to the addresses array.
|
||||
$this->addresses[] = array(
|
||||
'address' => trim($string),
|
||||
'group' => $is_group
|
||||
);
|
||||
|
||||
// Remove the now stored address from the initial line, the +1
|
||||
// is to account for the explode character.
|
||||
$address = trim(substr($address, strlen($string) + 1));
|
||||
|
||||
// If the next char is a comma and this was a group, then
|
||||
// there are more addresses, otherwise, if there are any more
|
||||
// chars, then there is another address.
|
||||
if ($is_group && substr($address, 0, 1) == ','){
|
||||
$address = trim(substr($address, 1));
|
||||
return $address;
|
||||
|
||||
} elseif (strlen($address) > 0) {
|
||||
return $address;
|
||||
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
// If you got here then something's off
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a group at the start of the string.
|
||||
*
|
||||
* @param string $address The address to check.
|
||||
* @return boolean Whether or not there is a group at the start of the string.
|
||||
*/
|
||||
protected function _isGroup($address)
|
||||
{
|
||||
// First comma not in quotes, angles or escaped:
|
||||
$parts = explode(',', $address);
|
||||
$string = $this->_splitCheck($parts, ',');
|
||||
|
||||
// Now we have the first address, we can reliably check for a
|
||||
// group by searching for a colon that's not escaped or in
|
||||
// quotes or angle brackets.
|
||||
if (count($parts = explode(':', $string)) > 1) {
|
||||
$string2 = $this->_splitCheck($parts, ':');
|
||||
return ($string2 !== $string);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A common function that will check an exploded string.
|
||||
*
|
||||
* @param array $parts The exloded string.
|
||||
* @param string $char The char that was exploded on.
|
||||
* @return mixed False if the string contains unclosed quotes/brackets, or the string on success.
|
||||
*/
|
||||
protected function _splitCheck($parts, $char)
|
||||
{
|
||||
$string = $parts[0];
|
||||
|
||||
for ($i = 0; $i < count($parts); $i++) {
|
||||
if ($this->_hasUnclosedQuotes($string)
|
||||
|| $this->_hasUnclosedBrackets($string, '<>')
|
||||
|| $this->_hasUnclosedBrackets($string, '[]')
|
||||
|| $this->_hasUnclosedBrackets($string, '()')
|
||||
|| substr($string, -1) == '\\') {
|
||||
if (isset($parts[$i + 1])) {
|
||||
$string = $string . $char . $parts[$i + 1];
|
||||
} else {
|
||||
$this->error = 'Invalid address spec. Unclosed bracket or quotes';
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->index = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string has unclosed quotes or not.
|
||||
*
|
||||
* @param string $string The string to check.
|
||||
* @return boolean True if there are unclosed quotes inside the string,
|
||||
* false otherwise.
|
||||
*/
|
||||
protected function _hasUnclosedQuotes($string)
|
||||
{
|
||||
$string = trim($string);
|
||||
$iMax = strlen($string);
|
||||
$in_quote = false;
|
||||
$i = $slashes = 0;
|
||||
|
||||
for (; $i < $iMax; ++$i) {
|
||||
switch ($string[$i]) {
|
||||
case '\\':
|
||||
++$slashes;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if ($slashes % 2 == 0) {
|
||||
$in_quote = !$in_quote;
|
||||
}
|
||||
// Fall through to default action below.
|
||||
|
||||
default:
|
||||
$slashes = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $in_quote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string has an unclosed brackets or not. IMPORTANT:
|
||||
* This function handles both angle brackets and square brackets;
|
||||
*
|
||||
* @param string $string The string to check.
|
||||
* @param string $chars The characters to check for.
|
||||
* @return boolean True if there are unclosed brackets inside the string, false otherwise.
|
||||
*/
|
||||
protected function _hasUnclosedBrackets($string, $chars)
|
||||
{
|
||||
$num_angle_start = substr_count($string, $chars[0]);
|
||||
$num_angle_end = substr_count($string, $chars[1]);
|
||||
|
||||
$this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]);
|
||||
$this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]);
|
||||
|
||||
if ($num_angle_start < $num_angle_end) {
|
||||
$this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')';
|
||||
return false;
|
||||
} else {
|
||||
return ($num_angle_start > $num_angle_end);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sub function that is used only by hasUnclosedBrackets().
|
||||
*
|
||||
* @param string $string The string to check.
|
||||
* @param integer &$num The number of occurences.
|
||||
* @param string $char The character to count.
|
||||
* @return integer The number of occurences of $char in $string, adjusted for backslashes.
|
||||
*/
|
||||
protected function _hasUnclosedBracketsSub($string, &$num, $char)
|
||||
{
|
||||
$parts = explode($char, $string);
|
||||
for ($i = 0; $i < count($parts); $i++){
|
||||
if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i]))
|
||||
$num--;
|
||||
if (isset($parts[$i + 1]))
|
||||
$parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
|
||||
}
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to begin checking the address.
|
||||
*
|
||||
* @param string $address The address to validate.
|
||||
* @return mixed False on failure, or a structured array of address information on success.
|
||||
*/
|
||||
protected function _validateAddress($address)
|
||||
{
|
||||
$is_group = false;
|
||||
$addresses = array();
|
||||
|
||||
if ($address['group']) {
|
||||
$is_group = true;
|
||||
|
||||
// Get the group part of the name
|
||||
$parts = explode(':', $address['address']);
|
||||
$groupname = $this->_splitCheck($parts, ':');
|
||||
$structure = array();
|
||||
|
||||
// And validate the group part of the name.
|
||||
if (!$this->_validatePhrase($groupname)){
|
||||
$this->error = 'Group name did not validate.';
|
||||
return false;
|
||||
} else {
|
||||
// Don't include groups if we are not nesting
|
||||
// them. This avoids returning invalid addresses.
|
||||
if ($this->nestGroups) {
|
||||
$structure = new stdClass;
|
||||
$structure->groupname = $groupname;
|
||||
}
|
||||
}
|
||||
|
||||
$address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
|
||||
}
|
||||
|
||||
// If a group then split on comma and put into an array.
|
||||
// Otherwise, Just put the whole address in an array.
|
||||
if ($is_group) {
|
||||
while (strlen($address['address']) > 0) {
|
||||
$parts = explode(',', $address['address']);
|
||||
$addresses[] = $this->_splitCheck($parts, ',');
|
||||
$address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
|
||||
}
|
||||
} else {
|
||||
$addresses[] = $address['address'];
|
||||
}
|
||||
|
||||
// Trim the whitespace from all of the address strings.
|
||||
array_map('trim', $addresses);
|
||||
|
||||
// Validate each mailbox.
|
||||
// Format could be one of: name <geezer@domain.com>
|
||||
// geezer@domain.com
|
||||
// geezer
|
||||
// ... or any other format valid by RFC 822.
|
||||
for ($i = 0; $i < count($addresses); $i++) {
|
||||
if (!$this->validateMailbox($addresses[$i])) {
|
||||
if (empty($this->error)) {
|
||||
$this->error = 'Validation failed for: ' . $addresses[$i];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Nested format
|
||||
if ($this->nestGroups) {
|
||||
if ($is_group) {
|
||||
$structure->addresses = $addresses;
|
||||
} else {
|
||||
$structure = $addresses[0];
|
||||
}
|
||||
|
||||
// Flat format
|
||||
} else {
|
||||
if ($is_group) {
|
||||
$structure = array_merge($structure, $addresses);
|
||||
} else {
|
||||
$structure = $addresses;
|
||||
}
|
||||
}
|
||||
|
||||
return $structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a phrase.
|
||||
*
|
||||
* @param string $phrase The phrase to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validatePhrase($phrase)
|
||||
{
|
||||
// Splits on one or more Tab or space.
|
||||
$parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$phrase_parts = array();
|
||||
while (count($parts) > 0){
|
||||
$phrase_parts[] = $this->_splitCheck($parts, ' ');
|
||||
for ($i = 0; $i < $this->index + 1; $i++)
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
foreach ($phrase_parts as $part) {
|
||||
// If quoted string:
|
||||
if (substr($part, 0, 1) == '"') {
|
||||
if (!$this->_validateQuotedString($part)) {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise it's an atom:
|
||||
if (!$this->_validateAtom($part)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate an atom which from rfc822 is:
|
||||
* atom = 1*<any CHAR except specials, SPACE and CTLs>
|
||||
*
|
||||
* If validation ($this->validate) has been turned off, then
|
||||
* validateAtom() doesn't actually check anything. This is so that you
|
||||
* can split a list of addresses up before encoding personal names
|
||||
* (umlauts, etc.), for example.
|
||||
*
|
||||
* @param string $atom The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validateAtom($atom)
|
||||
{
|
||||
if (!$this->validate) {
|
||||
// Validation has been turned off; assume the atom is okay.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for any char from ASCII 0 - ASCII 127
|
||||
if (!preg_match('/^[\\x00-\\x7E]+$/i', $atom, $matches)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for specials:
|
||||
if (preg_match('/[][()<>@,;\\:". ]/', $atom)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for control characters (ASCII 0-31):
|
||||
if (preg_match('/[\\x00-\\x1F]+/', $atom)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate quoted string, which is:
|
||||
* quoted-string = <"> *(qtext/quoted-pair) <">
|
||||
*
|
||||
* @param string $qstring The string to check
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validateQuotedString($qstring)
|
||||
{
|
||||
// Leading and trailing "
|
||||
$qstring = substr($qstring, 1, -1);
|
||||
|
||||
// Perform check, removing quoted characters first.
|
||||
return !preg_match('/[\x0D\\\\"]/', preg_replace('/\\\\./', '', $qstring));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a mailbox, which is:
|
||||
* mailbox = addr-spec ; simple address
|
||||
* / phrase route-addr ; name and route-addr
|
||||
*
|
||||
* @param string &$mailbox The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
public function validateMailbox(&$mailbox)
|
||||
{
|
||||
// A couple of defaults.
|
||||
$phrase = '';
|
||||
$comment = '';
|
||||
$comments = array();
|
||||
|
||||
// Catch any RFC822 comments and store them separately.
|
||||
$_mailbox = $mailbox;
|
||||
while (strlen(trim($_mailbox)) > 0) {
|
||||
$parts = explode('(', $_mailbox);
|
||||
$before_comment = $this->_splitCheck($parts, '(');
|
||||
if ($before_comment != $_mailbox) {
|
||||
// First char should be a (.
|
||||
$comment = substr(str_replace($before_comment, '', $_mailbox), 1);
|
||||
$parts = explode(')', $comment);
|
||||
$comment = $this->_splitCheck($parts, ')');
|
||||
$comments[] = $comment;
|
||||
|
||||
// +2 is for the brackets
|
||||
$_mailbox = substr($_mailbox, strpos($_mailbox, '('.$comment)+strlen($comment)+2);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($comments as $comment) {
|
||||
$mailbox = str_replace("($comment)", '', $mailbox);
|
||||
}
|
||||
|
||||
$mailbox = trim($mailbox);
|
||||
|
||||
// Check for name + route-addr
|
||||
if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') {
|
||||
$parts = explode('<', $mailbox);
|
||||
$name = $this->_splitCheck($parts, '<');
|
||||
|
||||
$phrase = trim($name);
|
||||
$route_addr = trim(substr($mailbox, strlen($name.'<'), -1));
|
||||
|
||||
if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only got addr-spec
|
||||
} else {
|
||||
// First snip angle brackets if present.
|
||||
if (substr($mailbox, 0, 1) == '<' && substr($mailbox, -1) == '>') {
|
||||
$addr_spec = substr($mailbox, 1, -1);
|
||||
} else {
|
||||
$addr_spec = $mailbox;
|
||||
}
|
||||
|
||||
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the object that will be returned.
|
||||
$mbox = new stdClass();
|
||||
|
||||
// Add the phrase (even if empty) and comments
|
||||
$mbox->personal = $phrase;
|
||||
$mbox->comment = isset($comments) ? $comments : array();
|
||||
|
||||
if (isset($route_addr)) {
|
||||
$mbox->mailbox = $route_addr['local_part'];
|
||||
$mbox->host = $route_addr['domain'];
|
||||
$route_addr['adl'] !== '' ? $mbox->adl = $route_addr['adl'] : '';
|
||||
} else {
|
||||
$mbox->mailbox = $addr_spec['local_part'];
|
||||
$mbox->host = $addr_spec['domain'];
|
||||
}
|
||||
|
||||
$mailbox = $mbox;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function validates a route-addr which is:
|
||||
* route-addr = "<" [route] addr-spec ">"
|
||||
*
|
||||
* Angle brackets have already been removed at the point of
|
||||
* getting to this function.
|
||||
*
|
||||
* @param string $route_addr The string to check.
|
||||
* @return mixed False on failure, or an array containing validated address/route information on success.
|
||||
*/
|
||||
protected function _validateRouteAddr($route_addr)
|
||||
{
|
||||
// Check for colon.
|
||||
if (strpos($route_addr, ':') !== false) {
|
||||
$parts = explode(':', $route_addr);
|
||||
$route = $this->_splitCheck($parts, ':');
|
||||
} else {
|
||||
$route = $route_addr;
|
||||
}
|
||||
|
||||
// If $route is same as $route_addr then the colon was in
|
||||
// quotes or brackets or, of course, non existent.
|
||||
if ($route === $route_addr){
|
||||
unset($route);
|
||||
$addr_spec = $route_addr;
|
||||
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Validate route part.
|
||||
if (($route = $this->_validateRoute($route)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$addr_spec = substr($route_addr, strlen($route . ':'));
|
||||
|
||||
// Validate addr-spec part.
|
||||
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($route)) {
|
||||
$return['adl'] = $route;
|
||||
} else {
|
||||
$return['adl'] = '';
|
||||
}
|
||||
|
||||
$return = array_merge($return, $addr_spec);
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a route, which is:
|
||||
* route = 1#("@" domain) ":"
|
||||
*
|
||||
* @param string $route The string to check.
|
||||
* @return mixed False on failure, or the validated $route on success.
|
||||
*/
|
||||
protected function _validateRoute($route)
|
||||
{
|
||||
// Split on comma.
|
||||
$domains = explode(',', trim($route));
|
||||
|
||||
foreach ($domains as $domain) {
|
||||
$domain = str_replace('@', '', trim($domain));
|
||||
if (!$this->_validateDomain($domain)) return false;
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a domain, though this is not quite what
|
||||
* you expect of a strict internet domain.
|
||||
*
|
||||
* domain = sub-domain *("." sub-domain)
|
||||
*
|
||||
* @param string $domain The string to check.
|
||||
* @return mixed False on failure, or the validated domain on success.
|
||||
*/
|
||||
protected function _validateDomain($domain)
|
||||
{
|
||||
// Note the different use of $subdomains and $sub_domains
|
||||
$subdomains = explode('.', $domain);
|
||||
|
||||
while (count($subdomains) > 0) {
|
||||
$sub_domains[] = $this->_splitCheck($subdomains, '.');
|
||||
for ($i = 0; $i < $this->index + 1; $i++)
|
||||
array_shift($subdomains);
|
||||
}
|
||||
|
||||
foreach ($sub_domains as $sub_domain) {
|
||||
if (!$this->_validateSubdomain(trim($sub_domain)))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Managed to get here, so return input.
|
||||
return $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a subdomain:
|
||||
* subdomain = domain-ref / domain-literal
|
||||
*
|
||||
* @param string $subdomain The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validateSubdomain($subdomain)
|
||||
{
|
||||
if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
|
||||
if (!$this->_validateDliteral($arr[1])) return false;
|
||||
} else {
|
||||
if (!$this->_validateAtom($subdomain)) return false;
|
||||
}
|
||||
|
||||
// Got here, so return successful.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate a domain literal:
|
||||
* domain-literal = "[" *(dtext / quoted-pair) "]"
|
||||
*
|
||||
* @param string $dliteral The string to check.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
protected function _validateDliteral($dliteral)
|
||||
{
|
||||
return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && ((! isset($matches[1])) || $matches[1] != '\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate an addr-spec.
|
||||
*
|
||||
* addr-spec = local-part "@" domain
|
||||
*
|
||||
* @param string $addr_spec The string to check.
|
||||
* @return mixed False on failure, or the validated addr-spec on success.
|
||||
*/
|
||||
protected function _validateAddrSpec($addr_spec)
|
||||
{
|
||||
$addr_spec = trim($addr_spec);
|
||||
|
||||
// Split on @ sign if there is one.
|
||||
if (strpos($addr_spec, '@') !== false) {
|
||||
$parts = explode('@', $addr_spec);
|
||||
$local_part = $this->_splitCheck($parts, '@');
|
||||
$domain = substr($addr_spec, strlen($local_part . '@'));
|
||||
|
||||
// No @ sign so assume the default domain.
|
||||
} else {
|
||||
$local_part = $addr_spec;
|
||||
$domain = $this->default_domain;
|
||||
}
|
||||
|
||||
if (($local_part = $this->_validateLocalPart($local_part)) === false) return false;
|
||||
if (($domain = $this->_validateDomain($domain)) === false) return false;
|
||||
|
||||
// Got here so return successful.
|
||||
return array('local_part' => $local_part, 'domain' => $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to validate the local part of an address:
|
||||
* local-part = word *("." word)
|
||||
*
|
||||
* @param string $local_part
|
||||
* @return mixed False on failure, or the validated local part on success.
|
||||
*/
|
||||
protected function _validateLocalPart($local_part)
|
||||
{
|
||||
$parts = explode('.', $local_part);
|
||||
$words = array();
|
||||
|
||||
// Split the local_part into words.
|
||||
while (count($parts) > 0) {
|
||||
$words[] = $this->_splitCheck($parts, '.');
|
||||
for ($i = 0; $i < $this->index + 1; $i++) {
|
||||
array_shift($parts);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate each word.
|
||||
foreach ($words as $word) {
|
||||
// word cannot be empty (#17317)
|
||||
if ($word === '') {
|
||||
return false;
|
||||
}
|
||||
// If this word contains an unquoted space, it is invalid. (6.2.4)
|
||||
if (strpos($word, ' ') && $word[0] !== '"')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->_validatePhrase(trim($word)) === false) return false;
|
||||
}
|
||||
|
||||
// Managed to get here, so return the input.
|
||||
return $local_part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an approximate count of how many addresses are in the
|
||||
* given string. This is APPROXIMATE as it only splits based on a
|
||||
* comma which has no preceding backslash. Could be useful as
|
||||
* large amounts of addresses will end up producing *large*
|
||||
* structures when used with parseAddressList().
|
||||
*
|
||||
* @param string $data Addresses to count
|
||||
* @return int Approximate count
|
||||
*/
|
||||
public function approximateCount($data)
|
||||
{
|
||||
return count(preg_split('/(?<!\\\\),/', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a email validating function separate to the rest of the
|
||||
* class. It simply validates whether an email is of the common
|
||||
* internet form: <user>@<domain>. This can be sufficient for most
|
||||
* people. Optional stricter mode can be utilised which restricts
|
||||
* mailbox characters allowed to alphanumeric, full stop, hyphen
|
||||
* and underscore.
|
||||
*
|
||||
* @param string $data Address to check
|
||||
* @param boolean $strict Optional stricter mode
|
||||
* @return mixed False if it fails, an indexed array
|
||||
* username/domain if it matches
|
||||
*/
|
||||
public function isValidInetAddress($data, $strict = false)
|
||||
{
|
||||
$regex = $strict ? '/^([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i';
|
||||
if (preg_match($regex, trim($data), $matches)) {
|
||||
return array($matches[1], $matches[2]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
168
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/mail.php
Normal file
168
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/mail.php
Normal file
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* internal PHP-mail() implementation of the PEAR Mail:: interface.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Chuck Hagenbuch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 2010-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/**
|
||||
* internal PHP-mail() implementation of the PEAR Mail:: interface.
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_mail extends Mail {
|
||||
|
||||
/**
|
||||
* Any arguments to pass to the mail() function.
|
||||
* @var string
|
||||
*/
|
||||
var $_params = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_mail:: object based on the parameters
|
||||
* passed in.
|
||||
*
|
||||
* @param array $params Extra arguments for the mail() function.
|
||||
*/
|
||||
public function __construct($params = null)
|
||||
{
|
||||
// The other mail implementations accept parameters as arrays.
|
||||
// In the interest of being consistent, explode an array into
|
||||
// a string of parameter arguments.
|
||||
if (is_array($params)) {
|
||||
$this->_params = join(' ', $params);
|
||||
} else {
|
||||
$this->_params = $params;
|
||||
}
|
||||
|
||||
/* Because the mail() function may pass headers as command
|
||||
* line arguments, we can't guarantee the use of the standard
|
||||
* "\r\n" separator. Instead, we use the system's native line
|
||||
* separator. */
|
||||
if (defined('PHP_EOL')) {
|
||||
$this->sep = PHP_EOL;
|
||||
} else {
|
||||
$this->sep = (strpos(PHP_OS, 'WIN') === false) ? "\n" : "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail_mail::send() function using php's built-in mail()
|
||||
* command.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$result = $this->_sanitizeHeaders($headers);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// If we're passed an array of recipients, implode it.
|
||||
if (is_array($recipients)) {
|
||||
$recipients = implode(', ', $recipients);
|
||||
}
|
||||
|
||||
// Get the Subject out of the headers array so that we can
|
||||
// pass it as a seperate argument to mail().
|
||||
$subject = '';
|
||||
if (isset($headers['Subject'])) {
|
||||
$subject = $headers['Subject'];
|
||||
unset($headers['Subject']);
|
||||
}
|
||||
|
||||
// Also remove the To: header. The mail() function will add its own
|
||||
// To: header based on the contents of $recipients.
|
||||
unset($headers['To']);
|
||||
|
||||
// Flatten the headers out.
|
||||
$headerElements = $this->prepareHeaders($headers);
|
||||
if (is_a($headerElements, 'PEAR_Error')) {
|
||||
return $headerElements;
|
||||
}
|
||||
list(, $text_headers) = $headerElements;
|
||||
|
||||
// We only use mail()'s optional fifth parameter if the additional
|
||||
// parameters have been provided and we're not running in safe mode.
|
||||
if (empty($this->_params) || ini_get('safe_mode')) {
|
||||
$result = mail($recipients, $subject, $body, $text_headers);
|
||||
} else {
|
||||
$result = mail($recipients, $subject, $body, $text_headers,
|
||||
$this->_params);
|
||||
}
|
||||
|
||||
// If the mail() function returned failure, we need to create a
|
||||
// PEAR_Error object and return it instead of the boolean result.
|
||||
if ($result === false) {
|
||||
$result = PEAR::raiseError('mail() returned failure');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
142
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/mock.php
Normal file
142
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/mock.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* Mock implementation
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Chuck Hagenbuch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 2010-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Mock implementation of the PEAR Mail:: interface for testing.
|
||||
* @access public
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_mock extends Mail {
|
||||
|
||||
/**
|
||||
* Array of messages that have been sent with the mock.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $sentMessages = array();
|
||||
|
||||
/**
|
||||
* Callback before sending mail.
|
||||
*
|
||||
* @var callback
|
||||
*/
|
||||
protected $_preSendCallback;
|
||||
|
||||
/**
|
||||
* Callback after sending mai.
|
||||
*
|
||||
* @var callback
|
||||
*/
|
||||
protected $_postSendCallback;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_mock:: object based on the parameters
|
||||
* passed in. It looks for the following parameters, both optional:
|
||||
* preSendCallback Called before an email would be sent.
|
||||
* postSendCallback Called after an email would have been sent.
|
||||
*
|
||||
* @param array Hash containing any parameters.
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (isset($params['preSendCallback']) &&
|
||||
is_callable($params['preSendCallback'])) {
|
||||
$this->_preSendCallback = $params['preSendCallback'];
|
||||
}
|
||||
|
||||
if (isset($params['postSendCallback']) &&
|
||||
is_callable($params['postSendCallback'])) {
|
||||
$this->_postSendCallback = $params['postSendCallback'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail_mock::send() function. Silently discards all
|
||||
* mail.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
if ($this->_preSendCallback) {
|
||||
call_user_func_array($this->_preSendCallback,
|
||||
array(&$this, $recipients, $headers, $body));
|
||||
}
|
||||
|
||||
$entry = array('recipients' => $recipients, 'headers' => $headers, 'body' => $body);
|
||||
$this->sentMessages[] = $entry;
|
||||
|
||||
if ($this->_postSendCallback) {
|
||||
call_user_func_array($this->_postSendCallback,
|
||||
array(&$this, $recipients, $headers, $body));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
85
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/null.php
Normal file
85
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/null.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* Null implementation of the PEAR Mail interface
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Phil Kernick
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Phil Kernick <philk@rotfl.com.au>
|
||||
* @copyright 2010-2017 Phil Kernick
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Null implementation of the PEAR Mail:: interface.
|
||||
* @access public
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_null extends Mail {
|
||||
|
||||
/**
|
||||
* Implements Mail_null::send() function. Silently discards all
|
||||
* mail.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
199
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/sendmail.php
Normal file
199
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/sendmail.php
Normal file
@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/**
|
||||
* Sendmail implementation of the PEAR Mail interface.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Chuck Hagenbuch & Jon Parise
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail
|
||||
* @author Jon Parise <jon@php.net>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 2010-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sendmail implementation of the PEAR Mail:: interface.
|
||||
* @access public
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_sendmail extends Mail {
|
||||
|
||||
/**
|
||||
* The location of the sendmail or sendmail wrapper binary on the
|
||||
* filesystem.
|
||||
* @var string
|
||||
*/
|
||||
var $sendmail_path = '/usr/sbin/sendmail';
|
||||
|
||||
/**
|
||||
* Any extra command-line parameters to pass to the sendmail or
|
||||
* sendmail wrapper binary.
|
||||
* @var string
|
||||
*/
|
||||
var $sendmail_args = '-i';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_sendmail:: object based on the parameters
|
||||
* passed in. It looks for the following parameters:
|
||||
* sendmail_path The location of the sendmail binary on the
|
||||
* filesystem. Defaults to '/usr/sbin/sendmail'.
|
||||
*
|
||||
* sendmail_args Any extra parameters to pass to the sendmail
|
||||
* or sendmail wrapper binary.
|
||||
*
|
||||
* If a parameter is present in the $params array, it replaces the
|
||||
* default.
|
||||
*
|
||||
* @param array $params Hash containing any parameters different from the
|
||||
* defaults.
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (isset($params['sendmail_path'])) {
|
||||
$this->sendmail_path = $params['sendmail_path'];
|
||||
}
|
||||
if (isset($params['sendmail_args'])) {
|
||||
$this->sendmail_args = $params['sendmail_args'];
|
||||
}
|
||||
|
||||
/*
|
||||
* Because we need to pass message headers to the sendmail program on
|
||||
* the commandline, we can't guarantee the use of the standard "\r\n"
|
||||
* separator. Instead, we use the system's native line separator.
|
||||
*/
|
||||
if (defined('PHP_EOL')) {
|
||||
$this->sep = PHP_EOL;
|
||||
} else {
|
||||
$this->sep = (strpos(PHP_OS, 'WIN') === false) ? "\n" : "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail::send() function using the sendmail
|
||||
* command-line binary.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (ie, 'Subject'), and the array value
|
||||
* is the header value (ie, 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* Mime parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$result = $this->_sanitizeHeaders($headers);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$recipients = $this->parseRecipients($recipients);
|
||||
if (is_a($recipients, 'PEAR_Error')) {
|
||||
return $recipients;
|
||||
}
|
||||
$recipients = implode(' ', array_map('escapeshellarg', $recipients));
|
||||
|
||||
$headerElements = $this->prepareHeaders($headers);
|
||||
if (is_a($headerElements, 'PEAR_Error')) {
|
||||
return $headerElements;
|
||||
}
|
||||
list($from, $text_headers) = $headerElements;
|
||||
|
||||
/* Since few MTAs are going to allow this header to be forged
|
||||
* unless it's in the MAIL FROM: exchange, we'll use
|
||||
* Return-Path instead of From: if it's set. */
|
||||
if (!empty($headers['Return-Path'])) {
|
||||
$from = $headers['Return-Path'];
|
||||
}
|
||||
|
||||
if (!isset($from)) {
|
||||
return PEAR::raiseError('No from address given.');
|
||||
} elseif (strpos($from, ' ') !== false ||
|
||||
strpos($from, ';') !== false ||
|
||||
strpos($from, '&') !== false ||
|
||||
strpos($from, '`') !== false) {
|
||||
return PEAR::raiseError('From address specified with dangerous characters.');
|
||||
}
|
||||
|
||||
$from = escapeshellarg($from); // Security bug #16200
|
||||
|
||||
$mail = @popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . " -f$from -- $recipients", 'w');
|
||||
if (!$mail) {
|
||||
return PEAR::raiseError('Failed to open sendmail [' . $this->sendmail_path . '] for execution.');
|
||||
}
|
||||
|
||||
// Write the headers following by two newlines: one to end the headers
|
||||
// section and a second to separate the headers block from the body.
|
||||
fputs($mail, $text_headers . $this->sep . $this->sep);
|
||||
|
||||
fputs($mail, $body);
|
||||
$result = pclose($mail);
|
||||
if (version_compare(phpversion(), '4.2.3') == -1) {
|
||||
// With older php versions, we need to shift the pclose
|
||||
// result to get the exit code.
|
||||
$result = $result >> 8 & 0xFF;
|
||||
}
|
||||
|
||||
if ($result != 0) {
|
||||
return PEAR::raiseError('sendmail returned error code ' . $result,
|
||||
$result);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
459
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/smtp.php
Normal file
459
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/smtp.php
Normal file
@ -0,0 +1,459 @@
|
||||
<?php
|
||||
/**
|
||||
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017, Chuck Hagenbuch & Jon Parise
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request
|
||||
* @author Jon Parise <jon@php.net>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 2010-2017 Chuck Hagenbuch
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
/** Error: Failed to create a Net_SMTP object */
|
||||
define('PEAR_MAIL_SMTP_ERROR_CREATE', 10000);
|
||||
|
||||
/** Error: Failed to connect to SMTP server */
|
||||
define('PEAR_MAIL_SMTP_ERROR_CONNECT', 10001);
|
||||
|
||||
/** Error: SMTP authentication failure */
|
||||
define('PEAR_MAIL_SMTP_ERROR_AUTH', 10002);
|
||||
|
||||
/** Error: No From: address has been provided */
|
||||
define('PEAR_MAIL_SMTP_ERROR_FROM', 10003);
|
||||
|
||||
/** Error: Failed to set sender */
|
||||
define('PEAR_MAIL_SMTP_ERROR_SENDER', 10004);
|
||||
|
||||
/** Error: Failed to add recipient */
|
||||
define('PEAR_MAIL_SMTP_ERROR_RECIPIENT', 10005);
|
||||
|
||||
/** Error: Failed to send data */
|
||||
define('PEAR_MAIL_SMTP_ERROR_DATA', 10006);
|
||||
|
||||
/**
|
||||
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
|
||||
* @access public
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_smtp extends Mail {
|
||||
|
||||
/**
|
||||
* SMTP connection object.
|
||||
*
|
||||
* @var object
|
||||
* @access private
|
||||
*/
|
||||
var $_smtp = null;
|
||||
|
||||
/**
|
||||
* The list of service extension parameters to pass to the Net_SMTP
|
||||
* mailFrom() command.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $_extparams = array();
|
||||
|
||||
/**
|
||||
* The SMTP host to connect to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $host = 'localhost';
|
||||
|
||||
/**
|
||||
* The port the SMTP server is on.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $port = 25;
|
||||
|
||||
/**
|
||||
* Should SMTP authentication be used?
|
||||
*
|
||||
* This value may be set to true, false or the name of a specific
|
||||
* authentication method.
|
||||
*
|
||||
* If the value is set to true, the Net_SMTP package will attempt to use
|
||||
* the best authentication method advertised by the remote SMTP server.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
var $auth = false;
|
||||
|
||||
/**
|
||||
* The username to use if the SMTP server requires authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $username = '';
|
||||
|
||||
/**
|
||||
* The password to use if the SMTP server requires authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $password = '';
|
||||
|
||||
/**
|
||||
* Hostname or domain that will be sent to the remote SMTP server in the
|
||||
* HELO / EHLO message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $localhost = 'localhost';
|
||||
|
||||
/**
|
||||
* SMTP connection timeout value. NULL indicates no timeout.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $timeout = null;
|
||||
|
||||
/**
|
||||
* Turn on Net_SMTP debugging?
|
||||
*
|
||||
* @var boolean $debug
|
||||
*/
|
||||
var $debug = false;
|
||||
|
||||
/**
|
||||
* Indicates whether or not the SMTP connection should persist over
|
||||
* multiple calls to the send() method.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
var $persist = false;
|
||||
|
||||
/**
|
||||
* Use SMTP command pipelining (specified in RFC 2920) if the SMTP server
|
||||
* supports it. This speeds up delivery over high-latency connections. By
|
||||
* default, use the default value supplied by Net_SMTP.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
var $pipelining;
|
||||
|
||||
/**
|
||||
* The list of socket options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $socket_options = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_smtp:: object based on the parameters
|
||||
* passed in. It looks for the following parameters:
|
||||
* host The server to connect to. Defaults to localhost.
|
||||
* port The port to connect to. Defaults to 25.
|
||||
* auth SMTP authentication. Defaults to none.
|
||||
* username The username to use for SMTP auth. No default.
|
||||
* password The password to use for SMTP auth. No default.
|
||||
* localhost The local hostname / domain. Defaults to localhost.
|
||||
* timeout The SMTP connection timeout. Defaults to none.
|
||||
* verp Whether to use VERP or not. Defaults to false.
|
||||
* DEPRECATED as of 1.2.0 (use setMailParams()).
|
||||
* debug Activate SMTP debug mode? Defaults to false.
|
||||
* persist Should the SMTP connection persist?
|
||||
* pipelining Use SMTP command pipelining
|
||||
*
|
||||
* If a parameter is present in the $params array, it replaces the
|
||||
* default.
|
||||
*
|
||||
* @param array Hash containing any parameters different from the
|
||||
* defaults.
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
if (isset($params['host'])) $this->host = $params['host'];
|
||||
if (isset($params['port'])) $this->port = $params['port'];
|
||||
if (isset($params['auth'])) $this->auth = $params['auth'];
|
||||
if (isset($params['username'])) $this->username = $params['username'];
|
||||
if (isset($params['password'])) $this->password = $params['password'];
|
||||
if (isset($params['localhost'])) $this->localhost = $params['localhost'];
|
||||
if (isset($params['timeout'])) $this->timeout = $params['timeout'];
|
||||
if (isset($params['debug'])) $this->debug = (bool)$params['debug'];
|
||||
if (isset($params['persist'])) $this->persist = (bool)$params['persist'];
|
||||
if (isset($params['pipelining'])) $this->pipelining = (bool)$params['pipelining'];
|
||||
if (isset($params['socket_options'])) $this->socket_options = $params['socket_options'];
|
||||
// Deprecated options
|
||||
if (isset($params['verp'])) {
|
||||
$this->addServiceExtensionParameter('XVERP', is_bool($params['verp']) ? null : $params['verp']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor implementation to ensure that we disconnect from any
|
||||
* potentially-alive persistent SMTP connections.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail::send() function using SMTP.
|
||||
*
|
||||
* @param mixed $recipients Either a comma-seperated list of recipients
|
||||
* (RFC822 compliant), or an array of recipients,
|
||||
* each RFC822 valid. This may contain recipients not
|
||||
* specified in the headers, for Bcc:, resending
|
||||
* messages, etc.
|
||||
*
|
||||
* @param array $headers The array of headers to send with the mail, in an
|
||||
* associative array, where the array key is the
|
||||
* header name (e.g., 'Subject'), and the array value
|
||||
* is the header value (e.g., 'test'). The header
|
||||
* produced from those values would be 'Subject:
|
||||
* test'.
|
||||
*
|
||||
* @param string $body The full text of the message body, including any
|
||||
* MIME parts, etc.
|
||||
*
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
* containing a descriptive error message on
|
||||
* failure.
|
||||
*/
|
||||
public function send($recipients, $headers, $body)
|
||||
{
|
||||
$result = $this->send_or_fail($recipients, $headers, $body);
|
||||
|
||||
/* If persistent connections are disabled, destroy our SMTP object. */
|
||||
if ($this->persist === false) {
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function send_or_fail($recipients, $headers, $body)
|
||||
{
|
||||
/* If we don't already have an SMTP object, create one. */
|
||||
$result = $this->getSMTPObject();
|
||||
if (PEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$this->_sanitizeHeaders($headers);
|
||||
|
||||
$headerElements = $this->prepareHeaders($headers);
|
||||
if (is_a($headerElements, 'PEAR_Error')) {
|
||||
$this->_smtp->rset();
|
||||
return $headerElements;
|
||||
}
|
||||
list($from, $textHeaders) = $headerElements;
|
||||
|
||||
/* Since few MTAs are going to allow this header to be forged
|
||||
* unless it's in the MAIL FROM: exchange, we'll use
|
||||
* Return-Path instead of From: if it's set. */
|
||||
if (!empty($headers['Return-Path'])) {
|
||||
$from = $headers['Return-Path'];
|
||||
}
|
||||
|
||||
if (!isset($from)) {
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError('No From: address has been provided',
|
||||
PEAR_MAIL_SMTP_ERROR_FROM);
|
||||
}
|
||||
|
||||
$params = null;
|
||||
if (!empty($this->_extparams)) {
|
||||
foreach ($this->_extparams as $key => $val) {
|
||||
$params .= ' ' . $key . (is_null($val) ? '' : '=' . $val);
|
||||
}
|
||||
}
|
||||
if (PEAR::isError($res = $this->_smtp->mailFrom($from, ltrim($params)))) {
|
||||
$error = $this->_error("Failed to set sender: $from", $res);
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_SENDER);
|
||||
}
|
||||
|
||||
$recipients = $this->parseRecipients($recipients);
|
||||
if (is_a($recipients, 'PEAR_Error')) {
|
||||
$this->_smtp->rset();
|
||||
return $recipients;
|
||||
}
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
$res = $this->_smtp->rcptTo($recipient);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$error = $this->_error("Failed to add recipient: $recipient", $res);
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_RECIPIENT);
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the message's headers and the body as SMTP data. */
|
||||
$res = $this->_smtp->data($body, $textHeaders);
|
||||
list(,$args) = $this->_smtp->getResponse();
|
||||
|
||||
if (preg_match("/ queued as (.*)/", $args, $queued)) {
|
||||
$this->queued_as = $queued[1];
|
||||
}
|
||||
|
||||
/* we need the greeting; from it we can extract the authorative name of the mail server we've really connected to.
|
||||
* ideal if we're connecting to a round-robin of relay servers and need to track which exact one took the email */
|
||||
$this->greeting = $this->_smtp->getGreeting();
|
||||
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$error = $this->_error('Failed to send data', $res);
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the SMTP server by instantiating a Net_SMTP object.
|
||||
*
|
||||
* @return mixed Returns a reference to the Net_SMTP object on success, or
|
||||
* a PEAR_Error containing a descriptive error message on
|
||||
* failure.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function getSMTPObject()
|
||||
{
|
||||
if (is_object($this->_smtp) !== false) {
|
||||
return $this->_smtp;
|
||||
}
|
||||
$this->_smtp = new Net_SMTP($this->host,
|
||||
$this->port,
|
||||
$this->localhost,
|
||||
$this->pipelining,
|
||||
0,
|
||||
$this->socket_options);
|
||||
|
||||
/* If we still don't have an SMTP object at this point, fail. */
|
||||
if (is_object($this->_smtp) === false) {
|
||||
return PEAR::raiseError('Failed to create a Net_SMTP object',
|
||||
PEAR_MAIL_SMTP_ERROR_CREATE);
|
||||
}
|
||||
|
||||
/* Configure the SMTP connection. */
|
||||
if ($this->debug) {
|
||||
$this->_smtp->setDebug(true);
|
||||
}
|
||||
|
||||
/* Attempt to connect to the configured SMTP server. */
|
||||
if (PEAR::isError($res = $this->_smtp->connect($this->timeout))) {
|
||||
$error = $this->_error('Failed to connect to ' .
|
||||
$this->host . ':' . $this->port,
|
||||
$res);
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT);
|
||||
}
|
||||
|
||||
/* Attempt to authenticate if authentication has been enabled. */
|
||||
if ($this->auth) {
|
||||
$method = is_string($this->auth) ? $this->auth : '';
|
||||
|
||||
if (PEAR::isError($res = $this->_smtp->auth($this->username,
|
||||
$this->password,
|
||||
$method))) {
|
||||
$error = $this->_error("$method authentication failure",
|
||||
$res);
|
||||
$this->_smtp->rset();
|
||||
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_smtp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add parameter associated with a SMTP service extension.
|
||||
*
|
||||
* @param string Extension keyword.
|
||||
* @param string Any value the keyword needs.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public function addServiceExtensionParameter($keyword, $value = null)
|
||||
{
|
||||
$this->_extparams[$keyword] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect and destroy the current SMTP connection.
|
||||
*
|
||||
* @return boolean True if the SMTP connection no longer exists.
|
||||
*
|
||||
* @since 1.1.9
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
/* If we have an SMTP object, disconnect and destroy it. */
|
||||
if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
|
||||
$this->_smtp = null;
|
||||
}
|
||||
|
||||
/* We are disconnected if we no longer have an SMTP object. */
|
||||
return ($this->_smtp === null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a standardized string describing the current SMTP error.
|
||||
*
|
||||
* @param string $text Custom string describing the error context.
|
||||
* @param object $error Reference to the current PEAR_Error object.
|
||||
*
|
||||
* @return string A string describing the current SMTP error.
|
||||
*
|
||||
* @since 1.1.7
|
||||
*/
|
||||
protected function _error($text, $error)
|
||||
{
|
||||
/* Split the SMTP response into a code and a response string. */
|
||||
list($code, $response) = $this->_smtp->getResponse();
|
||||
|
||||
/* Build our standardized error string. */
|
||||
return $text
|
||||
. ' [SMTP: ' . $error->getMessage()
|
||||
. " (code: $code, response: $response)]";
|
||||
}
|
||||
|
||||
}
|
||||
504
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/smtpmx.php
Normal file
504
democracy/sai/saimod_beta/cannon/Pear/Mail/Mail/smtpmx.php
Normal file
@ -0,0 +1,504 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* SMTP MX
|
||||
*
|
||||
* SMTP MX implementation of the PEAR Mail interface. Requires the Net_SMTP class.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2010-2017 gERD Schaufelberger
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Mail
|
||||
* @package Mail_smtpmx
|
||||
* @author gERD Schaufelberger <gerd@php-tools.net>
|
||||
* @copyright 2010-2017 gERD Schaufelberger
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @link http://pear.php.net/package/Mail/
|
||||
*/
|
||||
|
||||
require_once 'Net/SMTP.php';
|
||||
|
||||
/**
|
||||
* SMTP MX implementation of the PEAR Mail interface. Requires the Net_SMTP class.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @author gERD Schaufelberger <gerd@php-tools.net>
|
||||
* @package Mail
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Mail_smtpmx extends Mail {
|
||||
|
||||
/**
|
||||
* SMTP connection object.
|
||||
*
|
||||
* @var object
|
||||
* @access private
|
||||
*/
|
||||
var $_smtp = null;
|
||||
|
||||
/**
|
||||
* The port the SMTP server is on.
|
||||
* @var integer
|
||||
* @see getservicebyname()
|
||||
*/
|
||||
var $port = 25;
|
||||
|
||||
/**
|
||||
* Hostname or domain that will be sent to the remote SMTP server in the
|
||||
* HELO / EHLO message.
|
||||
*
|
||||
* @var string
|
||||
* @see posix_uname()
|
||||
*/
|
||||
var $mailname = 'localhost';
|
||||
|
||||
/**
|
||||
* SMTP connection timeout value. NULL indicates no timeout.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $timeout = 10;
|
||||
|
||||
/**
|
||||
* use either PEAR:Net_DNS or getmxrr
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
var $withNetDns = true;
|
||||
|
||||
/**
|
||||
* PEAR:Net_DNS_Resolver
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
var $resolver;
|
||||
|
||||
/**
|
||||
* Whether to use VERP or not. If not a boolean, the string value
|
||||
* will be used as the VERP separators.
|
||||
*
|
||||
* @var mixed boolean or string
|
||||
*/
|
||||
var $verp = false;
|
||||
|
||||
/**
|
||||
* Whether to use VRFY or not.
|
||||
*
|
||||
* @var boolean $vrfy
|
||||
*/
|
||||
var $vrfy = false;
|
||||
|
||||
/**
|
||||
* Switch to test mode - don't send emails for real
|
||||
*
|
||||
* @var boolean $debug
|
||||
*/
|
||||
var $test = false;
|
||||
|
||||
/**
|
||||
* Turn on Net_SMTP debugging?
|
||||
*
|
||||
* @var boolean $peardebug
|
||||
*/
|
||||
var $debug = false;
|
||||
|
||||
/**
|
||||
* internal error codes
|
||||
*
|
||||
* translate internal error identifier to PEAR-Error codes and human
|
||||
* readable messages.
|
||||
*
|
||||
* @var boolean $debug
|
||||
* @todo as I need unique error-codes to identify what exactly went wrond
|
||||
* I did not use intergers as it should be. Instead I added a "namespace"
|
||||
* for each code. This avoids conflicts with error codes from different
|
||||
* classes. How can I use unique error codes and stay conform with PEAR?
|
||||
*/
|
||||
var $errorCode = array(
|
||||
'not_connected' => array(
|
||||
'code' => 1,
|
||||
'msg' => 'Could not connect to any mail server ({HOST}) at port {PORT} to send mail to {RCPT}.'
|
||||
),
|
||||
'failed_vrfy_rcpt' => array(
|
||||
'code' => 2,
|
||||
'msg' => 'Recipient "{RCPT}" could not be veryfied.'
|
||||
),
|
||||
'failed_set_from' => array(
|
||||
'code' => 3,
|
||||
'msg' => 'Failed to set sender: {FROM}.'
|
||||
),
|
||||
'failed_set_rcpt' => array(
|
||||
'code' => 4,
|
||||
'msg' => 'Failed to set recipient: {RCPT}.'
|
||||
),
|
||||
'failed_send_data' => array(
|
||||
'code' => 5,
|
||||
'msg' => 'Failed to send mail to: {RCPT}.'
|
||||
),
|
||||
'no_from' => array(
|
||||
'code' => 5,
|
||||
'msg' => 'No from address has be provided.'
|
||||
),
|
||||
'send_data' => array(
|
||||
'code' => 7,
|
||||
'msg' => 'Failed to create Net_SMTP object.'
|
||||
),
|
||||
'no_mx' => array(
|
||||
'code' => 8,
|
||||
'msg' => 'No MX-record for {RCPT} found.'
|
||||
),
|
||||
'no_resolver' => array(
|
||||
'code' => 9,
|
||||
'msg' => 'Could not start resolver! Install PEAR:Net_DNS or switch off "netdns"'
|
||||
),
|
||||
'failed_rset' => array(
|
||||
'code' => 10,
|
||||
'msg' => 'RSET command failed, SMTP-connection corrupt.'
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Instantiates a new Mail_smtp:: object based on the parameters
|
||||
* passed in. It looks for the following parameters:
|
||||
* mailname The name of the local mail system (a valid hostname which matches the reverse lookup)
|
||||
* port smtp-port - the default comes from getservicebyname() and should work fine
|
||||
* timeout The SMTP connection timeout. Defaults to 30 seconds.
|
||||
* vrfy Whether to use VRFY or not. Defaults to false.
|
||||
* verp Whether to use VERP or not. Defaults to false.
|
||||
* test Activate test mode? Defaults to false.
|
||||
* debug Activate SMTP and Net_DNS debug mode? Defaults to false.
|
||||
* netdns whether to use PEAR:Net_DNS or the PHP build in function getmxrr, default is true
|
||||
*
|
||||
* If a parameter is present in the $params array, it replaces the
|
||||
* default.
|
||||
*
|
||||
* @access public
|
||||
* @param array Hash containing any parameters different from the
|
||||
* defaults.
|
||||
* @see _Mail_smtpmx()
|
||||
*/
|
||||
function __construct($params)
|
||||
{
|
||||
if (isset($params['mailname'])) {
|
||||
$this->mailname = $params['mailname'];
|
||||
} else {
|
||||
// try to find a valid mailname
|
||||
if (function_exists('posix_uname')) {
|
||||
$uname = posix_uname();
|
||||
$this->mailname = $uname['nodename'];
|
||||
}
|
||||
}
|
||||
|
||||
// port number
|
||||
if (isset($params['port'])) {
|
||||
$this->_port = $params['port'];
|
||||
} else {
|
||||
$this->_port = getservbyname('smtp', 'tcp');
|
||||
}
|
||||
|
||||
if (isset($params['timeout'])) $this->timeout = $params['timeout'];
|
||||
if (isset($params['verp'])) $this->verp = $params['verp'];
|
||||
if (isset($params['test'])) $this->test = $params['test'];
|
||||
if (isset($params['peardebug'])) $this->test = $params['peardebug'];
|
||||
if (isset($params['netdns'])) $this->withNetDns = $params['netdns'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor wrapper for PHP4
|
||||
*
|
||||
* @access public
|
||||
* @param array Hash containing any parameters different from the defaults
|
||||
* @see __construct()
|
||||
*/
|
||||
function Mail_smtpmx($params)
|
||||
{
|
||||
$this->__construct($params);
|
||||
register_shutdown_function(array(&$this, '__destruct'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor implementation to ensure that we disconnect from any
|
||||
* potentially-alive persistent SMTP connections.
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
if (is_object($this->_smtp)) {
|
||||
$this->_smtp->disconnect();
|
||||
$this->_smtp = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Mail::send() function using SMTP direct delivery
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $recipients in RFC822 style or array
|
||||
* @param array $headers The array of headers to send with the mail.
|
||||
* @param string $body The full text of the message body,
|
||||
* @return mixed Returns true on success, or a PEAR_Error
|
||||
*/
|
||||
function send($recipients, $headers, $body)
|
||||
{
|
||||
if (!is_array($headers)) {
|
||||
return PEAR::raiseError('$headers must be an array');
|
||||
}
|
||||
|
||||
$result = $this->_sanitizeHeaders($headers);
|
||||
if (is_a($result, 'PEAR_Error')) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Prepare headers
|
||||
$headerElements = $this->prepareHeaders($headers);
|
||||
if (is_a($headerElements, 'PEAR_Error')) {
|
||||
return $headerElements;
|
||||
}
|
||||
list($from, $textHeaders) = $headerElements;
|
||||
|
||||
// use 'Return-Path' if possible
|
||||
if (!empty($headers['Return-Path'])) {
|
||||
$from = $headers['Return-Path'];
|
||||
}
|
||||
if (!isset($from)) {
|
||||
return $this->_raiseError('no_from');
|
||||
}
|
||||
|
||||
// Prepare recipients
|
||||
$recipients = $this->parseRecipients($recipients);
|
||||
if (is_a($recipients, 'PEAR_Error')) {
|
||||
return $recipients;
|
||||
}
|
||||
|
||||
foreach ($recipients as $rcpt) {
|
||||
list($user, $host) = explode('@', $rcpt);
|
||||
|
||||
$mx = $this->_getMx($host);
|
||||
if (is_a($mx, 'PEAR_Error')) {
|
||||
return $mx;
|
||||
}
|
||||
|
||||
if (empty($mx)) {
|
||||
$info = array('rcpt' => $rcpt);
|
||||
return $this->_raiseError('no_mx', $info);
|
||||
}
|
||||
|
||||
$connected = false;
|
||||
foreach ($mx as $mserver => $mpriority) {
|
||||
$this->_smtp = new Net_SMTP($mserver, $this->port, $this->mailname);
|
||||
|
||||
// configure the SMTP connection.
|
||||
if ($this->debug) {
|
||||
$this->_smtp->setDebug(true);
|
||||
}
|
||||
|
||||
// attempt to connect to the configured SMTP server.
|
||||
$res = $this->_smtp->connect($this->timeout);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$this->_smtp = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
// connection established
|
||||
if ($res) {
|
||||
$connected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$connected) {
|
||||
$info = array(
|
||||
'host' => implode(', ', array_keys($mx)),
|
||||
'port' => $this->port,
|
||||
'rcpt' => $rcpt,
|
||||
);
|
||||
return $this->_raiseError('not_connected', $info);
|
||||
}
|
||||
|
||||
// Verify recipient
|
||||
if ($this->vrfy) {
|
||||
$res = $this->_smtp->vrfy($rcpt);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$info = array('rcpt' => $rcpt);
|
||||
return $this->_raiseError('failed_vrfy_rcpt', $info);
|
||||
}
|
||||
}
|
||||
|
||||
// mail from:
|
||||
$args['verp'] = $this->verp;
|
||||
$res = $this->_smtp->mailFrom($from, $args);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$info = array('from' => $from);
|
||||
return $this->_raiseError('failed_set_from', $info);
|
||||
}
|
||||
|
||||
// rcpt to:
|
||||
$res = $this->_smtp->rcptTo($rcpt);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$info = array('rcpt' => $rcpt);
|
||||
return $this->_raiseError('failed_set_rcpt', $info);
|
||||
}
|
||||
|
||||
// Don't send anything in test mode
|
||||
if ($this->test) {
|
||||
$result = $this->_smtp->rset();
|
||||
$res = $this->_smtp->rset();
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
return $this->_raiseError('failed_rset');
|
||||
}
|
||||
|
||||
$this->_smtp->disconnect();
|
||||
$this->_smtp = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Send data
|
||||
$res = $this->_smtp->data($body, $textHeaders);
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
$info = array('rcpt' => $rcpt);
|
||||
return $this->_raiseError('failed_send_data', $info);
|
||||
}
|
||||
|
||||
$this->_smtp->disconnect();
|
||||
$this->_smtp = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recieve mx rexords for a spciefied host
|
||||
*
|
||||
* The MX records
|
||||
*
|
||||
* @access private
|
||||
* @param string $host mail host
|
||||
* @return mixed sorted
|
||||
*/
|
||||
function _getMx($host)
|
||||
{
|
||||
$mx = array();
|
||||
|
||||
if ($this->withNetDns) {
|
||||
$res = $this->_loadNetDns();
|
||||
if (is_a($res, 'PEAR_Error')) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
$response = $this->resolver->query($host, 'MX');
|
||||
if (!$response) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($response->answer as $rr) {
|
||||
if ($rr->type == 'MX') {
|
||||
$mx[$rr->exchange] = $rr->preference;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$mxHost = array();
|
||||
$mxWeight = array();
|
||||
|
||||
if (!getmxrr($host, $mxHost, $mxWeight)) {
|
||||
return false;
|
||||
}
|
||||
for ($i = 0; $i < count($mxHost); ++$i) {
|
||||
$mx[$mxHost[$i]] = $mxWeight[$i];
|
||||
}
|
||||
}
|
||||
|
||||
asort($mx);
|
||||
return $mx;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize PEAR:Net_DNS_Resolver
|
||||
*
|
||||
* @access private
|
||||
* @return boolean true on success
|
||||
*/
|
||||
function _loadNetDns()
|
||||
{
|
||||
if (is_object($this->resolver)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!include_once 'Net/DNS.php') {
|
||||
return $this->_raiseError('no_resolver');
|
||||
}
|
||||
|
||||
$this->resolver = new Net_DNS_Resolver();
|
||||
if ($this->debug) {
|
||||
$this->resolver->test = 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* raise standardized error
|
||||
*
|
||||
* include additional information in error message
|
||||
*
|
||||
* @access private
|
||||
* @param string $id maps error ids to codes and message
|
||||
* @param array $info optional information in associative array
|
||||
* @see _errorCode
|
||||
*/
|
||||
function _raiseError($id, $info = array())
|
||||
{
|
||||
$code = $this->errorCode[$id]['code'];
|
||||
$msg = $this->errorCode[$id]['msg'];
|
||||
|
||||
// include info to messages
|
||||
if (!empty($info)) {
|
||||
$search = array();
|
||||
$replace = array();
|
||||
|
||||
foreach ($info as $key => $value) {
|
||||
array_push($search, '{' . strtoupper($key) . '}');
|
||||
array_push($replace, $value);
|
||||
}
|
||||
|
||||
$msg = str_replace($search, $replace, $msg);
|
||||
}
|
||||
|
||||
return PEAR::raiseError($msg, $code);
|
||||
}
|
||||
|
||||
}
|
||||
53
democracy/sai/saimod_beta/cannon/Pear/Mail/README.rst
Normal file
53
democracy/sai/saimod_beta/cannon/Pear/Mail/README.rst
Normal file
@ -0,0 +1,53 @@
|
||||
****
|
||||
Mail
|
||||
****
|
||||
Class that provides multiple interfaces for sending emails.
|
||||
|
||||
PEAR's Mail package defines an interface for implementing mailers under the
|
||||
PEAR hierarchy.
|
||||
It also provides supporting functions useful to multiple mailer backends.
|
||||
|
||||
Currently supported backends include:
|
||||
|
||||
- PHP's native ``mail()`` function
|
||||
- sendmail
|
||||
- SMTP
|
||||
|
||||
This package also provides a `RFC 822`__ email address list validation utility class.
|
||||
|
||||
Use Mail in combination with `Mail_Mime`__ to send HTML emails or emails with
|
||||
attachments - have a look at the example__.
|
||||
|
||||
__ https://tools.ietf.org/html/rfc822
|
||||
__ http://pear.php.net/package/Mail_Mime
|
||||
__ http://pear.php.net/manual/en/package.mail.mail-mime.example.php
|
||||
|
||||
============
|
||||
Installation
|
||||
============
|
||||
|
||||
PEAR
|
||||
====
|
||||
::
|
||||
|
||||
$ pear install mail
|
||||
|
||||
Composer
|
||||
========
|
||||
::
|
||||
|
||||
$ composer require pear/mail
|
||||
|
||||
=====
|
||||
Links
|
||||
=====
|
||||
Homepage
|
||||
http://pear.php.net/package/Mail
|
||||
Source code
|
||||
https://github.com/pear/Mail
|
||||
Issue tracker
|
||||
http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Mail
|
||||
Unit test status
|
||||
https://travis-ci.org/pear/Mail
|
||||
Packagist
|
||||
https://packagist.org/packages/pear/mail
|
||||
46
democracy/sai/saimod_beta/cannon/Pear/Mail/composer.json
Normal file
46
democracy/sai/saimod_beta/cannon/Pear/Mail/composer.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"authors": [
|
||||
{
|
||||
"email": "chuck@horde.org",
|
||||
"name": "Chuck Hagenbuch",
|
||||
"role": "Lead"
|
||||
},
|
||||
{
|
||||
"email": "richard@phpguru.org",
|
||||
"name": "Richard Heyes",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"email": "alec@alec.pl",
|
||||
"name": "Aleksander Machniak",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Mail": "./"
|
||||
}
|
||||
},
|
||||
"description": "Class that provides multiple interfaces for sending emails.",
|
||||
"homepage": "http://pear.php.net/package/Mail",
|
||||
"include-path": [
|
||||
"./"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"name": "pear/mail",
|
||||
"support": {
|
||||
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Mail",
|
||||
"source": "https://github.com/pear/Mail"
|
||||
},
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=5.2.1",
|
||||
"pear/pear-core-minimal": "~1.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"pear/pear": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"pear/net_smtp": "Install optionally via your project's composer.json"
|
||||
}
|
||||
}
|
||||
1616
democracy/sai/saimod_beta/cannon/Pear/Mail/mime.php
Normal file
1616
democracy/sai/saimod_beta/cannon/Pear/Mail/mime.php
Normal file
File diff suppressed because it is too large
Load Diff
1276
democracy/sai/saimod_beta/cannon/Pear/Mail/mimePart.php
Normal file
1276
democracy/sai/saimod_beta/cannon/Pear/Mail/mimePart.php
Normal file
File diff suppressed because it is too large
Load Diff
80
democracy/sai/saimod_beta/cannon/Pear/Mail/package.xml
Normal file
80
democracy/sai/saimod_beta/cannon/Pear/Mail/package.xml
Normal file
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<name>Mail</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<summary>Class that provides multiple interfaces for sending emails</summary>
|
||||
<description>PEAR's Mail package defines an interface for implementing mailers under the PEAR hierarchy. It also provides supporting functions useful to multiple mailer backends. Currently supported backends include: PHP's native mail() function, sendmail, and SMTP. This package also provides a RFC822 email address list validation utility class.</description>
|
||||
<lead>
|
||||
<name>Chuck Hagenbuch</name>
|
||||
<user>chagenbu</user>
|
||||
<email>chuck@horde.org</email>
|
||||
<active>no</active>
|
||||
</lead>
|
||||
<developer>
|
||||
<name>Richard Heyes</name>
|
||||
<user>richard</user>
|
||||
<email>richard@phpguru.org</email>
|
||||
<active>no</active>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Aleksander Machniak</name>
|
||||
<user>alec</user>
|
||||
<email>alec@alec.pl</email>
|
||||
<active>yes</active>
|
||||
</developer>
|
||||
<date>2017-04-11</date>
|
||||
<version>
|
||||
<release>1.4.1</release>
|
||||
<api>1.3.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="https://opensource.org/licenses/BSD-3-Clause">New BSD License</license>
|
||||
<notes>
|
||||
* Loosen recognition of "queued as" server response (PR #10)
|
||||
|
||||
* Bug #20463: domain-literal parsing error
|
||||
* Bug #20513: Mail_smtp::send() doesn't close socket for smtp connection
|
||||
</notes>
|
||||
<contents>
|
||||
<dir baseinstalldir="/" name="/">
|
||||
<file baseinstalldir="/" name="LICENSE" role="doc" />
|
||||
<file baseinstalldir="/" name="Mail/mail.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/mock.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/null.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/RFC822.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/sendmail.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/smtp.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail/smtpmx.php" role="php" />
|
||||
<file baseinstalldir="/" name="Mail.php" role="php" />
|
||||
<file baseinstalldir="/" name="tests/9137.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/9137_2.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/13659.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/bug17178.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/bug17317.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/rfc822.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/smtp_error.phpt" role="test" />
|
||||
<file baseinstalldir="/" name="tests/validateQuotedString.phpt" role="test" />
|
||||
</dir>
|
||||
</contents>
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>5.2.1</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.5.6</min>
|
||||
</pearinstaller>
|
||||
</required>
|
||||
<optional>
|
||||
<package>
|
||||
<name>Net_SMTP</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<min>1.4.1</min>
|
||||
</package>
|
||||
</optional>
|
||||
</dependencies>
|
||||
<phprelease />
|
||||
</package>
|
||||
25
democracy/sai/saimod_beta/cannon/Pear/Mail/tests/13659.phpt
Normal file
25
democracy/sai/saimod_beta/cannon/Pear/Mail/tests/13659.phpt
Normal file
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Mail: Test for bug #13659
|
||||
--FILE--
|
||||
<?php
|
||||
//require_once dirname(__FILE__) . '/../Mail/RFC822.php';
|
||||
require_once 'Mail/RFC822.php';
|
||||
require_once 'PEAR.php';
|
||||
|
||||
$address = '"Test Student" <test@mydomain.com> (test)';
|
||||
$parser = new Mail_RFC822();
|
||||
$result = $parser->parseAddressList($address, 'anydomain.com', TRUE);
|
||||
|
||||
if (!PEAR::isError($result) && is_array($result) && is_object($result[0]))
|
||||
if ($result[0]->personal == '"Test Student"' &&
|
||||
$result[0]->mailbox == "test" &&
|
||||
$result[0]->host == "mydomain.com" &&
|
||||
is_array($result[0]->comment) && $result[0]->comment[0] == 'test')
|
||||
{
|
||||
print("OK");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
OK
|
||||
33
democracy/sai/saimod_beta/cannon/Pear/Mail/tests/9137.phpt
Normal file
33
democracy/sai/saimod_beta/cannon/Pear/Mail/tests/9137.phpt
Normal file
@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
Mail: Test for bug #9137
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../Mail/RFC822.php';
|
||||
require_once 'PEAR.php';
|
||||
|
||||
$addresses = array(
|
||||
array('name' => 'John Doe', 'email' => 'test@example.com'),
|
||||
array('name' => 'John Doe\\', 'email' => 'test@example.com'),
|
||||
array('name' => 'John "Doe', 'email' => 'test@example.com'),
|
||||
array('name' => 'John "Doe\\', 'email' => 'test@example.com'),
|
||||
);
|
||||
|
||||
for ($i = 0; $i < count($addresses); $i++) {
|
||||
// construct the address
|
||||
$address = "\"" . addslashes($addresses[$i]['name']) . "\" ".
|
||||
"<".$addresses[$i]['email'].">";
|
||||
|
||||
$parsedAddresses = Mail_RFC822::parseAddressList($address);
|
||||
if (is_a($parsedAddresses, 'PEAR_Error')) {
|
||||
echo $address." :: Failed to validate\n";
|
||||
} else {
|
||||
echo $address." :: Parsed\n";
|
||||
}
|
||||
}
|
||||
|
||||
--EXPECT--
|
||||
"John Doe" <test@example.com> :: Parsed
|
||||
"John Doe\\" <test@example.com> :: Parsed
|
||||
"John \"Doe" <test@example.com> :: Parsed
|
||||
"John \"Doe\\" <test@example.com> :: Parsed
|
||||
35
democracy/sai/saimod_beta/cannon/Pear/Mail/tests/9137_2.phpt
Normal file
35
democracy/sai/saimod_beta/cannon/Pear/Mail/tests/9137_2.phpt
Normal file
@ -0,0 +1,35 @@
|
||||
--TEST--
|
||||
Mail: Test for bug #9137, take 2
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../Mail/RFC822.php';
|
||||
require_once 'PEAR.php';
|
||||
|
||||
$addresses = array(
|
||||
array('raw' => '"John Doe" <test@example.com>'),
|
||||
array('raw' => '"John Doe' . chr(92) . '" <test@example.com>'),
|
||||
array('raw' => '"John Doe' . chr(92) . chr(92) . '" <test@example.com>'),
|
||||
array('raw' => '"John Doe' . chr(92) . chr(92) . chr(92) . '" <test@example.com>'),
|
||||
array('raw' => '"John Doe' . chr(92) . chr(92) . chr(92) . chr(92) . '" <test@example.com>'),
|
||||
array('raw' => '"John Doe <test@example.com>'),
|
||||
);
|
||||
|
||||
for ($i = 0; $i < count($addresses); $i++) {
|
||||
// construct the address
|
||||
$address = $addresses[$i]['raw'];
|
||||
$parsedAddresses = Mail_RFC822::parseAddressList($address);
|
||||
if (PEAR::isError($parsedAddresses)) {
|
||||
echo $address." :: Failed to validate\n";
|
||||
} else {
|
||||
echo $address." :: Parsed\n";
|
||||
}
|
||||
}
|
||||
|
||||
--EXPECT--
|
||||
"John Doe" <test@example.com> :: Parsed
|
||||
"John Doe\" <test@example.com> :: Failed to validate
|
||||
"John Doe\\" <test@example.com> :: Parsed
|
||||
"John Doe\\\" <test@example.com> :: Failed to validate
|
||||
"John Doe\\\\" <test@example.com> :: Parsed
|
||||
"John Doe <test@example.com> :: Failed to validate
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
clean:
|
||||
rm -f *.log *.php *.diff *.exp *.out
|
||||
|
||||
|
||||
|
||||
test:
|
||||
cd .. && pear run-tests tests/*.phpt && cd tests;
|
||||
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Mail_RFC822::parseAddressList does not accept RFC-valid group syntax
|
||||
--FILE--
|
||||
<?php
|
||||
require "Mail/RFC822.php";
|
||||
|
||||
var_dump(Mail_RFC822::parseAddressList("empty-group:;","invalid",false,false));
|
||||
|
||||
--EXPECT--
|
||||
array(0) {
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
Mail_RFC822::parseAddressList invalid periods in mail address
|
||||
--FILE--
|
||||
<?php
|
||||
require "Mail/RFC822.php";
|
||||
|
||||
$result[] = Mail_RFC822::parseAddressList('.name@example.com');
|
||||
$result[] = Mail_RFC822::parseAddressList('name.@example.com');
|
||||
$result[] = Mail_RFC822::parseAddressList('name..name@example.com');
|
||||
|
||||
foreach ($result as $r) {
|
||||
if (is_a($r, 'PEAR_Error')) {
|
||||
echo "OK\n";
|
||||
}
|
||||
}
|
||||
--EXPECT--
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
107
democracy/sai/saimod_beta/cannon/Pear/Mail/tests/rfc822.phpt
Normal file
107
democracy/sai/saimod_beta/cannon/Pear/Mail/tests/rfc822.phpt
Normal file
@ -0,0 +1,107 @@
|
||||
--TEST--
|
||||
Mail_RFC822: Address Parsing
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'Mail/RFC822.php';
|
||||
|
||||
$parser = new Mail_RFC822();
|
||||
|
||||
/* A simple, bare address. */
|
||||
$address = 'user@example.com';
|
||||
print_r($parser->parseAddressList($address, null, true, true));
|
||||
|
||||
/* Address groups. */
|
||||
$address = 'My Group: "Richard" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
|
||||
print_r($parser->parseAddressList($address, null, true, true));
|
||||
|
||||
/* A valid address with spaces in the local part. */
|
||||
$address = '<"Jon Parise"@php.net>';
|
||||
print_r($parser->parseAddressList($address, null, true, true));
|
||||
|
||||
/* An invalid address with spaces in the local part. */
|
||||
$address = '<Jon Parise@php.net>';
|
||||
$result = $parser->parseAddressList($address, null, true, true);
|
||||
if (is_a($result, 'PEAR_Error')) echo $result->getMessage() . "\n";
|
||||
|
||||
/* A valid address with an uncommon TLD. */
|
||||
$address = 'jon@host.longtld';
|
||||
$result = $parser->parseAddressList($address, null, true, true);
|
||||
if (is_a($result, 'PEAR_Error')) echo $result->getMessage() . "\n";
|
||||
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[personal] =>
|
||||
[comment] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[mailbox] => user
|
||||
[host] => example.com
|
||||
)
|
||||
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[groupname] => My Group
|
||||
[addresses] => Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[personal] => "Richard"
|
||||
[comment] => Array
|
||||
(
|
||||
[0] => A comment
|
||||
)
|
||||
|
||||
[mailbox] => richard
|
||||
[host] => localhost
|
||||
)
|
||||
|
||||
[1] => stdClass Object
|
||||
(
|
||||
[personal] =>
|
||||
[comment] => Array
|
||||
(
|
||||
[0] => Ted Bloggs
|
||||
)
|
||||
|
||||
[mailbox] => ted
|
||||
[host] => example.com
|
||||
)
|
||||
|
||||
[2] => stdClass Object
|
||||
(
|
||||
[personal] =>
|
||||
[comment] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[mailbox] => Barney
|
||||
[host] => localhost
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => stdClass Object
|
||||
(
|
||||
[personal] =>
|
||||
[comment] => Array
|
||||
(
|
||||
)
|
||||
|
||||
[mailbox] => "Jon Parise"
|
||||
[host] => php.net
|
||||
)
|
||||
|
||||
)
|
||||
Validation failed for: <Jon Parise@php.net>
|
||||
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Mail: SMTP Error Reporting
|
||||
--SKIPIF--
|
||||
<?php
|
||||
|
||||
require_once 'PEAR/Registry.php';
|
||||
$registry = new PEAR_Registry();
|
||||
|
||||
if (!$registry->packageExists('Net_SMTP')) die("skip\n");
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'Mail.php';
|
||||
|
||||
/* Reference a bogus SMTP server address to guarantee a connection failure. */
|
||||
$params = array('host' => 'bogus.host.tld');
|
||||
|
||||
/* Create our SMTP-based mailer object. */
|
||||
$mailer = Mail::factory('smtp', $params);
|
||||
|
||||
/* Attempt to send an empty message in order to trigger an error. */
|
||||
$e = $mailer->send(array(), array(), '');
|
||||
if (is_a($e, 'PEAR_Error')) {
|
||||
$err = $e->getMessage();
|
||||
if (preg_match('/Failed to connect to bogus.host.tld:25 \[SMTP: Failed to connect socket:.*/i', $err)) {
|
||||
echo "OK";
|
||||
}
|
||||
}
|
||||
|
||||
--EXPECT--
|
||||
OK
|
||||
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
Mail_RFC822::parseAddressList simple tests
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'Mail/RFC822.php';
|
||||
$address_string = '"Joe Doe \(from Somewhere\)" <doe@example.com>, postmaster@example.com, root';
|
||||
|
||||
$address_array = Mail_RFC822::parseAddressList($address_string, "example.com");
|
||||
|
||||
foreach ($address_array as $val) {
|
||||
echo "mailbox : " . $val->mailbox . "\n";
|
||||
echo "host : " . $val->host . "\n";
|
||||
echo "personal: " . $val->personal . "\n";
|
||||
}
|
||||
--EXPECT--
|
||||
mailbox : doe
|
||||
host : example.com
|
||||
personal: "Joe Doe \(from Somewhere\)"
|
||||
mailbox : postmaster
|
||||
host : example.com
|
||||
personal:
|
||||
mailbox : root
|
||||
host : example.com
|
||||
personal:
|
||||
1274
democracy/sai/saimod_beta/cannon/Pear/Net/SMTP.php
Normal file
1274
democracy/sai/saimod_beta/cannon/Pear/Net/SMTP.php
Normal file
File diff suppressed because it is too large
Load Diff
738
democracy/sai/saimod_beta/cannon/Pear/Net/Socket.php
Normal file
738
democracy/sai/saimod_beta/cannon/Pear/Net/Socket.php
Normal file
@ -0,0 +1,738 @@
|
||||
<?php
|
||||
/**
|
||||
* Net_Socket
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 1997-2017 The PHP Group
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* o Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Net
|
||||
* @package Net_Socket
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 1997-2017 The PHP Group
|
||||
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
|
||||
* @link http://pear.php.net/packages/Net_Socket
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/../PEAR.php';
|
||||
|
||||
define('NET_SOCKET_READ', 1);
|
||||
define('NET_SOCKET_WRITE', 2);
|
||||
define('NET_SOCKET_ERROR', 4);
|
||||
|
||||
/**
|
||||
* Generalized Socket class.
|
||||
*
|
||||
* @category Net
|
||||
* @package Net_Socket
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Chuck Hagenbuch <chuck@horde.org>
|
||||
* @copyright 1997-2017 The PHP Group
|
||||
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
|
||||
* @link http://pear.php.net/packages/Net_Socket
|
||||
*/
|
||||
class Net_Socket extends PEAR
|
||||
{
|
||||
/**
|
||||
* Socket file pointer.
|
||||
* @var resource $fp
|
||||
*/
|
||||
public $fp = null;
|
||||
|
||||
/**
|
||||
* Whether the socket is blocking. Defaults to true.
|
||||
* @var boolean $blocking
|
||||
*/
|
||||
public $blocking = true;
|
||||
|
||||
/**
|
||||
* Whether the socket is persistent. Defaults to false.
|
||||
* @var boolean $persistent
|
||||
*/
|
||||
public $persistent = false;
|
||||
|
||||
/**
|
||||
* The IP address to connect to.
|
||||
* @var string $addr
|
||||
*/
|
||||
public $addr = '';
|
||||
|
||||
/**
|
||||
* The port number to connect to.
|
||||
* @var integer $port
|
||||
*/
|
||||
public $port = 0;
|
||||
|
||||
/**
|
||||
* Number of seconds to wait on socket operations before assuming
|
||||
* there's no more data. Defaults to no timeout.
|
||||
* @var integer|float $timeout
|
||||
*/
|
||||
public $timeout = null;
|
||||
|
||||
/**
|
||||
* Number of bytes to read at a time in readLine() and
|
||||
* readAll(). Defaults to 2048.
|
||||
* @var integer $lineLength
|
||||
*/
|
||||
public $lineLength = 2048;
|
||||
|
||||
/**
|
||||
* The string to use as a newline terminator. Usually "\r\n" or "\n".
|
||||
* @var string $newline
|
||||
*/
|
||||
public $newline = "\r\n";
|
||||
|
||||
/**
|
||||
* Connect to the specified port. If called when the socket is
|
||||
* already connected, it disconnects and connects again.
|
||||
*
|
||||
* @param string $addr IP address or host name (may be with protocol prefix).
|
||||
* @param integer $port TCP port number.
|
||||
* @param boolean $persistent (optional) Whether the connection is
|
||||
* persistent (kept open between requests
|
||||
* by the web server).
|
||||
* @param integer $timeout (optional) Connection socket timeout.
|
||||
* @param array $options See options for stream_context_create.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return boolean|PEAR_Error True on success or a PEAR_Error on failure.
|
||||
*/
|
||||
public function connect(
|
||||
$addr,
|
||||
$port = 0,
|
||||
$persistent = null,
|
||||
$timeout = null,
|
||||
$options = null
|
||||
) {
|
||||
if (is_resource($this->fp)) {
|
||||
@fclose($this->fp);
|
||||
$this->fp = null;
|
||||
}
|
||||
|
||||
if (!$addr) {
|
||||
return $this->raiseError('$addr cannot be empty');
|
||||
} else {
|
||||
if (strspn($addr, ':.0123456789') === strlen($addr)) {
|
||||
$this->addr = strpos($addr, ':') !== false ? '[' . $addr . ']' : $addr;
|
||||
} else {
|
||||
$this->addr = $addr;
|
||||
}
|
||||
}
|
||||
|
||||
$this->port = $port % 65536;
|
||||
|
||||
if ($persistent !== null) {
|
||||
$this->persistent = $persistent;
|
||||
}
|
||||
|
||||
$openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen';
|
||||
$errno = 0;
|
||||
$errstr = '';
|
||||
|
||||
if (function_exists('error_clear_last')) {
|
||||
error_clear_last();
|
||||
} else {
|
||||
$old_track_errors = @ini_set('track_errors', 1);
|
||||
}
|
||||
|
||||
if ($timeout <= 0) {
|
||||
$timeout = @ini_get('default_socket_timeout');
|
||||
}
|
||||
|
||||
if ($options && function_exists('stream_context_create')) {
|
||||
$context = stream_context_create($options);
|
||||
|
||||
// Since PHP 5 fsockopen doesn't allow context specification
|
||||
if (function_exists('stream_socket_client')) {
|
||||
$flags = STREAM_CLIENT_CONNECT;
|
||||
|
||||
if ($this->persistent) {
|
||||
$flags = STREAM_CLIENT_PERSISTENT;
|
||||
}
|
||||
|
||||
$addr = $this->addr . ':' . $this->port;
|
||||
$fp = @stream_socket_client($addr, $errno, $errstr,
|
||||
$timeout, $flags, $context);
|
||||
} else {
|
||||
$fp = @$openfunc($this->addr, $this->port, $errno,
|
||||
$errstr, $timeout, $context);
|
||||
}
|
||||
} else {
|
||||
$fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout);
|
||||
}
|
||||
|
||||
if (!$fp) {
|
||||
if ($errno === 0 && !strlen($errstr)) {
|
||||
$errstr = '';
|
||||
if (isset($old_track_errors)) {
|
||||
$errstr = $php_errormsg ?: '';
|
||||
@ini_set('track_errors', $old_track_errors);
|
||||
} else {
|
||||
$lastError = error_get_last();
|
||||
if (isset($lastError['message'])) {
|
||||
$errstr = $lastError['message'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->raiseError($errstr, $errno);
|
||||
}
|
||||
|
||||
if (isset($old_track_errors)) {
|
||||
@ini_set('track_errors', $old_track_errors);
|
||||
}
|
||||
|
||||
$this->fp = $fp;
|
||||
$this->setTimeout();
|
||||
|
||||
return $this->setBlocking($this->blocking);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects from the peer, closes the socket.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed true on success or a PEAR_Error instance otherwise
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
@fclose($this->fp);
|
||||
$this->fp = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the newline character/sequence to use.
|
||||
*
|
||||
* @param string $newline Newline character(s)
|
||||
* @return boolean True
|
||||
*/
|
||||
public function setNewline($newline)
|
||||
{
|
||||
$this->newline = $newline;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out if the socket is in blocking mode.
|
||||
*
|
||||
* @access public
|
||||
* @return boolean The current blocking mode.
|
||||
*/
|
||||
public function isBlocking()
|
||||
{
|
||||
return $this->blocking;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the socket connection should be blocking or
|
||||
* not. A read call to a non-blocking socket will return immediately
|
||||
* if there is no data available, whereas it will block until there
|
||||
* is data for blocking sockets.
|
||||
*
|
||||
* @param boolean $mode True for blocking sockets, false for nonblocking.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed true on success or a PEAR_Error instance otherwise
|
||||
*/
|
||||
public function setBlocking($mode)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$this->blocking = $mode;
|
||||
stream_set_blocking($this->fp, (int)$this->blocking);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the timeout value on socket descriptor,
|
||||
* expressed in the sum of seconds and microseconds
|
||||
*
|
||||
* @param integer $seconds Seconds.
|
||||
* @param integer $microseconds Microseconds, optional.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed True on success or false on failure or
|
||||
* a PEAR_Error instance when not connected
|
||||
*/
|
||||
public function setTimeout($seconds = null, $microseconds = null)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
if ($seconds === null && $microseconds === null) {
|
||||
$seconds = (int)$this->timeout;
|
||||
$microseconds = (int)(($this->timeout - $seconds) * 1000000);
|
||||
} else {
|
||||
$this->timeout = $seconds + $microseconds / 1000000;
|
||||
}
|
||||
|
||||
if ($this->timeout > 0) {
|
||||
return stream_set_timeout($this->fp, (int)$seconds, (int)$microseconds);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file buffering size on the stream.
|
||||
* See php's stream_set_write_buffer for more information.
|
||||
*
|
||||
* @param integer $size Write buffer size.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed on success or an PEAR_Error object otherwise
|
||||
*/
|
||||
public function setWriteBuffer($size)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$returned = stream_set_write_buffer($this->fp, $size);
|
||||
if ($returned === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->raiseError('Cannot set write buffer.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about an existing socket resource.
|
||||
* Currently returns four entries in the result array:
|
||||
*
|
||||
* <p>
|
||||
* timed_out (bool) - The socket timed out waiting for data<br>
|
||||
* blocked (bool) - The socket was blocked<br>
|
||||
* eof (bool) - Indicates EOF event<br>
|
||||
* unread_bytes (int) - Number of bytes left in the socket buffer<br>
|
||||
* </p>
|
||||
*
|
||||
* @access public
|
||||
* @return mixed Array containing information about existing socket
|
||||
* resource or a PEAR_Error instance otherwise
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
return stream_get_meta_data($this->fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specified line of data
|
||||
*
|
||||
* @param int $size Reading ends when size - 1 bytes have been read,
|
||||
* or a newline or an EOF (whichever comes first).
|
||||
* If no size is specified, it will keep reading from
|
||||
* the stream until it reaches the end of the line.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed $size bytes of data from the socket, or a PEAR_Error if
|
||||
* not connected. If an error occurs, FALSE is returned.
|
||||
*/
|
||||
public function gets($size = null)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
if (null === $size) {
|
||||
return @fgets($this->fp);
|
||||
} else {
|
||||
return @fgets($this->fp, $size);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a specified amount of data. This is guaranteed to return,
|
||||
* and has the added benefit of getting everything in one fread()
|
||||
* chunk; if you know the size of the data you're getting
|
||||
* beforehand, this is definitely the way to go.
|
||||
*
|
||||
* @param integer $size The number of bytes to read from the socket.
|
||||
*
|
||||
* @access public
|
||||
* @return string $size bytes of data from the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function read($size)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
return @fread($this->fp, $size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a specified amount of data.
|
||||
*
|
||||
* @param string $data Data to write.
|
||||
* @param integer $blocksize Amount of data to write at once.
|
||||
* NULL means all at once.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed If the socket is not connected, returns an instance of
|
||||
* PEAR_Error.
|
||||
* If the write succeeds, returns the number of bytes written.
|
||||
* If the write fails, returns false.
|
||||
* If the socket times out, returns an instance of PEAR_Error.
|
||||
*/
|
||||
public function write($data, $blocksize = null)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
if (null === $blocksize && !OS_WINDOWS) {
|
||||
$written = @fwrite($this->fp, $data);
|
||||
|
||||
// Check for timeout or lost connection
|
||||
if ($written === false) {
|
||||
$meta_data = $this->getStatus();
|
||||
|
||||
if (!is_array($meta_data)) {
|
||||
return $meta_data; // PEAR_Error
|
||||
}
|
||||
|
||||
if (!empty($meta_data['timed_out'])) {
|
||||
return $this->raiseError('timed out');
|
||||
}
|
||||
}
|
||||
|
||||
return $written;
|
||||
} else {
|
||||
if (null === $blocksize) {
|
||||
$blocksize = 1024;
|
||||
}
|
||||
|
||||
$pos = 0;
|
||||
$size = strlen($data);
|
||||
while ($pos < $size) {
|
||||
$written = @fwrite($this->fp, substr($data, $pos, $blocksize));
|
||||
|
||||
// Check for timeout or lost connection
|
||||
if ($written === false) {
|
||||
$meta_data = $this->getStatus();
|
||||
|
||||
if (!is_array($meta_data)) {
|
||||
return $meta_data; // PEAR_Error
|
||||
}
|
||||
|
||||
if (!empty($meta_data['timed_out'])) {
|
||||
return $this->raiseError('timed out');
|
||||
}
|
||||
|
||||
return $written;
|
||||
}
|
||||
|
||||
$pos += $written;
|
||||
}
|
||||
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a line of data to the socket, followed by a trailing newline.
|
||||
*
|
||||
* @param string $data Data to write
|
||||
*
|
||||
* @access public
|
||||
* @return mixed fwrite() result, or PEAR_Error when not connected
|
||||
*/
|
||||
public function writeLine($data)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
return fwrite($this->fp, $data . $this->newline);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for end-of-file on a socket descriptor.
|
||||
*
|
||||
* Also returns true if the socket is disconnected.
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function eof()
|
||||
{
|
||||
return (!is_resource($this->fp) || feof($this->fp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a byte of data
|
||||
*
|
||||
* @access public
|
||||
* @return integer 1 byte of data from the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readByte()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
return ord(@fread($this->fp, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a word of data
|
||||
*
|
||||
* @access public
|
||||
* @return integer 1 word of data from the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readWord()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$buf = @fread($this->fp, 2);
|
||||
|
||||
return (ord($buf[0]) + (ord($buf[1]) << 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an int of data
|
||||
*
|
||||
* @access public
|
||||
* @return integer 1 int of data from the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readInt()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$buf = @fread($this->fp, 4);
|
||||
|
||||
return (ord($buf[0]) + (ord($buf[1]) << 8) +
|
||||
(ord($buf[2]) << 16) + (ord($buf[3]) << 24));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a zero-terminated string of data
|
||||
*
|
||||
* @access public
|
||||
* @return string, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readString()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$string = '';
|
||||
while (($char = @fread($this->fp, 1)) !== "\x00") {
|
||||
$string .= $char;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an IP Address and returns it in a dot formatted string
|
||||
*
|
||||
* @access public
|
||||
* @return string Dot formatted string, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readIPAddress()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$buf = @fread($this->fp, 4);
|
||||
|
||||
return sprintf('%d.%d.%d.%d', ord($buf[0]), ord($buf[1]),
|
||||
ord($buf[2]), ord($buf[3]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read until either the end of the socket or a newline, whichever
|
||||
* comes first. Strips the trailing newline from the returned data.
|
||||
*
|
||||
* @access public
|
||||
* @return string All available data up to a newline, without that
|
||||
* newline, or until the end of the socket, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readLine()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$line = '';
|
||||
|
||||
$timeout = time() + $this->timeout;
|
||||
|
||||
while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) {
|
||||
$line .= @fgets($this->fp, $this->lineLength);
|
||||
if (substr($line, -1) == "\n") {
|
||||
return rtrim($line, $this->newline);
|
||||
}
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read until the socket closes, or until there is no more data in
|
||||
* the inner PHP buffer. If the inner buffer is empty, in blocking
|
||||
* mode we wait for at least 1 byte of data. Therefore, in
|
||||
* blocking mode, if there is no data at all to be read, this
|
||||
* function will never exit (unless the socket is closed on the
|
||||
* remote end).
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return string All data until the socket closes, or a PEAR_Error if
|
||||
* not connected.
|
||||
*/
|
||||
public function readAll()
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$data = '';
|
||||
$timeout = time() + $this->timeout;
|
||||
|
||||
while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) {
|
||||
$data .= @fread($this->fp, $this->lineLength);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the equivalent of the select() system call on the socket
|
||||
* with a timeout specified by tv_sec and tv_usec.
|
||||
*
|
||||
* @param integer $state Which of read/write/error to check for.
|
||||
* @param integer $tv_sec Number of seconds for timeout.
|
||||
* @param integer $tv_usec Number of microseconds for timeout.
|
||||
*
|
||||
* @access public
|
||||
* @return False if select fails, integer describing which of read/write/error
|
||||
* are ready, or PEAR_Error if not connected.
|
||||
*/
|
||||
public function select($state, $tv_sec, $tv_usec = 0)
|
||||
{
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
$read = null;
|
||||
$write = null;
|
||||
$except = null;
|
||||
if ($state & NET_SOCKET_READ) {
|
||||
$read[] = $this->fp;
|
||||
}
|
||||
if ($state & NET_SOCKET_WRITE) {
|
||||
$write[] = $this->fp;
|
||||
}
|
||||
if ($state & NET_SOCKET_ERROR) {
|
||||
$except[] = $this->fp;
|
||||
}
|
||||
if (false === ($sr = stream_select($read, $write, $except,
|
||||
$tv_sec, $tv_usec))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = 0;
|
||||
if (count($read)) {
|
||||
$result |= NET_SOCKET_READ;
|
||||
}
|
||||
if (count($write)) {
|
||||
$result |= NET_SOCKET_WRITE;
|
||||
}
|
||||
if (count($except)) {
|
||||
$result |= NET_SOCKET_ERROR;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns encryption on/off on a connected socket.
|
||||
*
|
||||
* @param bool $enabled Set this parameter to true to enable encryption
|
||||
* and false to disable encryption.
|
||||
* @param integer $type Type of encryption. See stream_socket_enable_crypto()
|
||||
* for values.
|
||||
*
|
||||
* @see http://se.php.net/manual/en/function.stream-socket-enable-crypto.php
|
||||
* @access public
|
||||
* @return false on error, true on success and 0 if there isn't enough data
|
||||
* and the user should try again (non-blocking sockets only).
|
||||
* A PEAR_Error object is returned if the socket is not
|
||||
* connected
|
||||
*/
|
||||
public function enableCrypto($enabled, $type)
|
||||
{
|
||||
if (version_compare(phpversion(), '5.1.0', '>=')) {
|
||||
if (!is_resource($this->fp)) {
|
||||
return $this->raiseError('not connected');
|
||||
}
|
||||
|
||||
return @stream_socket_enable_crypto($this->fp, $enabled, $type);
|
||||
} else {
|
||||
$msg = 'Net_Socket::enableCrypto() requires php version >= 5.1.0';
|
||||
|
||||
return $this->raiseError($msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1113
democracy/sai/saimod_beta/cannon/Pear/PEAR.php
Normal file
1113
democracy/sai/saimod_beta/cannon/Pear/PEAR.php
Normal file
File diff suppressed because it is too large
Load Diff
13
democracy/sai/saimod_beta/cannon/mailcannon.cli.php
Normal file
13
democracy/sai/saimod_beta/cannon/mailcannon.cli.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
require_once(dirname(__FILE__).'/mailcannon.php');
|
||||
|
||||
$file = $argv[1];
|
||||
if(!is_file($file)){
|
||||
throw new Exception('No json config file provided.');}
|
||||
|
||||
$input = json_decode(file_get_contents($file),true);
|
||||
|
||||
mailcannon::fire( $input['bcc'], $input['delay'], $input['from'], $input['subject'],
|
||||
array_key_exists('html_file', $input) ? $input['html_file'] : NULL, $input['text_file'], $input['member_list'],
|
||||
$input['unsubscribe_list'], $input['images'], $input['attachments'], $input['replacements'], $input['smtp']);
|
||||
179
democracy/sai/saimod_beta/cannon/mailcannon.php
Normal file
179
democracy/sai/saimod_beta/cannon/mailcannon.php
Normal file
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
require_once(dirname(__FILE__).'/Pear/Mail/Mail.php');
|
||||
require_once(dirname(__FILE__).'/Pear/Mail/mime.php');
|
||||
require_once(dirname(__FILE__).'/Pear/Net/SMTP.php');
|
||||
|
||||
class mailcannon {
|
||||
public static function fire($bcc,$delay,$from,$subject,$html_file,$text_file,$member_list,$unsubscribe_list,$images,$attachments,$replacements,$smtp = null,$silent = false){
|
||||
$silent ? null : print "Sending from ".$from." - '".$subject."'\n";
|
||||
|
||||
if(!$member_list){
|
||||
die("Empty Member List given\n");}
|
||||
|
||||
// load addresses
|
||||
$to_proto = array();
|
||||
if(!is_file($member_list)){
|
||||
$to_proto[] = $member_list;
|
||||
} else {
|
||||
$file = fopen($member_list, 'r');
|
||||
while (($line = fgetcsv($file,0,";")) != FALSE) {
|
||||
$to_proto[] = $line;}
|
||||
fclose($file);
|
||||
}
|
||||
$silent ? null : print "To address count: " . count($to_proto) . "\n";
|
||||
|
||||
// load unsubscribe addresses
|
||||
$dont_send = array();
|
||||
if(is_file($unsubscribe_list)){
|
||||
$file = fopen($unsubscribe_list, 'r');
|
||||
while (($line = fgetcsv($file)) != FALSE) {
|
||||
$dont_send[] = $line[0];}
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
if($dont_send && count($dont_send)>0) {
|
||||
$silent ? null : print "Dont send count: " . count($dont_send) . "\n";
|
||||
} else {
|
||||
$silent ? null : print "No dont sends\n";}
|
||||
|
||||
// remove unsubscribes from to_proto
|
||||
$to_addresses = array();
|
||||
foreach($to_proto as $addr){
|
||||
if( strlen($addr[0]) > 0 &&
|
||||
substr($addr[0], 0,1) !== '#' &&
|
||||
!in_array($addr[0], $dont_send)){
|
||||
$to_addresses[] = $addr;}
|
||||
}
|
||||
$silent ? null : print "Reduced to list count " . count($to_addresses)."\n\n";
|
||||
|
||||
if($smtp){
|
||||
$mail = Mail::factory('smtp', $smtp);
|
||||
} else {
|
||||
$mail = Mail::factory('mail');}
|
||||
|
||||
$silent ? null : print "Running...\n";
|
||||
$count = 0;
|
||||
foreach ($to_addresses as $addr) {
|
||||
$to = $addr;
|
||||
// load text & html file
|
||||
if(!file_exists($text_file)){
|
||||
$silent ? null : print "Skipping ".$to." - No Text found:".$text_file." \n";
|
||||
$text = file_get_contents($text_file);
|
||||
} else {
|
||||
$text = file_get_contents($text_file);}
|
||||
$html = file_exists($html_file) ? file_get_contents($html_file) : NULL;
|
||||
|
||||
//Calculate replacements
|
||||
$replace = array();
|
||||
foreach($replacements as $key=>$value){
|
||||
// value
|
||||
if( array_key_exists('value', $value)){
|
||||
// value attribute
|
||||
if( array_key_exists('attribute', $value['value'])){
|
||||
if(count($addr) <= $value['value']['attribute']){
|
||||
if(!array_key_exists('*',$value)){
|
||||
die('No Default Value found for "'.$key.'" - required on "'.$to.'" - dieing!');}
|
||||
$replace[$key] = $value['*'];
|
||||
} else {
|
||||
$replace[$key] = $addr[$value['value']['attribute']];
|
||||
}
|
||||
// value text
|
||||
} elseif(array_key_exists('text', $value['value'])){
|
||||
$replace[$key] = $value['value']['text'];
|
||||
// value template
|
||||
} elseif(array_key_exists('template', $value['value'])){
|
||||
$tpl = $value['value']['template'];
|
||||
if(!file_exists($tpl)){
|
||||
die('TPL File "'.$tpl.'" not found for "'.$key.'" - required on "'.$to.'" - dieing!');}
|
||||
$replace[$key] = file_get_contents($tpl);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// selector attribute
|
||||
if( array_key_exists('selector', $value) &&
|
||||
array_key_exists('attribute', $value['selector']) &&
|
||||
array_key_exists('values', $value)){
|
||||
if(count($addr) <= $value['selector']['attribute']){
|
||||
if(!array_key_exists('*',$value)){
|
||||
die('No Default Value found for "'.$key.'" - required on "'.$to.'" - dieing!');}
|
||||
$replace[$key] = $value['*'];
|
||||
} else {
|
||||
$replace[$key] = $value['values'][$addr[$value['selector']['attribute']]];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//Replace
|
||||
$preg_search = array();
|
||||
$preg_replace = array();
|
||||
foreach($replace as $key=>$value){
|
||||
$preg_search[] = '/\${'.$key.'}/';
|
||||
$preg_replace[] = $value;
|
||||
}
|
||||
$text = @preg_replace($preg_search, $preg_replace, $text);
|
||||
$html = @preg_replace($preg_search, $preg_replace, $html);
|
||||
|
||||
//Send mail
|
||||
$mime = new Mail_mime("\n");
|
||||
if($text){
|
||||
$mime->setTXTBody($text);
|
||||
}
|
||||
// attach images
|
||||
foreach($images as $name=>$image){
|
||||
$mime->addHTMLImage($image, 'image/png', $name, true, $name);}
|
||||
// attach other
|
||||
foreach($attachments as $name=>$attachment){
|
||||
$mime->addAttachment($attachment,'application/pdf',$name);}
|
||||
|
||||
if($html){
|
||||
$mime->setHTMLBody($html);}
|
||||
|
||||
$mime_params = array( 'text_encoding' => '7bit',
|
||||
'text_charset' => 'UTF-8',
|
||||
'html_charset' => 'UTF-8',
|
||||
'head_charset' => 'UTF-8');
|
||||
|
||||
$body = $mime->get($mime_params);
|
||||
$hdrs = $mime->headers(array( 'From' => $from,
|
||||
'Subject' => $subject,
|
||||
'Reply-to' => $from,
|
||||
'Return-Path' => $from,
|
||||
'Message-ID' => self::generateMessageID(),
|
||||
'Date' => date('r', time())));
|
||||
|
||||
$recipients = array( 'To' => $to);
|
||||
$succ = $mail->send($recipients, $hdrs, $body);
|
||||
if (PEAR::isError($succ)) {
|
||||
print 'Error Sending HTML message to ' . $to . ' ' . $succ->getMessage() . "\n";
|
||||
} else {
|
||||
if($unsubscribe_list) {
|
||||
file_put_contents($unsubscribe_list, $to.PHP_EOL , FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
if($html){
|
||||
$silent ? null : print 'Sending HTML message to ' . $to . "\n";
|
||||
} else {
|
||||
$silent ? null : print 'Sending TXT message to ' . $to . "\n";
|
||||
}
|
||||
}
|
||||
$count += 1;
|
||||
sleep($delay);
|
||||
}
|
||||
$silent ? null : print "Sent " . $count . " emails\n";
|
||||
$silent ? null : print "Done\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see http://www.jwz.org/doc/mid.html
|
||||
*/
|
||||
public static function generateMessageID()
|
||||
{
|
||||
return sprintf(
|
||||
"<%s.%s@%s>",
|
||||
base_convert(microtime(), 10, 36),
|
||||
base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
|
||||
"democracy-deutschland.de"
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ function init_saimod_beta_all() {
|
||||
$('#tabs_beta li a').each(function(){
|
||||
$(this).removeClass('active');});
|
||||
$('#menu_tag_beta').addClass('active');
|
||||
email_delete();
|
||||
};
|
||||
|
||||
function init_saimod_beta_code() {
|
||||
@ -32,7 +33,6 @@ function init_saimod_beta_code() {
|
||||
});
|
||||
$('.code_setcomment').click(function(){
|
||||
var code = $(this).attr('code');
|
||||
var email = $(this).attr('email');
|
||||
var i = $(this).attr('i');
|
||||
var comment = $('#comment_'+i).val();
|
||||
$.ajax({
|
||||
@ -54,6 +54,26 @@ function init_saimod_beta_code() {
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.code_delete').click(function(){
|
||||
var code = $(this).attr('code');
|
||||
$.ajax({
|
||||
async: true,
|
||||
url: this.endpoint,
|
||||
type: 'GET',
|
||||
dataType: 'JSON',
|
||||
data: {
|
||||
sai_mod: '.SAI.saimod_beta',
|
||||
action: 'code_delete',
|
||||
code: code
|
||||
},
|
||||
success: function(){
|
||||
system.reload();
|
||||
},
|
||||
error: function(){
|
||||
alert('Something happend - try again!');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function init_saimod_beta_store_android() {
|
||||
$("#table_beta_store_android").tablesorter();
|
||||
@ -90,6 +110,7 @@ function init_saimod_beta_store_android() {
|
||||
document.execCommand("copy");
|
||||
$temp.remove();
|
||||
});
|
||||
email_delete();
|
||||
};
|
||||
function init_saimod_beta_store_ios() {
|
||||
$("#table_beta_store_ios").tablesorter();
|
||||
@ -126,6 +147,7 @@ function init_saimod_beta_store_ios() {
|
||||
document.execCommand("copy");
|
||||
$temp.remove();
|
||||
});
|
||||
email_delete();
|
||||
};
|
||||
function init_saimod_beta_mail() {
|
||||
$("#table_beta_mail").tablesorter();
|
||||
@ -156,4 +178,30 @@ function init_saimod_beta_mail() {
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
email_delete();
|
||||
};
|
||||
|
||||
function email_delete(){
|
||||
$('.email_delete').click(function(){
|
||||
if (confirm('Are you sure you want to delete this user PERMANENTLY?')) {
|
||||
var email = $(this).attr('email');
|
||||
$.ajax({
|
||||
async: true,
|
||||
url: this.endpoint,
|
||||
type: 'GET',
|
||||
dataType: 'JSON',
|
||||
data: {
|
||||
sai_mod: '.SAI.saimod_beta',
|
||||
action: 'email_delete',
|
||||
email: email
|
||||
},
|
||||
success: function(){
|
||||
system.reload();
|
||||
},
|
||||
error: function(){
|
||||
alert('Something happend - try again!');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -61,6 +61,7 @@ class saimod_beta extends \SYSTEM\SAI\sai_module{
|
||||
while($row = $beta->next()){
|
||||
$row['i'] = $i++;
|
||||
$row['generated'] = \SYSTEM\time::time_ago_string(strtotime($row['createdAt']));
|
||||
$row['code_delete_disabled'] = $row['count'] == 0 ? '' : 'disabled';
|
||||
$vars['data'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_beta/tpl/code_tr.tpl'))->SERVERPATH(),$row);
|
||||
}
|
||||
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag('time'));
|
||||
@ -78,6 +79,16 @@ class saimod_beta extends \SYSTEM\SAI\sai_module{
|
||||
return \JsonResult::ok();
|
||||
}
|
||||
|
||||
public static function sai_mod__SAI_saimod_beta_action_code_delete($code){
|
||||
\SQL\BETA_CODE_DELETE::QI(array($code));
|
||||
return \JsonResult::ok();
|
||||
}
|
||||
|
||||
public static function sai_mod__SAI_saimod_beta_action_email_delete($email){
|
||||
\SQL\BETA_EMAIL_DELETE::QI(array($email));
|
||||
return \JsonResult::ok();
|
||||
}
|
||||
|
||||
public static function sai_mod__SAI_saimod_beta_action_store_android(){
|
||||
$vars = array();
|
||||
|
||||
@ -213,7 +224,7 @@ class saimod_beta extends \SYSTEM\SAI\sai_module{
|
||||
}
|
||||
|
||||
public static function sai_mod__SAI_saimod_beta_action_email($email,$android,$ios){
|
||||
require((new \SYSTEM\PROOT('PHPMailer-master/PHPMailerAutoload.php'))->SERVERPATH());
|
||||
/*require((new \SYSTEM\PROOT('PHPMailer-master/PHPMailerAutoload.php'))->SERVERPATH());
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
$mail = new \PHPMailer;
|
||||
@ -246,7 +257,27 @@ class saimod_beta extends \SYSTEM\SAI\sai_module{
|
||||
|
||||
//send the message, check for errors
|
||||
if(!$mail->send()){
|
||||
throw new \SYSTEM\LOG\ERROR("Mailer Error: " . $mail->ErrorInfo);}
|
||||
throw new \SYSTEM\LOG\ERROR("Mailer Error: " . $mail->ErrorInfo);}*/
|
||||
|
||||
$bcc = null;
|
||||
$delay = 0;
|
||||
$from = 'Prototyp | DEMOCRACY <prototyping@democracy-deutschland.de>';
|
||||
$subject = '📱 DEMOCRACY: Dein Prototyp Zugang';
|
||||
$html_file = $android ? (new \PSAI('saimod_beta/tpl/mail_android.tpl'))->SERVERPATH() : (new \PSAI('saimod_beta/tpl/mail_ios.tpl'))->SERVERPATH();
|
||||
$text_file = $android ? (new \PSAI('saimod_beta/tpl/mail_android.txt'))->SERVERPATH() : (new \PSAI('saimod_beta/tpl/mail_ios.txt'))->SERVERPATH();
|
||||
$to = $email;
|
||||
$unsubscribe_list = null;
|
||||
$images = ["democracy_logo" => (new \PSAI('saimod_beta/img/logo.png'))->SERVERPATH()];
|
||||
$attachments = [];
|
||||
$replacements = [];
|
||||
$smtp = [ "host" => "ssl://atmanspacher.eu",
|
||||
"port" => 465,
|
||||
"auth" => true,
|
||||
"username" => "prototyping@democracy-deutschland.de",
|
||||
"password" => "7$7ar0pZ"
|
||||
];
|
||||
$silent = true;
|
||||
\mailcannon::fire($bcc, $delay, $from, $subject, $html_file, $text_file, $to, $unsubscribe_list, $images, $attachments, $replacements,$smtp, $silent);
|
||||
|
||||
\SQL\BETA_MAIL::QI(array($email));
|
||||
|
||||
|
||||
@ -9,4 +9,7 @@ REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `na
|
||||
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (7040, 42, 2, 7000, 'email', 'email', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (7041, 42, 2, 7000, 'email', 'android', 'BOOL');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (7042, 42, 2, 7000, 'email', 'ios', 'BOOL');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (7042, 42, 2, 7000, 'email', 'ios', 'BOOL');
|
||||
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (7050, 42, 2, 7000, 'code_delete', 'code', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (7060, 42, 2, 7000, 'email_delete', 'email', 'STRING');
|
||||
@ -10,6 +10,7 @@
|
||||
<th>Store</th>
|
||||
<th>Email</th>
|
||||
<th>Comment</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>${data}</tbody>
|
||||
|
||||
@ -7,4 +7,5 @@
|
||||
<td><i class="fa fa-${stored}"></i> ${stored_time}</td>
|
||||
<td><i class="fa fa-${emailed}"></i> ${emailed_time}</td>
|
||||
<td>${comment}</td>
|
||||
<td><button type="button" class="btn btn-danger email_delete" email="${email}"><i class="fa fa-trash"></i></button></td>
|
||||
</tr>
|
||||
@ -6,5 +6,8 @@
|
||||
<td>${generated}</td>
|
||||
<td>${count}</td>
|
||||
<td><input id="comment_${i}" type="text" class="form-control" value="${comment}"></td>
|
||||
<td><button type="button" class="btn btn-warning code_setcomment" code="${code}" i="${i}"><i class="fa fa-pencil"></i></button></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-warning code_setcomment" code="${code}" i="${i}"><i class="fa fa-pencil"></i></button>
|
||||
<button type="button" class="btn btn-danger code_delete" ${code_delete_disabled} code="${code}"><i class="fa fa-trash"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
@ -9,18 +9,18 @@
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<span>im folgenden erklären wir Dir, wie du <b>zur 1. Version von DEMOCRACY </b>gelangst.</span>
|
||||
<span>im folgenden erklären wir Dir, wie Du <b>zur Beta-Version von DEMOCRACY </b>gelangst.</span>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
<span style="text-decoration: underline;"><b>Anleitung für Android</b></span>
|
||||
<ol style="line-height: 2;">
|
||||
<li>Öffne diesen Link mit Deinem Handy: <a href="https://play.google.com/apps/testing/de.democracydeutschland.app">https://play.google.com/apps/testing/de.democracydeutschland.app</a></li>
|
||||
<li>Öffne diesen Link mit Deinem Handy: <a href="https://play.google.com/apps/testing/de.democracydeutschland.app.beta">https://play.google.com/apps/testing/de.democracydeutschland.app.beta</a></li>
|
||||
<li>Drücke den Button ganz unten auf dem es heißt: <i>Tester werden</i></li>
|
||||
<li>Eine neue Ansicht lädt, drücke nun die <i>App DEMOCRACY bei Google Play herunterladen</i>.</li>
|
||||
<li>Du wirst in den Google Play Store weitergeleitet und kannst die App dort herunter laden</li>
|
||||
<li>Öffne DEMOCRACY und teste – wie du Bugs korrekt reportest, entnehme bitte der Anleitung zum Bug-Report</li>
|
||||
<li>Solltest Du beim Öffnen des Links von Schritt 1 eine Fehlermeldung bekommen, in der es heißt <i>App nicht verfügbar</i>, hast du dich entweder mit einer anderen als uns zur Verfügung gestellten Email-Adresse angemeldet oder uns die falsche Email-Adresse zur Verfügung gestellt. Gerne kannst du uns mit einer Mail an <a href="mailto:prototyping@democracy-deutschland.de">prototyping@democracy-deutschland.de</a> deine richtige Adresse zur Verfügung stellen.</li>
|
||||
<li>Öffne DEMOCRACY und teste – wie Du Bugs korrekt reportest, entnehme bitte der Anleitung zum Bug-Report</li>
|
||||
<li>Solltest Du beim Öffnen des Links von Schritt 1 eine Fehlermeldung bekommen, in der es heißt <i>App nicht verfügbar</i>, hast Du Dich entweder mit einer anderen als uns zur Verfügung gestellten Email-Adresse angemeldet oder uns die falsche Email-Adresse zur Verfügung gestellt. Gerne kannst Du uns mit einer Mail an <a href="mailto:prototyping@democracy-deutschland.de">prototyping@democracy-deutschland.de</a> deine richtige Adresse zur Verfügung stellen.</li>
|
||||
</ol>
|
||||
<div>
|
||||
<span><br></span>
|
||||
@ -34,17 +34,17 @@
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<span>Wie du das machst?</span>
|
||||
<span>Wie Du das machst?</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>Zunächst: Mach aus der unten stehenden Liste bitte nur das, was Dir zumutbar erscheint. Im Optimalfall:</span>
|
||||
</div>
|
||||
<br>
|
||||
<ol style="line-height: 2;">
|
||||
<li>Mach einen Screenshot (n Android: An- und Leiser-Taste gleichzeitig drücken oder An-Taste drücken und Screenshot auswählen)</li>
|
||||
<li>Mach einen Screenshot (in Android: An- und Leiser-Taste gleichzeitig drücken oder An-Taste drücken und Screenshot auswählen)</li>
|
||||
<li>Markiere die fehlerhaften Bereiche in dem Screenshot (z.B Roter Kreis um den Fehler)</li>
|
||||
<li>Beschreib das Problem möglichst genau in wenigen Sätzen</li>
|
||||
<li>Gib eine Schritt-für-Schritt-Anleitung, wie es zu dem Problem gekommen ist, und wenn es dir für notwendig erscheint</li>
|
||||
<li>Gib eine Schritt-für-Schritt-Anleitung, wie es zu dem Problem gekommen ist, und wenn es Dir für notwendig erscheint</li>
|
||||
<li>Klassifiziere das Problem in einen Fehlerbericht und/oder einen Verbesserungsvorschlag</li>
|
||||
<li>Schicke uns den (bearbeiteten) Screenshot, die Fehlerbeschreibung sowie Deine Plattform (iOS/Android) und Deine Gerätebezeichnung (z.B. iPhone SE) per E-Mail an <a href="mailto:prototyping@democracy-deutschland.de">prototyping@democracy-deutschland.de</a> oder optional</li>
|
||||
<li>Erstelle ein Issue für das Problem und lade den Screenshot auf Github hoch <a href="https://github.com/demokratie-live/democracy-client/issues">https://github.com/demokratie-live/democracy-client/issues</a></li>
|
||||
|
||||
30
democracy/sai/saimod_beta/tpl/mail_android.txt
Normal file
30
democracy/sai/saimod_beta/tpl/mail_android.txt
Normal file
@ -0,0 +1,30 @@
|
||||
Hallo lieber Prototyp-Tester,
|
||||
|
||||
im folgenden erklären wir Dir, wie Du zur Beta-Version von DEMOCRACY gelangst.
|
||||
|
||||
Anleitung für Android
|
||||
* Öffne diesen Link mit Deinem Handy: https://play.google.com/apps/testing/de.democracydeutschland.app.beta
|
||||
* Drücke den Button ganz unten auf dem es heißt: Tester werden
|
||||
* Eine neue Ansicht lädt, drücke nun die App DEMOCRACY bei Google Play herunterladen.
|
||||
* Du wirst in den Google Play Store weitergeleitet und kannst die App dort herunter laden
|
||||
* Öffne DEMOCRACY und teste – wie Du Bugs korrekt reportest, entnehme bitte der Anleitung zum Bug-Report
|
||||
* Solltest Du beim Öffnen des Links von Schritt 1 eine Fehlermeldung bekommen, in der es heißt App nicht verfügbar, hast Du Dich entweder mit einer anderen als uns zur Verfügung gestellten Email-Adresse angemeldet oder uns die falsche Email-Adresse zur Verfügung gestellt. Gerne kannst Du uns mit einer Mail an prototyping@democracy-deutschland.de deine richtige Adresse zur Verfügung stellen.
|
||||
|
||||
Anleitung zum Bug-Report
|
||||
* Ein qualifiziertes Feedback ist notwendig, um Fehler zu beheben. Deshalb gib uns möglichst viele Informationen zu den von Dir gefunden Fehlern oder Verbesserungsvorschlägen.
|
||||
* Wie Du das machst?
|
||||
* Zunächst: Mach aus der unten stehenden Liste bitte nur das, was Dir zumutbar erscheint. Im Optimalfall:
|
||||
|
||||
* Mach einen Screenshot (in Android: An- und Leiser-Taste gleichzeitig drücken oder An-Taste drücken und Screenshot auswählen)
|
||||
* Markiere die fehlerhaften Bereiche in dem Screenshot (z.B Roter Kreis um den Fehler)
|
||||
* Beschreib das Problem möglichst genau in wenigen Sätzen
|
||||
* Gib eine Schritt-für-Schritt-Anleitung, wie es zu dem Problem gekommen ist, und wenn es Dir für notwendig erscheint
|
||||
* Klassifiziere das Problem in einen Fehlerbericht und/oder einen Verbesserungsvorschlag
|
||||
* Schicke uns den (bearbeiteten) Screenshot, die Fehlerbeschreibung sowie Deine Plattform (iOS/Android) und Deine Gerätebezeichnung (z.B. iPhone SE) per E-Mail an prototyping@democracy-deutschland.de oder optional
|
||||
* Erstelle ein Issue für das Problem und lade den Screenshot auf Github hoch https://github.com/demokratie-live/democracy-client/issues
|
||||
|
||||
|
||||
DEMOCRACY Deutschland e.V.
|
||||
IBAN: DE33 5003 1000 1049 7560 00
|
||||
BIC: TRODDEF1
|
||||
mobil +49 176 470 40 213
|
||||
@ -9,18 +9,18 @@
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<span>im folgenden erklären wir Dir, wie du <b>zur 1. Version von DEMOCRACY </b>gelangst.</span>
|
||||
<span>im folgenden erklären wir Dir, wie Du <b>zur Beta-Version von DEMOCRACY </b>gelangst.</span>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
<span style="text-decoration: underline;"><b>Anleitung für iOS</b></span>
|
||||
<ol style="line-height: 2;">
|
||||
<li>Du erhälst in den folgenden Minuten eine Email von TestFlight mit der Betreffzeile <i>DEMOCRACY Deutschland e.V. has invited you to test "DEMOCRACY App"</i></li>
|
||||
<li>Du erhälst in den folgenden Minuten eine Email von TestFlight mit der Betreffzeile <i>DEMOCRACY Deutschland e.V. has invited you to test "DEMOCRACY Beta"</i></li>
|
||||
<li>Öffne diese Mail, klicke den blauen Button <i>View in TestFlight </i>und folge der aufgeführten Anleitung, also</li>
|
||||
<li>Lade dir TestFlight im AppStore herunter</li>
|
||||
<li>Lade Dir TestFlight im AppStore herunter</li>
|
||||
<li>Öffne TestFlight und Drücke “Redeem”</li>
|
||||
<li>Gib den Bestätigungscode, also z.B. QJHFFNDF ein und lade Dir DEMOCRACY herunter.</li>
|
||||
<li>Öffne DEMOCRACY und teste – wie du Bugs korrekt reportest, entnehme bitte der Anleitung zum Bug-Report</li>
|
||||
<li>Öffne DEMOCRACY und teste – wie Du Bugs korrekt reportest, entnehme bitte der Anleitung zum Bug-Report</li>
|
||||
</ol>
|
||||
<div>
|
||||
<span><br></span>
|
||||
@ -34,7 +34,7 @@
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<span>Wie du das machst?</span>
|
||||
<span>Wie Du das machst?</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>Zunächst: Mach aus der unten stehenden Liste bitte nur das, was Dir zumutbar erscheint. Im Optimalfall:</span>
|
||||
@ -44,7 +44,7 @@
|
||||
<li>Mach einen Screenshot (in iOS: Stand-by- und Home-Taste gleichzeitig drücken)</li>
|
||||
<li>Markiere die fehlerhaften Bereiche in dem Screenshot (z.B Roter Kreis um den Fehler)</li>
|
||||
<li>Beschreib das Problem möglichst genau in wenigen Sätzen</li>
|
||||
<li>Gib eine Schritt-für-Schritt-Anleitung, wie es zu dem Problem gekommen ist, und wenn es dir für notwendig erscheint</li>
|
||||
<li>Gib eine Schritt-für-Schritt-Anleitung, wie es zu dem Problem gekommen ist, und wenn es Dir für notwendig erscheint</li>
|
||||
<li>Klassifiziere das Problem in einen Fehlerbericht und/oder einen Verbesserungsvorschlag</li>
|
||||
<li>Schicke uns den (bearbeiteten) Screenshot, die Fehlerbeschreibung sowie Deine Plattform (iOS/Android) und Deine Gerätebezeichnung (z.B. iPhone SE) per E-Mail an <a href="mailto:prototyping@democracy-deutschland.de">prototyping@democracy-deutschland.de</a> oder optional</li>
|
||||
<li>Erstelle ein Issue für das Problem und lade den Screenshot auf Github hoch <a href="https://github.com/demokratie-live/democracy-client/issues">https://github.com/demokratie-live/democracy-client/issues</a></li>
|
||||
|
||||
30
democracy/sai/saimod_beta/tpl/mail_ios.txt
Normal file
30
democracy/sai/saimod_beta/tpl/mail_ios.txt
Normal file
@ -0,0 +1,30 @@
|
||||
Hallo lieber Prototyp-Tester,
|
||||
|
||||
im folgenden erklären wir Dir, wie Du zur Beta-Version von DEMOCRACY gelangst.
|
||||
|
||||
Anleitung für iOS
|
||||
* Du erhälst in den folgenden Minuten eine Email von TestFlight mit der Betreffzeile DEMOCRACY Deutschland e.V. has invited you to test "DEMOCRACY Beta"
|
||||
* Öffne diese Mail, klicke den blauen Button View in TestFlight und folge der aufgeführten Anleitung, also
|
||||
* Lade Dir TestFlight im AppStore herunter
|
||||
* Öffne TestFlight und Drücke “Redeem”
|
||||
* Gib den Bestätigungscode, also z.B. QJHFFNDF ein und lade Dir DEMOCRACY herunter.
|
||||
* Öffne DEMOCRACY und teste – wie Du Bugs korrekt reportest, entnehme bitte der Anleitung zum Bug-Report
|
||||
|
||||
Anleitung zum Bug-Report
|
||||
* Ein qualifiziertes Feedback ist notwendig, um Fehler zu beheben. Deshalb gib uns möglichst viele Informationen zu den von Dir gefunden Fehlern oder Verbesserungsvorschlägen.
|
||||
* Wie Du das machst?
|
||||
* Zunächst: Mach aus der unten stehenden Liste bitte nur das, was Dir zumutbar erscheint. Im Optimalfall:
|
||||
|
||||
* Mach einen Screenshot (in iOS: Stand-by- und Home-Taste gleichzeitig drücken)
|
||||
* Markiere die fehlerhaften Bereiche in dem Screenshot (z.B Roter Kreis um den Fehler)
|
||||
* Beschreib das Problem möglichst genau in wenigen Sätzen
|
||||
* Gib eine Schritt-für-Schritt-Anleitung, wie es zu dem Problem gekommen ist, und wenn es Dir für notwendig erscheint
|
||||
* Klassifiziere das Problem in einen Fehlerbericht und/oder einen Verbesserungsvorschlag
|
||||
* Schicke uns den (bearbeiteten) Screenshot, die Fehlerbeschreibung sowie Deine Plattform (iOS/Android) und Deine Gerätebezeichnung (z.B. iPhone SE) per E-Mail an prototyping@democracy-deutschland.de oder optional
|
||||
* Erstelle ein Issue für das Problem und lade den Screenshot auf Github hoch https://github.com/demokratie-live/democracy-client/issues
|
||||
|
||||
|
||||
DEMOCRACY Deutschland e.V.
|
||||
IBAN: DE33 5003 1000 1049 7560 00
|
||||
BIC: TRODDEF1
|
||||
mobil +49 176 470 40 213
|
||||
@ -6,5 +6,8 @@
|
||||
<td><i class="fa fa-${stored}"></i> ${stored_time}</td>
|
||||
<td><i class="fa fa-${mailed}"></i> ${mailed_time}</td>
|
||||
<td>${comment}</td>
|
||||
<td><button type="button" class="btn btn-danger beta_mail" ${disabled} email="${email}" ios="${ios}" android="${android}"><i class="fa fa-check"></i> Send Mail</button></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-warning beta_mail" ${disabled} email="${email}" ios="${ios}" android="${android}"><i class="fa fa-envelope"></i> Send Mail</button>
|
||||
<button type="button" class="btn btn-danger email_delete" email="${email}"><i class="fa fa-trash"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
@ -6,5 +6,8 @@
|
||||
<td><i class="fa fa-${redeemed}"></i> ${redeemed_time}</td>
|
||||
<td><i class="fa fa-${stored}"></i> ${stored_time}</td>
|
||||
<td>${comment}</td>
|
||||
<td><button type="button" class="btn btn-danger code_android" ${disabled} email="${email}"><i class="fa fa-check"></i> Habe ich dem Store hinzugefügt</button></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-warning code_android" ${disabled} email="${email}"><i class="fa fa-android"></i> Habe ich dem Store hinzugefügt</button>
|
||||
<button type="button" class="btn btn-danger email_delete" email="${email}"><i class="fa fa-trash"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
@ -6,5 +6,8 @@
|
||||
<td><i class="fa fa-${redeemed}"></i> ${redeemed_time}</td>
|
||||
<td><i class="fa fa-${stored}"></i> ${stored_time}</td>
|
||||
<td>${comment}</td>
|
||||
<td><button type="button" class="btn btn-danger code_ios" ${disabled} email="${email}"><i class="fa fa-check"></i> Habe ich dem Store hinzugefügt</button></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-warning code_ios" ${disabled} email="${email}"><i class="fa fa-apple"></i> Habe ich dem Store hinzugefügt</button>
|
||||
<button type="button" class="btn btn-danger email_delete" email="${email}"><i class="fa fa-trash"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
Reference in New Issue
Block a user