2018-04-13 10:46:03 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
************************************************************************
|
|
|
|
Copyright [2014] [PagSeguro Internet Ltda.]
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
************************************************************************
|
|
|
|
*/
|
|
|
|
require_once "../PagSeguroLibrary/PagSeguroLibrary.php";
|
Fix several bugs of PHP parser rule for function list
1. Fix the function name gets truncated issue if function starts with reserved words (ie. if, while, for, switch...).
2. Fix abstact function and classes not recognized by parser rule.
3. Fix function detection fails on string containing asterisk issue.
Contributed by @MAPJe71 & @TutoInformatik :
https://community.notepad-plus-plus.org/topic/15124/php-function-list-and-abstract-functions/18?_=1604532045222
Fix #3321, fix #5045, fix #4627, fix #4606, fix #8855, fix #4208, fix #981, fix #2522, fix #1103, fix #4712, fix #3560, fix #5150, fix #4606, close #9102
2020-11-04 22:49:14 +00:00
|
|
|
|
|
|
|
function for123(){
|
|
|
|
alert 'nothing';
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class PageGrille extends PageMotsBleus{
|
|
|
|
abstract function GetTypeGrille() ; // blabla blabla
|
|
|
|
abstract function GetGrilleJSON($p_grilleId); // Retourn JSON
|
|
|
|
|
|
|
|
function CleanStr($pStr){
|
|
|
|
return str_replace ( "\\" , "" , $pStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetJavascriptMajax() {
|
|
|
|
return "ABC";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function stringContainAsterisk_test1(){
|
|
|
|
$target = '/path/to/files/*';
|
|
|
|
}
|
|
|
|
|
|
|
|
function stringContainAsterisk_test2(){
|
|
|
|
$target = '/path/to/files/*.jpg';
|
|
|
|
}
|
|
|
|
|
2018-04-13 10:46:03 +00:00
|
|
|
class NotificationListener
|
|
|
|
{
|
|
|
|
public static function main()
|
|
|
|
{
|
|
|
|
$code = (isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ?
|
|
|
|
trim($_POST['notificationCode']) : null);
|
|
|
|
$type = (isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ?
|
|
|
|
trim($_POST['notificationType']) : null);
|
|
|
|
if ($code && $type) {
|
|
|
|
$notificationType = new PagSeguroNotificationType($type);
|
|
|
|
$strType = $notificationType->getTypeFromValue();
|
|
|
|
switch ($strType) {
|
|
|
|
case 'TRANSACTION':
|
|
|
|
self::transactionNotification($code);
|
|
|
|
break;
|
|
|
|
case 'APPLICATION_AUTHORIZATION':
|
|
|
|
self::authorizationNotification($code);
|
|
|
|
break;
|
|
|
|
case 'PRE_APPROVAL':
|
|
|
|
self::preApprovalNotification($code);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LogPagSeguro::error("Unknown notification type [" . $notificationType->getValue() . "]");
|
|
|
|
}
|
|
|
|
self::printLog($strType);
|
|
|
|
} else {
|
|
|
|
LogPagSeguro::error("Invalid notification parameters.");
|
|
|
|
self::printLog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private static function transactionNotification($notificationCode)
|
|
|
|
{
|
|
|
|
$credentials = PagSeguroConfig::getAccountCredentials();
|
|
|
|
try {
|
|
|
|
$transaction = PagSeguroNotificationService::checkTransaction($credentials, $notificationCode);
|
|
|
|
// Do something with $transaction
|
|
|
|
} catch (PagSeguroServiceException $e) {
|
|
|
|
die($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private static function authorizationNotification($notificationCode)
|
|
|
|
{
|
|
|
|
$credentials = PagSeguroConfig::getApplicationCredentials();
|
|
|
|
try {
|
|
|
|
$authorization = PagSeguroNotificationService::checkAuthorization($credentials, $notificationCode);
|
|
|
|
// Do something with $authorization
|
|
|
|
} catch (PagSeguroServiceException $e) {
|
|
|
|
die($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private static function preApprovalNotification($preApprovalCode)
|
|
|
|
{
|
|
|
|
$credentials = PagSeguroConfig::getAccountCredentials();
|
|
|
|
try {
|
|
|
|
$preApproval = PagSeguroNotificationService::checkPreApproval($credentials, $preApprovalCode);
|
|
|
|
// Do something with $preApproval
|
|
|
|
|
|
|
|
} catch (PagSeguroServiceException $e) {
|
|
|
|
die($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private static function printLog($strType = null)
|
|
|
|
{
|
|
|
|
$count = 4;
|
|
|
|
echo "<h2>Receive notifications</h2>";
|
|
|
|
if ($strType) {
|
|
|
|
echo "<h4>notifcationType: $strType</h4>";
|
|
|
|
}
|
|
|
|
echo "<p>Last <strong>$count</strong> items in <strong>log file:</strong></p><hr>";
|
|
|
|
echo LogPagSeguro::getHtml($count);
|
|
|
|
}
|
|
|
|
}
|
Fix several bugs of PHP parser rule for function list
1. Fix the function name gets truncated issue if function starts with reserved words (ie. if, while, for, switch...).
2. Fix abstact function and classes not recognized by parser rule.
3. Fix function detection fails on string containing asterisk issue.
Contributed by @MAPJe71 & @TutoInformatik :
https://community.notepad-plus-plus.org/topic/15124/php-function-list-and-abstract-functions/18?_=1604532045222
Fix #3321, fix #5045, fix #4627, fix #4606, fix #8855, fix #4208, fix #981, fix #2522, fix #1103, fix #4712, fix #3560, fix #5150, fix #4606, close #9102
2020-11-04 22:49:14 +00:00
|
|
|
|
2018-04-13 10:46:03 +00:00
|
|
|
NotificationListener::main();
|