PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,156 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\MobileMessaging\SMSProvider;
use Exception;
use Piwik\Http;
use Piwik\Piwik;
use Piwik\Plugins\MobileMessaging\APIException;
use Piwik\Plugins\MobileMessaging\SMSProvider;
require_once PIWIK_INCLUDE_PATH . "/plugins/MobileMessaging/APIException.php";
/**
* @ignore
*/
class ASPSMS extends SMSProvider
{
const SOCKET_TIMEOUT = 15;
const BASE_API_URL = 'https://json.aspsms.com/';
const CHECK_CREDIT_RESOURCE = 'CheckCredits';
const SEND_SMS_RESOURCE = 'SendTextSMS';
const MAXIMUM_FROM_LENGTH = 11;
const MAXIMUM_CONCATENATED_SMS = 9;
public function getId()
{
return 'ASPSMS';
}
public function getDescription()
{
return 'You can use <a target="_blank" rel="noreferrer noopener" href="http://www.aspsms.com/en/?REF=227830"><img src="plugins/MobileMessaging/images/ASPSMS.png"/></a> to send SMS Reports from Piwik.<br/>
<ul>
<li> First, <a target="_blank" rel="noreferrer noopener" href="http://www.aspsms.com/en/registration/?REF=227830">get an Account at ASPSMS</a> (Signup is free!)
</li><li> Enter your ASPSMS credentials on this page. </li>
</ul>
<br/>About ASPSMS.com: <ul>
<li>ASPSMS provides fast and reliable high quality worldwide SMS delivery, over 900 networks in every corner of the globe.
</li><li>Cost per SMS message depends on the target country and starts from ~0.06USD (0.04EUR).
</li><li>Most countries and networks are supported but we suggest you check the latest position on their supported networks list <a href="http://www.aspsms.com/en/networks/?REF=227830" target="_blank" rel="noreferrer noopener">here</a>.
</li><li>For sending an SMS, you need so-called ASPSMS credits, which are purchased in advance. The ASPSMS credits do not expire.
</li><li><a target="_blank" rel="noreferrer noopener" href="https://www.aspsms.com/instruction/payment.asp?REF=227830">Payment</a> by bank transfer, various credit cards such as Eurocard/Mastercard, Visa, American Express or Diners Club, PayPal or Swiss Postcard.
</li>
</ul>
';
}
public function getCredentialFields()
{
return array(
array(
'type' => 'text',
'name' => 'username',
'title' => 'MobileMessaging_UserKey'
),
array(
'type' => 'text',
'name' => 'password',
'title' => 'General_Password'
),
);
}
public function verifyCredential($credentials)
{
$this->getCreditLeft($credentials);
return true;
}
public function sendSMS($credentials, $smsText, $phoneNumber, $from)
{
$from = substr($from, 0, self::MAXIMUM_FROM_LENGTH);
$smsText = self::truncate($smsText, self::MAXIMUM_CONCATENATED_SMS);
$additionalParameters = array(
'Recipients' => array($phoneNumber),
'MessageText' => $smsText,
'Originator' => $from,
'AffiliateID' => '227830',
);
$this->issueApiCall(
$credentials,
self::SEND_SMS_RESOURCE,
$additionalParameters
);
}
private function issueApiCall($credentials, $resource, $additionalParameters = array())
{
$accountParameters = array(
'UserName' => $credentials['username'],
'Password' => $credentials['password'],
);
$parameters = array_merge($accountParameters, $additionalParameters);
$url = self::BASE_API_URL
. $resource;
$timeout = self::SOCKET_TIMEOUT;
try {
$result = Http::sendHttpRequestBy(
Http::getTransportMethod(),
$url,
$timeout,
$userAgent = null,
$destinationPath = null,
$file = null,
$followDepth = 0,
$acceptLanguage = false,
$acceptInvalidSslCertificate = true,
$byteRange = false,
$getExtendedInfo = false,
$httpMethod = 'POST',
$httpUserName = null,
$httpPassword = null,
$requestBody = json_encode($parameters)
);
} catch (Exception $e) {
throw new APIException($e->getMessage());
}
$result = @json_decode($result, true);
if (!$result || $result['StatusCode'] != 1) {
throw new APIException(
'ASPSMS API returned the following error message : ' . $result['StatusInfo']
);
}
return $result;
}
public function getCreditLeft($credentials)
{
$credits = $this->issueApiCall(
$credentials,
self::CHECK_CREDIT_RESOURCE
);
return Piwik::translate('MobileMessaging_Available_Credits', array($credits['Credits']));
}
}

View File

@ -0,0 +1,130 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\MobileMessaging\SMSProvider;
use Exception;
use Piwik\Http;
use Piwik\Plugins\MobileMessaging\APIException;
use Piwik\Plugins\MobileMessaging\SMSProvider;
require_once PIWIK_INCLUDE_PATH . "/plugins/MobileMessaging/APIException.php";
/**
* @ignore
*/
class Clockwork extends SMSProvider
{
const SOCKET_TIMEOUT = 15;
const BASE_API_URL = 'https://api.mediaburst.co.uk/http';
const CHECK_CREDIT_RESOURCE = '/credit.aspx';
const SEND_SMS_RESOURCE = '/send.aspx';
const ERROR_STRING = 'Error';
const MAXIMUM_FROM_LENGTH = 11;
const MAXIMUM_CONCATENATED_SMS = 3;
public function getId()
{
return 'Clockwork';
}
public function getDescription()
{
return 'You can use <a target="_blank" rel="noreferrer noopener" href="https://www.clockworksms.com/platforms/piwik/"><img src="plugins/MobileMessaging/images/Clockwork.png"/></a> to send SMS Reports from Piwik.<br/>
<ul>
<li> First, <a target="_blank" rel="noreferrer noopener" href="https://www.clockworksms.com/platforms/piwik/">get an API Key from Clockwork</a> (Signup is free!)
</li><li> Enter your Clockwork API Key on this page. </li>
</ul>
<br/>About Clockwork: <ul>
<li>Clockwork gives you fast, reliable high quality worldwide SMS delivery, over 450 networks in every corner of the globe.
</li><li>Cost per SMS message is around ~0.08USD (0.06EUR).
</li><li>Most countries and networks are supported but we suggest you check the latest position on their coverage map <a target="_blank" rel="noreferrer noopener" href="https://www.clockworksms.com/sms-coverage/">here</a>.
</li>
</ul>
';
}
public function verifyCredential($credentials)
{
$this->getCreditLeft($credentials);
return true;
}
public function sendSMS($credentials, $smsText, $phoneNumber, $from)
{
$from = substr($from, 0, self::MAXIMUM_FROM_LENGTH);
$smsText = self::truncate($smsText, self::MAXIMUM_CONCATENATED_SMS);
$additionalParameters = array(
'To' => str_replace('+', '', $phoneNumber),
'Content' => $smsText,
'From' => $from,
'Long' => 1,
'MsgType' => self::containsUCS2Characters($smsText) ? 'UCS2' : 'TEXT',
);
$this->issueApiCall(
$credentials['apiKey'],
self::SEND_SMS_RESOURCE,
$additionalParameters
);
}
private function issueApiCall($apiKey, $resource, $additionalParameters = array())
{
$accountParameters = array(
'Key' => $apiKey,
);
$parameters = array_merge($accountParameters, $additionalParameters);
$url = self::BASE_API_URL
. $resource
. '?' . Http::buildQuery($parameters);
$timeout = self::SOCKET_TIMEOUT;
try {
$result = Http::sendHttpRequestBy(
Http::getTransportMethod(),
$url,
$timeout,
$userAgent = null,
$destinationPath = null,
$file = null,
$followDepth = 0,
$acceptLanguage = false,
$acceptInvalidSslCertificate = true
);
} catch (Exception $e) {
$result = self::ERROR_STRING . " " . $e->getMessage();
}
if (strpos($result, self::ERROR_STRING) !== false) {
throw new APIException(
'Clockwork API returned the following error message : ' . $result
);
}
return $result;
}
public function getCreditLeft($credentials)
{
return $this->issueApiCall(
$credentials['apiKey'],
self::CHECK_CREDIT_RESOURCE
);
}
}

View File

@ -0,0 +1,64 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\MobileMessaging\SMSProvider;
use Piwik\Notification;
use Piwik\Plugins\MobileMessaging\SMSProvider;
use Piwik\Development as PiwikDevelopment;
use Piwik\Session;
/**
* Used for development only
*
* @ignore
*/
class Development extends SMSProvider
{
public function getId()
{
return 'Development';
}
public function getDescription()
{
return 'Development SMS Provider<br />All sent SMS will be displayed as Notification';
}
public function isAvailable()
{
return PiwikDevelopment::isEnabled();
}
public function verifyCredential($credentials)
{
return true;
}
public function getCredentialFields()
{
return array();
}
public function sendSMS($credentials, $smsText, $phoneNumber, $from)
{
Session::start(); // ensure session is writable to add a notification
$message = sprintf('An SMS was sent:<br />From: %s<br />To: %s<br />Message: %s', $from, $phoneNumber, $smsText);
$notification = new Notification($message);
$notification->raw = true;
$notification->context = Notification::CONTEXT_INFO;
Notification\Manager::notify('StubbedSMSProvider'.preg_replace('/[^a-z0-9]/', '', $phoneNumber), $notification);
}
public function getCreditLeft($credentials)
{
return 'Balance: 42';
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\MobileMessaging\SMSProvider;
use Piwik\Plugins\MobileMessaging\SMSProvider;
/**
* Used for testing
*
* @ignore
*/
class StubbedProvider extends SMSProvider
{
public function getId()
{
return 'StubbedProvider';
}
public function getDescription()
{
return 'Only during testing available';
}
public function isAvailable()
{
return defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE;
}
public function verifyCredential($credentials)
{
return true;
}
public function sendSMS($credentials, $smsText, $phoneNumber, $from)
{
// nothing to do
}
public function getCreditLeft($credentials)
{
return 1;
}
}