Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fecd3bf
fix: add MobileDetect via Composer
labmecanicatec Jun 1, 2025
96137ae
refactor: use Composer version of MobileDetect library
labmecanicatec Jun 1, 2025
77d502c
fix: delete unused lib/external/Mobile_Detect.php
labmecanicatec Jun 1, 2025
2196e9f
fix: add bacon-qr-code via Composer
labmecanicatec Jun 1, 2025
fa45989
refactor: use Composer version of bacon/bacon-qr-code library
labmecanicatec Jun 1, 2025
c10a007
fix: delete unused lib/external/phpqrcode
labmecanicatec Jun 1, 2025
1cda2c2
fix: add mibe/feedwriter via Composer
labmecanicatec Jun 1, 2025
dfb65a6
refactor: use Composer version of mibe/feedwriter library
labmecanicatec Jun 1, 2025
5c206b7
fix: delete unused lib/external/Feedwriter
labmecanicatec Jun 1, 2025
4152163
fix: add sabre/vobject via Composer
labmecanicatec Jun 1, 2025
2a7c079
refactor: use Composer version of vobject library
labmecanicatec Jun 1, 2025
9228d39
fix: delete unused lib/external/icalreader
labmecanicatec Jun 1, 2025
3ad5d92
fix: add egulias/email-validator via Composer
labmecanicatec Jun 2, 2025
aff9f34
refactor: use Composer version of Egulias\EmailValidator library
labmecanicatec Jun 2, 2025
57597a5
fix: delete unused lib/external/is_email
labmecanicatec Jun 2, 2025
a548240
fix: add phpmailer/phpmailer via Composer
labmecanicatec Jun 2, 2025
ab39173
refactor: use Composer version of phpmailer/phpmailer library
labmecanicatec Jun 2, 2025
86852e5
fix: delete unused lib/external/PHPMailer
labmecanicatec Jun 2, 2025
56aacc3
chore: remove lib/external/random
labmecanicatec Jun 2, 2025
7332fe9
fix: add claviska/simpleimage via Composer
labmecanicatec Jun 7, 2025
dfd1bad
refactor: use Composer version of claviska/simpleimage library
labmecanicatec Jun 7, 2025
169c3b8
fix: delete unused lib/external/SimpleImage
labmecanicatec Jun 2, 2025
efac813
fix: add mashape/unirest-php via Composer
labmecanicatec Jun 6, 2025
673ad77
refactor: use Composer version of mashape/unirest-php library
labmecanicatec Jun 4, 2025
a38807e
fix: delete unused lib/external/Unirest
labmecanicatec Jun 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 37 additions & 36 deletions Domain/PaymentGateway.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

if (file_exists(ROOT_DIR . 'vendor/autoload.php')) {
require_once ROOT_DIR . 'vendor/autoload.php';
require_once ROOT_DIR . 'vendor/autoload.php';
}
require ROOT_DIR . 'lib/external/Unirest/Unirest.php';


class PaymentGateways
{
Expand Down Expand Up @@ -254,9 +254,9 @@ public function IsEnabled()
public function Settings()
{
return [
new PaymentGatewaySetting(self::CLIENT_ID, $this->ClientId()),
new PaymentGatewaySetting(self::SECRET, $this->Secret()),
new PaymentGatewaySetting(self::ENVIRONMENT, $this->Environment()),
new PaymentGatewaySetting(self::CLIENT_ID, $this->ClientId()),
new PaymentGatewaySetting(self::SECRET, $this->Secret()),
new PaymentGatewaySetting(self::ENVIRONMENT, $this->Environment()),
];
}

Expand Down Expand Up @@ -302,7 +302,7 @@ private function GetBaseUrl()
$baseUrl = "https://api.paypal.com";
$paypalEnvironment = $this->Environment();
if (strtolower($paypalEnvironment) == "sandbox") {
$baseUrl = "https://api.sandbox.paypal.com";
$baseUrl = "https://api-m.sandbox.paypal.com";
}
return $baseUrl;
}
Expand All @@ -325,9 +325,10 @@ public function CreatePayment(CreditCartSession $cart, $returnUrl, $cancelUrl)
$headers = ['Accept' => 'application/json', 'Accept-Language' => 'en_US', 'Content-Type' => 'application/json', "Authorization" => "Bearer $token"];
$purchaseRequest = ['description' => $resources->GetString('CreditPurchase'), 'amount' => ['value' => "{$cart->Total()}", 'currency_code' => $cart->Currency]];
$data = [
'intent' => 'CAPTURE',
'application_context' => ['return_url' => $returnUrl, 'cancel_url' => $cancelUrl],
'purchase_units' => [$purchaseRequest]];
'intent' => 'CAPTURE',
'application_context' => ['return_url' => $returnUrl, 'cancel_url' => $cancelUrl],
'purchase_units' => [$purchaseRequest]
];
$body = Unirest\Request\Body::json($data);
Unirest\Request::verifyPeer(false);
$response = Unirest\Request::post($checkoutUrl, $headers, $body);
Expand Down Expand Up @@ -530,8 +531,8 @@ public function IsEnabled()
public function Settings()
{
return [
new PaymentGatewaySetting(self::PUBLISHABLE_KEY, $this->PublishableKey()),
new PaymentGatewaySetting(self::SECRET_KEY, $this->SecretKey()),
new PaymentGatewaySetting(self::PUBLISHABLE_KEY, $this->PublishableKey()),
new PaymentGatewaySetting(self::SECRET_KEY, $this->SecretKey()),
];
}

Expand Down Expand Up @@ -564,19 +565,19 @@ public function Charge(CreditCartSession $cart, $email, $token, IPaymentTransact
\Stripe\Stripe::setApiKey($this->SecretKey());

$customer = \Stripe\Customer::create([
'email' => $email,
'source' => $token
]);
'email' => $email,
'source' => $token
]);

$currency = new \Booked\Currency($cart->Currency);

$charge = \Stripe\Charge::create([
'customer' => $customer->id,
'amount' => $currency->ToStripe($cart->Total()),
'currency' => strtolower($cart->Currency),
'description' => Resources::GetInstance()->GetString('Credits'),
'expand' => ['balance_transaction']
]);
'customer' => $customer->id,
'amount' => $currency->ToStripe($cart->Total()),
'currency' => strtolower($cart->Currency),
'description' => Resources::GetInstance()->GetString('Credits'),
'expand' => ['balance_transaction']
]);

if (Log::DebugEnabled()) {
Log::Debug('Stripe charge response %s', json_encode($charge));
Expand All @@ -598,7 +599,7 @@ public function Charge(CreditCartSession $cart, $email, $token, IPaymentTransact
json_encode($charge)
);
return $charge->status == 'succeeded';
} catch (\Stripe\Error\Card $ex) {
} catch (\Stripe\Exception\CardException $ex) {
// Declined
$body = $ex->getJsonBody();
$err = $body['error'];
Expand All @@ -610,15 +611,15 @@ public function Charge(CreditCartSession $cart, $email, $token, IPaymentTransact
$err['param'],
$err['message']
);
} catch (\Stripe\Error\RateLimit $ex) {
} catch (\Stripe\Exception\RateLimitException $ex) {
Log::Error('Stripe - too many requests. %s', $ex);
} catch (\Stripe\Error\InvalidRequest $ex) {
} catch (\Stripe\Exception\InvalidRequestException $ex) {
Log::Error('Stripe - invalid request. %s', $ex);
} catch (\Stripe\Error\Authentication $ex) {
} catch (\Stripe\Exception\AuthenticationException $ex) {
Log::Error('Stripe - authentication error. %s', $ex);
} catch (\Stripe\Error\ApiConnection $ex) {
} catch (\Stripe\Exception\ApiConnectionException $ex) {
Log::Error('Stripe - connection failure. %s', $ex);
} catch (\Stripe\Error\Base $ex) {
} catch (\Stripe\Exception\ApiErrorException $ex) {
Log::Error('Stripe - error. %s', $ex);
} catch (Exception $ex) {
Log::Error('Stripe - internal error. %s', $ex);
Expand All @@ -640,10 +641,10 @@ public function Refund(TransactionLogView $log, $amount, IPaymentTransactionLogg

\Stripe\Stripe::setApiKey($this->SecretKey());
$refund = \Stripe\Refund::create([
'charge' => $log->TransactionId,
'amount' => $currency->ToStripe($amount),
'expand' => ['balance_transaction']
]);
'charge' => $log->TransactionId,
'amount' => $currency->ToStripe($amount),
'expand' => ['balance_transaction']
]);

if (Log::DebugEnabled()) {
Log::Debug('Stripe refund response %s', json_encode($refund));
Expand All @@ -663,7 +664,7 @@ public function Refund(TransactionLogView $log, $amount, IPaymentTransactionLogg
);

return $refund->status == 'succeeded';
} catch (\Stripe\Error\Card $ex) {
} catch (\Stripe\Exception\CardException $ex) {
// Declined
$body = $ex->getJsonBody();
$err = $body['error'];
Expand All @@ -675,15 +676,15 @@ public function Refund(TransactionLogView $log, $amount, IPaymentTransactionLogg
$err['param'],
$err['message']
);
} catch (\Stripe\Error\RateLimit $ex) {
} catch (\Stripe\Exception\RateLimitException $ex) {
Log::Error('Stripe refund - too many requests. %s', $ex);
} catch (\Stripe\Error\InvalidRequest $ex) {
} catch (\Stripe\Exception\InvalidRequestException $ex) {
Log::Error('Stripe refund - invalid request. %s', $ex);
} catch (\Stripe\Error\Authentication $ex) {
} catch (\Stripe\Exception\AuthenticationException $ex) {
Log::Error('Stripe refund - authentication error. %s', $ex);
} catch (\Stripe\Error\ApiConnection $ex) {
} catch (\Stripe\Exception\ApiConnectionException $ex) {
Log::Error('Stripe refund - connection failure. %s', $ex);
} catch (\Stripe\Error\Base $ex) {
} catch (\Stripe\Exception\ApiErrorException $ex) {
Log::Error('Stripe - error. %s', $ex);
} catch (Exception $ex) {
Log::Error('Stripe refund - internal error. %s', $ex);
Expand Down
11 changes: 5 additions & 6 deletions Pages/Export/AtomSubscriptionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
require_once(ROOT_DIR . 'lib/Application/Reservation/namespace.php');
require_once(ROOT_DIR . 'Domain/Access/namespace.php');
require_once(ROOT_DIR . 'Pages/Export/CalendarSubscriptionPage.php');
require_once(ROOT_DIR . 'lib/external/FeedWriter/FeedWriter.php');
require_once(ROOT_DIR . 'lib/external/FeedWriter/FeedItem.php');

use \FeedWriter\ATOM;

class AtomSubscriptionPage extends Page implements ICalendarSubscriptionPage
{
Expand Down Expand Up @@ -52,17 +52,16 @@ public function PageLoad()

$config = Configuration::Instance();

$feed = new FeedWriter(ATOM);
$feed = new ATOM();
$title = $config->GetKey(ConfigKeys::APP_TITLE);
$feed->setTitle(Resources::GetInstance()->GetString('AtomFeedTitle', [$title]));
$url = $config->GetScriptUrl();
$feed->setLink($url);

$lastUpdated = Date::Min();
$feed->setChannelElement('author', ['name'=>$title]);
$feed->setChannelElement('author', ['name' => $title]);

foreach ($this->reservations as $reservation) {
/** @var FeedItem $item */
$item = $feed->createNewItem();
$item->setTitle($reservation->Summary);
$item->setLink($reservation->ReservationUrl);
Expand All @@ -80,7 +79,7 @@ public function PageLoad()
}

$feed->setChannelElement('updated', $lastUpdated->Format(DATE_ATOM));
$feed->genarateFeed();
$feed->printFeed();
}

public function SetReservations($reservations)
Expand Down
7 changes: 4 additions & 3 deletions Pages/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
require_once(ROOT_DIR . 'lib/Common/namespace.php');
require_once(ROOT_DIR . 'lib/Server/namespace.php');
require_once(ROOT_DIR . 'lib/Config/namespace.php');
require_once(ROOT_DIR . 'lib/external/MobileDetect/Mobile_Detect.php');

use Detection\MobileDetect;

abstract class Page implements IPage
{
Expand Down Expand Up @@ -131,7 +132,7 @@ protected function __construct($titleKey = '', $pageDepth = 0)
}
$this->smarty->assign('HomeUrl', $logoUrl);

$detect = new Mobile_Detect();
$detect = new MobileDetect();
$this->IsMobile = $detect->isMobile();
$this->IsTablet = $detect->isTablet();
$this->IsDesktop = !$this->IsMobile && !$this->IsTablet;
Expand Down Expand Up @@ -403,7 +404,7 @@ protected function DisplayCsv($templateName, $fileName)
*/
protected function DisplayLocalized($templateName)
{
$languageCode = $this->GetVar('CurrentLanguage');
$languageCode = $this->GetVar('CurrentLanguage');
$localizedPath = ROOT_DIR . 'lang/' . $languageCode;
$defaultPath = ROOT_DIR . 'lang/en_us/';

Expand Down
59 changes: 22 additions & 37 deletions Presenters/Admin/Import/ICalImportPresenter.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

require_once(ROOT_DIR . 'Domain/namespace.php');
require_once(ROOT_DIR . 'lib/external/icalreader/icalreader.php');
require_once(ROOT_DIR . 'Pages/Admin/Import/ICalImportPage.php');

use Sabre\VObject\Reader;

class ICalImportPresenter extends ActionPresenter
{
/**
Expand Down Expand Up @@ -80,57 +81,43 @@ public function Import()
die($error);
}

$icalReader = new ICal();

$contents = $file->Contents();

if (empty($contents)) {
die('Invalid import file');
}

/** @var ICal $ical */
$ical = $icalReader->initLines(explode("\n", trim($file->Contents())));

if ($ical === false) {
die('Invalid import file');
try {
$vcalendar = Reader::read($contents);
} catch (\Exception $e) {
die('Invalid import file: ' . $e->getMessage());
}

$events = $icalReader->events();

$events = $vcalendar->VEVENT;
Log::Debug('Found %s events in ics file', count($events));

foreach ($events as $event) {
try {
if (!array_key_exists('LOCATION', $event)) {
$numberSkipped++;
Log::Debug('Skipping ics import - missing resource');
continue;
}
$location = $event['LOCATION'];

if (empty($location)) {
if (empty($event->LOCATION)) {
$numberSkipped++;
Log::Debug('Skipping ics import - missing resource');
continue;
}

$organizer = '';
if (array_key_exists('ORGANIZER', $event)) {
$organizer = $event['ORGANIZER'];
}
$location = (string)$event->LOCATION;
$organizer = isset($event->ORGANIZER) ? (string)$event->ORGANIZER : '';

$user = $this->GetOrCreateUser($organizer);
$resource = $this->GetOrCreateResource($location);

$startts = date('Y-m-d H:i:s', $icalReader->iCalDateToUnixTimestamp($event['DTSTART']));
$start = Date::Parse($startts, $this->GetTimezone($event, 'DTSTART_array'));
$start = $event->DTSTART->getDateTime(); // \DateTime object
$end = $event->DTEND->getDateTime(); // \DateTime object

$endts = date('Y-m-d H:i:s', $icalReader->iCalDateToUnixTimestamp($event['DTEND']));
$end = Date::Parse($endts, $this->GetTimezone($event, 'DTEND_array'));
$start = Date::Parse($start->format('Y-m-d H:i:s'));
$end = Date::Parse($end->format('Y-m-d H:i:s'));

$title = array_key_exists('SUMMARY', $event) ? htmlspecialchars($event['SUMMARY']) : '';
$description = array_key_exists('DESCRIPTION', $event) ? htmlspecialchars($event['DESCRIPTION']) : '';
;
$title = isset($event->SUMMARY) ? htmlspecialchars((string)$event->SUMMARY) : '';
$description = isset($event->DESCRIPTION) ? htmlspecialchars((string)$event->DESCRIPTION) : '';

$reservation = ReservationSeries::Create(
$user->Id(),
Expand All @@ -141,14 +128,14 @@ public function Import()
new RepeatNone(),
ServiceLocator::GetServer()->GetUserSession()
);

$participantIds = [];

if (array_key_exists('ATTENDEE_array', $event)) {
foreach ($event['ATTENDEE_array'] as $attendee) {
if (is_string($attendee)) {
$participant = $this->GetOrCreateUser($attendee);
$participantIds[] = $participant->Id();
}
if (isset($event->ATTENDEE)) {
foreach ($event->select('ATTENDEE') as $attendee) {
$email = (string)$attendee;
$participant = $this->GetOrCreateUser($email);
$participantIds[] = $participant->Id();
}
}

Expand All @@ -157,7 +144,6 @@ public function Import()
}

Log::Debug('Importing reservation on %s - %s for %s', $start, $end, $location);

$this->reservationRepository->Add($reservation);
$numberImported++;
} catch (Exception $ex) {
Expand All @@ -166,7 +152,6 @@ public function Import()
}

Log::Debug('Done running ics import. Imported %s Skipped %s', $numberImported, $numberSkipped);

$this->page->SetNumberImported($numberImported, $numberSkipped);
}

Expand Down
Loading