-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
86 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Jp\Jpfaq\Utility; | ||
|
||
class IsBot | ||
{ | ||
/** | ||
* Check if browser is a well known bot | ||
* | ||
* @return bool | ||
*/ | ||
public static function isBot(): bool | ||
{ | ||
$userAgent = $_SERVER['HTTP_USER_AGENT']; | ||
$bots = Typo3Utility::getSettings('tx_jpfaq_faq')['bots']; | ||
$bots = explode(',', $bots); | ||
|
||
foreach ($bots as $bot) { | ||
if (stripos($userAgent, htmlspecialchars($bot)) !== false) return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Jp\Jpfaq\Utility; | ||
|
||
use TYPO3\CMS\Core\TypoScript\TypoScriptService; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager; | ||
|
||
/** | ||
* Class: Typo3Utility | ||
* Description: general utilities | ||
* | ||
* 2024 Jacco van der Post <jacco@typo3-webdesign.nl> | ||
*/ | ||
class Typo3Utility | ||
{ | ||
/** | ||
* Get typoscript settings for a plugin | ||
* | ||
* @param string $plugin | ||
* | ||
* @return mixed | ||
*/ | ||
public static function getSettings(string $plugin): mixed | ||
{ | ||
$plugin = htmlspecialchars($plugin); | ||
$configurationManager = GeneralUtility::makeInstance(BackendConfigurationManager::class); | ||
$typoScriptSettings = $configurationManager->getTypoScriptSetup(); | ||
|
||
$typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class); | ||
$typoScriptSettingsWithoutDots = $typoScriptService->convertTypoScriptArrayToPlainArray($typoScriptSettings); | ||
|
||
return $typoScriptSettingsWithoutDots['plugin'][$plugin]['settings']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters